菜单修改为可配置
This commit is contained in:
parent
c6c531021b
commit
9a5066648c
@ -50,3 +50,11 @@ export const logoutApi = () => {
|
||||
export const jumpLargeUserInfoApi = (params?: any) => {
|
||||
return http.post(BASEURL + `/xmgl/base/getLoginInfoByToken`, params, { headers: { "Content-Type": "application/json" } });
|
||||
};
|
||||
// * 免登录用户信息
|
||||
export const jumpLargeByUserIdApi = (params?: any) => {
|
||||
return http.post(BASEURL + `/xmgl/base/userId/login`, params, { headers: { "Content-Type": "application/json" } });
|
||||
};
|
||||
|
||||
export const getAllModule = (params?: any) => {
|
||||
return http.post(BASEURL + `/xmgl/baseModule/getModuleAndMenuList`, params);
|
||||
};
|
||||
|
||||
@ -23,13 +23,13 @@ export const BAIDU_MAP_KEY: string = "";
|
||||
export const BASE_IMAGE_URL = import.meta.env.VITE_BASE_IMAGE_URL;
|
||||
|
||||
// 项目环境标识配置 部署时需更改对应的项目
|
||||
// export const COMPANY: string = ""; //标准版
|
||||
export const COMPANY: string = ""; //标准版
|
||||
// export const COMPANY: string = "zhzrf"; //中海·臻如府
|
||||
// export const COMPANY: string = "zsbf"; //中水北方
|
||||
// export const COMPANY: string = "as"; //鞍山项目
|
||||
// export const COMPANY: string = "agjt"; //鞍钢集团
|
||||
// export const COMPANY: string = "tj"; // 同济项目
|
||||
export const COMPANY: string = "agjtLive"; //鞍钢集团现场大屏
|
||||
// export const COMPANY: string = "agjtLive"; //鞍钢集团现场大屏
|
||||
// export const COMPANY: string = "bthg"; //包头化工
|
||||
// export const COMPANY: string = "agjtCommand"; //鞍钢集团指挥部大屏
|
||||
// export const COMPANY: string = "agjtProjectKanban"; //鞍钢集团项目看板大屏
|
||||
|
||||
@ -38,10 +38,14 @@ router.beforeEach(async (to, from, next) => {
|
||||
const globalStore = GlobalStore();
|
||||
// 解决首次跳转失败
|
||||
let freeToken = window.location.href.indexOf("token") != -1;
|
||||
let freeUserId = window.location.href.indexOf("userId") != -1;
|
||||
let freeSn = window.location.href.indexOf("sn") != -1;
|
||||
if (freeToken) {
|
||||
globalStore.token = window.location.href.split("token=")[1].split("&")[0];
|
||||
}
|
||||
if (freeUserId) {
|
||||
globalStore.setUserId(window.location.href.split("userId=")[1].split("&")[0]);
|
||||
}
|
||||
if (freeSn) {
|
||||
globalStore.setSN(window.location.href.split("sn=")[1]);
|
||||
}
|
||||
@ -69,7 +73,7 @@ router.beforeEach(async (to, from, next) => {
|
||||
// 3.判断是访问登陆页,有 Token 就在当前页面,没有 Token 重置路由并放行到登陆页
|
||||
if (to.path === LOGIN_URL) {
|
||||
console.log("判断是访问登陆页,有:", from.fullPath);
|
||||
console.log("要去的页面,有:", to.fullPath);
|
||||
console.log("要去的页面,有:", to);
|
||||
console.log("判断是访问登陆页,globalStore.token有:", globalStore.token);
|
||||
|
||||
if (globalStore.token && from.fullPath !='/') return next(from.fullPath);
|
||||
@ -81,7 +85,12 @@ router.beforeEach(async (to, from, next) => {
|
||||
if (ROUTER_WHITE_LIST.includes(to.path)) return next();
|
||||
|
||||
// 5.判断是否有 Token,没有重定向到 login
|
||||
if (!globalStore.token) return next({ path: LOGIN_URL, replace: true });
|
||||
if (!globalStore.token) {
|
||||
if (globalStore.userId) {
|
||||
return next();
|
||||
}
|
||||
return next({ path: LOGIN_URL, replace: true });
|
||||
}
|
||||
// if (to.path === "/") return next({ path: LOGIN_URL, replace: true });
|
||||
|
||||
// 6.如果没有菜单列表,就重新请求菜单列表并添加动态路由
|
||||
|
||||
@ -24,9 +24,9 @@ export const staticRouter: RouteRecordRaw[] = [
|
||||
{
|
||||
path: "/large",
|
||||
name: "大屏",
|
||||
// component: () => import("@/views/sevenLargeScreen/indexL.vue"), //七参数标准版
|
||||
component: () => import("@/views/sevenLargeScreen/indexL.vue"), //七参数标准版
|
||||
// component: () => import("@/views/commandScreen/indexCommand.vue"), //指挥部大屏
|
||||
component: () => import("@/views/agjtLiveScreen/indexLive.vue"), //鞍钢现场大屏
|
||||
// component: () => import("@/views/agjtLiveScreen/indexLive.vue"), //鞍钢现场大屏
|
||||
// component: () => import("@/views/overviewScreen/indexCommand.vue"), //总览大屏
|
||||
// component: () => import("@/views/locationLive/locationL.vue"), //人员定位大屏
|
||||
// component: () => import("@/views/agjtProjectKanban/indexL.vue"), //鞍钢集团项目看板大屏
|
||||
|
||||
@ -107,7 +107,7 @@
|
||||
import ScaleBox from "vue3-scale-box";
|
||||
import { ref, reactive, onMounted, onBeforeUnmount, computed } from "vue";
|
||||
import { getTaskTimeDetail } from "@/api/modules/schedulePlan";
|
||||
import { jumpLargeUserInfoApi } from "@/api/modules/login";
|
||||
import { jumpLargeUserInfoApi, jumpLargeByUserIdApi, getAllModule } from "@/api/modules/login";
|
||||
import {
|
||||
JSYCMenu,
|
||||
XJNBMenu,
|
||||
@ -491,6 +491,18 @@ const navigateTo = (path, type) => {
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
// 获取动态菜单
|
||||
const getModuleMenu = async () => {
|
||||
const res = await getAllModule({ moduleType: 8, userId: store.userId, projectSn: store.sn })
|
||||
console.info(res, "allModule");
|
||||
if (res.code == 200) {
|
||||
const { moduleList } = res.result;
|
||||
if (moduleList.length) {
|
||||
menuList.value = moduleList;
|
||||
}
|
||||
}
|
||||
};
|
||||
onMounted(async () => {
|
||||
if (window.location.href.indexOf("token") != -1) {
|
||||
console.log("免登录跳转进来了吗----", window.location.href.indexOf("token"));
|
||||
@ -505,6 +517,20 @@ onMounted(async () => {
|
||||
store.setAccountType(data.result.accountType);
|
||||
store.setProjectDateAuth(data.menuAuthority);
|
||||
}
|
||||
if (window.location.href.indexOf("userId") != -1) {
|
||||
console.log("免登录跳转进来了吗----", window.location.href.indexOf("userId"));
|
||||
const newUserId = window.location.href.split("userId=")[1].split("&")[0];
|
||||
const data: any = await jumpLargeByUserIdApi({ userId: newUserId });
|
||||
console.log("跳转请求的数据----", data.result);
|
||||
if (data.result.sn) {
|
||||
store.setSN(data.result.sn);
|
||||
}
|
||||
store.setToken(data.result.token);
|
||||
store.setAccount(data.result.account);
|
||||
store.setAccountType(data.result.accountType);
|
||||
store.setProjectDateAuth(data.menuAuthority);
|
||||
}
|
||||
await getModuleMenu();
|
||||
if (COMPANY === "jsyc") {
|
||||
menuList.value = JSYCMenu;
|
||||
}
|
||||
@ -631,7 +657,7 @@ function loginOut() {
|
||||
}
|
||||
//跳转后台
|
||||
function jumpBgd() {
|
||||
const envList = ["agjt", "zkax", "zkjc", "hfqc", "cpgs", "cqna", "jzjt", "tj"]; // 环境标识
|
||||
const envList = ["agjt", "zkax", "zkjc", "hfqc", "cpgs", "cqna", "jzjt", "tj", "bthg"]; // 环境标识
|
||||
// 标准版——跳转演示平台项目后台
|
||||
if (COMPANY == "") {
|
||||
window.location.replace("http://jxj.zhgdyun.com:100/#/login?token=" + store.token);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user