修复无权限访问菜单时连续报错

This commit is contained in:
z9130 2024-08-07 18:56:54 +08:00
parent 211ef27689
commit 3ecac77bfd
4 changed files with 68 additions and 50 deletions

View File

@ -421,7 +421,7 @@ export const useRouteStore = defineStore(SetupStoreId.Route, () => {
// mapPaths(r, routers);
console.log('[ generatedRoutes2 ] >', r)
let staticRouteKeys = ["home", "403", "404", "500", "login", "iframe_meeting", "iframe_meeting_standing-book"];
let staticRouteKeys = ["home", "403", "404", "500", "login", "message", "message_todo", "user-center", "iframe_meeting", "iframe_meeting_standing-book"];
let userStore = useUserStore()
@ -434,6 +434,10 @@ export const useRouteStore = defineStore(SetupStoreId.Route, () => {
if (!oldRoutes.length) {
window.$message?.error('无访问权限,如需访问请联系管理员');
setTimeout(() => {
authStore.resetStore();
}, 200);
return
throw new Error('无访问权限,如需访问请联系管理员');
}
addAuthRoutes(finalRoutes);

View File

@ -98,11 +98,17 @@ export const useUserStore = defineStore(
userInfo.userName = userInfo.display_name;
if (routeStore.isInitAuthRoute) {
window.$notification?.success({
title: $t('page.login.common.loginSuccess'),
content: $t('page.login.common.welcomeBack', { userName: userInfo.display_name }),
duration: 4500
});
// 防止中途退出但提前显示了登录成功提示
setTimeout(() => {
if (userInfo.display_name) {
window.$notification?.success({
title: $t('page.login.common.loginSuccess'),
content: $t('page.login.common.welcomeBack', { userName: userInfo.display_name }),
duration: 4500
});
}
}, 300);
}
}
} else {

View File

@ -39,9 +39,11 @@ const rules = computed<Record<keyof FormModel, App.Global.FormRule[]>>(() => {
async function handleSubmit() {
await validate();
let username = model.userName;
if (username != "Admin.itl") {
username = username + '.RL';
}
// if (username != "Admin.itl") {
// username = username + '.RL';
// }
username = username + '.RL';
await authStore.login(username, model.password);
}

View File

@ -225,31 +225,7 @@ function handleSubmit(type: "confirm" | "cancel") {
{{ orderTimeArr[0] }} {{ orderTimeArr[1] }}
</n-alert>
<NCard :title="'今日食谱 ' + dayjs().format('YYYY-MM-DD')">
<NDescriptions label-placement="left" label-class="w-150px" bordered>
<NDescriptionsItem :span="3">
<template #label>主食</template>
馒头米饭
</NDescriptionsItem>
<NDescriptionsItem label="堂食菜品" :span="3">
{{
todayRecipeInfo.eatinOpen == "1"
? todayRecipeInfo.eatinRecipe
: "暂未开放"
}}
<!-- <icon-mdi-alert-circle-outline></icon-mdi-alert-circle-outline> -->
</NDescriptionsItem>
<NDescriptionsItem label="派送菜品" :span="3">
{{
todayRecipeInfo.deliveryOpen == "1"
? todayRecipeInfo.deliveryRecipe
: "暂未开放"
}}
<!-- <icon-mdi-alert-circle-outline></icon-mdi-alert-circle-outline> -->
</NDescriptionsItem>
</NDescriptions>
</NCard>
<NCard title="订餐" class="h-full overflow-auto">
<template #header-extra>
@ -346,23 +322,53 @@ function handleSubmit(type: "confirm" | "cancel") {
</NSpace>
</NGridItem>
<NGridItem span="4">
<NCard title="近期食谱" class="h-full overflow-auto">
<n-list>
<template v-for="(item, index) in recipeData2" :key="index">
<n-list-item>
<n-thing :title="item.recipeDate" title-extra="" description="">
<n-p>
堂食菜品 {{ item.eatinOpen == "1" ? item.eatinRecipe : "暂未开放" }}
</n-p>
<n-p>
派送菜品
{{ item.deliveryOpen == "1" ? item.deliveryRecipe : "暂未开放" }}
</n-p>
</n-thing>
</n-list-item>
</template>
</n-list>
</NCard>
<NSpace vertical class="h-full" :wrap-item="false">
<NCard :title="'今日食谱 ' + dayjs().format('YYYY-MM-DD')">
<NDescriptions label-placement="left" label-class="w-150px" bordered>
<NDescriptionsItem :span="3">
<template #label>主食</template>
馒头米饭
</NDescriptionsItem>
<NDescriptionsItem label="堂食菜品" :span="3">
{{
todayRecipeInfo.eatinOpen == "1"
? todayRecipeInfo.eatinRecipe
: "暂未开放"
}}
<!-- <icon-mdi-alert-circle-outline></icon-mdi-alert-circle-outline> -->
</NDescriptionsItem>
<NDescriptionsItem label="派送菜品" :span="3">
{{
todayRecipeInfo.deliveryOpen == "1"
? todayRecipeInfo.deliveryRecipe
: "暂未开放"
}}
<!-- <icon-mdi-alert-circle-outline></icon-mdi-alert-circle-outline> -->
</NDescriptionsItem>
</NDescriptions>
</NCard>
<NCard title="近期食谱" class=" overflow-auto">
<n-list>
<template v-for="(item, index) in recipeData2" :key="index">
<n-list-item>
<n-thing :title="item.recipeDate" title-extra="" description="">
<n-p>
堂食菜品 {{ item.eatinOpen == "1" ? item.eatinRecipe : "暂未开放" }}
</n-p>
<n-p>
派送菜品
{{ item.deliveryOpen == "1" ? item.deliveryRecipe : "暂未开放" }}
</n-p>
</n-thing>
</n-list-item>
</template>
</n-list>
</NCard>
</NSpace>
</NGridItem>
</NGrid>
</div>