feat: 新增文档
All checks were successful
构建并部署前端到生产环境 / build-and-deploy (push) Successful in 1m2s

This commit is contained in:
luo
2026-07-27 16:21:34 +08:00
parent 861ffa371b
commit 6a794d88af
6 changed files with 810 additions and 3 deletions

View File

@@ -95,6 +95,9 @@
<view class="bottom-spacer"></view>
<NotificationPopup :show="notificationPopupShow" :items="notificationItems"
:current="notificationPopupCurrent" @change="onNotificationChange" @close="closeNotificationPopup" />
<!-- 日期选择器弹窗 -->
<up-datetime-picker v-if="!userInfo.isDevice" :show="showStartDatePicker" v-model="startDateTimestamp"
mode="date" @confirm="onStartDateConfirm" @cancel="showStartDatePicker=false"
@@ -123,6 +126,7 @@
import WifiCard from '@/components/WifiCard.vue';
import FunctionCard from '@/components/FunctionCard.vue';
import FloatingButton from '@/components/FloatingButton.vue';
import NotificationPopup from '@/components/NotificationPopup.vue';
import {
assetApi,
deviceApi,
@@ -213,6 +217,10 @@
let smsCode = ref('');
let indexEntryChecking = ref(false);
let notificationUnreadCount = ref(0);
let notificationPopupShow = ref(false);
let notificationItems = ref([]);
let notificationPopupCurrent = ref(0);
const notificationReadPending = new Set();
const formatDate = (dateStr) => {
if (!dateStr) return '-';
@@ -784,6 +792,47 @@
}
};
const markNotificationRead = async (item) => {
if (!item || item.is_read || notificationReadPending.has(item.id)) return;
notificationReadPending.add(item.id);
try {
await notificationApi.markRead(item.id);
item.is_read = true;
item.read_at = new Date().toISOString();
notificationUnreadCount.value = Math.max(notificationUnreadCount.value - 1, 0);
} catch (error) {
console.error('标记首页通知已读失败', error);
} finally {
notificationReadPending.delete(item.id);
}
};
const loadUnreadNotifications = async () => {
try {
const data = await notificationApi.getList(1, 50, false);
const items = (data?.items || []).filter(item => !item.is_read);
if (!items.length) return;
notificationItems.value = items;
notificationPopupCurrent.value = 0;
notificationPopupShow.value = true;
// 弹窗打开即视为用户已看到第一条通知。
markNotificationRead(items[0]);
} catch (error) {
console.error('加载首页未读通知失败', error);
}
};
const onNotificationChange = (event) => {
const index = Number(event?.detail?.current ?? event?.current ?? 0);
notificationPopupCurrent.value = index;
markNotificationRead(notificationItems.value[index]);
};
const closeNotificationPopup = () => {
notificationPopupShow.value = false;
};
onMounted(() => {
initCurrentMonth();
});
@@ -791,6 +840,7 @@
onShow(() => {
handleIndexEntry();
loadNotificationUnreadCount();
loadUnreadNotifications();
});
</script>