diff --git a/electron-builder.json5 b/electron-builder.json5 index c85bff7..4416420 100644 --- a/electron-builder.json5 +++ b/electron-builder.json5 @@ -89,7 +89,8 @@ } ], "x64ArchFiles": "Contents/Resources/extra/**/*", - "entitlementsInherit": "entitlements.mac.plist", + "entitlementsInherit": "./entitlements.mac.plist", + "entitlements": "./entitlements.mac.plist", "extendInfo": { "NSDocumentsFolderUsageDescription": "Application requests access to the user's Documents folder.", "NSDownloadsFolderUsageDescription": "Application requests access to the user's Downloads folder." @@ -97,7 +98,8 @@ "type": "development", "notarize": false, "darkModeSupport": false, - "hardenedRuntime": false + "hardenedRuntime": false, + "identity": "AigcPanelKey" }, "linux": { "icon": "logo.icns", diff --git a/electron/lib/env-main.ts b/electron/lib/env-main.ts index e9d4d1f..7371010 100644 --- a/electron/lib/env-main.ts +++ b/electron/lib/env-main.ts @@ -15,7 +15,7 @@ process.env.VITE_PUBLIC = VITE_DEV_SERVER_URL ? path.join(process.env.APP_ROOT, 'public') : RENDERER_DIST -export const preloadDefault = path.join(MAIN_DIST, 'preload/index.mjs') +export const preloadDefault = path.join(MAIN_DIST, 'preload/index.cjs') export const rendererLoadPath = (window: BrowserWindow | BrowserView, fileName: string) => { if (!isPackaged && process.env.VITE_DEV_SERVER_URL) { diff --git a/electron/lib/util.ts b/electron/lib/util.ts index c6dd7a9..52b9c5f 100644 --- a/electron/lib/util.ts +++ b/electron/lib/util.ts @@ -5,7 +5,7 @@ import fs from "node:fs"; import Showdown from "showdown" import iconvLite from "iconv-lite"; import chardet from "chardet"; -import {Iconv} from "iconv" +// import {Iconv} from "iconv" export const EncodeUtil = { base64Encode(str: string) { @@ -39,10 +39,10 @@ export const IconvUtil = { }, bufferToUtf8(buffer: Buffer) { const encoding = chardet.detect(buffer) - if ('ISO-2022-CN' === encoding) { - const iconvInstance = new Iconv('ISO-2022-CN', 'UTF-8//TRANSLIT//IGNORE'); - return iconvInstance.convert(buffer).toString() - } + // if ('ISO-2022-CN' === encoding) { + // const iconvInstance = new Iconv('ISO-2022-CN', 'UTF-8//TRANSLIT//IGNORE'); + // return iconvInstance.convert(buffer).toString() + // } return iconvLite.decode(buffer, encoding).toString() }, detect(buffer: Uint8Array) { diff --git a/entitlements.mac.plist b/entitlements.mac.plist new file mode 100644 index 0000000..273c351 --- /dev/null +++ b/entitlements.mac.plist @@ -0,0 +1,12 @@ + + + + + com.apple.security.cs.allow-jit + + com.apple.security.cs.allow-unsigned-executable-memory + + com.apple.security.cs.allow-dyld-environment-variables + + + \ No newline at end of file diff --git a/package.json b/package.json index 006fcbf..ff47e32 100644 --- a/package.json +++ b/package.json @@ -57,19 +57,23 @@ "@devicefarmer/adbkit": "^3.2.6", "@electron-toolkit/preload": "^3.0.1", "@electron-toolkit/utils": "^3.0.0", + "@electron/remote": "^2.1.2", "@gradio/client": "^1.7.0", "@types/showdown": "^2.0.6", "@xterm/addon-fit": "^0.10.0", "@xterm/xterm": "^5.5.0", "axios": "^1.7.2", + "chardet": "^2.0.0", "date-and-time": "^3.4.1", "dayjs": "^1.11.12", "electron-context-menu": "^4.0.4", "ffmpeg-static": "^5.2.0", "fix-path": "^4.0.0", + "iconv": "^3.0.1", "iconv-lite": "^0.6.3", "js-base64": "^3.7.7", "lodash-es": "^4.17.21", + "node-mac-permissions": "^2.4.0", "nodejs-base64": "^2.0.0", "pinia": "^2.1.7", "showdown": "^2.1.0", diff --git a/src/components/Setting/SettingBasic.vue b/src/components/Setting/SettingBasic.vue index ec005bb..8504e2b 100644 --- a/src/components/Setting/SettingBasic.vue +++ b/src/components/Setting/SettingBasic.vue @@ -29,14 +29,14 @@ const onLocaleChange = (value: string) => { - - - {{ t('明亮') }} - {{ t('暗黑') }} - {{ t('跟随系统') }} - - + + + + + + + + diff --git a/src/lang/en-US.json b/src/lang/en-US.json index f20f517..7aa95a0 100644 --- a/src/lang/en-US.json +++ b/src/lang/en-US.json @@ -14,7 +14,7 @@ "000a6ba1": "Select All", "000a72da": "Close", "000a823e": "Function", - "000a8359": "分钟", + "000a8359": "Minute", "000a8844": "Delete", "000a9472": "Cancel", "000aa783": "Name", @@ -23,7 +23,7 @@ "000b2b1e": "License", "000b5a14": "Failure", "000b5d03": "Sound", - "000b8bc7": "小时", + "000b8bc7": "Hour", "000b96b9": "Website", "000c328f": "Success", "000c3f65": "Screenshot", @@ -31,10 +31,12 @@ "000c8f6a": "Hint", "000c9ba9": "Zoom In", "000ca601": "Desc", + "000caa60": "明亮", "000cb692": "Log", "000cc4dc": "Undo", "000ccd34": "Service", "000ccf01": "Collapse", + "000d0b1a": "暗黑", "000d249f": "ID", "000d318a": "Model", "000d5f35": "Normal", @@ -99,6 +101,7 @@ "259ff066": "Download Failed", "25a0c8e1": "Download Successful", "25aba9c4": "View Code", + "25d99435": "主题样式", "25e596a4": "Feedback", "2615bdd6": "Where to find model files?", "26276a3a": "Stop Service", @@ -168,6 +171,7 @@ "4148da61": "Request Error", "41dff64a": "Extracting {name}", "41e0472e": "TTS", + "42c281d4": "跟随系统", "42ed4ed0": "Connect Device", "42fa058a": "Select Model", "42fe06e0": "Select character", diff --git a/src/lang/source.json b/src/lang/source.json index 7b73747..4c349de 100644 --- a/src/lang/source.json +++ b/src/lang/source.json @@ -9,6 +9,7 @@ "下载失败": "259ff066", "下载成功": "25a0c8e1", "下载模型文件到本地": "0158d357", + "主题样式": "25d99435", "代码查看": "25aba9c4", "任务已经提交成功,等待克隆完成": "3afff2ff", "任务已经提交成功,等待合成完成": "3a8639d2", @@ -92,9 +93,11 @@ "文件解压完成": "27840925", "日志": "000cb692", "日志查看": "2fc665d8", + "明亮": "000caa60", "显示主界面": "26e92d2b", "暂无日志": "302416b0", "暂时还没有模型,请添加模型~": "2c3ba30e", + "暗黑": "000d0b1a", "更多内容,请查看": "3d718795", "服务": "000ccd34", "服务端口": "301d8708", @@ -169,6 +172,7 @@ "请选择": "021f3e37", "请选择声音": "08ac1686", "请选择声音角色": "720a177b", + "跟随系统": "42c281d4", "跨语种": "02261f68", "输入关键词过滤": "5e1bac63", "输入语音内容开始克隆": "39600ad2", diff --git a/src/lang/zh-CN.json b/src/lang/zh-CN.json index 8e51002..4980c7f 100644 --- a/src/lang/zh-CN.json +++ b/src/lang/zh-CN.json @@ -31,10 +31,12 @@ "000c8f6a": "提示", "000c9ba9": "放大", "000ca601": "描述", + "000caa60": "明亮", "000cb692": "日志", "000cc4dc": "撤销", "000ccd34": "服务", "000ccf01": "收起", + "000d0b1a": "暗黑", "000d249f": "标识", "000d318a": "模型", "000d5f35": "正常", @@ -98,6 +100,7 @@ "259ff066": "下载失败", "25a0c8e1": "下载成功", "25aba9c4": "代码查看", + "25d99435": "主题样式", "25e596a4": "使用反馈", "2615bdd6": "在哪里找到模型文件?", "26276a3a": "停止服务", @@ -166,6 +169,7 @@ "4148da61": "请求错误", "41dff64a": "正在解压 {name}", "41e0472e": "语音合成", + "42c281d4": "跟随系统", "42ed4ed0": "连接设备", "42fa058a": "选择模型", "42fe06e0": "选择角色", diff --git a/src/store/modules/server.ts b/src/store/modules/server.ts index 4834690..2724105 100644 --- a/src/store/modules/server.ts +++ b/src/store/modules/server.ts @@ -111,18 +111,18 @@ export const serverStore = defineStore("server", { serverRuntime.status = EnumServerStatus.STARTING serverRuntime.startTimestampMS = TimeUtil.timestampMS() serverRuntime.logFile = `logs/${server.name}_${server.version}_${TimeUtil.dateString()}_${serverRuntime.startTimestampMS}.log` - const eventChannel = await window.$mapi.event.channelCreate(function (channelData) { + const eventChannel = window.__page.createChannel(function (channelData) { const {type, data} = channelData switch (type) { case 'success': clearTimeout(serverRuntime.pingCheckTimer) serverRuntime.status = EnumServerStatus.STOPPED - window.$mapi.event.channelDestroy(eventChannel).then() + window.__page.destroyChannel(eventChannel) break case 'error': clearTimeout(serverRuntime.pingCheckTimer) serverRuntime.status = EnumServerStatus.ERROR - window.$mapi.event.channelDestroy(eventChannel).then() + window.__page.destroyChannel(eventChannel) break case 'starting': break diff --git a/vite.config.ts b/vite.config.ts index 5a97b0e..21a8ea3 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -1,7 +1,8 @@ import fs from 'node:fs' import {defineConfig} from 'vite' import vue from '@vitejs/plugin-vue' -import electron from 'vite-plugin-electron/simple' +import electron from 'vite-plugin-electron' +import renderer from 'vite-plugin-electron-renderer' import pkg from './package.json' import path from "node:path"; import {AppConfig} from "./src/config"; @@ -53,8 +54,8 @@ export default defineConfig(({command}) => { }, }, - electron({ - main: { + electron([ + { // Shortcut of `build.lib.entry` entry: 'electron/main/index.ts', onstart({startup}) { @@ -79,26 +80,37 @@ export default defineConfig(({command}) => { }, }, }, - preload: { + { // Shortcut of `build.rollupOptions.input`. // Preload scripts may contain Web assets, so use the `build.rollupOptions.input` instead `build.lib.entry`. - input: 'electron/preload/index.ts', + entry: 'electron/preload/index.ts', + onstart({reload}) { + // Notify the Renderer process to reload the page when the Preload scripts build is complete, + // instead of restarting the entire Electron App. + reload() + }, vite: { build: { - sourcemap: sourcemap ? 'inline' : undefined, // #332 + target: 'es2015', + sourcemap: undefined, // #332 minify: minify, outDir: 'dist-electron/preload', + lib: { + formats: ['cjs'], + }, rollupOptions: { external: externalPackages, + output: { + format: 'cjs', + entryFileNames: '[name].cjs', + compact: false, + }, }, }, }, }, - // Ployfill the Electron and Node.js API for Renderer process. - // If you want use Node.js in Renderer process, the `nodeIntegration` needs to be enabled in the Main process. - // See 👉 https://github.com/electron-vite/vite-plugin-electron-renderer - renderer: {}, - }), + ]), + renderer(), ], build: { sourcemap: sourcemap,