抄盘手端 - 设置设备任务参数调整
This commit is contained in:
@@ -353,8 +353,11 @@ export default function DeviceDetailPage() {
|
||||
// 准备更新后的功能状态
|
||||
const updatedFeatures = { ...device.features, [feature]: checked }
|
||||
|
||||
// 创建API请求参数
|
||||
const configUpdate = { [feature]: checked }
|
||||
// 创建API请求参数,将布尔值转换为0/1
|
||||
const configUpdate = {
|
||||
deviceId: device.id,
|
||||
[feature]: checked ? 1 : 0
|
||||
}
|
||||
|
||||
// 立即更新UI状态,提供即时反馈
|
||||
setDevice(prev => prev ? {
|
||||
@@ -363,7 +366,7 @@ export default function DeviceDetailPage() {
|
||||
} : null)
|
||||
|
||||
// 调用API更新服务器配置
|
||||
const response = await updateDeviceTaskConfig(device.id, configUpdate)
|
||||
const response = await updateDeviceTaskConfig(configUpdate)
|
||||
|
||||
if (response && response.code === 200) {
|
||||
toast.success(`${getFeatureName(feature)}${checked ? '已启用' : '已禁用'}`)
|
||||
|
||||
@@ -127,5 +127,23 @@ export const deviceApi = {
|
||||
})
|
||||
return response.json()
|
||||
},
|
||||
|
||||
// 更新设备任务配置
|
||||
async updateDeviceTaskConfig(params: {
|
||||
deviceId: string;
|
||||
autoAddFriend?: number;
|
||||
autoReply?: number;
|
||||
momentsSync?: number;
|
||||
aiChat?: number;
|
||||
}): Promise<ApiResponse<Device>> {
|
||||
const response = await fetch(`${API_BASE}/task-config`, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify(params),
|
||||
});
|
||||
return response.json();
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user