Commit f72fb7c4 authored by chenjiahao's avatar chenjiahao

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

parent 3ea08d2c
<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 { useI18n } from '@/hooks/web/useI18n';
import { useUserStoreWithOut } from '@/store/modules/user';
......@@ -61,16 +61,30 @@
},
]);
const roleKey = ref('');
onMounted(() => {
if (localStorage.getItem('segmentValue') !== null) {
value.value = localStorage.getItem('segmentValue');
} else {
value.value = '数据要素';
localStorage.setItem('type', 6);
switch (localStorage.getItem('matchedTypes')[0]) {
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);
}
router.replace('' + localStorage.getItem('firstChild'));
router.replace(localStorage.getItem('firstChild'));
});
// 跳转前台
......@@ -79,6 +93,11 @@
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) {
localStorage.setItem('type', type);
localStorage.setItem('segmentValue', segmentValue);
......@@ -88,23 +107,12 @@
</script>
<template>
<div>
<!-- <a-button type="primary" @click="handleSelect(1)" style="margin-right: 10px">{{-->
<!-- t('layout.header.model1')-->
<!-- }}</a-button>-->
<!-- <a-button type="primary" @click="handleSelect(4)" style="margin-right: 10px">{{-->
<!-- t('layout.header.model4')-->
<!-- }}</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">
<Segmented
v-if="filteredData.length > 1"
v-model:value="value"
:options="filteredData"
size="large"
>
<template #label="{ payload, value: segmentValue }">
<div
@click="handleSelect(payload.key, segmentValue)"
......
......@@ -69,14 +69,6 @@ export const PCFontRoute: AppRouteRecordRaw = {
title: '',
},
},
{
path: '/aaaFont/individualCenter',
name: 'individualCenter',
component: () => import('@/views/AAAFont/individualCenter/index.vue'),
meta: {
title: '',
},
},
{
path: '/aaaFont/tradingMarket',
name: 'tradingMarket',
......
......@@ -207,7 +207,6 @@ export const useUserStore = defineStore({
} else {
this.setRoleList(['ROLE_DEFAULT']);
}
console.log(userInfo.data.menus);
// 获取动态路由下的第一个菜单路径
const firstChild = await this.getFirstChild(userInfo.data.menus[0]);
console.log('firstChild', firstChild);
......@@ -269,6 +268,7 @@ export const useUserStore = defineStore({
await this.logout(true);
},
});
localStorage.clear();
},
},
});
......
......@@ -98,7 +98,7 @@
showPopup: false,
showFixed: true,
timer: '',
isLogin: false,
isLogin: true,
seen: true,
navs: [
{ path: '/aaaFont/font', text: '首页' },
......@@ -146,6 +146,10 @@
},
},
mounted() {
console.log(getToken());
if (getToken()) {
this.isLogin = false;
}
// window.addEventListener('.el-main', this.handleScroll)
},
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