mirror of
https://github.com/hellodigua/ChatLab.git
synced 2026-05-19 04:49:36 +08:00
feat: 提示文案支持通过配置更新
This commit is contained in:
@@ -59,6 +59,17 @@ export function registerWindowHandlers(ctx: IpcContext): void {
|
||||
return app.getVersion()
|
||||
})
|
||||
|
||||
// 获取动态文案配置
|
||||
ipcMain.handle('app:fetchRemoteConfig', async (_, url: string) => {
|
||||
try {
|
||||
const response = await fetch(url)
|
||||
const data = await response.json()
|
||||
return { success: true, data }
|
||||
} catch (error) {
|
||||
return { success: false, error: String(error) }
|
||||
}
|
||||
})
|
||||
|
||||
// ==================== 更新检查 ====================
|
||||
ipcMain.on('check-update', () => {
|
||||
autoUpdater.checkForUpdates()
|
||||
|
||||
Vendored
+1
@@ -88,6 +88,7 @@ interface Api {
|
||||
getVersion: () => Promise<string>
|
||||
checkUpdate: () => void
|
||||
simulateUpdate: () => void
|
||||
fetchRemoteConfig: (url: string) => Promise<{ success: boolean; data?: unknown; error?: string }>
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -995,6 +995,12 @@ const extendedApi = {
|
||||
simulateUpdate: (): void => {
|
||||
ipcRenderer.send('simulate-update')
|
||||
},
|
||||
/**
|
||||
* 获取远程配置(通过主进程请求,绕过 CORS)
|
||||
*/
|
||||
fetchRemoteConfig: (url: string): Promise<{ success: boolean; data?: unknown; error?: string }> => {
|
||||
return ipcRenderer.invoke('app:fetchRemoteConfig', url)
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user