import { Local } from '/@/utils/storage';

/** Local 是否缺少角色信息（缺任一则需弹出角色选择） */
export function needRoleSelection(): boolean {
	try {
		const roleCode = Local.get('roleCode');
		const roleName = Local.get('roleName');
		const roleId = Local.get('roleId');
		return !roleCode || !roleName || !roleId;
	} catch {
		return true;
	}
}

/** 角色选择弹框是否已触发（防止多请求同时触发时重复弹出） */
let roleDialogTriggered = false;

export function isRoleDialogTriggered(): boolean {
	return roleDialogTriggered;
}

export function setRoleDialogTriggered(value: boolean): void {
	roleDialogTriggered = value;
}
