1
0
mirror of https://github.com/ialley-workshop-open/uni-halo.git synced 2026-11-13 22:11:42 +08:00

refactor: 统一加载状态组件,重构投票相关类型与逻辑,新增维护拦截功能

1. 替换所有页面的wd-skeleton与空状态为uh-data-loading组件
2. 重构投票相关API类型与列表/详情逻辑,适配Halo扩展对象结构
3. 新增维护拦截hook与维护页,统一插件可用性与维护模式检查跳转
4. 优化多个页面的代码结构与样式细节
This commit is contained in:
小莫唐尼
2026-09-04 04:19:50 +08:00
parent d0dd7d7a46
commit 2fbd3fb19a
15 changed files with 987 additions and 178 deletions
+60 -20
View File
@@ -230,27 +230,67 @@ export interface IVoteListReq {
[key: string]: unknown
}
export interface IVoteItem {
name: string
title: string
description?: string
[key: string]: unknown
}
export type IVoteListRes = IVoteItem[]
export interface IVote {
name: string
title: string
description?: string
options?: IVoteOption[]
[key: string]: unknown
}
/** 投票选项(插件 VoteSpec.options:{id,title}) */
export interface IVoteOption {
name?: string
label?: string
count?: number
id?: string
title?: string
[key: string]: unknown
}
/** 投票列表项(Halo 扩展对象,标识在 metadata.name、内容在 spec) */
export interface IVoteItem {
metadata?: { name?: string, [key: string]: unknown }
spec?: {
title?: string
remark?: string
type?: string
[key: string]: unknown
}
[key: string]: unknown
}
/** 投票列表响应(Halo 标准 ListResult 结构,与 posts/categories 等列表接口一致) */
export interface IVoteListRes {
items: IVoteItem[]
page?: number
size?: number
total?: number
hasNext?: boolean
}
/** 投票(Halo 扩展对象) */
export interface IVote {
metadata: { name: string, [key: string]: unknown }
spec?: {
title?: string
remark?: string
type?: 'single' | 'multiple' | 'pk' | string
maxVotes?: number
options?: IVoteOption[]
timeLimit?: 'custom' | 'permanent' | 'thirty' | 'seven' | 'one' | string
startDate?: string
endDate?: string
owner?: string
hasEnded?: boolean
canAnonymously?: boolean
canSeeVoters?: boolean
[key: string]: unknown
}
stats?: {
voteCount?: number
voteUser?: number
voteDataList?: { id?: string, voteCount?: number }[]
}
[key: string]: unknown
}
/** 投票详情(插件 VoteDetail:嵌套 vote + 统计) */
export interface IVoteDetail {
vote: IVote
voteDataList?: { id?: string, voteCount?: number }[]
userVoteData?: string[]
voteCount?: number
voteUser?: number
[key: string]: unknown
}
+2 -2
View File
@@ -42,7 +42,7 @@ import type {
IRestrictReadCheckRes,
ISubmitLinkForm,
IUpdateCheckRes,
IVote,
IVoteDetail,
IVoteListReq,
IVoteListRes,
IVoteSubmitReq,
@@ -381,7 +381,7 @@ export function getVoteList(params: IVoteListReq) {
* 投票详情
*/
export function getVoteDetail(name: string) {
return http.Get<IResponse<IVote>>(`/apis/api.vote.kunkunyu.com/v1alpha1/votes/${name}/detail`, {
return http.Get<IResponse<IVoteDetail>>(`/apis/api.vote.kunkunyu.com/v1alpha1/votes/${name}/detail`, {
meta: { requestFrom: RequestFrom.Halo },
})
}