Skip to content

Commit f5c890e

Browse files
committed
변경된 open-url로 macos도 동작하도록 수정
1 parent cf9dde7 commit f5c890e

File tree

1 file changed

+36
-19
lines changed

1 file changed

+36
-19
lines changed

src/main/main.js

Lines changed: 36 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,15 @@ const OAuthRequestManager = require('./oauth/OAuthRequestManager')
66

77
const PROTOCOL = "tistory-editor"
88

9+
console.log("DEBUG: platform", process.platform)
910
settings.configure({
1011
fileName: 'Settings'
1112
})
1213

1314
let deeplinkingUrl
1415
app.setAsDefaultProtocolClient(PROTOCOL)
15-
1616
app.showExitPrompt = false
17+
1718
app.on('ready', () => {
1819
initWindow()
1920
ipc.init()
@@ -29,32 +30,48 @@ app.on('window-all-closed', () => {
2930

3031
app.on("open-url", (e, urlString) => {
3132
e.preventDefault()
32-
deeplinkingUrl = urlString
33+
34+
if (process.platform === 'darwin') {
35+
execOAuthRequestHandler(urlString)
36+
} else {
37+
deeplinkingUrl = urlString
38+
}
3339
})
3440

41+
function execOAuthRequestHandler(deeplinkingUrl) {
42+
console.log("OPEN-URL", deeplinkingUrl)
43+
const url = new URL(deeplinkingUrl)
44+
let requestHandler = OAuthRequestManager.loadRequestInfo("oauth")
45+
if (requestHandler) {
46+
requestHandler(url.searchParams)
47+
}
48+
}
49+
50+
function restoreWindow() {
51+
const window = getWindow()
52+
if (!window) {
53+
return
54+
}
55+
if (window.isMinimized()) {
56+
window.restore()
57+
}
58+
59+
window.focus();
60+
}
61+
3562
const gotTheLock = app.requestSingleInstanceLock();
63+
console.log("DEBUG: gotTheLock", gotTheLock)
3664
if (!gotTheLock) {
37-
app.quit();
38-
return;
65+
app.quit()
3966
} else {
4067
app.on('second-instance', (e, argv) => {
41-
if (process.platform === 'darwin') {
68+
console.log("DEBUG: second-instance argv", argv)
69+
if (process.platform !== 'darwin') {
4270
deeplinkingUrl = argv.find((arg) => arg.startsWith('tistory-editor://'));
4371
}
4472

45-
const window = getWindow()
46-
47-
if (window) {
48-
if (window.isMinimized()) window.restore();
49-
window.focus();
50-
51-
console.log("OPEN-URL", deeplinkingUrl)
52-
const url = new URL(deeplinkingUrl)
53-
let requestHandler = OAuthRequestManager.loadRequestInfo("oauth")
54-
if (requestHandler) {
55-
requestHandler(url.searchParams)
56-
}
57-
}
58-
});
73+
restoreWindow()
74+
execOAuthRequestHandler(deeplinkingUrl)
75+
})
5976
}
6077

0 commit comments

Comments
 (0)