Merge branch 'developer' into 'master'
1 See merge request scj/zhxy/v3/cloud-ui!3
This commit is contained in:
17
src/App.vue
17
src/App.vue
@@ -65,7 +65,8 @@ async function validateCachedRoleId(): Promise<boolean> {
|
||||
const cachedRoleId = Local.get('roleId');
|
||||
if (cachedRoleId == null || cachedRoleId === '') return false;
|
||||
try {
|
||||
const res = await listAllRole();
|
||||
// 使用 skipRoleHeader 避免带上无效的缓存角色导致接口 403,确保首次即可拿到列表并清除缓存
|
||||
const res = await listAllRole({ skipRoleHeader: true });
|
||||
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));
|
||||
@@ -86,9 +87,17 @@ onMounted(() => {
|
||||
mittBus.on('openRoleSelectDialog', () => {
|
||||
if (roleDialogOpenedThisSession) return;
|
||||
roleDialogOpenedThisSession = true;
|
||||
setTimeout(() => {
|
||||
changeRoleFirRef.value?.open();
|
||||
}, 300);
|
||||
const tryOpen = (attempt = 0) => {
|
||||
const maxAttempts = 25; // 约 2.5 秒内每 100ms 重试
|
||||
if (changeRoleFirRef.value) {
|
||||
changeRoleFirRef.value.open();
|
||||
return;
|
||||
}
|
||||
if (attempt < maxAttempts) {
|
||||
setTimeout(() => tryOpen(attempt + 1), attempt === 0 ? 300 : 100);
|
||||
}
|
||||
};
|
||||
tryOpen();
|
||||
});
|
||||
nextTick(async () => {
|
||||
// 监听布局配置弹窗点击打开
|
||||
|
||||
@@ -158,9 +158,10 @@ export function validateRoleName(rule: any, value: any, callback: any, isEdit: b
|
||||
});
|
||||
}
|
||||
|
||||
export const listAllRole = () => {
|
||||
export const listAllRole = (options?: { skipRoleHeader?: boolean }) => {
|
||||
return request({
|
||||
url: '/admin/role/listAllRole',
|
||||
method: 'get',
|
||||
...options,
|
||||
});
|
||||
};
|
||||
|
||||
@@ -55,11 +55,11 @@ service.interceptors.request.use(
|
||||
}
|
||||
//统一增加 当前角色CODE
|
||||
const roleCode = Session.getRoleCode();
|
||||
if (roleCode) {
|
||||
if (roleCode && !(config as any).skipRoleHeader) {
|
||||
config.headers![CommonHeaderEnum.ROLE_CODE] = roleCode;
|
||||
}
|
||||
const roleId = Session.getRoleId();
|
||||
if (roleId) {
|
||||
if (roleId && !(config as any).skipRoleHeader) {
|
||||
config.headers![CommonHeaderEnum.RRID] = roleId;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user