From a992a9cb5ce5a142b31dedc802f518e820f00c0e Mon Sep 17 00:00:00 2001 From: pompurin404 Date: Tue, 13 Aug 2024 20:15:20 +0800 Subject: [PATCH] fix deeplink --- src/main/index.ts | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/src/main/index.ts b/src/main/index.ts index a3f1ea2..9dda507 100644 --- a/src/main/index.ts +++ b/src/main/index.ts @@ -1,6 +1,6 @@ import { electronApp, optimizer, is } from '@electron-toolkit/utils' import { registerIpcMainHandlers } from './utils/ipc' -import { app, shell, BrowserWindow, Menu, dialog } from 'electron' +import { app, shell, BrowserWindow, Menu, dialog, Notification } from 'electron' import { stopCore } from './core/manager' import { triggerSysProxy } from './resolve/sysproxy' import icon from '../../resources/icon.png?asset' @@ -83,23 +83,26 @@ app.whenReady().then(async () => { }) async function handleDeepLink(url: string): Promise { - if (url.startsWith('clash://install-config')) { - url = url.replace('clash://install-config/?url=', '').replace('clash://install-config?url=', '') + try { + if (url.startsWith('clash://install-config')) { + url = url + .replace('clash://install-config/?url=', '') + .replace('clash://install-config?url=', '') + } + if (url.startsWith('mihomo://install-config')) { + url = url + .replace('mihomo://install-config/?url=', '') + .replace('mihomo://install-config?url=', '') + } + url = url.split('&')[0] await addProfileItem({ type: 'remote', name: 'Remote File', - url - }) - } - if (url.startsWith('mihomo://install-config')) { - url = url - .replace('mihomo://install-config/?url=', '') - .replace('mihomo://install-config?url=', '') - await addProfileItem({ - type: 'remote', - name: 'Remote File', - url + url: decodeURIComponent(url) }) + new Notification({ title: '订阅导入成功' }).show() + } catch (e) { + dialog.showErrorBox('订阅导入失败', `${url}\n${e}`) } }