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:
2026-05-19 09:04:49 +08:00
parent 46c7887a18
commit c02029a5f3
471 changed files with 42313 additions and 2 deletions

View File

@@ -0,0 +1,54 @@
type ApiResponse<T> = {
code: number | string
message: string
data: T
requestId?: string
timestamp?: number
}
const BASE = typeof window !== 'undefined'
? window.location.protocol + '//' + window.location.host + '/api/hss'
: '/api/hss'
export function useApi() {
function headers(extra?: Record<string, string>): Record<string, string> {
const h: Record<string, string> = { 'Content-Type': 'application/json', 'X-Tenant-Id': '1', 'X-Org-Id': '1' }
if (typeof window !== 'undefined') {
const stored = localStorage.getItem('hss_platform_user')
if (stored) {
try {
const u = JSON.parse(stored)
h['X-User-Id'] = u.userId
h['X-User-Role'] = u.userRole
h['X-Tenant-Id'] = u.tenantId
h['X-Org-Id'] = u.orgId
} catch {}
}
}
return { ...h, ...extra }
}
async function get<T>(path: string): Promise<T> {
const res = await $fetch<ApiResponse<T>>(BASE + path, { headers: headers() })
if (typeof res.code === 'string' ? (res.code !== '200' && res.code !== 'SUCCESS') : res.code !== 200) {
throw new Error(res.message || 'API error')
}
return res.data
}
async function post<T>(path: string, body?: any): Promise<T> {
const h = headers()
if (body) h['Idempotency-Key'] = 'web-' + Date.now() + '-' + Math.random().toString(36).slice(2, 8)
const res = await $fetch<ApiResponse<T>>(BASE + path, { method: 'POST', headers: h, body: body ? JSON.stringify(body) : undefined })
if (typeof res.code === 'string' ? (res.code !== '200' && res.code !== 'SUCCESS') : res.code !== 200) {
throw new Error(res.message || 'API error')
}
return res.data
}
async function rawGet<T>(path: string): Promise<ApiResponse<T>> {
return await $fetch<ApiResponse<T>>(BASE + path, { headers: headers() })
}
return { get, post, rawGet }
}

View File

@@ -0,0 +1,101 @@
import { ref } from 'vue'
type LeadType = 'demo' | 'download' | 'contact'
type ApiResponse<T = unknown> = {
code: number | string
message: string
data?: T
requestId?: string
timestamp?: string | number
}
export type LeadForm = {
name: string
orgName: string
phone: string
city?: string
position?: string
focusArea?: string
contact?: string
message?: string
type: LeadType
extra?: Record<string, string>
}
function isSuccess(code: number | string): boolean {
return code === 200 || code === '200' || code === 'SUCCESS'
}
function validatePhone(phone: string): boolean {
return /^1[3-9]\d{9}$/.test(phone)
}
export function useLeadForm(type: LeadType) {
const config = useRuntimeConfig()
const loading = ref(false)
const success = ref(false)
const error = ref('')
const form = ref<LeadForm>({
name: '',
orgName: '',
phone: '',
type
})
async function submit() {
error.value = ''
if (!form.value.name.trim()) {
error.value = '请填写姓名'
return
}
if (!form.value.orgName.trim()) {
error.value = '请填写单位名称'
return
}
if (!validatePhone(form.value.phone)) {
error.value = '请填写正确的手机号'
return
}
loading.value = true
try {
if (config.public.useMockLead) {
await new Promise(resolve => setTimeout(resolve, 600))
success.value = true
loading.value = false
return
}
const res = await $fetch<ApiResponse>(`${config.public.apiPrefix}/leads`, {
method: 'POST',
body: {
...form.value,
source: 'official_website',
submittedAt: new Date().toISOString()
}
})
if (isSuccess(res.code)) {
success.value = true
} else {
error.value = res.message || '提交失败,请稍后重试'
}
} catch (e: any) {
error.value = e?.data?.message || e?.message || '网络异常,请稍后重试'
} finally {
loading.value = false
}
}
function reset() {
success.value = false
error.value = ''
}
return { form, loading, success, error, submit, reset }
}

View File

@@ -0,0 +1,90 @@
import { ref, computed } from 'vue'
export interface PlatformUser {
userId: string
userName: string
userRole: string
tenantId: string
orgId: string
}
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: Record<string, PlatformUser> = {
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<PlatformUser | null>(null)
function loadUser(): PlatformUser | null {
try {
const stored = localStorage.getItem(STORAGE_KEY)
return stored ? JSON.parse(stored) : null
} catch { return null }
}
function saveUser(user: PlatformUser) {
localStorage.setItem(STORAGE_KEY, JSON.stringify(user))
currentUser.value = user
}
function clearUser() {
localStorage.removeItem(STORAGE_KEY)
currentUser.value = null
}
export function usePlatformAuth() {
if (!currentUser.value) {
currentUser.value = loadUser()
}
const isLoggedIn = computed(() => !!currentUser.value)
const user = computed(() => currentUser.value)
function login(username: string): PlatformUser | null {
const u = PRESET_USERS[username.toLowerCase()]
if (u) { saveUser(u); return u }
return null
}
function logout() { clearUser() }
function switchRole(roleKey: string) {
if (!currentUser.value) return
const updated = { ...currentUser.value, userRole: roleKey }
saveUser(updated)
}
function getAuthHeaders(): Record<string, string> {
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 }
}

View File

@@ -0,0 +1,40 @@
import { ref, onMounted, onBeforeUnmount } from 'vue'
interface ScrollAnimOptions {
delay?: number
class?: string
threshold?: number
}
export function useScrollAnim(options: ScrollAnimOptions = {}) {
const { delay = 0, threshold = 0.15 } = options
const isVisible = ref(false)
let observer: IntersectionObserver | null = null
function observe(el: Element, overrides: ScrollAnimOptions = {}) {
const d = overrides.delay ?? delay
const cls = overrides.class ?? 'flow-visible'
observer = new IntersectionObserver(
(entries) => {
entries.forEach((entry) => {
if (entry.isIntersecting) {
setTimeout(() => {
entry.target.classList.add(cls)
}, d)
observer?.unobserve(entry.target)
}
})
},
{ threshold }
)
observer.observe(el)
}
function unobserveAll() {
observer?.disconnect()
}
onBeforeUnmount(() => unobserveAll())
return { isVisible, observe, unobserve: unobserveAll }
}

View File

@@ -0,0 +1,13 @@
import type { UseSeoMetaInput } from '@unhead/vue'
export function useSeo(overrides: Partial<UseSeoMetaInput> = {}) {
useSeoMeta({
title: '首页',
ogTitle: '智慧医养居家上门服务平台',
description: '面向政府、医院与养老机构的智慧医养居家上门服务闭环管理平台,覆盖申请、评估、方案、派单、执行、监管、验收、结算全流程。',
ogDescription: '面向政府、医院与养老机构的智慧医养居家上门服务闭环管理平台。',
ogImage: '/og-image.png',
twitterCard: 'summary_large_image',
...overrides,
})
}