This commit is contained in:
张良(004796)
2024-02-19 12:26:00 +08:00
parent db9b4e845b
commit 7cfc0583dd
5 changed files with 40 additions and 21 deletions

View File

@@ -1,6 +1,7 @@
import {createRouter, createWebHashHistory, RouteRecordRaw} from 'vue-router';
import {useUserStore} from "@/store/modules/user";
import {domainStoreWidthOut} from "@/store/modules/domain";
import {getDomainList} from "@/api/login";
export const constantRouter: Array<RouteRecordRaw> = [
{
@@ -235,8 +236,15 @@ const router = createRouter({
// @ts-ignore
router.beforeEach((to, from, next) => {
domainStoreWidthOut().refreshDomain();
router.beforeEach(async (to, from, next) => {
const dsw = domainStoreWidthOut()
if (!dsw.getDomain || dsw.getDomain.length == 0) {
const response = await getDomainList()
if (response && response.data) {
const domain = response.data.split(',')
dsw.setDomain(domain)
}
}
if (to.meta.title) { // 判断是否有标题
document.title = to.meta.title as string;
}