tianxincode 1.0.19 → 1.0.21
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.
- package/README.md +5 -1
- package/builder.html +98 -0
- package/dist/api/custom-actions.routes.d.ts +2 -0
- package/dist/api/custom-actions.routes.d.ts.map +1 -0
- package/dist/api/custom-actions.routes.js +101 -0
- package/dist/api/custom-actions.routes.js.map +1 -0
- package/dist/api/gateway.routes.d.ts.map +1 -1
- package/dist/api/gateway.routes.js +47 -0
- package/dist/api/gateway.routes.js.map +1 -1
- package/dist/api/index.d.ts.map +1 -1
- package/dist/api/index.js +2 -0
- package/dist/api/index.js.map +1 -1
- package/dist/components/Header.js +1 -1
- package/dist/modules/db/db.service.d.ts +2 -0
- package/dist/modules/db/db.service.d.ts.map +1 -1
- package/dist/modules/db/db.service.js +32 -0
- package/dist/modules/db/db.service.js.map +1 -1
- package/dist/modules/waf-gateway/index.d.ts +3 -0
- package/dist/modules/waf-gateway/index.d.ts.map +1 -0
- package/dist/modules/waf-gateway/index.js +2 -0
- package/dist/modules/waf-gateway/index.js.map +1 -0
- package/dist/modules/waf-gateway/waf-gateway.service.d.ts +32 -0
- package/dist/modules/waf-gateway/waf-gateway.service.d.ts.map +1 -0
- package/dist/modules/waf-gateway/waf-gateway.service.js +230 -0
- package/dist/modules/waf-gateway/waf-gateway.service.js.map +1 -0
- package/package.json +1 -1
- package/web/dist/assets/{AiLogsView-YNwXiYLj.js → AiLogsView-Dnk7hwQR.js} +1 -1
- package/web/dist/assets/CustomActionsView-DppAusC9.js +1 -0
- package/web/dist/assets/DevWorkflowView-BFRV0PSq.js +16 -0
- package/web/dist/assets/DevWorkflowView-m3rlqwHy.css +1 -0
- package/web/dist/assets/{GitChanges-aRQE_nKK.js → GitChanges-Ce91loC4.js} +1 -1
- package/web/dist/assets/{Layout-CjvPVc_q.js → Layout-CGd8ce9F.js} +1 -1
- package/web/dist/assets/{TasksView-BQeG7IlT.js → TasksView-BIVHfKfT.js} +1 -1
- package/web/dist/assets/{TerminalView-B6bgnhlc.js → TerminalView-MVCt-H7U.js} +1 -1
- package/web/dist/assets/{cssMode-MrcpzGyj.js → cssMode-b4McL4xZ.js} +1 -1
- package/web/dist/assets/{freemarker2-BmxDhO0V.js → freemarker2-DVKHC1DP.js} +1 -1
- package/web/dist/assets/{handlebars-gcG5qbcr.js → handlebars-BZJdpplH.js} +1 -1
- package/web/dist/assets/{html-DPniLrNg.js → html-BhdQsgMr.js} +1 -1
- package/web/dist/assets/{htmlMode-BoOnKRWM.js → htmlMode-DwBfibQy.js} +1 -1
- package/web/dist/assets/{index-ydlSv8Nj.css → index-2nC-4na6.css} +1 -1
- package/web/dist/assets/{index-gxvSC7oI.js → index-BR2hcxRn.js} +155 -155
- package/web/dist/assets/{javascript-DIh-4rjV.js → javascript-D1JSdfBe.js} +1 -1
- package/web/dist/assets/{jsonMode-DfQAhip9.js → jsonMode-BL6rI5IY.js} +1 -1
- package/web/dist/assets/{liquid-C9Ruy3XA.js → liquid-BJ_1CxIT.js} +1 -1
- package/web/dist/assets/{mdx-CSx8REuK.js → mdx-DF7vzSc0.js} +1 -1
- package/web/dist/assets/{python-CbBPpoMg.js → python-DxIO6p9P.js} +1 -1
- package/web/dist/assets/{razor-k1HEP5it.js → razor-IMF0jWc3.js} +1 -1
- package/web/dist/assets/{tsMode-ZPGfOmPP.js → tsMode-Dmcls-Gv.js} +1 -1
- package/web/dist/assets/{typescript-CPGMBX3f.js → typescript-Bi95U9ZL.js} +1 -1
- package/web/dist/assets/{xml-DpGT2I4w.js → xml-Vgp06Nxm.js} +1 -1
- package/web/dist/assets/{yaml-DyniUTVI.js → yaml-jEbIzjIx.js} +1 -1
- package/web/dist/index.html +2 -2
- package/doc/001.png +0 -0
- package/web/dist/assets/DevWorkflowView-DqtaAqQj.css +0 -1
- package/web/dist/assets/DevWorkflowView-lnG06gBv.js +0 -16
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
import * as os from 'os';
|
|
2
|
+
import * as path from 'path';
|
|
3
|
+
import * as fs from 'fs';
|
|
4
|
+
import { spawn } from 'child_process';
|
|
5
|
+
import { dbService } from '../db/db.service.js';
|
|
6
|
+
export class WafGatewayService {
|
|
7
|
+
constructor() {
|
|
8
|
+
this.clientProcess = null;
|
|
9
|
+
const homeDir = os.homedir();
|
|
10
|
+
this.clientDir = path.join(homeDir, '.txcode', 'waf_client');
|
|
11
|
+
this.pidFile = path.join(this.clientDir, 'waf_client.pid');
|
|
12
|
+
this.configFile = path.join(this.clientDir, 'tunnel_client.json');
|
|
13
|
+
this.ensureClientDir();
|
|
14
|
+
}
|
|
15
|
+
ensureClientDir() {
|
|
16
|
+
if (!fs.existsSync(this.clientDir)) {
|
|
17
|
+
fs.mkdirSync(this.clientDir, { recursive: true });
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
getConfig() {
|
|
21
|
+
return dbService.get('SELECT * FROM waf_gateway_config WHERE id = 1');
|
|
22
|
+
}
|
|
23
|
+
updateConfig(config) {
|
|
24
|
+
const now = new Date().toISOString();
|
|
25
|
+
const current = this.getConfig();
|
|
26
|
+
if (current) {
|
|
27
|
+
dbService.run(`UPDATE waf_gateway_config SET
|
|
28
|
+
secret_key = ?,
|
|
29
|
+
server_ip = ?,
|
|
30
|
+
updated_at = ?
|
|
31
|
+
WHERE id = 1`, [
|
|
32
|
+
config.secret_key ?? current.secret_key,
|
|
33
|
+
config.server_ip ?? current.server_ip,
|
|
34
|
+
now
|
|
35
|
+
]);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
updateStatus(status) {
|
|
39
|
+
const now = new Date().toISOString();
|
|
40
|
+
dbService.run(`UPDATE waf_gateway_config SET status = ?, updated_at = ? WHERE id = 1`, [status, now]);
|
|
41
|
+
}
|
|
42
|
+
getClientFileName() {
|
|
43
|
+
const platform = os.platform();
|
|
44
|
+
if (platform === 'win32') {
|
|
45
|
+
return 'waf_client.exe';
|
|
46
|
+
}
|
|
47
|
+
return 'waf_client';
|
|
48
|
+
}
|
|
49
|
+
getClientUrl() {
|
|
50
|
+
const platform = os.platform();
|
|
51
|
+
if (platform === 'win32') {
|
|
52
|
+
return 'https://homecommunity.oss-cn-beijing.aliyuncs.com/waf_client.exe';
|
|
53
|
+
}
|
|
54
|
+
return 'https://homecommunity.oss-cn-beijing.aliyuncs.com/waf_client';
|
|
55
|
+
}
|
|
56
|
+
async downloadClient() {
|
|
57
|
+
const clientFile = path.join(this.clientDir, this.getClientFileName());
|
|
58
|
+
if (fs.existsSync(clientFile)) {
|
|
59
|
+
return clientFile;
|
|
60
|
+
}
|
|
61
|
+
console.log(`Downloading WAF client from ${this.getClientUrl()}`);
|
|
62
|
+
return new Promise((resolve, reject) => {
|
|
63
|
+
const client = spawn('curl', ['-L', '-o', clientFile, this.getClientUrl()], {
|
|
64
|
+
stdio: 'pipe'
|
|
65
|
+
});
|
|
66
|
+
client.on('close', (code) => {
|
|
67
|
+
if (code === 0) {
|
|
68
|
+
if (os.platform() !== 'win32') {
|
|
69
|
+
fs.chmodSync(clientFile, 0o755);
|
|
70
|
+
}
|
|
71
|
+
console.log('WAF client downloaded successfully');
|
|
72
|
+
resolve(clientFile);
|
|
73
|
+
}
|
|
74
|
+
else {
|
|
75
|
+
reject(new Error(`Download failed with code ${code}`));
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
client.on('error', reject);
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
generateConfig() {
|
|
82
|
+
const config = this.getConfig();
|
|
83
|
+
if (!config) {
|
|
84
|
+
throw new Error('WAF gateway config not found');
|
|
85
|
+
}
|
|
86
|
+
const tunnelConfig = {
|
|
87
|
+
server_host: config.server_ip,
|
|
88
|
+
server_port: 5555,
|
|
89
|
+
register_secret: config.secret_key,
|
|
90
|
+
rsa_public_key: `-----BEGIN PUBLIC KEY-----
|
|
91
|
+
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAvmXlcvzBsEX5rhzQl2lo
|
|
92
|
+
usXBBtUpmnPykEf2MpRa4NmUOKZwjeVS2nmqwfUdgzVBuTfVXOF4paqnWh/DupMP
|
|
93
|
+
XzE8lWj72VPjoPFt8yO0+0baAOMCi6L6gwzOdzu/EF4cIN6Bh4V648zc+TqRg2o/
|
|
94
|
+
+UqUb6cRfIc2ftP0aT/CudSei/IYZxUuL55vckU9dlMb8D6OVllrg6m5YMnPj4W5
|
|
95
|
+
Gb5eQxMU5Yryux3/9vPwdmfiRmGteqNn/pLOQhgd6LxX+7bBUEb3y8sSyEwEN1eW
|
|
96
|
+
0SADkZXdofyQRsRrnmeJuk9bQUAeBBkbGOtUL/ROUbFckfsKLdzokPHpX8/+Pndh
|
|
97
|
+
RQIDAQAB
|
|
98
|
+
-----END PUBLIC KEY-----`
|
|
99
|
+
};
|
|
100
|
+
fs.writeFileSync(this.configFile, JSON.stringify(tunnelConfig, null, 2));
|
|
101
|
+
console.log(`Config file generated: ${this.configFile}`);
|
|
102
|
+
}
|
|
103
|
+
async start() {
|
|
104
|
+
const config = this.getConfig();
|
|
105
|
+
if (!config) {
|
|
106
|
+
throw new Error('WAF gateway config not found');
|
|
107
|
+
}
|
|
108
|
+
if (!config.server_ip || !config.secret_key) {
|
|
109
|
+
throw new Error('Server IP and secret key are required');
|
|
110
|
+
}
|
|
111
|
+
const isRunning = await this.isProcessRunning();
|
|
112
|
+
if (isRunning) {
|
|
113
|
+
console.log('WAF client is already running');
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
116
|
+
await this.downloadClient();
|
|
117
|
+
this.generateConfig();
|
|
118
|
+
const clientFile = path.join(this.clientDir, this.getClientFileName());
|
|
119
|
+
console.log(`Starting WAF client: ${clientFile}`);
|
|
120
|
+
return new Promise((resolve, reject) => {
|
|
121
|
+
if (os.platform() === 'win32') {
|
|
122
|
+
this.clientProcess = spawn('cmd', ['/c', 'start', '/b', '', clientFile], {
|
|
123
|
+
detached: true,
|
|
124
|
+
stdio: 'ignore',
|
|
125
|
+
shell: false,
|
|
126
|
+
cwd: this.clientDir
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
else {
|
|
130
|
+
this.clientProcess = spawn(clientFile, [], {
|
|
131
|
+
detached: true,
|
|
132
|
+
stdio: 'ignore',
|
|
133
|
+
cwd: this.clientDir
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
const pid = this.clientProcess.pid;
|
|
137
|
+
if (pid) {
|
|
138
|
+
fs.writeFileSync(this.pidFile, pid.toString());
|
|
139
|
+
}
|
|
140
|
+
this.clientProcess.on('error', (err) => {
|
|
141
|
+
console.error(`WAF client start error: ${err.message}`);
|
|
142
|
+
this.updateStatus('stopped');
|
|
143
|
+
reject(err);
|
|
144
|
+
});
|
|
145
|
+
this.clientProcess.on('exit', (code) => {
|
|
146
|
+
if (code !== 0 && code !== null) {
|
|
147
|
+
console.error(`WAF client exited with code ${code}`);
|
|
148
|
+
}
|
|
149
|
+
});
|
|
150
|
+
this.clientProcess.unref();
|
|
151
|
+
this.updateStatus('running');
|
|
152
|
+
console.log(`WAF client started with PID: ${pid}`);
|
|
153
|
+
resolve();
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
async stop() {
|
|
157
|
+
const isRunning = await this.isProcessRunning();
|
|
158
|
+
if (!isRunning && !fs.existsSync(this.pidFile)) {
|
|
159
|
+
this.updateStatus('stopped');
|
|
160
|
+
console.log('WAF client is not running');
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
163
|
+
if (os.platform() === 'win32') {
|
|
164
|
+
const exeName = this.getClientFileName();
|
|
165
|
+
spawn('powershell', [
|
|
166
|
+
'-WindowStyle', 'Hidden',
|
|
167
|
+
'-Command',
|
|
168
|
+
`Get-Process -Name "${exeName.replace('.exe', '')}" -ErrorAction SilentlyContinue | Stop-Process -Force`
|
|
169
|
+
], { stdio: 'ignore', shell: false });
|
|
170
|
+
console.log(`WAF client process ${exeName} terminated`);
|
|
171
|
+
}
|
|
172
|
+
else {
|
|
173
|
+
if (fs.existsSync(this.pidFile)) {
|
|
174
|
+
const pid = parseInt(fs.readFileSync(this.pidFile, 'utf-8').trim(), 10);
|
|
175
|
+
try {
|
|
176
|
+
process.kill(pid, 'SIGTERM');
|
|
177
|
+
console.log(`WAF client process ${pid} terminated`);
|
|
178
|
+
}
|
|
179
|
+
catch (err) {
|
|
180
|
+
console.error(`Failed to kill process ${pid}:`, err);
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
if (fs.existsSync(this.pidFile)) {
|
|
185
|
+
fs.unlinkSync(this.pidFile);
|
|
186
|
+
}
|
|
187
|
+
if (this.clientProcess) {
|
|
188
|
+
this.clientProcess.kill('SIGTERM');
|
|
189
|
+
this.clientProcess = null;
|
|
190
|
+
}
|
|
191
|
+
this.updateStatus('stopped');
|
|
192
|
+
console.log('WAF client stopped');
|
|
193
|
+
}
|
|
194
|
+
async isProcessRunning() {
|
|
195
|
+
if (!fs.existsSync(this.pidFile)) {
|
|
196
|
+
return false;
|
|
197
|
+
}
|
|
198
|
+
const pid = parseInt(fs.readFileSync(this.pidFile, 'utf-8').trim(), 10);
|
|
199
|
+
try {
|
|
200
|
+
if (os.platform() === 'win32') {
|
|
201
|
+
const result = spawn('tasklist', ['/FI', `PID eq ${pid}`], { stdio: 'pipe' });
|
|
202
|
+
return new Promise((resolve) => {
|
|
203
|
+
let output = '';
|
|
204
|
+
result.stdout?.on('data', (data) => {
|
|
205
|
+
output += data.toString();
|
|
206
|
+
});
|
|
207
|
+
result.on('close', () => {
|
|
208
|
+
resolve(output.includes(pid.toString()));
|
|
209
|
+
});
|
|
210
|
+
});
|
|
211
|
+
}
|
|
212
|
+
else {
|
|
213
|
+
process.kill(pid, 0);
|
|
214
|
+
return true;
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
catch {
|
|
218
|
+
return false;
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
getStatus() {
|
|
222
|
+
const config = this.getConfig();
|
|
223
|
+
return {
|
|
224
|
+
status: config?.status || 'stopped',
|
|
225
|
+
configured: Boolean(config?.server_ip && config?.secret_key),
|
|
226
|
+
};
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
export const wafGatewayService = new WafGatewayService();
|
|
230
|
+
//# sourceMappingURL=waf-gateway.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"waf-gateway.service.js","sourceRoot":"","sources":["../../../src/modules/waf-gateway/waf-gateway.service.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AACzB,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AACzB,OAAO,EAAE,KAAK,EAAgB,MAAM,eAAe,CAAC;AACpD,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAkBhD,MAAM,OAAO,iBAAiB;IAM5B;QALQ,kBAAa,GAAwB,IAAI,CAAC;QAMhD,MAAM,OAAO,GAAG,EAAE,CAAC,OAAO,EAAE,CAAC;QAC7B,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,SAAS,EAAE,YAAY,CAAC,CAAC;QAC7D,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,gBAAgB,CAAC,CAAC;QAC3D,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,oBAAoB,CAAC,CAAC;QAClE,IAAI,CAAC,eAAe,EAAE,CAAC;IACzB,CAAC;IAEO,eAAe;QACrB,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC;YACnC,EAAE,CAAC,SAAS,CAAC,IAAI,CAAC,SAAS,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;QACpD,CAAC;IACH,CAAC;IAED,SAAS;QACP,OAAO,SAAS,CAAC,GAAG,CAAmB,+CAA+C,CAAC,CAAC;IAC1F,CAAC;IAED,YAAY,CAAC,MAAmE;QAC9E,MAAM,GAAG,GAAG,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;QACrC,MAAM,OAAO,GAAG,IAAI,CAAC,SAAS,EAAE,CAAC;QAEjC,IAAI,OAAO,EAAE,CAAC;YACZ,SAAS,CAAC,GAAG,CACX;;;;qBAIa,EACb;gBACE,MAAM,CAAC,UAAU,IAAI,OAAO,CAAC,UAAU;gBACvC,MAAM,CAAC,SAAS,IAAI,OAAO,CAAC,SAAS;gBACrC,GAAG;aACJ,CACF,CAAC;QACJ,CAAC;IACH,CAAC;IAED,YAAY,CAAC,MAA6B;QACxC,MAAM,GAAG,GAAG,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;QACrC,SAAS,CAAC,GAAG,CACX,uEAAuE,EACvE,CAAC,MAAM,EAAE,GAAG,CAAC,CACd,CAAC;IACJ,CAAC;IAEO,iBAAiB;QACvB,MAAM,QAAQ,GAAG,EAAE,CAAC,QAAQ,EAAE,CAAC;QAC/B,IAAI,QAAQ,KAAK,OAAO,EAAE,CAAC;YACzB,OAAO,gBAAgB,CAAC;QAC1B,CAAC;QACD,OAAO,YAAY,CAAC;IACtB,CAAC;IAEO,YAAY;QAClB,MAAM,QAAQ,GAAG,EAAE,CAAC,QAAQ,EAAE,CAAC;QAC/B,IAAI,QAAQ,KAAK,OAAO,EAAE,CAAC;YACzB,OAAO,kEAAkE,CAAC;QAC5E,CAAC;QACD,OAAO,8DAA8D,CAAC;IACxE,CAAC;IAEO,KAAK,CAAC,cAAc;QAC1B,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,iBAAiB,EAAE,CAAC,CAAC;QAEvE,IAAI,EAAE,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,CAAC;YAC9B,OAAO,UAAU,CAAC;QACpB,CAAC;QAED,OAAO,CAAC,GAAG,CAAC,+BAA+B,IAAI,CAAC,YAAY,EAAE,EAAE,CAAC,CAAC;QAElE,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YACrC,MAAM,MAAM,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,CAAC,YAAY,EAAE,CAAC,EAAE;gBAC1E,KAAK,EAAE,MAAM;aACd,CAAC,CAAC;YAEH,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,IAAI,EAAE,EAAE;gBAC1B,IAAI,IAAI,KAAK,CAAC,EAAE,CAAC;oBACf,IAAI,EAAE,CAAC,QAAQ,EAAE,KAAK,OAAO,EAAE,CAAC;wBAC9B,EAAE,CAAC,SAAS,CAAC,UAAU,EAAE,KAAK,CAAC,CAAC;oBAClC,CAAC;oBACD,OAAO,CAAC,GAAG,CAAC,oCAAoC,CAAC,CAAC;oBAClD,OAAO,CAAC,UAAU,CAAC,CAAC;gBACtB,CAAC;qBAAM,CAAC;oBACN,MAAM,CAAC,IAAI,KAAK,CAAC,6BAA6B,IAAI,EAAE,CAAC,CAAC,CAAC;gBACzD,CAAC;YACH,CAAC,CAAC,CAAC;YAEH,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;QAC7B,CAAC,CAAC,CAAC;IACL,CAAC;IAEO,cAAc;QACpB,MAAM,MAAM,GAAG,IAAI,CAAC,SAAS,EAAE,CAAC;QAChC,IAAI,CAAC,MAAM,EAAE,CAAC;YACZ,MAAM,IAAI,KAAK,CAAC,8BAA8B,CAAC,CAAC;QAClD,CAAC;QAED,MAAM,YAAY,GAAuB;YACvC,WAAW,EAAE,MAAM,CAAC,SAAS;YAC7B,WAAW,EAAE,IAAI;YACjB,eAAe,EAAE,MAAM,CAAC,UAAU;YAClC,cAAc,EAAE;;;;;;;;yBAQG;SACpB,CAAC;QAEF,EAAE,CAAC,aAAa,CAAC,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,SAAS,CAAC,YAAY,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;QACzE,OAAO,CAAC,GAAG,CAAC,0BAA0B,IAAI,CAAC,UAAU,EAAE,CAAC,CAAC;IAC3D,CAAC;IAED,KAAK,CAAC,KAAK;QACT,MAAM,MAAM,GAAG,IAAI,CAAC,SAAS,EAAE,CAAC;QAChC,IAAI,CAAC,MAAM,EAAE,CAAC;YACZ,MAAM,IAAI,KAAK,CAAC,8BAA8B,CAAC,CAAC;QAClD,CAAC;QAED,IAAI,CAAC,MAAM,CAAC,SAAS,IAAI,CAAC,MAAM,CAAC,UAAU,EAAE,CAAC;YAC5C,MAAM,IAAI,KAAK,CAAC,uCAAuC,CAAC,CAAC;QAC3D,CAAC;QAED,MAAM,SAAS,GAAG,MAAM,IAAI,CAAC,gBAAgB,EAAE,CAAC;QAChD,IAAI,SAAS,EAAE,CAAC;YACd,OAAO,CAAC,GAAG,CAAC,+BAA+B,CAAC,CAAC;YAC7C,OAAO;QACT,CAAC;QAED,MAAM,IAAI,CAAC,cAAc,EAAE,CAAC;QAC5B,IAAI,CAAC,cAAc,EAAE,CAAC;QAEtB,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,iBAAiB,EAAE,CAAC,CAAC;QAEvE,OAAO,CAAC,GAAG,CAAC,wBAAwB,UAAU,EAAE,CAAC,CAAC;QAElD,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YACrC,IAAI,EAAE,CAAC,QAAQ,EAAE,KAAK,OAAO,EAAE,CAAC;gBAC9B,IAAI,CAAC,aAAa,GAAG,KAAK,CAAC,KAAK,EAAE,CAAC,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,EAAE,UAAU,CAAC,EAAE;oBACvE,QAAQ,EAAE,IAAI;oBACd,KAAK,EAAE,QAAQ;oBACf,KAAK,EAAE,KAAK;oBACZ,GAAG,EAAE,IAAI,CAAC,SAAS;iBACpB,CAAC,CAAC;YACL,CAAC;iBAAM,CAAC;gBACN,IAAI,CAAC,aAAa,GAAG,KAAK,CAAC,UAAU,EAAE,EAAE,EAAE;oBACzC,QAAQ,EAAE,IAAI;oBACd,KAAK,EAAE,QAAQ;oBACf,GAAG,EAAE,IAAI,CAAC,SAAS;iBACpB,CAAC,CAAC;YACL,CAAC;YAED,MAAM,GAAG,GAAG,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC;YACnC,IAAI,GAAG,EAAE,CAAC;gBACR,EAAE,CAAC,aAAa,CAAC,IAAI,CAAC,OAAO,EAAE,GAAG,CAAC,QAAQ,EAAE,CAAC,CAAC;YACjD,CAAC;YAED,IAAI,CAAC,aAAa,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,GAAG,EAAE,EAAE;gBACrC,OAAO,CAAC,KAAK,CAAC,2BAA2B,GAAG,CAAC,OAAO,EAAE,CAAC,CAAC;gBACxD,IAAI,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC;gBAC7B,MAAM,CAAC,GAAG,CAAC,CAAC;YACd,CAAC,CAAC,CAAC;YAEH,IAAI,CAAC,aAAa,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,EAAE;gBACrC,IAAI,IAAI,KAAK,CAAC,IAAI,IAAI,KAAK,IAAI,EAAE,CAAC;oBAChC,OAAO,CAAC,KAAK,CAAC,+BAA+B,IAAI,EAAE,CAAC,CAAC;gBACvD,CAAC;YACH,CAAC,CAAC,CAAC;YAEH,IAAI,CAAC,aAAa,CAAC,KAAK,EAAE,CAAC;YAC3B,IAAI,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC;YAC7B,OAAO,CAAC,GAAG,CAAC,gCAAgC,GAAG,EAAE,CAAC,CAAC;YACnD,OAAO,EAAE,CAAC;QACZ,CAAC,CAAC,CAAC;IACL,CAAC;IAED,KAAK,CAAC,IAAI;QACR,MAAM,SAAS,GAAG,MAAM,IAAI,CAAC,gBAAgB,EAAE,CAAC;QAChD,IAAI,CAAC,SAAS,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC;YAC/C,IAAI,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC;YAC7B,OAAO,CAAC,GAAG,CAAC,2BAA2B,CAAC,CAAC;YACzC,OAAO;QACT,CAAC;QAED,IAAI,EAAE,CAAC,QAAQ,EAAE,KAAK,OAAO,EAAE,CAAC;YAC9B,MAAM,OAAO,GAAG,IAAI,CAAC,iBAAiB,EAAE,CAAC;YACzC,KAAK,CAAC,YAAY,EAAE;gBAClB,cAAc,EAAE,QAAQ;gBACxB,UAAU;gBACV,sBAAsB,OAAO,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,uDAAuD;aACzG,EAAE,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAC;YACtC,OAAO,CAAC,GAAG,CAAC,sBAAsB,OAAO,aAAa,CAAC,CAAC;QAC1D,CAAC;aAAM,CAAC;YACN,IAAI,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC;gBAChC,MAAM,GAAG,GAAG,QAAQ,CAAC,EAAE,CAAC,YAAY,CAAC,IAAI,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE,EAAE,CAAC,CAAC;gBACxE,IAAI,CAAC;oBACH,OAAO,CAAC,IAAI,CAAC,GAAG,EAAE,SAAS,CAAC,CAAC;oBAC7B,OAAO,CAAC,GAAG,CAAC,sBAAsB,GAAG,aAAa,CAAC,CAAC;gBACtD,CAAC;gBAAC,OAAO,GAAG,EAAE,CAAC;oBACb,OAAO,CAAC,KAAK,CAAC,0BAA0B,GAAG,GAAG,EAAE,GAAG,CAAC,CAAC;gBACvD,CAAC;YACH,CAAC;QACH,CAAC;QAED,IAAI,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC;YAChC,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAC9B,CAAC;QAED,IAAI,IAAI,CAAC,aAAa,EAAE,CAAC;YACvB,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;YACnC,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC;QAC5B,CAAC;QAED,IAAI,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC;QAC7B,OAAO,CAAC,GAAG,CAAC,oBAAoB,CAAC,CAAC;IACpC,CAAC;IAED,KAAK,CAAC,gBAAgB;QACpB,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC;YACjC,OAAO,KAAK,CAAC;QACf,CAAC;QAED,MAAM,GAAG,GAAG,QAAQ,CAAC,EAAE,CAAC,YAAY,CAAC,IAAI,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE,EAAE,CAAC,CAAC;QAExE,IAAI,CAAC;YACH,IAAI,EAAE,CAAC,QAAQ,EAAE,KAAK,OAAO,EAAE,CAAC;gBAC9B,MAAM,MAAM,GAAG,KAAK,CAAC,UAAU,EAAE,CAAC,KAAK,EAAE,UAAU,GAAG,EAAE,CAAC,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC,CAAC;gBAC9E,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;oBAC7B,IAAI,MAAM,GAAG,EAAE,CAAC;oBAChB,MAAM,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,EAAE;wBACjC,MAAM,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;oBAC5B,CAAC,CAAC,CAAC;oBACH,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,GAAG,EAAE;wBACtB,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC;oBAC3C,CAAC,CAAC,CAAC;gBACL,CAAC,CAAC,CAAC;YACL,CAAC;iBAAM,CAAC;gBACN,OAAO,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC;gBACrB,OAAO,IAAI,CAAC;YACd,CAAC;QACH,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,KAAK,CAAC;QACf,CAAC;IACH,CAAC;IAED,SAAS;QACP,MAAM,MAAM,GAAG,IAAI,CAAC,SAAS,EAAE,CAAC;QAChC,OAAO;YACL,MAAM,EAAE,MAAM,EAAE,MAA+B,IAAI,SAAS;YAC5D,UAAU,EAAE,OAAO,CAAC,MAAM,EAAE,SAAS,IAAI,MAAM,EAAE,UAAU,CAAC;SAC7D,CAAC;IACJ,CAAC;CACF;AAED,MAAM,CAAC,MAAM,iBAAiB,GAAG,IAAI,iBAAiB,EAAE,CAAC"}
|
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{n as x,a as n}from"./index-
|
|
1
|
+
import{n as x,a as n}from"./index-BR2hcxRn.js";const c=[{key:"ai_call_logs",name:"AI 日志",icon:"fa-solid fa-robot text-xs"}],p={name:"AiLogsView",data(){return{logTypes:c,selectedLogType:c[0],logs:[],page:1,pageSize:20,total:0,totalPages:1,sessions:[],loading:!1,filters:{callType:"",sessionId:"",startTime:"",endTime:""}}},async created(){await this.loadSessions(),await this.loadLogs()},methods:{async loadSessions(){try{const s=await n.getSessions(100,0);this.sessions=s.data||[]}catch(s){console.error("Load sessions failed:",s)}},selectLogType(s){this.selectedLogType=s,this.resetFilters()},async loadLogs(){this.loading=!0;try{const s=await n.getAiCallLogs(this.page,this.pageSize);let t=s.data.rows||[];if(this.filters.callType&&(t=t.filter(e=>e.call_type===this.filters.callType)),this.filters.sessionId&&(t=t.filter(e=>e.session_id&&e.session_id.includes(this.filters.sessionId))),this.filters.startTime){const e=new Date(this.filters.startTime).getTime();t=t.filter(l=>new Date(l.request_time).getTime()>=e)}if(this.filters.endTime){const e=new Date(this.filters.endTime).getTime();t=t.filter(l=>new Date(l.request_time).getTime()<=e)}this.logs=t,this.total=s.data.total,this.totalPages=s.data.totalPages}catch(s){console.error("Load logs failed:",s),this.logs=[]}finally{this.loading=!1}},resetFilters(){this.filters.callType="",this.filters.sessionId="",this.filters.startTime="",this.filters.endTime="",this.page=1,this.loadLogs()},async prevPage(){this.page>1&&(this.page--,await this.loadLogs())},async nextPage(){this.page<this.totalPages&&(this.page++,await this.loadLogs())},formatTime(s){return s?new Date(s).toLocaleString("zh-CN"):"-"},getSessionTitle(s){if(!s)return"-";const t=this.sessions.find(e=>e.id===s);return t?t.title:s.substring(0,8)},formatDuration(s){return s?s<1e3?`${s}ms`:`${(s/1e3).toFixed(2)}s`:"0ms"}}};var b=function(){var l,d;var t=this,e=t._self._c;return e("div",{staticClass:"flex-1 flex overflow-hidden"},[e("aside",{staticClass:"w-[260px] bg-sidebar border-r border-border flex flex-col shrink-0"},[t._m(0),e("div",{staticClass:"flex-1 overflow-y-auto py-1"},t._l(t.logTypes,function(a){var i;return e("div",{key:a.key,staticClass:"flex items-center gap-2 px-3 py-1.5 cursor-pointer text-sm",class:((i=t.selectedLogType)==null?void 0:i.key)===a.key?"bg-active text-white border-l-2 border-accent":"text-textMuted hover:text-white hover:bg-white/5 border-l-2 border-transparent",on:{click:function(r){return t.selectLogType(a)}}},[e("i",{class:a.icon}),e("span",{staticClass:"truncate"},[t._v(t._s(a.name))])])}),0)]),e("main",{staticClass:"flex-1 flex flex-col min-w-0 bg-[#1e1e1e]"},[e("div",{staticClass:"px-4 py-3 border-b border-border bg-sidebar"},[e("div",{staticClass:"flex items-center gap-4 mb-3"},[e("div",{staticClass:"flex items-center gap-2"},[e("i",{class:(l=t.selectedLogType)==null?void 0:l.icon}),e("span",{staticClass:"text-white font-medium"},[t._v(t._s((d=t.selectedLogType)==null?void 0:d.name))])]),e("span",{staticClass:"text-xs text-textMuted"},[t._v(t._s(t.total)+" 条记录")])]),e("div",{staticClass:"flex items-center gap-4 flex-wrap"},[e("div",{staticClass:"flex items-center gap-2"},[e("label",{staticClass:"text-xs text-textMuted"},[t._v("调用类型:")]),e("select",{directives:[{name:"model",rawName:"v-model",value:t.filters.callType,expression:"filters.callType"}],staticClass:"bg-black/20 border border-white/10 text-white text-xs px-2 py-1 rounded",on:{change:[function(a){var i=Array.prototype.filter.call(a.target.options,function(r){return r.selected}).map(function(r){var o="_value"in r?r._value:r.value;return o});t.$set(t.filters,"callType",a.target.multiple?i:i[0])},t.loadLogs]}},[e("option",{attrs:{value:""}},[t._v("全部")]),e("option",{attrs:{value:"tool_call"}},[t._v("工具调用")]),e("option",{attrs:{value:"normal"}},[t._v("普通对话")])])]),e("div",{staticClass:"flex items-center gap-2"},[e("label",{staticClass:"text-xs text-textMuted"},[t._v("会话:")]),e("select",{directives:[{name:"model",rawName:"v-model",value:t.filters.sessionId,expression:"filters.sessionId"}],staticClass:"bg-black/20 border border-white/10 text-white text-xs px-2 py-1 rounded",on:{change:[function(a){var i=Array.prototype.filter.call(a.target.options,function(r){return r.selected}).map(function(r){var o="_value"in r?r._value:r.value;return o});t.$set(t.filters,"sessionId",a.target.multiple?i:i[0])},t.loadLogs]}},[e("option",{attrs:{value:""}},[t._v("全部会话")]),t._l(t.sessions,function(a){return e("option",{key:a.id,domProps:{value:a.id}},[t._v(t._s(a.title))])})],2)]),e("div",{staticClass:"flex items-center gap-2"},[e("label",{staticClass:"text-xs text-textMuted"},[t._v("开始时间:")]),e("input",{directives:[{name:"model",rawName:"v-model",value:t.filters.startTime,expression:"filters.startTime"}],staticClass:"bg-black/20 border border-white/10 text-white text-xs px-2 py-1 rounded",attrs:{type:"datetime-local"},domProps:{value:t.filters.startTime},on:{change:t.loadLogs,input:function(a){a.target.composing||t.$set(t.filters,"startTime",a.target.value)}}})]),e("div",{staticClass:"flex items-center gap-2"},[e("label",{staticClass:"text-xs text-textMuted"},[t._v("结束时间:")]),e("input",{directives:[{name:"model",rawName:"v-model",value:t.filters.endTime,expression:"filters.endTime"}],staticClass:"bg-black/20 border border-white/10 text-white text-xs px-2 py-1 rounded",attrs:{type:"datetime-local"},domProps:{value:t.filters.endTime},on:{change:t.loadLogs,input:function(a){a.target.composing||t.$set(t.filters,"endTime",a.target.value)}}})]),e("button",{staticClass:"px-3 py-1 bg-accent text-white text-xs rounded hover:bg-accent/80",on:{click:t.loadLogs}},[t._v(" 查询 ")]),e("button",{staticClass:"px-3 py-1 text-textMuted text-xs rounded hover:bg-white/10",on:{click:t.resetFilters}},[t._v(" 重置 ")])])]),e("div",{staticClass:"flex-1 overflow-auto p-4"},[e("table",{staticClass:"w-full text-sm"},[t._m(1),e("tbody",[t._l(t.logs,function(a){return e("tr",{key:a.id,staticClass:"hover:bg-white/5"},[e("td",{staticClass:"px-3 py-2 text-gray-300 border-b border-border/30"},[t._v(t._s(a.id))]),e("td",{staticClass:"px-3 py-2 text-gray-300 border-b border-border/30"},[t._v(t._s(t.formatTime(a.request_time)))]),e("td",{staticClass:"px-3 py-2 border-b border-border/30"},[e("span",{staticClass:"text-xs px-2 py-0.5 rounded",class:a.call_type==="tool_call"?"bg-blue-500/20 text-blue-400":"bg-green-500/20 text-green-400"},[t._v(" "+t._s(a.call_type==="tool_call"?"工具调用":"普通对话")+" ")])]),e("td",{staticClass:"px-3 py-2 text-gray-300 border-b border-border/30"},[t._v(t._s(a.model_name))]),e("td",{staticClass:"px-3 py-2 text-gray-300 border-b border-border/30"},[t._v(t._s(t.formatDuration(a.duration_ms)))]),e("td",{staticClass:"px-3 py-2 text-gray-300 border-b border-border/30"},[t._v(t._s(a.input_tokens||0))]),e("td",{staticClass:"px-3 py-2 text-gray-300 border-b border-border/30"},[t._v(t._s(a.output_tokens||0))]),e("td",{staticClass:"px-3 py-2 text-gray-300 border-b border-border/30"},[t._v("$"+t._s((a.cost||0).toFixed(4)))]),e("td",{staticClass:"px-3 py-2 text-gray-300 border-b border-border/30 truncate max-w-[150px]",attrs:{title:a.session_id}},[t._v(t._s(t.getSessionTitle(a.session_id)))])])}),t.logs.length===0?e("tr",[e("td",{staticClass:"px-3 py-8 text-center text-textMuted",attrs:{colspan:"9"}},[t._v("暂无数据")])]):t._e()],2)])]),e("div",{staticClass:"flex items-center justify-between px-4 py-2 border-t border-border bg-sidebar"},[e("span",{staticClass:"text-xs text-textMuted"},[t._v("共 "+t._s(t.total)+" 条")]),e("div",{staticClass:"flex items-center gap-2"},[e("button",{staticClass:"px-2 py-1 text-xs text-textMuted hover:text-white disabled:opacity-30 disabled:cursor-not-allowed",attrs:{disabled:t.page<=1},on:{click:t.prevPage}},[e("i",{staticClass:"fa-solid fa-chevron-left"}),t._v(" 上一页 ")]),e("span",{staticClass:"text-xs text-textMuted"},[t._v(t._s(t.page)+" / "+t._s(t.totalPages||1))]),e("button",{staticClass:"px-2 py-1 text-xs text-textMuted hover:text-white disabled:opacity-30 disabled:cursor-not-allowed",attrs:{disabled:t.page>=t.totalPages},on:{click:t.nextPage}},[t._v(" 下一页 "),e("i",{staticClass:"fa-solid fa-chevron-right"})])])])])])},f=[function(){var s=this,t=s._self._c;return t("div",{staticClass:"flex border-b border-border text-xs uppercase font-bold text-textMuted"},[t("div",{staticClass:"px-4 py-2 border-b-2 border-accent text-white flex items-center gap-2"},[t("i",{staticClass:"fa-solid fa-list"}),s._v(" 日志 ")])])},function(){var s=this,t=s._self._c;return t("thead",{staticClass:"bg-sidebar sticky top-0"},[t("tr",[t("th",{staticClass:"px-3 py-2 text-left text-xs font-bold text-textMuted uppercase border-b border-border"},[s._v("ID")]),t("th",{staticClass:"px-3 py-2 text-left text-xs font-bold text-textMuted uppercase border-b border-border"},[s._v("时间")]),t("th",{staticClass:"px-3 py-2 text-left text-xs font-bold text-textMuted uppercase border-b border-border"},[s._v("类型")]),t("th",{staticClass:"px-3 py-2 text-left text-xs font-bold text-textMuted uppercase border-b border-border"},[s._v("模型")]),t("th",{staticClass:"px-3 py-2 text-left text-xs font-bold text-textMuted uppercase border-b border-border"},[s._v("耗时")]),t("th",{staticClass:"px-3 py-2 text-left text-xs font-bold text-textMuted uppercase border-b border-border"},[s._v("输入Token")]),t("th",{staticClass:"px-3 py-2 text-left text-xs font-bold text-textMuted uppercase border-b border-border"},[s._v("输出Token")]),t("th",{staticClass:"px-3 py-2 text-left text-xs font-bold text-textMuted uppercase border-b border-border"},[s._v("费用")]),t("th",{staticClass:"px-3 py-2 text-left text-xs font-bold text-textMuted uppercase border-b border-border"},[s._v("会话ID")])])])}],u=x(p,b,f,!1,null,null);const _=u.exports;export{_ as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{n as d,a as n}from"./index-BR2hcxRn.js";const u={name:"CustomActionsView",data(){return{actions:[],currentType:"design",showDialog:!1,isEditing:!1,currentAction:null,form:{action_type:"design",name:"",prompt:"",auto_send:!1,sort_order:0},actionTypes:[{value:"design",label:"方案设计"},{value:"code",label:"代码生成"},{value:"test",label:"测试验收"}]}},computed:{filteredActions(){return this.actions.filter(s=>s.action_type===this.currentType)}},async created(){await this.loadActions();const s=this.$route.query.type;s&&["design","code","test"].includes(s)&&(this.currentType=s)},methods:{async loadActions(){try{const s=await n.getCustomActions();this.actions=s.data||[]}catch(s){console.error("Load actions failed:",s),this.$message.error("加载动作失败")}},selectType(s){this.currentType=s},getCountByType(s){return this.actions.filter(t=>t.action_type===s).length},openCreateDialog(){this.isEditing=!1,this.form={action_type:this.currentType,name:"",prompt:"",auto_send:!1,sort_order:0},this.showDialog=!0},openEditDialog(s){this.isEditing=!0,this.currentAction=s,this.form={action_type:s.action_type,name:s.name,prompt:s.prompt,auto_send:!!s.auto_send,sort_order:s.sort_order||0},this.showDialog=!0},closeDialog(){this.showDialog=!1,this.currentAction=null},async saveAction(){if(!this.form.name||!this.form.prompt){this.$message.error("请填写必填项");return}try{this.isEditing&&this.currentAction?(await n.updateCustomAction(this.currentAction.id,this.form),this.$message.success("动作已更新")):(await n.createCustomAction(this.form),this.$message.success("动作已创建")),this.closeDialog(),await this.loadActions()}catch(s){this.$message.error("保存失败: "+s.message)}},async deleteAction(s){if(confirm(`确定删除动作 "${s.name}" 吗?`))try{await n.deleteCustomAction(s.id),this.$message.success("动作已删除"),await this.loadActions()}catch(t){this.$message.error("删除失败: "+t.message)}},getTypeLabel(s){return{design:"方案设计",code:"代码生成",test:"测试验收"}[s]||s}}};var p=function(){var t=this,e=t._self._c;return e("div",{staticClass:"flex-1 flex overflow-hidden bg-[#1e1e1e]"},[e("div",{staticClass:"w-48 border-r border-border bg-sidebar shrink-0 flex flex-col"},[t._m(0),e("div",{staticClass:"flex-1 overflow-auto py-2"},t._l(t.actionTypes,function(r){return e("div",{key:r.value,staticClass:"px-4 py-2 cursor-pointer flex items-center justify-between",class:t.currentType===r.value?"bg-accent/20 text-accent":"text-textMuted hover:bg-white/5",on:{click:function(a){return t.selectType(r.value)}}},[e("span",{staticClass:"text-sm"},[t._v(t._s(r.label))]),e("span",{staticClass:"text-xs opacity-60"},[t._v("("+t._s(t.getCountByType(r.value))+")")])])}),0)]),e("div",{staticClass:"flex-1 flex flex-col overflow-hidden"},[e("div",{staticClass:"px-4 py-3 border-b border-border bg-sidebar shrink-0"},[e("div",{staticClass:"flex items-center justify-between"},[e("div",{staticClass:"flex items-center gap-2"},[e("i",{staticClass:"fa-solid fa-bolt text-accent"}),e("span",{staticClass:"text-white font-medium"},[t._v("自定义动作")]),e("span",{staticClass:"text-xs text-textMuted"},[t._v("("+t._s(t.getTypeLabel(t.currentType))+")")]),e("span",{staticClass:"text-xs text-textMuted"},[t._v(t._s(t.filteredActions.length)+" 个动作")])]),e("button",{staticClass:"px-3 py-1 bg-accent text-white text-xs rounded hover:bg-accent/80",on:{click:t.openCreateDialog}},[e("i",{staticClass:"fa-solid fa-plus mr-1"}),t._v(" 新增动作 ")])])]),e("div",{staticClass:"flex-1 overflow-auto p-4"},[e("table",{staticClass:"w-full text-sm"},[t._m(1),e("tbody",[t._l(t.filteredActions,function(r){return e("tr",{key:r.id,staticClass:"hover:bg-white/5"},[e("td",{staticClass:"px-3 py-2 border-b border-border/30 text-gray-200"},[t._v(t._s(r.name))]),e("td",{staticClass:"px-3 py-2 border-b border-border/30 text-gray-300 max-w-[300px] truncate",attrs:{title:r.prompt}},[t._v(t._s(r.prompt))]),e("td",{staticClass:"px-3 py-2 border-b border-border/30"},[r.auto_send?e("span",{staticClass:"text-xs px-2 py-0.5 rounded bg-green-500/20 text-green-400"},[t._v("是")]):e("span",{staticClass:"text-xs px-2 py-0.5 rounded bg-gray-500/20 text-gray-400"},[t._v("否")])]),e("td",{staticClass:"px-3 py-2 border-b border-border/30 text-gray-300"},[t._v(t._s(r.sort_order))]),e("td",{staticClass:"px-3 py-2 border-b border-border/30"},[e("div",{staticClass:"flex items-center gap-2"},[e("button",{staticClass:"text-xs px-2 py-1 text-blue-400 hover:bg-blue-500/20 rounded",on:{click:function(a){return t.openEditDialog(r)}}},[t._v("编辑")]),e("button",{staticClass:"text-xs px-2 py-1 text-red-400 hover:bg-red-500/20 rounded",on:{click:function(a){return t.deleteAction(r)}}},[t._v("删除")])])])])}),t.filteredActions.length===0?e("tr",[e("td",{staticClass:"px-3 py-8 text-center text-textMuted",attrs:{colspan:"5"}},[t._v('暂无动作,点击"新增动作"创建')])]):t._e()],2)])])]),t.showDialog?e("div",{staticClass:"fixed inset-0 bg-black/50 flex items-center justify-center z-50"},[e("div",{staticClass:"bg-sidebar border border-border rounded-lg w-[500px] max-h-[80vh] overflow-auto"},[e("div",{staticClass:"px-4 py-3 border-b border-border flex items-center justify-between"},[e("h3",{staticClass:"text-white font-medium"},[t._v(t._s(t.isEditing?"编辑动作":"新增动作"))]),e("button",{staticClass:"text-textMuted hover:text-white text-sm",on:{click:t.closeDialog}},[t._v("关闭")])]),e("div",{staticClass:"p-4 space-y-4"},[e("div",[t._m(2),e("select",{directives:[{name:"model",rawName:"v-model",value:t.form.action_type,expression:"form.action_type"}],staticClass:"w-full bg-black/20 border border-white/10 text-white text-sm px-3 py-2 rounded",attrs:{disabled:t.isEditing},on:{change:function(r){var a=Array.prototype.filter.call(r.target.options,function(o){return o.selected}).map(function(o){var l="_value"in o?o._value:o.value;return l});t.$set(t.form,"action_type",r.target.multiple?a:a[0])}}},[e("option",{attrs:{value:"design"}},[t._v("方案设计")]),e("option",{attrs:{value:"code"}},[t._v("代码生成")]),e("option",{attrs:{value:"test"}},[t._v("测试验收")])])]),e("div",[t._m(3),e("input",{directives:[{name:"model",rawName:"v-model",value:t.form.name,expression:"form.name"}],staticClass:"w-full bg-black/20 border border-white/10 text-white text-sm px-3 py-2 rounded",attrs:{type:"text",placeholder:"按钮显示名称"},domProps:{value:t.form.name},on:{input:function(r){r.target.composing||t.$set(t.form,"name",r.target.value)}}})]),e("div",[t._m(4),e("textarea",{directives:[{name:"model",rawName:"v-model",value:t.form.prompt,expression:"form.prompt"}],staticClass:"w-full bg-black/20 border border-white/10 text-white text-sm px-3 py-2 rounded resize-none",attrs:{rows:"4",placeholder:"点击按钮后填入输入框的内容"},domProps:{value:t.form.prompt},on:{input:function(r){r.target.composing||t.$set(t.form,"prompt",r.target.value)}}})]),e("div",[e("label",{staticClass:"block text-xs text-textMuted mb-1"},[t._v("排序")]),e("input",{directives:[{name:"model",rawName:"v-model.number",value:t.form.sort_order,expression:"form.sort_order",modifiers:{number:!0}}],staticClass:"w-full bg-black/20 border border-white/10 text-white text-sm px-3 py-2 rounded",attrs:{type:"number",placeholder:"数字越小越靠前"},domProps:{value:t.form.sort_order},on:{input:function(r){r.target.composing||t.$set(t.form,"sort_order",t._n(r.target.value))},blur:function(r){return t.$forceUpdate()}}})]),e("div",{staticClass:"flex items-center gap-2"},[e("input",{directives:[{name:"model",rawName:"v-model",value:t.form.auto_send,expression:"form.auto_send"}],staticClass:"accent-accent",attrs:{type:"checkbox",id:"autoSend"},domProps:{checked:Array.isArray(t.form.auto_send)?t._i(t.form.auto_send,null)>-1:t.form.auto_send},on:{change:function(r){var a=t.form.auto_send,o=r.target,l=!!o.checked;if(Array.isArray(a)){var c=null,i=t._i(a,c);o.checked?i<0&&t.$set(t.form,"auto_send",a.concat([c])):i>-1&&t.$set(t.form,"auto_send",a.slice(0,i).concat(a.slice(i+1)))}else t.$set(t.form,"auto_send",l)}}}),e("label",{staticClass:"text-xs text-textMuted",attrs:{for:"autoSend"}},[t._v("点击后自动发送(无需手动确认)")])])]),e("div",{staticClass:"px-4 py-3 border-t border-border flex justify-end gap-2"},[e("button",{staticClass:"px-4 py-1 text-textMuted text-sm rounded hover:bg-white/10",on:{click:t.closeDialog}},[t._v("取消")]),e("button",{staticClass:"px-4 py-1 bg-accent text-white text-sm rounded hover:bg-accent/80",on:{click:t.saveAction}},[t._v(" "+t._s(t.isEditing?"保存":"创建")+" ")])])])]):t._e()])},x=[function(){var s=this,t=s._self._c;return t("div",{staticClass:"px-4 py-3 border-b border-border"},[t("span",{staticClass:"text-white text-sm font-medium"},[s._v("类型")])])},function(){var s=this,t=s._self._c;return t("thead",{staticClass:"bg-sidebar sticky top-0"},[t("tr",[t("th",{staticClass:"px-3 py-2 text-left text-xs font-bold text-textMuted uppercase border-b border-border"},[s._v("名称")]),t("th",{staticClass:"px-3 py-2 text-left text-xs font-bold text-textMuted uppercase border-b border-border"},[s._v("提示词")]),t("th",{staticClass:"px-3 py-2 text-left text-xs font-bold text-textMuted uppercase border-b border-border"},[s._v("自动发送")]),t("th",{staticClass:"px-3 py-2 text-left text-xs font-bold text-textMuted uppercase border-b border-border"},[s._v("排序")]),t("th",{staticClass:"px-3 py-2 text-left text-xs font-bold text-textMuted uppercase border-b border-border"},[s._v("操作")])])])},function(){var s=this,t=s._self._c;return t("label",{staticClass:"block text-xs text-textMuted mb-1"},[s._v("类型 "),t("span",{staticClass:"text-red-400"},[s._v("*")])])},function(){var s=this,t=s._self._c;return t("label",{staticClass:"block text-xs text-textMuted mb-1"},[s._v("名称 "),t("span",{staticClass:"text-red-400"},[s._v("*")])])},function(){var s=this,t=s._self._c;return t("label",{staticClass:"block text-xs text-textMuted mb-1"},[s._v("提示词 "),t("span",{staticClass:"text-red-400"},[s._v("*")])])}],m=d(u,p,x,!1,null,null);const f=m.exports;export{f as default};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import{n as c,F as d,C as u,M as h,a as o,g as p,e as C,K as _,b as v}from"./index-BR2hcxRn.js";const b={name:"WorkflowSidebar",props:{categories:{type:Array,default:()=>[]},projects:{type:Object,default:()=>{}},currentCategory:{type:String,default:""},currentProject:{type:String,default:""},currentStep:{type:Number,default:1},isLoading:{type:Boolean,default:!1}},data(){return{selectedCategory:"",selectedProject:"",steps:[{id:1,title:"新建需求",desc:"创建新的需求项目",icon:"el-icon-folder-add"},{id:2,title:"方案设计",desc:"编写需求方案",icon:"el-icon-edit"},{id:3,title:"代码生成",desc:"根据方案生成代码",icon:"el-icon-document"},{id:4,title:"测试验收",desc:"测试验证功能",icon:"el-icon-s-check"}]}},computed:{hasAnyProject(){return Object.keys(this.projects||{}).length>0},visibleSteps(){return this.hasAnyProject?this.steps:this.steps.filter(s=>s.id===1)}},watch:{currentCategory(s){this.selectedCategory=s},currentProject(s){this.selectedProject=s}},methods:{onCategoryChange(s){this.selectedProject="",this.$emit("category-change",s)},onProjectChange(s){this.$emit("project-change",s)},onStepClick(s){this.$emit("step-change",s)},isStepCompleted(s){var i;if(!this.currentProject)return!1;const e=`${this.currentCategory}/${this.currentProject}`,t=this.projects[e];return((i=t==null?void 0:t.stepStatus)==null?void 0:i[s])===!0}}};var S=function(){var e=this,t=e._self._c;return t("div",{staticClass:"workflow-sidebar"},[t("div",{staticClass:"sidebar-header"},[t("h3",[e._v("当前项目")]),t("div",{staticClass:"project-display-row"},[t("span",{staticClass:"label"},[e._v("大类")]),t("span",{staticClass:"value"},[e._v(e._s(e.currentCategory||"-"))])]),t("div",{staticClass:"project-display-row"},[t("span",{staticClass:"label"},[e._v("需求")]),t("span",{staticClass:"value"},[e._v(e._s(e.currentProject||"-"))])])]),t("div",{staticClass:"step-list"},e._l(e.visibleSteps,function(i){return t("div",{key:i.id,class:["step-item",{active:e.currentStep===i.id,completed:e.isStepCompleted(i.id)}],on:{click:function(a){return e.onStepClick(i.id)}}},[t("div",{staticClass:"step-icon"},[t("i",{class:i.icon})]),t("div",{staticClass:"step-info"},[t("div",{staticClass:"step-title"},[e._v(e._s(i.title))]),t("div",{staticClass:"step-desc"},[e._v(e._s(i.desc))])]),t("div",{staticClass:"step-status"},[e.isStepCompleted(i.id)?t("i",{staticClass:"el-icon-circle-check",staticStyle:{color:"#22c55e"}}):e._e()])])}),0)])},w=[],k=c(b,S,w,!1,null,"8e3cf2bb");const $=k.exports,I={name:"Step1NewReq",props:{categories:{type:Array,default:()=>[]},projects:{type:Object,default:()=>({})},basePath:{type:String,default:""},currentCategory:{type:String,default:""},currentProject:{type:String,default:""}},data(){return{selectedCategory:"",selectedProject:"",dialogVisible:!1,dialogInput:"",requirementDialogVisible:!1,requirementDialogInput:""}},computed:{existingRequirementList(){if(!this.selectedCategory)return[];const s=`${this.selectedCategory}/`;return Object.keys(this.projects).filter(e=>e.startsWith(s)).map(e=>e.split("/")[1]).sort()}},watch:{currentCategory:{immediate:!0,handler(s){this.selectedCategory=s||""}},currentProject:{immediate:!0,handler(s){this.selectedProject=s||""}},selectedCategory(s){s||(this.selectedProject="")},existingRequirementList(s){this.selectedProject&&(!Array.isArray(s)||s.length===0||s.includes(this.selectedProject)||(this.selectedProject=""))}},methods:{onCategoryChange(){this.selectedProject="",this.$emit("category-change",this.selectedCategory||""),this.$emit("project-change","")},onProjectChange(){this.$emit("project-change",this.selectedProject||"")},showCreateRequirementDialog(){if(!this.selectedCategory){this.$message.warning("请先选择大类");return}this.requirementDialogInput="",this.requirementDialogVisible=!0},handleCreateRequirementConfirm(){const s=this.requirementDialogInput.trim();if(!s){this.$message.warning("需求名称不能为空");return}if(this.existingRequirementList.includes(s)){this.$message.warning("该需求已存在");return}this.$emit("create-requirement",{category:this.selectedCategory,name:s}),this.requirementDialogVisible=!1},showCreateCategoryDialog(){this.dialogInput="",this.dialogVisible=!0},handleDialogConfirm(){const s=this.dialogInput.trim();if(!s){this.$message.warning("名称不能为空");return}this.$emit("create-category",s),this.dialogVisible=!1}}};var M=function(){var e=this,t=e._self._c;return t("div",{staticClass:"step1-container"},[t("div",{staticClass:"step1-main"},[t("div",{staticClass:"panel-section"},[e._m(0),t("div",{staticClass:"panel-section-body"},[t("el-form",{attrs:{"label-position":"top",size:"small"}},[t("el-form-item",{attrs:{label:"所属大类"}},[t("div",{staticClass:"flex gap-2"},[t("el-select",{staticStyle:{flex:"1"},attrs:{placeholder:"请选择大类"},on:{change:e.onCategoryChange},model:{value:e.selectedCategory,callback:function(i){e.selectedCategory=i},expression:"selectedCategory"}},e._l(e.categories,function(i){return t("el-option",{key:i,attrs:{label:i,value:i}})}),1),t("el-button",{on:{click:e.showCreateCategoryDialog}},[t("i",{staticClass:"el-icon-plus"}),e._v(" 新建 ")])],1)]),t("el-form-item",{attrs:{label:"选择需求"}},[t("div",{staticClass:"flex gap-2"},[t("el-select",{staticStyle:{flex:"1"},attrs:{placeholder:"选择已有需求目录",disabled:!e.selectedCategory},on:{change:e.onProjectChange},model:{value:e.selectedProject,callback:function(i){e.selectedProject=i},expression:"selectedProject"}},e._l(e.existingRequirementList,function(i){return t("el-option",{key:i,attrs:{label:i,value:i}})}),1),t("el-button",{attrs:{disabled:!e.selectedCategory},on:{click:e.showCreateRequirementDialog}},[t("i",{staticClass:"el-icon-plus"}),e._v(" 新建 ")])],1)]),t("div",{staticClass:"form-hint",staticStyle:{color:"#84848a"}},[e._v(" "+e._s(e.selectedCategory?"可直接选择已有需求,或点击“新建”创建需求目录":"请先选择大类")+" ")])],1)],1)])]),t("el-dialog",{attrs:{title:"新建大类",visible:e.dialogVisible,width:"400px"},on:{"update:visible":function(i){e.dialogVisible=i}}},[t("el-form",[t("el-form-item",{attrs:{label:"大类名称"}},[t("el-input",{attrs:{placeholder:"输入大类名称"},model:{value:e.dialogInput,callback:function(i){e.dialogInput=i},expression:"dialogInput"}})],1)],1),t("span",{attrs:{slot:"footer"},slot:"footer"},[t("el-button",{on:{click:function(i){e.dialogVisible=!1}}},[e._v("取消")]),t("el-button",{attrs:{type:"primary"},on:{click:e.handleDialogConfirm}},[e._v("确定")])],1)],1),t("el-dialog",{attrs:{title:"新建需求",visible:e.requirementDialogVisible,width:"400px"},on:{"update:visible":function(i){e.requirementDialogVisible=i}}},[t("el-form",[t("el-form-item",{attrs:{label:"需求目录名称"}},[t("el-input",{attrs:{placeholder:"输入需求名称,如:用户管理"},model:{value:e.requirementDialogInput,callback:function(i){e.requirementDialogInput=i},expression:"requirementDialogInput"}})],1)],1),t("span",{attrs:{slot:"footer"},slot:"footer"},[t("el-button",{on:{click:function(i){e.requirementDialogVisible=!1}}},[e._v("取消")]),t("el-button",{attrs:{type:"primary"},on:{click:e.handleCreateRequirementConfirm}},[e._v("确定")])],1)],1)],1)},P=[function(){var s=this,e=s._self._c;return e("div",{staticClass:"panel-section-header"},[e("span",[e("i",{staticClass:"el-icon-folder-add"}),s._v(" 创建新需求")])])}],j=c(I,M,P,!1,null,"bf976168");const x=j.exports,D={name:"Step2Design",components:{ModelSelectDialog:h,CommandDialog:u,FileSelectDialog:d},props:{category:{type:String,default:""},name:{type:String,default:""},reqBasePath:{type:String,default:""}},data(){return{editor:null,specContent:"",inputMessage:"",disabled:!1,stopping:!1,promptTokens:0,logItems:[],modelName:"",modelSelectVisible:!1,commandDialogVisible:!1,fileSelectVisible:!1,sessionId:"",sessionStatus:"idle",customActions:[]}},computed:{specFilePath(){return!this.category||!this.name?"等待选择需求...":`${this.reqBasePath}\\${this.category}\\${this.name}\\${this.name}_方案.md`}},watch:{category:{handler(){this.loadData()}},name:{handler(){this.loadData()}}},async mounted(){this.initMonacoEditor(),await this.loadData(),await this.loadDefaultModel(),await this.loadCustomActions(),o.ws.init()},beforeDestroy(){this.editor&&(this.editor.dispose(),this.editor=null),this.wsUnsubscribe&&this.wsUnsubscribe()},methods:{handleKeydown(s){if(s.key==="Enter")if(s.ctrlKey){const e=s.target,t=e.selectionStart,i=e.selectionEnd,a=this.inputMessage;this.inputMessage=a.substring(0,t)+`
|
|
2
|
+
`+a.substring(i),this.$nextTick(()=>{e.selectionStart=e.selectionEnd=t+1})}else s.preventDefault(),this.sendMessage()},async loadData(){await Promise.all([this.loadSpec(),this.loadSession()])},async loadSpec(){if(!this.category||!this.name){this.specContent=`# 选择或创建需求项目开始设计
|
|
3
|
+
`,this.syncEditorContent(this.specContent);return}try{const s=this.specFilePath,e=await o.getFileContent(s);this.specContent=e.content||"",this.syncEditorContent(this.specContent)}catch(s){console.error("Load spec failed:",s),this.specContent="",this.syncEditorContent("")}},async loadSession(){if(!this.category||!this.name){this.sessionId="";return}try{const s=`${this.reqBasePath}\\${this.category}\\${this.name}\\session.json`,e=await o.getFileContent(s);if(e&&e.content){const t=JSON.parse(e.content);this.sessionId=t.designSessionId||""}else this.sessionId="";this.sessionId?(await this.loadMessages(),this.subscribeSession()):this.logItems=[]}catch(s){console.error("Load session failed:",s),this.sessionId="",this.logItems=[]}},syncEditorContent(s){if(!this.editor||s===void 0||s===null)return;const e=String(s);this.editor.getValue()!==e&&this.editor.setValue(e)},initMonacoEditor(){this.editor||this.$nextTick(()=>{this.createEditor()})},createEditor(){this.editor||(this.editor=C.create(this.$refs.editorContainer,{value:this.specContent||`# 选择或创建需求项目开始设计
|
|
4
|
+
`,language:"markdown",theme:"vs-dark",fontSize:14,fontFamily:"ui-monospace, SFMono-Regular, 'JetBrains Mono', Menlo, Monaco, Consolas, monospace",minimap:{enabled:!1},lineNumbers:"on",wordWrap:"on",scrollBeyondLastLine:!1,automaticLayout:!0,padding:{top:16}}),this.editor.addCommand(_.CtrlCmd|v.KeyS,()=>{this.saveSpec()}),this.syncEditorContent(this.specContent))},saveSpec(){if(!this.editor)return;const s=this.editor.getValue();this.$emit("save-spec",s)},async sendMessage(){const s=this.inputMessage.trim();if(!s||this.disabled)return;if(!this.sessionId){this.$message.error("会话不存在,请刷新页面");return}this.wsUnsubscribe||this.subscribeSession();const e=`先在 ${this.specFilePath} 生成方案,先不要修改代码。
|
|
5
|
+
|
|
6
|
+
用户输入: ${s}`;this.inputMessage="",this.disabled=!0,this.stopping=!1,this.logItems.push({type:"chat",content:s}),o.sessionWsSend(this.sessionId,"chat",{message:e,sessionId:this.sessionId,modelName:this.modelName||void 0})},stopChat(){!this.sessionId||this.stopping||(this.stopping=!0,o.sessionWsSend(this.sessionId,"stop",{sessionId:this.sessionId}))},subscribeSession(){this.sessionId&&(this.wsUnsubscribe&&this.wsUnsubscribe(),this.wsUnsubscribe=o.wsSubscribe(this.sessionId,{running_sessions:s=>{const t=((s==null?void 0:s.runningSessionIds)||[]).includes(this.sessionId);this.sessionStatus=t?"processing":"idle",this.disabled=t},todos:s=>{s!=null&&s.todos&&this.logItems.push({type:"todos",todos:s.todos}),this.scrollToBottom()},step:s=>{var e;this.logItems.push({type:"step",thought:s.thought,toolCalls:s.toolCalls,success:s.success}),(e=s.usage)!=null&&e.promptTokens&&(this.promptTokens=s.usage.promptTokens),this.scrollToBottom()},compact:s=>{this.logItems.push({type:"system",content:`【压缩完成】${s.summary||""}`}),this.loadMessages()},done:s=>{var e;this.disabled=!1,this.stopping=!1,this.sessionStatus="completed",s!=null&&s.modelName&&(this.modelName=s.modelName),(e=s==null?void 0:s.usage)!=null&&e.promptTokens&&(this.promptTokens=s.usage.promptTokens),s!=null&&s.response&&this.logItems.push({type:"think",content:s.response}),this.$emit("spec-updated"),this.scrollToBottom()},stopped:()=>{this.disabled=!1,this.stopping=!1,this.sessionStatus="idle",this.logItems.push({type:"think",content:"【已停止】"}),this.scrollToBottom()},error:s=>{this.$message.error((s==null?void 0:s.error)||"发生错误"),this.disabled=!1,this.stopping=!1,this.sessionStatus="idle"}}))},scrollToBottom(){this.$nextTick(()=>{const s=this.$refs.messagesContainer;s&&(s.scrollTop=s.scrollHeight)})},async loadMessages(){if(this.sessionId)try{const s=await o.getMessages(this.sessionId);this.logItems=s.data||[]}catch(s){console.error("Load messages failed:",s)}},async loadDefaultModel(){var s;try{const e=await o.getConfig("defaultModel");(s=e.data)!=null&&s.value&&(this.modelName=e.data.value)}catch(e){console.error("Load default model failed:",e)}},openModelSelector(){this.modelSelectVisible=!0},onModelSelected(s){const e=s.name.split("/");this.modelName=e.length>2?e.slice(1).join("/"):s.name,o.setConfig("defaultModel",this.modelName)},openCommandDialog(){this.commandDialogVisible=!0},handleExecuteCommand(s){this.inputMessage=s+" ",this.$nextTick(()=>{const e=this.$el.querySelector(".input-area textarea");e&&e.focus()})},openFileSelect(){this.fileSelectVisible=!0},onFileSelected(s){const e=this.inputMessage.lastIndexOf("@");e!==-1?this.inputMessage=this.inputMessage.slice(0,e)+s+" ":this.inputMessage+=s+" ",this.cancelFileSelect()},cancelFileSelect(){this.fileSelectVisible=!1},getTodoStatusIcon(s){return{completed:"✅",in_progress:"🔄",pending:"⬜",cancelled:"❌"}[s]||"⬜"},formatInput(s,e){try{const t=JSON.parse(e);return s==="bash"||s==="execute_bash"?t.command+(t.workdir?` (${t.workdir})`:""):s==="read_file"?t.file_path+(t.offset?`:${t.offset}`:""):s==="edit_file"||s==="write_file"?t.file_path:s==="glob"||s==="find_files"?t.pattern+(t.directory?` (${t.directory})`:""):s==="grep"||s==="search_content"?`"${t.pattern}" (${t.directory||""})`:e}catch{return e}},renderMarkdown(s){return s?p(s):""},openCustomActions(){window.open("/custom-actions","_blank")},async loadCustomActions(){try{const s=await o.getCustomActions("design");this.customActions=s.data||[]}catch(s){console.error("Load custom actions failed:",s)}},executeCustomAction(s){this.inputMessage=s.prompt,this.$nextTick(()=>{const e=this.$el.querySelector(".input-area textarea");e&&e.focus(),s.auto_send&&this.sendMessage()})}}};var T=function(){var e=this,t=e._self._c;return t("div",{staticClass:"step2-container"},[t("div",{staticClass:"step2-main"},[t("div",{staticClass:"editor-panel"},[t("div",{staticClass:"editor-header"},[t("i",{staticClass:"el-icon-document"}),t("span",[e._v(e._s(e.specFilePath))])]),t("div",{ref:"editorContainer",staticClass:"editor-container"})]),t("div",{staticClass:"chat-panel"},[e._m(0),t("div",{ref:"messagesContainer",staticClass:"chat-messages"},[e.logItems.length?e._e():t("div",{staticClass:"empty-state"},[t("i",{staticClass:"el-icon-chat-dot-round"}),t("p",[e._v("输入需求描述,AI将协助您完善方案")])]),e._l(e.logItems,function(i,a){return[i.type==="todos"?t("div",{staticClass:"todos-list"},e._l(i.todos,function(n,r){return t("div",{key:r,staticClass:"todo-item"},[t("span",{staticClass:"todo-status"},[e._v(e._s(e.getTodoStatusIcon(n.status)))]),t("span",{staticClass:"todo-name"},[e._v(e._s(n.name))])])}),0):i.type==="chat"||i.type==="think"?t("div",{staticClass:"user-question",domProps:{innerHTML:e._s(e.renderMarkdown(i.content))}}):i.type==="system"?t("div",{staticClass:"system-message",domProps:{innerHTML:e._s(e.renderMarkdown(i.content))}}):i.type==="step"?[i.thought?t("div",{staticClass:"ai-thought",domProps:{innerHTML:e._s(e.renderMarkdown(i.thought))}}):e._e(),e._l(i.toolCalls,function(n,r){return t("div",{key:r,staticClass:"log-mute"},[t("span",{class:i.success!==!1?"tool-success":"tool-fail"},[e._v(" "+e._s(i.success!==!1?"✓":"✗")+" ")]),e._v(" "+e._s(n.function.name)+" "),n.function.arguments?t("span",{staticClass:"tool-input"},[e._v(e._s(e.formatInput(n.function.name,n.function.arguments)))]):e._e()])})]:e._e()]}),e.modelName?t("div",{staticClass:"build-info"},[t("span",{staticClass:"icon"},[e._v("▣")]),e._v(" Build · "+e._s(e.modelName)+" ")]):e._e()],2),t("div",{staticClass:"chat-input-area"},[t("el-input",{staticClass:"input-area",attrs:{type:"textarea",rows:3,placeholder:"输入消息... (Enter 发送, Ctrl+Enter 换行, @ 选择文件)",disabled:e.disabled&&!e.stopping},nativeOn:{keydown:function(i){return!i.type.indexOf("key")&&e._k(i.keyCode,"enter",13,i.key,"Enter")?null:e.handleKeydown.apply(null,arguments)}},model:{value:e.inputMessage,callback:function(i){e.inputMessage=i},expression:"inputMessage"}}),t("div",{staticClass:"input-actions"},[e._l(e.customActions,function(i){return t("el-button",{key:i.id,attrs:{type:"info",size:"small",disabled:e.disabled},on:{click:function(a){return e.executeCustomAction(i)}}},[e._v(" "+e._s(i.name)+" ")])}),e.disabled&&!e.stopping?t("el-button",{staticClass:"stop-btn",attrs:{type:"danger"},on:{click:e.stopChat}},[e._v(" ■ 停止 ")]):e.stopping?t("el-button",{staticClass:"stop-btn",attrs:{type:"info",disabled:""}},[e._v(" 停止中... ")]):t("el-button",{staticClass:"send-btn",attrs:{type:"primary",disabled:!e.inputMessage.trim()},on:{click:e.sendMessage}},[e._v(" 发送 ")])],2)],1),t("div",{staticClass:"status-bar"},[t("span",{class:e.sessionStatus==="processing"?"status-thinking":"status-ready"},[e.sessionStatus==="processing"?t("span",{staticClass:"thinking-spinner"}):e._e(),e._v(" "+e._s(e.sessionStatus==="processing"?"思考中":"✓ 就绪")+" ")]),t("span",{staticClass:"separator"},[e._v("|")]),t("span",{staticClass:"model-selector",on:{click:e.openModelSelector,mousedown:function(i){i.preventDefault()}}},[e._v(" 模型:"+e._s(e.modelName||"-")+" ▾ ")]),t("span",{staticClass:"separator"},[e._v("|")]),t("span",[e._v("会话:"+e._s(e.sessionId?e.sessionId.slice(0,8):"--------"))]),t("span",{staticClass:"separator"},[e._v("|")]),t("span",[e._v("token:"+e._s(e.promptTokens||0))]),t("span",{staticClass:"separator"},[e._v("|")]),t("span",{staticClass:"status-action",on:{click:e.openCommandDialog,mousedown:function(i){i.preventDefault()}}},[e._v("命令")]),t("span",{staticClass:"separator"},[e._v("|")]),t("span",{staticClass:"status-action",on:{click:e.openFileSelect,mousedown:function(i){i.preventDefault()}}},[e._v("选择文件")])])])]),t("ModelSelectDialog",{attrs:{visible:e.modelSelectVisible,"current-model":e.modelName},on:{"update:visible":function(i){e.modelSelectVisible=i},select:e.onModelSelected}}),t("CommandDialog",{attrs:{visible:e.commandDialogVisible},on:{"update:visible":function(i){e.commandDialogVisible=i},execute:e.handleExecuteCommand}}),t("FileSelectDialog",{attrs:{visible:e.fileSelectVisible},on:{"update:visible":function(i){e.fileSelectVisible=i},select:e.onFileSelected,close:e.cancelFileSelect}})],1)},q=[function(){var s=this,e=s._self._c;return e("div",{staticClass:"panel-header"},[e("span",[e("i",{staticClass:"el-icon-chat-dot-round"}),s._v(" AI 方案助手")])])}],F=c(D,T,q,!1,null,"aa4cddfa");const V=F.exports,B={name:"Step3CodeGen",components:{ModelSelectDialog:h,CommandDialog:u,FileSelectDialog:d},props:{category:{type:String,default:""},name:{type:String,default:""},reqBasePath:{type:String,default:""}},data(){return{inputMessage:"",disabled:!1,stopping:!1,promptTokens:0,dotAnimation:"",dotInterval:null,dots:["⠋","⠙","⠹","⠸","⠼","⠴","⠦","⠧"],logItems:[],modelName:"",modelSelectVisible:!1,commandDialogVisible:!1,fileSelectVisible:!1,sessionId:"",sessionStatus:"idle",customActions:[]}},computed:{specFilePath(){return!this.category||!this.name?"":`${this.reqBasePath}\\${this.category}\\${this.name}\\${this.name}_方案.md`}},watch:{category:{handler(){this.loadSession()}},name:{handler(){this.loadSession()}}},async mounted(){await this.loadSession(),await this.loadDefaultModel(),await this.loadCustomActions(),o.ws.init()},beforeDestroy(){this.dotInterval&&clearInterval(this.dotInterval),this.wsUnsubscribe&&this.wsUnsubscribe()},methods:{handleKeydown(s){if(s.key==="Enter")if(s.ctrlKey){const e=s.target,t=e.selectionStart,i=e.selectionEnd,a=this.inputMessage;this.inputMessage=a.substring(0,t)+`
|
|
7
|
+
`+a.substring(i),this.$nextTick(()=>{e.selectionStart=e.selectionEnd=t+1})}else s.preventDefault(),this.sendMessage()},async loadSession(){if(!this.category||!this.name){this.sessionId="";return}try{const s=`${this.reqBasePath}\\${this.category}\\${this.name}\\session.json`,e=await o.getFileContent(s);if(e&&e.content){const t=JSON.parse(e.content);this.sessionId=t.codeSessionId||""}else this.sessionId="";this.sessionId?(await this.loadMessages(),this.subscribeSession()):this.logItems=[]}catch(s){console.error("Load session failed:",s),this.sessionId="",this.logItems=[]}},insertGenerateCommand(){this.specFilePath&&(this.inputMessage=`根据 ${this.specFilePath} 方案开发相应功能,先不要修改方案文档。`)},async sendMessage(){const s=this.inputMessage.trim();if(!(!s||this.disabled)){if(!this.sessionId){this.$message.error("会话不存在,请刷新页面");return}this.wsUnsubscribe||this.subscribeSession(),this.inputMessage="",this.disabled=!0,this.stopping=!1,this.logItems.push({type:"chat",content:s}),o.sessionWsSend(this.sessionId,"chat",{message:s,sessionId:this.sessionId,modelName:this.modelName||void 0})}},stopChat(){!this.sessionId||this.stopping||(this.stopping=!0,o.sessionWsSend(this.sessionId,"stop",{sessionId:this.sessionId}))},subscribeSession(){this.sessionId&&(this.wsUnsubscribe&&this.wsUnsubscribe(),this.wsUnsubscribe=o.wsSubscribe(this.sessionId,{running_sessions:s=>{const t=((s==null?void 0:s.runningSessionIds)||[]).includes(this.sessionId);this.sessionStatus=t?"processing":"idle",this.disabled=t},todos:s=>{s!=null&&s.todos&&this.logItems.push({type:"todos",todos:s.todos}),this.scrollToBottom()},step:s=>{var e;this.logItems.push({type:"step",thought:s.thought,toolCalls:s.toolCalls,success:s.success}),(e=s.usage)!=null&&e.promptTokens&&(this.promptTokens=s.usage.promptTokens),this.scrollToBottom()},compact:s=>{this.logItems.push({type:"system",content:`【压缩完成】${s.summary||""}`}),this.loadMessages()},done:s=>{var e;this.disabled=!1,this.stopping=!1,this.sessionStatus="completed",s!=null&&s.modelName&&(this.modelName=s.modelName),(e=s==null?void 0:s.usage)!=null&&e.promptTokens&&(this.promptTokens=s.usage.promptTokens),s!=null&&s.response&&this.logItems.push({type:"think",content:s.response}),this.scrollToBottom()},stopped:()=>{this.disabled=!1,this.stopping=!1,this.sessionStatus="idle",this.logItems.push({type:"think",content:"【已停止】"}),this.scrollToBottom()},error:s=>{this.$message.error((s==null?void 0:s.error)||"发生错误"),this.disabled=!1,this.stopping=!1,this.sessionStatus="idle"}}))},scrollToBottom(){this.$nextTick(()=>{const s=this.$refs.messagesContainer;s&&(s.scrollTop=s.scrollHeight)})},async loadMessages(){if(this.sessionId)try{const s=await o.getMessages(this.sessionId);this.logItems=s.data||[]}catch(s){console.error("Load messages failed:",s)}},async loadDefaultModel(){var s;try{const e=await o.getConfig("defaultModel");(s=e.data)!=null&&s.value&&(this.modelName=e.data.value)}catch(e){console.error("Load default model failed:",e)}},openModelSelector(){this.modelSelectVisible=!0},onModelSelected(s){const e=s.name.split("/");this.modelName=e.length>2?e.slice(1).join("/"):s.name,o.setConfig("defaultModel",this.modelName)},openCommandDialog(){this.commandDialogVisible=!0},handleExecuteCommand(s){this.inputMessage=s+" ",this.$nextTick(()=>{const e=this.$el.querySelector(".input-area textarea");e&&e.focus()})},openFileSelect(){this.fileSelectVisible=!0},onFileSelected(s){const e=this.inputMessage.lastIndexOf("@");e!==-1?this.inputMessage=this.inputMessage.slice(0,e)+s+" ":this.inputMessage+=s+" ",this.cancelFileSelect()},cancelFileSelect(){this.fileSelectVisible=!1},getTodoStatusIcon(s){return{completed:"✅",in_progress:"🔄",pending:"⬜",cancelled:"❌"}[s]||"⬜"},formatInput(s,e){try{const t=JSON.parse(e);return s==="bash"||s==="execute_bash"?t.command+(t.workdir?` (${t.workdir})`:""):s==="read_file"?t.file_path+(t.offset?`:${t.offset}`:""):s==="edit_file"||s==="write_file"?t.file_path:s==="glob"||s==="find_files"?t.pattern+(t.directory?` (${t.directory})`:""):s==="grep"||s==="search_content"?`"${t.pattern}" (${t.directory||""})`:e}catch{return e}},renderMarkdown(s){return s?p(s):""},async loadCustomActions(){try{const s=await o.getCustomActions("code");this.customActions=s.data||[]}catch(s){console.error("Load custom actions failed:",s),this.customActions=[]}},executeCustomAction(s){this.inputMessage=s.prompt,this.$nextTick(()=>{const e=this.$el.querySelector(".input-area textarea");e&&e.focus(),s.auto_send&&this.sendMessage()})},openCustomActions(){window.open("/custom-actions","_blank")}}};var N=function(){var e=this,t=e._self._c;return t("div",{staticClass:"step3-container"},[t("div",{staticClass:"step3-main"},[t("div",{staticClass:"code-chat-panel"},[t("div",{staticClass:"panel-header"},[e._m(0),t("div",{staticClass:"header-actions"},[t("el-button",{attrs:{type:"primary",size:"small",disabled:e.disabled},on:{click:e.insertGenerateCommand}},[t("i",{staticClass:"el-icon-document"}),e._v(" 根据方案生成代码 ")]),t("el-button",{attrs:{type:"warning",size:"small"},on:{click:e.openCustomActions}},[t("i",{staticClass:"el-icon-setting"}),e._v(" 动作配置 ")])],1)]),t("div",{ref:"messagesContainer",staticClass:"chat-messages"},[e.logItems.length?e._e():t("div",{staticClass:"empty-state"},[t("i",{staticClass:"el-icon-chat-dot-round"}),t("p",[e._v("点击上方按钮或输入需求生成代码")])]),e._l(e.logItems,function(i,a){return[i.type==="todos"?t("div",{staticClass:"todos-list"},e._l(i.todos,function(n,r){return t("div",{key:r,staticClass:"todo-item"},[t("span",{staticClass:"todo-status"},[e._v(e._s(e.getTodoStatusIcon(n.status)))]),t("span",{staticClass:"todo-name"},[e._v(e._s(n.name))])])}),0):i.type==="chat"||i.type==="think"?t("div",{staticClass:"user-question",domProps:{innerHTML:e._s(e.renderMarkdown(i.content))}}):i.type==="system"?t("div",{staticClass:"system-message",domProps:{innerHTML:e._s(e.renderMarkdown(i.content))}}):i.type==="step"?[i.thought?t("div",{staticClass:"ai-thought",domProps:{innerHTML:e._s(e.renderMarkdown(i.thought))}}):e._e(),e._l(i.toolCalls,function(n,r){return t("div",{key:r,staticClass:"log-mute"},[t("span",{class:i.success!==!1?"tool-success":"tool-fail"},[e._v(" "+e._s(i.success!==!1?"✓":"✗")+" ")]),e._v(" "+e._s(n.function.name)+" "),n.function.arguments?t("span",{staticClass:"tool-input"},[e._v(e._s(e.formatInput(n.function.name,n.function.arguments)))]):e._e()])})]:e._e()]}),e.modelName?t("div",{staticClass:"build-info"},[t("span",{staticClass:"icon"},[e._v("▣")]),e._v(" Build · "+e._s(e.modelName)+" ")]):e._e()],2),t("div",{staticClass:"chat-input-area"},[t("el-input",{staticClass:"input-area",attrs:{type:"textarea",rows:3,placeholder:"输入代码修改要求... (Enter 发送, Ctrl+Enter 换行, @ 选择文件)",disabled:e.disabled&&!e.stopping},nativeOn:{keydown:function(i){return!i.type.indexOf("key")&&e._k(i.keyCode,"enter",13,i.key,"Enter")?null:e.handleKeydown.apply(null,arguments)}},model:{value:e.inputMessage,callback:function(i){e.inputMessage=i},expression:"inputMessage"}}),t("div",{staticClass:"input-actions"},[e._l(e.customActions,function(i){return t("el-button",{key:i.id,attrs:{type:"info",size:"small",disabled:e.disabled},on:{click:function(a){return e.executeCustomAction(i)}}},[e._v(" "+e._s(i.name)+" ")])}),e.disabled&&!e.stopping?t("el-button",{staticClass:"stop-btn",attrs:{type:"danger"},on:{click:e.stopChat}},[e._v(" ■ 停止 ")]):e.stopping?t("el-button",{staticClass:"stop-btn",attrs:{type:"info",disabled:""}},[e._v(" 停止中... ")]):t("el-button",{staticClass:"send-btn",attrs:{type:"primary",disabled:!e.inputMessage.trim()},on:{click:e.sendMessage}},[e._v(" 发送 ")])],2)],1),t("div",{staticClass:"status-bar"},[t("span",{class:e.sessionStatus==="processing"?"status-thinking":"status-ready"},[e.sessionStatus==="processing"?t("span",{staticClass:"thinking-spinner"}):e._e(),e._v(" "+e._s(e.sessionStatus==="processing"?"思考中":"✓ 就绪")+" ")]),t("span",{staticClass:"separator"},[e._v("|")]),t("span",{staticClass:"model-selector",on:{click:e.openModelSelector,mousedown:function(i){i.preventDefault()}}},[e._v(" 模型:"+e._s(e.modelName||"-")+" ▾ ")]),t("span",{staticClass:"separator"},[e._v("|")]),t("span",[e._v("会话:"+e._s(e.sessionId?e.sessionId.slice(0,8):"--------"))]),t("span",{staticClass:"separator"},[e._v("|")]),t("span",[e._v("token:"+e._s(e.promptTokens||0))]),t("span",{staticClass:"separator"},[e._v("|")]),t("span",{staticClass:"status-action",on:{click:e.openCommandDialog,mousedown:function(i){i.preventDefault()}}},[e._v("命令")]),t("span",{staticClass:"separator"},[e._v("|")]),t("span",{staticClass:"status-action",on:{click:e.openFileSelect,mousedown:function(i){i.preventDefault()}}},[e._v("选择文件")])])])]),t("ModelSelectDialog",{attrs:{visible:e.modelSelectVisible,"current-model":e.modelName},on:{"update:visible":function(i){e.modelSelectVisible=i},select:e.onModelSelected}}),t("CommandDialog",{attrs:{visible:e.commandDialogVisible},on:{"update:visible":function(i){e.commandDialogVisible=i},execute:e.handleExecuteCommand}}),t("FileSelectDialog",{attrs:{visible:e.fileSelectVisible},on:{"update:visible":function(i){e.fileSelectVisible=i},select:e.onFileSelected,close:e.cancelFileSelect}})],1)},R=[function(){var s=this,e=s._self._c;return e("span",[e("i",{staticClass:"el-icon-code"}),s._v(" 代码生成对话")])}],A=c(B,N,R,!1,null,"c21cb50f");const L=A.exports,E={name:"Step4Test",components:{ModelSelectDialog:h,CommandDialog:u,FileSelectDialog:d},props:{category:{type:String,default:""},name:{type:String,default:""},reqBasePath:{type:String,default:""}},data(){return{inputMessage:"",disabled:!1,stopping:!1,promptTokens:0,dotAnimation:"",dotInterval:null,dots:["⠋","⠙","⠹","⠸","⠼","⠴","⠦","⠧"],logItems:[],modelName:"",modelSelectVisible:!1,commandDialogVisible:!1,fileSelectVisible:!1,sessionId:"",sessionStatus:"idle",customActions:[]}},computed:{specFilePath(){return!this.category||!this.name?"":`${this.reqBasePath}\\${this.category}\\${this.name}\\${this.name}_方案.md`}},watch:{category:{handler(){this.loadSession()}},name:{handler(){this.loadSession()}}},async mounted(){await this.loadSession(),await this.loadDefaultModel(),await this.loadCustomActions(),o.ws.init()},beforeDestroy(){this.dotInterval&&clearInterval(this.dotInterval),this.wsUnsubscribe&&this.wsUnsubscribe()},methods:{handleKeydown(s){if(s.key==="Enter")if(s.ctrlKey){const e=s.target,t=e.selectionStart,i=e.selectionEnd,a=this.inputMessage;this.inputMessage=a.substring(0,t)+`
|
|
8
|
+
`+a.substring(i),this.$nextTick(()=>{e.selectionStart=e.selectionEnd=t+1})}else s.preventDefault(),this.sendMessage()},async loadSession(){if(!this.category||!this.name){this.sessionId="";return}try{const s=`${this.reqBasePath}\\${this.category}\\${this.name}\\session.json`,e=await o.getFileContent(s);if(e&&e.content){const t=JSON.parse(e.content);this.sessionId=t.testSessionId||""}else this.sessionId="";this.sessionId?(await this.loadMessages(),this.subscribeSession()):this.logItems=[]}catch(s){console.error("Load session failed:",s),this.sessionId="",this.logItems=[]}},insertTestCommand(){this.specFilePath&&(this.inputMessage=`根据 ${this.specFilePath} 方案测试相应功能是否实现。`)},async sendMessage(){const s=this.inputMessage.trim();if(!(!s||this.disabled)){if(!this.sessionId){this.$message.error("会话不存在,请刷新页面");return}this.wsUnsubscribe||this.subscribeSession(),this.inputMessage="",this.disabled=!0,this.stopping=!1,this.logItems.push({type:"chat",content:s}),o.sessionWsSend(this.sessionId,"chat",{message:s,sessionId:this.sessionId,modelName:this.modelName||void 0})}},stopChat(){!this.sessionId||this.stopping||(this.stopping=!0,o.sessionWsSend(this.sessionId,"stop",{sessionId:this.sessionId}))},subscribeSession(){this.sessionId&&(this.wsUnsubscribe&&this.wsUnsubscribe(),this.wsUnsubscribe=o.wsSubscribe(this.sessionId,{running_sessions:s=>{const t=((s==null?void 0:s.runningSessionIds)||[]).includes(this.sessionId);this.sessionStatus=t?"processing":"idle",this.disabled=t},todos:s=>{s!=null&&s.todos&&this.logItems.push({type:"todos",todos:s.todos}),this.scrollToBottom()},step:s=>{var e;this.logItems.push({type:"step",thought:s.thought,toolCalls:s.toolCalls,success:s.success}),(e=s.usage)!=null&&e.promptTokens&&(this.promptTokens=s.usage.promptTokens),this.scrollToBottom()},compact:s=>{this.logItems.push({type:"system",content:`【压缩完成】${s.summary||""}`}),this.loadMessages()},done:s=>{var e;this.disabled=!1,this.stopping=!1,this.sessionStatus="completed",s!=null&&s.modelName&&(this.modelName=s.modelName),(e=s==null?void 0:s.usage)!=null&&e.promptTokens&&(this.promptTokens=s.usage.promptTokens),s!=null&&s.response&&this.logItems.push({type:"think",content:s.response}),this.scrollToBottom()},stopped:()=>{this.disabled=!1,this.stopping=!1,this.sessionStatus="idle",this.logItems.push({type:"think",content:"【已停止】"}),this.scrollToBottom()},error:s=>{this.$message.error((s==null?void 0:s.error)||"发生错误"),this.disabled=!1,this.stopping=!1,this.sessionStatus="idle"}}))},scrollToBottom(){this.$nextTick(()=>{const s=this.$refs.messagesContainer;s&&(s.scrollTop=s.scrollHeight)})},async loadMessages(){if(this.sessionId)try{const s=await o.getMessages(this.sessionId);this.logItems=s.data||[]}catch(s){console.error("Load messages failed:",s)}},async loadDefaultModel(){var s;try{const e=await o.getConfig("defaultModel");(s=e.data)!=null&&s.value&&(this.modelName=e.data.value)}catch(e){console.error("Load default model failed:",e)}},openModelSelector(){this.modelSelectVisible=!0},onModelSelected(s){const e=s.name.split("/");this.modelName=e.length>2?e.slice(1).join("/"):s.name,o.setConfig("defaultModel",this.modelName)},openCommandDialog(){this.commandDialogVisible=!0},handleExecuteCommand(s){this.inputMessage=s+" ",this.$nextTick(()=>{const e=this.$el.querySelector(".input-area textarea");e&&e.focus()})},openFileSelect(){this.fileSelectVisible=!0},onFileSelected(s){const e=this.inputMessage.lastIndexOf("@");e!==-1?this.inputMessage=this.inputMessage.slice(0,e)+s+" ":this.inputMessage+=s+" ",this.cancelFileSelect()},cancelFileSelect(){this.fileSelectVisible=!1},getTodoStatusIcon(s){return{completed:"✅",in_progress:"🔄",pending:"⬜",cancelled:"❌"}[s]||"⬜"},formatInput(s,e){try{const t=JSON.parse(e);return s==="bash"||s==="execute_bash"?t.command+(t.workdir?` (${t.workdir})`:""):s==="read_file"?t.file_path+(t.offset?`:${t.offset}`:""):s==="edit_file"||s==="write_file"?t.file_path:s==="glob"||s==="find_files"?t.pattern+(t.directory?` (${t.directory})`:""):s==="grep"||s==="search_content"?`"${t.pattern}" (${t.directory||""})`:e}catch{return e}},renderMarkdown(s){return s?p(s):""},async loadCustomActions(){try{const s=await o.getCustomActions("test");this.customActions=s.data||[]}catch(s){console.error("Load custom actions failed:",s),this.customActions=[]}},executeCustomAction(s){this.inputMessage=s.prompt,this.$nextTick(()=>{const e=this.$el.querySelector(".input-area textarea");e&&e.focus(),s.auto_send&&this.sendMessage()})}}};var O=function(){var e=this,t=e._self._c;return t("div",{staticClass:"step4-container"},[t("div",{staticClass:"step4-main"},[t("div",{staticClass:"code-chat-panel"},[t("div",{staticClass:"panel-header"},[e._m(0),t("el-button",{attrs:{type:"primary",size:"small",disabled:e.disabled},on:{click:e.insertTestCommand}},[t("i",{staticClass:"el-icon-s-claim"}),e._v(" 根据方案测试 ")])],1),t("div",{ref:"messagesContainer",staticClass:"chat-messages"},[e.logItems.length?e._e():t("div",{staticClass:"empty-state"},[t("i",{staticClass:"el-icon-chat-dot-round"}),t("p",[e._v("点击上方按钮或输入测试要求进行验收")])]),e._l(e.logItems,function(i,a){return[i.type==="todos"?t("div",{staticClass:"todos-list"},e._l(i.todos,function(n,r){return t("div",{key:r,staticClass:"todo-item"},[t("span",{staticClass:"todo-status"},[e._v(e._s(e.getTodoStatusIcon(n.status)))]),t("span",{staticClass:"todo-name"},[e._v(e._s(n.name))])])}),0):i.type==="chat"||i.type==="think"?t("div",{staticClass:"user-question",domProps:{innerHTML:e._s(e.renderMarkdown(i.content))}}):i.type==="system"?t("div",{staticClass:"system-message",domProps:{innerHTML:e._s(e.renderMarkdown(i.content))}}):i.type==="step"?[i.thought?t("div",{staticClass:"ai-thought",domProps:{innerHTML:e._s(e.renderMarkdown(i.thought))}}):e._e(),e._l(i.toolCalls,function(n,r){return t("div",{key:r,staticClass:"log-mute"},[t("span",{class:i.success!==!1?"tool-success":"tool-fail"},[e._v(" "+e._s(i.success!==!1?"✓":"✗")+" ")]),e._v(" "+e._s(n.function.name)+" "),n.function.arguments?t("span",{staticClass:"tool-input"},[e._v(e._s(e.formatInput(n.function.name,n.function.arguments)))]):e._e()])})]:e._e()]}),e.modelName?t("div",{staticClass:"build-info"},[t("span",{staticClass:"icon"},[e._v("▣")]),e._v(" Build · "+e._s(e.modelName)+" ")]):e._e()],2),t("div",{staticClass:"chat-input-area"},[t("el-input",{staticClass:"input-area",attrs:{type:"textarea",rows:3,placeholder:"输入测试要求... (Enter 发送, Ctrl+Enter 换行, @ 选择文件)",disabled:e.disabled&&!e.stopping},nativeOn:{keydown:function(i){return!i.type.indexOf("key")&&e._k(i.keyCode,"enter",13,i.key,"Enter")?null:e.handleKeydown.apply(null,arguments)}},model:{value:e.inputMessage,callback:function(i){e.inputMessage=i},expression:"inputMessage"}}),t("div",{staticClass:"input-actions"},[e._l(e.customActions,function(i){return t("el-button",{key:i.id,attrs:{type:"info",size:"small",disabled:e.disabled},on:{click:function(a){return e.executeCustomAction(i)}}},[e._v(" "+e._s(i.name)+" ")])}),e.disabled&&!e.stopping?t("el-button",{staticClass:"stop-btn",attrs:{type:"danger"},on:{click:e.stopChat}},[e._v(" ■ 停止 ")]):e.stopping?t("el-button",{staticClass:"stop-btn",attrs:{type:"info",disabled:""}},[e._v(" 停止中... ")]):t("el-button",{staticClass:"send-btn",attrs:{type:"primary",disabled:!e.inputMessage.trim()},on:{click:e.sendMessage}},[e._v(" 发送 ")])],2)],1),t("div",{staticClass:"status-bar"},[t("span",{class:e.sessionStatus==="processing"?"status-thinking":"status-ready"},[e.sessionStatus==="processing"?t("span",{staticClass:"thinking-spinner"}):e._e(),e._v(" "+e._s(e.sessionStatus==="processing"?"思考中":"✓ 就绪")+" ")]),t("span",{staticClass:"separator"},[e._v("|")]),t("span",{staticClass:"model-selector",on:{click:e.openModelSelector,mousedown:function(i){i.preventDefault()}}},[e._v(" 模型:"+e._s(e.modelName||"-")+" ▾ ")]),t("span",{staticClass:"separator"},[e._v("|")]),t("span",[e._v("会话:"+e._s(e.sessionId?e.sessionId.slice(0,8):"--------"))]),t("span",{staticClass:"separator"},[e._v("|")]),t("span",[e._v("token:"+e._s(e.promptTokens||0))]),t("span",{staticClass:"separator"},[e._v("|")]),t("span",{staticClass:"status-action",on:{click:e.openCommandDialog,mousedown:function(i){i.preventDefault()}}},[e._v("命令")]),t("span",{staticClass:"separator"},[e._v("|")]),t("span",{staticClass:"status-action",on:{click:e.openFileSelect,mousedown:function(i){i.preventDefault()}}},[e._v("选择文件")])])])]),t("ModelSelectDialog",{attrs:{visible:e.modelSelectVisible,"current-model":e.modelName},on:{"update:visible":function(i){e.modelSelectVisible=i},select:e.onModelSelected}}),t("CommandDialog",{attrs:{visible:e.commandDialogVisible},on:{"update:visible":function(i){e.commandDialogVisible=i},execute:e.handleExecuteCommand}}),t("FileSelectDialog",{attrs:{visible:e.fileSelectVisible},on:{"update:visible":function(i){e.fileSelectVisible=i},select:e.onFileSelected,close:e.cancelFileSelect}})],1)},U=[function(){var s=this,e=s._self._c;return e("span",[e("i",{staticClass:"el-icon-s-check"}),s._v(" 测试验收对话")])}],K=c(E,O,U,!1,null,"bc0169a8");const W=K.exports,H={name:"DevWorkflowView",components:{WorkflowSidebar:$,Step1NewReq:x,Step2Design:V,Step3CodeGen:L,Step4Test:W},props:{sidebarVisible:{type:Boolean,default:!0}},data(){return{currentCategory:"",currentProject:"",currentStep:1,categories:[],projects:{},reqBasePath:"",isLoadingProjects:!1}},computed:{projectKey(){return!this.currentCategory||!this.currentProject?"":`${this.currentCategory}/${this.currentProject}`},hasSelectedProject(){return!!this.currentProject},stepTitle(){return{1:"新建需求",2:"方案设计",3:"代码生成",4:"测试验收"}[this.currentStep]||""},statusText(){return this.projectKey?`步骤 ${this.currentStep} / 4`:"就绪"}},created(){this.loadState(),this.loadCategories()},methods:{async loadState(){try{const e=(await o.getWorkflowState()).data;e&&(this.currentCategory=e.currentCategory||"",this.currentProject=e.currentProject||"",this.currentStep=e.currentStep||1)}catch(s){console.error("Load workflow state failed:",s)}},async saveState(){try{await o.updateWorkflowState(this.currentCategory,this.currentProject,this.currentStep)}catch(s){console.error("Save workflow state failed:",s)}},async loadCategories(){var s,e;try{const t=await o.getCwd();this.reqBasePath=((s=t.data)==null?void 0:s.basePath)||"";const a=((e=(await o.browseFilesystem(this.reqBasePath)).data)==null?void 0:e.items)||[];this.categories=a.filter(n=>n.is_directory).map(n=>n.name),this.categories.sort(),this.currentCategory&&this.categories.includes(this.currentCategory)&&await this.loadProjectsForCategory(this.currentCategory)}catch(t){console.error("Load categories failed:",t),this.categories=[]}},async loadProjectsForCategory(s){var e;if(s){this.isLoadingProjects=!0;try{const t=`${this.reqBasePath}\\${s}`,a=((e=(await o.browseFilesystem(t)).data)==null?void 0:e.items)||[];this.projects={},a.filter(n=>n.is_directory).forEach(n=>{const r=`${s}/${n.name}`;this.projects[r]={name:n.name,stepStatus:{}}})}catch(t){console.error("Load projects failed:",t)}finally{this.isLoadingProjects=!1}}},async onCategoryChange(s){this.currentCategory=s,this.currentProject="",this.currentStep=1,s?await this.loadProjectsForCategory(s):this.projects={}},onProjectChange(s){this.currentProject=s,!this.currentProject&&this.currentStep>1&&(this.currentStep=1)},onStepChange(s){!this.currentProject&&s>1||(this.currentStep=s)},async createCategory(s){if(this.categories.includes(s)){this.$message.warning("大类已存在");return}try{const e=`${this.reqBasePath}\\${s}`;await o.createDirectory(e),this.categories.push(s),this.categories.sort(),this.$message.success(`大类「${s}」创建成功`)}catch(e){console.error("Create category failed:",e),this.$message.error("创建大类失败")}},async renameCategory({oldName:s,newName:e}){if(this.categories.includes(e)){this.$message.warning("名称已存在");return}try{const t=`${this.reqBasePath}\\${s}`;await o.renameFile(t,e);const i=this.categories.indexOf(s);i>-1&&(this.categories[i]=e),this.categories.sort(),this.currentCategory===s&&(this.currentCategory=e,await this.loadProjectsForCategory(e)),await this.saveState(),this.$message.success(`已重命名为「${e}」`)}catch(t){console.error("Rename category failed:",t),this.$message.error("重命名大类失败")}},async deleteCategory(s){try{const e=`${this.reqBasePath}\\${s}`;await o.deleteFile(e),this.categories=this.categories.filter(t=>t!==s),this.currentCategory===s&&(this.currentCategory="",this.currentProject="",this.currentStep=1,this.projects={}),await this.saveState(),this.$message.success(`大类「${s}」已删除`)}catch(e){console.error("Delete category failed:",e),this.$message.error("删除大类失败")}},async createRequirement({category:s,name:e}){var n,r,g;if(this.projects[e]){this.$message.warning("需求已存在");return}try{const l=`${this.reqBasePath}\\${s}\\${e}`;await o.createDirectory(l)}catch(l){console.error("Create requirement directory failed:",l)}const t=`# ${e}方案
|
|
9
|
+
|
|
10
|
+
> 所属大类:${s}
|
|
11
|
+
|
|
12
|
+
## 业务目标
|
|
13
|
+
|
|
14
|
+
## 功能点
|
|
15
|
+
|
|
16
|
+
`;try{const l=`${this.reqBasePath}\\${s}\\${e}\\${e}_方案.md`;await o.writeFile(l,t)}catch(l){console.error("Write spec file failed:",l)}let i={designSessionId:"",codeSessionId:"",testSessionId:""};try{const[l,m,f]=await Promise.all([o.createSession(`workflow:${s}/${e}:design`),o.createSession(`workflow:${s}/${e}:code`),o.createSession(`workflow:${s}/${e}:test`)]);i={designSessionId:((n=l.data)==null?void 0:n.id)||"",codeSessionId:((r=m.data)==null?void 0:r.id)||"",testSessionId:((g=f.data)==null?void 0:g.id)||""};const y=`${this.reqBasePath}\\${s}\\${e}\\session.json`;await o.writeFile(y,JSON.stringify(i,null,2))}catch(l){console.error("Create sessions failed:",l)}const a=`${s}/${e}`;this.$set(this.projects,a,{name:e,stepStatus:{}}),this.currentCategory=s,this.currentProject=e,this.$message.success(`需求「${e}」创建成功`),this.$nextTick(()=>{this.currentStep=2})},async onSaveSpec(s){if(!this.projectKey)return;const e=`${this.reqBasePath}\\${this.currentCategory}\\${this.currentProject}\\${this.currentProject}_方案.md`;try{await o.writeFile(e,s),this.$message.success("方案已保存")}catch(t){console.error("Save spec failed:",t),this.$message.error("保存方案失败")}},saveSpec(){this.$refs.step2Ref&&this.$refs.step2Ref.saveSpec()},async refreshSpec(){var s;(s=this.$refs.step2Ref)!=null&&s.loadSpec&&await this.$refs.step2Ref.loadSpec(),this.$message.success("方案已刷新")}}};var z=function(){var e=this,t=e._self._c;return t("div",{staticClass:"dev-workflow-view"},[t("WorkflowSidebar",{ref:"sidebar",attrs:{categories:e.categories,projects:e.projects,"current-category":e.currentCategory,"current-project":e.currentProject,"current-step":e.currentStep,"is-loading":e.isLoadingProjects},on:{"category-change":e.onCategoryChange,"project-change":e.onProjectChange,"step-change":e.onStepChange,"delete-category":e.deleteCategory,"rename-category":e.renameCategory}}),t("div",{staticClass:"main-content"},[t("div",{staticClass:"panel-header"},[t("span",{staticClass:"panel-title"},[e._v(e._s(e.stepTitle))]),t("div",{staticClass:"panel-actions"},[e.currentStep===2?[t("el-button",{attrs:{type:"primary",plain:""},on:{click:e.saveSpec}},[t("i",{staticClass:"el-icon-save"}),e._v(" 保存方案 ")]),t("el-button",{attrs:{type:"info",plain:""},on:{click:e.refreshSpec}},[t("i",{staticClass:"el-icon-refresh"}),e._v(" 刷新方案 ")])]:e._e()],2)]),t("div",{staticClass:"step-content"},[t("Step1NewReq",{directives:[{name:"show",rawName:"v-show",value:e.currentStep===1,expression:"currentStep === 1"}],attrs:{categories:e.categories,projects:e.projects,"base-path":e.reqBasePath,"current-category":e.currentCategory,"current-project":e.currentProject},on:{"category-change":e.onCategoryChange,"project-change":e.onProjectChange,"create-category":e.createCategory,"create-requirement":e.createRequirement}}),e.currentStep===2&&e.hasSelectedProject?t("Step2Design",{ref:"step2Ref",attrs:{category:e.currentCategory,name:e.currentProject,"req-base-path":e.reqBasePath},on:{"update:sessionId":e.updateDesignSessionId,"save-spec":e.onSaveSpec,"spec-updated":e.refreshSpec}}):e._e(),e.currentStep===3&&e.hasSelectedProject?t("Step3CodeGen",{ref:"step3Ref",attrs:{category:e.currentCategory,name:e.currentProject,"req-base-path":e.reqBasePath},on:{"update:sessionId":e.updateCodeSessionId}}):e._e(),e.currentStep===4&&e.hasSelectedProject?t("Step4Test",{ref:"step4Ref",attrs:{category:e.currentCategory,name:e.currentProject,"req-base-path":e.reqBasePath},on:{"update:sessionId":e.updateTestSessionId}}):e._e()],1),t("div",{staticClass:"status-bar"},[t("span",[t("i",{staticClass:"el-icon-info"}),e._v(" "+e._s(e.statusText)+" ")]),t("span",[e._v(e._s(e.projectKey||"未选择项目"))])])])],1)},J=[],G=c(H,z,J,!1,null,"df83d415");const X=G.exports;export{X as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.workflow-sidebar[data-v-8e3cf2bb]{width:280px;background:#2d2d2d;border-right:1px solid #1e1e1e;display:flex;flex-direction:column;flex-shrink:0}.sidebar-header[data-v-8e3cf2bb]{padding:16px;border-bottom:1px solid #1e1e1e}.sidebar-header h3[data-v-8e3cf2bb]{font-size:14px;color:#84848a;margin-bottom:12px}.sidebar-header .el-select[data-v-8e3cf2bb]{width:100%;margin-bottom:8px}.project-display-row[data-v-8e3cf2bb]{display:flex;justify-content:space-between;gap:8px;margin-bottom:8px;padding:8px 10px;background:#ffffff0a;border:1px solid #3f3f46;border-radius:6px}.project-display-row .label[data-v-8e3cf2bb]{color:#84848a;font-size:12px}.project-display-row .value[data-v-8e3cf2bb]{color:#d4d4d8;font-size:12px;max-width:180px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.step-list[data-v-8e3cf2bb]{flex:1;overflow-y:auto;padding:16px}.step-item[data-v-8e3cf2bb]{display:flex;align-items:center;gap:12px;padding:14px 16px;border-radius:8px;margin-bottom:8px;cursor:pointer;transition:all .2s;border:1px solid transparent}.step-item[data-v-8e3cf2bb]:hover{background:#ffffff0d}.step-item.active[data-v-8e3cf2bb]{background:#409eff26;border-color:#409eff}.step-item.completed .step-icon[data-v-8e3cf2bb]{background:#22c55e}.step-item.active .step-icon[data-v-8e3cf2bb]{background:#409eff}.step-icon[data-v-8e3cf2bb]{width:32px;height:32px;border-radius:50%;display:flex;align-items:center;justify-content:center;font-size:14px;color:#fff;flex-shrink:0}.step-info[data-v-8e3cf2bb]{flex:1}.step-title[data-v-8e3cf2bb]{font-size:14px;font-weight:500;margin-bottom:2px;color:#f4f4f5}.step-desc[data-v-8e3cf2bb]{font-size:12px;color:#84848a}.step-status[data-v-8e3cf2bb]{font-size:14px}.step1-container[data-v-bf976168]{height:100%;padding:24px;overflow:hidden}.step1-main[data-v-bf976168]{max-width:600px;margin:0 auto}.panel-section[data-v-bf976168]{background:#121212;border:1px solid #1e1e1e;border-radius:8px;overflow:hidden}.panel-section-header[data-v-bf976168]{background:#121212;border-bottom:1px solid #1e1e1e;padding:12px 16px;font-size:14px;font-weight:500;display:flex;align-items:center;justify-content:space-between;color:#f4f4f5}.panel-section-header .el-button[data-v-bf976168]{padding:4px 8px;font-size:12px}.panel-section-body[data-v-bf976168]{padding:24px}.form-hint[data-v-bf976168]{font-size:12px;color:#84848a;margin-top:8px}.form-hint code[data-v-bf976168]{background:#18191b;padding:2px 6px;border-radius:4px;font-family:ui-monospace,monospace;color:#409eff}.flex[data-v-bf976168]{display:flex}.gap-2[data-v-bf976168]{gap:8px}.step2-container[data-v-aa4cddfa]{height:100%;display:flex;flex-direction:column}.step2-main[data-v-aa4cddfa]{display:flex;flex:1;gap:16px;overflow:hidden;padding:16px}.editor-panel[data-v-aa4cddfa]{flex:1;min-width:300px;background:#121212;border:1px solid #1e1e1e;border-radius:8px;overflow:hidden;display:flex;flex-direction:column}.editor-header[data-v-aa4cddfa]{background:#121212;border-bottom:1px solid #1e1e1e;padding:12px 16px;font-size:13px;color:#84848a;display:flex;align-items:center;gap:8px}.editor-container[data-v-aa4cddfa]{flex:1;min-height:0}.chat-panel[data-v-aa4cddfa]{width:480px;background:#121212;border:1px solid #1e1e1e;border-radius:8px;overflow:hidden;display:flex;flex-direction:column;flex-shrink:0}.panel-header[data-v-aa4cddfa]{background:#121212;border-bottom:1px solid #1e1e1e;padding:12px 16px;font-size:14px;font-weight:500;color:#f4f4f5;flex-shrink:0}.chat-messages[data-v-aa4cddfa]{flex:1;overflow-y:auto;padding:0 16px 16px;font-size:14px;line-height:1.6}.empty-state[data-v-aa4cddfa]{display:flex;flex-direction:column;align-items:center;justify-content:center;height:100%;color:#84848a}.empty-state i[data-v-aa4cddfa]{font-size:48px;margin-bottom:16px;opacity:.5}.todos-list[data-v-aa4cddfa]{margin-bottom:16px;color:#d4d4d8}.todo-item[data-v-aa4cddfa]{display:flex;align-items:center;gap:8px;padding:2px 0}.user-question[data-v-aa4cddfa]{color:#60a5fa;font-weight:700;margin-bottom:16px}.user-question[data-v-aa4cddfa] p{color:#d4d4d8;font-weight:400;margin:0 0 8px}.ai-thought[data-v-aa4cddfa]{color:#d4d4d8;margin-bottom:16px}.log-mute[data-v-aa4cddfa]{color:#84848a;margin-bottom:16px;white-space:pre}.tool-success[data-v-aa4cddfa]{color:#22c55e}.tool-fail[data-v-aa4cddfa]{color:#ef4444}.tool-input[data-v-aa4cddfa]{color:#60a5fa;margin-left:8px}.build-info[data-v-aa4cddfa]{color:#84848a;display:flex;align-items:center;gap:8px;margin-bottom:16px}.chat-input-area[data-v-aa4cddfa]{border-top:1px solid #1e1e1e;padding:12px 16px;background:#121212;display:flex;flex-direction:column;gap:8px;flex-shrink:0}.input-area[data-v-aa4cddfa]{width:100%}.input-actions[data-v-aa4cddfa]{display:flex;justify-content:flex-end;gap:8px}.status-bar[data-v-aa4cddfa]{display:flex;gap:8px;align-items:center;padding:6px 16px;font-size:12px;color:#84848a;border-top:1px solid #1e1e1e;flex-shrink:0;flex-wrap:wrap;background:#0a0a09}.status-bar .separator[data-v-aa4cddfa]{color:#3f3f46}.status-ready[data-v-aa4cddfa]{color:#22c55e}.status-thinking[data-v-aa4cddfa]{color:#60a5fa}.thinking-spinner[data-v-aa4cddfa]{display:inline-block;width:12px;height:12px;border:2px solid #60a5fa;border-top-color:transparent;border-radius:50%;animation:spin-aa4cddfa .8s linear infinite}@keyframes spin-aa4cddfa{to{transform:rotate(360deg)}}.model-selector[data-v-aa4cddfa]{cursor:pointer}.model-selector[data-v-aa4cddfa]:hover{color:#60a5fa}.step3-container[data-v-c21cb50f]{height:100%;display:flex;flex-direction:column}.step3-main[data-v-c21cb50f]{display:flex;flex:1;overflow:hidden;padding:16px}.code-chat-panel[data-v-c21cb50f]{flex:1;background:#121212;border:1px solid #1e1e1e;border-radius:8px;overflow:hidden;display:flex;flex-direction:column}.panel-header[data-v-c21cb50f]{display:flex;justify-content:space-between;align-items:center;padding:12px 16px;background:#121212;border-bottom:1px solid #1e1e1e;flex-shrink:0}.panel-header span[data-v-c21cb50f]{font-size:14px;font-weight:500;color:#f4f4f5}.header-actions[data-v-c21cb50f]{display:flex;gap:8px}.chat-messages[data-v-c21cb50f]{flex:1;overflow-y:auto;padding:16px;font-size:14px;line-height:1.6}.empty-state[data-v-c21cb50f]{display:flex;flex-direction:column;align-items:center;justify-content:center;height:100%;color:#84848a}.empty-state i[data-v-c21cb50f]{font-size:48px;margin-bottom:16px;opacity:.5}.todos-list[data-v-c21cb50f]{margin-bottom:16px;color:#d4d4d8}.todo-item[data-v-c21cb50f]{display:flex;align-items:center;gap:8px;padding:2px 0}.user-question[data-v-c21cb50f]{color:#60a5fa;font-weight:700;margin-bottom:16px}.user-question[data-v-c21cb50f] p{color:#d4d4d8;font-weight:400;margin:0 0 8px}.ai-thought[data-v-c21cb50f]{color:#d4d4d8;margin-bottom:16px}.log-mute[data-v-c21cb50f]{color:#84848a;margin-bottom:16px;white-space:pre}.tool-success[data-v-c21cb50f]{color:#22c55e}.tool-fail[data-v-c21cb50f]{color:#ef4444}.tool-input[data-v-c21cb50f]{color:#60a5fa;margin-left:8px}.build-info[data-v-c21cb50f]{color:#84848a;display:flex;align-items:center;gap:8px;margin-bottom:16px}.chat-input-area[data-v-c21cb50f]{border-top:1px solid #1e1e1e;padding:12px 16px;background:#121212;display:flex;flex-direction:column;gap:8px;flex-shrink:0}.input-area[data-v-c21cb50f]{width:100%}.input-actions[data-v-c21cb50f]{display:flex;justify-content:flex-end;gap:8px}.status-bar[data-v-c21cb50f]{display:flex;gap:8px;align-items:center;padding:6px 16px;font-size:12px;color:#84848a;border-top:1px solid #1e1e1e;flex-shrink:0;flex-wrap:wrap;background:#0a0a09}.status-bar .separator[data-v-c21cb50f]{color:#3f3f46}.status-ready[data-v-c21cb50f]{color:#22c55e}.status-thinking[data-v-c21cb50f]{color:#60a5fa}.thinking-spinner[data-v-c21cb50f]{display:inline-block;width:12px;height:12px;border:2px solid #60a5fa;border-top-color:transparent;border-radius:50%;animation:spin-c21cb50f .8s linear infinite}@keyframes spin-c21cb50f{to{transform:rotate(360deg)}}.model-selector[data-v-c21cb50f]{cursor:pointer}.model-selector[data-v-c21cb50f]:hover{color:#60a5fa}.step4-container[data-v-bc0169a8]{height:100%;display:flex;flex-direction:column}.step4-main[data-v-bc0169a8]{display:flex;flex:1;overflow:hidden;padding:16px}.code-chat-panel[data-v-bc0169a8]{flex:1;background:#121212;border:1px solid #1e1e1e;border-radius:8px;overflow:hidden;display:flex;flex-direction:column}.panel-header[data-v-bc0169a8]{display:flex;justify-content:space-between;align-items:center;padding:12px 16px;background:#121212;border-bottom:1px solid #1e1e1e;flex-shrink:0}.panel-header span[data-v-bc0169a8]{font-size:14px;font-weight:500;color:#f4f4f5}.chat-messages[data-v-bc0169a8]{flex:1;overflow-y:auto;padding:16px;font-size:14px;line-height:1.6}.empty-state[data-v-bc0169a8]{display:flex;flex-direction:column;align-items:center;justify-content:center;height:100%;color:#84848a}.empty-state i[data-v-bc0169a8]{font-size:48px;margin-bottom:16px;opacity:.5}.todos-list[data-v-bc0169a8]{margin-bottom:16px;color:#d4d4d8}.todo-item[data-v-bc0169a8]{display:flex;align-items:center;gap:8px;padding:2px 0}.user-question[data-v-bc0169a8]{color:#60a5fa;font-weight:700;margin-bottom:16px}.user-question[data-v-bc0169a8] p{color:#d4d4d8;font-weight:400;margin:0 0 8px}.ai-thought[data-v-bc0169a8]{color:#d4d4d8;margin-bottom:16px}.log-mute[data-v-bc0169a8]{color:#84848a;margin-bottom:16px;white-space:pre}.tool-success[data-v-bc0169a8]{color:#22c55e}.tool-fail[data-v-bc0169a8]{color:#ef4444}.tool-input[data-v-bc0169a8]{color:#60a5fa;margin-left:8px}.build-info[data-v-bc0169a8]{color:#84848a;display:flex;align-items:center;gap:8px;margin-bottom:16px}.chat-input-area[data-v-bc0169a8]{border-top:1px solid #1e1e1e;padding:12px 16px;background:#121212;display:flex;flex-direction:column;gap:8px;flex-shrink:0}.input-area[data-v-bc0169a8]{width:100%}.input-actions[data-v-bc0169a8]{display:flex;justify-content:flex-end;gap:8px}.status-bar[data-v-bc0169a8]{display:flex;gap:8px;align-items:center;padding:6px 16px;font-size:12px;color:#84848a;border-top:1px solid #1e1e1e;flex-shrink:0;flex-wrap:wrap;background:#0a0a09}.status-bar .separator[data-v-bc0169a8]{color:#3f3f46}.status-ready[data-v-bc0169a8]{color:#22c55e}.status-thinking[data-v-bc0169a8]{color:#60a5fa}.thinking-spinner[data-v-bc0169a8]{display:inline-block;width:12px;height:12px;border:2px solid #60a5fa;border-top-color:transparent;border-radius:50%;animation:spin-bc0169a8 .8s linear infinite}@keyframes spin-bc0169a8{to{transform:rotate(360deg)}}.model-selector[data-v-bc0169a8]{cursor:pointer}.model-selector[data-v-bc0169a8]:hover{color:#60a5fa}.dev-workflow-view[data-v-df83d415]{display:flex;height:100%;overflow:hidden;background:#0a0a09}.main-content[data-v-df83d415]{flex:1;display:flex;flex-direction:column;overflow:hidden}.panel-header[data-v-df83d415]{background:#121212;border-bottom:1px solid #1e1e1e;padding:12px 24px;display:flex;align-items:center;justify-content:space-between;flex-shrink:0}.panel-title[data-v-df83d415]{font-size:16px;font-weight:500;color:#f4f4f5}.panel-actions[data-v-df83d415]{display:flex;gap:12px}.step-content[data-v-df83d415]{flex:1;overflow:hidden}.status-bar[data-v-df83d415]{background:#121212;border-top:1px solid #1e1e1e;padding:8px 24px;font-size:12px;color:#84848a;display:flex;align-items:center;justify-content:space-between;flex-shrink:0}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{n,e as o,K as c,b as d,a as r}from"./index-
|
|
1
|
+
import{n,e as o,K as c,b as d,a as r}from"./index-BR2hcxRn.js";const f={name:"GitChangesSidebar",props:{changes:{type:Array,default:()=>[]},selectedPath:{type:String,default:null},isRepo:{type:Boolean,default:!1},loading:{type:Boolean,default:!1},width:{type:Number,default:320}},methods:{getStatusClass(s){return{modified:"bg-blue-600 text-white",added:"bg-green-600 text-white",deleted:"bg-red-600 text-white",untracked:"bg-gray-600 text-white",renamed:"bg-purple-600 text-white"}[s]||"bg-gray-600 text-white"},getFileName(s){return s.split("/").pop()||s.split("\\").pop()||s},getDirPath(s){const t=s.split("/");return t.pop(),t.join("/")||"."}}};var h=function(){var t=this,e=t._self._c;return e("aside",{staticClass:"bg-sidebar border-r border-border flex flex-col shrink-0",style:{width:t.width+"px"}},[e("div",{staticClass:"flex border-b border-border text-xs uppercase font-bold text-textMuted"},[t._m(0),e("button",{staticClass:"ml-auto px-3 py-2 hover:text-white text-textMuted",attrs:{title:"刷新"},on:{click:function(i){return t.$emit("refresh")}}},[e("i",{staticClass:"fa-solid fa-refresh"})]),e("button",{staticClass:"px-3 py-2 hover:text-yellow-400 text-textMuted disabled:opacity-30",attrs:{disabled:t.changes.length===0,title:"撤销全部"},on:{click:function(i){return t.$emit("revert-all")}}},[e("i",{staticClass:"fa-solid fa-undo-alt"})])]),e("div",{staticClass:"flex-1 overflow-y-auto py-1 sidebar-scroll"},[t.loading?e("div",{staticClass:"flex items-center justify-center py-8 text-textMuted"},[e("i",{staticClass:"fa-solid fa-spinner fa-spin mr-2"}),t._v(" 加载中... ")]):t.isRepo?t.changes.length===0?e("div",{staticClass:"flex items-center justify-center py-8 text-textMuted text-sm"},[t._m(2)]):e("div",t._l(t.changes,function(i){return e("div",{key:i.path,staticClass:"px-3 py-2 cursor-pointer border-b border-border/50 hover:bg-[#2a2a2a] transition-colors",class:t.selectedPath===i.path?"bg-[#2a2a2a] border-l-2 border-l-accent":"",on:{click:function(a){return t.$emit("select",i)}}},[e("div",{staticClass:"flex items-center gap-2"},[e("span",{staticClass:"text-xs font-bold px-1.5 py-0.5 rounded shrink-0",class:t.getStatusClass(i.status)},[t._v(" "+t._s(i.statusCode)+" ")]),e("div",{staticClass:"flex-1 min-w-0"},[e("div",{staticClass:"text-sm text-gray-200 truncate",attrs:{title:i.path}},[t._v(" "+t._s(t.getFileName(i.path))+" ")]),e("div",{staticClass:"text-xs text-gray-500 truncate",attrs:{title:i.path}},[t._v(" "+t._s(t.getDirPath(i.path))+" ")])]),e("div",{staticClass:"flex items-center gap-1 shrink-0",on:{click:function(a){a.stopPropagation()}}},[e("button",{staticClass:"p-1 text-gray-500 hover:text-blue-400 transition-colors",attrs:{title:"打开"},on:{click:function(a){return t.$emit("open-file",i)}}},[e("i",{staticClass:"fa-solid fa-external-link-alt text-xs"})]),e("button",{staticClass:"p-1 text-gray-500 hover:text-yellow-400 transition-colors",attrs:{title:"撤销"},on:{click:function(a){return t.$emit("revert",i)}}},[e("i",{staticClass:"fa-solid fa-undo text-xs"})])])])])}),0):e("div",{staticClass:"flex items-center justify-center py-8 text-textMuted text-sm"},[t._m(1)])]),e("div",{staticClass:"border-t border-border px-3 py-2 text-xs text-textMuted"},[e("span",[t._v(t._s(t.changes.length)+" 个文件变更")])])])},u=[function(){var s=this,t=s._self._c;return t("div",{staticClass:"px-4 py-2 border-b-2 border-accent text-white flex items-center gap-2"},[t("i",{staticClass:"fa-brands fa-git-alt"}),s._v(" Git Changes ")])},function(){var s=this,t=s._self._c;return t("div",{staticClass:"text-center"},[t("i",{staticClass:"fa-brands fa-git-alt text-4xl mb-4 opacity-30"}),t("p",[s._v("当前目录不是 Git 仓库")])])},function(){var s=this,t=s._self._c;return t("div",{staticClass:"text-center"},[t("i",{staticClass:"fa-solid fa-check-circle text-4xl mb-4 opacity-30 text-green-500"}),t("p",[s._v("没有待提交的变更")])])}],g=n(f,h,u,!1,null,"42cc079f");const p=g.exports,x={name:"DiffViewer",props:{change:{type:Object,default:null},diffContent:{type:String,default:""},loading:{type:Boolean,default:!1}},data(){return{oldLines:[],newLines:[]}},watch:{diffContent:{immediate:!0,handler(s){this.parseDiff(s)}}},methods:{getStatusClass(s){return{modified:"bg-blue-600 text-white",added:"bg-green-600 text-white",deleted:"bg-red-600 text-white",untracked:"bg-gray-600 text-white",renamed:"bg-purple-600 text-white"}[s]||"bg-gray-600 text-white"},getLinePrefix(s){return s.removed?"-":s.added?"+":" "},getLineClass(s){return s.type==="header"?"bg-[#1a1a1a] text-blue-400":s.removed?"bg-red-900/50 text-red-300":s.added?"bg-green-900/50 text-green-300":s.empty?"bg-[#252525]":"text-gray-200"},parseDiff(s){if(this.oldLines=[],this.newLines=[],!s)return;const t=s.split(`
|
|
2
2
|
`);let e=1,i=1;for(const a of t)if(a.startsWith("@@")){const l=a.match(/@@ -(\d+),?\d* \+(\d+),?\d* @@/);l&&(e=parseInt(l[1]),i=parseInt(l[2])),this.oldLines.push({lineNum:"",content:a,type:"header"}),this.newLines.push({lineNum:"",content:a,type:"header"})}else a.startsWith("---")||a.startsWith("+++")||a.startsWith("diff ")||a.startsWith("index ")||(a.startsWith("-")?(this.oldLines.push({lineNum:e++,content:a.substring(1),removed:!0}),this.newLines.push({lineNum:"",content:"",empty:!0})):a.startsWith("+")?(this.oldLines.push({lineNum:"",content:"",empty:!0}),this.newLines.push({lineNum:i++,content:a.substring(1),added:!0})):(this.oldLines.push({lineNum:e++,content:a}),this.newLines.push({lineNum:i++,content:a})))}}};var v=function(){var t=this,e=t._self._c;return e("div",{staticClass:"flex-1 flex flex-col overflow-hidden"},[t.change?e("div",{staticClass:"flex-1 flex flex-col overflow-hidden"},[e("div",{staticClass:"flex items-center justify-between px-4 py-2 border-b border-border bg-sidebar"},[e("div",{staticClass:"flex items-center gap-2"},[e("span",{staticClass:"text-xs font-bold px-1.5 py-0.5 rounded",class:t.getStatusClass(t.change.status)},[t._v(" "+t._s(t.change.statusCode)+" ")]),e("span",{staticClass:"text-white text-sm"},[t._v(t._s(t.change.path))])]),e("div",{staticClass:"flex items-center gap-2"},[e("button",{staticClass:"px-3 py-1 text-xs bg-blue-600 hover:bg-blue-700 text-white rounded",on:{click:function(i){return t.$emit("open-file",t.change)}}},[e("i",{staticClass:"fa-solid fa-external-link-alt mr-1"}),t._v(" 打开文件 ")]),e("button",{staticClass:"px-3 py-1 text-xs bg-yellow-600 hover:bg-yellow-700 text-white rounded",on:{click:function(i){return t.$emit("revert",t.change)}}},[e("i",{staticClass:"fa-solid fa-undo mr-1"}),t._v(" 撤销 ")])])]),t.loading?e("div",{staticClass:"flex-1 flex items-center justify-center text-textMuted"},[e("i",{staticClass:"fa-solid fa-spinner fa-spin mr-2"}),t._v(" 加载 diff 中... ")]):t.diffContent?e("div",{staticClass:"flex-1 flex overflow-hidden"},[e("div",{staticClass:"flex-1 flex flex-col overflow-hidden border-r border-border"},[e("div",{staticClass:"px-4 py-2 bg-[#3c3c3c] border-b border-border text-xs text-gray-300 font-bold"},[t._v(" 旧版本 (Original) ")]),e("div",{staticClass:"flex-1 overflow-auto bg-[#2d2d2d]"},t._l(t.oldLines,function(i,a){return e("div",{key:"old-"+a,staticClass:"flex font-mono text-sm",class:t.getLineClass(i)},[e("span",{staticClass:"w-12 shrink-0 text-right pr-2 select-none opacity-40"},[t._v(t._s(i.lineNum||""))]),e("span",{staticClass:"flex-1 whitespace-pre"},[e("span",{staticClass:"select-none font-bold w-4 inline-block"},[t._v(t._s(t.getLinePrefix(i)))]),t._v(t._s(i.content))])])}),0)]),e("div",{staticClass:"flex-1 flex flex-col overflow-hidden"},[e("div",{staticClass:"px-4 py-2 bg-[#3c3c3c] border-b border-border text-xs text-gray-300 font-bold"},[t._v(" 新版本 (Modified) ")]),e("div",{staticClass:"flex-1 overflow-auto bg-[#2d2d2d]"},t._l(t.newLines,function(i,a){return e("div",{key:"new-"+a,staticClass:"flex font-mono text-sm",class:t.getLineClass(i)},[e("span",{staticClass:"w-12 shrink-0 text-right pr-2 select-none opacity-40"},[t._v(t._s(i.lineNum||""))]),e("span",{staticClass:"flex-1 whitespace-pre"},[e("span",{staticClass:"select-none font-bold w-4 inline-block"},[t._v(t._s(t.getLinePrefix(i)))]),t._v(t._s(i.content))])])}),0)])]):e("div",{staticClass:"flex-1 flex items-center justify-center text-textMuted"},[t._m(1)])]):e("div",{staticClass:"flex-1 flex items-center justify-center text-textMuted"},[t._m(0)])])},m=[function(){var s=this,t=s._self._c;return t("div",{staticClass:"text-center"},[t("i",{staticClass:"fa-solid fa-code text-6xl mb-4 opacity-20"}),t("p",[s._v("点击文件查看变更详情")])])},function(){var s=this,t=s._self._c;return t("div",{staticClass:"text-center"},[t("i",{staticClass:"fa-solid fa-file text-4xl mb-4 opacity-30"}),t("p",[s._v("无法显示此文件的 diff")])])}],b=n(x,v,m,!1,null,null);const C=b.exports,_=console.error;console.error=(...s)=>{var t;(t=s[0])!=null&&t.toString().includes("toUrl")||_(...s)};const y={name:"FileViewerModal",data(){return{visible:!1,fullPath:"",fileStatus:null,loading:!1,saving:!1,editor:null,originalContent:""}},computed:{filePath(){if(!this.fullPath)return"";const s=this.fullPath.split("/");return s[s.length-1]},hasChanges(){return this.editor?this.editor.getValue()!==this.originalContent:!1},statusCode(){return this.fileStatus&&this.fileStatus.statusCode||""},statusClass(){return this.fileStatus&&{modified:"bg-blue-600 text-white",added:"bg-green-600 text-white",deleted:"bg-red-600 text-white",untracked:"bg-gray-600 text-white",renamed:"bg-purple-600 text-white"}[this.fileStatus.status]||"bg-gray-600 text-white"}},beforeDestroy(){this.destroyEditor()},methods:{async open(s,t=null){this.fullPath=s,this.fileStatus=t,this.visible=!0,this.loading=!0;try{const e=await r.getFileContent(s);this.originalContent=e.content||"",this.$nextTick(()=>{this.initEditor(this.originalContent)})}catch(e){console.error("Failed to load file:",e),this.$message.error("加载文件失败")}finally{this.loading=!1}},close(){this.visible=!1},async save(){if(!(!this.fullPath||!this.hasChanges)){this.saving=!0;try{await r.writeFile(this.fullPath,this.editor.getValue()),this.originalContent=this.editor.getValue(),this.$message.success("文件已保存")}catch(s){console.error("Save file failed:",s),this.$message.error("保存文件失败")}finally{this.saving=!1}}},initEditor(s){console.log("-----------initEditor called with content length:",s.length),this.$refs.editorContainer&&(console.log("-----------initEditor called with content length:aaaa",s.length),this.editor=o.create(this.$refs.editorContainer,{value:s||"",language:this.getLanguage(),theme:"vs-dark",automaticLayout:!0,minimap:{enabled:!1},scrollBeyondLastLine:!1,fontSize:14,fontFamily:'Consolas, Monaco, "Courier New", monospace',lineNumbers:"on",scrollbar:{useShadows:!1,vertical:"auto",horizontal:"auto"}}),this.editor.addCommand(c.CtrlCmd|d.KeyS,()=>{this.save()}))},destroyEditor(){this.editor&&(this.editor.dispose(),this.editor=null)},getLanguage(){const s=this.filePath.split(".").pop().toLowerCase();return{js:"javascript",ts:"typescript",html:"html",css:"css",vue:"html",py:"python",md:"markdown",json:"json",yaml:"yaml",yml:"yaml",xml:"xml",sql:"sql",sh:"shell",go:"go",rs:"rust",java:"java",cpp:"cpp",c:"c",jsx:"javascript",tsx:"typescript"}[s]||"plaintext"}}};var w=function(){var t=this,e=t._self._c;return t.visible?e("div",{staticClass:"fixed inset-0 bg-black/70 flex items-center justify-center z-50",on:{click:function(i){return i.target!==i.currentTarget?null:t.close.apply(null,arguments)}}},[e("div",{staticClass:"bg-sidebar border border-border rounded-lg w-[90%] h-[80%] flex flex-col overflow-hidden"},[e("div",{staticClass:"flex items-center justify-between px-4 py-3 border-b border-border"},[e("div",{staticClass:"flex items-center gap-2"},[t.fileStatus?e("span",{staticClass:"text-xs font-bold px-1.5 py-0.5 rounded",class:t.statusClass},[t._v(" "+t._s(t.statusCode)+" ")]):t._e(),e("span",{staticClass:"text-white text-sm"},[t._v(t._s(t.filePath))])]),e("button",{staticClass:"text-gray-400 hover:text-white",on:{click:t.close}},[e("i",{staticClass:"fa-solid fa-times text-lg"})])]),e("div",{staticClass:"flex-1 overflow-hidden bg-[#1e1e1e]"},[e("div",{ref:"editorContainer",staticClass:"w-full h-full"})]),e("div",{staticClass:"h-8 bg-sidebar border-t border-border flex items-center justify-between px-3"},[e("div",{staticClass:"flex items-center gap-4 text-xs text-gray-400"},[e("span",[t._v(t._s(t.fullPath))]),t.hasChanges?e("span",{staticClass:"text-yellow-500"},[t._v("已修改")]):t._e()]),e("div",{staticClass:"flex items-center gap-2"},[e("button",{staticClass:"px-3 py-1 text-xs bg-primary hover:bg-blue-600 disabled:opacity-50 disabled:cursor-not-allowed text-white rounded",attrs:{disabled:!t.hasChanges||t.saving},on:{click:t.save}},[t.saving?e("i",{staticClass:"fa-solid fa-spinner fa-spin mr-1"}):e("i",{staticClass:"fa-solid fa-save mr-1"}),t._v(" 保存 ")])])])])]):t._e()},$=[],R=n(y,w,$,!1,null,null);const k=R.exports,L={name:"ConfirmDialog",props:{visible:{type:Boolean,default:!1},message:{type:String,default:""}}};var D=function(){var t=this,e=t._self._c;return t.visible?e("div",{staticClass:"fixed inset-0 bg-black/50 flex items-center justify-center z-50"},[e("div",{staticClass:"bg-sidebar border border-border rounded p-4 w-96"},[e("p",{staticClass:"text-gray-200 text-sm mb-4"},[t._v(t._s(t.message))]),e("div",{staticClass:"flex justify-end gap-2"},[e("button",{staticClass:"px-3 py-1 text-xs text-gray-400 hover:text-white",on:{click:function(i){return t.$emit("cancel")}}},[t._v("取消")]),e("button",{staticClass:"px-3 py-1 text-xs bg-red-600 text-white rounded hover:bg-red-700",on:{click:function(i){return t.$emit("confirm")}}},[t._v("确定")])])])]):t._e()},S=[],j=n(L,D,S,!1,null,null);const F=j.exports,z={name:"GitChanges",components:{GitChangesSidebar:p,DiffViewer:C,FileViewerModal:k,ConfirmDialog:F},data(){return{isRepo:!1,gitRoot:null,changes:[],selectedChange:null,diffContent:null,loading:!1,diffLoading:!1,sidebarWidth:320,isResizing:!1,confirmDialog:{visible:!1,message:"",action:null,target:null}}},async created(){await this.checkRepo(),await this.refreshChanges(),document.addEventListener("mousemove",this.handleResize),document.addEventListener("mouseup",this.stopResize)},beforeDestroy(){document.removeEventListener("mousemove",this.handleResize),document.removeEventListener("mouseup",this.stopResize)},methods:{async checkRepo(){try{const s=await r.gitIsRepo();this.isRepo=s.isRepo,this.gitRoot=s.gitRoot}catch{this.isRepo=!1}},async refreshChanges(){if(this.isRepo){this.loading=!0;try{const s=await r.gitStatus();this.changes=s.changes||[],this.selectedChange&&(this.changes.find(e=>e.path===this.selectedChange.path)||(this.selectedChange=null,this.diffContent=null))}catch(s){console.error("Failed to get git status:",s),this.$message.error("获取变更列表失败")}finally{this.loading=!1}}},async refresh(){await this.refreshChanges(),this.selectedChange&&await this.loadDiff(this.selectedChange)},selectChange(s){this.selectedChange=s,this.loadDiff(s)},async loadDiff(s){this.diffLoading=!0,this.diffContent=null;try{const t=await r.gitDiff(s.path);this.diffContent=t.diff||""}catch(t){console.error("Failed to get diff:",t),this.diffContent=""}finally{this.diffLoading=!1}},async openFile(s){var e;const t=this.gitRoot?`${this.gitRoot.replace(/\\/g,"/")}/${s.path}`:s.path;(e=this.$refs.fileModalRef)==null||e.open(t,s)},revertFile(s){const t=s.isNew?"delete":"revert",e=s.isNew?`确定要删除未跟踪的文件 "${s.path}" 吗?`:`确定要撤销对 "${s.path}" 的修改吗?`;this.confirmDialog={visible:!0,message:e,action:t,target:s}},confirmRevertAll(){this.changes.length!==0&&(this.confirmDialog={visible:!0,message:`确定要撤销所有 ${this.changes.length} 个文件的变更吗?此操作不可恢复。`,action:"revertAll",target:null})},cancelConfirm(){this.confirmDialog.visible=!1},async executeConfirm(){const{action:s,target:t}=this.confirmDialog;this.confirmDialog.visible=!1;try{s==="revertAll"?(await r.gitRevertAll(),await r.gitDiscardUntracked(),this.$message.success("所有变更已撤销")):s==="revert"?(await r.gitRevert(t.path),this.$message.success("文件已撤销")):s==="delete"&&(await r.gitDeleteFile(t.path),this.$message.success("文件已删除")),await this.refreshChanges()}catch(e){console.error("Operation failed:",e),this.$message.error("操作失败: "+(e.message||"未知错误"))}},startResize(s){this.isResizing=!0,document.body.style.cursor="col-resize",document.body.style.userSelect="none"},handleResize(s){if(!this.isResizing)return;const t=s.clientX;t>=200&&t<=500&&(this.sidebarWidth=t)},stopResize(){this.isResizing=!1,document.body.style.cursor="",document.body.style.userSelect=""}}};var M=function(){var i;var t=this,e=t._self._c;return e("div",{staticClass:"flex-1 flex overflow-hidden"},[e("git-changes-sidebar",{attrs:{width:t.sidebarWidth,changes:t.changes,"selected-path":(i=t.selectedChange)==null?void 0:i.path,"is-repo":t.isRepo,loading:t.loading},on:{refresh:t.refresh,select:t.selectChange,"open-file":t.openFile,revert:t.revertFile,"revert-all":t.confirmRevertAll}}),e("div",{staticClass:"w-1 bg-border hover:bg-accent cursor-col-resize transition-colors shrink-0",on:{mousedown:t.startResize}}),e("diff-viewer",{attrs:{change:t.selectedChange,"diff-content":t.diffContent,loading:t.diffLoading},on:{"open-file":t.openFile,revert:t.revertFile}}),e("file-viewer-modal",{ref:"fileModalRef"}),e("confirm-dialog",{attrs:{visible:t.confirmDialog.visible,message:t.confirmDialog.message},on:{confirm:t.executeConfirm,cancel:t.cancelConfirm}})],1)},N=[],P=n(z,M,N,!1,null,null);const W=P.exports;export{W as default};
|