This commit is contained in:
张成
2025-11-26 22:39:07 +08:00
parent 3ff3169d74
commit 71b717aecb
3 changed files with 14 additions and 39 deletions

View File

@@ -26,11 +26,11 @@ const baseConfig = {
// 开发环境配置 // 开发环境配置
const developmentConfig = { const developmentConfig = {
...baseConfig, ...baseConfig,
apiUrl: 'http://localhost:9097/admin_api/', // apiUrl: 'http://localhost:9097/admin_api/',
uploadUrl: 'http://localhost:9097/admin_api/upload', // uploadUrl: 'http://localhost:9097/admin_api/upload',
// apiUrl: 'http://work.light120.com/admin_api/', apiUrl: 'http://work.light120.com/admin_api/',
// uploadUrl: 'http://work.light120.com/admin_api/upload', uploadUrl: 'http://work.light120.com/admin_api/upload',
// 开发环境显示更多调试信息 // 开发环境显示更多调试信息
debug: true debug: true
} }

View File

@@ -753,11 +753,11 @@ export default {
} }
} }
// 确保布尔值字段正确初始化 // 确保布尔值字段正确初始化转换为数字类型0 或 1
accountData.is_enabled = accountData.is_enabled !== undefined ? accountData.is_enabled : 1 accountData.is_enabled = accountData.is_enabled !== undefined ? Number(accountData.is_enabled) : 1
accountData.auto_deliver = accountData.auto_deliver !== undefined ? accountData.auto_deliver : 0 accountData.auto_deliver = accountData.auto_deliver !== undefined ? Number(accountData.auto_deliver) : 0
accountData.auto_chat = accountData.auto_chat !== undefined ? accountData.auto_chat : 0 accountData.auto_chat = accountData.auto_chat !== undefined ? Number(accountData.auto_chat) : 0
accountData.auto_active = accountData.auto_active !== undefined ? accountData.auto_active : 0 accountData.auto_active = accountData.auto_active !== undefined ? Number(accountData.auto_active) : 0
this.accountInfo = accountData this.accountInfo = accountData
console.log('设置账户信息:', this.accountInfo) console.log('设置账户信息:', this.accountInfo)
@@ -798,8 +798,8 @@ export default {
this.switchLoading[field] = true this.switchLoading[field] = true
try { try {
// 确保 value 是数字类型0 或 1 // i-switch 的 on-change 事件已经返回了正确的值1 或 0直接使用
const numericValue = value ? 1 : 0 const numericValue = Number(value)
// 构建更新数据,确保是纯对象,只包含基本类型 // 构建更新数据,确保是纯对象,只包含基本类型
const updateData = { const updateData = {
@@ -819,19 +819,8 @@ export default {
const errorMsg = error.response?.data?.message || error.message || '请稍后重试' const errorMsg = error.response?.data?.message || error.message || '请稍后重试'
this.$Message.error('更新失败:' + errorMsg) this.$Message.error('更新失败:' + errorMsg)
// 恢复原值 // 恢复原值(从数据库重新加载)
this.$nextTick(() => { await this.loadAccountInfo()
const oldValue = this.accountInfo[field]
if (field === 'is_enabled') {
this.accountInfo.is_enabled = oldValue === 1 ? 0 : 1
} else if (field === 'auto_deliver') {
this.accountInfo.auto_deliver = oldValue === 1 ? 0 : 1
} else if (field === 'auto_chat') {
this.accountInfo.auto_chat = oldValue === 1 ? 0 : 1
} else if (field === 'auto_active') {
this.accountInfo.auto_active = oldValue === 1 ? 0 : 1
}
})
} finally { } finally {
this.switchLoading[field] = false this.switchLoading[field] = false
} }

View File

@@ -267,20 +267,6 @@ class MqttDispatcher {
if (device) { if (device) {
await device_status.update(updateData, { where: { sn_code } }); await device_status.update(updateData, { where: { sn_code } });
console.log(`[MQTT心跳] 设备 ${sn_code} 状态已更新 - 在线: true, 登录: ${updateData.isLoggedIn}`); console.log(`[MQTT心跳] 设备 ${sn_code} 状态已更新 - 在线: true, 登录: ${updateData.isLoggedIn}`);
} else {
// 创建新设备记录
await device_status.create({
sn_code,
device_id: clientId,
deviceName: `设备_${sn_code}`,
deviceType: 'node_mqtt_client',
...updateData,
isRunning: false,
taskStatus: 'idle',
healthStatus: 'unknown',
healthScore: 0
});
console.log(`[MQTT心跳] 设备 ${sn_code} 记录已创建 - 在线: true, 登录: ${updateData.isLoggedIn}`);
} }
// 记录心跳到设备管理器 // 记录心跳到设备管理器