mirror of
https://github.com/ksyasuda/SubMiner.git
synced 2026-03-21 12:11:28 -07:00
feat(core): add Electron runtime, services, and app composition
This commit is contained in:
27
src/main/runtime/protocol-url-handlers.ts
Normal file
27
src/main/runtime/protocol-url-handlers.ts
Normal file
@@ -0,0 +1,27 @@
|
||||
export function registerProtocolUrlHandlers(deps: {
|
||||
registerOpenUrl: (
|
||||
listener: (event: { preventDefault: () => void }, rawUrl: string) => void,
|
||||
) => void;
|
||||
registerSecondInstance: (listener: (_event: unknown, argv: string[]) => void) => void;
|
||||
handleAnilistSetupProtocolUrl: (rawUrl: string) => boolean;
|
||||
findAnilistSetupDeepLinkArgvUrl: (argv: string[]) => string | null;
|
||||
logUnhandledOpenUrl: (rawUrl: string) => void;
|
||||
logUnhandledSecondInstanceUrl: (rawUrl: string) => void;
|
||||
}) {
|
||||
deps.registerOpenUrl((event, rawUrl) => {
|
||||
event.preventDefault();
|
||||
if (!deps.handleAnilistSetupProtocolUrl(rawUrl)) {
|
||||
deps.logUnhandledOpenUrl(rawUrl);
|
||||
}
|
||||
});
|
||||
|
||||
deps.registerSecondInstance((_event, argv) => {
|
||||
const rawUrl = deps.findAnilistSetupDeepLinkArgvUrl(argv);
|
||||
if (!rawUrl) {
|
||||
return;
|
||||
}
|
||||
if (!deps.handleAnilistSetupProtocolUrl(rawUrl)) {
|
||||
deps.logUnhandledSecondInstanceUrl(rawUrl);
|
||||
}
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user