mirror of
https://github.com/ialley-workshop-open/uni-halo.git
synced 2026-11-13 22:11:42 +08:00
refactor: 重构维护模式相关逻辑,拆分维护说明与详情
- 拆分维护接口类型,新增notice和description字段区分纯文本说明与富文本详情 - 重构useMaintenanceIntercept钩子,统一维护拦截逻辑 - 新增维护详情弹窗组件,优化维护页UI与交互 - 修复按钮布局、滚动置顶黑名单等细节问题 - 优化公告弹窗组件样式与代码结构
This commit is contained in:
@@ -10,7 +10,7 @@
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<view v-bind="attrs" class="bg-primary uh-shadow-xs text-black text-sm px-4 py-1.5 rounded-lg" :class="props.customClass">
|
||||
<view v-bind="attrs" class="bg-primary uh-shadow-xs text-black flex items-center justify-center text-sm px-4 py-1.5 rounded-lg" :class="props.customClass">
|
||||
<slot></slot>
|
||||
</view>
|
||||
</template>
|
||||
@@ -0,0 +1,42 @@
|
||||
<script lang="ts" setup>
|
||||
import { computed } from 'vue'
|
||||
import { markdownConfig } from '@/config/markdown'
|
||||
|
||||
const props = withDefaults(defineProps<{
|
||||
modelValue ?: boolean
|
||||
content ?: string
|
||||
}>(), {
|
||||
modelValue: false,
|
||||
content: '',
|
||||
})
|
||||
|
||||
const emit = defineEmits<{
|
||||
(e : 'update:modelValue', value : boolean) : void
|
||||
}>()
|
||||
|
||||
const show = computed({
|
||||
get: () => props.modelValue,
|
||||
set: (value : boolean) => {
|
||||
emit('update:modelValue', value)
|
||||
},
|
||||
})
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<wd-popup v-model="show" position="bottom" :z-index="200" :safe-area-inset-bottom="true" closable
|
||||
custom-class="rounded-lt-4 rounded-rt-4">
|
||||
<view class="flex flex-col bg-white">
|
||||
<view class="box-border px-4 py-4 text-center">
|
||||
<text class="text-[30rpx] text-[#17181a] font-bold">
|
||||
维护详情
|
||||
</text>
|
||||
</view>
|
||||
<scroll-view scroll-y
|
||||
class="box-border max-h-[60vh] px-[32rpx] pb-4 text-[26rpx] text-[#3a3e44] leading-[1.8]">
|
||||
<mp-html :content="content" lazy-load :domain="markdownConfig.domain ?? ''" scroll-table selectable
|
||||
:tag-style="markdownConfig.tagStyle" :container-style="markdownConfig.containStyle"
|
||||
copy-by-long-press />
|
||||
</scroll-view>
|
||||
</view>
|
||||
</wd-popup>
|
||||
</template>
|
||||
@@ -1,12 +1,4 @@
|
||||
<script lang="ts" setup>
|
||||
/**
|
||||
* 通知/最新公告弹窗(源自旧项目 components/notify-dialog,2026-09-03 改造为
|
||||
* plugin-uni-halo 最新公告自治宿主):挂载后自动拉取 GET /notices/latest,
|
||||
* 「今日已看」命中(键 notice_latest_{name}_{yyyyMMdd})则不打扰;
|
||||
* 「不再提醒/查看全文」写今日键;查看全文跳公告详情页。
|
||||
* 放置:页面模板中直接 <uh-notify-dialog /> 即可(easycom)。
|
||||
* UIUX 见 .docs/notice-module-client-design.md
|
||||
*/
|
||||
import { onMounted, ref } from 'vue'
|
||||
import { getNoticeLatest } from '@/api/uni-halo'
|
||||
import { getCache, setCache } from '@/utils/storage'
|
||||
@@ -89,23 +81,23 @@ onMounted(() => {
|
||||
<wd-popup
|
||||
v-model="isShow"
|
||||
position="center"
|
||||
width="80vw"
|
||||
custom-style="border-radius:16rpx;"
|
||||
custom-class="rounded-xl"
|
||||
z-index="9999"
|
||||
@close="handleClose"
|
||||
>
|
||||
<view v-if="notice" class="uh-notify-dialog box-border w-[80vw] p-6">
|
||||
<view v-if="notice" class="box-border w-[80vw] p-6">
|
||||
<!-- 头部:标题 + 关闭 -->
|
||||
<view class="flex items-center justify-between">
|
||||
<view class="flex items-center gap-2">
|
||||
<text class="text-[28rpx]">
|
||||
<text class="text-sm">
|
||||
📢
|
||||
</text>
|
||||
<text class="text-[30rpx] font-bold text-[#333]">
|
||||
<text class="text-md font-bold text-gray-900">
|
||||
最新公告
|
||||
</text>
|
||||
<view
|
||||
v-if="notice.typeDisplayName"
|
||||
class="rounded px-1.5 py-0.5 text-[20rpx]"
|
||||
class="rounded px-1.5 py-0.5 text-xs"
|
||||
:style="{
|
||||
color: notice.typeColor || '#f83856',
|
||||
backgroundColor: notice.typeColor ? `${notice.typeColor}1a` : '#fdeef1',
|
||||
@@ -114,7 +106,7 @@ onMounted(() => {
|
||||
{{ notice.typeDisplayName }}
|
||||
</view>
|
||||
</view>
|
||||
<view class="flex h-8 w-8 items-center justify-center text-[#bbb]" @click="handleClose">
|
||||
<view class="flex h-8 w-8 items-center justify-center text-gray-500" @click="handleClose">
|
||||
<wd-icon name="close" size="16px" />
|
||||
</view>
|
||||
</view>
|
||||
@@ -124,29 +116,23 @@ onMounted(() => {
|
||||
<view class="text-[32rpx] font-bold leading-snug text-[#222]">
|
||||
{{ notice.title }}
|
||||
</view>
|
||||
<view v-if="notice.summary" class="mt-3 text-[26rpx] leading-relaxed text-[#666]">
|
||||
<view v-if="notice.summary" class="mt-3 text-[26rpx] leading-relaxed text-gray-500">
|
||||
{{ notice.summary }}
|
||||
</view>
|
||||
<view v-if="notice.publishTime" class="mt-3 text-[22rpx] text-[#bbb]">
|
||||
{{ formatDate(notice.publishTime) }}
|
||||
<view v-if="notice.publishTime" class="mt-3 text-[22rpx] text-gray-400">
|
||||
日期:{{ formatDate(notice.publishTime) }}
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 操作 -->
|
||||
<view class="mt-6 flex items-center justify-between border-t border-[#f5f5f5] pt-4">
|
||||
<view class="text-[24rpx] text-[#999]" @click="handleDismissForever">
|
||||
<view class="box-border mt-4 flex items-center justify-between pt-4">
|
||||
<view class="text-xs text-gray-600 " @click="handleDismissForever">
|
||||
今日不再提醒
|
||||
</view>
|
||||
<wd-button size="small" type="primary" round @click="handleViewAll">
|
||||
<uh-button custom-class="font-semibold text-xs" @click="handleViewAll">
|
||||
查看全文 →
|
||||
</wd-button>
|
||||
</uh-button>
|
||||
</view>
|
||||
</view>
|
||||
</wd-popup>
|
||||
</template>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.uh-notify-dialog {
|
||||
/* 布局全部由 UnoCSS 原子类实现 */
|
||||
}
|
||||
</style>
|
||||
</template>
|
||||
@@ -7,14 +7,22 @@
|
||||
return []
|
||||
},
|
||||
})
|
||||
|
||||
|
||||
function handleScrollTop() {
|
||||
uni.pageScrollTo({ scrollTop: 0, duration: 500 })
|
||||
}
|
||||
|
||||
// 获取当前页面,并且设置黑名单模式,因为有的页面可能不需要滚动到顶部
|
||||
const balckList = ['pages/maintenance/maintenance']
|
||||
const pages = getCurrentPages()
|
||||
const currentPage = pages[pages.length - 1]
|
||||
const visible = computed(() => {
|
||||
return !balckList.includes(currentPage.route)
|
||||
})
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<view
|
||||
<view v-if="visible"
|
||||
class="uh-global-card-glass border fixed bottom-24 right-4 z-50 h-10 w-10 flex items-center justify-center rounded-full text-primary"
|
||||
:class="props.customClass" @click="handleScrollTop">
|
||||
<wd-icon name="arrow-up" size="20px" />
|
||||
|
||||
Reference in New Issue
Block a user