zen-gitsync 2.16.28 → 2.16.30

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (80) hide show
  1. package/README.md +2 -2
  2. package/package.json +1 -1
  3. package/src/cli/ai/platformGuard.js +200 -200
  4. package/src/cli/ai/platformGuard.test.js +253 -253
  5. package/src/gitCommit.js +484 -484
  6. package/src/ui/public/assets/AgentView-Cp9Xgs_B.js +4 -0
  7. package/src/ui/public/assets/AppVersionBadge-DcgY2eSV.js +2 -0
  8. package/src/ui/public/assets/BranchSelector-Bc_nwnaf.js +1 -0
  9. package/src/ui/public/assets/CommitForm-DmTaYwYF.js +6 -0
  10. package/src/ui/public/assets/CommonDialog-Brk9ZIx_.js +1 -0
  11. package/src/ui/public/assets/EditorView-BXcPstel.js +1 -0
  12. package/src/ui/public/assets/{FlowExecutionViewer-B7CdeiSp.js → FlowExecutionViewer-DT4WJ3H6.js} +1 -1
  13. package/src/ui/public/assets/FlowOrchestrationWorkspace-kzpWFreh.js +21 -0
  14. package/src/ui/public/assets/LogList-BlJplIi1.css +1 -0
  15. package/src/ui/public/assets/LogList-FyPUAVK6.js +7 -0
  16. package/src/ui/public/assets/MindmapView-qul1kc2j.js +2 -0
  17. package/src/ui/public/assets/MonitorView-CJO-jTlG.js +1 -0
  18. package/src/ui/public/assets/ProjectStartupButton-oZJIaL1F.js +1 -0
  19. package/src/ui/public/assets/{RemoteRepoCard-CGn4tRy-.js → RemoteRepoCard-Cyz5QDia.js} +2 -2
  20. package/src/ui/public/assets/SourceMapView-BXHG1JE_.js +3 -0
  21. package/src/ui/public/assets/{SvgIcon-CL2qPswh.js → SvgIcon-DjCKMwo1.js} +1 -1
  22. package/src/ui/public/assets/UserInputNode-lSHdQ7nQ.js +1 -0
  23. package/src/ui/public/assets/WorkbenchView-BSupsbko.js +28 -0
  24. package/src/ui/public/assets/{_plugin-vue_export-helper-D3_upOKo.js → _plugin-vue_export-helper-DExUTKTW.js} +5 -3
  25. package/src/ui/public/assets/configStore-BFc69UjA.js +1 -0
  26. package/src/ui/public/assets/{css.worker-CvXBzhp8.js → css.worker-Wv5dxAWO.js} +1 -1
  27. package/src/ui/public/assets/{dagre-CWIGcX9d.js → dagre-CyRyf1aT.js} +1 -1
  28. package/src/ui/public/assets/element-plus--ayTjGvF.js +25 -0
  29. package/src/ui/public/assets/element-plus-D3Dn7nX0.css +1 -0
  30. package/src/ui/public/assets/{flow-mindmap-B5aqOviR.js → flow-mindmap-BcBVGR99.js} +38 -38
  31. package/src/ui/public/assets/{html.worker-BO6WuOEO.js → html.worker-CQP8QQsS.js} +1 -1
  32. package/src/ui/public/assets/index-DX3FHIo4.js +79 -0
  33. package/src/ui/public/assets/index-zmReBTKj.css +1 -0
  34. package/src/ui/public/assets/{json.worker-BkJRGcCJ.js → json.worker-DzV-CpCQ.js} +1 -1
  35. package/src/ui/public/assets/{monaco-BFLoT2VD.js → monaco-43aputPh.js} +198 -198
  36. package/src/ui/public/assets/socket-io-BZIzo1US.js +1 -0
  37. package/src/ui/public/assets/toolsStore-B2zt5KJ0.js +1 -0
  38. package/src/ui/public/assets/{ts.worker-B0J26iPs.js → ts.worker-Dth06zuC.js} +15 -15
  39. package/src/ui/public/assets/{vendor-Cx8PA1NP.js → vendor-Dan_vdyX.js} +14 -14
  40. package/src/ui/public/assets/{vue-flow-COROsN-V.js → vue-flow-CUR1dbQb.js} +2 -2
  41. package/src/ui/public/favicon.svg +75 -75
  42. package/src/ui/public/index.html +32 -32
  43. package/src/ui/public/logo.svg +74 -74
  44. package/src/ui/server/middleware/requestLogger.js +53 -53
  45. package/src/ui/server/routes/branchStatus.js +105 -105
  46. package/src/ui/server/routes/git/diff.js +426 -426
  47. package/src/ui/server/routes/git/diffUtils.js +149 -149
  48. package/src/ui/server/routes/git/stash.js +550 -550
  49. package/src/ui/server/routes/git/tags.js +176 -176
  50. package/src/ui/server/routes/process.js +86 -86
  51. package/src/ui/server/routes/status.js +67 -67
  52. package/src/ui/server/routes/workbench/pdfText.js +145 -145
  53. package/src/ui/server/utils/createSavePortToFile.js +48 -48
  54. package/src/ui/server/utils/instanceRegistry.js +282 -282
  55. package/src/ui/server/utils/startServerOnAvailablePort.js +116 -116
  56. package/src/ui/public/assets/AgentView-Bytr0HbV.js +0 -4
  57. package/src/ui/public/assets/AppVersionBadge-DTsgbuSQ.js +0 -2
  58. package/src/ui/public/assets/BranchSelector-C9OPOmaJ.js +0 -1
  59. package/src/ui/public/assets/CommitForm-Cr5Ajewf.js +0 -6
  60. package/src/ui/public/assets/CommonDialog-CQz6iEqp.js +0 -1
  61. package/src/ui/public/assets/EditorView-BYoWEp7_.js +0 -1
  62. package/src/ui/public/assets/FlowOrchestrationWorkspace--Sguba2_.js +0 -21
  63. package/src/ui/public/assets/LogList-Bo53PBwg.css +0 -1
  64. package/src/ui/public/assets/LogList-CF47CGZw.js +0 -7
  65. package/src/ui/public/assets/MindmapView-DR5bT_oQ.js +0 -2
  66. package/src/ui/public/assets/MonitorView-DoLNabxl.js +0 -1
  67. package/src/ui/public/assets/ProjectStartupButton-BiNiH43W.js +0 -1
  68. package/src/ui/public/assets/SourceMapView-DhxMPULM.js +0 -3
  69. package/src/ui/public/assets/UserInputNode-BftMuqji.js +0 -1
  70. package/src/ui/public/assets/WorkbenchView-CJwU_MsO.js +0 -28
  71. package/src/ui/public/assets/configStore-Cqnbpz5-.js +0 -1
  72. package/src/ui/public/assets/element-plus-B3pTS_5R.js +0 -32
  73. package/src/ui/public/assets/element-plus-CQrjg9us.css +0 -1
  74. package/src/ui/public/assets/index-BgKFctmf.js +0 -71
  75. package/src/ui/public/assets/index-DnD8_s3s.css +0 -1
  76. package/src/ui/public/assets/socket-io-Bcae2P7B.js +0 -1
  77. package/src/ui/public/assets/toolsStore-D9gXnqwO.js +0 -1
  78. package/src/ui/server/.claude/codediff.txt +0 -8
  79. /package/src/ui/public/assets/{editor.worker-Cn2oRESe.js → editor.worker-Bd9IXS8d.js} +0 -0
  80. /package/src/ui/public/assets/{rolldown-runtime-CMxvf4Kt.js → rolldown-runtime-BM3Ffeng.js} +0 -0
@@ -1,145 +1,145 @@
1
- // Copyright 2026 xz333221
2
- //
3
- // Licensed under the Apache License, Version 2.0 (the "License");
4
- // you may not use this file except in compliance with the License.
5
- // You may obtain a copy of the License at
6
- //
7
- // http://www.apache.org/licenses/LICENSE-2.0
8
- //
9
- // Unless required by applicable law or agreed to in writing, software
10
- // distributed under the License is distributed on an "AS IS" BASIS,
11
- // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- // See the License for the specific language governing permissions and
13
- // limitations under the License.
14
- //
15
- // PDF 文本预提取工具。
16
- //
17
- // Claude CLI (claude.exe v2.1.x) 在解析 PDF 时内部 pdfParse 函数不可用,
18
- // 报错 "pdfParse is not a function"。本模块在服务端用 pdf-parse 库
19
- // 预提取 PDF 文本,将提取出的内容直接拼入 prompt,绕过 Claude CLI
20
- // 的 PDF 解析 bug。
21
- //
22
- // 核心 API:
23
- // - extractPdfText(filePath) 读取 PDF 文件并返回纯文本,失败返回 null
24
- // - isPdfAttachment(att) 判断附件是否为 PDF
25
- // - buildAttachmentBlock(attachments) 构建附件文本块,PDF 自动预提取
26
-
27
- import fs from 'fs';
28
- import { isImageExt } from './attachmentUtils.js';
29
-
30
- // 最大提取字符数(避免超大 PDF 把 prompt 撑爆)
31
- const MAX_PDF_TEXT_CHARS = 80_000;
32
-
33
- /**
34
- * 判断附件是否为 PDF
35
- * @param {{ext?: string, mimeType?: string}} att
36
- * @returns {boolean}
37
- */
38
- export function isPdfAttachment(att) {
39
- if (!att) return false;
40
- const ext = String(att.ext || '').toLowerCase();
41
- const mime = String(att.mimeType || '').toLowerCase();
42
- return ext === 'pdf' || mime === 'application/pdf';
43
- }
44
-
45
- /**
46
- * 从 PDF 文件中提取纯文本。
47
- * 使用 pdf-parse 库(node 端),失败时返回 null。
48
- *
49
- * @param {string} filePath PDF 文件的绝对路径
50
- * @returns {Promise<string|null>} 提取的文本(可能截断),失败返回 null
51
- */
52
- export async function extractPdfText(filePath) {
53
- try {
54
- const buffer = fs.readFileSync(filePath);
55
- // 动态 import 避免在非 PDF 场景加载 pdfjs
56
- const { PDFParse } = await import('pdf-parse');
57
- const parser = new PDFParse({ data: new Uint8Array(buffer) });
58
- const result = await parser.getText();
59
- await parser.destroy();
60
- const text = result?.text || '';
61
- if (!text.trim()) return null;
62
- // 截断超长文本
63
- if (text.length > MAX_PDF_TEXT_CHARS) {
64
- return text.slice(0, MAX_PDF_TEXT_CHARS) + '\n\n[... 文档过长,已截断 ...]';
65
- }
66
- return text;
67
- } catch (err) {
68
- // 常见失败:加密 PDF / 扫描版 PDF(无可提取文本) / 损坏文件
69
- console.error('[pdfText] PDF 解析失败:', err?.message || String(err));
70
- return null;
71
- }
72
- }
73
-
74
- /**
75
- * 构建附件信息块。
76
- * - 图片:列路径(Claude CLI 可直接读取)
77
- * - PDF:预提取文本并内联,不列路径(绕过 Claude CLI 的 pdfParse bug)
78
- * - 其他:列路径
79
- *
80
- * @param {Array<{absolutePath?: string, ext?: string, mimeType?: string}>} attachments
81
- * @param {object} [opts]
82
- * @param {boolean} [opts.withImageData=false] 是否读取图片为 data URL(预览/拆分场景需要)
83
- * @returns {Promise<{ block: string, imageDataUrls: string[] }>}
84
- */
85
- export async function buildAttachmentBlock(attachments, opts) {
86
- const withImages = opts?.withImageData ?? false;
87
- const imageDataUrls = [];
88
- if (!attachments || attachments.length === 0) {
89
- return { block: '', imageDataUrls };
90
- }
91
-
92
- const lines = [];
93
- let pdfCount = 0;
94
- let pdfFailedCount = 0;
95
-
96
- for (let i = 0; i < attachments.length; i++) {
97
- const a = attachments[i];
98
- if (!a || !a.absolutePath) continue;
99
-
100
- if (isPdfAttachment(a)) {
101
- // PDF:预提取文本,不把路径交给 Claude CLI
102
- const text = await extractPdfText(a.absolutePath);
103
- if (text) {
104
- pdfCount++;
105
- lines.push(` ${i + 1}. [PDF 全文提取] ${a.absolutePath}`);
106
- lines.push(` <pdf_content>\n${text}\n </pdf_content>`);
107
- } else {
108
- pdfFailedCount++;
109
- lines.push(` ${i + 1}. [PDF 解析失败] ${a.absolutePath}(可能是扫描版/加密/损坏,请尝试用其他工具转换为文本后重新上传)`);
110
- }
111
- } else if (isImageExt(a.ext)) {
112
- // 图片:列路径,可选读 data URL
113
- lines.push(` ${i + 1}. [${a.mimeType || 'image'}] ${a.absolutePath}`);
114
- if (withImages) {
115
- try {
116
- const buf = fs.readFileSync(a.absolutePath);
117
- const mime = a.mimeType || 'image/png';
118
- imageDataUrls.push(`data:${mime};base64,${buf.toString('base64')}`);
119
- } catch { /* 文件丢失就跳过 */ }
120
- }
121
- } else {
122
- // 其他文件:列路径
123
- lines.push(` ${i + 1}. [${a.mimeType || 'application/octet-stream'}] ${a.absolutePath}`);
124
- }
125
- }
126
-
127
- if (lines.length === 0) {
128
- return { block: '', imageDataUrls };
129
- }
130
-
131
- const parts = [];
132
- if (pdfCount > 0) {
133
- parts.push(`其中 ${pdfCount} 个 PDF 已预提取全文`);
134
- }
135
- if (pdfFailedCount > 0) {
136
- parts.push(`${pdfFailedCount} 个 PDF 解析失败`);
137
- }
138
- const imgNote = withImages && imageDataUrls.length > 0
139
- ? `(其中 ${imageDataUrls.length} 张图片已随消息一并发送,请直接基于图片内容分析)`
140
- : '';
141
- const note = parts.length > 0 ? `(${parts.join(',')})` : imgNote;
142
-
143
- const block = `\n\n## 任务附件${note}\n${lines.join('\n')}`;
144
- return { block, imageDataUrls };
145
- }
1
+ // Copyright 2026 xz333221
2
+ //
3
+ // Licensed under the Apache License, Version 2.0 (the "License");
4
+ // you may not use this file except in compliance with the License.
5
+ // You may obtain a copy of the License at
6
+ //
7
+ // http://www.apache.org/licenses/LICENSE-2.0
8
+ //
9
+ // Unless required by applicable law or agreed to in writing, software
10
+ // distributed under the License is distributed on an "AS IS" BASIS,
11
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ // See the License for the specific language governing permissions and
13
+ // limitations under the License.
14
+ //
15
+ // PDF 文本预提取工具。
16
+ //
17
+ // Claude CLI (claude.exe v2.1.x) 在解析 PDF 时内部 pdfParse 函数不可用,
18
+ // 报错 "pdfParse is not a function"。本模块在服务端用 pdf-parse 库
19
+ // 预提取 PDF 文本,将提取出的内容直接拼入 prompt,绕过 Claude CLI
20
+ // 的 PDF 解析 bug。
21
+ //
22
+ // 核心 API:
23
+ // - extractPdfText(filePath) 读取 PDF 文件并返回纯文本,失败返回 null
24
+ // - isPdfAttachment(att) 判断附件是否为 PDF
25
+ // - buildAttachmentBlock(attachments) 构建附件文本块,PDF 自动预提取
26
+
27
+ import fs from 'fs';
28
+ import { isImageExt } from './attachmentUtils.js';
29
+
30
+ // 最大提取字符数(避免超大 PDF 把 prompt 撑爆)
31
+ const MAX_PDF_TEXT_CHARS = 80_000;
32
+
33
+ /**
34
+ * 判断附件是否为 PDF
35
+ * @param {{ext?: string, mimeType?: string}} att
36
+ * @returns {boolean}
37
+ */
38
+ export function isPdfAttachment(att) {
39
+ if (!att) return false;
40
+ const ext = String(att.ext || '').toLowerCase();
41
+ const mime = String(att.mimeType || '').toLowerCase();
42
+ return ext === 'pdf' || mime === 'application/pdf';
43
+ }
44
+
45
+ /**
46
+ * 从 PDF 文件中提取纯文本。
47
+ * 使用 pdf-parse 库(node 端),失败时返回 null。
48
+ *
49
+ * @param {string} filePath PDF 文件的绝对路径
50
+ * @returns {Promise<string|null>} 提取的文本(可能截断),失败返回 null
51
+ */
52
+ export async function extractPdfText(filePath) {
53
+ try {
54
+ const buffer = fs.readFileSync(filePath);
55
+ // 动态 import 避免在非 PDF 场景加载 pdfjs
56
+ const { PDFParse } = await import('pdf-parse');
57
+ const parser = new PDFParse({ data: new Uint8Array(buffer) });
58
+ const result = await parser.getText();
59
+ await parser.destroy();
60
+ const text = result?.text || '';
61
+ if (!text.trim()) return null;
62
+ // 截断超长文本
63
+ if (text.length > MAX_PDF_TEXT_CHARS) {
64
+ return text.slice(0, MAX_PDF_TEXT_CHARS) + '\n\n[... 文档过长,已截断 ...]';
65
+ }
66
+ return text;
67
+ } catch (err) {
68
+ // 常见失败:加密 PDF / 扫描版 PDF(无可提取文本) / 损坏文件
69
+ console.error('[pdfText] PDF 解析失败:', err?.message || String(err));
70
+ return null;
71
+ }
72
+ }
73
+
74
+ /**
75
+ * 构建附件信息块。
76
+ * - 图片:列路径(Claude CLI 可直接读取)
77
+ * - PDF:预提取文本并内联,不列路径(绕过 Claude CLI 的 pdfParse bug)
78
+ * - 其他:列路径
79
+ *
80
+ * @param {Array<{absolutePath?: string, ext?: string, mimeType?: string}>} attachments
81
+ * @param {object} [opts]
82
+ * @param {boolean} [opts.withImageData=false] 是否读取图片为 data URL(预览/拆分场景需要)
83
+ * @returns {Promise<{ block: string, imageDataUrls: string[] }>}
84
+ */
85
+ export async function buildAttachmentBlock(attachments, opts) {
86
+ const withImages = opts?.withImageData ?? false;
87
+ const imageDataUrls = [];
88
+ if (!attachments || attachments.length === 0) {
89
+ return { block: '', imageDataUrls };
90
+ }
91
+
92
+ const lines = [];
93
+ let pdfCount = 0;
94
+ let pdfFailedCount = 0;
95
+
96
+ for (let i = 0; i < attachments.length; i++) {
97
+ const a = attachments[i];
98
+ if (!a || !a.absolutePath) continue;
99
+
100
+ if (isPdfAttachment(a)) {
101
+ // PDF:预提取文本,不把路径交给 Claude CLI
102
+ const text = await extractPdfText(a.absolutePath);
103
+ if (text) {
104
+ pdfCount++;
105
+ lines.push(` ${i + 1}. [PDF 全文提取] ${a.absolutePath}`);
106
+ lines.push(` <pdf_content>\n${text}\n </pdf_content>`);
107
+ } else {
108
+ pdfFailedCount++;
109
+ lines.push(` ${i + 1}. [PDF 解析失败] ${a.absolutePath}(可能是扫描版/加密/损坏,请尝试用其他工具转换为文本后重新上传)`);
110
+ }
111
+ } else if (isImageExt(a.ext)) {
112
+ // 图片:列路径,可选读 data URL
113
+ lines.push(` ${i + 1}. [${a.mimeType || 'image'}] ${a.absolutePath}`);
114
+ if (withImages) {
115
+ try {
116
+ const buf = fs.readFileSync(a.absolutePath);
117
+ const mime = a.mimeType || 'image/png';
118
+ imageDataUrls.push(`data:${mime};base64,${buf.toString('base64')}`);
119
+ } catch { /* 文件丢失就跳过 */ }
120
+ }
121
+ } else {
122
+ // 其他文件:列路径
123
+ lines.push(` ${i + 1}. [${a.mimeType || 'application/octet-stream'}] ${a.absolutePath}`);
124
+ }
125
+ }
126
+
127
+ if (lines.length === 0) {
128
+ return { block: '', imageDataUrls };
129
+ }
130
+
131
+ const parts = [];
132
+ if (pdfCount > 0) {
133
+ parts.push(`其中 ${pdfCount} 个 PDF 已预提取全文`);
134
+ }
135
+ if (pdfFailedCount > 0) {
136
+ parts.push(`${pdfFailedCount} 个 PDF 解析失败`);
137
+ }
138
+ const imgNote = withImages && imageDataUrls.length > 0
139
+ ? `(其中 ${imageDataUrls.length} 张图片已随消息一并发送,请直接基于图片内容分析)`
140
+ : '';
141
+ const note = parts.length > 0 ? `(${parts.join(',')})` : imgNote;
142
+
143
+ const block = `\n\n## 任务附件${note}\n${lines.join('\n')}`;
144
+ return { block, imageDataUrls };
145
+ }
@@ -1,48 +1,48 @@
1
- // Copyright 2026 xz333221
2
- //
3
- // Licensed under the Apache License, Version 2.0 (the "License");
4
- // you may not use this file except in compliance with the License.
5
- // You may obtain a copy of the License at
6
- //
7
- // http://www.apache.org/licenses/LICENSE-2.0
8
- //
9
- // Unless required by applicable law or agreed to in writing, software
10
- // distributed under the License is distributed on an "AS IS" BASIS,
11
- // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- // See the License for the specific language governing permissions and
13
- // limitations under the License.
14
- //
15
- import logger from './logger.js'
16
-
17
- export function createSavePortToFile({ savePort, fs, path, cwdFn = process.cwd }) {
18
- let savedPort = null;
19
-
20
- return async function savePortToFile(port) {
21
- try {
22
- if (savePort && savedPort !== port) {
23
- savedPort = port;
24
-
25
- const portFilePath = path.join(cwdFn(), '.port');
26
- await fs.writeFile(portFilePath, port.toString(), 'utf8');
27
- logger.info(`端口号 ${port} 已保存到 ${portFilePath}`);
28
-
29
- try {
30
- const clientPath = path.join(cwdFn(), 'src', 'ui', 'client');
31
- const envPath = path.join(clientPath, '.env.local');
32
-
33
- await fs.access(clientPath).catch(() => {
34
- logger.info(`客户端目录 ${clientPath} 不存在,跳过环境变量设置`);
35
- return Promise.reject(new Error('Client directory not found'));
36
- });
37
-
38
- await fs.writeFile(envPath, `VITE_BACKEND_PORT=${port}\n`, 'utf8');
39
- logger.info(`端口号环境变量已保存到 ${envPath}`);
40
- } catch (envError) {
41
- logger.error('保存端口号到环境变量失败,但不影响主要功能:', envError);
42
- }
43
- }
44
- } catch (error) {
45
- logger.error('保存端口号到文件失败:', error);
46
- }
47
- };
48
- }
1
+ // Copyright 2026 xz333221
2
+ //
3
+ // Licensed under the Apache License, Version 2.0 (the "License");
4
+ // you may not use this file except in compliance with the License.
5
+ // You may obtain a copy of the License at
6
+ //
7
+ // http://www.apache.org/licenses/LICENSE-2.0
8
+ //
9
+ // Unless required by applicable law or agreed to in writing, software
10
+ // distributed under the License is distributed on an "AS IS" BASIS,
11
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ // See the License for the specific language governing permissions and
13
+ // limitations under the License.
14
+ //
15
+ import logger from './logger.js'
16
+
17
+ export function createSavePortToFile({ savePort, fs, path, cwdFn = process.cwd }) {
18
+ let savedPort = null;
19
+
20
+ return async function savePortToFile(port) {
21
+ try {
22
+ if (savePort && savedPort !== port) {
23
+ savedPort = port;
24
+
25
+ const portFilePath = path.join(cwdFn(), '.port');
26
+ await fs.writeFile(portFilePath, port.toString(), 'utf8');
27
+ logger.info(`端口号 ${port} 已保存到 ${portFilePath}`);
28
+
29
+ try {
30
+ const clientPath = path.join(cwdFn(), 'src', 'ui', 'client');
31
+ const envPath = path.join(clientPath, '.env.local');
32
+
33
+ await fs.access(clientPath).catch(() => {
34
+ logger.info(`客户端目录 ${clientPath} 不存在,跳过环境变量设置`);
35
+ return Promise.reject(new Error('Client directory not found'));
36
+ });
37
+
38
+ await fs.writeFile(envPath, `VITE_BACKEND_PORT=${port}\n`, 'utf8');
39
+ logger.info(`端口号环境变量已保存到 ${envPath}`);
40
+ } catch (envError) {
41
+ logger.error('保存端口号到环境变量失败,但不影响主要功能:', envError);
42
+ }
43
+ }
44
+ } catch (error) {
45
+ logger.error('保存端口号到文件失败:', error);
46
+ }
47
+ };
48
+ }