Sky
提交者 GitHub

Merge pull request #25 from jiumengs/master

修复进程通信重复监听
...@@ -79,6 +79,28 @@ export default { ...@@ -79,6 +79,28 @@ export default {
79 }), 79 }),
80 created() { 80 created() {
81 console.log(__lib); 81 console.log(__lib);
82 + // 异步进程通信监听
83 + this.$ipcApi.on("confirm-message", (event, arg) => {
84 + console.log(arg);
85 + if (arg.response === 0) {
86 + this.$db.deleall({name: "yyy"}).then(res => {
87 + console.log(res);
88 + if (res !== 0) {
89 + this.getdata();
90 + this.$message({
91 + message: "成功删除" + res + "条",
92 + type: "success"
93 + });
94 + } else {
95 + let errormsg = {
96 + title: "错误",
97 + message: "已经没有数据可以被删除!"
98 + };
99 + this.$ipcApi.send("open-errorbox", errormsg);
100 + }
101 + });
102 + }
103 + });
82 }, 104 },
83 methods: { 105 methods: {
84 getMessage() { 106 getMessage() {
...@@ -129,27 +151,6 @@ export default { ...@@ -129,27 +151,6 @@ export default {
129 message: "此操作会清空本地数据库中的所有数据,是否继续?" 151 message: "此操作会清空本地数据库中的所有数据,是否继续?"
130 }; 152 };
131 this.$ipcApi.send("open-messagebox", data); 153 this.$ipcApi.send("open-messagebox", data);
132 - this.$ipcApi.on("confirm-message", (event, arg) => {
133 - console.log(arg);
134 - if (arg.response === 0) {
135 - this.$db.deleall({ name: "yyy" }).then(res => {
136 - console.log(res);
137 - if (res !== 0) {
138 - this.getdata();
139 - this.$message({
140 - message: "成功删除" + res + "条",
141 - type: "success"
142 - });
143 - } else {
144 - let errormsg = {
145 - title: "错误",
146 - message: "已经没有数据可以被删除!"
147 - };
148 - this.$ipcApi.send("open-errorbox", errormsg);
149 - }
150 - });
151 - }
152 - });
153 }, 154 },
154 CheckUpdate(data) { 155 CheckUpdate(data) {
155 switch (data) { 156 switch (data) {
......