elec_rag_ui/electron-builder.config.ts
ssurui 6f93912c86 feat: 初始提交——elec_rag_ui 独立前端工程
基于 Electron + Vue3 + TypeScript + LanceDB 的本地化 RAG 问答桌面应用。
仅支持 Linux(Kylin V10 / Ubuntu),适配 ER160(揽月 M50 NPU)和 ER25(芯动力 RPP)计算卡。
服务进程管理委托给 er_backend(HTTP 17700),前端专注 RAG 逻辑与用户交互。

包含:
- src/elec_rag_ui 前端工程(Electron + Vue3)
- models/ 本地嵌入模型(bge-small/base/large,ASR,标点恢复,onnx 文件由 Git LFS 管理)
- docs/ 示例文档(用于测试索引与问答)
2026-08-15 19:25:28 +08:00

69 lines
2.1 KiB
TypeScript
Raw Permalink 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'
},
files: ['out/**/*'],
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