diff --git a/.editorconfig b/.editorconfig index 36f80cf..f87cbf1 100644 --- a/.editorconfig +++ b/.editorconfig @@ -5,8 +5,30 @@ charset = utf-8 end_of_line = lf indent_style = space indent_size = 2 +tab_width = 2 trim_trailing_whitespace = true insert_final_newline = true max_line_length = 1000 +[*.styl] +ij_continuation_indent_size = 4 +ij_stylus_align_closing_brace_with_properties = false +ij_stylus_blank_lines_around_nested_selector = 1 +ij_stylus_blank_lines_between_blocks = 1 +ij_stylus_brace_placement = 0 +ij_stylus_enforce_property_name_value_separator_on_format = false +ij_stylus_enforce_quotes_on_format = false +ij_stylus_hex_color_long_format = true +ij_stylus_hex_color_lower_case = false +ij_stylus_hex_color_short_format = false +ij_stylus_hex_color_upper_case = true +ij_stylus_is_property_name_value_separated_by_colon = false +ij_stylus_keep_blank_lines_in_code = 2 +ij_stylus_keep_indents_on_empty_lines = false +ij_stylus_keep_single_line_blocks = false +ij_stylus_properties_order = font, font-family, font-size, font-weight, font-style, font-variant, font-size-adjust, font-stretch, line-height, position, z-index, top, right, bottom, left, display, visibility, float, clear, overflow, overflow-x, overflow-y, clip, zoom, align-content, align-items, align-self, flex, flex-flow, flex-basis, flex-direction, flex-grow, flex-shrink, flex-wrap, justify-content, order, box-sizing, width, min-width, max-width, height, min-height, max-height, margin, margin-top, margin-right, margin-bottom, margin-left, padding, padding-top, padding-right, padding-bottom, padding-left, table-layout, empty-cells, caption-side, border-spacing, border-collapse, list-style, list-style-position, list-style-type, list-style-image, content, quotes, counter-reset, counter-increment, resize, cursor, user-select, nav-index, nav-up, nav-right, nav-down, nav-left, transition, transition-delay, transition-timing-function, transition-duration, transition-property, transform, transform-origin, animation, animation-name, animation-duration, animation-play-state, animation-timing-function, animation-delay, animation-iteration-count, animation-direction, text-align, text-align-last, vertical-align, white-space, text-decoration, text-emphasis, text-emphasis-color, text-emphasis-style, text-emphasis-position, text-indent, text-justify, letter-spacing, word-spacing, text-outline, text-transform, text-wrap, text-overflow, text-overflow-ellipsis, text-overflow-mode, word-wrap, word-break, tab-size, hyphens, pointer-events, opacity, color, border, border-width, border-style, border-color, border-top, border-top-width, border-top-style, border-top-color, border-right, border-right-width, border-right-style, border-right-color, border-bottom, border-bottom-width, border-bottom-style, border-bottom-color, border-left, border-left-width, border-left-style, border-left-color, border-radius, border-top-left-radius, border-top-right-radius, border-bottom-right-radius, border-bottom-left-radius, border-image, border-image-source, border-image-slice, border-image-width, border-image-outset, border-image-repeat, outline, outline-width, outline-style, outline-color, outline-offset, background, background-color, background-image, background-repeat, background-attachment, background-position, background-position-x, background-position-y, background-clip, background-origin, background-size, box-decoration-break, box-shadow, text-shadow +ij_stylus_space_after_colon = true +ij_stylus_space_before_opening_brace = true +ij_stylus_use_double_quotes = true +ij_stylus_value_alignment = 0 diff --git a/src/common/app/app-page-store.ts b/src/common/app/app-page-store.ts index dfd9768..dd1624c 100644 --- a/src/common/app/app-page-store.ts +++ b/src/common/app/app-page-store.ts @@ -1,112 +1,102 @@ import { defineStore } from 'pinia' import Evt from '@/common/utils/evt.ts' -import Nav from '@/common/router/nav.ts' - -const pageContextCache = new Map() - - -function initCache() { - pageContextCache.clear() -} - -initCache() +import Strings from '@/common/utils/strings.ts' +import Utils from '@/common/utils' +import { SpecialPage } from '@/common/router/constants.ts' export const useAppPageStore = defineStore('AppPage', () => { - const keepAliveInclude = ref([]) - const pages = ref([]) + const pages = Utils.resetAble(reactive([]))/* as Reactive */ - const currentPage = ref('') + const currentPage = Utils.resetAble(reactive({ + insId: '', + title: '', + keepAlive: false, + params: {}, + routeName: '', + menuId: '', + icon: '', + breadcrumb: [], + }))/* as Reactive */ - const ctx = computed(() => { - return pageContextCache.get(currentPage.value)! + const keepAliveInclude = computed(() => { + return pages.filter(it => it.keepAlive).map(it => it.routeName) }) - function open(ctx_: AppTypes.PageContext) { - currentPage.value = ctx_.insId - if (!pageContextCache.has(ctx_.insId)) { - pageContextCache.set(ctx_.insId, ctx_) - } - if (!keepAliveInclude.value.includes(ctx_.insId)) { - keepAliveInclude.value.push(ctx_.insId) - } - if (!pages.value.find(it => it.insId === ctx_.insId)) { - pages.value.push(ctx_) - } + function open(ctx?: AppTypes.PageContext) { + if ( + ctx == null + || Strings.isBlank(ctx.insId) + || currentPage.insId === ctx.insId) return Promise.reject('已在当前页面') + const page = pages.find(it => it.insId === ctx.insId) + if (page == null) pages.push(ctx) + currentPage.$reset(ctx) + return Promise.resolve(ctx) } function reopen(insId: string) { - if (currentPage.value === insId) { - return - } - const page = pageContextCache.get(insId) - if (page) { - currentPage.value = insId - Nav.open(page.routeName) - } + const page = pages.find(it => it.insId === insId) + return open(page) } function closePage(insId: string) { - pageContextCache.delete(insId) - if (keepAliveInclude.value.includes(insId)) { - keepAliveInclude.value = keepAliveInclude.value.splice(keepAliveInclude.value.indexOf(insId), 1) - } - const index = pages.value.findIndex(it => it.insId === insId) - if (index !== -1) { - const oldLen = pages.value.length - pages.value = pages.value.filter(it => it.insId !== insId) - - if (currentPage.value !== insId) { - return - } - if (index === 0) { - if (pages.value.length > 0) { - reopen(pages.value[0]?.insId) - } else { - Nav.open('home') - } - } else if (index === oldLen - 1) { - if (pages.value.length > 0) { - reopen(pages.value[pages.value.length - 1]?.insId) - } else { - Nav.open('home') - } - } else { - if (pages.value.length > 0) { - reopen(pages.value[index]?.insId) - } else { - Nav.open('home') - } - } + const index = pages.findIndex(it => it.insId === insId) + if (index < 1 || pages[index].routeName === SpecialPage.Home) return Promise.reject('不能关闭首页') + pages.splice(index, 1) + if (currentPage.insId !== insId) return Promise.resolve(null) + const newLen = pages.length + const oldLen = newLen + 1 + let page: AppTypes.PageContext | undefined + if (index === 1) { + page = newLen > 1 ? pages[1] : pages[0] + } else if (index === oldLen - 1) { + page = pages[newLen - 1] + } else { + page = pages[index] } + return open(page) } function closeCurrent() { - closePage(currentPage.value) + return closePage(currentPage.insId) + } + + function closeLeft() { + const index = pages.findIndex(it => it.insId === currentPage.insId) + if (index < 2) return + pages.splice(1, index - 1) + } + + function closeRight() { + const index = pages.findIndex(it => it.insId === currentPage.insId) + if (index < 0) return + pages.splice(index + 1, pages.length - index - 1) } function closeOther() { - pages.value = pages.value.filter(it => it.insId === currentPage.value) + const pageList = pages.filter(it => it.routeName === SpecialPage.Home || it.insId === currentPage.insId) + pages.$reset(pageList) } function closeAll() { - pages.value = [] - Nav.open('home') + const page = pages.find(it => it.routeName === SpecialPage.Home)! + pages.$reset([ page ]) + return open(page) } function $reset() { - keepAliveInclude.value = [] - currentPage.value = '' - initCache() + pages.$reset() + currentPage.$reset() } Evt.on('logout', $reset) return { - ctx, reopen, open, closePage, closeCurrent, + closeLeft, + closeRight, closeOther, closeAll, pages, diff --git a/src/common/app/index.ts b/src/common/app/index.ts index 754be9c..9746762 100644 --- a/src/common/app/index.ts +++ b/src/common/app/index.ts @@ -11,7 +11,7 @@ const home = { 'sn': 'menus', 'pid': '0', 'title': '首页', - 'icon': 'menus', + 'icon': 'home-3-line', 'tier': 1, 'breadcrumb': [ '首页', @@ -22,7 +22,8 @@ const home = { 'routeName': 'home', 'path': '/home', } -export const reloadUserInfo = () => { + +export function reloadUserInfo() { const appSettingStore = useAppSettingStore() const appUserStore = useAppUserStore() return LoginApi.my() @@ -49,31 +50,6 @@ export const reloadUserInfo = () => { }) } -/* export const loadUserInfo = () => { - const appSettingStore = useAppSettingStore() - const appUserStore = useAppUserStore() - return LoginApi.my() - .then(({data}) => { - const menuTree = Utils.clone(Colls.toTree(data.menus)) - appSettingStore.$patch({ - menus: data.menus, menuTree, - theme: data.setting?.theme ?? 'light', - collectedMenus: data.setting?.collectedMenus ?? [], - logo: data.setting?.logo, - language: data.setting?.language ?? 'zh', - }) - appUserStore.$patch({ - userId: data.id, - nickname: data.nickname, - avatar: data.avatar, - tenantId: data.tenantId, - tenantName: data.tenantName, - bizObj: data.bizObj, - roles: data.roles, - }) - }) - } */ - export function hasPermission(resSn?: string) { const appSettingStore = useAppSettingStore() const res = appSettingStore.menus.find(it => it.sn === resSn) diff --git a/src/common/router/index.ts b/src/common/router/index.ts index 4d888e6..d9e10ca 100644 --- a/src/common/router/index.ts +++ b/src/common/router/index.ts @@ -15,7 +15,6 @@ import { getRoutes, } from '@/common/router/route-config.ts' import { SpecialPage } from '@/common/router/constants.ts' -import Nav from '@/common/router/nav.ts' function addRoutes(routNames: string[]) { if (Colls.isEmpty(routNames)) return @@ -81,7 +80,7 @@ router.beforeEach((to, from) => { routeName = SpecialPage.Home } setTimeout(() => { - Nav.open(routeName) + Evt.emit('browserReflash', routeName) }) return false } @@ -118,19 +117,4 @@ export function reloadRouter() { return true } -Evt.on('login', (_) => { - Nav.open(SpecialPage.Home) -}) - -Evt.on('logout', (_) => { - const routes = router - .getRoutes() - .filter((it) => it.name !== SpecialPage.Main && it.name !== SpecialPage.Login && it.name !== SpecialPage.NotFound && it.name !== SpecialPage.Home) - .map((it) => it.name as string) - removeRoutes(routes) - router.push({replace: true, name: SpecialPage.Login}).then(() => { - // console.log(r) - }) -}) - export default router diff --git a/src/common/router/nav.ts b/src/common/router/nav.ts index a0cdfba..f2342dc 100644 --- a/src/common/router/nav.ts +++ b/src/common/router/nav.ts @@ -1,10 +1,14 @@ -import router, { reloadRouter } from '@/common/router/index.ts' +import router, { + reloadRouter, + removeRoutes, +} from '@/common/router/index.ts' import Evt from '@/common/utils/evt.ts' import { useAppSettingStore } from '@/common/app/app-setting-store.ts' import { useAppPageStore } from '@/common/app/app-page-store.ts' -import { nanoid } from 'nanoid' import { reloadUserInfo } from '@/common/app' import { ElMessage } from 'element-plus' +import type { App } from 'vue' +import { SpecialPage } from '@/common/router/constants.ts' type Option = Partial> & Pick @@ -13,153 +17,280 @@ type Option = Partial> * * @param option */ -function open(option: string | Option) { - let ctx: AppTypes.PageContext - const appSettingStore = useAppSettingStore() + +/* function open(option: string | Option) { + let ctx: AppTypes.PageContext + const appSettingStore = useAppSettingStore() + if (typeof option === 'string') { + const routeName = option + if (!router.hasRoute(routeName)) { + return reloadUserInfo() + .then(reloadRouter) + .then(() => { + if (!router.hasRoute(routeName)) { + ElMessage.error('页面不存在') + return Promise.reject('页面不存在') + } + const menu = appSettingStore.menus.find(it => it.routeName === routeName) + if (menu == null) { + ElMessage.error('页面不存在') + return Promise.reject('页面不存在') + } + ctx = { + insId: routeName, + title: menu.title, + keepAlive: true, + params: {}, + routeName, + menuId: menu.id, + icon: menu.icon, + breadcrumb: menu.breadcrumb, + } + useAppPageStore().open(ctx) + return router.push({name: ctx.routeName, params: ctx.params}) + .then(err => { + if (err == null) { + Evt.emit('openPage') + return Promise.resolve(true) + } else { + return Promise.reject(err) + } + }) + .catch(err => { + return Promise.reject(err) + }) + }) + } + const menu = appSettingStore.menus.find(it => it.routeName === routeName) + if (menu == null) { + ElMessage.error('页面不存在') + return Promise.reject('页面不存在') + } + ctx = { + insId: routeName , + title: menu.title, + keepAlive: true, + params: {}, + routeName, + menuId: menu.id, + icon: menu.icon, + breadcrumb: menu.breadcrumb, + } + } else { + const routeName = option.routeName + if (!router.hasRoute(routeName)) { + return reloadUserInfo() + .then(reloadRouter) + .then(() => { + if (!router.hasRoute(routeName)) { + ElMessage.error('页面不存在') + return Promise.reject('页面不存在') + } + const menu = appSettingStore.menus.find(it => it.routeName === routeName) + if (menu == null) { + ElMessage.error('页面不存在') + return Promise.reject('页面不存在') + } + const option_ = option as Option + ctx = { + insId: option_.insId ?? routeName, + title: option_.title ?? menu.title, + routeName: routeName, + keepAlive: true, + params: option_.params ?? {}, + menuId: menu.id, + icon: menu.icon, + breadcrumb: menu.breadcrumb, + } + useAppPageStore().open(ctx) + return router.push({name: ctx.routeName, params: ctx.params}) + .then(err => { + if (err == null) { + Evt.emit('openPage') + return Promise.resolve(true) + } else { + return Promise.reject(err) + } + }) + .catch(err => { + return Promise.reject(err) + }) + }) + } + const menu = appSettingStore.menus.find(it => it.routeName === routeName) + if (menu == null) { + ElMessage.error('页面不存在') + return Promise.reject('页面不存在') + } + + ctx = { + insId: option.insId ?? routeName, + title: option.title ?? menu.title, + routeName: routeName, + keepAlive: true, + params: option.params ?? {}, + menuId: menu.id, + icon: menu.icon, + breadcrumb: menu.breadcrumb, + } + } + useAppPageStore().open(ctx) + return router.push({name: ctx.routeName, params: ctx.params}) + .then(err => { + if (err == null) { + Evt.emit('openPage') + return Promise.resolve(true) + } else { + return Promise.reject(err) + } + }) + .catch(err => { + return Promise.reject(err) + }) + } */ + +function checkRoute(option: string | Option) { + let opt: Option if (typeof option === 'string') { - const routeName = option - if (!router.hasRoute(routeName)) { - return reloadUserInfo() - .then(reloadRouter) - .then(() => { - if (!router.hasRoute(routeName)) { - ElMessage.error('页面不存在') - return Promise.reject('页面不存在') - } - const menu = appSettingStore.menus.find(it => it.routeName === routeName) - if (menu == null) { - ElMessage.error('页面不存在') - return Promise.reject('页面不存在') - } - ctx = { - insId: routeName + '_' + nanoid(), - title: menu.title, - keepAlive: true, - params: {}, - routeName, - menuId: menu.id, - icon: menu.icon, - breadcrumb: menu.breadcrumb, - } - ctx.insId = ctx.routeName - useAppPageStore().open(ctx) - return router.push({name: ctx.routeName, params: ctx.params}) - .then(err => { - if (err == null) { - Evt.emit('openPage') - return Promise.resolve(true) - } else { - return Promise.reject(err) - } - }) - .catch(err => { - return Promise.reject(err) - }) - }) - } - const menu = appSettingStore.menus.find(it => it.routeName === routeName) - if (menu == null) { - ElMessage.error('页面不存在') - return Promise.reject('页面不存在') - } - ctx = { - insId: routeName + '_' + nanoid(), - title: menu.title, - keepAlive: true, - params: {}, - routeName, - menuId: menu.id, - icon: menu.icon, - breadcrumb: menu.breadcrumb, + opt = { + routeName: option, } } else { - const routeName = option.routeName - if (!router.hasRoute(routeName)) { - return reloadUserInfo() - .then(reloadRouter) - .then(() => { - if (!router.hasRoute(routeName)) { - ElMessage.error('页面不存在') - return Promise.reject('页面不存在') - } - const menu = appSettingStore.menus.find(it => it.routeName === routeName) - if (menu == null) { - ElMessage.error('页面不存在') - return Promise.reject('页面不存在') - } - const option_ = option as Option - ctx = { - insId: option_.insId ?? routeName + '_' + nanoid(), - title: option_.title ?? menu.title, - routeName: routeName, - keepAlive: true, - params: option_.params ?? {}, - menuId: menu.id, - icon: menu.icon, - breadcrumb: menu.breadcrumb, - } - ctx.insId = ctx.routeName - useAppPageStore().open(ctx) - return router.push({name: ctx.routeName, params: ctx.params}) - .then(err => { - if (err == null) { - Evt.emit('openPage') - return Promise.resolve(true) - } else { - return Promise.reject(err) - } - }) - .catch(err => { - return Promise.reject(err) - }) - }) - } - const menu = appSettingStore.menus.find(it => it.routeName === routeName) - if (menu == null) { - ElMessage.error('页面不存在') - return Promise.reject('页面不存在') - } - - ctx = { - insId: option.insId ?? routeName + '_' + nanoid(), - title: option.title ?? menu.title, - routeName: routeName, - keepAlive: true, - params: option.params ?? {}, - menuId: menu.id, - icon: menu.icon, - breadcrumb: menu.breadcrumb, - } + opt = option } - ctx.insId = ctx.routeName - useAppPageStore().open(ctx) + const appSettingStore = useAppSettingStore() + const menu = appSettingStore.menus.find(it => it.routeName === opt.routeName) + + if (menu == null + || !router.hasRoute(opt.routeName)) { + return reloadUserInfo() + .then(reloadRouter) + .then(() => { + const menu_ = appSettingStore.menus.find(it => it.routeName === opt.routeName) + if (menu_ == null || !router.hasRoute(opt.routeName)) { + ElMessage.error('页面不存在') + return Promise.reject('页面不存在') + } else { + return {option: opt, menu: menu_} + } + }) + } + return Promise.resolve({option: opt, menu}) +} + +function jump(ctx: AppTypes.PageContext) { return router.push({name: ctx.routeName, params: ctx.params}) .then(err => { if (err == null) { - Evt.emit('openPage') - return Promise.resolve(true) - } else { - return Promise.reject(err) + return Promise.resolve(ctx) } - }) - .catch(err => { return Promise.reject(err) }) } +function open(option: string | Option) { + return checkRoute(option) + .then(({option, menu}) => { + return jump({ + insId: option.insId ?? option.routeName, + title: option.title ?? menu.title, + keepAlive: true, + params: option.params ?? {}, + routeName: option.routeName, + menuId: menu.id, + icon: menu.icon, + breadcrumb: menu.breadcrumb, + }) + }) + .then(useAppPageStore().open) +} + /** * 关闭页面并删除标签 * * @param id */ function close(id: string) { - useAppPageStore().close(id) - Evt.emit('closePage', id) + useAppPageStore() + .closePage(id) + .then(ctx => { + if (ctx == null) return Promise.resolve(null) + return jump(ctx) + }) } +function closeCurrent() { + return useAppPageStore().closeCurrent() + .then(ctx => { + if (ctx == null) return Promise.resolve(null) + return jump(ctx) + }) +} + +function closeLeft() { + useAppPageStore().closeLeft() +} + +function closeRight() { + useAppPageStore().closeRight() +} + +function closeOther() { + useAppPageStore().closeOther() +} + +function closeAll() { + return useAppPageStore().closeAll() + .then(jump) +} + +const install = (_: App): void => { + Evt.on('login', (_) => { + open(SpecialPage.Home) + }) + + Evt.on('browserReflash', (routeName: string) => { + if (routeName === SpecialPage.Home) { + open(routeName) + return + } + checkRoute(SpecialPage.Home) + .then(({option, menu}) => { + useAppPageStore().open({ + insId: option.insId ?? option.routeName, + title: option.title ?? menu.title, + keepAlive: true, + params: option.params ?? {}, + routeName: option.routeName, + menuId: menu.id, + icon: menu.icon, + breadcrumb: menu.breadcrumb, + }) + open(routeName) + }) + }) + + Evt.on('logout', (_) => { + const routes = router + .getRoutes() + .filter((it) => it.name !== SpecialPage.Main && it.name !== SpecialPage.Login && it.name !== SpecialPage.NotFound && it.name !== SpecialPage.Home) + .map((it) => it.name as string) + removeRoutes(routes) + router.push({replace: true, name: SpecialPage.Login}).then(() => { + // console.log(r) + }) + }) + +} export default { open, close, + closeCurrent, + closeLeft, + closeRight, + closeOther, + closeAll, + install, } diff --git a/src/common/utils/evt.ts b/src/common/utils/evt.ts index 619b12d..5a8f012 100644 --- a/src/common/utils/evt.ts +++ b/src/common/utils/evt.ts @@ -3,6 +3,7 @@ import mitt, { type EventType } from 'mitt' export interface EventList extends Record { login?: string logout?: string + browserReflash: string connect_ws?: string disconnect_ws?: string openPage?: string diff --git a/src/components/a-icon/iconfont.css b/src/components/a-icon/iconfont.css index 3842f38..c9fdde8 100644 --- a/src/components/a-icon/iconfont.css +++ b/src/components/a-icon/iconfont.css @@ -1,8 +1,8 @@ @font-face { font-family: "iconfont"; /* 项目名称 再昇云 */ - src: url('@/components/a-icon/iconfont.woff2?t=1768370216119') format('woff2'), - url('@/components/a-icon/iconfont.woff?t=1768370216119') format('woff'), - url('@/components/a-icon/iconfont.ttf?t=1768370216119') format('truetype'); + src: url('@/components/a-icon/iconfont.woff2?t=1768642091253') format('woff2'), + url('@/components/a-icon/iconfont.woff?t=1768642091253') format('woff'), + url('@/components/a-icon/iconfont.ttf?t=1768642091253') format('truetype'); } .iconfont { @@ -13,6 +13,10 @@ -moz-osx-font-smoothing: grayscale; } +.icon-home-3-line:before { + content: "\e6b3"; +} + .icon-bell:before { content: "\e7c4"; } diff --git a/src/components/a-icon/iconfont.json b/src/components/a-icon/iconfont.json index af2ce5f..f6472f0 100644 --- a/src/components/a-icon/iconfont.json +++ b/src/components/a-icon/iconfont.json @@ -5,6 +5,13 @@ "css_prefix_text": "icon-", "description": "", "glyphs": [ + { + "icon_id": "17102563", + "name": "home-3-line", + "font_class": "home-3-line", + "unicode": "e6b3", + "unicode_decimal": 59059 + }, { "icon_id": "4766680", "name": "bell", diff --git a/src/components/a-icon/iconfont.ts b/src/components/a-icon/iconfont.ts index 4b1f051..7d58035 100644 --- a/src/components/a-icon/iconfont.ts +++ b/src/components/a-icon/iconfont.ts @@ -5,6 +5,13 @@ export const icons = { 'css_prefix_text': 'icon-', 'description': '', 'glyphs': [ + { + 'icon_id': '17102563', + 'name': 'home-3-line', + 'font_class': 'home-3-line', + 'unicode': 'e6b3', + 'unicode_decimal': 59059, + }, { 'icon_id': '4766680', 'name': 'bell', diff --git a/src/components/a-icon/iconfont.ttf b/src/components/a-icon/iconfont.ttf index 84c127b..7e9b710 100644 Binary files a/src/components/a-icon/iconfont.ttf and b/src/components/a-icon/iconfont.ttf differ diff --git a/src/components/a-icon/iconfont.woff b/src/components/a-icon/iconfont.woff index a3a6fb4..5e24df3 100644 Binary files a/src/components/a-icon/iconfont.woff and b/src/components/a-icon/iconfont.woff differ diff --git a/src/components/a-icon/iconfont.woff2 b/src/components/a-icon/iconfont.woff2 index 36ad335..992c7fe 100644 Binary files a/src/components/a-icon/iconfont.woff2 and b/src/components/a-icon/iconfont.woff2 differ diff --git a/src/components/page/FormPage.vue b/src/components/page/FormPage.vue index a8d57ba..984ffae 100644 --- a/src/components/page/FormPage.vue +++ b/src/components/page/FormPage.vue @@ -225,10 +225,11 @@ onMounted(doSearch) - { - const router = useRouter() const appSettingStore = useAppSettingStore() - const defaultActive = ref('') + const menuIns = useTemplateRef('menu') - onMounted(() => { - const currentRouteName = router.currentRoute.value.name - defaultActive.value = appSettingStore.menus.find(it => it.routeName === currentRouteName)?.id - }) + const appPageStore = useAppPageStore() + + watch( + () => appPageStore.currentPage.menuId, + () => { + menuIns.value?.updateActiveIndex(appPageStore.currentPage.menuId) + }) const menuTree = computed(() => { return Colls.toTree(appSettingStore.menus.filter((it) => it.menuCategory === MenuCategory.Page || it.menuCategory === MenuCategory.Group || it.menuCategory === MenuCategory.Catalog).sort((a, b) => (a.sort ?? 0) - (b.sort ?? 0))) @@ -59,10 +62,7 @@ export default defineComponent( const onMenuClick = (menuItem: MenuItemRegistered) => { const menu = appSettingStore.menus.find(it => it.id === menuItem.index) - Nav.open({ - insId: menu?.routeName ?? '', - routeName: menu?.routeName ?? '', - }) + Nav.open(menu?.routeName ?? '') } const renderMenu = (it: Menu) => { let renderChildNode: (() => VNode[] | undefined) | undefined = undefined @@ -116,12 +116,13 @@ export default defineComponent( return () => ( <> -
+
Nav.open('home')}>
再昇云
- + {{ default: () => menuTree.value.map(renderMenu), }} diff --git a/src/pages/a-frame/ATabbar.vue b/src/pages/a-frame/ATabbar.vue index 40d688a..a7fef0b 100644 --- a/src/pages/a-frame/ATabbar.vue +++ b/src/pages/a-frame/ATabbar.vue @@ -8,14 +8,15 @@
+ @click="Nav.open(item.routeName)">
{{ item.title }}
- +
+
@@ -23,9 +24,10 @@ @@ -37,15 +39,17 @@ import { elIcons } from '@/common/element/element.ts' import type { IconName } from '@/components/a-icon/iconfont.ts' import AIcon from '@/components/a-icon/AIcon.vue' import type { ScrollbarInstance } from 'element-plus' +import Nav from '@/common/router/nav.ts' +import { SpecialPage } from '@/common/router/constants.ts' const appPageStore = useAppPageStore() const tabsScrollbarIns = useTemplateRef('tabsScrollbar') watch( - () => appPageStore.currentPage, + () => appPageStore.currentPage.insId, () => { nextTick(() => { - const tabItem = document.getElementById(appPageStore.currentPage) + const tabItem = document.getElementById(appPageStore.currentPage.insId) if (tabItem != null) tabsScrollbarIns.value?.setScrollLeft(tabItem.offsetLeft) }) }) @@ -55,7 +59,7 @@ function reopen(insId: string) { } function handleCommand(command: 'closeCurrent' | 'closeOther' | 'closeAll') { - appPageStore[command]() + Nav[command]() }