umbrella22

添加原生弹窗

{
"name": "my-project",
"version": "0.0.1",
"author": "fengjie <fengjie1438@f-road.com.cn>",
"author": "sky <https://github.com/umbrella22>",
"description": "An electron-vue project",
"license": null,
"main": "./dist/electron/main.js",
......
......@@ -30,7 +30,7 @@
<script>
import SystemInformation from "./LandingPage/SystemInformation";
import api from '../tools/dialog'
export default {
name: "landing-page",
components: { SystemInformation },
......@@ -63,13 +63,16 @@ export default {
.catch(err => console.log(err));
},
deledata(){
let data={
name:"yyy"
const dialog = this.$electron.remote.dialog
const data = {
title:'清除数据',
buttons:['OK', 'Cancel'],
message:'此操作会清空本地数据库中的所有数据,是否继续?'
}
this.$db.deleall(data).then(res=>{
api.MessageBox(dialog,data,this.$db.deleall({name:'yyy'})).then(res=>{
console.log(res)
})
}
},
}
};
</script>
......
export default {
/**
* @export
* @param {Array} data
* @param {Object} dialog
* @param {function} fun
* @returns
* @feature 消息弹窗通用函数
*/
MessageBox(dialog, data, fun) {
return new Promise((resolve, reject) => {
dialog.showMessageBox({
type: 'info',
title: data.title,
buttons: data.buttons,
message: data.message
}, index => {
if (index === 0) {
let tempfun = async () => {
try {
resolve(await fun)
} catch (error) {
reject(error)
}
}
tempfun()
}
})
})
}
}
\ No newline at end of file