优化审核入口权限刷新逻辑

This commit is contained in:
kx_guo 2026-09-18 13:46:14 +08:00
parent d04e8888cb
commit 31e5325cc6
3 changed files with 26 additions and 15 deletions

View File

@ -15,7 +15,12 @@ import { ref } from "vue";
import { featureFlags } from "@/config/features";
defineProps<{ modelValue: string; loading: boolean; canUpload: boolean }>();
const props = defineProps<{
modelValue: string;
loading: boolean;
canUpload: boolean;
canReview: boolean;
}>();
const emit = defineEmits<{
"update:modelValue": [value: string];
@ -153,21 +158,22 @@ const functions: Array<{
</form>
<div class="function-grid">
<button
v-for="item in functions"
:key="item.title"
class="function-card"
type="button"
@click="emit('tool', item.tool)"
>
<span class="function-dot" :class="`function-dot--${item.tone}`"></span>
<component :is="item.icon" :size="13" />
<span v-if="item.isNew" class="function-new">新</span>
<span
><strong>{{ item.title }}</strong
><small>{{ item.description }}</small></span
<template v-for="item in functions" :key="item.title">
<button
v-if="item.tool !== 'review' || props.canReview"
class="function-card"
type="button"
@click="emit('tool', item.tool)"
>
</button>
<span class="function-dot" :class="`function-dot--${item.tone}`"></span>
<component :is="item.icon" :size="13" />
<span v-if="item.isNew" class="function-new">新</span>
<span
><strong>{{ item.title }}</strong
><small>{{ item.description }}</small></span
>
</button>
</template>
</div>
</div>
</template>

View File

@ -681,6 +681,7 @@ async function scrollToBottom(behavior: "smooth" | "auto" = "smooth") {
v-model="prompt"
:loading="loading"
:can-upload="auth.hasPermission('risk_item.submit')"
:can-review="auth.hasPermission('risk_item.review')"
@submit="submit"
@select="usePrompt"
@tool="openTool"

View File

@ -24,6 +24,10 @@ router.beforeEach(async (to) => {
return { name: "login", query: { redirect: to.fullPath } };
}
const permission = to.meta.permission;
// Refresh the permission snapshot before protected navigation. A role or
// permission changed directly in the database must take effect without
// requiring the user to clear the old browser session first.
if (typeof permission === "string" && auth.token) await auth.restore();
if (typeof permission === "string" && !auth.hasPermission(permission))
return { name: "assessment" };
return true;