import { computed, ref } from "vue"; const ROLES = [ { key: "ADMIN", label: "系统管理员" }, { key: "RECEPTIONIST", label: "受理员" }, { key: "ASSESSOR", label: "评估员" }, { key: "PLANNER", label: "方案制定员" }, { key: "DISPATCHER", label: "调度员" }, { key: "STAFF", label: "服务人员" }, { key: "SETTLER", label: "结算员" }, { key: "SUPERVISOR", label: "监管员" }, { key: "REVIEWER", label: "复核员" } ]; const PRESET_USERS = { admin: { userId: "1", userName: "系统管理员", userRole: "ADMIN", tenantId: "1", orgId: "1" }, receptionist: { userId: "2", userName: "受理员小王", userRole: "RECEPTIONIST", tenantId: "1", orgId: "1" }, assessor: { userId: "3", userName: "评估员老张", userRole: "ASSESSOR", tenantId: "1", orgId: "1" }, planner: { userId: "4", userName: "方案员小李", userRole: "PLANNER", tenantId: "1", orgId: "1" }, dispatcher: { userId: "5", userName: "调度员老赵", userRole: "DISPATCHER", tenantId: "1", orgId: "1" }, staff: { userId: "6", userName: "护理员老陈", userRole: "STAFF", tenantId: "1", orgId: "1" }, settler: { userId: "7", userName: "结算员小周", userRole: "SETTLER", tenantId: "1", orgId: "1" }, supervisor: { userId: "8", userName: "监管员老刘", userRole: "SUPERVISOR", tenantId: "1", orgId: "1" } }; const STORAGE_KEY = "hss_platform_user"; const currentUser = ref(null); function loadUser() { try { const stored = localStorage.getItem(STORAGE_KEY); return stored ? JSON.parse(stored) : null; } catch { return null; } } function saveUser(user) { localStorage.setItem(STORAGE_KEY, JSON.stringify(user)); currentUser.value = user; } function clearUser() { localStorage.removeItem(STORAGE_KEY); currentUser.value = null; } function usePlatformAuth() { if (!currentUser.value) { currentUser.value = loadUser(); } const isLoggedIn = computed(() => !!currentUser.value); const user = computed(() => currentUser.value); function login(username) { const u = PRESET_USERS[username.toLowerCase()]; if (u) { saveUser(u); return u; } return null; } function logout() { clearUser(); } function switchRole(roleKey) { if (!currentUser.value) return; const updated = { ...currentUser.value, userRole: roleKey }; saveUser(updated); } function getAuthHeaders() { const u = currentUser.value; if (!u) return {}; return { "X-User-Id": u.userId, "X-User-Role": u.userRole, "X-Tenant-Id": u.tenantId, "X-Org-Id": u.orgId, "Content-Type": "application/json" }; } return { isLoggedIn, user, login, logout, switchRole, getAuthHeaders, ROLES, PRESET_USERS }; } export { usePlatformAuth as u }; //# sourceMappingURL=usePlatformAuth-DS6-BJES.js.map