mirror of
https://gh.catmak.name/https://github.com/mihomo-party-org/mihomo-party
synced 2025-12-27 05:00:30 +08:00
normalize deeplink
This commit is contained in:
parent
2dead0f521
commit
87daeea90f
@ -80,28 +80,29 @@ app.whenReady().then(async () => {
|
|||||||
|
|
||||||
async function handleDeepLink(url: string): Promise<void> {
|
async function handleDeepLink(url: string): Promise<void> {
|
||||||
if (!url.startsWith('clash://') && !url.startsWith('mihomo://')) return
|
if (!url.startsWith('clash://') && !url.startsWith('mihomo://')) return
|
||||||
|
|
||||||
|
const urlObj = new URL(url)
|
||||||
|
switch (urlObj.host) {
|
||||||
|
case 'install-config': {
|
||||||
try {
|
try {
|
||||||
if (url.startsWith('clash://install-config')) {
|
const profileUrl = urlObj.searchParams.get('url')
|
||||||
url = url
|
const profileName = urlObj.searchParams.get('name')
|
||||||
.replace('clash://install-config/?url=', '')
|
if (!profileUrl) {
|
||||||
.replace('clash://install-config?url=', '')
|
throw new Error('缺少参数 url')
|
||||||
}
|
}
|
||||||
if (url.startsWith('mihomo://install-config')) {
|
|
||||||
url = url
|
|
||||||
.replace('mihomo://install-config/?url=', '')
|
|
||||||
.replace('mihomo://install-config?url=', '')
|
|
||||||
}
|
|
||||||
url = decodeURIComponent(url.split('&')[0])
|
|
||||||
await addProfileItem({
|
await addProfileItem({
|
||||||
type: 'remote',
|
type: 'remote',
|
||||||
name: 'Remote File',
|
name: profileName ?? undefined,
|
||||||
url: decodeURIComponent(url)
|
url: profileUrl
|
||||||
})
|
})
|
||||||
new Notification({ title: '订阅导入成功' }).show()
|
new Notification({ title: '订阅导入成功' }).show()
|
||||||
|
break
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
dialog.showErrorBox('订阅导入失败', `${url}\n${e}`)
|
dialog.showErrorBox('订阅导入失败', `${url}\n${e}`)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export function createWindow(show = false): void {
|
export function createWindow(show = false): void {
|
||||||
Menu.setApplicationMenu(null)
|
Menu.setApplicationMenu(null)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user