Jelajahi Sumber

优化升级维护确认对话框样式

shmily1213 1 bulan lalu
induk
melakukan
d1f743d52f

+ 13 - 1
src/pagesMain/pages/index/components/index-maintain-popup.vue

@@ -5,7 +5,10 @@
         mode="aspectFill" />
       <view class="text-center my-40 text-[16px] text-fore-title font-bold">系统维护公告</view>
       <view class="px-30 mt-30 text-[15px] whitespace-pre leading-[24px]">
-        {{ maintainContent }}
+        <view>{{ maintainTitle }}</view>
+        <view>维护开始时间:<text class="text-primary">{{ maintainBeginTime }}</text></view>
+        <view>维护结束时间:<text class="text-primary">{{ maintainEndTime }}</text></view>
+        <view>{{ maintainContent }}</view>
       </view>
       <view class="px-30 my-40">
         <uv-button type="primary" shape="circle" @click="handleConfirm">知道了</uv-button>
@@ -19,9 +22,18 @@ import { useAppStore } from '@/store/appStore';
 const appStore = useAppStore();
 const popupRef = ref();
 let callback: ((value: void | PromiseLike<void>) => void) | null = null;
+const maintainTitle = computed(() => {
+  return appStore.maintainNotice?.title || '';
+});
 const maintainContent = computed(() => {
   return appStore.maintainNotice?.content || '';
 });
+const maintainBeginTime = computed(() => {
+  return appStore.maintainNotice?.beginTime || '';
+});
+const maintainEndTime = computed(() => {
+  return appStore.maintainNotice?.endTime || '';
+});
 const handleConfirm = () => {
   appStore.maintainNotice!.read = true;
   if (callback !== null) {

+ 1 - 1
src/pagesMain/pages/splash/components/maintain-popup.vue

@@ -5,7 +5,7 @@
         mode="aspectFill" />
       <view class="text-center my-40 text-[16px] text-fore-title font-bold">系统维护中</view>
       <view class="px-30 mt-30 text-[15px] whitespace-pre leading-[24px]">
-        <view>预计结束时间:{{ endTime }}</view>
+        <view>预计结束时间:<text class="text-primary">{{ endTime }}</text></view>
         <view>系统维护期间暂停使用,敬请谅解!</view>
       </view>
       <view class="px-30 my-40">

+ 6 - 5
src/store/appStore.ts

@@ -98,8 +98,9 @@ export const useAppStore = defineStore('ie-app', {
         if (rows && rows.length) {
           const notice = extractMaintenanceContent(rows[0].noticeContent);
           if (notice) {
-            const { beginTime, endTime, content } = notice;
+            const { title, beginTime, endTime, content } = notice;
             this.maintainNotice = {
+              title,
               beginTime,
               endTime,
               content,
@@ -152,17 +153,17 @@ const convertToStandardFormat = (dateStr: string): string => {
 };
 
 function extractMaintenanceContent(htmlString: string): System.MaintainNotice | null {
-  const content = htmlString.replaceAll("</p><p>", "\n").replaceAll("</p>", "").replaceAll("<br>", "").replaceAll("<p>", "");
+  const htmlContent = htmlString.replaceAll("</p><p>", "\n").replaceAll("</p>", "").replaceAll("<br>", "").replaceAll("<p>", "");
   // 使用正则表达式匹配维护时间范围(完整的一次匹配)
-  const timeMatch = content.match(/维护开始时间:(\d{4}年\d{1,2}月\d{1,2}日\d{1,2}:\d{1,2}:\d{1,2})\n维护结束时间:(\d{4}年\d{1,2}月\d{1,2}日\d{1,2}:\d{1,2}:\d{1,2})/);
+  const timeMatch = htmlContent.match(/维护开始时间:(\d{4}年\d{1,2}月\d{1,2}日\d{1,2}:\d{1,2}:\d{1,2})\n维护结束时间:(\d{4}年\d{1,2}月\d{1,2}日\d{1,2}:\d{1,2}:\d{1,2})/);
   if (timeMatch) {
     // 提取开始时间和结束时间
     const startTimeStr = timeMatch[1];
     const endTimeStr = timeMatch[2];
     const beginTime = convertToStandardFormat(startTimeStr);
     const endTime = convertToStandardFormat(endTimeStr);
-
-    return { content, beginTime, endTime, read: false };
+    const rows = htmlContent.split('\n');
+    return { title: rows[0], content: rows[3], beginTime, endTime, read: false };
   }
   return null;
 }

+ 1 - 0
src/types/system.ts

@@ -15,6 +15,7 @@ export type SystemNotice = {
 }
 
 export interface MaintainNotice {
+  title: string;
   content: string;
   beginTime: string;
   endTime: string;