完善个人中心页面

This commit is contained in:
Eamon
2026-09-04 13:21:47 +08:00
parent 6d6d300203
commit f59e929843
27 changed files with 614 additions and 414 deletions

View File

@@ -0,0 +1,41 @@
import { create } from "zustand"
import { fetchAgreementStatus } from "@/api/agreement"
import { fetchApiIndex } from "@/api/dashboard"
import type { ApiIndexItem } from "@/lib/models/dashboard"
// ==================== 个人中心账户总览 ====================
// 数据源:.NET /user/ApiIndex;协议签署状态:php-api /tencent/index/get_is_upload
export type DashboardState = {
data: ApiIndexItem | null
agreementSigned: boolean | null
loading: boolean
error: string | null
}
type DashboardActions = {
refresh: () => Promise<void>
refreshAgreement: () => Promise<void>
}
export type DashboardStore = DashboardState & DashboardActions
export const useDashboardStore = create<DashboardStore>()(set => ({
data: null,
agreementSigned: null,
loading: false,
error: null,
refresh: async () => {
set({ loading: true })
const res = await fetchApiIndex()
if (res.success) {
set({ data: res.data, error: null, loading: false })
} else {
set({ error: res.message, loading: false })
}
},
refreshAgreement: async () => {
const res = await fetchAgreementStatus()
if (res.success) set({ agreementSigned: res.data })
},
}))