perf: 省略 window 前缀
This commit is contained in:
parent
05f8cc6404
commit
d3b09be774
@ -1,4 +1,4 @@
|
|||||||
// Tip: Simple judgments may not fully cover
|
// Tip: Simple judgments may not fully cover
|
||||||
if (/MSIE\s|Trident\//.test(window.navigator.userAgent)) {
|
if (/MSIE\s|Trident\//.test(navigator.userAgent)) {
|
||||||
document.body.innerHTML = "<strong>Sorry, this browser is currently not supported. We recommend using the latest version of a modern browser. For example, Chrome/Firefox/Edge.</strong>"
|
document.body.innerHTML = "<strong>Sorry, this browser is currently not supported. We recommend using the latest version of a modern browser. For example, Chrome/Firefox/Edge.</strong>"
|
||||||
}
|
}
|
||||||
|
@ -36,7 +36,7 @@ export const useUserStore = defineStore("user", () => {
|
|||||||
token.value = newToken
|
token.value = newToken
|
||||||
_setToken(newToken)
|
_setToken(newToken)
|
||||||
// 用刷新页面代替重新登录
|
// 用刷新页面代替重新登录
|
||||||
window.location.reload()
|
location.reload()
|
||||||
}
|
}
|
||||||
|
|
||||||
// 登出
|
// 登出
|
||||||
|
@ -197,7 +197,8 @@ export const dynamicRoutes: RouteRecordRaw[] = [
|
|||||||
meta: {
|
meta: {
|
||||||
title: "权限演示",
|
title: "权限演示",
|
||||||
elIcon: "lock",
|
elIcon: "lock",
|
||||||
roles: ["admin", "editor"], // 可以在根路由中设置角色
|
// 可以在根路由中设置角色
|
||||||
|
roles: ["admin", "editor"],
|
||||||
alwaysShow: true
|
alwaysShow: true
|
||||||
},
|
},
|
||||||
children: [
|
children: [
|
||||||
@ -207,7 +208,8 @@ export const dynamicRoutes: RouteRecordRaw[] = [
|
|||||||
name: "PagePermission",
|
name: "PagePermission",
|
||||||
meta: {
|
meta: {
|
||||||
title: "页面级",
|
title: "页面级",
|
||||||
roles: ["admin"] // 或者在子路由中设置角色
|
// 或者在子路由中设置角色
|
||||||
|
roles: ["admin"]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -215,7 +217,9 @@ export const dynamicRoutes: RouteRecordRaw[] = [
|
|||||||
component: () => import("@/pages/demo/permission/directive.vue"),
|
component: () => import("@/pages/demo/permission/directive.vue"),
|
||||||
name: "DirectivePermission",
|
name: "DirectivePermission",
|
||||||
meta: {
|
meta: {
|
||||||
title: "按钮级" // 如果未设置角色,则表示:该页面不需要权限,但会继承根路由的角色
|
title: "按钮级",
|
||||||
|
// 如果未设置角色,则表示:该页面不需要权限,但会继承根路由的角色
|
||||||
|
roles: undefined
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
@ -230,8 +234,8 @@ export const router = createRouter({
|
|||||||
|
|
||||||
/** 重置路由 */
|
/** 重置路由 */
|
||||||
export function resetRouter() {
|
export function resetRouter() {
|
||||||
// 注意:所有动态路由路由必须带有 Name 属性,否则可能会不能完全重置干净
|
|
||||||
try {
|
try {
|
||||||
|
// 注意:所有动态路由路由必须带有 Name 属性,否则可能会不能完全重置干净
|
||||||
router.getRoutes().forEach((route) => {
|
router.getRoutes().forEach((route) => {
|
||||||
const { name, meta } = route
|
const { name, meta } = route
|
||||||
if (name && meta.roles?.length) {
|
if (name && meta.roles?.length) {
|
||||||
@ -240,7 +244,7 @@ export function resetRouter() {
|
|||||||
})
|
})
|
||||||
} catch {
|
} catch {
|
||||||
// 强制刷新浏览器也行,只是交互体验不是很好
|
// 强制刷新浏览器也行,只是交互体验不是很好
|
||||||
window.location.reload()
|
location.reload()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user