feat: 优化前端代码

This commit is contained in:
JaguarJack 2023-04-17 16:48:16 +08:00
parent 521f32dce0
commit dc0c86fcc2
3 changed files with 4 additions and 3 deletions

View File

@ -7,7 +7,7 @@
</div> </div>
<template #dropdown> <template #dropdown>
<el-dropdown-menu class="w-28"> <el-dropdown-menu class="w-28">
<el-dropdown-item> <Icon name="user" /> <router-link :to="{ name: 'user-center' }"> 个人信息</router-link> </el-dropdown-item> <el-dropdown-item> <Icon name="user" /> <router-link :to="{ path: 'center' }"> 个人信息</router-link> </el-dropdown-item>
<el-dropdown-item divided @click="logout"> <el-dropdown-item divided @click="logout">
<Icon name="power" className="mr-1 w-4 h-4" /> <Icon name="power" className="mr-1 w-4 h-4" />
退 退

View File

@ -38,6 +38,7 @@ const guard = (router: Router) => {
const permissionStore = usePermissionsStore() const permissionStore = usePermissionsStore()
// 动态路由挂载 // 动态路由挂载
const asyncRoutes = permissionStore.getAsyncMenusFrom(toRaw(userStore.getPermissions)) const asyncRoutes = permissionStore.getAsyncMenusFrom(toRaw(userStore.getPermissions))
console.log(asyncRoutes)
asyncRoutes.forEach((route: Menu) => { asyncRoutes.forEach((route: Menu) => {
router.addRoute(route as unknown as RouteRecordRaw) router.addRoute(route as unknown as RouteRecordRaw)
}) })

View File

@ -191,7 +191,7 @@ export const usePermissionsStore = defineStore('PermissionsStore', {
*/ */
resolveRoutePathRoutePath(route: string, path: string): string { resolveRoutePathRoutePath(route: string, path: string): string {
if (path.length) { if (path.length) {
return (path + (route.indexOf('/') === -1 ? '/' : '') + route).replace(/\/$/g, '') return (path + (!route.startsWith('/') ? '/' : '') + route).replace(/\/$/g, '')
} }
// 去除尾部的 / // 去除尾部的 /