From 07948ec07c94ee4e1ce1dfb376e124a8927b776d Mon Sep 17 00:00:00 2001 From: fhysy <1149505133@qq.com> Date: Tue, 27 May 2025 14:17:38 +0800 Subject: [PATCH] =?UTF-8?q?fast(=E5=9E=8B=E5=8F=B7):=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E4=BB=A3=E7=A0=81=E7=BB=93=E6=9E=84=E5=B9=B6=E7=A7=BB=E9=99=A4?= =?UTF-8?q?=E7=B3=BB=E7=BB=9F=E9=85=8D=E7=BD=AE=E8=84=9A=E6=9C=AC=E3=80=81?= =?UTF-8?q?=E8=A7=A3=E5=86=B3=E5=9E=8B=E5=8F=B7=E5=88=97=E8=A1=A8=E9=80=89?= =?UTF-8?q?=E6=8B=A9=E5=9E=8B=E5=8F=B7=E6=8A=A5=E9=94=99=E9=97=AE=E9=A2=98?= =?UTF-8?q?=EF=BC=8C=E6=89=93=E5=8C=85=E5=B1=8F=E8=94=BDconsole=E5=92=8Cde?= =?UTF-8?q?bugger?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 移除 public/index.html 中的系统配置脚本引用 - 删除 public/systenConfig.js 文件 - 优化多个组件中的代码结构,移除未使用的变量和注释 - 解决型号列表选择系列报错问题和不显示问题 - 在 vue.config.js 中添加生产环境下的屏蔽console和debugger --- public/index.html | 1 - public/systenConfig.js | 3 - src/layout/components/Navbar.vue | 2 +- src/layout/index.vue | 16 +- src/store/modules/attribute.js | 1 - src/views/iot/model/index.vue | 1 - src/views/iot/vendor/index.vue | 2 +- src/views/profile/attribute/attributeView.vue | 435 ++++++++---------- src/views/profile/attribute/eventView.vue | 11 + .../profile/attribute/functionFormModel.vue | 2 +- src/views/profile/attribute/functionView.vue | 44 +- src/views/profile/attribute/groupView.vue | 12 - src/views/profile/attribute/index.vue | 77 +--- vue.config.js | 19 + 14 files changed, 292 insertions(+), 334 deletions(-) delete mode 100644 public/systenConfig.js diff --git a/public/index.html b/public/index.html index bc6f459e..f74c2b2d 100644 --- a/public/index.html +++ b/public/index.html @@ -225,7 +225,6 @@ - <% if (process.env.VUE_APP_ENV === 'drprod' ) { %> diff --git a/src/views/profile/attribute/eventView.vue b/src/views/profile/attribute/eventView.vue index 845d48b7..28f272a6 100644 --- a/src/views/profile/attribute/eventView.vue +++ b/src/views/profile/attribute/eventView.vue @@ -136,6 +136,17 @@ export default { } }; }, + computed: { + eventsList() { + return this.$store.state.attribute.eventList; + } + }, + watch: { + eventsList(newVal, oldVal) { + // 处理数据变化 + this.getList(); + } + }, created() { this.getList(); }, diff --git a/src/views/profile/attribute/functionFormModel.vue b/src/views/profile/attribute/functionFormModel.vue index 8c8e3dd6..c631a53f 100644 --- a/src/views/profile/attribute/functionFormModel.vue +++ b/src/views/profile/attribute/functionFormModel.vue @@ -265,7 +265,7 @@ export default { }, functionList: { type: Array, - default: [] + default: () => [] } }, data() { diff --git a/src/views/profile/attribute/functionView.vue b/src/views/profile/attribute/functionView.vue index 6c01ea59..403568a5 100644 --- a/src/views/profile/attribute/functionView.vue +++ b/src/views/profile/attribute/functionView.vue @@ -12,7 +12,7 @@ - + @@ -42,7 +42,7 @@ @click="handleMoveUp(scope.$index)" >上移 import functionFormModel from "@/views/profile/attribute/functionFormModel"; +import { mapGetters } from "vuex"; export default { name: "FunctionView", @@ -104,7 +105,7 @@ export default { // 遮罩层 loading: true, // 功能定义表格数据 - functionList: [], + functionsList: [], // 弹出层标题 title: "", // 表单参数 @@ -123,6 +124,15 @@ export default { } }; }, + computed: { + ...mapGetters(["functionList"]), + }, + watch: { + functionList(newVal, oldVal) { + // 处理数据变化 + this.getList() + } + }, created() { this.getList(); }, @@ -139,10 +149,10 @@ export default { /** 查询功能定义列表 */ getList() { this.loading = true; - this.functionList = []; + this.functionsList = []; setTimeout(() => { this.$store.dispatch("GetFunctionList").then(res => { - this.functionList = res; + this.functionsList = res; this.$forceUpdate(); this.loading = false; }); @@ -150,9 +160,9 @@ export default { }, setList(list) { this.loading = true; - this.functionList = []; + this.functionsList = []; setTimeout(() => { - this.functionList = list; + this.functionsList = list; this.$forceUpdate(); this.loading = false; }, 50); @@ -207,12 +217,12 @@ export default { if (index === 0) return; // 已经是第一个,不能再上移 // 交换当前项与上一项的位置 - const temp = this.functionList[index]; - this.$set(this.functionList, index, this.functionList[index - 1]); - this.$set(this.functionList, index - 1, temp); + const temp = this.functionsList[index]; + this.$set(this.functionsList, index, this.functionsList[index - 1]); + this.$set(this.functionsList, index - 1, temp); // 保存到 store - this.$store.dispatch("UpdateFunctionList", this.functionList).then(() => { + this.$store.dispatch("UpdateFunctionList", this.functionsList).then(() => { this.$message({ type: 'success', message: '上移成功!' @@ -229,15 +239,15 @@ export default { * @param {Number} index 当前功能索引 */ handleMoveDown(index) { - if (index === this.functionList.length - 1) return; // 已经是最后一个,不能再下移 + if (index === this.functionsList.length - 1) return; // 已经是最后一个,不能再下移 // 交换当前项与下一项的位置 - const temp = this.functionList[index]; - this.$set(this.functionList, index, this.functionList[index + 1]); - this.$set(this.functionList, index + 1, temp); + const temp = this.functionsList[index]; + this.$set(this.functionsList, index, this.functionsList[index + 1]); + this.$set(this.functionsList, index + 1, temp); // 保存到 store - this.$store.dispatch("UpdateFunctionList", this.functionList).then(() => { + this.$store.dispatch("UpdateFunctionList", this.functionsList).then(() => { this.$message({ type: 'success', message: '下移成功!' diff --git a/src/views/profile/attribute/groupView.vue b/src/views/profile/attribute/groupView.vue index 6b9625ea..51c88c05 100644 --- a/src/views/profile/attribute/groupView.vue +++ b/src/views/profile/attribute/groupView.vue @@ -184,18 +184,6 @@ export default { this.getList(); }, methods: { - // 查询分组参数列表 - getCmdById(row) { - // getCmdFun({ - // cmdId: row.cmdId, - // sourceId: this.sourceId - // }).then(res => { - // this.selectCmdInfo = row; - // this.paramsList = res.data; - // this.cmdParamTitle = `${row.cmdName}--示例`; - // this.paramsOpen = true; - // }); - }, /** 重置按钮操作 */ resetQuery() { this.resetForm("queryForm"); diff --git a/src/views/profile/attribute/index.vue b/src/views/profile/attribute/index.vue index c25503eb..8a57162b 100644 --- a/src/views/profile/attribute/index.vue +++ b/src/views/profile/attribute/index.vue @@ -47,8 +47,6 @@ import attributeView from "./attributeView"; import groupView from "./groupView"; import FunctionView from "./functionView"; import EventView from "./eventView"; -// this.$store.state.tagsView.visitedViews -// this.$store.dispatch("Login", this.loginForm) export default { components: { FunctionView, attributeView, groupView, EventView }, props: { @@ -138,42 +136,6 @@ export default { break; } }, - functionEvent(data) { - switch (data.type) { - case "add": - // 执行add - this.$emit("handleEvent", { - type: data.type, - title: "新增参数", - component: "functionForm", - paramIdx: null - }); - break; - - case "update": - this.$emit("handleEvent", { - type: data.type, - title: "修改参数", - component: "functionForm", - paramIdx: data.idx, - row: data.row - }); - break; - - case "list": - this.$refs.functionref.getList(); - break; - - case "param": - this.$emit("handleEvent", { - type: data.type, - title: "物模型", - component: "paramsJson", - paramIdx: null - }); - break; - } - }, forceUpdate(component) { if (component === "groupForm") { this.$refs.groupref && this.$refs.groupref.getList(); @@ -185,14 +147,28 @@ export default { }, forceUpdateList(component) { let arttributeList = [], - groupList = []; + groupList = [], + functionList = [], + eventList = []; try { - arttributeList = JSON.parse(this.arttributeList); + let json = JSON.parse(this.arttributeList); + // if (json.properties) { + arttributeList = json.properties; groupList = JSON.parse(this.groupList); + functionList = json.functions; + eventList = json.events; + // } else { + // arttributeList = json; + // groupList = JSON.parse(this.groupList); + // functionList = json.functions; + // eventList = json.events; + // } } catch (error) { - (arttributeList = []), (groupList = []); - console.log(error); + arttributeList = []; + groupList = []; + functionList = []; + eventList = []; } if (component === "groupForm") { @@ -216,27 +192,24 @@ export default { try { let json = JSON.parse(this.arttributeList); - if (json.properties) { + // if (json.properties) { arttributeList = json.properties; groupList = JSON.parse(this.groupList); functionList = json.functions; eventList = json.events; - } else { - arttributeList = json; - groupList = JSON.parse(this.groupList); - functionList = json.functions; - eventList = json.events; - } + // } else { + // arttributeList = json; + // groupList = JSON.parse(this.groupList); + // functionList = json.functions; + // eventList = json.events; + // } } catch (error) { arttributeList = []; groupList = []; functionList = []; eventList = []; - console.log(error); } - console.log(arttributeList, groupList); - this.$store.dispatch("InitAttributeAndGroup", { attrList: arttributeList, groupList: groupList, diff --git a/vue.config.js b/vue.config.js index 5f9f2caa..02e0d559 100644 --- a/vue.config.js +++ b/vue.config.js @@ -134,6 +134,25 @@ module.exports = { from: path.resolve(__dirname, './public/robots.txt'), //防爬虫文件 to: './', //到根目录下 } + if (process.env.NODE_ENV === 'production' || process.env.NODE_ENV === 'drprod' || process.env.NODE_ENV === 'drgyprod' || process.env.NODE_ENV === 'ccprod') { + config.optimization.minimizer('terser').tap(args => { + args[0].terserOptions = { + compress: { + // 注释console.* + drop_console: true, + // remove debugger + drop_debugger: true, + // 移除特定的 console 方法 + pure_funcs: ['console.log', 'console.info', 'console.debug'] + }, + format: { + comments: false + } + }; + args[0].extractComments = false; + return args; + }); + } } ) }