11'use strict'
22/* global __static */
3+ import './utils/os-network-fallback'
34import path from 'node:path'
45import DevSidecar from '@docmirror/dev-sidecar'
56import { app , BrowserWindow , dialog , globalShortcut , ipcMain , Menu , nativeImage , nativeTheme , powerMonitor , protocol , Tray } from 'electron'
@@ -47,7 +48,7 @@ protocol.registerSchemesAsPrivileged([
4748 { scheme : 'app' , privileges : { secure : true , standard : true } } ,
4849] )
4950
50- function openDevTools ( ) {
51+ function openDevTools ( ) {
5152 try {
5253 log . debug ( '尝试打开 `开发者工具`' )
5354 win . webContents . openDevTools ( )
@@ -57,7 +58,7 @@ function openDevTools () {
5758 }
5859}
5960
60- function closeDevTools ( ) {
61+ function closeDevTools ( ) {
6162 try {
6263 log . debug ( '尝试关闭 `开发者工具`' )
6364 win . webContents . closeDevTools ( )
@@ -67,7 +68,7 @@ function closeDevTools () {
6768 }
6869}
6970
70- function switchDevTools ( ) {
71+ function switchDevTools ( ) {
7172 if ( ! win || ! win . webContents ) {
7273 return
7374 }
@@ -79,7 +80,7 @@ function switchDevTools () {
7980}
8081
8182// 隐藏主窗口,并创建托盘,绑定关闭事件
82- function setTray ( ) {
83+ function setTray ( ) {
8384 // const topMenu = Menu.buildFromTemplate({})
8485 // Menu.setApplicationMenu(topMenu)
8586 // 用一个 Tray 来表示一个图标,这个图标处于正在运行的系统的通知区
@@ -148,7 +149,7 @@ function setTray () {
148149 return appTray
149150}
150151
151- function checkHideWin ( ) {
152+ function checkHideWin ( ) {
152153 const config = DevSidecar . api . config . get ( )
153154
154155 // 配置为false时,不需要校验
@@ -170,7 +171,7 @@ function checkHideWin () {
170171 return true
171172}
172173
173- function hideWin ( reason = '' , needCheck = false ) {
174+ function hideWin ( reason = '' , needCheck = false ) {
174175 if ( win ) {
175176 if ( needCheck && ! checkHideWin ( ) ) {
176177 return
@@ -186,7 +187,7 @@ function hideWin (reason = '', needCheck = false) {
186187 }
187188}
188189
189- function showWin ( ) {
190+ function showWin ( ) {
190191 if ( win ) {
191192 win . show ( )
192193 } else {
@@ -198,13 +199,13 @@ function showWin () {
198199 winIsHidden = false
199200}
200201
201- function changeAppConfig ( config ) {
202+ function changeAppConfig ( config ) {
202203 if ( config . hideDockWhenWinClose != null ) {
203204 hideDockWhenWinClose = config . hideDockWhenWinClose
204205 }
205206}
206207
207- function createWindow ( startHideWindow , autoQuitIfError = true ) {
208+ function createWindow ( startHideWindow , autoQuitIfError = true ) {
208209 // Create the browser window.
209210 const windowSize = DevSidecar . api . config . get ( ) . app . windowSize || { }
210211
@@ -361,11 +362,11 @@ function createWindow (startHideWindow, autoQuitIfError = true) {
361362 return true
362363}
363364
364- async function beforeQuit ( ) {
365+ async function beforeQuit ( ) {
365366 log . info ( 'before quit' )
366367 return DevSidecar . api . shutdown ( )
367368}
368- async function quit ( reason ) {
369+ async function quit ( reason ) {
369370 log . info ( 'app quit:' , reason )
370371
371372 if ( tray ) {
@@ -376,11 +377,11 @@ async function quit (reason) {
376377 app . quit ( )
377378}
378379
379- function hasShortcut ( showHideShortcut ) {
380+ function hasShortcut ( showHideShortcut ) {
380381 return showHideShortcut && showHideShortcut . length > 1
381382}
382383
383- function registerShowHideShortcut ( showHideShortcut ) {
384+ function registerShowHideShortcut ( showHideShortcut ) {
384385 globalShortcut . unregisterAll ( )
385386 if ( hasShortcut ( showHideShortcut ) ) {
386387 try {
@@ -407,7 +408,7 @@ function registerShowHideShortcut (showHideShortcut) {
407408 }
408409}
409410
410- function initApp ( ) {
411+ function initApp ( ) {
411412 if ( isMac ) {
412413 app . whenReady ( ) . then ( ( ) => {
413414 app . dock . setIcon ( path . join ( __dirname , '../extra/icons/512x512-2.png' ) )
0 commit comments