zoukankan      html  css  js  c++  java
  • electron 显示对话框 showMessageBoxSync showMessageBox

    7.3.2的文档:https://github.com/electron/electron/blob/v7.3.2/docs/api/dialog.md 不同版本可以切换

    一个是同步对话框,另外一个是异步。

    同步:

    win.webContents.on('xxx-event', (event) => {
        console.log(" ==cust_event_notify_dialog_confirm==");
        const options = {
            type: 'question',
            buttons: ['Cancel', 'Yes, please', 'No, thanks'],
            defaultId: 2,
            cancelId: 0,
            title: 'Question',
            message: 'my window?',
            detail: 'It does not really matter',
            checkboxLabel: 'remember',
            checkboxChecked: true,
        }; 
      
      const choice= dialog.showMessageBoxSync(win, options);
       const isCancel = (choice === 0)
       
      if (!isCancel) {
        event.preventDefault()//确认
      }  
    })

    异步:

    // 窗口关闭
    win.on('close', (e) => {
            e.preventDefault();
            dialog.showMessageBox(win, {
                type: 'warning',
                title: '关闭',
                message: '是否退出?',
                buttons: ['取消', '确定']
            }).then((index) => {
                if (index.response === 1) {
                    win = null;
                    app.exit();
                }
            });
    });
  • 相关阅读:
    Leetcode | Work Break I & II
    X-Japan
    Leetcode | Gas Station
    jstring, String, char* 变换函数
    动态链接库的创建
    C语言实现md5函数代码
    ARM汇编指令集
    2014年 各类黑客工具包
    ARM汇编指令的一些总结-转
    ARM指令集学习总结-转载
  • 原文地址:https://www.cnblogs.com/bigben0123/p/13444496.html
Copyright © 2011-2022 走看看