diff --git a/mock/system/router.js b/mock/system/router.js index 089344f..feafafa 100644 --- a/mock/system/router.js +++ b/mock/system/router.js @@ -21,7 +21,7 @@ const asyncRoutes = [ component: 'views/system/user/index', name: 'SystemUser', meta: { - title: '菜单管理' + title: '用户管理' } }, { diff --git a/src/layout/components/Tags/index.vue b/src/layout/components/Tags/index.vue index ccb2bf8..6b4e9c3 100644 --- a/src/layout/components/Tags/index.vue +++ b/src/layout/components/Tags/index.vue @@ -18,7 +18,7 @@
@@ -42,15 +42,18 @@ import { CloseOutlined } from '@vicons/antd' import Draggable from 'vuedraggable' -import { reactive, computed, toRaw } from 'vue' +import { reactive, computed, watch } from 'vue' import { useRoute, useRouter } from 'vue-router' import { useTagsMenuStore } from '@/store/modules/tagsMenu.js' import { useSettingStore } from '@/store/modules/setting.js' import { getTags, setTags } from '@/utils/tags.js' +import { isString } from '@/utils/is.js' /* 获取路由器 */ const route = useRoute() const router = useRouter() +const { push, replace } = router + const tagsMenuStore = useTagsMenuStore() const settingStore = useSettingStore() const tabsList = computed(() => tagsMenuStore.tabsList) @@ -82,6 +85,18 @@ const state = reactive({ scrollable: false }) +watch( + () => route.fullPath, + (to) => { + console.log('to', to) + // if (whiteList.includes(route.name)) return + state.activeKey = to + tagsMenuStore.addTabs(getSimpleRoute(route)) + // updateNavScroll(true) + }, + { immediate: true } +) + /** * @description: * @param { Object } route @@ -119,10 +134,10 @@ function scrollNext() { * @return {*} */ function goPage(e) { -// const { fullPath } = e -// if (fullPath === route.fullPath) return -// state.activeKey = fullPath -// go(e, true) + const { fullPath } = e + if (fullPath === route.fullPath) return + state.activeKey = fullPath + go(e, true) } /** * @description: 删除项 @@ -149,6 +164,18 @@ function handleContextMenu(e, item) { // }) } +function go(opt, isReplace = false) { + if (!opt) { + return + } + if (isString(opt)) { + isReplace ? replace(opt).catch(e => console.log(e)) : push(opt).catch(e => console.log(e)) + } else { + const o = opt + isReplace ? replace(o).catch(e => console.log(e)) : push(o).catch(e => console.log(e)) + } +} + diff --git a/src/layout/index.vue b/src/layout/index.vue index 0c47da6..22d24a4 100644 --- a/src/layout/index.vue +++ b/src/layout/index.vue @@ -17,7 +17,7 @@
- + @@ -39,5 +39,7 @@ const tagsMenuSetting = computed(() => settingStore.getTagsMenuSetting)