mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-09-22 03:33:06 +08:00
fix(electron): deep link handling without running instance (#8661)
fix AF-1586
This commit is contained in:
@@ -20,6 +20,8 @@ export const config = (): BuildOptions => {
|
|||||||
'process.env.GITHUB_SHA': process.env.GITHUB_SHA,
|
'process.env.GITHUB_SHA': process.env.GITHUB_SHA,
|
||||||
'process.env.SENTRY_RELEASE': process.env.SENTRY_RELEASE,
|
'process.env.SENTRY_RELEASE': process.env.SENTRY_RELEASE,
|
||||||
'process.env.SENTRY_DSN': process.env.SENTRY_DSN,
|
'process.env.SENTRY_DSN': process.env.SENTRY_DSN,
|
||||||
|
'process.env.DEV_SERVER_URL': process.env.DEV_SERVER_URL,
|
||||||
|
'process.env.NODE_ENV': process.env.NODE_ENV,
|
||||||
REPLACE_ME_BUILD_ENV: process.env.BUILD_TYPE ?? 'stable',
|
REPLACE_ME_BUILD_ENV: process.env.BUILD_TYPE ?? 'stable',
|
||||||
...Object.entries(
|
...Object.entries(
|
||||||
getBuildConfig({
|
getBuildConfig({
|
||||||
|
|||||||
@@ -57,6 +57,18 @@ export function setupDeepLink(app: App) {
|
|||||||
})
|
})
|
||||||
.catch(e => console.error('Failed to restore or create window:', e));
|
.catch(e => console.error('Failed to restore or create window:', e));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
app.on('ready', () => {
|
||||||
|
// app may be brought up without having a running instance
|
||||||
|
// need to read the url from the command line
|
||||||
|
const url = process.argv.at(-1);
|
||||||
|
logger.log('url from argv', process.argv, url);
|
||||||
|
if (url?.startsWith(`${protocol}://`)) {
|
||||||
|
handleAffineUrl(url).catch(e => {
|
||||||
|
logger.error('failed to handle affine url', e);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async function handleAffineUrl(url: string) {
|
async function handleAffineUrl(url: string) {
|
||||||
|
|||||||
@@ -58,10 +58,12 @@ export function registerEvents() {
|
|||||||
}
|
}
|
||||||
app.on('before-quit', () => {
|
app.on('before-quit', () => {
|
||||||
// subscription on quit sometimes crashes the app
|
// subscription on quit sometimes crashes the app
|
||||||
try {
|
unsubs.forEach(unsub => {
|
||||||
unsubs.forEach(unsub => unsub());
|
try {
|
||||||
} catch (err) {
|
unsub();
|
||||||
logger.error('unsubscribe error', err);
|
} catch (err) {
|
||||||
}
|
logger.warn('unsubscribe error on quit', err);
|
||||||
|
}
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user