Skip to content

Commit e079fee

Browse files
committed
fix: 修复设置页面外部链接无法打开的问题
- 添加 app:openExternal IPC 通道用于打开外部链接 - 在主进程中实现 shell.openExternal 处理 - 修复 OtherSetting.tsx 中的 URL 格式错误(移除多余括号) - 将 <a> 标签改为 Button onClick 事件,通过 IPC 调用打开外部链接 - 更新相关类型定义
1 parent 1c0b550 commit e079fee

4 files changed

Lines changed: 36 additions & 28 deletions

File tree

electron/main/ipc/app.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ function setupIpcHandlers() {
1919
shell.openPath(app.getPath('logs'))
2020
})
2121

22+
typedIpcMainHandle(IPC_CHANNELS.app.openExternal, (_, url: string) => {
23+
shell.openExternal(url)
24+
})
25+
2226
typedIpcMainHandle(IPC_CHANNELS.account.switch, (_, { account }) => {
2327
accountManager.setAccountName(account.id, account.name)
2428
})

shared/electron-api.d.ts

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@ export interface IpcChannels {
1818
[IPC_CHANNELS.tasks.liveControl.notifyAccountName]: (
1919
params:
2020
| {
21-
ok: true
22-
accountId: string
23-
accountName: string | null
24-
}
21+
ok: true
22+
accountId: string
23+
accountName: string | null
24+
}
2525
| { ok: false },
2626
) => void
2727

@@ -89,9 +89,9 @@ export interface IpcChannels {
8989
[IPC_CHANNELS.tasks.aiChat.stream]: (
9090
data:
9191
| {
92-
chunk: string
93-
type: 'content' | 'reasoning'
94-
}
92+
chunk: string
93+
type: 'content' | 'reasoning'
94+
}
9595
| { done: boolean },
9696
) => void
9797
[IPC_CHANNELS.tasks.aiChat.error]: (data: { error: string }) => void
@@ -119,6 +119,7 @@ export interface IpcChannels {
119119

120120
// App
121121
[IPC_CHANNELS.app.openLogFolder]: () => void
122+
[IPC_CHANNELS.app.openExternal]: (url: string) => void
122123
[IPC_CHANNELS.app.notifyUpdate]: (arg: {
123124
currentVersion: string
124125
latestVersion: string
@@ -150,4 +151,4 @@ export interface ElectronAPI {
150151
listener: (...args: Parameters<IpcChannels[Channel]>) => void,
151152
) => () => void
152153
}
153-
}
154+
}

shared/ipcChannels.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,5 +68,6 @@ export const IPC_CHANNELS = {
6868
app: {
6969
openLogFolder: 'app:openLogFolder',
7070
notifyUpdate: 'app:notifyUpdate',
71+
openExternal: 'app:openExternal',
7172
},
7273
} as const

src/pages/SettingsPage/components/OtherSetting.tsx

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,20 @@ export function OtherSetting() {
99
await window.ipcRenderer.invoke(IPC_CHANNELS.app.openLogFolder)
1010
}
1111

12+
const handleOpenGitHub = async () => {
13+
await window.ipcRenderer.invoke(
14+
IPC_CHANNELS.app.openExternal,
15+
'https://github.com/TuoLingTeam/TLS-live-tool',
16+
)
17+
}
18+
19+
const handleOpenIssues = async () => {
20+
await window.ipcRenderer.invoke(
21+
IPC_CHANNELS.app.openExternal,
22+
'https://github.com/TuoLingTeam/TLS-live-tool/issues',
23+
)
24+
}
25+
1226
return (
1327
<Card>
1428
<CardHeader>
@@ -34,27 +48,15 @@ export function OtherSetting() {
3448
<p className="text-sm text-muted-foreground">了解更多项目相关内容</p>
3549
</div>
3650
<div className="flex gap-2">
37-
<Button variant="outline" size="sm" className="gap-2" asChild>
38-
<a
39-
href="(https://github.com/TuoLingTeam/TLS-live-tool"
40-
target="_blank"
41-
rel="noopener noreferrer"
42-
>
43-
<SimpleIconsGithub className="h-4 w-4" />
44-
GitHub
45-
<ExternalLinkIcon className="h-4 w-4" />
46-
</a>
51+
<Button variant="outline" size="sm" className="gap-2" onClick={handleOpenGitHub}>
52+
<SimpleIconsGithub className="h-4 w-4" />
53+
GitHub
54+
<ExternalLinkIcon className="h-4 w-4" />
4755
</Button>
48-
<Button variant="outline" size="sm" className="gap-2" asChild>
49-
<a
50-
href="(https://github.com/TuoLingTeam/TLS-live-tool/issues"
51-
target="_blank"
52-
rel="noopener noreferrer"
53-
>
54-
<BugIcon className="h-4 w-4" />
55-
反馈问题
56-
<ExternalLinkIcon className="h-4 w-4" />
57-
</a>
56+
<Button variant="outline" size="sm" className="gap-2" onClick={handleOpenIssues}>
57+
<BugIcon className="h-4 w-4" />
58+
反馈问题
59+
<ExternalLinkIcon className="h-4 w-4" />
5860
</Button>
5961
</div>
6062
</div>

0 commit comments

Comments
 (0)