| | |
| | | import { getConfig } from "@/config"; |
| | | import { emitter } from "@/utils/mitt"; |
| | | import Avatar from "@/assets/user.jpg"; |
| | | import { getTopMenu } from "@/router/utils"; |
| | | import { initRouter, getTopMenu, handleAliveRoute } from "@/router/utils"; |
| | | import { useFullscreen } from "@vueuse/core"; |
| | | import type { routeMetaType } from "../types"; |
| | | import { useRouter, useRoute } from "vue-router"; |
| | |
| | | import { usePermissionStoreHook } from "@/store/modules/permission"; |
| | | import ExitFullscreen from "~icons/ri/fullscreen-exit-fill"; |
| | | import Fullscreen from "~icons/ri/fullscreen-fill"; |
| | | import { unref } from "vue"; |
| | | |
| | | const errorInfo = |
| | | "The current routing configuration is incorrect, please check the configuration"; |
| | |
| | | |
| | | /** 角色 */ |
| | | const userRoles = computed(() => { |
| | | return useUserStoreHook()?.exRoles[0]; |
| | | return useUserStoreHook()?.nowRole; |
| | | }); |
| | | |
| | | /** 角色 */ |
| | | const userRolesList = computed(() => { |
| | | return useUserStoreHook()?.exRoles ?? []; |
| | | }); |
| | | |
| | | const avatarsStyle = computed(() => { |
| | |
| | | if (Title) document.title = `${meta.title} | ${Title}`; |
| | | else document.title = meta.title; |
| | | } |
| | | |
| | | /** 刷新路由 */ |
| | | function onFresh() { |
| | | const { fullPath, query } = unref(route); |
| | | router.replace({ |
| | | path: "/redirect" + fullPath, |
| | | query |
| | | }); |
| | | handleAliveRoute(route as ToRouteType, "refresh"); |
| | | } |
| | | /** 切换角色 */ |
| | | const changRole = item => { |
| | | useUserStoreHook() |
| | | .changeLogoInExRule({ |
| | | ruleCode: item.code |
| | | }) |
| | | .then(res => { |
| | | if (res.code == 200) { |
| | | // 获取后端路由 |
| | | initRouter(); |
| | | onFresh(); |
| | | } |
| | | }); |
| | | }; |
| | | /** 退出登录 */ |
| | | function logout() { |
| | | useUserStoreHook().logOut(); |
| | |
| | | pureApp, |
| | | username, |
| | | userRoles, |
| | | userRolesList, |
| | | userAvatar, |
| | | avatarsStyle, |
| | | tooltipEffect |
| | | tooltipEffect, |
| | | changRole |
| | | }; |
| | | } |