正在显示
3 个修改的文件
包含
40 行增加
和
6 行删除
| 1 | { | 1 | { |
| 2 | "name": "my-project", | 2 | "name": "my-project", |
| 3 | "version": "0.0.1", | 3 | "version": "0.0.1", |
| 4 | - "author": "fengjie <fengjie1438@f-road.com.cn>", | 4 | + "author": "sky <https://github.com/umbrella22>", |
| 5 | "description": "An electron-vue project", | 5 | "description": "An electron-vue project", |
| 6 | "license": null, | 6 | "license": null, |
| 7 | "main": "./dist/electron/main.js", | 7 | "main": "./dist/electron/main.js", | ... | ... |
| ... | @@ -30,7 +30,7 @@ | ... | @@ -30,7 +30,7 @@ |
| 30 | 30 | ||
| 31 | <script> | 31 | <script> |
| 32 | import SystemInformation from "./LandingPage/SystemInformation"; | 32 | import SystemInformation from "./LandingPage/SystemInformation"; |
| 33 | - | 33 | +import api from '../tools/dialog' |
| 34 | export default { | 34 | export default { |
| 35 | name: "landing-page", | 35 | name: "landing-page", |
| 36 | components: { SystemInformation }, | 36 | components: { SystemInformation }, |
| ... | @@ -63,13 +63,16 @@ export default { | ... | @@ -63,13 +63,16 @@ export default { |
| 63 | .catch(err => console.log(err)); | 63 | .catch(err => console.log(err)); |
| 64 | }, | 64 | }, |
| 65 | deledata(){ | 65 | deledata(){ |
| 66 | - let data={ | 66 | + const dialog = this.$electron.remote.dialog |
| 67 | - name:"yyy" | 67 | + const data = { |
| 68 | + title:'清除数据', | ||
| 69 | + buttons:['OK', 'Cancel'], | ||
| 70 | + message:'此操作会清空本地数据库中的所有数据,是否继续?' | ||
| 68 | } | 71 | } |
| 69 | - this.$db.deleall(data).then(res=>{ | 72 | + api.MessageBox(dialog,data,this.$db.deleall({name:'yyy'})).then(res=>{ |
| 70 | console.log(res) | 73 | console.log(res) |
| 71 | }) | 74 | }) |
| 72 | - } | 75 | + }, |
| 73 | } | 76 | } |
| 74 | }; | 77 | }; |
| 75 | </script> | 78 | </script> | ... | ... |
src/renderer/tools/dialog.js
0 → 100644
| 1 | +export default { | ||
| 2 | + /** | ||
| 3 | + * @export | ||
| 4 | + * @param {Array} data | ||
| 5 | + * @param {Object} dialog | ||
| 6 | + * @param {function} fun | ||
| 7 | + * @returns | ||
| 8 | + * @feature 消息弹窗通用函数 | ||
| 9 | + */ | ||
| 10 | + MessageBox(dialog, data, fun) { | ||
| 11 | + return new Promise((resolve, reject) => { | ||
| 12 | + dialog.showMessageBox({ | ||
| 13 | + type: 'info', | ||
| 14 | + title: data.title, | ||
| 15 | + buttons: data.buttons, | ||
| 16 | + message: data.message | ||
| 17 | + }, index => { | ||
| 18 | + if (index === 0) { | ||
| 19 | + let tempfun = async () => { | ||
| 20 | + try { | ||
| 21 | + resolve(await fun) | ||
| 22 | + } catch (error) { | ||
| 23 | + reject(error) | ||
| 24 | + } | ||
| 25 | + } | ||
| 26 | + tempfun() | ||
| 27 | + } | ||
| 28 | + }) | ||
| 29 | + }) | ||
| 30 | + } | ||
| 31 | +} | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
-
请 注册 或 登录 后发表评论