feat: migrate app routes and business modules

This commit is contained in:
2026-08-12 18:22:59 +08:00
parent 555aa00043
commit cc706378c2
247 changed files with 28623 additions and 14988 deletions
+211
View File
@@ -0,0 +1,211 @@
<template>
<view class="message-page">
<ModulePageBackground module="notification" />
<view class="page-header"><PageHeader root title="消息中心" :action="unreadCount > 0 ? '设为已读' : ''" @action="requestMarkAllRead" /></view>
<view class="page-content">
<view v-if="notificationListState === 'loading'" class="state-card"><AppLoading text="正在读取消息通知" /></view>
<view v-else-if="notificationListState === 'error'" class="state-card">
<text>暂时无法读取消息状态</text>
<text>{{ notificationListError || "请检查网络后重新加载。" }}</text>
<AppButton block type="secondary" label="重新加载" @click="loadNotifications" />
<AppButton block label="返回我的" @click="returnToProfile" />
</view>
<view v-else-if="!notifications.length" class="state-card message-status-card">
<text>当前没有通知</text>
<text>新的家谱动态审核和活动消息会在这里展示</text>
<text v-if="markAllReadError" class="message-operation-error">{{ markAllReadError }}</text>
<AppButton block type="secondary" label="返回我的" @click="returnToProfile" />
</view>
<view v-else class="message-list">
<view
v-for="item in notifications"
:key="item.notificationId"
class="message-row"
hover-class="action-hover"
@click="openNotification(item)"
>
<view class="message-row__body">
<view class="message-row__title-line">
<text class="message-row__title">{{ item.noticeTitle || '通知消息' }}</text>
<text v-if="item.readStatus === '0'" class="message-row__unread">未读</text>
</view>
<text class="message-row__summary">{{ item.noticeContent || item.bizSummary || '暂无通知摘要' }}</text>
<text class="message-row__meta">{{ item.publishTime || '刚刚发布' }}</text>
</view>
<text class="message-row__chevron"></text>
</view>
<text v-if="markAllReadError" class="message-operation-error">{{ markAllReadError }}</text>
<AppButton v-if="unreadCount" block label="全部设为已读" @click="requestMarkAllRead" />
</view>
</view>
<AppPromotionStrip placement="message_bottom" title="消息页推荐" />
<AppTabbar active="profile" />
<AppDialog
:visible="markAllVisible"
eyebrow="消息状态"
title="把全部消息设为已读?"
message="这些消息将不再显示为未读。"
:confirm-text="markAllSubmitting ? '正在设置' : '确认设为已读'"
cancel-text="取消"
show-cancel
:close-on-mask="false"
@confirm="confirmMarkAllRead"
@cancel="markAllVisible = false"
/>
</view>
</template>
<script setup>
import { ref } from "vue";
import { onLoad, onShow, onUnload } from "@dcloudio/uni-app";
import AppButton from "@/components/AppButton.vue";
import AppDialog from "@/components/AppDialog.vue";
import AppLoading from "@/components/AppLoading.vue";
import AppPromotionStrip from "@/components/AppPromotionStrip.vue";
import AppTabbar from "@/components/AppTabbar.vue";
import ModulePageBackground from "@/components/ModulePageBackground.vue";
import PageHeader from "@/components/PageHeader.vue";
import {
createRequestController,
isRequestCancelled
} from "@/services/api/request-controller.js";
import { notificationApi } from "@/services/api/notification-service.js";
import { getRequestErrorMessage } from "@/services/api/request-error-message.js";
import { goRoot, openPage } from "@/utils/navigation/gateway.js";
const unreadCount = ref(0);
const notifications = ref([]);
const notificationListState = ref("loading");
const notificationListError = ref("");
const notificationListController = createRequestController();
const markAllReadController = createRequestController();
const markAllVisible = ref(false);
const markAllSubmitting = ref(false);
const markAllReadError = ref("");
let isPageActive = true;
const loadNotifications = async () => {
notificationListController.abort();
notificationListState.value = "loading";
notificationListError.value = "";
try {
const notificationRows = await notificationApi.getNotifications({
requestController: notificationListController,
});
if (!isPageActive) return;
notifications.value = notificationRows;
unreadCount.value = notificationRows.filter((item) => item.readStatus === "0").length;
notificationListState.value = "ready";
} catch (error) {
if (!isPageActive || isRequestCancelled(error)) return;
notificationListError.value = getRequestErrorMessage(error, "请稍后重试。");
notificationListState.value = "error";
}
};
const requestMarkAllRead = () => {
if (notificationListState.value !== "ready" || !unreadCount.value || markAllSubmitting.value) return;
markAllReadError.value = "";
markAllVisible.value = true;
};
const confirmMarkAllRead = async () => {
if (markAllSubmitting.value || !unreadCount.value) return;
markAllSubmitting.value = true;
markAllReadError.value = "";
try {
await notificationApi.markAllNotificationsRead({ requestController: markAllReadController });
if (!isPageActive) return;
markAllVisible.value = false;
await loadNotifications();
} catch (error) {
if (!isPageActive || isRequestCancelled(error)) return;
markAllReadError.value = getRequestErrorMessage(error, "全部标记已读失败,请稍后重试。");
} finally {
if (isPageActive) markAllSubmitting.value = false;
}
};
const returnToProfile = () => goRoot("M01");
const openNotification = (item) => openPage("N02", { id: item.notificationId });
onLoad(loadNotifications);
onShow(() => {
if (notificationListState.value !== "loading") loadNotifications();
});
onUnload(() => {
isPageActive = false;
notificationListController.abort();
markAllReadController.abort();
});
</script>
<style scoped lang="scss">
@import "../../styles/adaptive-frame-profiles.scss";
.message-page {
display: flex;
min-height: 100vh;
flex-direction: column;
background: $paper;
}
.page-header,
.page-content {
z-index: 1;
}
.page-content {
flex: 1;
padding: 18rpx 24rpx 190rpx;
}
.state-card {
box-sizing: border-box;
min-height: 340rpx;
padding: 78rpx 52rpx 50rpx;
text-align: center;
@include adaptive-notification-content;
}
.state-card text {
display: block;
}
.state-card text:first-child {
color: $ink;
font-family: STKaiti, KaiTi, serif;
font-size: clamp(19px, 35rpx, 24px);
font-weight: 700;
}
.state-card text:nth-child(2) {
margin-top: 18rpx;
color: $ink-muted;
font-size: clamp(15px, 24rpx, 18px);
line-height: 1.65;
}
.state-card .app-button {
margin-top: 28rpx;
}
.message-list {
display: grid;
gap: 16rpx;
@include adaptive-notification-content;
}
.message-row {
display: flex;
gap: 18rpx;
align-items: center;
padding: 24rpx;
border: 1rpx solid rgba(128, 89, 49, 0.26);
border-radius: 12rpx;
background: rgba(255, 252, 245, 0.78);
}
.message-row__body { min-width: 0; flex: 1; }
.message-row__title-line { display: flex; gap: 12rpx; align-items: center; }
.message-row__title { overflow: hidden; flex: 1; color: $ink; font-size: clamp(16px, 27rpx, 20px); font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }
.message-row__unread { flex: 0 0 auto; color: $brand-red; font-size: clamp(12px, 20rpx, 15px); }
.message-row__summary, .message-row__meta { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.message-row__summary { margin-top: 9rpx; color: $ink-muted; font-size: clamp(14px, 23rpx, 17px); }
.message-row__meta { margin-top: 9rpx; color: #8b7d6c; font-size: clamp(13px, 21rpx, 16px); }
.message-row__chevron { color: $ink-muted; font-size: clamp(24px, 42rpx, 30px); line-height: 1; }
.message-operation-error {
margin-top: 18rpx;
color: $brand-red;
font-size: clamp(14px, 22rpx, 17px);
line-height: 1.5;
}
</style>