From 629b1f9219cc6b14bde88681a43359c8ccaf6f8c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=8F=E8=8E=AB=E5=94=90=E5=B0=BC?= Date: Fri, 4 Sep 2026 16:05:09 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E9=87=8D=E6=9E=84=E7=BB=B4?= =?UTF-8?q?=E6=8A=A4=E6=A8=A1=E5=BC=8F=E7=9B=B8=E5=85=B3=E9=80=BB=E8=BE=91?= =?UTF-8?q?=EF=BC=8C=E6=8B=86=E5=88=86=E7=BB=B4=E6=8A=A4=E8=AF=B4=E6=98=8E?= =?UTF-8?q?=E4=B8=8E=E8=AF=A6=E6=83=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 拆分维护接口类型,新增notice和description字段区分纯文本说明与富文本详情 - 重构useMaintenanceIntercept钩子,统一维护拦截逻辑 - 新增维护详情弹窗组件,优化维护页UI与交互 - 修复按钮布局、滚动置顶黑名单等细节问题 - 优化公告弹窗组件样式与代码结构 --- .agents/skills/uni-halo/SKILL.md | 2 +- src/api/types/uni-halo.ts | 4 +- src/components/uh-button/uh-button.vue | 2 +- .../uh-maintenance-detail.vue | 42 ++ .../uh-notify-dialog/uh-notify-dialog.vue | 44 +- .../uh-scroll-top/uh-scroll-top.vue | 12 +- src/hooks/useDataLoadingStatus.ts | 6 +- ...ntercept.ts => useMaintenanceIntercept.ts} | 0 src/pages/index/index.vue | 174 +++-- src/pages/maintenance/maintenance.vue | 601 ++++-------------- src/pages/tabbar/category/category.vue | 323 +++++----- src/pages/tabbar/gallery/gallery.vue | 435 ++++++------- src/pages/tabbar/home/home.vue | 18 +- src/pages/tabbar/moments/moments.vue | 48 +- 14 files changed, 676 insertions(+), 1035 deletions(-) create mode 100644 src/components/uh-maintenance-detail/uh-maintenance-detail.vue rename src/hooks/{use-maintenance-intercept.ts => useMaintenanceIntercept.ts} (100%) diff --git a/.agents/skills/uni-halo/SKILL.md b/.agents/skills/uni-halo/SKILL.md index a34d734..6cf6b0b 100644 --- a/.agents/skills/uni-halo/SKILL.md +++ b/.agents/skills/uni-halo/SKILL.md @@ -534,7 +534,7 @@ function handleSubmit() { 投票状态、自己提交投票,页面只传 `vote-name`、监听 `on-vote-success` 提示 - **页面尽量薄**:页面只负责数据请求编排(hooks)、跳转、传参给组件 - **能抽 hooks 的就抽 hooks**:跨页面复用的业务逻辑放 `src/hooks/`(如 - `use-maintenance-intercept`、`useScroll`、`useUpload`),auto-import 免 import 直接调用 + `useMaintenanceIntercept`、`useScroll`、`useUpload`),auto-import 免 import 直接调用 - 组件不直接依赖 store 的散装字段,通过 props 传入、events 传出,降低耦合 --- diff --git a/src/api/types/uni-halo.ts b/src/api/types/uni-halo.ts index 96bb1be..a6a687a 100644 --- a/src/api/types/uni-halo.ts +++ b/src/api/types/uni-halo.ts @@ -141,7 +141,9 @@ export interface IPublicMaintenance { status: 'scheduled' | 'active' /** 维护页标题 */ title?: string - /** 维护说明(富文本 HTML,mp-html 渲染) */ + /** 维护说明(纯文本,维护页标题下方直接展示,留空展示默认文案) */ + notice?: string + /** 维护详情(富文本 HTML,「维护详情」弹窗内 mp-html 渲染) */ description?: string /** 维护开始时间(RFC3339 UTC 字符串) */ startTime?: string diff --git a/src/components/uh-button/uh-button.vue b/src/components/uh-button/uh-button.vue index d9384c2..e1e95e5 100644 --- a/src/components/uh-button/uh-button.vue +++ b/src/components/uh-button/uh-button.vue @@ -10,7 +10,7 @@ \ No newline at end of file diff --git a/src/components/uh-maintenance-detail/uh-maintenance-detail.vue b/src/components/uh-maintenance-detail/uh-maintenance-detail.vue new file mode 100644 index 0000000..ffcd485 --- /dev/null +++ b/src/components/uh-maintenance-detail/uh-maintenance-detail.vue @@ -0,0 +1,42 @@ + + + \ No newline at end of file diff --git a/src/components/uh-notify-dialog/uh-notify-dialog.vue b/src/components/uh-notify-dialog/uh-notify-dialog.vue index 8797385..4215130 100644 --- a/src/components/uh-notify-dialog/uh-notify-dialog.vue +++ b/src/components/uh-notify-dialog/uh-notify-dialog.vue @@ -1,12 +1,4 @@ \ No newline at end of file diff --git a/src/pages/maintenance/maintenance.vue b/src/pages/maintenance/maintenance.vue index 914de14..a7e8ec2 100644 --- a/src/pages/maintenance/maintenance.vue +++ b/src/pages/maintenance/maintenance.vue @@ -3,7 +3,6 @@ import { onLoad, onUnload } from '@dcloudio/uni-app' import { useAppConfigStore } from '@/store/appConfig' import { checkUrl } from '@/utils/url' - import { markdownConfig } from '@/config/markdown' import { usePluginAvailable } from '@/utils/plugin' import type { IPublicMaintenance } from '@/api/types/uni-halo' @@ -34,6 +33,8 @@ const spinning = ref(false) /** Toast 文案(空 = 隐藏) */ const toast = ref('') + /** 「维护详情」弹窗显隐 */ + const showDetail = ref(false) let timer : ReturnType | null = null let recoveryTimer : ReturnType | null = null let toastTimer : ReturnType | null = null @@ -42,8 +43,10 @@ const isIntercepted = computed(() => !!fromReason.value) const isScheduled = computed(() => maintenance.value?.status === 'scheduled') const title = computed(() => maintenance.value?.title || DEFAULT_MAINTENANCE_TITLE) - /** 配置的富文本说明(未配置时展示设计稿默认文案) */ - const description = computed(() => maintenance.value?.description || '') + /** 维护详情(富文本 HTML;小程序端「维护详情」弹窗内 mp-html 渲染) */ + const detailHtml = computed(() => maintenance.value?.description || '') + /** 维护说明(纯文本;标题下方按行直接展示,留空展示设计稿默认文案) */ + const noticeLines = computed(() => (maintenance.value?.notice || '').split('\n')) /** 应用信息 logo(相对插件内置资源路径 → BASE_API 补全) */ const appLogo = computed(() => { @@ -137,7 +140,8 @@ * 拉取失败(服务器停机)保持维护页不打扰。 */ async function silentCheck() { - if (refreshing) { return } + if (refreshing) + return refreshing = true try { await store.bootstrap({ force: true }) @@ -189,14 +193,12 @@ startRecoveryCheck() } else if (isIntercepted.value) { - // 拦截场景无维护信息(插件未激活/未配置)→ 默认文案 maintenance.value = null viewState.value = 'maintenance' startRecoveryCheck() } else if (ok) { - // 拉取成功但无 maintenance 键:未维护(或已到点自动结束)→ 服务正常 - viewState.value = 'normal' + goIndex() } else { viewState.value = 'error' @@ -251,7 +253,7 @@ onLoad((options) => { const from = options?.from fromReason.value = from === 'plugin' || from === 'maintenance' ? from : null - void load() + load() }) onUnload(() => { @@ -264,142 +266,153 @@ \ No newline at end of file diff --git a/src/pages/tabbar/category/category.vue b/src/pages/tabbar/category/category.vue index 8c85ccf..0fef65d 100644 --- a/src/pages/tabbar/category/category.vue +++ b/src/pages/tabbar/category/category.vue @@ -1,186 +1,181 @@ + + + + + + + + {{ item.spec.displayName }} + + + 共 {{ item.postCount }} 篇文章 + + + + + + {{ loadMoreText }} + + + + \ No newline at end of file diff --git a/src/pages/tabbar/gallery/gallery.vue b/src/pages/tabbar/gallery/gallery.vue index d53b73a..50d8576 100644 --- a/src/pages/tabbar/gallery/gallery.vue +++ b/src/pages/tabbar/gallery/gallery.vue @@ -1,250 +1,233 @@ + + \ No newline at end of file diff --git a/src/pages/tabbar/home/home.vue b/src/pages/tabbar/home/home.vue index 98ef5f6..e1f6b4b 100644 --- a/src/pages/tabbar/home/home.vue +++ b/src/pages/tabbar/home/home.vue @@ -6,6 +6,7 @@ import { useSettingStore } from '@/store/setting' import { checkAvatarUrl, checkImageUrl } from '@/utils/url' import { t } from '@/locale' + import { useMaintenanceIntercept } from '@/hooks/useMaintenanceIntercept' import type { IPost } from '@/api/types/halo' definePage({ @@ -146,12 +147,20 @@ }, }) } - + + function init(){ + if (!intercepted.value) { + handleQuery() + } + } + init() + /* ---------------- 生命周期 ---------------- */ // 维护检查 onShow(async () => { intercepted.value = await interceptOrContinue() + console.log('拦截状态', intercepted.value) }) onPullDownRefresh(() => { @@ -175,13 +184,6 @@ } }) - // 首次加载 - onMounted(() => { - if (intercepted.value) { - return - } - handleQuery() - })