tianxincode 1.0.39 → 1.0.41
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/dist/api/config.routes.js +16 -0
- package/dist/api/config.routes.js.map +1 -1
- package/dist/modules/ai/deepseek.provider.d.ts +1 -0
- package/dist/modules/ai/deepseek.provider.d.ts.map +1 -1
- package/dist/modules/ai/deepseek.provider.js +6 -2
- package/dist/modules/ai/deepseek.provider.js.map +1 -1
- package/dist/modules/ai/openai.provider.d.ts +1 -0
- package/dist/modules/ai/openai.provider.d.ts.map +1 -1
- package/dist/modules/ai/openai.provider.js +6 -2
- package/dist/modules/ai/openai.provider.js.map +1 -1
- package/dist/modules/ai/provider.d.ts.map +1 -1
- package/dist/modules/ai/provider.js +20 -0
- package/dist/modules/ai/provider.js.map +1 -1
- package/dist/modules/config/config.service.d.ts +3 -1
- package/dist/modules/config/config.service.d.ts.map +1 -1
- package/dist/modules/config/config.service.js +36 -0
- package/dist/modules/config/config.service.js.map +1 -1
- package/dist/modules/config/config.types.d.ts +6 -0
- package/dist/modules/config/config.types.d.ts.map +1 -1
- package/dist/modules/config/config.types.js.map +1 -1
- package/dist/modules/db/db.service.d.ts +1 -0
- package/dist/modules/db/db.service.d.ts.map +1 -1
- package/dist/modules/db/db.service.js +16 -0
- package/dist/modules/db/db.service.js.map +1 -1
- package/dist/modules/gateway/gateway.service.d.ts.map +1 -1
- package/dist/modules/gateway/gateway.service.js +0 -6
- package/dist/modules/gateway/gateway.service.js.map +1 -1
- package/dist/service/config-export-import.service.d.ts +6 -0
- package/dist/service/config-export-import.service.d.ts.map +1 -1
- package/dist/service/config-export-import.service.js +12 -0
- package/dist/service/config-export-import.service.js.map +1 -1
- package/package.json +2 -1
- package/web/dist/assets/{AiLogsView-DyWYCMia.js → AiLogsView-D4q7SeY_.js} +1 -1
- package/web/dist/assets/{ConfirmDialog-B7xoYLNo.js → ConfirmDialog-BG4cU7oU.js} +1 -1
- package/web/dist/assets/{CustomActionsView-Bz0FJhS4.js → CustomActionsView-DTvj_4OE.js} +1 -1
- package/web/dist/assets/{DevWorkflowView-CU2_o5uq.js → DevWorkflowView-BjUv5lsU.js} +1 -1
- package/web/dist/assets/{DevWorkflowViewApp-pt4oKglX.js → DevWorkflowViewApp-D8czrLj2.js} +1 -1
- package/web/dist/assets/{GitChanges-Y__3euKt.js → GitChanges-DxJT8Ng9.js} +1 -1
- package/web/dist/assets/{GitChangesApp-n1OxZEvL.js → GitChangesApp-DGRKqsrc.js} +1 -1
- package/web/dist/assets/{Layout-CilYY1KK.js → Layout-CIntssMR.js} +1 -1
- package/web/dist/assets/{TasksView-CHnpwvyb.js → TasksView-DuTglEsf.js} +1 -1
- package/web/dist/assets/{TerminalView-C3s5BbKP.js → TerminalView-RG937_-M.js} +1 -1
- package/web/dist/assets/{WikiView-B10BVOEI.js → WikiView-wDIfjQT_.js} +1 -1
- package/web/dist/assets/{cssMode-D518Vum_.js → cssMode-DAdY-5X0.js} +1 -1
- package/web/dist/assets/{deployView-D4BgJiy-.js → deployView-OlhJU698.js} +1 -1
- package/web/dist/assets/{fileZihao-BQ2XDoAg.js → fileZihao-Bm-uB2BS.js} +1 -1
- package/web/dist/assets/{freemarker2-DRNJ6FYB.js → freemarker2-OIgEfGdK.js} +1 -1
- package/web/dist/assets/{handlebars-mubTvOO1.js → handlebars-CwUrtebj.js} +1 -1
- package/web/dist/assets/{html-DS4rz_hZ.js → html-DplPIfs6.js} +1 -1
- package/web/dist/assets/{htmlMode-D87cKX8Z.js → htmlMode-BpbIfVaE.js} +1 -1
- package/web/dist/assets/{index-BQkX4XfJ.css → index-D4xhVePW.css} +1 -1
- package/web/dist/assets/{index-dOZe8hsN.js → index-Dtkc_ka-.js} +50 -50
- package/web/dist/assets/{javascript-DyGvY_0Y.js → javascript-B_eZzRqF.js} +1 -1
- package/web/dist/assets/{jsonMode-ixGH1Eb2.js → jsonMode-9MZfSMtt.js} +1 -1
- package/web/dist/assets/{liquid-BgvfOJcH.js → liquid-Q68k40m8.js} +1 -1
- package/web/dist/assets/{mdx-DUbMPmbc.js → mdx-BH-rWx_x.js} +1 -1
- package/web/dist/assets/{python-CYK0c6tb.js → python-DvT3SN5P.js} +1 -1
- package/web/dist/assets/{razor-CC84D436.js → razor-C2wZYTc7.js} +1 -1
- package/web/dist/assets/{tsMode-C-wonHgC.js → tsMode-Cm8eLc0y.js} +1 -1
- package/web/dist/assets/{typescript-DzuJLwji.js → typescript-B5qDQjhx.js} +1 -1
- package/web/dist/assets/{xml-CMPFw__l.js → xml-CZxclJkM.js} +1 -1
- package/web/dist/assets/{yaml-BYzkFta5.js → yaml-BAVixhgZ.js} +1 -1
- package/web/dist/index.html +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config-export-import.service.d.ts","sourceRoot":"","sources":["../../src/service/config-export-import.service.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,UAAU;IACzB,SAAS,CAAC,EAAE,GAAG,EAAE,CAAC;IAClB,MAAM,CAAC,EAAE,GAAG,EAAE,CAAC;IACf,YAAY,CAAC,EAAE,GAAG,EAAE,CAAC;IACrB,OAAO,CAAC,EAAE,GAAG,CAAC;IACd,UAAU,CAAC,EAAE,GAAG,CAAC;IACjB,KAAK,CAAC,EAAE,GAAG,CAAC;
|
|
1
|
+
{"version":3,"file":"config-export-import.service.d.ts","sourceRoot":"","sources":["../../src/service/config-export-import.service.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,UAAU;IACzB,SAAS,CAAC,EAAE,GAAG,EAAE,CAAC;IAClB,MAAM,CAAC,EAAE,GAAG,EAAE,CAAC;IACf,YAAY,CAAC,EAAE,GAAG,EAAE,CAAC;IACrB,OAAO,CAAC,EAAE,GAAG,CAAC;IACd,UAAU,CAAC,EAAE,GAAG,CAAC;IACjB,KAAK,CAAC,EAAE,GAAG,CAAC;IACZ,KAAK,CAAC,EAAE;QAAE,OAAO,EAAE,OAAO,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC;CACxE;AAED,qBAAa,yBAAyB;IACpC,SAAS,IAAI,UAAU;IAkFvB,UAAU,CAAC,IAAI,EAAE,UAAU,GAAG;QAAE,OAAO,EAAE,OAAO,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE;CAsGpE;AAED,eAAO,MAAM,yBAAyB,2BAAkC,CAAC"}
|
|
@@ -62,6 +62,15 @@ export class ConfigExportImportService {
|
|
|
62
62
|
fromName: email.from_name || '',
|
|
63
63
|
};
|
|
64
64
|
}
|
|
65
|
+
const proxy = dbService.get('SELECT * FROM proxy_config WHERE id = 1');
|
|
66
|
+
if (proxy) {
|
|
67
|
+
data.proxy = {
|
|
68
|
+
enabled: Boolean(proxy.enabled),
|
|
69
|
+
type: proxy.type || 'http',
|
|
70
|
+
host: proxy.host || '',
|
|
71
|
+
port: proxy.port || 1080,
|
|
72
|
+
};
|
|
73
|
+
}
|
|
65
74
|
return data;
|
|
66
75
|
}
|
|
67
76
|
importData(data) {
|
|
@@ -120,6 +129,9 @@ export class ConfigExportImportService {
|
|
|
120
129
|
dbService.run(`INSERT INTO email_config (name, host, port, secure, user, password, from_name, is_default) VALUES (?, ?, ?, ?, ?, ?, ?, 1)`, ['Default', data.email.host, data.email.port, data.email.secure ? 1 : 0, data.email.user, data.email.password, data.email.fromName || '']);
|
|
121
130
|
}
|
|
122
131
|
}
|
|
132
|
+
if (data.proxy) {
|
|
133
|
+
dbService.run(`INSERT OR REPLACE INTO proxy_config (id, enabled, type, host, port, updated_at) VALUES (1, ?, ?, ?, ?, datetime('now'))`, [data.proxy.enabled ? 1 : 0, data.proxy.type || 'http', data.proxy.host || '', data.proxy.port || 1080]);
|
|
134
|
+
}
|
|
123
135
|
return { success: true, message: '配置导入成功' };
|
|
124
136
|
}
|
|
125
137
|
catch (error) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config-export-import.service.js","sourceRoot":"","sources":["../../src/service/config-export-import.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"config-export-import.service.js","sourceRoot":"","sources":["../../src/service/config-export-import.service.ts"],"names":[],"mappings":"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"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tianxincode",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.41",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "AI Coding Assistant",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -44,6 +44,7 @@
|
|
|
44
44
|
"react": "^19.2.4",
|
|
45
45
|
"react-dom": "^19.2.4",
|
|
46
46
|
"sql.js": "^1.12.0",
|
|
47
|
+
"undici": "^7.25.0",
|
|
47
48
|
"uuid": "^9.0.1",
|
|
48
49
|
"which": "^6.0.1",
|
|
49
50
|
"ws": "^8.20.0",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{n as x,a as n}from"./index-
|
|
1
|
+
import{n as x,a as n}from"./index-Dtkc_ka-.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};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{n}from"./index-
|
|
1
|
+
import{n}from"./index-Dtkc_ka-.js";const r={name:"ConfirmDialog",props:{visible:{type:Boolean,default:!1},message:{type:String,default:""}}};var i=function(){var e=this,t=e._self._c;return e.visible?t("div",{staticClass:"fixed inset-0 bg-black/50 flex items-center justify-center z-50"},[t("div",{staticClass:"bg-sidebar border border-border rounded p-4 w-96"},[t("p",{staticClass:"text-gray-200 text-sm mb-4"},[e._v(e._s(e.message))]),t("div",{staticClass:"flex justify-end gap-2"},[t("button",{staticClass:"px-3 py-1 text-xs text-gray-400 hover:text-white",on:{click:function(s){return e.$emit("cancel")}}},[e._v("取消")]),t("button",{staticClass:"px-3 py-1 text-xs bg-red-600 text-white rounded hover:bg-red-700",on:{click:function(s){return e.$emit("confirm")}}},[e._v("确定")])])])]):e._e()},a=[],o=n(r,i,a,!1,null,null);const d=o.exports;export{d as C};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{n as d,a as n}from"./index-
|
|
1
|
+
import{n as d,a as n}from"./index-Dtkc_ka-.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};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{n as c,R as u,S as h,F as p,C as g,M as f,a as o,g as d,s as m,b as C,e as b,K as k,c as I}from"./index-
|
|
1
|
+
import{n as c,R as u,S as h,F as p,C as g,M as f,a as o,g as d,s as m,b as C,e as b,K as k,c as I}from"./index-Dtkc_ka-.js";const w={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 $=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)])},M=[],P=c(w,$,M,!1,null,"d95049e3");const D=P.exports,j={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 x=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)},T=[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(" 创建新需求")])])}],V=c(j,x,T,!1,null,"4d22db92");const q=V.exports,F={name:"Step2Design",components:{ModelSelectDialog:f,CommandDialog:g,FileSelectDialog:p,SkillSelectDialog:h,ResizableTextarea:u},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,skillSelectVisible:!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
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
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="",this.$emit("update: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.$emit("update:sessionId",this.sessionId),this.sessionId?(await this.loadMessages(),this.subscribeSession()):this.logItems=[]}catch(s){console.error("Load session failed:",s),this.sessionId="",this.$emit("update: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=b.create(this.$refs.editorContainer,{value:this.specContent||`# 选择或创建需求项目开始设计
|
|
4
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(k.CtrlCmd|I.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} 生成方案,先不要修改代码。
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{n as h,f as p,g as u,w as c,h as m,a as o}from"./index-dOZe8hsN.js";const C={name:"AppWorkflowStep",props:{currentStep:{type:Number,default:1}},data(){return{steps:[{id:1,label:"需求"},{id:2,label:"设计"},{id:3,label:"代码"},{id:4,label:"测试"}]}}};var _=function(){var s=this,t=s._self._c;return t("div",{staticClass:"workflow-step-bar"},s._l(s.steps,function(i){return t("div",{key:i.id,staticClass:"step-item",class:{active:s.currentStep>=i.id,current:s.currentStep===i.id},on:{click:function(r){return s.$emit("step-change",i.id)}}},[t("div",{staticClass:"step-number"},[s._v(s._s(i.id))]),t("div",{staticClass:"step-label"},[s._v(s._s(i.label))])])}),0)},w=[],y=h(C,_,w,!1,null,"1cf39c0c");const b=y.exports,k={name:"AppStep1Req",props:{categories:{type:Array,default:()=>[]},projects:{type:Object,default:()=>({})},reqBasePath:{type:String,default:""},currentCategory:{type:String,default:""},currentProject:{type:String,default:""}},data(){return{selectedCategory:"",selectedProject:"",dialogVisible:!1,dialogInput:"",requirementDialogVisible:!1,requirementDialogInput:""}},computed:{requirementList(){if(!this.selectedCategory)return[];const e=`${this.selectedCategory}/`;return Object.keys(this.projects).filter(s=>s.startsWith(e)).map(s=>s.split("/")[1]).sort()}},watch:{currentCategory:{immediate:!0,handler(e){this.selectedCategory=e||""}},currentProject:{immediate:!0,handler(e){this.selectedProject=e||""}},selectedCategory(e){e||(this.selectedProject="")}},methods:{selectCategory(e){this.selectedCategory=e,this.$emit("category-change",e),this.$emit("project-change","")},selectProject(e){this.selectedProject=e,this.$emit("project-change",e)},showCreateCategoryDialog(){this.dialogInput="",this.dialogVisible=!0},handleDialogConfirm(){const e=this.dialogInput.trim();e&&(this.$emit("create-category",e),this.dialogVisible=!1)},showCreateRequirementDialog(){this.selectedCategory&&(this.requirementDialogInput="",this.requirementDialogVisible=!0)},handleCreateRequirementConfirm(){const e=this.requirementDialogInput.trim();e&&(this.requirementList.includes(e)||(this.$emit("create-requirement",{category:this.selectedCategory,name:e}),this.requirementDialogVisible=!1))}}};var S=function(){var s=this,t=s._self._c;return t("div",{staticClass:"step1-req"},[t("div",{staticClass:"category-section"},[s._m(0),t("div",{staticClass:"category-list"},[s._l(s.categories,function(i){return t("div",{key:i,staticClass:"category-item",class:{active:s.selectedCategory===i},on:{click:function(r){return s.selectCategory(i)}}},[t("i",{staticClass:"fa-solid fa-folder"}),t("span",[s._v(s._s(i))])])}),t("div",{staticClass:"category-item add-btn",on:{click:s.showCreateCategoryDialog}},[t("i",{staticClass:"fa-solid fa-plus"}),t("span",[s._v("新建大类")])])],2)]),t("div",{staticClass:"divider"}),t("div",{staticClass:"project-section"},[t("div",{staticClass:"section-header"},[t("span",[s._v("选择需求")]),t("button",{staticClass:"btn-primary",attrs:{disabled:!s.selectedCategory},on:{click:s.showCreateRequirementDialog}},[t("i",{staticClass:"fa-solid fa-plus"}),s._v(" 新建 ")])]),t("div",{staticClass:"project-list"},[s._l(s.requirementList,function(i){return t("div",{key:i,staticClass:"project-item",on:{click:function(r){return s.selectProject(i)}}},[t("div",{staticClass:"project-info"},[t("i",{staticClass:"fa-solid fa-folder-open"}),t("span",[s._v(s._s(i))])]),t("i",{staticClass:"fa-solid fa-chevron-right"})])}),!s.requirementList.length&&s.selectedCategory?t("div",{staticClass:"empty-hint"},[s._v(" 暂无需求,请点击新建 ")]):s._e(),s.selectedCategory?s._e():t("div",{staticClass:"empty-hint"},[s._v(" 请先选择大类 ")])],2)]),s.dialogVisible?t("div",{staticClass:"dialog-overlay",on:{click:function(i){if(i.target!==i.currentTarget)return null;s.dialogVisible=!1}}},[t("div",{staticClass:"dialog"},[t("div",{staticClass:"dialog-header"},[t("span",[s._v("新建大类")]),t("button",{staticClass:"close-btn",on:{click:function(i){s.dialogVisible=!1}}},[t("i",{staticClass:"fa-solid fa-xmark"})])]),t("div",{staticClass:"dialog-body"},[t("input",{directives:[{name:"model",rawName:"v-model",value:s.dialogInput,expression:"dialogInput"}],attrs:{type:"text",placeholder:"输入大类名称"},domProps:{value:s.dialogInput},on:{keydown:function(i){return!i.type.indexOf("key")&&s._k(i.keyCode,"enter",13,i.key,"Enter")?null:s.handleDialogConfirm.apply(null,arguments)},input:function(i){i.target.composing||(s.dialogInput=i.target.value)}}})]),t("div",{staticClass:"dialog-footer"},[t("button",{staticClass:"btn-cancel",on:{click:function(i){s.dialogVisible=!1}}},[s._v("取消")]),t("button",{staticClass:"btn-confirm",on:{click:s.handleDialogConfirm}},[s._v("确定")])])])]):s._e(),s.requirementDialogVisible?t("div",{staticClass:"dialog-overlay",on:{click:function(i){if(i.target!==i.currentTarget)return null;s.requirementDialogVisible=!1}}},[t("div",{staticClass:"dialog"},[t("div",{staticClass:"dialog-header"},[t("span",[s._v("新建需求")]),t("button",{staticClass:"close-btn",on:{click:function(i){s.requirementDialogVisible=!1}}},[t("i",{staticClass:"fa-solid fa-xmark"})])]),t("div",{staticClass:"dialog-body"},[t("input",{directives:[{name:"model",rawName:"v-model",value:s.requirementDialogInput,expression:"requirementDialogInput"}],attrs:{type:"text",placeholder:"输入需求名称"},domProps:{value:s.requirementDialogInput},on:{keydown:function(i){return!i.type.indexOf("key")&&s._k(i.keyCode,"enter",13,i.key,"Enter")?null:s.handleCreateRequirementConfirm.apply(null,arguments)},input:function(i){i.target.composing||(s.requirementDialogInput=i.target.value)}}})]),t("div",{staticClass:"dialog-footer"},[t("button",{staticClass:"btn-cancel",on:{click:function(i){s.requirementDialogVisible=!1}}},[s._v("取消")]),t("button",{staticClass:"btn-confirm",on:{click:s.handleCreateRequirementConfirm}},[s._v("确定")])])])]):s._e()])},$=[function(){var e=this,s=e._self._c;return s("div",{staticClass:"section-header"},[s("span",[e._v("选择大类")])])}],P=h(k,S,$,!1,null,"ff2d2605");const D=P.exports,I={name:"AppStep2Design",components:{FileSelectDrawer:p},props:{category:{type:String,default:""},name:{type:String,default:""},reqBasePath:{type:String,default:""}},data(){return{mode:"chat",specView:"edit",specContent:"",inputMessage:"",isProcessing:!1,stopping:!1,logItems:[],sessionId:"",modelName:"",promptTokens:0,showModelDrawer:!1,showCommandDrawer:!1,showFileDrawer:!1,models:[],logSeq:0,wsUnsubscribe:null}},computed:{specFilePath(){return!this.category||!this.name?"":`${this.reqBasePath}/${this.category}/${this.name}/${this.name}_方案.md`},renderedContent(){return u(this.specContent||"")}},watch:{category:{handler(){this.loadData()}},name:{handler(){this.loadData()}}},async mounted(){c.init(),await this.loadModels(),await this.loadDefaultModel(),await this.loadData()},beforeDestroy(){this.wsUnsubscribe&&this.wsUnsubscribe()},methods:{async loadData(){await Promise.all([this.loadSpec(),this.loadSession()])},async loadSpec(){if(!this.category||!this.name){this.specContent="";return}try{const e=await o.getFileContent(this.specFilePath);this.specContent=e.content||""}catch{this.specContent=""}},async loadSession(){if(!this.category||!this.name){this.sessionId="";return}try{const e=`${this.reqBasePath}/${this.category}/${this.name}/session.json`,s=await o.getFileContent(e);if(s&&s.content){const t=JSON.parse(s.content);this.sessionId=t.designSessionId||""}else this.sessionId="";this.sessionId&&(await this.loadMessages(),this.subscribeSession())}catch{this.sessionId=""}},async saveSpec(){if(this.specFilePath)try{await o.writeFile(this.specFilePath,this.specContent),this.$emit("save-spec",this.specContent),this.$emit("spec-updated"),this.$message.success("方案已保存")}catch{this.$message.error("保存失败")}},async loadModels(){try{const e=await o.getModels();this.models=e.data||[]}catch(e){console.error("Load models failed:",e)}},async loadDefaultModel(){var e;try{const s=await o.getConfig("defaultModel");(e=s.data)!=null&&e.value&&(this.modelName=s.data.value)}catch{this.modelName="gpt-4o"}},selectModel(e){const s=e.name.split("/");this.modelName=s.length>2?s.slice(1).join("/"):e.name,o.setConfig("defaultModel",this.modelName),this.showModelDrawer=!1},async loadMessages(){if(this.sessionId)try{const e=await m(this.sessionId);this.logItems=(e.data||[]).map(s=>s.type==="think"?{type:"think",content:s.content||"",_id:`log-${++this.logSeq}`}:s.type==="step"?{type:"step",thought:s.thought,toolCalls:s.toolCalls||[],success:s.success,_id:`log-${++this.logSeq}`}:s.type==="chat"?{type:"chat",content:s.content,_id:`log-${++this.logSeq}`}:s.type==="todos"?{type:"todos",todos:s.todos||[],_id:`log-${++this.logSeq}`}:{type:"system",content:String(s),_id:`log-${++this.logSeq}`}),this.scrollToBottom()}catch(e){console.error("Load messages failed:",e)}},subscribeSession(){this.sessionId&&(this.wsUnsubscribe&&this.wsUnsubscribe(),this.wsUnsubscribe=c.subscribe(this.sessionId,{running_sessions:e=>{const s=(e==null?void 0:e.runningSessionIds)||[];this.isProcessing=s.includes(this.sessionId)},todos:e=>{this.logItems.push({type:"todos",todos:e.todos,_id:`log-${++this.logSeq}`}),this.scrollToBottom()},step:e=>{var s;this.logItems.push({type:"step",thought:e==null?void 0:e.thought,toolCalls:(e==null?void 0:e.toolCalls)||[],success:e==null?void 0:e.success,_id:`log-${++this.logSeq}`}),(s=e==null?void 0:e.usage)!=null&&s.promptTokens&&(this.promptTokens=e.usage.promptTokens),this.scrollToBottom()},compact:e=>{this.logItems.push({type:"system",content:`【压缩完成】${e.summary||""}`,_id:`log-${++this.logSeq}`}),this.loadMessages()},done:e=>{var s;this.isProcessing=!1,this.stopping=!1,e!=null&&e.modelName&&(this.modelName=e.modelName),(s=e==null?void 0:e.usage)!=null&&s.promptTokens&&(this.promptTokens=e.usage.promptTokens),e!=null&&e.response&&this.logItems.push({type:"think",content:e.response,_id:`log-${++this.logSeq}`}),this.$emit("spec-updated"),this.loadSpec(),this.scrollToBottom()},stopped:()=>{this.isProcessing=!1,this.stopping=!1,this.logItems.push({type:"think",content:"【已停止】",_id:`log-${++this.logSeq}`}),this.scrollToBottom()},error:e=>{this.isProcessing=!1,this.stopping=!1,this.$message.error((e==null?void 0:e.error)||"发生错误")}}))},async sendMessage(){const e=this.inputMessage.trim();if(!e||this.isProcessing||!this.sessionId)return;this.wsUnsubscribe||this.subscribeSession();const s=`先在 ${this.specFilePath} 生成方案,先不要修改代码。
|
|
1
|
+
import{n as h,f as p,g as u,w as c,h as m,a as o}from"./index-Dtkc_ka-.js";const C={name:"AppWorkflowStep",props:{currentStep:{type:Number,default:1}},data(){return{steps:[{id:1,label:"需求"},{id:2,label:"设计"},{id:3,label:"代码"},{id:4,label:"测试"}]}}};var _=function(){var s=this,t=s._self._c;return t("div",{staticClass:"workflow-step-bar"},s._l(s.steps,function(i){return t("div",{key:i.id,staticClass:"step-item",class:{active:s.currentStep>=i.id,current:s.currentStep===i.id},on:{click:function(r){return s.$emit("step-change",i.id)}}},[t("div",{staticClass:"step-number"},[s._v(s._s(i.id))]),t("div",{staticClass:"step-label"},[s._v(s._s(i.label))])])}),0)},w=[],y=h(C,_,w,!1,null,"1cf39c0c");const b=y.exports,k={name:"AppStep1Req",props:{categories:{type:Array,default:()=>[]},projects:{type:Object,default:()=>({})},reqBasePath:{type:String,default:""},currentCategory:{type:String,default:""},currentProject:{type:String,default:""}},data(){return{selectedCategory:"",selectedProject:"",dialogVisible:!1,dialogInput:"",requirementDialogVisible:!1,requirementDialogInput:""}},computed:{requirementList(){if(!this.selectedCategory)return[];const e=`${this.selectedCategory}/`;return Object.keys(this.projects).filter(s=>s.startsWith(e)).map(s=>s.split("/")[1]).sort()}},watch:{currentCategory:{immediate:!0,handler(e){this.selectedCategory=e||""}},currentProject:{immediate:!0,handler(e){this.selectedProject=e||""}},selectedCategory(e){e||(this.selectedProject="")}},methods:{selectCategory(e){this.selectedCategory=e,this.$emit("category-change",e),this.$emit("project-change","")},selectProject(e){this.selectedProject=e,this.$emit("project-change",e)},showCreateCategoryDialog(){this.dialogInput="",this.dialogVisible=!0},handleDialogConfirm(){const e=this.dialogInput.trim();e&&(this.$emit("create-category",e),this.dialogVisible=!1)},showCreateRequirementDialog(){this.selectedCategory&&(this.requirementDialogInput="",this.requirementDialogVisible=!0)},handleCreateRequirementConfirm(){const e=this.requirementDialogInput.trim();e&&(this.requirementList.includes(e)||(this.$emit("create-requirement",{category:this.selectedCategory,name:e}),this.requirementDialogVisible=!1))}}};var S=function(){var s=this,t=s._self._c;return t("div",{staticClass:"step1-req"},[t("div",{staticClass:"category-section"},[s._m(0),t("div",{staticClass:"category-list"},[s._l(s.categories,function(i){return t("div",{key:i,staticClass:"category-item",class:{active:s.selectedCategory===i},on:{click:function(r){return s.selectCategory(i)}}},[t("i",{staticClass:"fa-solid fa-folder"}),t("span",[s._v(s._s(i))])])}),t("div",{staticClass:"category-item add-btn",on:{click:s.showCreateCategoryDialog}},[t("i",{staticClass:"fa-solid fa-plus"}),t("span",[s._v("新建大类")])])],2)]),t("div",{staticClass:"divider"}),t("div",{staticClass:"project-section"},[t("div",{staticClass:"section-header"},[t("span",[s._v("选择需求")]),t("button",{staticClass:"btn-primary",attrs:{disabled:!s.selectedCategory},on:{click:s.showCreateRequirementDialog}},[t("i",{staticClass:"fa-solid fa-plus"}),s._v(" 新建 ")])]),t("div",{staticClass:"project-list"},[s._l(s.requirementList,function(i){return t("div",{key:i,staticClass:"project-item",on:{click:function(r){return s.selectProject(i)}}},[t("div",{staticClass:"project-info"},[t("i",{staticClass:"fa-solid fa-folder-open"}),t("span",[s._v(s._s(i))])]),t("i",{staticClass:"fa-solid fa-chevron-right"})])}),!s.requirementList.length&&s.selectedCategory?t("div",{staticClass:"empty-hint"},[s._v(" 暂无需求,请点击新建 ")]):s._e(),s.selectedCategory?s._e():t("div",{staticClass:"empty-hint"},[s._v(" 请先选择大类 ")])],2)]),s.dialogVisible?t("div",{staticClass:"dialog-overlay",on:{click:function(i){if(i.target!==i.currentTarget)return null;s.dialogVisible=!1}}},[t("div",{staticClass:"dialog"},[t("div",{staticClass:"dialog-header"},[t("span",[s._v("新建大类")]),t("button",{staticClass:"close-btn",on:{click:function(i){s.dialogVisible=!1}}},[t("i",{staticClass:"fa-solid fa-xmark"})])]),t("div",{staticClass:"dialog-body"},[t("input",{directives:[{name:"model",rawName:"v-model",value:s.dialogInput,expression:"dialogInput"}],attrs:{type:"text",placeholder:"输入大类名称"},domProps:{value:s.dialogInput},on:{keydown:function(i){return!i.type.indexOf("key")&&s._k(i.keyCode,"enter",13,i.key,"Enter")?null:s.handleDialogConfirm.apply(null,arguments)},input:function(i){i.target.composing||(s.dialogInput=i.target.value)}}})]),t("div",{staticClass:"dialog-footer"},[t("button",{staticClass:"btn-cancel",on:{click:function(i){s.dialogVisible=!1}}},[s._v("取消")]),t("button",{staticClass:"btn-confirm",on:{click:s.handleDialogConfirm}},[s._v("确定")])])])]):s._e(),s.requirementDialogVisible?t("div",{staticClass:"dialog-overlay",on:{click:function(i){if(i.target!==i.currentTarget)return null;s.requirementDialogVisible=!1}}},[t("div",{staticClass:"dialog"},[t("div",{staticClass:"dialog-header"},[t("span",[s._v("新建需求")]),t("button",{staticClass:"close-btn",on:{click:function(i){s.requirementDialogVisible=!1}}},[t("i",{staticClass:"fa-solid fa-xmark"})])]),t("div",{staticClass:"dialog-body"},[t("input",{directives:[{name:"model",rawName:"v-model",value:s.requirementDialogInput,expression:"requirementDialogInput"}],attrs:{type:"text",placeholder:"输入需求名称"},domProps:{value:s.requirementDialogInput},on:{keydown:function(i){return!i.type.indexOf("key")&&s._k(i.keyCode,"enter",13,i.key,"Enter")?null:s.handleCreateRequirementConfirm.apply(null,arguments)},input:function(i){i.target.composing||(s.requirementDialogInput=i.target.value)}}})]),t("div",{staticClass:"dialog-footer"},[t("button",{staticClass:"btn-cancel",on:{click:function(i){s.requirementDialogVisible=!1}}},[s._v("取消")]),t("button",{staticClass:"btn-confirm",on:{click:s.handleCreateRequirementConfirm}},[s._v("确定")])])])]):s._e()])},$=[function(){var e=this,s=e._self._c;return s("div",{staticClass:"section-header"},[s("span",[e._v("选择大类")])])}],P=h(k,S,$,!1,null,"ff2d2605");const D=P.exports,I={name:"AppStep2Design",components:{FileSelectDrawer:p},props:{category:{type:String,default:""},name:{type:String,default:""},reqBasePath:{type:String,default:""}},data(){return{mode:"chat",specView:"edit",specContent:"",inputMessage:"",isProcessing:!1,stopping:!1,logItems:[],sessionId:"",modelName:"",promptTokens:0,showModelDrawer:!1,showCommandDrawer:!1,showFileDrawer:!1,models:[],logSeq:0,wsUnsubscribe:null}},computed:{specFilePath(){return!this.category||!this.name?"":`${this.reqBasePath}/${this.category}/${this.name}/${this.name}_方案.md`},renderedContent(){return u(this.specContent||"")}},watch:{category:{handler(){this.loadData()}},name:{handler(){this.loadData()}}},async mounted(){c.init(),await this.loadModels(),await this.loadDefaultModel(),await this.loadData()},beforeDestroy(){this.wsUnsubscribe&&this.wsUnsubscribe()},methods:{async loadData(){await Promise.all([this.loadSpec(),this.loadSession()])},async loadSpec(){if(!this.category||!this.name){this.specContent="";return}try{const e=await o.getFileContent(this.specFilePath);this.specContent=e.content||""}catch{this.specContent=""}},async loadSession(){if(!this.category||!this.name){this.sessionId="";return}try{const e=`${this.reqBasePath}/${this.category}/${this.name}/session.json`,s=await o.getFileContent(e);if(s&&s.content){const t=JSON.parse(s.content);this.sessionId=t.designSessionId||""}else this.sessionId="";this.sessionId&&(await this.loadMessages(),this.subscribeSession())}catch{this.sessionId=""}},async saveSpec(){if(this.specFilePath)try{await o.writeFile(this.specFilePath,this.specContent),this.$emit("save-spec",this.specContent),this.$emit("spec-updated"),this.$message.success("方案已保存")}catch{this.$message.error("保存失败")}},async loadModels(){try{const e=await o.getModels();this.models=e.data||[]}catch(e){console.error("Load models failed:",e)}},async loadDefaultModel(){var e;try{const s=await o.getConfig("defaultModel");(e=s.data)!=null&&e.value&&(this.modelName=s.data.value)}catch{this.modelName="gpt-4o"}},selectModel(e){const s=e.name.split("/");this.modelName=s.length>2?s.slice(1).join("/"):e.name,o.setConfig("defaultModel",this.modelName),this.showModelDrawer=!1},async loadMessages(){if(this.sessionId)try{const e=await m(this.sessionId);this.logItems=(e.data||[]).map(s=>s.type==="think"?{type:"think",content:s.content||"",_id:`log-${++this.logSeq}`}:s.type==="step"?{type:"step",thought:s.thought,toolCalls:s.toolCalls||[],success:s.success,_id:`log-${++this.logSeq}`}:s.type==="chat"?{type:"chat",content:s.content,_id:`log-${++this.logSeq}`}:s.type==="todos"?{type:"todos",todos:s.todos||[],_id:`log-${++this.logSeq}`}:{type:"system",content:String(s),_id:`log-${++this.logSeq}`}),this.scrollToBottom()}catch(e){console.error("Load messages failed:",e)}},subscribeSession(){this.sessionId&&(this.wsUnsubscribe&&this.wsUnsubscribe(),this.wsUnsubscribe=c.subscribe(this.sessionId,{running_sessions:e=>{const s=(e==null?void 0:e.runningSessionIds)||[];this.isProcessing=s.includes(this.sessionId)},todos:e=>{this.logItems.push({type:"todos",todos:e.todos,_id:`log-${++this.logSeq}`}),this.scrollToBottom()},step:e=>{var s;this.logItems.push({type:"step",thought:e==null?void 0:e.thought,toolCalls:(e==null?void 0:e.toolCalls)||[],success:e==null?void 0:e.success,_id:`log-${++this.logSeq}`}),(s=e==null?void 0:e.usage)!=null&&s.promptTokens&&(this.promptTokens=e.usage.promptTokens),this.scrollToBottom()},compact:e=>{this.logItems.push({type:"system",content:`【压缩完成】${e.summary||""}`,_id:`log-${++this.logSeq}`}),this.loadMessages()},done:e=>{var s;this.isProcessing=!1,this.stopping=!1,e!=null&&e.modelName&&(this.modelName=e.modelName),(s=e==null?void 0:e.usage)!=null&&s.promptTokens&&(this.promptTokens=e.usage.promptTokens),e!=null&&e.response&&this.logItems.push({type:"think",content:e.response,_id:`log-${++this.logSeq}`}),this.$emit("spec-updated"),this.loadSpec(),this.scrollToBottom()},stopped:()=>{this.isProcessing=!1,this.stopping=!1,this.logItems.push({type:"think",content:"【已停止】",_id:`log-${++this.logSeq}`}),this.scrollToBottom()},error:e=>{this.isProcessing=!1,this.stopping=!1,this.$message.error((e==null?void 0:e.error)||"发生错误")}}))},async sendMessage(){const e=this.inputMessage.trim();if(!e||this.isProcessing||!this.sessionId)return;this.wsUnsubscribe||this.subscribeSession();const s=`先在 ${this.specFilePath} 生成方案,先不要修改代码。
|
|
2
2
|
|
|
3
3
|
用户输入: ${e}`;this.inputMessage="",this.isProcessing=!0,this.logItems.push({type:"chat",content:e,_id:`log-${++this.logSeq}`}),this.scrollToBottom(),c.send("chat",{message:s,sessionId:this.sessionId,modelName:this.modelName||void 0})},stopGeneration(){this.sessionId&&(this.isProcessing=!1,this.stopping=!0,c.send("stop",{sessionId:this.sessionId}))},appendCommand(e){var s;this.inputMessage=e+" ",(s=this.$refs.inputField)==null||s.focus()},onFileSelected(e){var s;this.inputMessage=this.inputMessage+e+" ",this.showFileDrawer=!1,(s=this.$refs.inputField)==null||s.focus()},closeAllDrawers(){this.showModelDrawer=!1,this.showCommandDrawer=!1,this.showFileDrawer=!1},renderMarkdown(e){return e?u(e):""},getTodoStatusIcon(e){return{completed:"✅",in_progress:"🔄",pending:"⬜",cancelled:"❌"}[e]||"⬜"},formatToolArgs(e){var s;try{const t=JSON.parse(((s=e==null?void 0:e.function)==null?void 0:s.arguments)||"{}");return t.file_path?t.file_path:t.command?t.command:""}catch{return""}},scrollToBottom(){this.$nextTick(()=>{this.$refs.chatArea&&(this.$refs.chatArea.scrollTop=this.$refs.chatArea.scrollHeight)})}}};var M=function(){var s=this,t=s._self._c;return t("div",{staticClass:"step2-design"},[t("div",{staticClass:"mode-tabs"},[t("button",{staticClass:"tab-btn",class:{active:s.mode==="chat"},on:{click:function(i){s.mode="chat"}}},[t("i",{staticClass:"fa-solid fa-robot"}),s._v(" AI方案助手 ")]),t("button",{staticClass:"tab-btn",class:{active:s.mode==="spec"},on:{click:function(i){s.mode="spec"}}},[t("i",{staticClass:"fa-solid fa-file-alt"}),s._v(" 方案 ")])]),s.mode==="chat"?t("div",{staticClass:"chat-mode"},[t("div",{staticClass:"chat-toolbar"},[t("span",{staticClass:"model-name",on:{click:function(i){s.showModelDrawer=!0}}},[s._v(" "+s._s(s.modelName||"gpt-4o")+" "),t("i",{staticClass:"fa-solid fa-chevron-down"})]),t("button",{staticClass:"toolbar-btn",on:{click:function(i){s.showCommandDrawer=!0}}},[t("i",{staticClass:"fa-solid fa-terminal"})]),t("button",{staticClass:"toolbar-btn",on:{click:function(i){s.showFileDrawer=!0}}},[t("i",{staticClass:"fa-solid fa-file-circle-plus"})])]),t("div",{ref:"chatArea",staticClass:"chat-area"},[s.logItems.length?s._e():t("div",{staticClass:"empty-state"},[t("p",[s._v("描述你的需求,AI将协助完善方案")])]),s._l(s.logItems,function(i,r){return[i.type==="chat"?t("div",{staticClass:"message user"},[t("div",{staticClass:"message-bubble"},[s._v(s._s(i.content))])]):i.type==="think"?t("div",{staticClass:"message assistant"},[t("div",{staticClass:"message-bubble",domProps:{innerHTML:s._s(s.renderMarkdown(i.content))}})]):i.type==="step"?t("div",{staticClass:"step-block"},[i.thought?t("div",{staticClass:"message assistant"},[t("div",{staticClass:"message-bubble",domProps:{innerHTML:s._s(s.renderMarkdown(i.thought))}})]):s._e(),s._l(i.toolCalls,function(a,n){var l;return t("div",{key:"tc-"+n,staticClass:"tool-log",class:i.success!==!1?"tool-success":"tool-fail"},[t("span",[s._v(s._s(i.success!==!1?"✓":"✗"))]),t("span",{staticClass:"tool-name"},[s._v(s._s(((l=a==null?void 0:a.function)==null?void 0:l.name)||"unknown"))]),t("span",{staticClass:"tool-args"},[s._v(s._s(s.formatToolArgs(a)))])])})],2):i.type==="system"?t("div",{staticClass:"message assistant"},[t("div",{staticClass:"message-bubble system"},[s._v(s._s(i.content))])]):i.type==="todos"?t("div",{staticClass:"message assistant"},[t("div",{staticClass:"todo-list"},s._l(i.todos,function(a,n){return t("div",{key:n,staticClass:"todo-item"},[t("span",{staticClass:"todo-status"},[s._v(s._s(s.getTodoStatusIcon(a.status)))]),t("span",[s._v(s._s(a.name))])])}),0)]):s._e()]}),s.isProcessing?t("div",{staticClass:"message assistant thinking"},[t("div",{staticClass:"message-bubble"},[s._v("思考中...")])]):s._e()],2),t("div",{staticClass:"input-area"},[t("div",{staticClass:"input-wrapper"},[t("textarea",{directives:[{name:"model",rawName:"v-model",value:s.inputMessage,expression:"inputMessage"}],ref:"inputField",staticClass:"input-field",attrs:{placeholder:"描述需求... (Enter发送)"},domProps:{value:s.inputMessage},on:{keydown:function(i){return!i.type.indexOf("key")&&s._k(i.keyCode,"enter",13,i.key,"Enter")||i.ctrlKey||i.shiftKey||i.altKey||i.metaKey?null:(i.preventDefault(),s.sendMessage.apply(null,arguments))},input:function(i){i.target.composing||(s.inputMessage=i.target.value)}}})]),t("button",{staticClass:"send-btn",class:{"stop-btn":s.isProcessing},attrs:{disabled:!s.inputMessage.trim()&&!s.isProcessing},on:{click:function(i){s.isProcessing?s.stopGeneration():s.sendMessage()}}},[t("i",{class:s.isProcessing?"fa-solid fa-stop":"fa-solid fa-paper-plane"})])]),t("div",{staticClass:"status-bar"},[t("span",{staticClass:"status-indicator"},[t("span",{staticClass:"status-dot",class:{processing:s.isProcessing}}),s._v(" "+s._s(s.isProcessing?"处理中...":"就绪")+" ")]),t("span",[s._v("Token: "+s._s(s.promptTokens||0))])])]):t("div",{staticClass:"spec-mode"},[t("div",{staticClass:"spec-tabs"},[t("button",{staticClass:"spec-tab-btn",class:{active:s.specView==="edit"},on:{click:function(i){s.specView="edit"}}},[t("i",{staticClass:"fa-solid fa-edit"}),s._v(" 编辑 ")]),t("button",{staticClass:"spec-tab-btn",class:{active:s.specView==="preview"},on:{click:function(i){s.specView="preview"}}},[t("i",{staticClass:"fa-solid fa-eye"}),s._v(" 预览 ")])]),s.specView==="edit"?t("div",{staticClass:"editor-area"},[t("div",{staticClass:"editor-toolbar"},[t("button",{staticClass:"toolbar-btn primary",on:{click:s.saveSpec}},[t("i",{staticClass:"fa-solid fa-save"}),s._v(" 保存 ")])]),t("textarea",{directives:[{name:"model",rawName:"v-model",value:s.specContent,expression:"specContent"}],staticClass:"markdown-editor",attrs:{placeholder:"输入方案内容..."},domProps:{value:s.specContent},on:{keydown:function(i){return!i.type.indexOf("key")&&s._k(i.keyCode,"s",void 0,i.key,void 0)||!i.ctrlKey?null:(i.preventDefault(),s.saveSpec.apply(null,arguments))},input:function(i){i.target.composing||(s.specContent=i.target.value)}}})]):t("div",{staticClass:"preview-area"},[t("div",{staticClass:"preview-content",domProps:{innerHTML:s._s(s.renderedContent)}})])]),t("div",{staticClass:"drawer-overlay",class:{show:s.showModelDrawer||s.showCommandDrawer||s.showFileDrawer},on:{click:s.closeAllDrawers}}),t("FileSelectDrawer",{attrs:{visible:s.showFileDrawer},on:{select:s.onFileSelected,close:function(i){s.showFileDrawer=!1}}}),t("div",{staticClass:"model-drawer",class:{show:s.showModelDrawer}},[t("div",{staticClass:"drawer-header"},[t("span",{staticClass:"drawer-title"},[s._v("选择模型")]),t("button",{staticClass:"drawer-close",on:{click:function(i){s.showModelDrawer=!1}}},[t("i",{staticClass:"fa-solid fa-xmark"})])]),t("div",{staticClass:"command-list"},s._l(s.models,function(i){return t("div",{key:i.id,staticClass:"command-item",class:{active:i.name===s.modelName},on:{click:function(r){return s.selectModel(i)}}},[s._m(0,!0),t("div",{staticClass:"command-info"},[t("div",{staticClass:"command-name"},[s._v(s._s(i.name))]),t("div",{staticClass:"command-desc"},[s._v(s._s(i.provider||"默认"))])])])}),0)]),t("div",{staticClass:"command-drawer",class:{show:s.showCommandDrawer}},[t("div",{staticClass:"drawer-header"},[t("span",{staticClass:"drawer-title"},[s._v("快捷命令")]),t("button",{staticClass:"drawer-close",on:{click:function(i){s.showCommandDrawer=!1}}},[t("i",{staticClass:"fa-solid fa-xmark"})])]),t("div",{staticClass:"command-list"},[t("div",{staticClass:"command-item",on:{click:function(i){s.appendCommand("/compact"),s.showCommandDrawer=!1}}},[s._m(1),s._m(2)]),t("div",{staticClass:"command-item",on:{click:function(i){s.appendCommand("/clear"),s.showCommandDrawer=!1}}},[s._m(3),s._m(4)])])])],1)},q=[function(){var e=this,s=e._self._c;return s("div",{staticClass:"command-icon"},[s("i",{staticClass:"fa-solid fa-microchip"})])},function(){var e=this,s=e._self._c;return s("div",{staticClass:"command-icon"},[s("i",{staticClass:"fa-solid fa-compress-alt"})])},function(){var e=this,s=e._self._c;return s("div",{staticClass:"command-info"},[s("div",{staticClass:"command-name"},[e._v("压缩会话")]),s("div",{staticClass:"command-desc"},[e._v("减少上下文长度")])])},function(){var e=this,s=e._self._c;return s("div",{staticClass:"command-icon"},[s("i",{staticClass:"fa-solid fa-trash"})])},function(){var e=this,s=e._self._c;return s("div",{staticClass:"command-info"},[s("div",{staticClass:"command-name"},[e._v("清空对话")]),s("div",{staticClass:"command-desc"},[e._v("清空当前会话内容")])])}],T=h(I,M,q,!1,null,"1372dbb7");const F=T.exports,j={name:"AppStep3Code",components:{FileSelectDrawer:p},props:{category:{type:String,default:""},name:{type:String,default:""},reqBasePath:{type:String,default:""}},data(){return{inputMessage:"",isProcessing:!1,stopping:!1,logItems:[],sessionId:"",modelName:"",promptTokens:0,showModelDrawer:!1,showCommandDrawer:!1,showFileDrawer:!1,models:[],logSeq:0,wsUnsubscribe:null}},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(){c.init(),await this.loadModels(),await this.loadDefaultModel(),await this.loadSession()},beforeDestroy(){this.wsUnsubscribe&&this.wsUnsubscribe()},methods:{async loadModels(){try{const e=await o.getModels();this.models=e.data||[]}catch(e){console.error("Load models failed:",e)}},async loadDefaultModel(){var e;try{const s=await o.getConfig("defaultModel");(e=s.data)!=null&&e.value&&(this.modelName=s.data.value)}catch{this.modelName="gpt-4o"}},selectModel(e){const s=e.name.split("/");this.modelName=s.length>2?s.slice(1).join("/"):e.name,o.setConfig("defaultModel",this.modelName),this.showModelDrawer=!1},async loadSession(){if(!this.category||!this.name){this.sessionId="";return}try{const e=`${this.reqBasePath}/${this.category}/${this.name}/session.json`,s=await o.getFileContent(e);if(s&&s.content){const t=JSON.parse(s.content);this.sessionId=t.codeSessionId||""}else this.sessionId="";this.sessionId&&(await this.loadMessages(),this.subscribeSession())}catch{this.sessionId=""}},async loadMessages(){if(this.sessionId)try{const e=await m(this.sessionId);this.logItems=(e.data||[]).map(s=>s.type==="think"?{type:"think",content:s.content||"",_id:`log-${++this.logSeq}`}:s.type==="step"?{type:"step",thought:s.thought,toolCalls:s.toolCalls||[],success:s.success,_id:`log-${++this.logSeq}`}:s.type==="chat"?{type:"chat",content:s.content,_id:`log-${++this.logSeq}`}:s.type==="todos"?{type:"todos",todos:s.todos||[],_id:`log-${++this.logSeq}`}:{type:"system",content:String(s),_id:`log-${++this.logSeq}`}),this.scrollToBottom()}catch(e){console.error("Load messages failed:",e)}},subscribeSession(){this.sessionId&&(this.wsUnsubscribe&&this.wsUnsubscribe(),this.wsUnsubscribe=c.subscribe(this.sessionId,{running_sessions:e=>{const s=(e==null?void 0:e.runningSessionIds)||[];this.isProcessing=s.includes(this.sessionId)},todos:e=>{this.logItems.push({type:"todos",todos:e.todos,_id:`log-${++this.logSeq}`}),this.scrollToBottom()},step:e=>{var s;this.logItems.push({type:"step",thought:e==null?void 0:e.thought,toolCalls:(e==null?void 0:e.toolCalls)||[],success:e==null?void 0:e.success,_id:`log-${++this.logSeq}`}),(s=e==null?void 0:e.usage)!=null&&s.promptTokens&&(this.promptTokens=e.usage.promptTokens),this.scrollToBottom()},compact:e=>{this.logItems.push({type:"system",content:`【压缩完成】${e.summary||""}`,_id:`log-${++this.logSeq}`}),this.loadMessages()},done:e=>{var s;this.isProcessing=!1,this.stopping=!1,e!=null&&e.modelName&&(this.modelName=e.modelName),(s=e==null?void 0:e.usage)!=null&&s.promptTokens&&(this.promptTokens=e.usage.promptTokens),e!=null&&e.response&&this.logItems.push({type:"think",content:e.response,_id:`log-${++this.logSeq}`}),this.scrollToBottom()},stopped:()=>{this.isProcessing=!1,this.stopping=!1,this.logItems.push({type:"think",content:"【已停止】",_id:`log-${++this.logSeq}`}),this.scrollToBottom()},error:e=>{this.isProcessing=!1,this.stopping=!1,this.$message.error((e==null?void 0:e.error)||"发生错误")}}))},insertGenerateCommand(){this.specFilePath&&(this.inputMessage=`根据 ${this.specFilePath} 方案开发相应功能,先不要修改方案文档。`)},async sendMessage(){const e=this.inputMessage.trim();!e||this.isProcessing||!this.sessionId||(this.wsUnsubscribe||this.subscribeSession(),this.inputMessage="",this.isProcessing=!0,this.logItems.push({type:"chat",content:e,_id:`log-${++this.logSeq}`}),this.scrollToBottom(),c.send("chat",{message:e,sessionId:this.sessionId,modelName:this.modelName||void 0}))},stopGeneration(){this.sessionId&&(this.isProcessing=!1,this.stopping=!0,c.send("stop",{sessionId:this.sessionId}))},appendCommand(e){var s;this.inputMessage=e+" ",(s=this.$refs.inputField)==null||s.focus()},openFileSelect(){this.showFileDrawer=!0},onFileSelected(e){var s;this.inputMessage=this.inputMessage+e+" ",this.showFileDrawer=!1,(s=this.$refs.inputField)==null||s.focus()},closeAllDrawers(){this.showModelDrawer=!1,this.showCommandDrawer=!1,this.showFileDrawer=!1},renderMarkdown(e){return e?u(e):""},getTodoStatusIcon(e){return{completed:"✅",in_progress:"🔄",pending:"⬜",cancelled:"❌"}[e]||"⬜"},formatToolArgs(e){var s;try{const t=JSON.parse(((s=e==null?void 0:e.function)==null?void 0:s.arguments)||"{}");return t.file_path?t.file_path:t.command?t.command:""}catch{return""}},scrollToBottom(){this.$nextTick(()=>{this.$refs.chatArea&&(this.$refs.chatArea.scrollTop=this.$refs.chatArea.scrollHeight)})}}};var N=function(){var s=this,t=s._self._c;return t("div",{staticClass:"step3-code"},[t("div",{staticClass:"chat-toolbar"},[t("span",{staticClass:"model-name",on:{click:function(i){s.showModelDrawer=!0}}},[s._v(" "+s._s(s.modelName||"gpt-4o")+" "),t("i",{staticClass:"fa-solid fa-chevron-down"})]),t("button",{staticClass:"toolbar-btn",attrs:{disabled:s.isProcessing},on:{click:s.insertGenerateCommand}},[t("i",{staticClass:"fa-solid fa-code"})]),t("button",{staticClass:"toolbar-btn",on:{click:function(i){s.showCommandDrawer=!0}}},[t("i",{staticClass:"fa-solid fa-terminal"})]),t("button",{staticClass:"toolbar-btn",on:{click:function(i){s.showFileDrawer=!0}}},[t("i",{staticClass:"fa-solid fa-file-circle-plus"})])]),t("div",{ref:"chatArea",staticClass:"chat-area"},[s.logItems.length?s._e():t("div",{staticClass:"empty-state"},[t("i",{staticClass:"fa-solid fa-code"}),t("p",[s._v("描述代码需求,AI将生成代码")])]),s._l(s.logItems,function(i,r){return[i.type==="chat"?t("div",{staticClass:"message user"},[t("div",{staticClass:"message-bubble"},[s._v(s._s(i.content))])]):i.type==="think"?t("div",{staticClass:"message assistant"},[t("div",{staticClass:"message-bubble",domProps:{innerHTML:s._s(s.renderMarkdown(i.content))}})]):i.type==="step"?t("div",{staticClass:"step-block"},[i.thought?t("div",{staticClass:"message assistant"},[t("div",{staticClass:"message-bubble",domProps:{innerHTML:s._s(s.renderMarkdown(i.thought))}})]):s._e(),s._l(i.toolCalls,function(a,n){var l;return t("div",{key:"tc-"+n,staticClass:"tool-log",class:i.success!==!1?"tool-success":"tool-fail"},[t("span",[s._v(s._s(i.success!==!1?"✓":"✗"))]),t("span",{staticClass:"tool-name"},[s._v(s._s(((l=a==null?void 0:a.function)==null?void 0:l.name)||"unknown"))]),t("span",{staticClass:"tool-args"},[s._v(s._s(s.formatToolArgs(a)))])])})],2):i.type==="system"?t("div",{staticClass:"message assistant"},[t("div",{staticClass:"message-bubble system"},[s._v(s._s(i.content))])]):i.type==="todos"?t("div",{staticClass:"message assistant"},[t("div",{staticClass:"todo-list"},s._l(i.todos,function(a,n){return t("div",{key:n,staticClass:"todo-item"},[t("span",{staticClass:"todo-status"},[s._v(s._s(s.getTodoStatusIcon(a.status)))]),t("span",[s._v(s._s(a.name))])])}),0)]):s._e()]}),s.isProcessing?t("div",{staticClass:"message assistant thinking"},[t("div",{staticClass:"message-bubble"},[s._v("生成中...")])]):s._e()],2),t("div",{staticClass:"input-area"},[t("div",{staticClass:"input-wrapper"},[t("textarea",{directives:[{name:"model",rawName:"v-model",value:s.inputMessage,expression:"inputMessage"}],ref:"inputField",staticClass:"input-field",attrs:{placeholder:"描述代码需求... (Enter发送)"},domProps:{value:s.inputMessage},on:{keydown:function(i){return!i.type.indexOf("key")&&s._k(i.keyCode,"enter",13,i.key,"Enter")||i.ctrlKey||i.shiftKey||i.altKey||i.metaKey?null:(i.preventDefault(),s.sendMessage.apply(null,arguments))},input:function(i){i.target.composing||(s.inputMessage=i.target.value)}}})]),t("button",{staticClass:"send-btn",class:{"stop-btn":s.isProcessing},attrs:{disabled:!s.inputMessage.trim()&&!s.isProcessing},on:{click:function(i){s.isProcessing?s.stopGeneration():s.sendMessage()}}},[t("i",{class:s.isProcessing?"fa-solid fa-stop":"fa-solid fa-paper-plane"})])]),t("div",{staticClass:"status-bar"},[t("span",{staticClass:"status-indicator"},[t("span",{staticClass:"status-dot",class:{processing:s.isProcessing}}),s._v(" "+s._s(s.isProcessing?"生成中...":"就绪")+" ")]),t("span",[s._v("Token: "+s._s(s.promptTokens||0))])]),t("div",{staticClass:"drawer-overlay",class:{show:s.showModelDrawer||s.showCommandDrawer||s.showFileDrawer},on:{click:s.closeAllDrawers}}),t("FileSelectDrawer",{attrs:{visible:s.showFileDrawer},on:{select:s.onFileSelected,close:function(i){s.showFileDrawer=!1}}}),t("div",{staticClass:"model-drawer",class:{show:s.showModelDrawer}},[t("div",{staticClass:"drawer-header"},[t("span",{staticClass:"drawer-title"},[s._v("选择模型")]),t("button",{staticClass:"drawer-close",on:{click:function(i){s.showModelDrawer=!1}}},[t("i",{staticClass:"fa-solid fa-xmark"})])]),t("div",{staticClass:"command-list"},s._l(s.models,function(i){return t("div",{key:i.id,staticClass:"command-item",class:{active:i.name===s.modelName},on:{click:function(r){return s.selectModel(i)}}},[s._m(0,!0),t("div",{staticClass:"command-info"},[t("div",{staticClass:"command-name"},[s._v(s._s(i.name))]),t("div",{staticClass:"command-desc"},[s._v(s._s(i.provider||"默认"))])])])}),0)]),t("div",{staticClass:"command-drawer",class:{show:s.showCommandDrawer}},[t("div",{staticClass:"drawer-header"},[t("span",{staticClass:"drawer-title"},[s._v("快捷命令")]),t("button",{staticClass:"drawer-close",on:{click:function(i){s.showCommandDrawer=!1}}},[t("i",{staticClass:"fa-solid fa-xmark"})])]),t("div",{staticClass:"command-list"},[t("div",{staticClass:"command-item",on:{click:function(i){s.appendCommand("/compact"),s.showCommandDrawer=!1}}},[s._m(1),s._m(2)]),t("div",{staticClass:"command-item",on:{click:function(i){s.appendCommand("/clear"),s.showCommandDrawer=!1}}},[s._m(3),s._m(4)]),t("div",{staticClass:"command-item",on:{click:function(i){s.openFileSelect(),s.showCommandDrawer=!1}}},[s._m(5),s._m(6)])])])],1)},A=[function(){var e=this,s=e._self._c;return s("div",{staticClass:"command-icon"},[s("i",{staticClass:"fa-solid fa-microchip"})])},function(){var e=this,s=e._self._c;return s("div",{staticClass:"command-icon"},[s("i",{staticClass:"fa-solid fa-compress-alt"})])},function(){var e=this,s=e._self._c;return s("div",{staticClass:"command-info"},[s("div",{staticClass:"command-name"},[e._v("压缩会话")]),s("div",{staticClass:"command-desc"},[e._v("减少上下文长度")])])},function(){var e=this,s=e._self._c;return s("div",{staticClass:"command-icon"},[s("i",{staticClass:"fa-solid fa-trash"})])},function(){var e=this,s=e._self._c;return s("div",{staticClass:"command-info"},[s("div",{staticClass:"command-name"},[e._v("清空对话")]),s("div",{staticClass:"command-desc"},[e._v("清空当前会话内容")])])},function(){var e=this,s=e._self._c;return s("div",{staticClass:"command-icon"},[s("i",{staticClass:"fa-solid fa-file-circle-plus"})])},function(){var e=this,s=e._self._c;return s("div",{staticClass:"command-info"},[s("div",{staticClass:"command-name"},[e._v("选择文件")]),s("div",{staticClass:"command-desc"},[e._v("添加参考文件到上下文")])])}],B=h(j,N,A,!1,null,"4f825433");const x=B.exports,R={name:"AppStep4Test",components:{FileSelectDrawer:p},props:{category:{type:String,default:""},name:{type:String,default:""},reqBasePath:{type:String,default:""}},data(){return{inputMessage:"",isProcessing:!1,stopping:!1,logItems:[],sessionId:"",modelName:"",promptTokens:0,showModelDrawer:!1,showCommandDrawer:!1,showFileDrawer:!1,models:[],logSeq:0,wsUnsubscribe:null}},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(){c.init(),await this.loadModels(),await this.loadDefaultModel(),await this.loadSession()},beforeDestroy(){this.wsUnsubscribe&&this.wsUnsubscribe()},methods:{async loadModels(){try{const e=await o.getModels();this.models=e.data||[]}catch(e){console.error("Load models failed:",e)}},async loadDefaultModel(){var e;try{const s=await o.getConfig("defaultModel");(e=s.data)!=null&&e.value&&(this.modelName=s.data.value)}catch{this.modelName="gpt-4o"}},selectModel(e){const s=e.name.split("/");this.modelName=s.length>2?s.slice(1).join("/"):e.name,o.setConfig("defaultModel",this.modelName),this.showModelDrawer=!1},async loadSession(){if(!this.category||!this.name){this.sessionId="";return}try{const e=`${this.reqBasePath}/${this.category}/${this.name}/session.json`,s=await o.getFileContent(e);if(s&&s.content){const t=JSON.parse(s.content);this.sessionId=t.testSessionId||""}else this.sessionId="";this.sessionId&&(await this.loadMessages(),this.subscribeSession())}catch{this.sessionId=""}},async loadMessages(){if(this.sessionId)try{const e=await m(this.sessionId);this.logItems=(e.data||[]).map(s=>s.type==="think"?{type:"think",content:s.content||"",_id:`log-${++this.logSeq}`}:s.type==="step"?{type:"step",thought:s.thought,toolCalls:s.toolCalls||[],success:s.success,_id:`log-${++this.logSeq}`}:s.type==="chat"?{type:"chat",content:s.content,_id:`log-${++this.logSeq}`}:s.type==="todos"?{type:"todos",todos:s.todos||[],_id:`log-${++this.logSeq}`}:{type:"system",content:String(s),_id:`log-${++this.logSeq}`}),this.scrollToBottom()}catch(e){console.error("Load messages failed:",e)}},subscribeSession(){this.sessionId&&(this.wsUnsubscribe&&this.wsUnsubscribe(),this.wsUnsubscribe=c.subscribe(this.sessionId,{running_sessions:e=>{const s=(e==null?void 0:e.runningSessionIds)||[];this.isProcessing=s.includes(this.sessionId)},todos:e=>{this.logItems.push({type:"todos",todos:e.todos,_id:`log-${++this.logSeq}`}),this.scrollToBottom()},step:e=>{var s;this.logItems.push({type:"step",thought:e==null?void 0:e.thought,toolCalls:(e==null?void 0:e.toolCalls)||[],success:e==null?void 0:e.success,_id:`log-${++this.logSeq}`}),(s=e==null?void 0:e.usage)!=null&&s.promptTokens&&(this.promptTokens=e.usage.promptTokens),this.scrollToBottom()},compact:e=>{this.logItems.push({type:"system",content:`【压缩完成】${e.summary||""}`,_id:`log-${++this.logSeq}`}),this.loadMessages()},done:e=>{var s;this.isProcessing=!1,this.stopping=!1,e!=null&&e.modelName&&(this.modelName=e.modelName),(s=e==null?void 0:e.usage)!=null&&s.promptTokens&&(this.promptTokens=e.usage.promptTokens),e!=null&&e.response&&this.logItems.push({type:"think",content:e.response,_id:`log-${++this.logSeq}`}),this.scrollToBottom()},stopped:()=>{this.isProcessing=!1,this.stopping=!1,this.logItems.push({type:"think",content:"【已停止】",_id:`log-${++this.logSeq}`}),this.scrollToBottom()},error:e=>{this.isProcessing=!1,this.stopping=!1,this.$message.error((e==null?void 0:e.error)||"发生错误")}}))},insertTestCommand(){this.specFilePath&&(this.inputMessage=`根据 ${this.specFilePath} 方案测试相应功能是否实现。`)},async sendMessage(){const e=this.inputMessage.trim();!e||this.isProcessing||!this.sessionId||(this.wsUnsubscribe||this.subscribeSession(),this.inputMessage="",this.isProcessing=!0,this.logItems.push({type:"chat",content:e,_id:`log-${++this.logSeq}`}),this.scrollToBottom(),c.send("chat",{message:e,sessionId:this.sessionId,modelName:this.modelName||void 0}))},stopGeneration(){this.sessionId&&(this.isProcessing=!1,this.stopping=!0,c.send("stop",{sessionId:this.sessionId}))},appendCommand(e){var s;this.inputMessage=e+" ",(s=this.$refs.inputField)==null||s.focus()},openFileSelect(){this.showFileDrawer=!0},onFileSelected(e){var s;this.inputMessage=this.inputMessage+e+" ",this.showFileDrawer=!1,(s=this.$refs.inputField)==null||s.focus()},closeAllDrawers(){this.showModelDrawer=!1,this.showCommandDrawer=!1,this.showFileDrawer=!1},renderMarkdown(e){return e?u(e):""},getTodoStatusIcon(e){return{completed:"✅",in_progress:"🔄",pending:"⬜",cancelled:"❌"}[e]||"⬜"},formatToolArgs(e){var s;try{const t=JSON.parse(((s=e==null?void 0:e.function)==null?void 0:s.arguments)||"{}");return t.file_path?t.file_path:t.command?t.command:""}catch{return""}},scrollToBottom(){this.$nextTick(()=>{this.$refs.chatArea&&(this.$refs.chatArea.scrollTop=this.$refs.chatArea.scrollHeight)})}}};var V=function(){var s=this,t=s._self._c;return t("div",{staticClass:"step4-test"},[t("div",{staticClass:"chat-toolbar"},[t("span",{staticClass:"model-name",on:{click:function(i){s.showModelDrawer=!0}}},[s._v(" "+s._s(s.modelName||"gpt-4o")+" "),t("i",{staticClass:"fa-solid fa-chevron-down"})]),t("button",{staticClass:"toolbar-btn",attrs:{disabled:s.isProcessing},on:{click:s.insertTestCommand}},[t("i",{staticClass:"fa-solid fa-check-circle"})]),t("button",{staticClass:"toolbar-btn",on:{click:function(i){s.showCommandDrawer=!0}}},[t("i",{staticClass:"fa-solid fa-terminal"})]),t("button",{staticClass:"toolbar-btn",on:{click:function(i){s.showFileDrawer=!0}}},[t("i",{staticClass:"fa-solid fa-file-circle-plus"})])]),t("div",{ref:"chatArea",staticClass:"chat-area"},[s.logItems.length?s._e():t("div",{staticClass:"empty-state"},[t("i",{staticClass:"fa-solid fa-clipboard-check"}),t("p",[s._v("描述测试需求,AI将进行验收测试")])]),s._l(s.logItems,function(i,r){return[i.type==="chat"?t("div",{staticClass:"message user"},[t("div",{staticClass:"message-bubble"},[s._v(s._s(i.content))])]):i.type==="think"?t("div",{staticClass:"message assistant"},[t("div",{staticClass:"message-bubble",domProps:{innerHTML:s._s(s.renderMarkdown(i.content))}})]):i.type==="step"?t("div",{staticClass:"step-block"},[i.thought?t("div",{staticClass:"message assistant"},[t("div",{staticClass:"message-bubble",domProps:{innerHTML:s._s(s.renderMarkdown(i.thought))}})]):s._e(),s._l(i.toolCalls,function(a,n){var l;return t("div",{key:"tc-"+n,staticClass:"tool-log",class:i.success!==!1?"tool-success":"tool-fail"},[t("span",[s._v(s._s(i.success!==!1?"✓":"✗"))]),t("span",{staticClass:"tool-name"},[s._v(s._s(((l=a==null?void 0:a.function)==null?void 0:l.name)||"unknown"))]),t("span",{staticClass:"tool-args"},[s._v(s._s(s.formatToolArgs(a)))])])})],2):i.type==="system"?t("div",{staticClass:"message assistant"},[t("div",{staticClass:"message-bubble system"},[s._v(s._s(i.content))])]):i.type==="todos"?t("div",{staticClass:"message assistant"},[t("div",{staticClass:"todo-list"},s._l(i.todos,function(a,n){return t("div",{key:n,staticClass:"todo-item"},[t("span",{staticClass:"todo-status"},[s._v(s._s(s.getTodoStatusIcon(a.status)))]),t("span",[s._v(s._s(a.name))])])}),0)]):s._e()]}),s.isProcessing?t("div",{staticClass:"message assistant thinking"},[t("div",{staticClass:"message-bubble"},[s._v("测试中...")])]):s._e()],2),t("div",{staticClass:"input-area"},[t("div",{staticClass:"input-wrapper"},[t("textarea",{directives:[{name:"model",rawName:"v-model",value:s.inputMessage,expression:"inputMessage"}],ref:"inputField",staticClass:"input-field",attrs:{placeholder:"描述测试需求... (Enter发送)"},domProps:{value:s.inputMessage},on:{keydown:function(i){return!i.type.indexOf("key")&&s._k(i.keyCode,"enter",13,i.key,"Enter")||i.ctrlKey||i.shiftKey||i.altKey||i.metaKey?null:(i.preventDefault(),s.sendMessage.apply(null,arguments))},input:function(i){i.target.composing||(s.inputMessage=i.target.value)}}})]),t("button",{staticClass:"send-btn",class:{"stop-btn":s.isProcessing},attrs:{disabled:!s.inputMessage.trim()&&!s.isProcessing},on:{click:function(i){s.isProcessing?s.stopGeneration():s.sendMessage()}}},[t("i",{class:s.isProcessing?"fa-solid fa-stop":"fa-solid fa-paper-plane"})])]),t("div",{staticClass:"status-bar"},[t("span",{staticClass:"status-indicator"},[t("span",{staticClass:"status-dot",class:{processing:s.isProcessing}}),s._v(" "+s._s(s.isProcessing?"测试中...":"就绪")+" ")]),t("span",[s._v("Token: "+s._s(s.promptTokens||0))])]),t("div",{staticClass:"drawer-overlay",class:{show:s.showModelDrawer||s.showCommandDrawer||s.showFileDrawer},on:{click:s.closeAllDrawers}}),t("FileSelectDrawer",{attrs:{visible:s.showFileDrawer},on:{select:s.onFileSelected,close:function(i){s.showFileDrawer=!1}}}),t("div",{staticClass:"model-drawer",class:{show:s.showModelDrawer}},[t("div",{staticClass:"drawer-header"},[t("span",{staticClass:"drawer-title"},[s._v("选择模型")]),t("button",{staticClass:"drawer-close",on:{click:function(i){s.showModelDrawer=!1}}},[t("i",{staticClass:"fa-solid fa-xmark"})])]),t("div",{staticClass:"command-list"},s._l(s.models,function(i){return t("div",{key:i.id,staticClass:"command-item",class:{active:i.name===s.modelName},on:{click:function(r){return s.selectModel(i)}}},[s._m(0,!0),t("div",{staticClass:"command-info"},[t("div",{staticClass:"command-name"},[s._v(s._s(i.name))]),t("div",{staticClass:"command-desc"},[s._v(s._s(i.provider||"默认"))])])])}),0)]),t("div",{staticClass:"command-drawer",class:{show:s.showCommandDrawer}},[t("div",{staticClass:"drawer-header"},[t("span",{staticClass:"drawer-title"},[s._v("快捷命令")]),t("button",{staticClass:"drawer-close",on:{click:function(i){s.showCommandDrawer=!1}}},[t("i",{staticClass:"fa-solid fa-xmark"})])]),t("div",{staticClass:"command-list"},[t("div",{staticClass:"command-item",on:{click:function(i){s.appendCommand("/compact"),s.showCommandDrawer=!1}}},[s._m(1),s._m(2)]),t("div",{staticClass:"command-item",on:{click:function(i){s.appendCommand("/clear"),s.showCommandDrawer=!1}}},[s._m(3),s._m(4)]),t("div",{staticClass:"command-item",on:{click:function(i){s.openFileSelect(),s.showCommandDrawer=!1}}},[s._m(5),s._m(6)])])])],1)},U=[function(){var e=this,s=e._self._c;return s("div",{staticClass:"command-icon"},[s("i",{staticClass:"fa-solid fa-microchip"})])},function(){var e=this,s=e._self._c;return s("div",{staticClass:"command-icon"},[s("i",{staticClass:"fa-solid fa-compress-alt"})])},function(){var e=this,s=e._self._c;return s("div",{staticClass:"command-info"},[s("div",{staticClass:"command-name"},[e._v("压缩会话")]),s("div",{staticClass:"command-desc"},[e._v("减少上下文长度")])])},function(){var e=this,s=e._self._c;return s("div",{staticClass:"command-icon"},[s("i",{staticClass:"fa-solid fa-trash"})])},function(){var e=this,s=e._self._c;return s("div",{staticClass:"command-info"},[s("div",{staticClass:"command-name"},[e._v("清空对话")]),s("div",{staticClass:"command-desc"},[e._v("清空当前会话内容")])])},function(){var e=this,s=e._self._c;return s("div",{staticClass:"command-icon"},[s("i",{staticClass:"fa-solid fa-file-circle-plus"})])},function(){var e=this,s=e._self._c;return s("div",{staticClass:"command-info"},[s("div",{staticClass:"command-name"},[e._v("选择文件")]),s("div",{staticClass:"command-desc"},[e._v("添加参考文件到上下文")])])}],L=h(R,V,U,!1,null,"63c253f0");const K=L.exports,O={name:"DevWorkflowViewApp",components:{AppWorkflowStep:b,AppStep1Req:D,AppStep2Design:F,AppStep3Code:x,AppStep4Test:K},data(){return{currentCategory:"",currentProject:"",currentStep:1,categories:[],projects:{},reqBasePath:""}},computed:{projectKey(){return!this.currentCategory||!this.currentProject?"":`${this.currentCategory}/${this.currentProject}`}},async created(){await this.loadState(),await this.loadCategories()},watch:{currentProject(e){var t;const s=((t=this.$route.meta)==null?void 0:t.title)||"软件研发";e?document.title=`${e} · ${s} - TXCode`:document.title=`${s} - TXCode`}},methods:{async loadState(){try{const s=(await o.getWorkflowState()).data;s&&(this.currentCategory=s.currentCategory||"",this.currentProject=s.currentProject||"",this.currentStep=s.currentStep||1)}catch(e){console.error("Load workflow state failed:",e)}},async saveState(){try{await o.updateWorkflowState(this.currentCategory,this.currentProject,this.currentStep)}catch(e){console.error("Save workflow state failed:",e)}},async loadCategories(){var e,s;try{const t=await o.getCwd();this.reqBasePath=((e=t.data)==null?void 0:e.basePath)||"";const r=((s=(await o.browseFilesystem(this.reqBasePath)).data)==null?void 0:s.items)||[];this.categories=r.filter(a=>a.is_directory).map(a=>a.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(e){var s;if(e)try{const t=`${this.reqBasePath}/${e}`,r=((s=(await o.browseFilesystem(t)).data)==null?void 0:s.items)||[];this.projects={},r.filter(a=>a.is_directory).forEach(a=>{const n=`${e}/${a.name}`;this.projects[n]={name:a.name,stepStatus:{}}})}catch(t){console.error("Load projects failed:",t)}},async onCategoryChange(e){this.currentCategory=e,this.currentProject="",this.currentStep=1,e?await this.loadProjectsForCategory(e):this.projects={},await this.saveState()},onProjectChange(e){this.currentProject=e,this.currentProject?this.currentStep=2:this.currentStep>1&&(this.currentStep=1),this.saveState()},onStepChange(e){!this.currentProject&&e>1||(this.currentStep=e,this.saveState())},async createCategory(e){if(!this.categories.includes(e))try{const s=`${this.reqBasePath}/${e}`;await o.createDirectory(s),this.categories.push(e),this.categories.sort()}catch(s){console.error("Create category failed:",s)}},async createRequirement({category:e,name:s}){var a,n,l;if(this.projects[s])return;try{const d=`${this.reqBasePath}/${e}/${s}`;await o.createDirectory(d)}catch(d){console.error("Create requirement directory failed:",d)}const t=`# ${s}方案
|
|
4
4
|
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{n,e as o,K as c,c as d,a as r}from"./index-
|
|
1
|
+
import{n,e as o,K as c,c as d,a as r}from"./index-Dtkc_ka-.js";import{C as f}from"./ConfirmDialog-BG4cU7oU.js";const h={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 u=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)+" 个文件变更")])])])},g=[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("没有待提交的变更")])])}],p=n(h,u,g,!1,null,"1c0b3629");const x=p.exports,v={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 m=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)])])},b=[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")])])}],C=n(v,m,b,!1,null,null);const _=C.exports,y=console.error;console.error=(...s)=>{var t;(t=s[0])!=null&&t.toString().includes("toUrl")||y(...s)};const w={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 $=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=[],L=n(w,$,R,!1,null,null);const k=L.exports,D={name:"GitChanges",components:{GitChangesSidebar:x,DiffViewer:_,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 S=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)},F=[],j=n(D,S,F,!1,null,null);const z=j.exports;export{z as default};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{n as r,a as n}from"./index-
|
|
1
|
+
import{n as r,a as n}from"./index-Dtkc_ka-.js";import{C as c}from"./ConfirmDialog-BG4cU7oU.js";const f={name:"GitChangesApp",components:{ConfirmDialog:c},data(){return{isRepo:!1,branch:"",changes:[],loading:!1,selectedChange:null,diffLines:[],diffLoading:!1,currentTab:"modified",currentFilter:"all",confirmDialog:{visible:!1,message:"",action:null,target:null}}},computed:{tabs(){return[{key:"modified",label:"已修改",count:this.changes.filter(e=>e.status==="modified").length},{key:"staged",label:"已暂存",count:this.changes.filter(e=>e.status==="staged").length},{key:"untracked",label:"未跟踪",count:this.changes.filter(e=>e.status==="untracked").length}]},filters(){return[{key:"all",label:"全部"},{key:"file",label:"仅文件"},{key:"dir",label:"仅目录"}]},stats(){return{add:this.changes.filter(e=>e.status==="add"||e.status==="new").length,mod:this.changes.filter(e=>e.status==="mod"||e.status==="modified").length,del:this.changes.filter(e=>e.status==="del"||e.status==="deleted").length}},filteredChanges(){let e=this.changes;return this.currentTab==="modified"?e=e.filter(s=>s.status==="modified"||s.status==="mod"):this.currentTab==="staged"?e=e.filter(s=>s.status==="staged"):this.currentTab==="untracked"&&(e=e.filter(s=>s.status==="untracked"||s.status==="new"||s.status==="add")),this.currentFilter==="file"?e=e.filter(s=>!s.path.endsWith("/")):this.currentFilter==="dir"&&(e=e.filter(s=>s.path.endsWith("/"))),e}},async created(){await this.checkRepo(),await this.refreshChanges()},methods:{async checkRepo(){try{const e=await n.gitIsRepo();this.isRepo=e.isRepo,this.branch=e.branch||""}catch{this.isRepo=!1}},async refreshChanges(){if(this.isRepo){this.loading=!0;try{const e=await n.gitStatus();this.changes=(e.changes||[]).map(s=>{let t="modified";return s.isNew||s.status==="new"?t="untracked":s.isStaged||s.status==="staged"?t="staged":s.isDeleted||s.status==="deleted"?t="del":s.isModified||s.status==="modified"?t="mod":(s.isAdded||s.status==="added")&&(t="add"),{...s,status:t}}),this.selectedChange&&(this.changes.find(t=>t.path===this.selectedChange.path)||(this.selectedChange=null))}catch(e){console.error("Failed to get git status:",e)}finally{this.loading=!1}}},async refresh(){await this.refreshChanges()},selectChange(e){this.selectedChange=e,this.loadDiff(e)},async loadDiff(e){this.diffLoading=!0,this.diffLines=[];try{const s=await n.gitDiff(e.path);this.diffLines=this.parseDiff(s.diff||"")}catch(s){console.error("Failed to get diff:",s)}finally{this.diffLoading=!1}},parseDiff(e){if(!e)return[];const s=e.split(`
|
|
2
2
|
`);let t=1,a=1;const l=[];for(const i of s)if(i.startsWith("@@")){const d=i.match(/@@ -(\d+),?\d* \+(\d+),?\d* @@/);d&&(t=parseInt(d[1]),a=parseInt(d[2])),l.push({lineNum:"",sign:"",content:i,type:"header"})}else{if(i.startsWith("---")||i.startsWith("+++")||i.startsWith("diff ")||i.startsWith("index "))continue;i.startsWith("-")?l.push({lineNum:t++,sign:"-",content:i.substring(1),type:"del"}):i.startsWith("+")?l.push({lineNum:a++,sign:"+",content:i.substring(1),type:"add"}):(l.push({lineNum:t++,sign:" ",content:i,type:"context"}),a++)}return l},getStatusClass(e){return{add:"add",new:"new",mod:"mod",modified:"mod",del:"del",deleted:"del",untracked:"new"}[e]||"mod"},getStatusIcon(e){return{add:"fa-solid fa-plus",new:"fa-solid fa-star",mod:"fa-solid fa-pen",modified:"fa-solid fa-pen",del:"fa-solid fa-trash",deleted:"fa-solid fa-trash",staged:"fa-solid fa-check",untracked:"fa-solid fa-star"}[e]||"fa-solid fa-pen"},getFileName(e){const s=e.split("/");return s[s.length-1]},getFilePath(e){const s=e.split("/");return s.pop(),s.join("/")},confirmRevertAll(){this.filteredChanges.length!==0&&(this.confirmDialog={visible:!0,message:`确定要撤销所有 ${this.filteredChanges.length} 个文件的变更吗?此操作不可恢复。`,action:"revertAll",target:null})},cancelConfirm(){this.confirmDialog.visible=!1},async executeConfirm(){const{action:e,target:s}=this.confirmDialog;this.confirmDialog.visible=!1;try{e==="revertAll"?(await n.gitRevertAll(),await n.gitDiscardUntracked(),this.$message.success("所有变更已撤销")):e==="revert"?(await n.gitRevert(s.path),this.$message.success("文件已撤销")):e==="delete"&&(await n.gitDeleteFile(s.path),this.$message.success("文件已删除")),await this.refreshChanges()}catch(t){console.error("Operation failed:",t),this.$message.error("操作失败: "+(t.message||"未知错误"))}},openCommit(){this.$message.info("提交功能开发中")}}};var o=function(){var s=this,t=s._self._c;return t("div",{staticClass:"git-changes-app"},[t("header",{staticClass:"header"},[s._m(0),t("span",{staticClass:"header-title"},[s._v("Git 变更")]),t("div",{staticClass:"header-actions"},[t("button",{staticClass:"header-btn",attrs:{title:"刷新"},on:{click:s.refresh}},[t("i",{staticClass:"fa-solid fa-rotate",class:{"fa-spin":s.loading}})])])]),t("div",{staticClass:"change-summary"},[t("div",{staticClass:"summary-stats"},[t("span",{staticClass:"stat-item add"},[t("i",{staticClass:"fa-solid fa-plus"}),s._v(" "+s._s(s.stats.add)+" ")]),t("span",{staticClass:"stat-item mod"},[t("i",{staticClass:"fa-solid fa-pen"}),s._v(" "+s._s(s.stats.mod)+" ")]),t("span",{staticClass:"stat-item del"},[t("i",{staticClass:"fa-solid fa-minus"}),s._v(" "+s._s(s.stats.del)+" ")])]),s.branch?t("div",{staticClass:"branch-info"},[t("i",{staticClass:"fa-solid fa-code-branch"}),t("span",[s._v(s._s(s.branch))])]):s._e()]),t("div",{staticClass:"tab-bar"},s._l(s.tabs,function(a){return t("div",{key:a.key,staticClass:"tab-item",class:{active:s.currentTab===a.key},on:{click:function(l){s.currentTab=a.key}}},[s._v(" "+s._s(a.label)),t("span",{staticClass:"count"},[s._v(s._s(a.count))])])}),0),t("div",{staticClass:"filter-bar"},s._l(s.filters,function(a){return t("div",{key:a.key,staticClass:"filter-chip",class:{active:s.currentFilter===a.key},on:{click:function(l){s.currentFilter=a.key}}},[s._v(" "+s._s(a.label)+" ")])}),0),s.isRepo?s.filteredChanges.length>0?[s.selectedChange?t("div",{ref:"diffViewRef",staticClass:"diff-view"},[t("div",{staticClass:"diff-header"},[t("i",{staticClass:"fa-solid fa-file-code"}),t("span",[s._v(s._s(s.selectedChange.path))]),t("span",{staticStyle:{"margin-left":"auto",color:"var(--accent)"},on:{click:function(a){s.selectedChange=null}}},[s._v("收起")])]),!s.diffLoading&&s.diffLines.length>0?t("div",{staticClass:"diff-content"},s._l(s.diffLines,function(a,l){return t("div",{key:l,staticClass:"diff-line",class:a.type},[t("span",{staticClass:"line-num"},[s._v(s._s(a.lineNum))]),t("span",{staticClass:"line-sign",class:a.type},[s._v(s._s(a.sign))]),t("span",{staticClass:"line-text"},[s._v(s._s(a.content))])])}),0):s._e(),s.diffLoading?t("div",{staticClass:"diff-loading"},[t("span",{staticClass:"loading-spinner"}),s._v(" 加载中... ")]):s._e()]):t("div",{ref:"fileListRef",staticClass:"file-list"},s._l(s.filteredChanges,function(a,l){var i;return t("div",{key:l,staticClass:"change-item",class:{selected:((i=s.selectedChange)==null?void 0:i.path)===a.path},on:{click:function(d){return s.selectChange(a)}}},[t("div",{staticClass:"change-status",class:s.getStatusClass(a.status)},[t("i",{class:s.getStatusIcon(a.status)})]),t("div",{staticClass:"change-info"},[t("div",{staticClass:"change-name"},[s._v(s._s(s.getFileName(a.path)))]),t("div",{staticClass:"change-path"},[s._v(s._s(s.getFilePath(a.path)))])]),a.linesAdded!==void 0||a.linesDeleted!==void 0?t("div",{staticClass:"change-stats"},[a.linesAdded?t("span",{staticClass:"add-line"},[s._v("+"+s._s(a.linesAdded))]):s._e(),a.linesAdded&&a.linesDeleted?t("span",[s._v(" / ")]):s._e(),a.linesDeleted?t("span",{staticClass:"del-line"},[s._v("-"+s._s(a.linesDeleted))]):s._e()]):s._e()])}),0)]:t("div",{staticClass:"file-list"},[s._m(2)]):t("div",{staticClass:"file-list"},[s._m(1)]),t("div",{staticClass:"bottom-actions"},[t("button",{staticClass:"action-btn secondary",attrs:{disabled:s.filteredChanges.length===0},on:{click:s.confirmRevertAll}},[t("i",{staticClass:"fa-solid fa-arrow-rotate-left"}),s._v(" 撤销全部 ")])]),t("confirm-dialog",{attrs:{visible:s.confirmDialog.visible,message:s.confirmDialog.message},on:{confirm:s.executeConfirm,cancel:s.cancelConfirm}})],2)},h=[function(){var e=this,s=e._self._c;return s("a",{staticClass:"header-back",attrs:{href:"/app"}},[s("i",{staticClass:"fa-solid fa-chevron-left"})])},function(){var e=this,s=e._self._c;return s("div",{staticClass:"empty-state"},[s("div",{staticClass:"empty-icon"},[s("i",{staticClass:"fa-solid fa-folder-open"})]),s("div",{staticClass:"empty-title"},[e._v("非 Git 仓库")]),s("div",{staticClass:"empty-desc"},[e._v("当前目录不是 Git 仓库,无法查看变更")])])},function(){var e=this,s=e._self._c;return s("div",{staticClass:"empty-state"},[s("div",{staticClass:"empty-icon"},[s("i",{staticClass:"fa-solid fa-check"})]),s("div",{staticClass:"empty-title"},[e._v("暂无变更")]),s("div",{staticClass:"empty-desc"},[e._v("工作区干净,没有检测到变更")])])}],u=r(f,o,h,!1,null,"ca727fe2");const p=u.exports;export{p as default};
|