Skip to content

Commit 1803517

Browse files
committed
优化 hidden 启动参数的行为
1 parent 49c8081 commit 1803517

2 files changed

Lines changed: 11 additions & 11 deletions

File tree

src/main/app.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -84,16 +84,16 @@ export const initSingleInstanceHandle = () => {
8484
}
8585

8686
app.on('second-instance', (event, argv, cwd) => {
87-
for (const param of argv) {
88-
if (URL_SCHEME_RXP.test(param)) {
89-
global.envParams.deeplink = param
90-
break
91-
}
92-
}
93-
9487
if (isExistMainWindow()) {
95-
if (global.envParams.deeplink) global.lx.event_app.deeplink(global.envParams.deeplink)
96-
else showMainWindow()
88+
const envParams = parseEnvParams(argv)
89+
if (envParams.deeplink) {
90+
global.envParams.deeplink = envParams.deeplink
91+
global.lx.event_app.deeplink(global.envParams.deeplink)
92+
return
93+
}
94+
if (envParams.cmdParams.hidden !== true) {
95+
showMainWindow()
96+
}
9797
} else {
9898
app.quit()
9999
}

src/main/utils/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@ import { nativeTheme, powerSaveBlocker } from 'electron'
99
import { joinPath } from '@common/utils/nodejs'
1010
import themes from '@common/theme/index.json'
1111

12-
export const parseEnvParams = (): { cmdParams: LX.CmdParams, deeplink: string | null } => {
12+
export const parseEnvParams = (argv = process.argv): { cmdParams: LX.CmdParams, deeplink: string | null } => {
1313
const cmdParams: LX.CmdParams = {}
1414
let deeplink = null
1515
const rx = /^-\w+/
16-
for (let param of process.argv) {
16+
for (let param of argv) {
1717
if (URL_SCHEME_RXP.test(param)) {
1818
deeplink = param
1919
}

0 commit comments

Comments
 (0)