1.1需求处理、修改请求地址IP
1.广播页面及功能 接口对接 完成更新正式网 2.用户管理页面 处理中 3.工单管理 完成 4.用户算力
This commit is contained in:
@@ -86,7 +86,7 @@ const childrenRoutes = [
|
||||
}
|
||||
}
|
||||
},
|
||||
{//报块页面
|
||||
{//用户管理
|
||||
path: 'userManagement',
|
||||
name: 'UserManagement',
|
||||
component: () => import('../views/userManagement/index.vue'),
|
||||
@@ -97,8 +97,23 @@ const childrenRoutes = [
|
||||
en: 'userManagement',
|
||||
zh: '用户管理'
|
||||
}
|
||||
},
|
||||
|
||||
},
|
||||
{//用户详情
|
||||
path: 'userDetails',
|
||||
name: 'UserDetails',
|
||||
component: () => import('../views/userDetails/index.vue'),
|
||||
meta: {title: '用户详情',
|
||||
description:i18n.t(`seo.userManagement`),
|
||||
allAuthority:[`admin`,`back_admin`],
|
||||
keywords:{
|
||||
en: 'userDetails',
|
||||
zh: '用户详情'
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
|
||||
{//费率
|
||||
@@ -662,88 +677,167 @@ const router = new VueRouter({
|
||||
|
||||
|
||||
|
||||
router.beforeEach((to, from, next) => {
|
||||
// 检查语言参数
|
||||
const lang = to.params.lang;
|
||||
const supportedLanguages = ['zh', 'en'];
|
||||
// router.beforeEach((to, from, next) => {
|
||||
|
||||
// 如果路径以斜杠结尾且不是根路径,则重定向
|
||||
if (to.path.endsWith('/') && to.path.length > 1) {
|
||||
const path = to.path.slice(0, -1);
|
||||
return next({
|
||||
path,
|
||||
query: to.query,
|
||||
hash: to.hash,
|
||||
params: to.params
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// // 检查语言参数
|
||||
// const lang = to.params.lang;
|
||||
// const supportedLanguages = ['zh', 'en'];
|
||||
|
||||
// // 如果路径以斜杠结尾且不是根路径,则重定向
|
||||
// if (to.path.endsWith('/') && to.path.length > 1) {
|
||||
// const path = to.path.slice(0, -1);
|
||||
// return next({
|
||||
// path,
|
||||
// query: to.query,
|
||||
// hash: to.hash,
|
||||
// params: to.params
|
||||
// });
|
||||
// }
|
||||
|
||||
if (!lang && to.path !== '/') {
|
||||
const defaultLang = localStorage.getItem('lang') || 'en';
|
||||
return next(`/${defaultLang}${to.path}`);
|
||||
}
|
||||
// if (!lang && to.path !== '/') {
|
||||
// const defaultLang = localStorage.getItem('lang') || 'en';
|
||||
// return next(`/${defaultLang}${to.path}`);
|
||||
// }
|
||||
|
||||
let data = localStorage.getItem("jurisdiction");
|
||||
let jurisdiction =JSON.parse(data);
|
||||
console.log(jurisdiction,"权限");
|
||||
// let data = localStorage.getItem("jurisdiction");
|
||||
// let jurisdiction =JSON.parse(data);
|
||||
// console.log(jurisdiction,"权限");
|
||||
|
||||
localStorage.setItem('superReportError',"")
|
||||
let element = document.getElementsByClassName('el-main')[0];
|
||||
if(element){
|
||||
element.scrollTop = 0
|
||||
}
|
||||
// localStorage.setItem('superReportError',"")
|
||||
// let element = document.getElementsByClassName('el-main')[0];
|
||||
// if(element){
|
||||
// element.scrollTop = 0
|
||||
// }
|
||||
|
||||
let token
|
||||
try{
|
||||
token =JSON.parse(localStorage.getItem('token'))
|
||||
}catch(e){
|
||||
console.log(e);
|
||||
}
|
||||
// let token
|
||||
// try{
|
||||
// token =JSON.parse(localStorage.getItem('token'))
|
||||
// }catch(e){
|
||||
// console.log(e);
|
||||
// }
|
||||
|
||||
// console.log('beforeEach:', to.path, 'token:', token);
|
||||
|
||||
|
||||
|
||||
if (token) {
|
||||
// if (token) {
|
||||
|
||||
|
||||
if (to.path === `/${lang}/login`|| to.path === `/${lang}/register`) {
|
||||
next({ path: `/${lang}` })
|
||||
}else if(to.meta.allAuthority && to.meta.allAuthority[0] ==`all`){
|
||||
next()
|
||||
}else if(jurisdiction.roleKey && to.meta.allAuthority&&to.meta.allAuthority.some(item=>item == jurisdiction.roleKey )){
|
||||
next()
|
||||
}else{
|
||||
console.log(to.meta.allAuthority,to.path,"权限");
|
||||
// if (to.path === `/${lang}/login`|| to.path === `/${lang}/register`) {
|
||||
// next({ path: `/${lang}` })
|
||||
// }else if(to.meta.allAuthority && to.meta.allAuthority[0] ==`all`){
|
||||
// next()
|
||||
// }else if(jurisdiction.roleKey && to.meta.allAuthority&&to.meta.allAuthority.some(item=>item == jurisdiction.roleKey )){
|
||||
// next()
|
||||
// }else{
|
||||
// console.log(to.meta.allAuthority,to.path,"权限");
|
||||
|
||||
Message({//权限不足
|
||||
showClose: true,
|
||||
message:i18n.t(`mining.jurisdiction`),
|
||||
type: 'error'
|
||||
});
|
||||
// Message({//权限不足
|
||||
// showClose: true,
|
||||
// message:i18n.t(`mining.jurisdiction`),
|
||||
// type: 'error'
|
||||
// });
|
||||
|
||||
next({ path: `/${lang}` }) // 添加这行,重定向到首页
|
||||
}
|
||||
// next({ path: `/${lang}` }) // 添加这行,重定向到首页
|
||||
// }
|
||||
|
||||
}else{
|
||||
// }else{
|
||||
|
||||
// console.log(to.path,"to.path 权限不足");
|
||||
// let paths = [`/${lang}/miningAccount`,`/${lang}/workOrderRecords`,`/${lang}/userWorkDetails`,`/${lang}/submitWorkOrder`,`/${lang}/workOrderBackend`,`/${lang}/BKWorkDetails`]
|
||||
// if (paths.includes(to.path) || to.path.includes(`personalCenter`) ) {
|
||||
// console.log(to.path,"to.path 权限不足");
|
||||
|
||||
let paths = [`/${lang}/miningAccount`,`/${lang}/workOrderRecords`,`/${lang}/userWorkDetails`,`/${lang}/submitWorkOrder`,`/${lang}/workOrderBackend`,`/${lang}/BKWorkDetails`]
|
||||
if (paths.includes(to.path) || to.path.includes(`personalCenter`) ) {
|
||||
|
||||
Message({//权限不足
|
||||
showClose: true,
|
||||
message:i18n.t(`mining.logInFirst`),
|
||||
type: 'error'
|
||||
});
|
||||
// Message({//权限不足
|
||||
// showClose: true,
|
||||
// message:i18n.t(`mining.logInFirst`),
|
||||
// type: 'error'
|
||||
// });
|
||||
|
||||
next({ path: `/${lang}/login` })
|
||||
} else {
|
||||
// next({ path: `/${lang}/login` })
|
||||
// } else {
|
||||
|
||||
next()
|
||||
}
|
||||
}
|
||||
// next()
|
||||
// }
|
||||
// return; // 防止多次 next
|
||||
// }
|
||||
|
||||
|
||||
|
||||
})
|
||||
// })
|
||||
|
||||
router.beforeEach((to, from, next) => {
|
||||
const lang = to.params.lang || (localStorage.getItem('lang') || 'en');
|
||||
let token = null;
|
||||
try {
|
||||
token = JSON.parse(localStorage.getItem('token'));
|
||||
} catch (e) {
|
||||
token = null;
|
||||
}
|
||||
|
||||
// 需要登录的页面
|
||||
const needLoginPaths = [
|
||||
`/${lang}/miningAccount`,
|
||||
`/${lang}/workOrderRecords`,
|
||||
`/${lang}/userWorkDetails`,
|
||||
`/${lang}/submitWorkOrder`,
|
||||
`/${lang}/workOrderBackend`,
|
||||
`/${lang}/BKWorkDetails`
|
||||
];
|
||||
|
||||
// 未登录
|
||||
if (!token) {
|
||||
// 只在不是登录/注册页时才跳转
|
||||
if (
|
||||
(needLoginPaths.includes(to.path) || to.path.includes('personalCenter')) &&
|
||||
to.name !== 'Login' &&
|
||||
to.name !== 'Register'
|
||||
) {
|
||||
Message({
|
||||
showClose: true,
|
||||
message: i18n.t(`mining.logInFirst`),
|
||||
type: 'error'
|
||||
});
|
||||
return next({ path: `/${lang}/login` });
|
||||
}
|
||||
return next();
|
||||
}
|
||||
|
||||
// 已登录
|
||||
if (to.name === 'Login' || to.name === 'Register') {
|
||||
return next({ path: `/${lang}` });
|
||||
}
|
||||
|
||||
// 权限判断
|
||||
let jurisdiction = null;
|
||||
try {
|
||||
jurisdiction = JSON.parse(localStorage.getItem("jurisdiction"));
|
||||
} catch (e) {
|
||||
jurisdiction = null;
|
||||
}
|
||||
if (
|
||||
to.meta.allAuthority &&
|
||||
(
|
||||
to.meta.allAuthority[0] === 'all' ||
|
||||
(jurisdiction && jurisdiction.roleKey && to.meta.allAuthority.includes(jurisdiction.roleKey))
|
||||
)
|
||||
) {
|
||||
return next();
|
||||
}
|
||||
|
||||
// 无权限
|
||||
Message({
|
||||
showClose: true,
|
||||
message: i18n.t(`mining.jurisdiction`),
|
||||
type: 'error'
|
||||
});
|
||||
return next({ path: `/${lang}/login` }); // 建议无权限时跳转登录页而不是首页
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user