feat: 初始化居家上门服务系统完整项目代码
- Spring Boot 后端服务 (hss-home-service) - delivery-miniapp 配送小程序 - website 官网 (Nuxt) - docs 架构设计文档 - Docker 容器化部署配置 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,79 @@
|
||||
import { computed, ref } from 'file:///home/akoo/%E5%B1%85%E5%AE%B6%E6%9C%8D%E5%8A%A1/hss-home-service/website/node_modules/vue/index.mjs';
|
||||
|
||||
const ROLES = [
|
||||
{ key: "ADMIN", label: "\u7CFB\u7EDF\u7BA1\u7406\u5458" },
|
||||
{ key: "RECEPTIONIST", label: "\u53D7\u7406\u5458" },
|
||||
{ key: "ASSESSOR", label: "\u8BC4\u4F30\u5458" },
|
||||
{ key: "PLANNER", label: "\u65B9\u6848\u5236\u5B9A\u5458" },
|
||||
{ key: "DISPATCHER", label: "\u8C03\u5EA6\u5458" },
|
||||
{ key: "STAFF", label: "\u670D\u52A1\u4EBA\u5458" },
|
||||
{ key: "SETTLER", label: "\u7ED3\u7B97\u5458" },
|
||||
{ key: "SUPERVISOR", label: "\u76D1\u7BA1\u5458" },
|
||||
{ key: "REVIEWER", label: "\u590D\u6838\u5458" }
|
||||
];
|
||||
const PRESET_USERS = {
|
||||
admin: { userId: "1", userName: "\u7CFB\u7EDF\u7BA1\u7406\u5458", userRole: "ADMIN", tenantId: "1", orgId: "1" },
|
||||
receptionist: { userId: "2", userName: "\u53D7\u7406\u5458\u5C0F\u738B", userRole: "RECEPTIONIST", tenantId: "1", orgId: "1" },
|
||||
assessor: { userId: "3", userName: "\u8BC4\u4F30\u5458\u8001\u5F20", userRole: "ASSESSOR", tenantId: "1", orgId: "1" },
|
||||
planner: { userId: "4", userName: "\u65B9\u6848\u5458\u5C0F\u674E", userRole: "PLANNER", tenantId: "1", orgId: "1" },
|
||||
dispatcher: { userId: "5", userName: "\u8C03\u5EA6\u5458\u8001\u8D75", userRole: "DISPATCHER", tenantId: "1", orgId: "1" },
|
||||
staff: { userId: "6", userName: "\u62A4\u7406\u5458\u8001\u9648", userRole: "STAFF", tenantId: "1", orgId: "1" },
|
||||
settler: { userId: "7", userName: "\u7ED3\u7B97\u5458\u5C0F\u5468", userRole: "SETTLER", tenantId: "1", orgId: "1" },
|
||||
supervisor: { userId: "8", userName: "\u76D1\u7BA1\u5458\u8001\u5218", 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.mjs.map
|
||||
Reference in New Issue
Block a user