[AI Generated]: chore(*): 统一页面后缀为TS+LESS并清理searchDevice页
This commit is contained in:
+21
-3
@@ -1,3 +1,18 @@
|
||||
/** 设备项模型 */
|
||||
interface DeviceItem {
|
||||
/** 设备唯一 id */
|
||||
id: string
|
||||
/** 设备名称 */
|
||||
name: string
|
||||
/** 设备图标 */
|
||||
icon: string
|
||||
/** 是否已连接 */
|
||||
connected: boolean
|
||||
}
|
||||
|
||||
/** 页面状态 */
|
||||
type DeviceStatus = 'idle' | 'searching' | 'found' | 'empty'
|
||||
|
||||
// 是否 mock 能搜索到设备,false 则走空状态
|
||||
const MOCK_HAS_DEVICES = true
|
||||
|
||||
@@ -5,6 +20,9 @@ const MOCK_HAS_DEVICES = true
|
||||
const MOCK_SEARCH_DURATION = 2000
|
||||
|
||||
Page({
|
||||
/* 搜索定时器引用,onUnload 时清理 */
|
||||
_searchTimer: null as number | null,
|
||||
|
||||
data: {
|
||||
/**
|
||||
* 页面状态
|
||||
@@ -13,10 +31,10 @@ Page({
|
||||
* - found: 搜索完成且有设备
|
||||
* - empty: 搜索完成但无设备
|
||||
*/
|
||||
status: 'idle',
|
||||
status: 'idle' as DeviceStatus,
|
||||
|
||||
/* 设备列表(包含已连接和未连接,每项含 connected: boolean) */
|
||||
deviceList: [],
|
||||
deviceList: [] as DeviceItem[],
|
||||
},
|
||||
|
||||
onLoad() {
|
||||
@@ -56,7 +74,7 @@ Page({
|
||||
},
|
||||
|
||||
/* 连接某台设备:同时只能一台已连接,自动断开其他设备 */
|
||||
onConnect(e) {
|
||||
onConnect(e: WechatMiniprogram.TouchEvent) {
|
||||
const { id } = e.currentTarget.dataset
|
||||
const deviceList = this.data.deviceList.map(item => ({
|
||||
...item,
|
||||
Reference in New Issue
Block a user