feat 异常警告

This commit is contained in:
Ironsp
2026-09-14 15:10:48 +08:00
parent 3d857002e0
commit dd7c8b4162
9 changed files with 443 additions and 68 deletions

View File

@@ -1,9 +1,31 @@
<script setup lang="ts">
import type { WarningRecord } from '@/service/warningRecord'
import { onMounted } from 'vue'
import { useDbStore } from '@/store/modules/db'
const db = useDbStore()
/** 首页只展示最近几条 */
const list = computed(() => (db.warning_record || []).slice(0, 3))
onMounted(async () => {
if (!db.warning_record?.length)
await db.loadAll()
})
function goToWarningList() {
uni.navigateTo({
url: '/pages/warning/index',
})
}
function goToDetail(item: WarningRecord) {
if (!item.id)
return
uni.navigateTo({
url: `/pages/warning/detail/index?id=${item.id}`,
})
}
</script>
<template>
@@ -17,7 +39,15 @@ function goToWarningList() {
</wd-button>
</view>
<view class="card-body">
<home-warning_list />
<view v-if="!list.length" class="empty-tip">
暂无异常警告
</view>
<home-warning_list
v-for="item in list"
:key="item.id"
:item="item"
@tap="goToDetail(item)"
/>
</view>
</view>
</template>
@@ -47,4 +77,11 @@ function goToWarningList() {
.card-body {
padding: 12px 16px;
}
.empty-tip {
font-size: 14px;
color: #999999;
text-align: center;
padding: 16px 0;
}
</style>