From 5c03ae9605c31301eb4f820409164aee45b00248 Mon Sep 17 00:00:00 2001 From: xingyu Date: Sun, 17 Nov 2024 01:28:19 +0800 Subject: [PATCH] chore: basic router --- .vscode/settings.json | 2 +- apps/web-antd/src/layouts/basic.vue | 27 ++++++++----- apps/web-antd/src/router/access.ts | 40 +++++++++++++++++-- apps/web-antd/src/views/_core/about/index.vue | 6 ++- .../src/views/_core/profile/profile.vue | 10 +++++ 5 files changed, 71 insertions(+), 14 deletions(-) create mode 100644 apps/web-antd/src/views/_core/profile/profile.vue diff --git a/.vscode/settings.json b/.vscode/settings.json index 5b6a6cc75..855efedd8 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -224,5 +224,5 @@ "vue.server.hybridMode": true, "typescript.tsdk": "node_modules/typescript/lib", "oxc.enable": false, - "cSpell.words": ["Yudao", "xingyu", "xingyuv"] + "cSpell.words": ["Gitee", "xingyu", "xingyuv", "Yudao"] } diff --git a/apps/web-antd/src/layouts/basic.vue b/apps/web-antd/src/layouts/basic.vue index 51412956a..5c23354f1 100644 --- a/apps/web-antd/src/layouts/basic.vue +++ b/apps/web-antd/src/layouts/basic.vue @@ -2,11 +2,12 @@ import type { NotificationItem } from '@vben/layouts'; import { computed, ref, watch } from 'vue'; +import { useRouter } from 'vue-router'; import { AuthenticationLoginExpiredModal } from '@vben/common-ui'; -import { VBEN_DOC_URL, VBEN_GITHUB_URL } from '@vben/constants'; +import { VBEN_DOC_URL } from '@vben/constants'; import { useWatermark } from '@vben/hooks'; -import { BookOpenText, CircleHelp, MdiGithub } from '@vben/icons'; +import { BookOpenText, CircleHelp, Info, MdiGithub } from '@vben/icons'; import { BasicLayout, LockScreen, @@ -21,6 +22,8 @@ import { $t } from '#/locales'; import { useAuthStore } from '#/store'; import LoginForm from '#/views/_core/authentication/login.vue'; +const router = useRouter(); + const notifications = ref([ { avatar: 'https://avatar.vercel.sh/vercel.svg?text=VB', @@ -61,6 +64,13 @@ const showDot = computed(() => ); const menus = computed(() => [ + { + handler: () => { + router.push('/profile/index'); + }, + icon: Info, + text: '个人中心', + }, { handler: () => { openWindow(VBEN_DOC_URL, { @@ -72,16 +82,16 @@ const menus = computed(() => [ }, { handler: () => { - openWindow(VBEN_GITHUB_URL, { + openWindow('https://gitee.com/yudaocode/yudao-ui-admin-vben', { target: '_blank', }); }, icon: MdiGithub, - text: 'GitHub', + text: 'Gitee', }, { handler: () => { - openWindow(`${VBEN_GITHUB_URL}/issues`, { + openWindow(`https://gitee.com/yudaocode/yudao-ui-admin-vben/issues`, { target: '_blank', }); }, @@ -91,7 +101,7 @@ const menus = computed(() => [ ]); const avatar = computed(() => { - return userStore.userInfo?.avatar ?? preferences.app.defaultAvatar; + return userStore.userInfo?.user.avatar ?? preferences.app.defaultAvatar; }); async function handleLogout() { @@ -128,9 +138,8 @@ watch( diff --git a/apps/web-antd/src/router/access.ts b/apps/web-antd/src/router/access.ts index 3ca4c59d8..db9fda0c6 100644 --- a/apps/web-antd/src/router/access.ts +++ b/apps/web-antd/src/router/access.ts @@ -19,9 +19,9 @@ import { buildMenus } from './helper'; const forbiddenComponent = () => import('#/views/_core/fallback/forbidden.vue'); /** - * dashboard路由 + * base路由 */ -const dashboardMenus: RouteRecordStringComponent[] = [ +const baseMenus: RouteRecordStringComponent[] = [ { component: 'BasicLayout', meta: { @@ -38,6 +38,7 @@ const dashboardMenus: RouteRecordStringComponent[] = [ component: '/dashboard/analytics/index', meta: { affixTab: true, + icon: 'lucide:area-chart', title: 'page.dashboard.analytics', }, }, @@ -46,9 +47,42 @@ const dashboardMenus: RouteRecordStringComponent[] = [ path: '/workspace', component: '/dashboard/workspace/index', meta: { + icon: 'carbon:workspace', title: 'page.dashboard.workspace', }, }, + { + name: 'VbenAbout', + path: '/about', + component: '/_core/about/index.vue', + meta: { + icon: 'lucide:copyright', + title: 'demos.vben.about', + }, + }, + ], + }, + { + component: 'BasicLayout', + meta: { + icon: 'ant-design:user-outlined', + order: -1, + title: '个人中心', + hideInMenu: true, + }, + name: 'profile', + path: '/profile', + children: [ + { + name: 'UserProfile', + path: '/profile/index', + component: '/_core/profile/profile.vue', + meta: { + icon: 'ant-design:user-outlined', + title: '个人中心', + hideInMenu: true, + }, + }, ], }, ]; @@ -71,7 +105,7 @@ async function generateAccess(options: GenerateMenuAndRoutesOptions) { const userStore = useUserStore(); const menus = userStore.userInfo?.menus; const routes = buildMenus(menus); - const menuList = [...cloneDeep(dashboardMenus), ...routes]; + const menuList = [...cloneDeep(baseMenus), ...routes]; return menuList; }, // 可以指定没有权限跳转403页面 diff --git a/apps/web-antd/src/views/_core/about/index.vue b/apps/web-antd/src/views/_core/about/index.vue index 0ee524335..678cecac3 100644 --- a/apps/web-antd/src/views/_core/about/index.vue +++ b/apps/web-antd/src/views/_core/about/index.vue @@ -5,5 +5,9 @@ defineOptions({ name: 'About' }); diff --git a/apps/web-antd/src/views/_core/profile/profile.vue b/apps/web-antd/src/views/_core/profile/profile.vue new file mode 100644 index 000000000..5b8a34c6c --- /dev/null +++ b/apps/web-antd/src/views/_core/profile/profile.vue @@ -0,0 +1,10 @@ + +