Commit f72fb7c4 authored by chenjiahao's avatar chenjiahao

新增:根据用户权限显示不同的可选模块&当登陆后首页才显示个人中心;修复路由问题

parent 3ea08d2c
<script setup lang="ts"> <script setup lang="ts">
import { h, ref, onMounted } from 'vue'; import { h, ref, onMounted, computed } from 'vue';
import { Modal, Segmented } from 'ant-design-vue'; import { Modal, Segmented } from 'ant-design-vue';
import { useI18n } from '@/hooks/web/useI18n'; import { useI18n } from '@/hooks/web/useI18n';
import { useUserStoreWithOut } from '@/store/modules/user'; import { useUserStoreWithOut } from '@/store/modules/user';
...@@ -61,16 +61,30 @@ ...@@ -61,16 +61,30 @@
}, },
]); ]);
const roleKey = ref('');
onMounted(() => { onMounted(() => {
if (localStorage.getItem('segmentValue') !== null) { if (localStorage.getItem('segmentValue') !== null) {
value.value = localStorage.getItem('segmentValue'); value.value = localStorage.getItem('segmentValue');
} else { } else {
value.value = '数据要素'; switch (localStorage.getItem('matchedTypes')[0]) {
localStorage.setItem('type', 6); case '1':
value.value = '基础平台';
break;
case '2':
value.value = '数据治理';
break;
case '3':
value.value = '数据服务';
break;
case '4':
value.value = '数仓开发';
break;
case '6':
value.value = '数据要素';
break;
}
localStorage.setItem('segmentValue', value.value); localStorage.setItem('segmentValue', value.value);
} }
router.replace('' + localStorage.getItem('firstChild')); router.replace(localStorage.getItem('firstChild'));
}); });
// 跳转前台 // 跳转前台
...@@ -79,6 +93,11 @@ ...@@ -79,6 +93,11 @@
window.location.reload(); window.location.reload();
} }
const filteredData = computed(() => {
const types = localStorage.getItem('matchedTypes') || '';
return data.value.filter((item) => types.includes(String(item.payload.key)));
});
async function handleSelect(type, segmentValue) { async function handleSelect(type, segmentValue) {
localStorage.setItem('type', type); localStorage.setItem('type', type);
localStorage.setItem('segmentValue', segmentValue); localStorage.setItem('segmentValue', segmentValue);
...@@ -88,23 +107,12 @@ ...@@ -88,23 +107,12 @@
</script> </script>
<template> <template>
<div> <div>
<!-- <a-button type="primary" @click="handleSelect(1)" style="margin-right: 10px">{{--> <Segmented
<!-- t('layout.header.model1')--> v-if="filteredData.length > 1"
<!-- }}</a-button>--> v-model:value="value"
<!-- <a-button type="primary" @click="handleSelect(4)" style="margin-right: 10px">{{--> :options="filteredData"
<!-- t('layout.header.model4')--> size="large"
<!-- }}</a-button>--> >
<!-- <a-button type="primary" @click="handleSelect(2)" style="margin-right: 10px">{{-->
<!-- t('layout.header.model2')-->
<!-- }}</a-button>-->
<!-- <a-button type="primary" @click="handleSelect(3)" style="margin-right: 10px">{{-->
<!-- t('layout.header.model3')-->
<!-- }}</a-button>-->
<!-- <a-button type="primary" @click="handleSelect(6)" style="margin-right: 10px">{{-->
<!-- t('layout.header.model5')-->
<!-- }}</a-button>-->
<Segmented v-show="roleKey !== 'test'" v-model:value="value" :options="data" size="large">
<template #label="{ payload, value: segmentValue }"> <template #label="{ payload, value: segmentValue }">
<div <div
@click="handleSelect(payload.key, segmentValue)" @click="handleSelect(payload.key, segmentValue)"
......
...@@ -69,14 +69,6 @@ export const PCFontRoute: AppRouteRecordRaw = { ...@@ -69,14 +69,6 @@ export const PCFontRoute: AppRouteRecordRaw = {
title: '', title: '',
}, },
}, },
{
path: '/aaaFont/individualCenter',
name: 'individualCenter',
component: () => import('@/views/AAAFont/individualCenter/index.vue'),
meta: {
title: '',
},
},
{ {
path: '/aaaFont/tradingMarket', path: '/aaaFont/tradingMarket',
name: 'tradingMarket', name: 'tradingMarket',
......
...@@ -207,7 +207,6 @@ export const useUserStore = defineStore({ ...@@ -207,7 +207,6 @@ export const useUserStore = defineStore({
} 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); console.log('firstChild', firstChild);
...@@ -269,6 +268,7 @@ export const useUserStore = defineStore({ ...@@ -269,6 +268,7 @@ export const useUserStore = defineStore({
await this.logout(true); await this.logout(true);
}, },
}); });
localStorage.clear();
}, },
}, },
}); });
......
...@@ -98,7 +98,7 @@ ...@@ -98,7 +98,7 @@
showPopup: false, showPopup: false,
showFixed: true, showFixed: true,
timer: '', timer: '',
isLogin: false, isLogin: true,
seen: true, seen: true,
navs: [ navs: [
{ path: '/aaaFont/font', text: '首页' }, { path: '/aaaFont/font', text: '首页' },
...@@ -146,6 +146,10 @@ ...@@ -146,6 +146,10 @@
}, },
}, },
mounted() { mounted() {
console.log(getToken());
if (getToken()) {
this.isLogin = false;
}
// window.addEventListener('.el-main', this.handleScroll) // window.addEventListener('.el-main', this.handleScroll)
}, },
methods: { methods: {
......
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