久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

Atom Electron - 使用 javascript 關(guān)閉窗口

Atom Electron - Close the window with javascript(Atom Electron - 使用 javascript 關(guān)閉窗口)
本文介紹了Atom Electron - 使用 javascript 關(guān)閉窗口的處理方法,對(duì)大家解決問(wèn)題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)吧!

問(wèn)題描述

我正在使用 Electron(以前的 atom-shell)并希望有一個(gè)簡(jiǎn)約的框架窗口,以便從 可以看到三個(gè) OSX 窗口按鈕(關(guān)閉、最大化、最小化)在 HTML 頁(yè)面內(nèi).

I'm using Electron (formerly atom-shell) and would like to have a minimalist frame window so that the three OSX window buttons (close, maximize, minimize) are visible from within the HTML page.

我在定義 frame 設(shè)置為 false/api/browser-window.md#new-browserwindowoptions" rel="noreferrer">BrowserWindow 擁有一個(gè)無(wú)邊框、無(wú)邊框的窗口.

I set the Electron option frame to false when defining the BrowserWindow to have a chromeless, frameless window.

我認(rèn)為我可以用這樣的方式處理關(guān)閉按鈕:

And I thought I could handle the close button with something like this:

<a btn href="#" id="close" onclick="window.top.close(); return false"></a>

不幸的是,沒(méi)有運(yùn)氣.知道如何實(shí)現(xiàn)這一目標(biāo)嗎?

With no luck, sadly. Any idea how to achieve this?

推薦答案

您必須訪問(wèn)您的主進(jìn)程創(chuàng)建的 BrowserWindow 對(duì)象并調(diào)用 minimizemaximizeclose 方法.您可以使用 remote 模塊訪問(wèn)它.以下是綁定所有三個(gè)按鈕的示例:

You must access the BrowserWindow object created by your main process and call the minimize, maximize, and close methods on that. You can access this using the remote module. Here is an example of binding all three buttons:

  const remote = require('electron').remote;

  document.getElementById("min-btn").addEventListener("click", function (e) {
       var window = remote.getCurrentWindow();
       window.minimize(); 
  });

  document.getElementById("max-btn").addEventListener("click", function (e) {
       var window = remote.getCurrentWindow();
       if (!window.isMaximized()) {
           window.maximize();          
       } else {
           window.unmaximize();
       }
  });

  document.getElementById("close-btn").addEventListener("click", function (e) {
       var window = remote.getCurrentWindow();
       window.close();
  }); 

假設(shè)您的最小、最大、關(guān)閉按鈕的 ID 分別為 min-btnmax-btnclose-btn.

assuming your min, max, close buttons have ids of min-btn, max-btn, and close-btn, respectively.

您可以在此處查看 BrowserWindow 的完整文檔以及您可能需要的其他功能:http://electron.atom.io/docs/v0.28.0/api/browser-window/.

You can view the full documentation for the BrowserWindow along with other functionality you might need here: http://electron.atom.io/docs/v0.28.0/api/browser-window/.

它也可以幫助你看看我寫(xiě)的關(guān)于構(gòu)建一個(gè)看起來(lái)像 Visual Studio 的無(wú)鉻窗口的教程:http://www.mylifeforthecode.com/making-the-electron-shell-as-pretty-as-the-visual-工作室外殼.您的問(wèn)題與一些 css 一起涵蓋了正確定位按鈕.

It might also help you to take a look at a tutorial I wrote about building a chromeless window that looks like Visual Studio here: http://www.mylifeforthecode.com/making-the-electron-shell-as-pretty-as-the-visual-studio-shell. Your question is covered along with some css to properly position the buttons.

這篇關(guān)于Atom Electron - 使用 javascript 關(guān)閉窗口的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

【網(wǎng)站聲明】本站部分內(nèi)容來(lái)源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問(wèn)題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請(qǐng)聯(lián)系我們刪除處理,感謝您的支持!

相關(guān)文檔推薦

discord.js v12: How do I await for messages in a DM channel?(discord.js v12:我如何等待 DM 頻道中的消息?)
how to make my bot mention the person who gave that bot command(如何讓我的機(jī)器人提及發(fā)出該機(jī)器人命令的人)
How to fix Must use import to load ES Module discord.js(如何修復(fù)必須使用導(dǎo)入來(lái)加載 ES 模塊 discord.js)
How to list all members from a specific server?(如何列出來(lái)自特定服務(wù)器的所有成員?)
Discord bot: Fix ‘FFMPEG not found’(Discord bot:修復(fù)“找不到 FFMPEG)
Welcome message when joining discord Server using discord.js(使用 discord.js 加入 discord 服務(wù)器時(shí)的歡迎消息)
主站蜘蛛池模板: 久久精品欧美一区二区三区不卡 | 国产欧美一区二区三区在线看 | 成人性视频在线播放 | 日韩精品一区二区三区中文字幕 | 国产情品 | 成人婷婷 | 黄色三级毛片 | 久久久国产精品入口麻豆 | av特级毛片 | 91精品国产91久久久久久 | 99在线免费观看视频 | 亚洲日韩中文字幕一区 | 91看片网站 | www.伊人.com | 一级高清视频 | 99婷婷 | 香蕉av免费 | 看一级毛片 | 亚洲欧美中文日韩在线v日本 | 国产精品亚洲综合 | 亚洲喷水 | 国产欧美精品一区二区 | 久久丝袜视频 | 四虎影院欧美 | 国产成人精品一区二区三区视频 | 日美女逼逼 | 天天干亚洲 | 成在线人视频免费视频 | 欧美看片 | 亚洲国产激情 | 毛片在线看看 | 亚洲欧美中文字幕 | 午夜爱爱毛片xxxx视频免费看 | 古装三级在线播放 | 午夜精品久久久久久久久久久久 | 久久精品久久久 | 国产一区二区在线播放 | 夜夜操天天操 | 日韩欧美精品一区 | 天天操夜夜艹 | 国产区一区二区三区 |