Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/fortran/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Typescript 带定时器的日志盒_Typescript_Timer_Dialog_Electron_Messagebox - Fatal编程技术网

Typescript 带定时器的日志盒

Typescript 带定时器的日志盒,typescript,timer,dialog,electron,messagebox,Typescript,Timer,Dialog,Electron,Messagebox,我想创建一个带有30秒倒计时的消息对话框,以及一条消息如何在typescript中做到这一点,倒计时应该像30 29 28。。。。0则此消息框应自动消失 dialog.showMessageBoxSync({ type: "info", defaultId: 0, title: "Timer.", mess

我想创建一个带有30秒倒计时的消息对话框,以及一条消息如何在typescript中做到这一点,倒计时应该像30 29 28。。。。0则此消息框应自动消失

dialog.showMessageBoxSync({
                        type: "info",
                        defaultId: 0,
                        title: "Timer.",
                        message: `you will be redirect to another screen in +count down+`
                    })
像这样

您可以使用setInterval创建一个倒计时函数,并传递该函数

dialog.showMessageBoxSync({
输入:“信息”,
defaultId:0,
标题:“计时器。”,
消息:
您将在+倒计时+

})
对话框函数作为对该倒计时函数的回调

const countdown = function(counter){

   const timer = setInterval(() => {
   counter--;
   console.log(counter);
   if(counter === 0) {
     console.log("its up");
     dialog.showMessageBoxSync({
          type: "info",
          defaultId: 0,
          title: "Timer.",
          message:you will be redirect to another screen in +counter+
      });
      clearInterval(timer);
    }
   },1000)

  }

是的,我试过了,但运气不好:(它不显示对话框。当它达到0时,它将进入对话框,但我想在对话框内计数器处显示倒计时秒数。您的意思是要动态更新打开的对话框吗?我从未见过任何关于该功能的提及。似乎您必须使用
浏览器构建自己的功能窗口
模式
等。