From 1b0f9368fd66f0fff34609a8207a3343348b6dcf Mon Sep 17 00:00:00 2001 From: lzq <2495532633@qq.com> Date: Fri, 16 Jan 2026 17:31:34 +0800 Subject: [PATCH] =?UTF-8?q?=E6=A0=B7=E5=BC=8F=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- index.html | 1 + src/assets/stylus/index.styl | 7 +- src/common/app/app-page-store.ts | 67 +++++++- src/common/app/app.d.ts | 2 + src/common/app/index.ts | 67 +++++--- src/common/router/index.ts | 17 +- src/common/router/nav.ts | 8 + src/components/page/FormPage.vue | 63 +++++--- src/components/page/Page.vue | 3 +- src/dts/components.d.ts | 8 +- src/pages/a-frame/AAside.tsx | 38 ++--- src/pages/a-frame/AFrame.vue | 228 +++++++++++++++++--------- src/pages/a-frame/ATabbar.vue | 150 +++++++++++++++++ src/pages/a-frame/aaside.module.styl | 54 ++++++- src/pages/home/Home.vue | 7 + src/pages/login/Login.vue | 4 +- src/pages/sys/menus/Menus.vue | 233 ++++++++++----------------- 17 files changed, 651 insertions(+), 306 deletions(-) create mode 100644 src/pages/a-frame/ATabbar.vue diff --git a/index.html b/index.html index 65997a9..329d3c9 100644 --- a/index.html +++ b/index.html @@ -18,6 +18,7 @@ padding: 0; border: 0; font-size: var(--el-font-size-medium); + font-family: ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"; } html, diff --git a/src/assets/stylus/index.styl b/src/assets/stylus/index.styl index b15a207..a7bb178 100644 --- a/src/assets/stylus/index.styl +++ b/src/assets/stylus/index.styl @@ -1,7 +1,7 @@ // 优化 Element Plus 组件库默认样式 :root { - --custom-radius: 5px; + --custom-radius: 9px; // 系统主色 --main-color: #1C6EFF; --el-color-white: white !important; @@ -11,6 +11,11 @@ --el-button-hover-border-color: #458FFF !important; --el-color-primary-light-3: #458FFF !important; --el-color-danger: #CF171D !important; + --el-menu-text-color: #29343D !important; + --el-menu-hover-text-color: #29343D !important; + --el-menu-bg-color: #FFFFFF !important; + --el-menu-hover-bg-color: rgb(204, 204, 204) !important; + --el-menu-level: 0; // 输入框边框颜色 // --el-border-color: #E4E4E7 !important; // DCDFE6 // 按钮粗度 diff --git a/src/common/app/app-page-store.ts b/src/common/app/app-page-store.ts index a0a97b4..dfd9768 100644 --- a/src/common/app/app-page-store.ts +++ b/src/common/app/app-page-store.ts @@ -1,5 +1,6 @@ import { defineStore } from 'pinia' import Evt from '@/common/utils/evt.ts' +import Nav from '@/common/router/nav.ts' const pageContextCache = new Map() @@ -12,6 +13,7 @@ initCache() export const useAppPageStore = defineStore('AppPage', () => { const keepAliveInclude = ref([]) + const pages = ref([]) const currentPage = ref('') @@ -27,13 +29,68 @@ export const useAppPageStore = defineStore('AppPage', () => { 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 close(insId: string) { + function reopen(insId: string) { + if (currentPage.value === insId) { + return + } + const page = pageContextCache.get(insId) + if (page) { + currentPage.value = insId + Nav.open(page.routeName) + } + } + + 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') + } + } + } + } + + function closeCurrent() { + closePage(currentPage.value) + } + + function closeOther() { + pages.value = pages.value.filter(it => it.insId === currentPage.value) + } + + function closeAll() { + pages.value = [] + Nav.open('home') } function $reset() { @@ -46,8 +103,14 @@ export const useAppPageStore = defineStore('AppPage', () => { return { ctx, + reopen, open, - close, + closePage, + closeCurrent, + closeOther, + closeAll, + pages, + currentPage, keepAliveInclude, $reset, } diff --git a/src/common/app/app.d.ts b/src/common/app/app.d.ts index b5c1b76..7f8a826 100644 --- a/src/common/app/app.d.ts +++ b/src/common/app/app.d.ts @@ -11,6 +11,8 @@ declare global { params: Record routeName: string menuId: string + icon: string + breadcrumb: string[] } // 菜单 diff --git a/src/common/app/index.ts b/src/common/app/index.ts index bbbf88b..754be9c 100644 --- a/src/common/app/index.ts +++ b/src/common/app/index.ts @@ -4,13 +4,32 @@ import { useAppSettingStore } from '@/common/app/app-setting-store.ts' import { useAppUserStore } from '@/common/app/app-user-store.ts' import Utils from '@/common/utils' import type { R } from '@/common/utils/http-util.ts' +import { MenuCategory } from '@/common/app/constants.ts' +const home = { + 'id': '-1', + 'sn': 'menus', + 'pid': '0', + 'title': '首页', + 'icon': 'menus', + 'tier': 1, + 'breadcrumb': [ + '首页', + ], + 'menuCategory': MenuCategory.Page, + 'freeze': null, + 'sort': 0, + 'routeName': 'home', + 'path': '/home', +} export const reloadUserInfo = () => { const appSettingStore = useAppSettingStore() const appUserStore = useAppUserStore() return LoginApi.my() .then(({data}) => { const menuTree = Utils.clone(Colls.toTree(data.menus)) + data.menus.unshift(home) + menuTree.unshift(home) appSettingStore.$patch({ menus: data.menus, menuTree, theme: data.setting?.theme ?? 'light', @@ -30,30 +49,30 @@ 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 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() diff --git a/src/common/router/index.ts b/src/common/router/index.ts index 44b38a0..bdb0a09 100644 --- a/src/common/router/index.ts +++ b/src/common/router/index.ts @@ -9,11 +9,13 @@ import { useAppUserStore } from '@/common/app/app-user-store.ts' import { MenuCategory } from '@/common/app/constants.ts' import { appBaseUrl } from '@/common' import strings from '@/common/utils/strings.ts' +import Strings from '@/common/utils/strings.ts' import { getRoute, 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 @@ -74,10 +76,17 @@ router.beforeEach((to, from) => { name: SpecialPage.Home, } } else { - return { - replace: true, - path: to.fullPath, + let routeName = router.getRoutes().find((it) => it.path === to.path)?.name as string + console.log('reloadRouter11', routeName, Strings.isBlank(routeName)) + if (Strings.isBlank(routeName)) { + routeName = SpecialPage.Home + ElMessage.error('页面不存在222') } + console.log('reloadRouter', to, router.getRoutes(), routeName) + setTimeout(() => { + Nav.open(routeName) + }) + return false } } return true @@ -113,7 +122,7 @@ export function reloadRouter() { } Evt.on('login', (_) => { - router.replace('/') + Nav.open(SpecialPage.Home) }) Evt.on('logout', (_) => { diff --git a/src/common/router/nav.ts b/src/common/router/nav.ts index 295cd51..a0cdfba 100644 --- a/src/common/router/nav.ts +++ b/src/common/router/nav.ts @@ -38,6 +38,8 @@ function open(option: string | Option) { params: {}, routeName, menuId: menu.id, + icon: menu.icon, + breadcrumb: menu.breadcrumb, } ctx.insId = ctx.routeName useAppPageStore().open(ctx) @@ -67,6 +69,8 @@ function open(option: string | Option) { params: {}, routeName, menuId: menu.id, + icon: menu.icon, + breadcrumb: menu.breadcrumb, } } else { const routeName = option.routeName @@ -91,6 +95,8 @@ function open(option: string | Option) { keepAlive: true, params: option_.params ?? {}, menuId: menu.id, + icon: menu.icon, + breadcrumb: menu.breadcrumb, } ctx.insId = ctx.routeName useAppPageStore().open(ctx) @@ -121,6 +127,8 @@ function open(option: string | Option) { keepAlive: true, params: option.params ?? {}, menuId: menu.id, + icon: menu.icon, + breadcrumb: menu.breadcrumb, } } ctx.insId = ctx.routeName diff --git a/src/components/page/FormPage.vue b/src/components/page/FormPage.vue index 20c6acd..fbd473d 100644 --- a/src/components/page/FormPage.vue +++ b/src/components/page/FormPage.vue @@ -1,4 +1,4 @@ - @@ -156,7 +177,6 @@ onMounted(doSearch) - 搜索 重置 @@ -165,7 +185,7 @@ onMounted(doSearch)
-
+