优化审核入口权限刷新逻辑
This commit is contained in:
parent
d04e8888cb
commit
31e5325cc6
@ -15,7 +15,12 @@ import { ref } from "vue";
|
|||||||
|
|
||||||
import { featureFlags } from "@/config/features";
|
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<{
|
const emit = defineEmits<{
|
||||||
"update:modelValue": [value: string];
|
"update:modelValue": [value: string];
|
||||||
@ -153,21 +158,22 @@ const functions: Array<{
|
|||||||
</form>
|
</form>
|
||||||
|
|
||||||
<div class="function-grid">
|
<div class="function-grid">
|
||||||
<button
|
<template v-for="item in functions" :key="item.title">
|
||||||
v-for="item in functions"
|
<button
|
||||||
:key="item.title"
|
v-if="item.tool !== 'review' || props.canReview"
|
||||||
class="function-card"
|
class="function-card"
|
||||||
type="button"
|
type="button"
|
||||||
@click="emit('tool', item.tool)"
|
@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
|
|
||||||
>
|
>
|
||||||
</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>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@ -681,6 +681,7 @@ async function scrollToBottom(behavior: "smooth" | "auto" = "smooth") {
|
|||||||
v-model="prompt"
|
v-model="prompt"
|
||||||
:loading="loading"
|
:loading="loading"
|
||||||
:can-upload="auth.hasPermission('risk_item.submit')"
|
:can-upload="auth.hasPermission('risk_item.submit')"
|
||||||
|
:can-review="auth.hasPermission('risk_item.review')"
|
||||||
@submit="submit"
|
@submit="submit"
|
||||||
@select="usePrompt"
|
@select="usePrompt"
|
||||||
@tool="openTool"
|
@tool="openTool"
|
||||||
|
|||||||
@ -24,6 +24,10 @@ router.beforeEach(async (to) => {
|
|||||||
return { name: "login", query: { redirect: to.fullPath } };
|
return { name: "login", query: { redirect: to.fullPath } };
|
||||||
}
|
}
|
||||||
const permission = to.meta.permission;
|
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))
|
if (typeof permission === "string" && !auth.hasPermission(permission))
|
||||||
return { name: "assessment" };
|
return { name: "assessment" };
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user