feat: 优化前端代码
This commit is contained in:
parent
521f32dce0
commit
dc0c86fcc2
@ -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" />
|
||||||
退 出
|
退 出
|
||||||
|
@ -38,7 +38,8 @@ const guard = (router: Router) => {
|
|||||||
const permissionStore = usePermissionsStore()
|
const permissionStore = usePermissionsStore()
|
||||||
// 动态路由挂载
|
// 动态路由挂载
|
||||||
const asyncRoutes = permissionStore.getAsyncMenusFrom(toRaw(userStore.getPermissions))
|
const asyncRoutes = permissionStore.getAsyncMenusFrom(toRaw(userStore.getPermissions))
|
||||||
asyncRoutes.forEach((route: Menu) => {
|
console.log(asyncRoutes)
|
||||||
|
asyncRoutes.forEach((route: Menu) => {
|
||||||
router.addRoute(route as unknown as RouteRecordRaw)
|
router.addRoute(route as unknown as RouteRecordRaw)
|
||||||
})
|
})
|
||||||
// 在动态路由之后挂载匹配 404 路由
|
// 在动态路由之后挂载匹配 404 路由
|
||||||
|
@ -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, '')
|
||||||
}
|
}
|
||||||
|
|
||||||
// 去除尾部的 /
|
// 去除尾部的 /
|
||||||
|
Loading…
x
Reference in New Issue
Block a user