From 8eafdac1d7a0bc7001bbf60c3b97bb25d996d901 Mon Sep 17 00:00:00 2001
From: 1 <1>
Date: Tue, 8 Jul 2025 09:32:07 +0800
Subject: [PATCH] =?UTF-8?q?=E7=BB=A7=E7=94=B5=E5=99=A8=E9=A1=B5=E9=9D=A2?=
=?UTF-8?q?=E6=B7=BB=E5=8A=A0=E7=BC=96=E8=BE=91=E4=BB=A5=E5=8F=8A=E5=8E=BB?=
=?UTF-8?q?=E9=99=A4=E6=97=A0=E5=85=B3=E5=8A=9F=E8=83=BD?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
node_modules/.package-lock.json | 191 +++++++-
package.json | 5 +-
pagesA/home/device/index.vue | 25 +-
pagesA/home/device/status/index.vue | 10 +-
pagesA/home/device/status/relay.vue | 722 +++++++++++++++-------------
pagesA/home/device/status/voice.vue | 203 ++++----
vue.config.js | 15 +
7 files changed, 699 insertions(+), 472 deletions(-)
diff --git a/node_modules/.package-lock.json b/node_modules/.package-lock.json
index 46af71f..ce0eb08 100644
--- a/node_modules/.package-lock.json
+++ b/node_modules/.package-lock.json
@@ -7,7 +7,6 @@
"node_modules/@babel/helper-string-parser": {
"version": "7.25.9",
"license": "MIT",
- "peer": true,
"engines": {
"node": ">=6.9.0"
}
@@ -15,7 +14,6 @@
"node_modules/@babel/helper-validator-identifier": {
"version": "7.25.9",
"license": "MIT",
- "peer": true,
"engines": {
"node": ">=6.9.0"
}
@@ -23,7 +21,6 @@
"node_modules/@babel/parser": {
"version": "7.27.0",
"license": "MIT",
- "peer": true,
"dependencies": {
"@babel/types": "^7.27.0"
},
@@ -37,7 +34,6 @@
"node_modules/@babel/types": {
"version": "7.27.0",
"license": "MIT",
- "peer": true,
"dependencies": {
"@babel/helper-string-parser": "^7.25.9",
"@babel/helper-validator-identifier": "^7.25.9"
@@ -92,7 +88,6 @@
"node_modules/@vue/compiler-core": {
"version": "3.5.13",
"license": "MIT",
- "peer": true,
"dependencies": {
"@babel/parser": "^7.25.3",
"@vue/shared": "3.5.13",
@@ -104,7 +99,6 @@
"node_modules/@vue/compiler-dom": {
"version": "3.5.13",
"license": "MIT",
- "peer": true,
"dependencies": {
"@vue/compiler-core": "3.5.13",
"@vue/shared": "3.5.13"
@@ -181,8 +175,30 @@
},
"node_modules/@vue/shared": {
"version": "3.5.13",
+ "license": "MIT"
+ },
+ "node_modules/ansi-styles": {
+ "version": "4.3.0",
+ "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz",
+ "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==",
+ "dev": true,
"license": "MIT",
- "peer": true
+ "dependencies": {
+ "color-convert": "^2.0.1"
+ },
+ "engines": {
+ "node": ">=8"
+ },
+ "funding": {
+ "url": "https://github.com/chalk/ansi-styles?sponsor=1"
+ }
+ },
+ "node_modules/async": {
+ "version": "3.2.6",
+ "resolved": "https://registry.npmjs.org/async/-/async-3.2.6.tgz",
+ "integrity": "sha512-htCUDlxyyCLMgaM3xXg0C0LW2xqfuQ6p05pCEIsXuyQ+a1koYKTuBMzRNwmybfLgvJDMd0r1LTn4+E0Ti6C2AA==",
+ "dev": true,
+ "license": "MIT"
},
"node_modules/async-limiter": {
"version": "1.0.1",
@@ -273,6 +289,72 @@
"readable-stream": "> 1.0.0 < 3.0.0"
}
},
+ "node_modules/chalk": {
+ "version": "4.1.1",
+ "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.1.tgz",
+ "integrity": "sha512-diHzdDKxcU+bAsUboHLPEDQiw0qEe0qd7SYUn3HgcFlWgbDcfLGswOHYeGrHKzG9z6UYf01d9VFMfZxPM1xZSg==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "ansi-styles": "^4.1.0",
+ "supports-color": "^7.1.0"
+ },
+ "engines": {
+ "node": ">=10"
+ },
+ "funding": {
+ "url": "https://github.com/chalk/chalk?sponsor=1"
+ }
+ },
+ "node_modules/code-inspector-core": {
+ "version": "0.20.15",
+ "resolved": "https://registry.npmjs.org/code-inspector-core/-/code-inspector-core-0.20.15.tgz",
+ "integrity": "sha512-2PKFKkrdacwieS/A0e8nHf6AfqOGN4OQx4HtIPh8H+GfQry1jwsLdi+uCMMoBP4w/Cujy6onVYVg55Iu5w2OYQ==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "@vue/compiler-dom": "^3.5.13",
+ "chalk": "^4.1.1",
+ "dotenv": "^16.1.4",
+ "launch-ide": "1.0.7",
+ "portfinder": "^1.0.28"
+ }
+ },
+ "node_modules/code-inspector-plugin": {
+ "version": "0.20.15",
+ "resolved": "https://registry.npmjs.org/code-inspector-plugin/-/code-inspector-plugin-0.20.15.tgz",
+ "integrity": "sha512-JIFNpBor45i1SnyD28TqbTsB6bND57kYzGR4c3gqIhZj9bO1nxSd51ef8OOSbsBXxhMpNjbldwYoBuQExdFAVA==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "chalk": "4.1.1",
+ "code-inspector-core": "0.20.15",
+ "dotenv": "^16.3.1",
+ "esbuild-code-inspector-plugin": "0.20.15",
+ "vite-code-inspector-plugin": "0.20.15",
+ "webpack-code-inspector-plugin": "0.20.15"
+ }
+ },
+ "node_modules/color-convert": {
+ "version": "2.0.1",
+ "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz",
+ "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "color-name": "~1.1.4"
+ },
+ "engines": {
+ "node": ">=7.0.0"
+ }
+ },
+ "node_modules/color-name": {
+ "version": "1.1.4",
+ "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz",
+ "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==",
+ "dev": true,
+ "license": "MIT"
+ },
"node_modules/commist": {
"version": "1.1.0",
"license": "MIT",
@@ -333,6 +415,19 @@
}
}
},
+ "node_modules/dotenv": {
+ "version": "16.6.1",
+ "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.6.1.tgz",
+ "integrity": "sha512-uBq4egWHTcTt33a72vpSG0z3HnPuIl6NqYcTrKEg2azoEyl2hpW0zqlxysq2pK9HlDIHyHyakeYaYnSAwd8bow==",
+ "dev": true,
+ "license": "BSD-2-Clause",
+ "engines": {
+ "node": ">=12"
+ },
+ "funding": {
+ "url": "https://dotenvx.com"
+ }
+ },
"node_modules/duplexify": {
"version": "3.7.1",
"license": "MIT",
@@ -353,7 +448,6 @@
"node_modules/entities": {
"version": "4.5.0",
"license": "BSD-2-Clause",
- "peer": true,
"engines": {
"node": ">=0.12"
},
@@ -422,6 +516,16 @@
"node": ">=0.12"
}
},
+ "node_modules/esbuild-code-inspector-plugin": {
+ "version": "0.20.15",
+ "resolved": "https://registry.npmjs.org/esbuild-code-inspector-plugin/-/esbuild-code-inspector-plugin-0.20.15.tgz",
+ "integrity": "sha512-iCTPL4plbWPX+KerG1VUMK/+iuxm/RB9DLBKGVCgB2z7viw3O00+C2HIVua9QBcb13kU33Ws61BuIP7nfz74PQ==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "code-inspector-core": "0.20.15"
+ }
+ },
"node_modules/esniff": {
"version": "2.0.1",
"license": "ISC",
@@ -437,8 +541,7 @@
},
"node_modules/estree-walker": {
"version": "2.0.2",
- "license": "MIT",
- "peer": true
+ "license": "MIT"
},
"node_modules/event-emitter": {
"version": "0.3.5",
@@ -508,6 +611,16 @@
"node": ">= 0.10"
}
},
+ "node_modules/has-flag": {
+ "version": "4.0.0",
+ "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz",
+ "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==",
+ "dev": true,
+ "license": "MIT",
+ "engines": {
+ "node": ">=8"
+ }
+ },
"node_modules/help-me": {
"version": "1.1.0",
"license": "MIT",
@@ -622,6 +735,17 @@
"version": "1.0.1",
"license": "MIT"
},
+ "node_modules/launch-ide": {
+ "version": "1.0.7",
+ "resolved": "https://registry.npmjs.org/launch-ide/-/launch-ide-1.0.7.tgz",
+ "integrity": "sha512-wJMTq6U2sVYqxrlp544KQxtl8cHoXFfQa2ivDtKJ6ock2ARneiEHqUFce/NQsnNP1aZNg4OXB6g00oFRvni1/Q==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "chalk": "^4.1.1",
+ "dotenv": "^16.1.4"
+ }
+ },
"node_modules/leven": {
"version": "2.1.0",
"license": "MIT",
@@ -754,6 +878,20 @@
"license": "ISC",
"peer": true
},
+ "node_modules/portfinder": {
+ "version": "1.0.37",
+ "resolved": "https://registry.npmjs.org/portfinder/-/portfinder-1.0.37.tgz",
+ "integrity": "sha512-yuGIEjDAYnnOex9ddMnKZEMFE0CcGo6zbfzDklkmT1m5z734ss6JMzN9rNB3+RR7iS+F10D4/BVIaXOyh8PQKw==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "async": "^3.2.6",
+ "debug": "^4.3.6"
+ },
+ "engines": {
+ "node": ">= 10.12"
+ }
+ },
"node_modules/postcss": {
"version": "8.5.3",
"funding": [
@@ -872,6 +1010,19 @@
"safe-buffer": "~5.1.0"
}
},
+ "node_modules/supports-color": {
+ "version": "7.2.0",
+ "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz",
+ "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "has-flag": "^4.0.0"
+ },
+ "engines": {
+ "node": ">=8"
+ }
+ },
"node_modules/through2": {
"version": "2.0.5",
"license": "MIT",
@@ -930,6 +1081,16 @@
"version": "1.0.2",
"license": "MIT"
},
+ "node_modules/vite-code-inspector-plugin": {
+ "version": "0.20.15",
+ "resolved": "https://registry.npmjs.org/vite-code-inspector-plugin/-/vite-code-inspector-plugin-0.20.15.tgz",
+ "integrity": "sha512-Zd6dFN5/uqz0zkys6F+pNG//ToWw5nBGerPfwsD4KWMgEauXbPsQl78k20Fur/4dsrmUDXtM2uGG6FSdAsVT9A==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "code-inspector-core": "0.20.15"
+ }
+ },
"node_modules/vue": {
"version": "3.5.13",
"license": "MIT",
@@ -968,6 +1129,16 @@
"vue": "^3.0.0"
}
},
+ "node_modules/webpack-code-inspector-plugin": {
+ "version": "0.20.15",
+ "resolved": "https://registry.npmjs.org/webpack-code-inspector-plugin/-/webpack-code-inspector-plugin-0.20.15.tgz",
+ "integrity": "sha512-CaaIAMHOVCjWT2TEvhutZdR4SW/F0AAmRDtfafirRnhgmGH7fRHn8UB4hTI5z1AnS4FtLOt/RrW+UZkMMZc8+Q==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "code-inspector-core": "0.20.15"
+ }
+ },
"node_modules/websocket-stream": {
"version": "5.5.2",
"license": "BSD-2-Clause",
diff --git a/package.json b/package.json
index 789fc4a..60976b0 100644
--- a/package.json
+++ b/package.json
@@ -21,5 +21,8 @@
"fastbee"
],
"author": "fastbee",
- "license": "ISC"
+ "license": "ISC",
+ "devDependencies": {
+ "code-inspector-plugin": "^0.20.15"
+ }
}
diff --git a/pagesA/home/device/index.vue b/pagesA/home/device/index.vue
index 0ead7b9..a397ac3 100644
--- a/pagesA/home/device/index.vue
+++ b/pagesA/home/device/index.vue
@@ -23,9 +23,9 @@
-
-
+ -->
@@ -235,12 +235,12 @@
-
+
@@ -254,12 +254,12 @@
src="/static/home/tabBar/statistic_black.png">
-
+
showScada = false"
@cancel="() => showScada = false" showCancelButton>
@@ -309,11 +309,14 @@
tabbarIndex: 0,
baseTabList: [{
name: this.$tt('deviceDetail.overview')
- }, {
- name: this.$tt('deviceDetail.monitor')
- }, {
- name: this.$tt('deviceDetail.Surveillance')
- }, {
+ },
+ // {
+ // name: this.$tt('deviceDetail.monitor')
+ // },
+ // {
+ // name: this.$tt('deviceDetail.Surveillance')
+ // },
+ {
name: this.$tt('deviceDetail.alert')
}],
videoTabList: [{
diff --git a/pagesA/home/device/status/index.vue b/pagesA/home/device/status/index.vue
index 314c10b..c809518 100644
--- a/pagesA/home/device/status/index.vue
+++ b/pagesA/home/device/status/index.vue
@@ -1,17 +1,19 @@
-
+
-
+
-
+
diff --git a/pagesA/home/device/status/relay.vue b/pagesA/home/device/status/relay.vue
index 6d39380..307d4ca 100644
--- a/pagesA/home/device/status/relay.vue
+++ b/pagesA/home/device/status/relay.vue
@@ -36,12 +36,12 @@
- {{item.status === 1 ? '开启' : '关闭'}}
+ 当前状态:{{item.status === 1 ? '吸合' : '断开'}}
-
- {{item.status === 1 ? '关闭' : '开启'}}
+ {{item.status === 1 ? '断开' : '吸合'}}
@@ -118,6 +118,10 @@
+
+ 编辑
+
删除
@@ -128,10 +132,10 @@
-
-
+
+
@@ -263,7 +267,9 @@
action: 1,
relayIndexes: [],
weekdays: []
- }
+ },
+ isEditing: false, // 是否处于编辑模式
+ editingIndex: -1 // 当前编辑的时间方案索引
}
},
@@ -554,6 +560,10 @@
showAddSchedule() {
if (!this.checkOnline()) return;
+ // 重置编辑状态
+ this.isEditing = false;
+ this.editingIndex = -1;
+
const now = new Date();
const hours = now.getHours().toString().padStart(2, '0');
const minutes = now.getMinutes().toString().padStart(2, '0');
@@ -701,382 +711,412 @@
});
}
},
+
+ // 编辑时间方案
+ editSchedule(index) {
+ if (!this.checkOnline()) return;
+
+ // 设置编辑模式
+ this.isEditing = true;
+ this.editingIndex = index;
+
+ // 获取要编辑的时间方案
+ const schedule = this.scheduleList[index];
+
+ // 填充表单数据
+ this.scheduleForm = {
+ time: schedule.time,
+ action: schedule.action,
+ relayIndexes: [...schedule.relayIndexes], // 深拷贝数组
+ weekdays: [...schedule.weekdays] // 深拷贝数组
+ };
+
+ // 显示弹窗
+ this.showPopup = true;
+ },
+
+ // 更新时间方案
+ async updateSchedule() {
+ try {
+ // 1. 更新本地数据
+ const updatedSchedule = {
+ ...this.scheduleForm
+ };
+
+ // 保留原始数据(如果存在)
+ if (this.scheduleList[this.editingIndex].originalData) {
+ updatedSchedule.originalData = this.scheduleList[this.editingIndex].originalData;
+ }
+
+ this.scheduleList[this.editingIndex] = updatedSchedule;
+ this.showPopup = false;
+
+ // 2. 转换为设备需要的格式
+ const deviceSchedule = this.convertToDeviceSchedule(updatedSchedule);
+ console.log('【updateSchedule】deviceSchedule:', deviceSchedule);
+
+ // 3. 准备要发送的数据
+ const scheduleConfig = {
+ shedule: this.scheduleList.map(s => s.originalData || this.convertToDeviceSchedule(s))
+ };
+ console.log('【updateSchedule】scheduleConfig:', scheduleConfig);
+
+ // 4. 找到 cfg_param 模型
+ const cfgParamModel = this.device.thingsModels.find(item => item.id === 'cfg_param');
+ if (!cfgParamModel) {
+ throw new Error('找不到定时配置模型');
+ }
+
+ // 5. 更新模型值
+ cfgParamModel.shadow = `JSON=${JSON.stringify(scheduleConfig)}`;
+
+ // 6. 通过 MQTT 发布
+ await this.mqttPublish(this.device, cfgParamModel);
+
+ // 7. 重置编辑状态
+ this.isEditing = false;
+ this.editingIndex = -1;
+
+ uni.showToast({
+ title: '时间方案更新成功',
+ icon: 'success'
+ });
+ } catch (error) {
+ console.error('更新时间方案失败:', error);
+ uni.showToast({
+ title: '更新失败: ' + error.message,
+ icon: 'none'
+ });
+ }
+ },
+
+ // 关闭时间方案弹窗
+ closeSchedulePopup() {
+ this.showPopup = false;
+ this.resetScheduleForm();
+ },
+
+ // 重置表单(在关闭弹窗时调用)
+ resetScheduleForm() {
+ this.scheduleForm = {
+ time: '12:00:00',
+ action: 1,
+ relayIndexes: [],
+ weekdays: []
+ };
+ this.isEditing = false;
+ this.editingIndex = -1;
+ },
}
}
-
\ No newline at end of file
diff --git a/pagesA/home/device/status/voice.vue b/pagesA/home/device/status/voice.vue
index 74715ba..d04fb2b 100644
--- a/pagesA/home/device/status/voice.vue
+++ b/pagesA/home/device/status/voice.vue
@@ -104,9 +104,11 @@
handleStatusChange(index, value)" size="22">
-
-
+ @change="(value) => handleStatusChange(index, value)" size="22" :disabled="device.status !== 3">
+
+
+
+
@@ -298,6 +300,7 @@
},
watch: {
device: function(newVal, oldVal) {
+ console.log("newVal", newVal)
if (newVal.deviceName !== '') {
this.deviceInfo = newVal;
if (this.deviceInfo.deviceType != 3) {
@@ -511,14 +514,17 @@
let productId = topics[1];
let deviceNum = topics[2];
message = JSON.parse(message.toString());
+ // 只处理当前设备
+ if (this.deviceInfo.serialNumber !== deviceNum) return;
+
if (topics[3] == 'status') {
- if (this.deviceInfo.serialNumber == deviceNum) {
- this.deviceInfo.status = message.status;
- this.deviceInfo.isShadow = message.isShadow;
- this.deviceInfo.rssi = message.rssi;
- this.updateDeviceStatus(this.deviceInfo);
- this.updateBasicSettings();
- }
+ this.deviceInfo.status = message.status;
+ this.deviceInfo.isShadow = message.isShadow;
+ this.deviceInfo.rssi = message.rssi;
+ this.deviceInfo = Object.assign({}, this.deviceInfo);
+ this.updateDeviceStatus(this.deviceInfo);
+ this.updateBasicSettings();
+ this.$forceUpdate();
}
if (topics[4] == 'reply') {
uni.showToast({
@@ -527,98 +533,66 @@
})
}
if (topics[3] == 'property' || topics[3] == 'function' || topic.endsWith('ws/service')) {
- if (this.deviceInfo.serialNumber == deviceNum) {
- for (let j = 0; j < message.message.length; j++) {
- let isComplete = false;
- for (let k = 0; k < this.deviceInfo.thingsModels.length && !isComplete; k++) {
- if (this.deviceInfo.thingsModels[k].id == message.message[j].id) {
- this.deviceInfo.thingsModels[k].shadow = message.message[j].value;
- isComplete = true;
- break;
- } else if (this.deviceInfo.thingsModels[k].datatype.type == "object") {
- for (let n = 0; n < this.deviceInfo.thingsModels[k].datatype.params
- .length; n++) {
- if (this.deviceInfo.thingsModels[k].datatype.params[n].id == message
- .message[j].id) {
- this.deviceInfo.thingsModels[k].datatype.params[n].shadow = message
- .message[j].value;
- isComplete = true;
- break;
- }
- }
- } else if (this.deviceInfo.thingsModels[k].datatype.type == "array") {
- if (this.deviceInfo.thingsModels[k].datatype.arrayType == "object") {
- if (String(message.message[j].id).indexOf("array_") == 0) {
- for (let n = 0; n < this.deviceInfo.thingsModels[k].datatype
- .arrayParams.length; n++) {
- for (let m = 0; m < this.deviceInfo.thingsModels[k].datatype
- .arrayParams[n].length; m++) {
- if (this.deviceInfo.thingsModels[k].datatype.arrayParams[n]
- [m].id == message.message[j].id) {
- this.deviceInfo.thingsModels[k].datatype.arrayParams[n]
- [m].shadow = message.message[j].value;
- isComplete = true;
- break;
- }
- }
- if (isComplete) {
- break;
- }
- }
- } else {
- for (let n = 0; n < this.deviceInfo.thingsModels[k].datatype
- .arrayParams.length; n++) {
- for (let m = 0; m < this.deviceInfo.thingsModels[k].datatype
- .arrayParams[n].length; m++) {
- let index = n > 9 ? String(n) : '0' + k;
- let prefix = 'array_' + index + '_';
- if (this.deviceInfo.thingsModels[k].datatype.arrayParams[n]
- [m].id == prefix + message.message[j].id) {
- this.deviceInfo.thingsModels[k].datatype.arrayParams[n]
- [m].shadow = message.message[j].value;
- isComplete = true;
- }
- }
- if (isComplete) {
- break;
- }
- }
- }
- } else {
- for (let n = 0; n < this.deviceInfo.thingsModels[k].datatype.arrayModel
- .length; n++) {
- if (this.deviceInfo.thingsModels[k].datatype.arrayModel[n].id ==
- message.message[j].id) {
- this.deviceInfo.thingsModels[k].datatype.arrayModel[n].shadow =
- message.message[j].value;
- isComplete = true;
- break;
- }
- }
+ if (Array.isArray(message.message)) {
+ let mp3ListChanged = false;
+ let playListChanged = false;
+ message.message.forEach(item => {
+ if (item.id === '103#mp3List') mp3ListChanged = true;
+ if (item.id === '103#playList') playListChanged = true;
+ // 你可以在这里补充其他针对性属性的处理
+ });
+ if (mp3ListChanged) {
+ const mp3ListModel = this.deviceInfo.thingsModels.find(model => model.id === '103#mp3List');
+ if (mp3ListModel && mp3ListModel.shadow) {
+ try {
+ const jsonStr = mp3ListModel.shadow.replace('JSON=', '');
+ const data = JSON.parse(jsonStr);
+ if (data && data.mp3_list) {
+ this.audioList = data.mp3_list.map((item, index) => {
+ const [id, ...nameArr] = item.split('_');
+ const name = nameArr.join('_') || item;
+ return {
+ id: Number(id),
+ name: name,
+ filename: item
+ };
+ });
+ this.audioList = [...this.audioList];
}
+ } catch (error) {
+ console.error('解析音频列表失败:', error);
}
- };
- for (let k = 0; k < this.deviceInfo.chartList.length && !isComplete; k++) {
- if (this.deviceInfo.chartList[k].id.indexOf("array_") == 0) {
- if (this.deviceInfo.chartList[k].id == message.message[j].id) {
- this.deviceInfo.chartList[k].shadow = message.message[j].value;
- isComplete = true;
- break;
- }
- } else {
- if (this.deviceInfo.chartList[k].id == message.message[j].id) {
- this.deviceInfo.chartList[k].shadow = message.message[j].value;
- isComplete = true;
- break;
+ }
+ }
+ if (playListChanged) {
+ const playListModel = this.deviceInfo.thingsModels.find(model => model.id === '103#playList');
+ if (playListModel && playListModel.shadow) {
+ try {
+ const jsonStr = playListModel.shadow.replace('JSON=', '');
+ const data = JSON.parse(jsonStr);
+ if (data && data.play_list) {
+ this.defaultList = data.play_list.map((item, index) => {
+ const beginTime = this.formatSecondsToTime(item.time.begin);
+ const endTime = this.formatSecondsToTime(item.time.end);
+ const weekdays = this.convertWeekToArray(item.time.week);
+ return {
+ id: index + 1,
+ name: item.play.filename,
+ playTime: `${beginTime} - ${endTime}`,
+ weekdays: weekdays.join(', '),
+ radarEnabled: item.speed.en === 1,
+ status: item.play.en === 1 ? '启用' : '禁用',
+ radarSpeed: item.speed.en === 1 ? `${item.speed.min}-${item.speed.max}km/h` : ''
+ };
+ });
+ this.defaultList = [...this.defaultList];
}
+ } catch (error) {
+ console.error('解析播放列表失败:', error);
}
- if (isComplete) {
- break;
- }
- };
+ }
}
}
- this.updateBasicSettings();
}
});
},
@@ -860,10 +834,15 @@
weekValue |= (1 << day);
});
+ const audioIndex = this.audioList.findIndex(a => a.name === this.newDefault.audioFile.name);
+ const filename = this.newDefault.audioFile.filename;
+
const newPlayItem = {
play: {
- num: this.isEditDefault && this.editDefaultIndex !== null && data.play_list[this.editDefaultIndex] ? data.play_list[this.editDefaultIndex].play.num : maxNum + 1,
- filename: this.newDefault.audioFile.name,
+ num: this.isEditDefault && this.editDefaultIndex !== null && data.play_list[this
+ .editDefaultIndex] ? data.play_list[this.editDefaultIndex].play.num :
+ maxNum + 1,
+ filename: filename,
en: 1
},
time: {
@@ -883,7 +862,7 @@
} else {
data.play_list.push(newPlayItem);
}
-
+ console.log(JSON.stringify(data))
playListModel.shadow = 'JSON=' + JSON.stringify(data);
try {
@@ -973,6 +952,8 @@
}
},
deleteDefault(index) {
+ if (!this.checkOnline()) return;
+
uni.showModal({
title: '提示',
content: '确认删除该播放项吗?',
@@ -1115,12 +1096,16 @@
if (data && data.mp3_list) {
this.audioList = data.mp3_list.map((item, index) => {
- const name = item.split('_')[1] || item;
+ const [id, ...nameArr] = item.split('_');
+ const name = nameArr.join('_') || item;
return {
- id: index + 1,
- name: name
+ id: Number(id),
+ name: name,
+ filename: item
};
});
+ // 强制整体赋值,保证小程序端响应
+ this.audioList = [...this.audioList];
}
} catch (error) {
console.error('解析音频列表失败:', error);
@@ -1150,6 +1135,8 @@
''
};
});
+ // 强制整体赋值,保证小程序端响应
+ this.defaultList = [...this.defaultList];
}
} catch (error) {
console.error('解析播放列表失败:', error);
@@ -1171,6 +1158,8 @@
return weekdays;
},
async handleStatusChange(index, value) {
+ if (!this.checkOnline()) return;
+
const playListModel = this.deviceInfo.thingsModels.find(model => model.id === '103#playList');
if (playListModel) {
try {
@@ -1225,16 +1214,19 @@
});
},
editDefault(index) {
+ if (!this.checkOnline()) return;
+
const item = this.defaultList[index];
- const audioFile = this.audioList.find(a => a.name === item.name);
- const audioIndex = this.audioList.findIndex(a => a.name === item.name);
+ const audioFile = this.audioList.find(a => a.filename === item.name || a.name === item.name);
+ const audioIndex = this.audioList.findIndex(a => a.filename === item.name || a.name === item.name);
this.newDefault = {
startTime: item.playTime.split(' - ')[0],
endTime: item.playTime.split(' - ')[1],
repeatDays: this.weekDays.map((d, i) => item.weekdays.includes(d) ? i : -1).filter(i => i !== -1),
radarEnabled: item.radarEnabled,
minSpeed: item.radarEnabled && item.radarSpeed ? item.radarSpeed.split('-')[0] : '',
- maxSpeed: item.radarEnabled && item.radarSpeed ? item.radarSpeed.split('-')[1].replace('km/h', '') : '',
+ maxSpeed: item.radarEnabled && item.radarSpeed ? item.radarSpeed.split('-')[1].replace('km/h',
+ '') : '',
audioFile: audioFile
};
this.audioIndex = audioIndex;
@@ -1681,6 +1673,7 @@
.slider-with-value {
width: 100% !important;
display: block !important;
+
.custom-slider {
width: 100% !important;
min-width: 0 !important;
diff --git a/vue.config.js b/vue.config.js
index e69de29..8c59e61 100644
--- a/vue.config.js
+++ b/vue.config.js
@@ -0,0 +1,15 @@
+// vue.config.js
+const {
+ codeInspectorPlugin
+} = require('code-inspector-plugin');
+
+module.exports = {
+ // ...other code
+ chainWebpack: (config) => {
+ config.plugin('code-inspector-plugin').use(
+ codeInspectorPlugin({
+ bundler: 'webpack',
+ })
+ );
+ },
+};
\ No newline at end of file