Commit a89ab49c authored by 曹泽华's avatar 曹泽华

Merge remote-tracking branch 'origin/master'

parents 6325a838 3ea08d2c
...@@ -63,25 +63,16 @@ ...@@ -63,25 +63,16 @@
const roleKey = ref(''); const roleKey = ref('');
onMounted(() => { onMounted(() => {
if (userStore.getUserInfo.roles.length > 0) {
roleKey.value = '' + userStore.getUserInfo.roles[0].roleKey; // 获取当前用户权限
} else {
roleKey.value = '' + userStore.getUserInfo.user.roleNames;
}
if (localStorage.getItem('segmentValue') !== null) { if (localStorage.getItem('segmentValue') !== null) {
value.value = localStorage.getItem('segmentValue'); value.value = localStorage.getItem('segmentValue');
} else if (roleKey.value === 'test') { } else {
value.value = '数据要素'; value.value = '数据要素';
localStorage.setItem('type', 6); localStorage.setItem('type', 6);
localStorage.setItem('segmentValue', value.value); localStorage.setItem('segmentValue', value.value);
router.replace('/');
// handleSelect(6, value.value);
} }
router.replace('' + localStorage.getItem('firstChild'));
}); });
function handleClick() {
window.open('https://www.vben.pro', '_blank');
}
// 跳转前台 // 跳转前台
async function handleGoFont() { async function handleGoFont() {
await router.replace('/aaaFont/font'); await router.replace('/aaaFont/font');
......
...@@ -128,20 +128,92 @@ export const useUserStore = defineStore({ ...@@ -128,20 +128,92 @@ export const useUserStore = defineStore({
}, },
async getUserInfoAction(): Promise<UserInfo | null> { async getUserInfoAction(): Promise<UserInfo | null> {
if (!this.getToken) return null; if (!this.getToken) return null;
var type = localStorage.getItem('type'); let userInfo;
let type = localStorage.getItem('type');
if (type === null) { if (type === null) {
type = '1'; type = '1';
// 第一次调用getUserInfo 获取当前用户的权限集合
userInfo = await getUserInfo(type);
const perm = userInfo.data.permissions;
// 定义各个模块的权限集合
const models = {
// 基础平台 type = 1
'1': [
'homePage',
'system',
'notifications',
'dataSourceManage',
'commonFile',
'mainBody',
'auditLog',
'processCenter',
'knowledgeBase',
'dataSecurity',
'metaModel',
'ArchitecturePlan',
'nameStandard',
],
// 数据治理 type = 2
'2': ['metadata', 'dataWarehousePlanning', 'dataStandards', 'dataQuality', 'kinship'],
// 数据服务 type = 3
'3': ['dataService', 'log'],
// 数仓开发 type = 4
'4': [
'dataIntegration',
'realTimeSync',
'taskScheduling',
'scriptDevelopment',
'parameterConfiguration',
],
// 数据要素 type = 6
'6': [
'OverviewMallResource',
'mallResourceDevelopment',
'dataSharingAndExchange',
'servicePlatform',
'personalCenter',
],
};
// 存储匹配到的类型
let matchedTypes = [];
// 检查是否有管理员权限
if (perm.includes('*:*:*')) {
// 如果存在管理员权限,赋予所有模块的权限
matchedTypes = Object.keys(models);
} else {
// 遍历 寻找用户权限集合与各模块权限集合的交集 将有交集的模块存储
for (const [type, permissions] of Object.entries(models)) {
if (permissions.some((permission) => perm.includes(permission))) {
matchedTypes.push(type);
}
}
}
// 刨去无意义的权限(空值)
matchedTypes = matchedTypes.filter((item) => item && !['', null].includes(item));
// 记录当前用户有哪些模块的权限,用以筛选右上角模块
localStorage.setItem('matchedTypes', matchedTypes);
console.log(localStorage.getItem('matchedTypes'));
// 使用用户第一个拥有模块的type值
if (matchedTypes.length > 0) {
type = matchedTypes[0];
}
// 第二次调用getUserInfo 获取正确的用户信息
userInfo = await getUserInfo(type);
} else {
userInfo = await getUserInfo(type);
} }
const userInfo = await getUserInfo(type);
if (userInfo.data.roles && userInfo.data.roles.length > 0) { if (userInfo.data.roles && userInfo.data.roles.length > 0) {
this.setRoleList(userInfo.data.roles); this.setRoleList(userInfo.data.roles);
} else { } else {
this.setRoleList(['ROLE_DEFAULT']); this.setRoleList(['ROLE_DEFAULT']);
} }
console.log(userInfo.data.menus);
// 获取动态路由下的第一个菜单路径 // 获取动态路由下的第一个菜单路径
const firstChild = await this.getFirstChild(userInfo.data.menus[0]); const firstChild = await this.getFirstChild(userInfo.data.menus[0]);
console.log('firstChild', firstChild);
// 登陆后进入的第一个页面 // 登陆后进入的第一个页面
userInfo.data.homePath = firstChild; userInfo.data.homePath = firstChild;
localStorage.setItem('firstChild', firstChild);
// 设置用户信息,并存储本地缓存 // 设置用户信息,并存储本地缓存
this.setUserInfo(userInfo.data); this.setUserInfo(userInfo.data);
return userInfo.data; return userInfo.data;
......
...@@ -47,7 +47,7 @@ ...@@ -47,7 +47,7 @@
>注册</el-button >注册</el-button
> >
</div> </div>
<div v-else style="display: flex;align-items: center"> <div v-else style="display: flex; align-items: center">
<a-button class="long_btn" type="link" /> <a-button class="long_btn" type="link" />
<a-button <a-button
style="color: #486fe1; background-color: #dce5f9" style="color: #486fe1; background-color: #dce5f9"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment