Commit eef815bf authored by chenjiahao's avatar chenjiahao

权限设置

parent b7dfdd1a
...@@ -10,7 +10,9 @@ ...@@ -10,7 +10,9 @@
<!-- </div>--> <!-- </div>-->
<div style="display: flex; align-items: center" @click="handleGoFont"> <div style="display: flex; align-items: center" @click="handleGoFont">
<img src="../../../assets/svg/logo.svg" alt="融创软通" /> <img src="../../../assets/svg/logo.svg" alt="融创软通" />
<span style="margin-left: 10px; font-size: 20px; color: white">数据要素平台</span> <span v-show="showTitle" style="margin-left: 10px; font-size: 20px; color: white"
>数据要素平台</span
>
</div> </div>
</div> </div>
</template> </template>
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
editColumnData, editColumnData,
editTableData, editTableData,
} from '@/views/metaModel/standardModel/modelData'; } from '@/views/metaModel/standardModel/modelData';
import { getUserInfo } from '@/api/sys/user';
const { t } = useI18n(); const { t } = useI18n();
const userStore = useUserStoreWithOut(); const userStore = useUserStoreWithOut();
...@@ -26,7 +27,7 @@ ...@@ -26,7 +27,7 @@
// } // }
localStorage.setItem(localKey, String(Date.now())); localStorage.setItem(localKey, String(Date.now()));
const value = ref('服务平台'); const value = ref('数据要素');
const data = ref([ const data = ref([
{ {
payload: { payload: {
...@@ -60,16 +61,28 @@ ...@@ -60,16 +61,28 @@
}, },
]); ]);
const roleKey = ref('');
onMounted(() => { onMounted(() => {
console.log(localStorage.getItem('segmentValue')); 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') {
value.value = '数据要素';
localStorage.setItem('type', 6);
localStorage.setItem('segmentValue', value.value);
router.replace('/');
// handleSelect(6, value.value);
} }
}); });
function handleClick() { function handleClick() {
window.open('https://www.vben.pro', '_blank'); window.open('https://www.vben.pro', '_blank');
} }
// 跳转前台
async function handleGoFont() { async function handleGoFont() {
await router.replace('/aaaFont/font'); await router.replace('/aaaFont/font');
window.location.reload(); window.location.reload();
...@@ -100,7 +113,7 @@ ...@@ -100,7 +113,7 @@
<!-- t('layout.header.model5')--> <!-- t('layout.header.model5')-->
<!-- }}</a-button>--> <!-- }}</a-button>-->
<Segmented v-model:value="value" :options="data" size="large"> <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)"
...@@ -118,7 +131,7 @@ ...@@ -118,7 +131,7 @@
</div> </div>
</template> </template>
</Segmented> </Segmented>
<!-- <a-button type="link" @click="handleGoFont"> 前台页面 </a-button>--> <!-- <a-button type="link" @click="handleGoFont"> 前台页面 </a-button>-->
<!-- 前往体验新版--> <!-- 前往体验新版-->
<!-- <a-button type="primary" @click="handleClick">{{--> <!-- <a-button type="primary" @click="handleClick">{{-->
<!-- t('layout.header.upgrade-prompt.ok-text')--> <!-- t('layout.header.upgrade-prompt.ok-text')-->
......
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
:sider="false" :sider="false"
/> />
<LayoutBreadcrumb v-if="getShowContent && getShowBread" :theme="getHeaderTheme" /> <LayoutBreadcrumb v-if="getShowContent && getShowBread" :theme="getHeaderTheme" />
<!-- <UpgradePrompt class="mr-2 ml-4" />--> <!-- <UpgradePrompt class="mr-2 ml-4" />-->
</div> </div>
<!-- left end --> <!-- left end -->
...@@ -33,34 +33,33 @@ ...@@ -33,34 +33,33 @@
<!-- menu-end --> <!-- menu-end -->
<!-- action --> <!-- action -->
<div :class="`${prefixCls}-action`"> <div :class="`${prefixCls}-action`" style="display: flex; justify-content: end">
<!-- 切换模块 按钮--> <!-- 切换模块 按钮-->
<UpgradePrompt class="mr-2" /> <UpgradePrompt />
<!-- 搜索 按钮-->
<!-- <AppSearch v-if="getShowSearch" :class="`${prefixCls}-action__item `" />-->
<!-- 搜索 按钮-->
<!-- <AppSearch v-if="getShowSearch" :class="`${prefixCls}-action__item `" />-->
<ErrorAction v-if="getUseErrorHandle" :class="`${prefixCls}-action__item error-action`" /> <ErrorAction v-if="getUseErrorHandle" :class="`${prefixCls}-action__item error-action`" />
<Notify v-if="getShowNotice" :class="`${prefixCls}-action__item notify-item`" /> <Notify v-if="getShowNotice" :class="`${prefixCls}-action__item notify-item`" />
<!-- 全屏 按钮--> <!-- 全屏 按钮-->
<!-- <FullScreen v-if="getShowFullScreen" :class="`${prefixCls}-action__item fullscreen-item`" />--> <!-- <FullScreen v-if="getShowFullScreen" :class="`${prefixCls}-action__item fullscreen-item`" />-->
<!-- 英汉翻译 按钮--> <!-- 英汉翻译 按钮-->
<!-- <AppLocalePicker--> <!-- <AppLocalePicker-->
<!-- v-if="getShowLocalePicker"--> <!-- v-if="getShowLocalePicker"-->
<!-- :reload="true"--> <!-- :reload="true"-->
<!-- :showText="false"--> <!-- :showText="false"-->
<!-- :class="`${prefixCls}-action__item`"--> <!-- :class="`${prefixCls}-action__item`"-->
<!-- />--> <!-- />-->
<!-- 头像 按钮--> <!-- 头像 按钮-->
<UserDropDown :theme="getHeaderTheme" /> <UserDropDown :theme="getHeaderTheme" />
<!-- 设置 按钮--> <!-- 设置 按钮-->
<!-- <SettingDrawer v-if="getShowSetting" :class="`${prefixCls}-action__item`" />--> <!-- <SettingDrawer v-if="getShowSetting" :class="`${prefixCls}-action__item`" />-->
</div> </div>
</Layout.Header> </Layout.Header>
</template> </template>
......
...@@ -105,7 +105,7 @@ export const useUserStore = defineStore({ ...@@ -105,7 +105,7 @@ export const useUserStore = defineStore({
if (!this.getToken) return null; if (!this.getToken) return null;
// 3、获取用户信息 // 3、获取用户信息
const userInfo = await this.getUserInfoAction(); const userInfo = await this.getUserInfoAction();
console.log('userInfo',userInfo) console.log('userInfo', userInfo);
const sessionTimeout = this.sessionTimeout; const sessionTimeout = this.sessionTimeout;
if (sessionTimeout) { if (sessionTimeout) {
this.setSessionTimeout(false); this.setSessionTimeout(false);
...@@ -129,8 +129,8 @@ export const useUserStore = defineStore({ ...@@ -129,8 +129,8 @@ 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'); var type = localStorage.getItem('type');
if (type === null){ if (type === null) {
type = '1' type = '1';
} }
const 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) {
...@@ -139,9 +139,9 @@ export const useUserStore = defineStore({ ...@@ -139,9 +139,9 @@ export const useUserStore = defineStore({
this.setRoleList(['ROLE_DEFAULT']); this.setRoleList(['ROLE_DEFAULT']);
} }
// 获取动态路由下的第一个菜单路径 // 获取动态路由下的第一个菜单路径
const firstChild = await this.getFirstChild(userInfo.data.menus[0]) const firstChild = await this.getFirstChild(userInfo.data.menus[0]);
// 登陆后进入的第一个页面 // 登陆后进入的第一个页面
userInfo.data.homePath = firstChild userInfo.data.homePath = firstChild;
// 设置用户信息,并存储本地缓存 // 设置用户信息,并存储本地缓存
this.setUserInfo(userInfo.data); this.setUserInfo(userInfo.data);
return userInfo.data; return userInfo.data;
...@@ -149,9 +149,9 @@ export const useUserStore = defineStore({ ...@@ -149,9 +149,9 @@ export const useUserStore = defineStore({
/** 获取动态路由下的第一个菜单路径*/ /** 获取动态路由下的第一个菜单路径*/
getFirstChild(item): Promise<any> { getFirstChild(item): Promise<any> {
if (item.children && item.children.length > 0) { if (item.children && item.children.length > 0) {
return this.getFirstChild(item.children[0]) return this.getFirstChild(item.children[0]);
} else { } else {
return item.path return item.path;
} }
}, },
/** /**
......
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