fix(bridge): window call should catch error

Signed-off-by: Innei <tukon479@gmail.com>
This commit is contained in:
Innei
2024-12-01 22:02:23 +08:00
parent 605c3d66b9
commit 7bdf10050c
2 changed files with 3 additions and 2 deletions
+2 -1
View File
@@ -68,7 +68,8 @@ export const readerRoute = {
}
await tts.setMetadata(input, OUTPUT_FORMAT.WEBM_24KHZ_16BIT_MONO_OPUS).catch((error) => {
return callWindowExpose(window).toast.error(error.message, {
const msg = typeof error === "string" ? error : error.message
return callWindowExpose(window).toast.error(msg || "unknown set voice error", {
duration: 1000,
})
})
+1 -1
View File
@@ -89,7 +89,7 @@ function createProxy<T extends RenderGlobalContext>(window: BrowserWindow, path:
try {
return await window.webContents.executeJavaScript(
`globalThis.${PREFIX}?.${methodPath}?.(${args.map((arg) => JSON.stringify(arg)).join(",")})`,
`(async () => { try { return await globalThis.${PREFIX}?.${methodPath}?.(${args.map((arg) => JSON.stringify(arg)).join(",")}) } catch (err) { console.error('Failed to executeJavaScript: ${methodPath}', err) } })()`,
)
} catch (err) {
console.error(`Failed to executeJavaScript: ${methodPath}`, err)