正在显示
1 个修改的文件
包含
78 行增加
和
68 行删除
| ... | @@ -6,12 +6,12 @@ | ... | @@ -6,12 +6,12 @@ |
| 6 | <span class="title">欢迎进入本框架</span> | 6 | <span class="title">欢迎进入本框架</span> |
| 7 | <system-information></system-information> | 7 | <system-information></system-information> |
| 8 | <div v-if="textarray.length === 0"> | 8 | <div v-if="textarray.length === 0"> |
| 9 | - <span>{{text}}</span> | 9 | + <span>{{ text }}</span> |
| 10 | </div> | 10 | </div> |
| 11 | - <div v-for="(itme,index) in textarray" :key="index" v-else> | 11 | + <div v-for="(itme, index) in textarray" :key="index" v-else> |
| 12 | - <span>{{itme._id}}</span> | 12 | + <span>{{ itme._id }}</span> |
| 13 | - <span>{{itme.name}}</span> | 13 | + <span>{{ itme.name }}</span> |
| 14 | - <span>{{itme.age}}</span> | 14 | + <span>{{ itme.age }}</span> |
| 15 | </div> | 15 | </div> |
| 16 | </div> | 16 | </div> |
| 17 | 17 | ||
| ... | @@ -21,13 +21,23 @@ | ... | @@ -21,13 +21,23 @@ |
| 21 | <el-button type="primary" round @click="open()">控制台打印</el-button> | 21 | <el-button type="primary" round @click="open()">控制台打印</el-button> |
| 22 | <el-button type="primary" round @click="setdata">写入数据</el-button> | 22 | <el-button type="primary" round @click="setdata">写入数据</el-button> |
| 23 | <el-button type="primary" round @click="getdata">读取数据</el-button> | 23 | <el-button type="primary" round @click="getdata">读取数据</el-button> |
| 24 | - <el-button type="primary" round @click="deledata">清除所有数据</el-button> | 24 | + <el-button type="primary" round @click="deledata" |
| 25 | - <el-button type="primary" round @click="CheckUpdate('one')">检查更新</el-button> | 25 | + >清除所有数据</el-button |
| 26 | + > | ||
| 27 | + <el-button type="primary" round @click="CheckUpdate('one')" | ||
| 28 | + >检查更新</el-button | ||
| 29 | + > | ||
| 26 | </div> | 30 | </div> |
| 27 | <div class="doc"> | 31 | <div class="doc"> |
| 28 | - <el-button type="primary" round @click="CheckUpdate('two')">检查更新(第二种方法)</el-button> | 32 | + <el-button type="primary" round @click="CheckUpdate('two')" |
| 29 | - <el-button type="primary" round @click="StartServer">启动内置服务端</el-button> | 33 | + >检查更新(第二种方法)</el-button |
| 30 | - <el-button type="primary" round @click="getMessage">查看消息</el-button> | 34 | + > |
| 35 | + <el-button type="primary" round @click="StartServer" | ||
| 36 | + >启动内置服务端</el-button | ||
| 37 | + > | ||
| 38 | + <el-button type="primary" round @click="getMessage" | ||
| 39 | + >查看消息</el-button | ||
| 40 | + > | ||
| 31 | </div> | 41 | </div> |
| 32 | </div> | 42 | </div> |
| 33 | </main> | 43 | </main> |
| ... | @@ -61,7 +71,7 @@ export default { | ... | @@ -61,7 +71,7 @@ export default { |
| 61 | text: "等待数据读取", | 71 | text: "等待数据读取", |
| 62 | newdata: { | 72 | newdata: { |
| 63 | name: "yyy", | 73 | name: "yyy", |
| 64 | - age: "12" | 74 | + age: "12", |
| 65 | }, | 75 | }, |
| 66 | logo: require("@/assets/logo.png"), | 76 | logo: require("@/assets/logo.png"), |
| 67 | textarray: [], | 77 | textarray: [], |
| ... | @@ -71,11 +81,11 @@ export default { | ... | @@ -71,11 +81,11 @@ export default { |
| 71 | { color: "#e6a23c", percentage: 40 }, | 81 | { color: "#e6a23c", percentage: 40 }, |
| 72 | { color: "#6f7ad3", percentage: 60 }, | 82 | { color: "#6f7ad3", percentage: 60 }, |
| 73 | { color: "#1989fa", percentage: 80 }, | 83 | { color: "#1989fa", percentage: 80 }, |
| 74 | - { color: "#5cb87a", percentage: 100 } | 84 | + { color: "#5cb87a", percentage: 100 }, |
| 75 | ], | 85 | ], |
| 76 | dialogVisible: false, | 86 | dialogVisible: false, |
| 77 | progressStaus: null, | 87 | progressStaus: null, |
| 78 | - filePath: "" | 88 | + filePath: "", |
| 79 | }), | 89 | }), |
| 80 | created() { | 90 | created() { |
| 81 | console.log(__lib); | 91 | console.log(__lib); |
| ... | @@ -83,30 +93,66 @@ export default { | ... | @@ -83,30 +93,66 @@ export default { |
| 83 | this.$ipcApi.on("confirm-message", (event, arg) => { | 93 | this.$ipcApi.on("confirm-message", (event, arg) => { |
| 84 | console.log(arg); | 94 | console.log(arg); |
| 85 | if (arg.response === 0) { | 95 | if (arg.response === 0) { |
| 86 | - this.$db.deleall({name: "yyy"}).then(res => { | 96 | + this.$db.deleall({ name: "yyy" }).then((res) => { |
| 87 | console.log(res); | 97 | console.log(res); |
| 88 | if (res !== 0) { | 98 | if (res !== 0) { |
| 89 | this.getdata(); | 99 | this.getdata(); |
| 90 | this.$message({ | 100 | this.$message({ |
| 91 | message: "成功删除" + res + "条", | 101 | message: "成功删除" + res + "条", |
| 92 | - type: "success" | 102 | + type: "success", |
| 93 | }); | 103 | }); |
| 94 | } else { | 104 | } else { |
| 95 | let errormsg = { | 105 | let errormsg = { |
| 96 | title: "错误", | 106 | title: "错误", |
| 97 | - message: "已经没有数据可以被删除!" | 107 | + message: "已经没有数据可以被删除!", |
| 98 | }; | 108 | }; |
| 99 | this.$ipcApi.send("open-errorbox", errormsg); | 109 | this.$ipcApi.send("open-errorbox", errormsg); |
| 100 | } | 110 | } |
| 101 | }); | 111 | }); |
| 102 | } | 112 | } |
| 103 | }); | 113 | }); |
| 114 | + this.$ipcApi.on("confirm-download", (event, arg) => { | ||
| 115 | + if (arg) { | ||
| 116 | + this.dialogVisible = true; | ||
| 117 | + } | ||
| 118 | + }); | ||
| 119 | + this.$ipcApi.on("download-progress", (event, arg) => { | ||
| 120 | + this.percentage = Number(arg); | ||
| 121 | + }); | ||
| 122 | + this.$ipcApi.on("download-error", (event, arg) => { | ||
| 123 | + if (arg) { | ||
| 124 | + this.progressStaus = "exception"; | ||
| 125 | + this.percentage = 40; | ||
| 126 | + this.colors = "#d81e06"; | ||
| 127 | + } | ||
| 128 | + }); | ||
| 129 | + this.$ipcApi.on("download-paused", (event, arg) => { | ||
| 130 | + if (arg) { | ||
| 131 | + this.progressStaus = "warning"; | ||
| 132 | + this.$alert("下载由于未知原因被中断!", "提示", { | ||
| 133 | + confirmButtonText: "重试", | ||
| 134 | + callback: (action) => { | ||
| 135 | + this.$ipcApi.send("satrt-download"); | ||
| 136 | + }, | ||
| 137 | + }); | ||
| 138 | + } | ||
| 139 | + }); | ||
| 140 | + this.$ipcApi.on("download-done", (event, age) => { | ||
| 141 | + this.filePath = age.filePath; | ||
| 142 | + this.progressStaus = "success"; | ||
| 143 | + this.$alert("更新下载完成!", "提示", { | ||
| 144 | + confirmButtonText: "确定", | ||
| 145 | + callback: (action) => { | ||
| 146 | + this.$electron.shell.openItem(this.filePath); | ||
| 147 | + }, | ||
| 148 | + }); | ||
| 149 | + }); | ||
| 104 | }, | 150 | }, |
| 105 | methods: { | 151 | methods: { |
| 106 | getMessage() { | 152 | getMessage() { |
| 107 | - message().then(res => { | 153 | + message().then((res) => { |
| 108 | this.$alert(res.data, "提示", { | 154 | this.$alert(res.data, "提示", { |
| 109 | - confirmButtonText: "确定" | 155 | + confirmButtonText: "确定", |
| 110 | }); | 156 | }); |
| 111 | }); | 157 | }); |
| 112 | }, | 158 | }, |
| ... | @@ -116,30 +162,29 @@ export default { | ... | @@ -116,30 +162,29 @@ export default { |
| 116 | console.log(arg); | 162 | console.log(arg); |
| 117 | this.$message({ | 163 | this.$message({ |
| 118 | type: "success", | 164 | type: "success", |
| 119 | - message: arg | 165 | + message: arg, |
| 120 | }); | 166 | }); |
| 121 | }); | 167 | }); |
| 122 | }, | 168 | }, |
| 123 | // 获取electron方法 | 169 | // 获取electron方法 |
| 124 | - open() { | 170 | + open() {}, |
| 125 | - }, | ||
| 126 | // 设置数据库的数据 | 171 | // 设置数据库的数据 |
| 127 | setdata() { | 172 | setdata() { |
| 128 | this.$db | 173 | this.$db |
| 129 | .adddata(this.newdata) | 174 | .adddata(this.newdata) |
| 130 | - .then(res => this.getdata()) | 175 | + .then((res) => this.getdata()) |
| 131 | - .catch(err => console.log(err)); | 176 | + .catch((err) => console.log(err)); |
| 132 | }, | 177 | }, |
| 133 | // 获取数据库的数据 | 178 | // 获取数据库的数据 |
| 134 | getdata() { | 179 | getdata() { |
| 135 | this.$db | 180 | this.$db |
| 136 | .finddata() | 181 | .finddata() |
| 137 | - .then(res => { | 182 | + .then((res) => { |
| 138 | console.log(res); | 183 | console.log(res); |
| 139 | this.textarray = res; | 184 | this.textarray = res; |
| 140 | console.log(this.textarray); | 185 | console.log(this.textarray); |
| 141 | }) | 186 | }) |
| 142 | - .catch(err => console.log(err)); | 187 | + .catch((err) => console.log(err)); |
| 143 | }, | 188 | }, |
| 144 | // 清空数据库的数据 | 189 | // 清空数据库的数据 |
| 145 | deledata() { | 190 | deledata() { |
| ... | @@ -148,7 +193,7 @@ export default { | ... | @@ -148,7 +193,7 @@ export default { |
| 148 | title: "清除数据", | 193 | title: "清除数据", |
| 149 | buttons: ["确定了!", "才不要,我手滑了"], | 194 | buttons: ["确定了!", "才不要,我手滑了"], |
| 150 | noLink: true, | 195 | noLink: true, |
| 151 | - message: "此操作会清空本地数据库中的所有数据,是否继续?" | 196 | + message: "此操作会清空本地数据库中的所有数据,是否继续?", |
| 152 | }; | 197 | }; |
| 153 | this.$ipcApi.send("open-messagebox", data); | 198 | this.$ipcApi.send("open-messagebox", data); |
| 154 | }, | 199 | }, |
| ... | @@ -163,7 +208,7 @@ export default { | ... | @@ -163,7 +208,7 @@ export default { |
| 163 | switch (data.state) { | 208 | switch (data.state) { |
| 164 | case -1: | 209 | case -1: |
| 165 | const msgdata = { | 210 | const msgdata = { |
| 166 | - title: data.msg | 211 | + title: data.msg, |
| 167 | }; | 212 | }; |
| 168 | api.MessageBox(dialog, msgdata); | 213 | api.MessageBox(dialog, msgdata); |
| 169 | break; | 214 | break; |
| ... | @@ -173,7 +218,7 @@ export default { | ... | @@ -173,7 +218,7 @@ export default { |
| 173 | case 1: | 218 | case 1: |
| 174 | this.$message({ | 219 | this.$message({ |
| 175 | type: "success", | 220 | type: "success", |
| 176 | - message: "已检查到新版本,开始下载" | 221 | + message: "已检查到新版本,开始下载", |
| 177 | }); | 222 | }); |
| 178 | this.dialogVisible = true; | 223 | this.dialogVisible = true; |
| 179 | break; | 224 | break; |
| ... | @@ -187,9 +232,9 @@ export default { | ... | @@ -187,9 +232,9 @@ export default { |
| 187 | this.progressStaus = "success"; | 232 | this.progressStaus = "success"; |
| 188 | this.$alert("更新下载完成!", "提示", { | 233 | this.$alert("更新下载完成!", "提示", { |
| 189 | confirmButtonText: "确定", | 234 | confirmButtonText: "确定", |
| 190 | - callback: action => { | 235 | + callback: (action) => { |
| 191 | this.$ipcApi.send("confirm-update"); | 236 | this.$ipcApi.send("confirm-update"); |
| 192 | - } | 237 | + }, |
| 193 | }); | 238 | }); |
| 194 | break; | 239 | break; |
| 195 | 240 | ||
| ... | @@ -201,42 +246,7 @@ export default { | ... | @@ -201,42 +246,7 @@ export default { |
| 201 | case "two": | 246 | case "two": |
| 202 | console.log(111); | 247 | console.log(111); |
| 203 | this.$ipcApi.send("start-download"); | 248 | this.$ipcApi.send("start-download"); |
| 204 | - this.$ipcApi.on("confirm-download", (event, arg) => { | 249 | + |
| 205 | - if (arg) { | ||
| 206 | - this.dialogVisible = true; | ||
| 207 | - } | ||
| 208 | - }); | ||
| 209 | - this.$ipcApi.on("download-progress", (event, arg) => { | ||
| 210 | - this.percentage = Number(arg); | ||
| 211 | - }); | ||
| 212 | - this.$ipcApi.on("download-error", (event, arg) => { | ||
| 213 | - if (arg) { | ||
| 214 | - this.progressStaus = "exception"; | ||
| 215 | - this.percentage = 40; | ||
| 216 | - this.colors = "#d81e06"; | ||
| 217 | - } | ||
| 218 | - }); | ||
| 219 | - this.$ipcApi.on("download-paused", (event, arg) => { | ||
| 220 | - if (arg) { | ||
| 221 | - this.progressStaus = "warning"; | ||
| 222 | - this.$alert("下载由于未知原因被中断!", "提示", { | ||
| 223 | - confirmButtonText: "重试", | ||
| 224 | - callback: action => { | ||
| 225 | - this.$ipcApi.send("satrt-download"); | ||
| 226 | - } | ||
| 227 | - }); | ||
| 228 | - } | ||
| 229 | - }); | ||
| 230 | - this.$ipcApi.on("download-done", (event, age) => { | ||
| 231 | - this.filePath = age.filePath; | ||
| 232 | - this.progressStaus = "success"; | ||
| 233 | - this.$alert("更新下载完成!", "提示", { | ||
| 234 | - confirmButtonText: "确定", | ||
| 235 | - callback: action => { | ||
| 236 | - this.$electron.shell.openItem(this.filePath); | ||
| 237 | - } | ||
| 238 | - }); | ||
| 239 | - }); | ||
| 240 | break; | 250 | break; |
| 241 | 251 | ||
| 242 | default: | 252 | default: |
| ... | @@ -245,7 +255,7 @@ export default { | ... | @@ -245,7 +255,7 @@ export default { |
| 245 | }, | 255 | }, |
| 246 | handleClose() { | 256 | handleClose() { |
| 247 | this.dialogVisible = false; | 257 | this.dialogVisible = false; |
| 248 | - } | 258 | + }, |
| 249 | }, | 259 | }, |
| 250 | destroyed() { | 260 | destroyed() { |
| 251 | this.$ipcApi.remove("confirm-message"); | 261 | this.$ipcApi.remove("confirm-message"); |
| ... | @@ -254,7 +264,7 @@ export default { | ... | @@ -254,7 +264,7 @@ export default { |
| 254 | this.$ipcApi.remove("confirm-download"); | 264 | this.$ipcApi.remove("confirm-download"); |
| 255 | this.$ipcApi.remove("download-progress"); | 265 | this.$ipcApi.remove("download-progress"); |
| 256 | this.$ipcApi.remove("download-error"); | 266 | this.$ipcApi.remove("download-error"); |
| 257 | - } | 267 | + }, |
| 258 | }; | 268 | }; |
| 259 | </script> | 269 | </script> |
| 260 | 270 | ... | ... |
-
请 注册 或 登录 后发表评论