Skip to content

Commit cb2baeb

Browse files
committed
fix unfind model
1 parent a3f03eb commit cb2baeb

3 files changed

Lines changed: 17 additions & 6 deletions

File tree

packages/desktop/electron-builder.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ extraResources:
1616
to: backend/cli.bundle.js
1717
- from: ../codingcode/dist/cli.bundle.js.map
1818
to: backend/cli.bundle.js.map
19+
- from: ../../config/models.json
20+
to: config/models.json
1921

2022
asar: true
2123

packages/desktop/electron/core/child-process.ts

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,23 +9,26 @@ function isDev(): boolean {
99
return !!process.env.ELECTRON_RENDERER_URL;
1010
}
1111

12+
function getResourcesDir(): string {
13+
return process.platform === 'darwin'
14+
? join(process.execPath, '../../Resources')
15+
: join(process.execPath, '../resources');
16+
}
17+
1218
function getBackendEntry(): string {
1319
if (isDev()) {
1420
return resolve(app.getAppPath(), '../../packages/codingcode/src/cli.ts');
1521
}
1622
// 生产模式:后端 bundle 通过 extraResources 放到 resources/backend/
17-
const resourcesDir =
18-
process.platform === 'darwin'
19-
? join(process.execPath, '../../Resources')
20-
: join(process.execPath, '../resources');
21-
return join(resourcesDir, 'backend', 'cli.bundle.js');
23+
return join(getResourcesDir(), 'backend', 'cli.bundle.js');
2224
}
2325

2426
function getProjectRoot(): string {
2527
if (isDev()) {
2628
return resolve(app.getAppPath(), '../../');
2729
}
28-
return process.cwd();
30+
// 生产模式:config/models.json 通过 extraResources 放到 resources/config/
31+
return getResourcesDir();
2932
}
3033

3134
export async function startBackend(): Promise<number> {

packages/desktop/test/child-process.test.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,12 @@ describe('child-process', () => {
151151
const env = (options as any)?.env;
152152
expect(env?.NODE_ENV).toBe('production');
153153

154+
// 生产模式 cwd 应指向 resources 目录(而非 process.cwd())
155+
const cwd = (options as any)?.cwd;
156+
expect(cwd).toBeDefined();
157+
expect(cwd).not.toBe(process.cwd());
158+
expect(cwd.toLowerCase()).toContain('resources');
159+
154160
mockCp.stdout.emit('data', Buffer.from('CODINGCODE_SERVER_READY:3000\n'));
155161

156162
const port = await promise;

0 commit comments

Comments
 (0)