elec_rag_ui/electron-builder.config.ts
ssurui 598922dd16 fix: 修正打包产物缺失窗口图标的问题
electron-builder.config.ts 的 files 只包含 out/**/*,没有把顶层
resources/icon.png 带进应用包。src/main/index.ts 用相对路径
__dirname/../../resources/icon.png 定位窗口图标(打包后 __dirname
是 <app>/out/main),文件缺失导致任务栏/菜单栏图标显示不出来。

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-08-22 11:31:58 +08:00

71 lines
2.3 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import type { Configuration } from 'electron-builder'
import { execSync } from 'child_process'
import { readFileSync } from 'fs'
import { resolve } from 'path'
const releaseVersion = (() => {
try {
const tag = execSync('git describe --tags --abbrev=0').toString().trim()
return tag.replace(/^v/, '')
} catch {
// 无 git 环境(PAD rsync 部署):读取 .app-version 文件
try {
const tag = readFileSync(resolve('.app-version'), 'utf-8').trim()
return tag.replace(/^v/, '')
} catch {
return '0.0.0'
}
}
})()
const config: Configuration = {
appId: 'com.elec-rag-ui.app',
extraMetadata: { version: releaseVersion },
productName: '智能电子手册',
directories: {
buildResources: 'resources',
output: 'dist'
},
// resources/icon.png 单独列出:src/main/index.ts 用相对路径 __dirname/../../resources/icon.png
// 定位窗口图标(打包后 __dirname 是 <app>/out/main),必须让它落在 <app>/resources/ 下
files: ['out/**/*', 'resources/icon.png'],
asarUnpack: [
'node_modules/@lancedb/**',
'node_modules/apache-arrow/**',
'node_modules/onnxruntime-node/**',
'node_modules/sherpa-onnx-node/**',
'node_modules/sherpa-onnx-linux-x64/**'
],
// 打包时内嵌模型:LOCAL_MODEL_PATH=/path/to/bge-small-zh-v1.5 npm run package:mac
extraResources: [
...(process.env.LOCAL_MODEL_PATH
? [{ from: process.env.LOCAL_MODEL_PATH, to: 'models/bge-small-zh-v1.5' }]
: []),
{
from: 'models/asr/sherpa-onnx-streaming-paraformer-bilingual-zh-en',
to: 'models/asr/sherpa-onnx-streaming-paraformer-bilingual-zh-en'
},
// 内嵌离线 TTS 引擎(espeak-ng + 数据 + 依赖库),避免目标系统无 speech-dispatcher/espeak
{
from: 'resources/tts',
to: 'tts'
}
],
linux: {
// Linux 禁用 asar:sherpa-onnx-node 通过相对路径加载 sherpa-onnx-linux-x64 原生模块,
// 在 asar 归档内 __dirname 指向虚拟路径,导致 require 无法定位 .node 文件。
asar: false,
target: [
{ target: 'AppImage', arch: ['x64', 'arm64'] },
{ target: 'deb', arch: ['x64', 'arm64'] }
],
category: 'Utility'
},
// 加快 deb 打包速度:gzip 比 xz 快很多,体积略大
deb: {
compression: 'gz' as const
}
}
export default config