mirror of
https://github.com/Kuingsmile/PicList.git
synced 2026-05-06 20:42:57 +08:00
🐛 Fix(custom): remove usage of router-link
This commit is contained in:
@@ -22,18 +22,19 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="nav-menu">
|
<div class="nav-menu">
|
||||||
<router-link
|
<div
|
||||||
v-for="item in navigationItems.slice(0, 3)"
|
v-for="item in navigationItems.slice(0, 3)"
|
||||||
:key="item.path"
|
:key="item.path"
|
||||||
:to="item.path"
|
|
||||||
class="nav-item"
|
class="nav-item"
|
||||||
|
:class="{ 'router-link-active': isPathActive(item.path) }"
|
||||||
:title="`${item.name}`"
|
:title="`${item.name}`"
|
||||||
|
@click="navigateToPath(item.path)"
|
||||||
>
|
>
|
||||||
<div class="nav-icon-container">
|
<div class="nav-icon-container">
|
||||||
<component :is="item.icon" :size="18" />
|
<component :is="item.icon" :size="18" />
|
||||||
</div>
|
</div>
|
||||||
<span v-if="!isCollapsed" class="nav-label">{{ item.name }}</span>
|
<span v-if="!isCollapsed" class="nav-label">{{ item.name }}</span>
|
||||||
</router-link>
|
</div>
|
||||||
|
|
||||||
<Disclosure v-if="!isCollapsed" v-slot="{ open }" as="div" class="nav-submenu">
|
<Disclosure v-if="!isCollapsed" v-slot="{ open }" as="div" class="nav-submenu">
|
||||||
<DisclosureButton class="nav-item submenu-trigger">
|
<DisclosureButton class="nav-item submenu-trigger">
|
||||||
@@ -44,14 +45,14 @@
|
|||||||
<ChevronDownIcon :size="16" class="submenu-arrow" :class="{ 'rotate-180': open }" />
|
<ChevronDownIcon :size="16" class="submenu-arrow" :class="{ 'rotate-180': open }" />
|
||||||
</DisclosureButton>
|
</DisclosureButton>
|
||||||
<DisclosurePanel class="submenu-panel">
|
<DisclosurePanel class="submenu-panel">
|
||||||
<router-link
|
<div
|
||||||
v-for="item in visiblePicBeds"
|
v-for="item in visiblePicBeds"
|
||||||
:key="item.type"
|
:key="item.type"
|
||||||
:to="{ name: routerConfig.UPLOADER_CONFIG_PAGE, params: { type: item.type } }"
|
|
||||||
class="submenu-item"
|
class="submenu-item"
|
||||||
|
@click="navigateToUploaderConfig(item.type)"
|
||||||
>
|
>
|
||||||
<span>{{ item.name }}</span>
|
<span>{{ item.name }}</span>
|
||||||
</router-link>
|
</div>
|
||||||
</DisclosurePanel>
|
</DisclosurePanel>
|
||||||
</Disclosure>
|
</Disclosure>
|
||||||
<div v-else class="nav-item collapsed-picbed" :title="t('navigation.picbed')" @click="isCollapsed = !isCollapsed">
|
<div v-else class="nav-item collapsed-picbed" :title="t('navigation.picbed')" @click="isCollapsed = !isCollapsed">
|
||||||
@@ -60,18 +61,19 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<router-link
|
<div
|
||||||
v-for="item in navigationItems.slice(3)"
|
v-for="item in navigationItems.slice(3)"
|
||||||
:key="item.path"
|
:key="item.path"
|
||||||
:to="item.path"
|
|
||||||
class="nav-item"
|
class="nav-item"
|
||||||
|
:class="{ 'router-link-active': isPathActive(item.path) }"
|
||||||
:title="`${item.name}`"
|
:title="`${item.name}`"
|
||||||
|
@click="navigateToPath(item.path)"
|
||||||
>
|
>
|
||||||
<div class="nav-icon-container">
|
<div class="nav-icon-container">
|
||||||
<component :is="item.icon" :size="18" />
|
<component :is="item.icon" :size="18" />
|
||||||
</div>
|
</div>
|
||||||
<span v-if="!isCollapsed" class="nav-label">{{ item.name }}</span>
|
<span v-if="!isCollapsed" class="nav-label">{{ item.name }}</span>
|
||||||
</router-link>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="sidebar-footer">
|
<div class="sidebar-footer">
|
||||||
<button class="footer-button" :title="t('navigation.moreOptions')" @click="openMenu">
|
<button class="footer-button" :title="t('navigation.moreOptions')" @click="openMenu">
|
||||||
@@ -190,6 +192,7 @@ import QrcodeVue from 'qrcode.vue'
|
|||||||
import pkg from 'root/package.json'
|
import pkg from 'root/package.json'
|
||||||
import { computed, nextTick, onBeforeMount, onBeforeUnmount, reactive, Ref, ref, watch } from 'vue'
|
import { computed, nextTick, onBeforeMount, onBeforeUnmount, reactive, Ref, ref, watch } from 'vue'
|
||||||
import { useI18n } from 'vue-i18n'
|
import { useI18n } from 'vue-i18n'
|
||||||
|
import { useRoute, useRouter } from 'vue-router'
|
||||||
|
|
||||||
import useMessage from '@/hooks/useMessage'
|
import useMessage from '@/hooks/useMessage'
|
||||||
import * as config from '@/router/config'
|
import * as config from '@/router/config'
|
||||||
@@ -203,6 +206,8 @@ const version = ref(pkg.version)
|
|||||||
const isCollapsed = ref(false)
|
const isCollapsed = ref(false)
|
||||||
|
|
||||||
const { t } = useI18n()
|
const { t } = useI18n()
|
||||||
|
const route = useRoute()
|
||||||
|
const router = useRouter()
|
||||||
const message = useMessage()
|
const message = useMessage()
|
||||||
const routerConfig = reactive(config)
|
const routerConfig = reactive(config)
|
||||||
const qrcodeVisible = ref(false)
|
const qrcodeVisible = ref(false)
|
||||||
@@ -245,6 +250,18 @@ function handleCopyPicBedConfig() {
|
|||||||
message.success(t('navigation.copySuccess'))
|
message.success(t('navigation.copySuccess'))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function navigateToPath(path: string) {
|
||||||
|
router.push(path)
|
||||||
|
}
|
||||||
|
|
||||||
|
function navigateToUploaderConfig(type: string) {
|
||||||
|
router.push({ name: routerConfig.UPLOADER_CONFIG_PAGE, params: { type } })
|
||||||
|
}
|
||||||
|
|
||||||
|
function isPathActive(path: string): boolean {
|
||||||
|
return route.path === path
|
||||||
|
}
|
||||||
|
|
||||||
const navigationItems = computed(() => [
|
const navigationItems = computed(() => [
|
||||||
{ name: t('navigation.upload'), path: '/main-page/upload', icon: UploadIcon },
|
{ name: t('navigation.upload'), path: '/main-page/upload', icon: UploadIcon },
|
||||||
{ name: t('navigation.manage'), path: '/main-page/manage-login-page', icon: BriefcaseBusiness },
|
{ name: t('navigation.manage'), path: '/main-page/manage-login-page', icon: BriefcaseBusiness },
|
||||||
@@ -406,6 +423,7 @@ onBeforeUnmount(() => {
|
|||||||
font-size: 0.875rem;
|
font-size: 0.875rem;
|
||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
transition: all 0.2s ease;
|
transition: all 0.2s ease;
|
||||||
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
.navigation.collapsed .nav-item {
|
.navigation.collapsed .nav-item {
|
||||||
@@ -555,6 +573,7 @@ onBeforeUnmount(() => {
|
|||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
border-radius: 6px;
|
border-radius: 6px;
|
||||||
transition: all 0.2s ease;
|
transition: all 0.2s ease;
|
||||||
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
.submenu-item:hover {
|
.submenu-item:hover {
|
||||||
|
|||||||
Reference in New Issue
Block a user