diff --git a/src/main/index.ts b/src/main/index.ts index 897dd72..d223090 100644 --- a/src/main/index.ts +++ b/src/main/index.ts @@ -130,6 +130,7 @@ async function handleDeepLink(url: string): Promise { name: profileName ?? undefined, url: profileUrl }) + mainWindow?.webContents.send('profileConfigUpdated') new Notification({ title: '订阅导入成功' }).show() break } catch (e) { diff --git a/src/renderer/src/hooks/use-profile-config.tsx b/src/renderer/src/hooks/use-profile-config.tsx index 4a30b82..167b61d 100644 --- a/src/renderer/src/hooks/use-profile-config.tsx +++ b/src/renderer/src/hooks/use-profile-config.tsx @@ -76,6 +76,15 @@ export const ProfileConfigProvider: React.FC<{ children: ReactNode }> = ({ child } } + React.useEffect(() => { + window.electron.ipcRenderer.on('profileConfigUpdated', () => { + mutateProfileConfig() + }) + return (): void => { + window.electron.ipcRenderer.removeAllListeners('profileConfigUpdated') + } + }, []) + return ( { const handleImport = async (): Promise => { setImporting(true) await addProfileItem({ name: '', type: 'remote', url, useProxy }) + setUrl('') setImporting(false) } const pageRef = useRef(null)