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

feat: 新增公告模块、数据加载hook与多项体验优化

- 新增公告全流程功能:首页公告轮播、公告列表页、公告详情页
- 新增统一数据加载状态hook useDataLoading与配套测试
- 重构配置加载逻辑,新增统一bootstrap静态配置拉取
- 新增维护模式、恋爱模块支持与验证码防刷功能
- 优化投票卡片、联系页、关于页UI样式
- 新增测试页面与全局玻璃卡片样式
- 修复markdown容器内边距与首页生命周期逻辑
This commit is contained in:
小莫唐尼
2026-09-04 02:57:25 +08:00
parent 902faa70e7
commit 5f22f4fa01
39 changed files with 4474 additions and 2244 deletions
+71
View File
@@ -124,6 +124,29 @@ export interface IAppConfig {
articleCardType?: string
avatarRadius?: boolean
}
/**
* 维护模式(additive,2026-09-04 插件端 GeneralConfig.spec.maintenance 经 getConfigs
* 下发;仅 scheduled/active 时存在,键缺失=未维护或已到点自动结束)
*/
maintenance?: IPublicMaintenance
[key: string]: unknown
}
/**
* getConfigs 顶层 maintenance 键(插件端输出;status 判定权威在服务端,客户端仅据此
* 展示维护页与倒计时,设计见插件 .docs/maintenance-config-design.md)
*/
export interface IPublicMaintenance {
/** scheduled 维护预告(倒计时至 startTime)/ active 维护中(倒计时至 endTime) */
status: 'scheduled' | 'active'
/** 维护页标题 */
title?: string
/** 维护说明(富文本 HTML,mp-html 渲染) */
description?: string
/** 维护开始时间(RFC3339 UTC 字符串) */
startTime?: string
/** 预计恢复时间(RFC3339 UTC 字符串) */
endTime?: string
[key: string]: unknown
}
@@ -269,6 +292,54 @@ export interface ICommentCaptcha {
[key: string]: unknown
}
/* ---------- 通知公告(plugin-uni-halo notice,2026-09-03 客户端接入) ---------- */
/** 公告公开列表项(脱敏,不含 content;内嵌类型信息 typeDisplayName/typeColor) */
export interface INoticeListVo {
name?: string
title?: string
summary?: string
cover?: string
link?: string
typeName?: string
typeDisplayName?: string
typeColor?: string
priority?: number
/** 发布时间(spec.publishTime,ISO-8601) */
publishTime?: string
}
/** 公告公开分页列表响应(ListResult 形态) */
export interface INoticeListRes {
page?: number
size?: number
total?: number
items: INoticeListVo[]
}
/** 公告详情 spec(完整 Notice + 内嵌 typeDisplayName/typeColor) */
export interface INoticeDetailSpec {
title?: string
/** 富文本 HTML(仅详情返回) */
content?: string
summary?: string
cover?: string
link?: string
typeName?: string
status?: string
priority?: number
publishTime?: string
typeDisplayName?: string
typeColor?: string
}
/** 公告详情(完整 extension 对象: metadata + spec) */
export interface INoticeDetail {
metadata?: { name?: string, [key: string]: unknown }
spec?: INoticeDetailSpec
[key: string]: unknown
}
/* ---------- 恋爱模块(plugin-uni-halo love) ---------- */
export interface ILoveConfig {
+72 -4
View File
@@ -34,6 +34,9 @@ import type {
IMiniProgramLinkGroupedRes,
IMiniProgramLinkGroupOption,
IMiniProgramLinkSubmissionForm,
INoticeDetail,
INoticeListRes,
INoticeListVo,
IQRCodeInfo,
IRestrictReadCheckReq,
IRestrictReadCheckRes,
@@ -109,7 +112,7 @@ export function getCommentWidgetConfig() {
* 检查更新(uhalo-upgrade 插件对接,插件本体引入后业务侧入口)
*/
export function checkVersion(baseUrl: string) {
return http.Get<IResponse<IUpdateCheckRes>>('/apis/api.unihalo.ialley.cn/v1alpha1/plugins/plugin-uni-halo/checkVersion', {
return http.Get<IResponse<IUpdateCheckRes>>('/apis/api.unihalo.ialley.cn/v1alpha1/plugins/plugin-uni-halo/upgrade/checkVersion', {
params: { baseUrl },
meta: { requestFrom: RequestFrom.Halo },
})
@@ -124,6 +127,68 @@ export function getQRCodeInfo(key: string) {
})
}
/* ==================== 防刷验证码(plugin-uni-halo,2026-09-03 客户端接入) ==================== */
/** 防刷验证码(服务端 captcha/generate 返回;受保护写接口 403 时响应体亦附带新验证码) */
export interface IPluginCaptcha {
id: string
imageBase64: string
}
/** 受保护写接口携带的验证码 query(未触发时省略,触发后每次提交都需携带,一次性) */
export interface ICaptchaQuery {
captchaId?: string
captchaCode?: string
}
/**
* 获取防刷验证码(公开;适用 POST /mini-program-links/submissions 与
* /love-albums/{name}/unlock;站点关闭验证码或该功能不在生效范围时无需携带)
*/
export function getPluginCaptcha() {
return http.Get<IResponse<IPluginCaptcha>>('/apis/api.unihalo.ialley.cn/v1alpha1/plugins/plugin-uni-halo/captcha/generate', {
meta: { requestFrom: RequestFrom.Halo },
})
}
/** 仅当携带有效验证码时拼接 query 参数 */
export function buildCaptchaQuery(captcha?: ICaptchaQuery | null): ICaptchaQuery | undefined {
if (!captcha || !captcha.captchaId || !captcha.captchaCode)
return undefined
return { captchaId: captcha.captchaId, captchaCode: captcha.captchaCode }
}
/* ==================== 通知公告(plugin-uni-halo,2026-09-03 客户端接入) ==================== */
/**
* 公告分页列表(公开,仅已发布;脱敏不含 content,内嵌类型信息)。
* 注意:公开接口当前仅支持分页,类型筛选/排序由页面本地聚合处理(公告量小)。
*/
export function getNotices(params: { page?: number, size?: number }) {
return http.Get<IResponse<INoticeListRes>>('/apis/api.unihalo.ialley.cn/v1alpha1/plugins/plugin-uni-halo/notices', {
params,
meta: { requestFrom: RequestFrom.Halo },
})
}
/**
* 最新一条已发布公告(公开;无数据返回 null,供首页/我的弹窗)
*/
export function getNoticeLatest() {
return http.Get<IResponse<INoticeListVo | null>>('/apis/api.unihalo.ialley.cn/v1alpha1/plugins/plugin-uni-halo/notices/latest', {
meta: { requestFrom: RequestFrom.Halo },
})
}
/**
* 公告详情(公开;含 content 富文本 HTML 与内嵌类型信息;不存在/删除中返回 404)
*/
export function getNoticeDetail(name: string) {
return http.Get<IResponse<INoticeDetail>>(`/apis/api.unihalo.ialley.cn/v1alpha1/plugins/plugin-uni-halo/notices/${name}`, {
meta: { requestFrom: RequestFrom.Halo },
})
}
/* ==================== 恋爱模块 ==================== */
/**
@@ -158,13 +223,14 @@ export function getLoveAlbumByName(name: string, params: ILoveAlbumListReq) {
/**
* 密码解锁相册
*/
export function unlockAlbum(name: string, password: string) {
export function unlockAlbum(name: string, password: string, captcha?: ICaptchaQuery | null) {
return http.Post<IResponse<{ token: string, photos?: unknown[] }>>(
`/apis/api.unihalo.ialley.cn/v1alpha1/plugins/plugin-uni-halo/love-albums/${name}/unlock`,
{
password,
},
{
params: buildCaptchaQuery(captcha),
meta: { requestFrom: RequestFrom.Halo },
},
)
@@ -233,15 +299,17 @@ export function getMiniProgramLinkDetail(name: string) {
}
/**
* 提交小程序链接申请(公开接口,落库为待审核;受 linkConfig.submissionEnabled 开关控制)
* 提交小程序链接申请(公开接口,落库为待审核;受 linkConfig.submissionEnabled 开关
* 与防刷验证码 captchaConfig 控制)
*/
export function submitMiniProgramLinkApplication(data: IMiniProgramLinkSubmissionForm) {
export function submitMiniProgramLinkApplication(data: IMiniProgramLinkSubmissionForm, captcha?: ICaptchaQuery | null) {
return http.Post<IResponse<unknown>>(
'/apis/api.unihalo.ialley.cn/v1alpha1/plugins/plugin-uni-halo/mini-program-links/submissions',
{
spec: data,
},
{
params: buildCaptchaQuery(captcha),
meta: { requestFrom: RequestFrom.Halo },
},
)