wangzhibo
2026-08-30 c8515170fd399b4d2dfaebb59128d4674e58915e
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
import type { Device, FirmwareType } from './types'
import { http } from '@/http/request/alova'
 
/**
 * 获取设备类型列表
 */
export function getFirmwareTypes() {
  return http.Get<FirmwareType[]>('/admin/dict/data/type/FIRMWARE_TYPE')
}
 
/**
 * 获取绑定设备列表
 * @param agentId 智能体ID
 */
export function getBindDevices(agentId: string) {
  return http.Get<Device[]>(`/device/bind/${agentId}`, {
    meta: {
      ignoreAuth: false,
      toast: false,
    },
    cacheFor: {
      expire: 0,
    },
  })
}
 
/**
 * 添加设备
 * @param agentId 智能体ID
 * @param code 验证码
 */
export function bindDevice(agentId: string, code: string) {
  return http.Post(`/device/bind/${agentId}/${code}`, null)
}
 
/**
 * 手动添加设备
 * @param agentId 智能体ID
 * @param board 设备类型
 * @param appVersion 固件版本
 * @param macAddress MAC地址
 */
export function bindDeviceManual(data: {
  agentId: string
  board: string
  appVersion: string
  macAddress: string
}) {
  return http.Post('/device/manual-add', data)
}
 
/**
 * 设置设备OTA升级开关
 * @param deviceId 设备ID (MAC地址)
 * @param autoUpdate 是否自动升级 0|1
 */
export function updateDeviceAutoUpdate(deviceId: string, autoUpdate: number) {
  return http.Put(`/device/update/${deviceId}`, {
    autoUpdate,
  })
}
 
/**
 * 解绑设备
 * @param deviceId 设备ID (MAC地址)
 */
export function unbindDevice(deviceId: string) {
  return http.Post('/device/unbind', {
    deviceId,
  })
}