This commit is contained in:
吴红兵
2026-03-07 01:34:48 +08:00
parent adc511cfdc
commit 94c3473958
1211 changed files with 599405 additions and 322105 deletions

View File

@@ -58,7 +58,7 @@ onBeforeMount(() => {
setIntroduction.jsCdn();
});
// 角色选择弹框是否已在本轮打开过(防止事件被触发两次)
let roleDialogOpenedThisSession = false
let roleDialogOpenedThisSession = false;
/** 校验缓存中的 roleId 是否仍在 listAllRole 结果中;若不存在则清除 roleId/roleCode/roleName 并返回 true需要弹框 */
async function validateCachedRoleId(): Promise<boolean> {
@@ -67,14 +67,8 @@ async function validateCachedRoleId(): Promise<boolean> {
try {
const res = await listAllRole();
const data = res?.data;
const allRoles: any[] = Array.isArray(data)
? data
: data && typeof data === 'object'
? (Object.values(data) as any[]).flat()
: [];
const exists = allRoles.some(
(r: any) => r && String(r.roleId) === String(cachedRoleId)
);
const allRoles: any[] = Array.isArray(data) ? data : data && typeof data === 'object' ? (Object.values(data) as any[]).flat() : [];
const exists = allRoles.some((r: any) => r && String(r.roleId) === String(cachedRoleId));
if (!exists) {
Local.remove('roleId');
Local.remove('roleCode');
@@ -90,12 +84,12 @@ async function validateCachedRoleId(): Promise<boolean> {
onMounted(() => {
// 唯一入口:只通过事件打开,且只打开一次;延迟打开以等待异步组件挂载
mittBus.on('openRoleSelectDialog', () => {
if (roleDialogOpenedThisSession) return
roleDialogOpenedThisSession = true
if (roleDialogOpenedThisSession) return;
roleDialogOpenedThisSession = true;
setTimeout(() => {
changeRoleFirRef.value?.open()
}, 300)
})
changeRoleFirRef.value?.open();
}, 300);
});
nextTick(async () => {
// 监听布局配置弹窗点击打开
mittBus.on('openSettingsDrawer', () => {
@@ -121,7 +115,7 @@ onMounted(() => {
mittBus.emit('openRoleSelectDialog');
}
}
})
});
});
// 页面销毁时,关闭监听
onUnmounted(() => {