Initial commit of akmon project

This commit is contained in:
2026-01-20 08:04:15 +08:00
commit 77a2bab985
1309 changed files with 343305 additions and 0 deletions

View File

@@ -0,0 +1,98 @@
<template>
<view class="alert-container">
<view class="top-bar">
<button @click="goRealtime" style="margin-right: 16rpx;">实时告警</button>
<text class="title">历史健康告警</text>
</view>
<view class="section" style="margin-bottom: 24rpx;">
<button @click="loadHistory">刷新历史</button>
</view>
<scroll-view style="height: 600rpx; border: 1px solid #ccc; padding: 8rpx;" scroll-y scroll-with-animation>
<view v-for="(msg, idx) in messages" :key="idx" style="font-size: 26rpx; color: #333; margin-bottom: 12rpx;">
<text>{{ msg.timeStr }}</text>
<text>{{ msg.content }}</text>
<text>{{ msg.raw_data }}</text>
</view>
</scroll-view>
</view>
</template>
<script lang="uts">
type AlertMessage = {
type: string;
mid?:string;
content: string;
timeStr: string;
raw_data:string
};
import { parseAlertMessage } from './alertparse.uts';
import supa from '@/components/supadb/aksupainstance.uts';
export default {
data() {
return {
/** 历史告警消息列表,强类型 */
messages: [] as AlertMessage[],
loading: false
};
},
methods: {
goRealtime() {
uni.navigateTo({ url: '/pages/ec/health/ecalert' });
},
async loadHistory() {
this.loading = true;
let historyList: any[] = [];
try {
// UTS Android 风格获取 Supabase 查询结果
const resp = await supa.from('ps_push_msg_raw').select('*',{}).order('created_at', { ascending: false }).limit(100).execute();
if (resp && resp.error) {
uni.showToast({ title: '获取历史告警失败', icon: 'none' });
} else if (resp && Array.isArray(resp.data)) {
historyList = resp.data;
} else {
historyList = [];
}
} catch (e) {
uni.showToast({ title: '请求异常', icon: 'none' });
}
this.messages = (historyList || []).map((item): AlertMessage => {
// item.raw_data 可能为 UTSJSONObjectparseAlertMessage 返回强类型对象
const parseResult = parseAlertMessage(item.raw_data ? item.raw_data : item);
return {
type: parseResult.type,
mid:parseResult.mid,
content: (parseResult.mid ? `[${parseResult.mid}] ` : '') + parseResult.title + (parseResult.content ? (': ' + parseResult.content) : ''),
timeStr: parseResult.time || '',
raw_data: item.raw_data
};
});
this.loading = false;
}
},
onLoad() {
this.loadHistory();
}
};
</script>
<style>
.alert-container {
padding: 32rpx;
}
.title {
font-size: 36rpx;
font-weight: bold;
margin-bottom: 32rpx;
}
.section {
margin-bottom: 24rpx;
}
.top-bar {
display: flex;
align-items: center;
margin-bottom: 24rpx;
}
</style>