- 新增系统设置、壁纸、图标包、设备管理、通讯录、通话、短信、相册、文件、应用、告警、信息、首页布局、账号安全、绑定手机号、法律条款等页面 - utils/api.ts 补齐设备操作、策略、壁纸、图标包等 /api/v1/client/** 接口,新增多文件上传 - 新增 utils/sse.ts 与 utils/wx-session.ts - 「更多/进入」指示统一改为图片箭头,首卡统一 .hero-card 高度,页面首卡贴顶 - AGENTS.md 补充功能对接状态与小程序 UI 约定
84 lines
2.0 KiB
TypeScript
84 lines
2.0 KiB
TypeScript
import type { SmsRecord } from '../../utils/api'
|
|
import { getSmsContent, getSmsPage, syncMessages } from '../../utils/api'
|
|
import { getDeviceSn } from '../../utils/token'
|
|
|
|
Page({
|
|
data: {
|
|
records: [] as SmsRecord[],
|
|
keyword: '',
|
|
loading: false
|
|
},
|
|
|
|
onShow() {
|
|
this.load()
|
|
},
|
|
|
|
onKeywordInput(e: WechatMiniprogram.Input) {
|
|
this.setData({ keyword: e.detail.value })
|
|
},
|
|
|
|
onSearch() {
|
|
this.load()
|
|
},
|
|
|
|
async onSync() {
|
|
const sn = getDeviceSn()
|
|
if (!sn) {
|
|
this.toast('请先选择设备')
|
|
return
|
|
}
|
|
wx.showLoading({ title: '同步中' })
|
|
try {
|
|
await syncMessages(sn)
|
|
wx.hideLoading()
|
|
this.toast('已请求设备同步短信')
|
|
setTimeout(() => this.load(), 1000)
|
|
} catch (err) {
|
|
wx.hideLoading()
|
|
this.toast((err as Error).message || '同步失败')
|
|
}
|
|
},
|
|
|
|
async load() {
|
|
const sn = getDeviceSn()
|
|
if (!sn) {
|
|
this.toast('请先选择设备')
|
|
return
|
|
}
|
|
if (this.data.loading) return
|
|
this.setData({ loading: true })
|
|
try {
|
|
const result = await getSmsPage(sn, 1, this.data.keyword.trim() || undefined)
|
|
this.setData({ records: result.list || result.records || [] })
|
|
} catch (err) {
|
|
this.toast((err as Error).message || '记录加载失败')
|
|
} finally {
|
|
this.setData({ loading: false })
|
|
}
|
|
},
|
|
|
|
onContent(e: WechatMiniprogram.TouchEvent) {
|
|
const { sourceid } = e.currentTarget.dataset as { sourceid: number }
|
|
const sn = getDeviceSn()
|
|
if (!sn || !sourceid) return
|
|
wx.showLoading({ title: '读取正文' })
|
|
void getSmsContent(sn, sourceid)
|
|
.then((result) => {
|
|
wx.hideLoading()
|
|
wx.showModal({
|
|
title: '短信正文',
|
|
content: result.content || '设备未返回正文',
|
|
showCancel: false
|
|
})
|
|
})
|
|
.catch((err: Error) => {
|
|
wx.hideLoading()
|
|
this.toast(err.message || '正文获取失败')
|
|
})
|
|
},
|
|
|
|
toast(title: string) {
|
|
wx.showToast({ title, icon: 'none', duration: 1800 })
|
|
}
|
|
})
|