mirror of
https://github.com/hellodigua/ChatLab.git
synced 2026-10-25 17:54:34 +08:00
refactor: extract Electron shell to apps/desktop/
Move Electron-specific code (main, preload, shared) and configs (electron.vite, electron-builder) into apps/desktop/ to prepare for multi-platform support (Web Browser standalone). - Create apps/desktop/ with dedicated package.json and tsconfig - Split Electron deps (electron, electron-updater, better-sqlite3, etc.) from shared frontend deps in root package.json - Declare better-sqlite3 and @node-rs/jieba in packages/node-runtime - Add stream-json to packages/parser where it belongs - Update all path aliases (@electron/* → apps/desktop/*) in tsconfig, vite configs, and relative imports in preload/main - Keep slim root tsconfig.node.json as shared base for packages - Update CI/CD release workflow for new directory layout - Fix pre-existing type errors (pi-ai Model generic, SQLLabTab LLMChatStreamChunk, filter.test.ts empty methods)
This commit is contained in:
1 parent
ba29346bfe
commit
b12c07dc32
135 files changed
+275
-222
No files matched your search
@@ -90,18 +90,19 @@ jobs:
|
||||
APPLE_API_ISSUER: ${{ secrets.APPLE_API_ISSUER }}
|
||||
# 分析服务
|
||||
APTABASE_APP_KEY: ${{ secrets.APTABASE_APP_KEY }}
|
||||
run: pnpm build && pnpm exec electron-builder --mac --${{ matrix.arch }} --config electron-builder.yml -p never
|
||||
working-directory: apps/desktop
|
||||
run: pnpm run build && pnpm exec electron-builder --mac --${{ matrix.arch }} --config electron-builder.yml -p never
|
||||
|
||||
- name: Upload macOS artifacts (${{ matrix.arch }})
|
||||
uses: actions/upload-artifact@v6
|
||||
with:
|
||||
name: ChatLab-mac-${{ matrix.arch }}
|
||||
path: |
|
||||
dist/*.dmg
|
||||
dist/*.zip
|
||||
dist/*.yml
|
||||
dist/*.json
|
||||
dist/*.blockmap
|
||||
apps/desktop/dist/*.dmg
|
||||
apps/desktop/dist/*.zip
|
||||
apps/desktop/dist/*.yml
|
||||
apps/desktop/dist/*.json
|
||||
apps/desktop/dist/*.blockmap
|
||||
if-no-files-found: warn
|
||||
retention-days: 1 # 只保留1天,Release后会上传到GitHub Releases
|
||||
|
||||
@@ -153,17 +154,18 @@ jobs:
|
||||
GH_TOKEN: ${{ secrets.GH_TOKEN }}
|
||||
# 分析服务
|
||||
APTABASE_APP_KEY: ${{ secrets.APTABASE_APP_KEY }}
|
||||
run: pnpm build:win
|
||||
working-directory: apps/desktop
|
||||
run: pnpm run build && pnpm exec electron-builder --win --config electron-builder.yml -p never
|
||||
|
||||
- name: Upload Windows artifacts
|
||||
uses: actions/upload-artifact@v6
|
||||
with:
|
||||
name: ChatLab-win
|
||||
path: |
|
||||
dist/*.exe
|
||||
dist/*.yml
|
||||
dist/*.json
|
||||
dist/*.blockmap
|
||||
apps/desktop/dist/*.exe
|
||||
apps/desktop/dist/*.yml
|
||||
apps/desktop/dist/*.json
|
||||
apps/desktop/dist/*.blockmap
|
||||
if-no-files-found: warn
|
||||
retention-days: 1 # 只保留1天,Release后会上传到GitHub Releases
|
||||
|
||||
@@ -221,11 +223,13 @@ jobs:
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.GH_TOKEN }}
|
||||
APTABASE_APP_KEY: ${{ secrets.APTABASE_APP_KEY }}
|
||||
working-directory: apps/desktop
|
||||
run: |
|
||||
pnpm run build
|
||||
if [ "${{ matrix.arch }}" = "arm64" ]; then
|
||||
pnpm run build && pnpm exec electron-builder --linux deb --arm64 --config electron-builder.yml -p never
|
||||
pnpm exec electron-builder --linux deb --arm64 --config electron-builder.yml -p never
|
||||
else
|
||||
pnpm build:linux
|
||||
pnpm exec electron-builder --linux --config electron-builder.yml -p never
|
||||
fi
|
||||
|
||||
- name: Upload Linux artifacts (${{ matrix.arch }})
|
||||
@@ -233,11 +237,11 @@ jobs:
|
||||
with:
|
||||
name: ChatLab-linux-${{ matrix.arch }}
|
||||
path: |
|
||||
dist/*.AppImage
|
||||
dist/*.deb
|
||||
dist/*.tar.gz
|
||||
dist/*.yml
|
||||
dist/*.json
|
||||
apps/desktop/dist/*.AppImage
|
||||
apps/desktop/dist/*.deb
|
||||
apps/desktop/dist/*.tar.gz
|
||||
apps/desktop/dist/*.yml
|
||||
apps/desktop/dist/*.json
|
||||
if-no-files-found: warn
|
||||
retention-days: 1
|
||||
|
||||
@@ -254,34 +258,34 @@ jobs:
|
||||
uses: actions/download-artifact@v8
|
||||
with:
|
||||
name: ChatLab-mac-x64
|
||||
path: dist
|
||||
path: release-dist
|
||||
|
||||
- name: Download macOS artifacts (arm64)
|
||||
uses: actions/download-artifact@v8
|
||||
with:
|
||||
name: ChatLab-mac-arm64
|
||||
path: dist
|
||||
path: release-dist
|
||||
|
||||
- name: Download Windows artifacts
|
||||
uses: actions/download-artifact@v8
|
||||
with:
|
||||
name: ChatLab-win
|
||||
path: dist
|
||||
path: release-dist
|
||||
|
||||
- name: Download Linux artifacts
|
||||
uses: actions/download-artifact@v8
|
||||
with:
|
||||
name: ChatLab-linux-x64
|
||||
path: dist
|
||||
path: release-dist
|
||||
|
||||
- name: Download Linux artifacts (arm64)
|
||||
uses: actions/download-artifact@v8
|
||||
with:
|
||||
name: ChatLab-linux-arm64
|
||||
path: dist
|
||||
path: release-dist
|
||||
|
||||
- name: List files
|
||||
run: ls -la dist/
|
||||
run: ls -la release-dist/
|
||||
|
||||
- name: Generate Release Notes
|
||||
id: release_notes
|
||||
@@ -297,8 +301,8 @@ jobs:
|
||||
echo "Current version: $CURRENT_VERSION"
|
||||
|
||||
# 从 changelog JSON 中提取最新版本的 summary
|
||||
EN_SUMMARY=$(jq -r '.[0].summary' docs/public/changelogs/en.json)
|
||||
CN_SUMMARY=$(jq -r '.[0].summary' docs/public/changelogs/cn.json)
|
||||
EN_SUMMARY=$(jq -r '.[0].summary' docs/public/changelogs/en.json 2>/dev/null || echo "See changelog for details")
|
||||
CN_SUMMARY=$(jq -r '.[0].summary' docs/public/changelogs/cn.json 2>/dev/null || echo "详见更新日志")
|
||||
|
||||
echo "EN summary: $EN_SUMMARY"
|
||||
echo "CN summary: $CN_SUMMARY"
|
||||
@@ -339,14 +343,14 @@ jobs:
|
||||
name: ChatLab ${{ github.event_name == 'workflow_dispatch' && inputs.version || github.ref_name }}
|
||||
body_path: release_notes.md
|
||||
files: |
|
||||
dist/*.exe
|
||||
dist/*.dmg
|
||||
dist/*.zip
|
||||
dist/*.AppImage
|
||||
dist/*.deb
|
||||
dist/*.tar.gz
|
||||
dist/*.yml
|
||||
dist/*.blockmap
|
||||
release-dist/*.exe
|
||||
release-dist/*.dmg
|
||||
release-dist/*.zip
|
||||
release-dist/*.AppImage
|
||||
release-dist/*.deb
|
||||
release-dist/*.tar.gz
|
||||
release-dist/*.yml
|
||||
release-dist/*.blockmap
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
@@ -380,7 +384,7 @@ jobs:
|
||||
r2-access-key-id: ${{ secrets.R2_ACCESS_KEY_ID }}
|
||||
r2-secret-access-key: ${{ secrets.R2_SECRET_ACCESS_KEY }}
|
||||
r2-bucket: ${{ secrets.R2_BUCKET_NAME }}
|
||||
source-dir: dist
|
||||
source-dir: release-dist
|
||||
destination-dir: releases/download/${{ steps.version.outputs.tag }}
|
||||
|
||||
# 准备 yml 文件用于根目录上传
|
||||
@@ -392,7 +396,7 @@ jobs:
|
||||
VERSION_TAG="${{ steps.version.outputs.tag }}"
|
||||
|
||||
# 处理所有 yml 文件
|
||||
for yml_file in dist/*.yml; do
|
||||
for yml_file in release-dist/*.yml; do
|
||||
filename=$(basename "$yml_file")
|
||||
echo "Processing $filename..."
|
||||
|
||||
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -14,11 +14,10 @@ directories:
|
||||
files:
|
||||
- out/**/*
|
||||
- '!**/.vscode/*'
|
||||
- '!src/*'
|
||||
- '!electron.vite.config.{js,ts,mjs,cjs}'
|
||||
- '!{.eslintignore,.eslintrc.cjs,.prettierignore,.prettierrc.yaml,CHANGELOG.md,README.md}'
|
||||
- '!{.env,.env.*,.npmrc,pnpm-lock.yaml}'
|
||||
- '!{tsconfig.json,tsconfig.node.json,tsconfig.web.json}'
|
||||
- '!{tsconfig.json,tsconfig.node.json}'
|
||||
# jieba 词库文件已改为启动时远程下载,无需打包内置
|
||||
- '!node_modules/@node-rs/jieba/dict.txt'
|
||||
- '!node_modules/@node-rs/jieba/idf.txt'
|
||||
@@ -3,13 +3,15 @@ import { defineConfig, externalizeDepsPlugin } from 'electron-vite'
|
||||
import vue from '@vitejs/plugin-vue'
|
||||
import ui from '@nuxt/ui/vite'
|
||||
|
||||
const rootDir = resolve(__dirname, '../..')
|
||||
|
||||
export default defineConfig(() => {
|
||||
return {
|
||||
main: {
|
||||
plugins: [externalizeDepsPlugin()],
|
||||
resolve: {
|
||||
alias: {
|
||||
'@openchatlab': resolve('packages'),
|
||||
'@openchatlab': resolve(rootDir, 'packages'),
|
||||
},
|
||||
},
|
||||
define: {
|
||||
@@ -21,8 +23,8 @@ export default defineConfig(() => {
|
||||
build: {
|
||||
rollupOptions: {
|
||||
input: {
|
||||
index: resolve(__dirname, 'electron/main/index.ts'),
|
||||
'worker/dbWorker': resolve(__dirname, 'electron/main/worker/dbWorker.ts'),
|
||||
index: resolve(__dirname, 'main/index.ts'),
|
||||
'worker/dbWorker': resolve(__dirname, 'main/worker/dbWorker.ts'),
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -31,13 +33,13 @@ export default defineConfig(() => {
|
||||
plugins: [externalizeDepsPlugin()],
|
||||
resolve: {
|
||||
alias: {
|
||||
'@openchatlab': resolve('packages'),
|
||||
'@openchatlab': resolve(rootDir, 'packages'),
|
||||
},
|
||||
},
|
||||
build: {
|
||||
rollupOptions: {
|
||||
input: {
|
||||
index: resolve(__dirname, 'electron/preload/index.ts'),
|
||||
index: resolve(__dirname, 'preload/index.ts'),
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -45,9 +47,10 @@ export default defineConfig(() => {
|
||||
renderer: {
|
||||
resolve: {
|
||||
alias: {
|
||||
'@': resolve('src/'),
|
||||
'~': resolve('src/'),
|
||||
'@openchatlab': resolve('packages'),
|
||||
'@': resolve(rootDir, 'src/'),
|
||||
'~': resolve(rootDir, 'src/'),
|
||||
'@openchatlab': resolve(rootDir, 'packages'),
|
||||
'@electron': resolve(__dirname),
|
||||
},
|
||||
},
|
||||
define: {
|
||||
@@ -64,12 +67,12 @@ export default defineConfig(() => {
|
||||
},
|
||||
}),
|
||||
],
|
||||
root: 'src/',
|
||||
root: resolve(rootDir, 'src/'),
|
||||
build: {
|
||||
sourcemap: false,
|
||||
rollupOptions: {
|
||||
input: {
|
||||
index: resolve(__dirname, 'src/index.html'),
|
||||
index: resolve(rootDir, 'src/index.html'),
|
||||
},
|
||||
output: {
|
||||
manualChunks(id) {
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -13,7 +13,7 @@ import {
|
||||
renameSession as coreRenameSession,
|
||||
} from '@openchatlab/core'
|
||||
import { BetterSqliteAdapter, writeParseResultToDb } from '@openchatlab/node-runtime'
|
||||
import type { ParseResult } from '../../../src/types/base'
|
||||
import type { ParseResult } from '../../../../src/types/base'
|
||||
import { migrateDatabase, needsMigration, CURRENT_SCHEMA_VERSION } from './migrations'
|
||||
import { getPathProvider } from '../path-context'
|
||||
import { ensureDir } from '../paths'
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -7,7 +7,7 @@ import * as worker from '../worker/workerManager'
|
||||
import * as merger from '../merger'
|
||||
import { deleteTempDatabase, cleanupAllTempDatabases } from '../merger/tempCache'
|
||||
import type { ParseProgress } from '../parser'
|
||||
import type { MergeParams } from '../../../src/types/format'
|
||||
import type { MergeParams } from '../../../../src/types/format'
|
||||
import type { IpcContext } from './types'
|
||||
|
||||
// ==================== 临时数据库缓存 ====================
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -11,14 +11,14 @@ import type { ChatLabOutput } from '@openchatlab/node-runtime'
|
||||
import { importData } from '../database/core'
|
||||
import { TempDbReader } from './tempCache'
|
||||
import { getPathProvider } from '../path-context'
|
||||
import type { ChatPlatform, ChatType } from '../../../src/types/base'
|
||||
import type { ChatPlatform, ChatType } from '../../../../src/types/base'
|
||||
import type {
|
||||
ChatLabFormat,
|
||||
ChatLabMessage,
|
||||
ConflictCheckResult,
|
||||
MergeParams,
|
||||
MergeResult,
|
||||
} from '../../../src/types/format'
|
||||
} from '../../../../src/types/format'
|
||||
|
||||
function getDefaultOutputDir(): string {
|
||||
return getPathProvider().getDownloadsDir()
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loaded 100 of 135 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user