fix: vConsole 异步加载 tags 后不显示的问题
getTags() 在 setCurrentUser() 之后异步执行,原 watch 无 deep:true 导致 store.current.tags 被 mutation 后不触发可见性更新。 - 原 watch 添加 deep:true - 提取 updateVConsoleVisibility 函数 - 新增独立 watch 监听 store.current.tags 变化 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
+11
@@ -77,6 +77,10 @@ export default defineComponent({
|
||||
})
|
||||
|
||||
watch(() => store.current, () => {
|
||||
updateVConsoleVisibility();
|
||||
}, { deep: true })
|
||||
|
||||
function updateVConsoleVisibility() {
|
||||
// vConsole 仅对 sudoer(有 SYS_CAN_SUDO tag)用户可见
|
||||
let showVConsole = store.current.tags?.some(t => t.tag_name === 'SYS_CAN_SUDO') ?? false;
|
||||
console.log('vconsole visibility (sudoer only)...', { showVConsole, tags: store.current.tags });
|
||||
@@ -84,6 +88,13 @@ export default defineComponent({
|
||||
if (vconsole) {
|
||||
vconsole.hidden = !showVConsole;
|
||||
}
|
||||
}
|
||||
|
||||
// 同时监听 tags 的独立变化(getTags 异步加载完成后触发)
|
||||
watch(() => store.current.tags, (val) => {
|
||||
if (val && val.length > 0) {
|
||||
updateVConsoleVisibility();
|
||||
}
|
||||
})
|
||||
|
||||
const tab_change_check = (name: number | string) => {
|
||||
|
||||
Reference in New Issue
Block a user