Skip to content

Commit

Permalink
优化:Mac 打包增加自建证书,避免安装提示被损坏问题
Browse files Browse the repository at this point in the history
  • Loading branch information
modstart committed Dec 14, 2024
1 parent 60b0413 commit 8903082
Show file tree
Hide file tree
Showing 11 changed files with 74 additions and 32 deletions.
6 changes: 4 additions & 2 deletions electron-builder.json5
Original file line number Diff line number Diff line change
Expand Up @@ -89,15 +89,17 @@
}
],
"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."
},
"type": "development",
"notarize": false,
"darkModeSupport": false,
"hardenedRuntime": false
"hardenedRuntime": false,
"identity": "AigcPanelKey"
},
"linux": {
"icon": "logo.icns",
Expand Down
2 changes: 1 addition & 1 deletion electron/lib/env-main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
10 changes: 5 additions & 5 deletions electron/lib/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down
12 changes: 12 additions & 0 deletions entitlements.mac.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.security.cs.allow-jit</key>
<true/>
<key>com.apple.security.cs.allow-unsigned-executable-memory</key>
<true/>
<key>com.apple.security.cs.allow-dyld-environment-variables</key>
<true/>
</dict>
</plist>
4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
16 changes: 8 additions & 8 deletions src/components/Setting/SettingBasic.vue
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,14 @@ const onLocaleChange = (value: string) => {
</a-option>
</a-select>
</a-form-item>
<a-form-item field="name" :label="t('主题样式')">
<a-radio-group :model-value="setting.configGet('darkMode').value"
@change="setting.onConfigChange('darkMode',$event)">
<a-radio value="light">{{ t('明亮') }}</a-radio>
<a-radio value="dark">{{ t('暗黑') }}</a-radio>
<a-radio value="auto">{{ t('跟随系统') }}</a-radio>
</a-radio-group>
</a-form-item>
<!-- <a-form-item field="name" :label="t('主题样式')">-->
<!-- <a-radio-group :model-value="setting.configGet('darkMode').value"-->
<!-- @change="setting.onConfigChange('darkMode',$event)">-->
<!-- <a-radio value="light">{{ t('明亮') }}</a-radio>-->
<!-- <a-radio value="dark">{{ t('暗黑') }}</a-radio>-->
<!-- <a-radio value="auto">{{ t('跟随系统') }}</a-radio>-->
<!-- </a-radio-group>-->
<!-- </a-form-item>-->
<a-form-item field="name" :label="t('点击关闭时')">
<a-radio-group :model-value="setting.configGet('exitMode').value"
@change="setting.onConfigChange('exitMode',$event)">
Expand Down
8 changes: 6 additions & 2 deletions src/lang/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"000a6ba1": "Select All",
"000a72da": "Close",
"000a823e": "Function",
"000a8359": "分钟",
"000a8359": "Minute",
"000a8844": "Delete",
"000a9472": "Cancel",
"000aa783": "Name",
Expand All @@ -23,18 +23,20 @@
"000b2b1e": "License",
"000b5a14": "Failure",
"000b5d03": "Sound",
"000b8bc7": "小时",
"000b8bc7": "Hour",
"000b96b9": "Website",
"000c328f": "Success",
"000c3f65": "Screenshot",
"000c842f": "Operate",
"000c8f6a": "Hint",
"000c9ba9": "Zoom In",
"000ca601": "Desc",
"000caa60": "明亮",
"000cb692": "Log",
"000cc4dc": "Undo",
"000ccd34": "Service",
"000ccf01": "Collapse",
"000d0b1a": "暗黑",
"000d249f": "ID",
"000d318a": "Model",
"000d5f35": "Normal",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -168,6 +171,7 @@
"4148da61": "Request Error",
"41dff64a": "Extracting {name}",
"41e0472e": "TTS",
"42c281d4": "跟随系统",
"42ed4ed0": "Connect Device",
"42fa058a": "Select Model",
"42fe06e0": "Select character",
Expand Down
4 changes: 4 additions & 0 deletions src/lang/source.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"下载失败": "259ff066",
"下载成功": "25a0c8e1",
"下载模型文件到本地": "0158d357",
"主题样式": "25d99435",
"代码查看": "25aba9c4",
"任务已经提交成功,等待克隆完成": "3afff2ff",
"任务已经提交成功,等待合成完成": "3a8639d2",
Expand Down Expand Up @@ -92,9 +93,11 @@
"文件解压完成": "27840925",
"日志": "000cb692",
"日志查看": "2fc665d8",
"明亮": "000caa60",
"显示主界面": "26e92d2b",
"暂无日志": "302416b0",
"暂时还没有模型,请添加模型~": "2c3ba30e",
"暗黑": "000d0b1a",
"更多内容,请查看": "3d718795",
"服务": "000ccd34",
"服务端口": "301d8708",
Expand Down Expand Up @@ -169,6 +172,7 @@
"请选择": "021f3e37",
"请选择声音": "08ac1686",
"请选择声音角色": "720a177b",
"跟随系统": "42c281d4",
"跨语种": "02261f68",
"输入关键词过滤": "5e1bac63",
"输入语音内容开始克隆": "39600ad2",
Expand Down
4 changes: 4 additions & 0 deletions src/lang/zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,12 @@
"000c8f6a": "提示",
"000c9ba9": "放大",
"000ca601": "描述",
"000caa60": "明亮",
"000cb692": "日志",
"000cc4dc": "撤销",
"000ccd34": "服务",
"000ccf01": "收起",
"000d0b1a": "暗黑",
"000d249f": "标识",
"000d318a": "模型",
"000d5f35": "正常",
Expand Down Expand Up @@ -98,6 +100,7 @@
"259ff066": "下载失败",
"25a0c8e1": "下载成功",
"25aba9c4": "代码查看",
"25d99435": "主题样式",
"25e596a4": "使用反馈",
"2615bdd6": "在哪里找到模型文件?",
"26276a3a": "停止服务",
Expand Down Expand Up @@ -166,6 +169,7 @@
"4148da61": "请求错误",
"41dff64a": "正在解压 {name}",
"41e0472e": "语音合成",
"42c281d4": "跟随系统",
"42ed4ed0": "连接设备",
"42fa058a": "选择模型",
"42fe06e0": "选择角色",
Expand Down
6 changes: 3 additions & 3 deletions src/store/modules/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
34 changes: 23 additions & 11 deletions vite.config.ts
Original file line number Diff line number Diff line change
@@ -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";
Expand Down Expand Up @@ -53,8 +54,8 @@ export default defineConfig(({command}) => {

},
},
electron({
main: {
electron([
{
// Shortcut of `build.lib.entry`
entry: 'electron/main/index.ts',
onstart({startup}) {
Expand All @@ -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,
Expand Down

0 comments on commit 8903082

Please sign in to comment.