diff --git a/src/api/system/developer/index.ts b/src/api/system/developer/index.ts new file mode 100644 index 00000000..bb36bd03 --- /dev/null +++ b/src/api/system/developer/index.ts @@ -0,0 +1,62 @@ +import request from "@/utils/request"; +import type { DeveloperQueryParams, DeveloperForm, DeveloperItem } from "./types"; +import type { PageResult } from "@/api/common"; + +const DEVELOPER_BASE_URL = "/api/v1/developers"; + +const DeveloperAPI = { + /** 获取开发者选项分页数据 */ + getPage(queryParams?: DeveloperQueryParams) { + return request>({ + url: `${DEVELOPER_BASE_URL}`, + method: "get", + params: queryParams, + }); + }, + /** 获取开发者选项表单数据 */ + getFormData(id: string) { + return request({ + url: `${DEVELOPER_BASE_URL}/${id}/form`, + method: "get", + }); + }, + /** 新增开发者选项配置 */ + create(data: DeveloperForm) { + return request({ url: `${DEVELOPER_BASE_URL}`, method: "post", data }); + }, + /** 修改开发者选项配置 */ + update(id: string, data: DeveloperForm) { + return request({ url: `${DEVELOPER_BASE_URL}/${id}`, method: "put", data }); + }, + /** 批量删除开发者选项配置,多个以英文逗号(,)分隔 */ + deleteByIds(ids: string) { + return request({ url: `${DEVELOPER_BASE_URL}/${ids}`, method: "delete" }); + }, + /** 根据设备序列号获取开发者选项开关 */ + getBySn(sn: string) { + return request({ + url: `${DEVELOPER_BASE_URL}/sn/${sn}`, + method: "get", + }); + }, + /** 根据设备序列号保存或更新开发者选项开关 */ + saveOrUpdateBySn(sn: string, developerOptions: number) { + return request({ + url: `${DEVELOPER_BASE_URL}/sn/${sn}`, + method: "put", + params: { developerOptions }, + }); + }, + /** 推送开发者模式指令到设备 */ + pushBySn(sn: string) { + return request({ + url: `${DEVELOPER_BASE_URL}/sn/${sn}/push`, + method: "post", + }); + }, +}; + +export default DeveloperAPI; + +// 重导出类型 +export * from "./types"; diff --git a/src/api/system/developer/types.ts b/src/api/system/developer/types.ts new file mode 100644 index 00000000..808ccc88 --- /dev/null +++ b/src/api/system/developer/types.ts @@ -0,0 +1,37 @@ +/** + * Developer 设备开发者选项类型定义 + */ + +import type { BaseQueryParams } from "@/api/common"; + +/** 开发者选项分页查询参数 */ +export interface DeveloperQueryParams extends BaseQueryParams { + /** 搜索关键字(设备序列号) */ + keywords?: string; + /** 开发者选项开关(0关闭,1开启) */ + developerOptions?: number; +} + +/** 开发者选项表单对象 */ +export interface DeveloperForm { + /** 配置ID */ + id?: string; + /** 设备序列号 */ + sn?: string; + /** 开发者选项开关(0关闭,1开启) */ + developerOptions?: number; +} + +/** 开发者选项分页对象 */ +export interface DeveloperItem { + /** 配置ID */ + id: string; + /** 设备序列号 */ + sn: string; + /** 开发者选项开关(0关闭,1开启) */ + developerOptions: number; + /** 创建时间 */ + createTime?: string; + /** 更新时间 */ + updateTime?: string; +} diff --git a/src/api/system/device/index.ts b/src/api/system/device/index.ts index 619becde..5771b832 100644 --- a/src/api/system/device/index.ts +++ b/src/api/system/device/index.ts @@ -307,6 +307,18 @@ const DeviceAPI = { params: { sn }, }); }, + + /** + * 推送开发者模式指令到设备 + * @param sn 设备SN号 + */ + deviceDeveloper(sn: string) { + return request({ + url: `${DEVICE_BASE_URL}/developer`, + method: "post", + params: { sn }, + }); + }, }; export default DeviceAPI; diff --git a/src/components/DeviceSn/DevicePageContent.vue b/src/components/DeviceSn/DevicePageContent.vue index 27cec77b..3aafd8d1 100644 --- a/src/components/DeviceSn/DevicePageContent.vue +++ b/src/components/DeviceSn/DevicePageContent.vue @@ -160,11 +160,17 @@