菜单动态路由及头部角色切换修改

This commit is contained in:
duyufeng
2024-08-30 10:25:42 +08:00
parent c76dcaa7c5
commit 699754c902
10 changed files with 262 additions and 41 deletions

View File

@@ -135,4 +135,6 @@ export const useRouteStore = defineStore({
});
},
},
// //开启数据缓存
// persist:true,
});

View File

@@ -266,18 +266,18 @@
resizeButtom() {
this.$nextTick(() => {
if (this.$refs.tags !== undefined) {
const clientWidth = (this.$refs.tags as HTMLElement).clientWidth;
if (this.currentPage === 0) {
this.isdisabledl = this.tagList.length * 100 > clientWidth;
} else {
this.isdisabledl =
(this.tagList.length - this.number * this.currentPage) * 100 > clientWidth;
if (this.tagList.length * 100 < clientWidth) {
(this.$refs.tags as HTMLElement).style.cssText = `transform: translateX(${0}px)`;
this.isdisabledr = false;
this.currentPage = 0;
const clientWidth = (this.$refs.tags as HTMLElement).clientWidth;
if (this.currentPage === 0) {
this.isdisabledl = this.tagList.length * 100 > clientWidth;
} else {
this.isdisabledl =
(this.tagList.length - this.number * this.currentPage) * 100 > clientWidth;
if (this.tagList.length * 100 < clientWidth) {
(this.$refs.tags as HTMLElement).style.cssText = `transform: translateX(${0}px)`;
this.isdisabledr = false;
this.currentPage = 0;
}
}
}
}
});
},

View File

@@ -79,6 +79,7 @@
import { Cookies } from '/nerv-lib/util/cookie';
import { storeToRefs } from 'pinia';
import { NsMessage } from '/nerv-lib/component';
import { replyDynamRoutesPath } from '/nerv-lib/util/dynamicRoutesss';
export default defineComponent({
name: 'UserLogin',
@@ -194,12 +195,22 @@
name: initRouterList.length === 0 ? 'error403' : res.data[0]['code'],
});
} else {
router.replace({ name: 'root' });
const sessionStoreRoute = sessionStorage.getItem("dynamicRouteList");
let getDynamicRouteList = sessionStoreRoute?JSON.parse(sessionStoreRoute):[];
if(getDynamicRouteList && getDynamicRouteList.lenght>0){
let addDynamicRoutes = replyDynamRoutesPath(getDynamicRouteList);
addDynamicRoutes.forEach(item => {
if (item.children && !item.component) {
item.component = () => import('/nerv-lib/saas/view/system/application.vue');//hx-ai-intelligent项目下的首页
}
router.addRoute(item);
});
}
router.replace({ name: 'home' });
}
}
} catch (err) {
console.log(err);
loading.value = false;
}
}