tianxincode 1.0.43 → 1.0.45

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. package/dist/modules/ai/agents/dream/prompts/init.txt +21 -0
  2. package/package.json +1 -1
  3. package/scripts/copy-txt.js +2 -0
  4. package/web/dist/assets/{AiLogsView-D4q7SeY_.js → AiLogsView-CGChYsCu.js} +1 -1
  5. package/web/dist/assets/{ConfirmDialog-BG4cU7oU.js → ConfirmDialog-i764Fe1J.js} +1 -1
  6. package/web/dist/assets/{CustomActionsView-DTvj_4OE.js → CustomActionsView-DK90gPZQ.js} +1 -1
  7. package/web/dist/assets/DevWorkflowView-Dlx87j1J.css +1 -0
  8. package/web/dist/assets/DevWorkflowView-DrB-43Yj.js +32 -0
  9. package/web/dist/assets/{DevWorkflowViewApp-CPTC7cf7.css → DevWorkflowViewApp-Dh8RmDTn.css} +1 -1
  10. package/web/dist/assets/{DevWorkflowViewApp-D8czrLj2.js → DevWorkflowViewApp-_HnmCVhK.js} +14 -3
  11. package/web/dist/assets/{GitChanges-DxJT8Ng9.js → GitChanges-SeV5YkQj.js} +1 -1
  12. package/web/dist/assets/{GitChangesApp-DGRKqsrc.js → GitChangesApp-DKYWSFuu.js} +1 -1
  13. package/web/dist/assets/{Layout-CIntssMR.js → Layout-Dac-0iLp.js} +1 -1
  14. package/web/dist/assets/{TasksView-DuTglEsf.js → TasksView-Czet5EAj.js} +1 -1
  15. package/web/dist/assets/{TerminalView-RG937_-M.js → TerminalView-D0lsGhmz.js} +1 -1
  16. package/web/dist/assets/{WikiView-wDIfjQT_.js → WikiView-Dv89zXYv.js} +1 -1
  17. package/web/dist/assets/{cssMode-DAdY-5X0.js → cssMode-DMbMrSuH.js} +1 -1
  18. package/web/dist/assets/{deployView-OlhJU698.js → deployView-3xv4omoq.js} +1 -1
  19. package/web/dist/assets/{fileZihao-Bm-uB2BS.js → fileZihao-BtiZhQPu.js} +1 -1
  20. package/web/dist/assets/{freemarker2-OIgEfGdK.js → freemarker2-SNlo5J8Q.js} +1 -1
  21. package/web/dist/assets/{handlebars-CwUrtebj.js → handlebars-BpK8If7E.js} +1 -1
  22. package/web/dist/assets/{html-DplPIfs6.js → html-nEQAifNW.js} +1 -1
  23. package/web/dist/assets/{htmlMode-BpbIfVaE.js → htmlMode-DEqGTpB2.js} +1 -1
  24. package/web/dist/assets/{index-D4xhVePW.css → index-BBtbYgnN.css} +1 -1
  25. package/web/dist/assets/{index-Dtkc_ka-.js → index-Ch_-1SCN.js} +170 -168
  26. package/web/dist/assets/{javascript-B_eZzRqF.js → javascript-BwcOXj_g.js} +1 -1
  27. package/web/dist/assets/{jsonMode-9MZfSMtt.js → jsonMode-53JPwHSr.js} +1 -1
  28. package/web/dist/assets/{liquid-Q68k40m8.js → liquid-V_os1vrB.js} +1 -1
  29. package/web/dist/assets/{mdx-BH-rWx_x.js → mdx-CPetceIt.js} +1 -1
  30. package/web/dist/assets/{python-DvT3SN5P.js → python-CMN0i-H4.js} +1 -1
  31. package/web/dist/assets/{razor-C2wZYTc7.js → razor-BNIl4Aha.js} +1 -1
  32. package/web/dist/assets/{tsMode-Cm8eLc0y.js → tsMode-DIXOnfbq.js} +1 -1
  33. package/web/dist/assets/{typescript-B5qDQjhx.js → typescript-eB2uDNeR.js} +1 -1
  34. package/web/dist/assets/{xml-CZxclJkM.js → xml-BsumxOS3.js} +1 -1
  35. package/web/dist/assets/{yaml-BAVixhgZ.js → yaml-CzHP1b1B.js} +1 -1
  36. package/web/dist/index.html +2 -2
  37. package/web/dist/assets/DevWorkflowView-BjUv5lsU.js +0 -16
  38. package/web/dist/assets/DevWorkflowView-Cc_t3ltj.css +0 -1
@@ -1,6 +1,8 @@
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} 生成方案,先不要修改代码。
1
+ import{n as p,f as g,g as m,w as h,h as v,a as o}from"./index-Ch_-1SCN.js";const w={name:"AppWorkflowStep",props:{currentStep:{type:Number,default:1}},data(){return{steps:[{id:1,label:"需求"},{id:2,label:"设计"},{id:3,label:"代码"},{id:4,label:"测试"}]}}};var y=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)},b=[],S=p(w,y,b,!1,null,"1cf39c0c");const $=S.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 P=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()])},D=[function(){var e=this,s=e._self._c;return s("div",{staticClass:"section-header"},[s("span",[e._v("选择大类")])])}],I=p(k,P,D,!1,null,"ff2d2605");const M=I.exports,q={name:"AppStep2Design",components:{FileSelectDrawer:g},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,parentInfo:null}},computed:{specFilePath(){return!this.category||!this.name?"":`${this.reqBasePath}/${this.category}/${this.name}/${this.name}_方案.md`},renderedContent(){return m(this.specContent||"")}},watch:{category:{handler(){this.loadData()}},name:{handler(){this.loadData()}},reqBasePath:{handler(e){e&&this.loadData()}}},async mounted(){h.init(),await this.loadModels(),await this.loadDefaultModel(),await this.loadData()},beforeDestroy(){this.wsUnsubscribe&&this.wsUnsubscribe()},methods:{async loadData(){this.reqBasePath&&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="",this.parentInfo=null;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||"",this.parentInfo=t.parent||null}else this.sessionId="",this.parentInfo=null;this.sessionId&&(await this.loadMessages(),this.subscribeSession())}catch{this.sessionId="",this.parentInfo=null}},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 v(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=h.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();let s="";this.logItems.length===0&&this.parentInfo&&(s=`
2
2
 
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}方案
3
+ 注意:当前方案是「${this.parentInfo.name}」的子方案,请参考父方案内容。父方案路径:${this.parentInfo.specPath}`);const t=`先在 ${this.specFilePath} 生成方案,先不要修改代码。${s}
4
+
5
+ 用户输入: ${e}`;this.inputMessage="",this.isProcessing=!0,this.logItems.push({type:"chat",content:e,_id:`log-${++this.logSeq}`}),this.scrollToBottom(),h.send("chat",{message:t,sessionId:this.sessionId,modelName:this.modelName||void 0})},stopGeneration(){this.sessionId&&(this.isProcessing=!1,this.stopping=!0,h.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?m(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 F=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)},T=[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("清空当前会话内容")])])}],j=p(q,F,T,!1,null,"f76fd17f");const B=j.exports,N={name:"AppStep3Code",components:{FileSelectDrawer:g},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(){h.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 v(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=h.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(),h.send("chat",{message:e,sessionId:this.sessionId,modelName:this.modelName||void 0}))},stopGeneration(){this.sessionId&&(this.isProcessing=!1,this.stopping=!0,h.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?m(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 A=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)},x=[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("添加参考文件到上下文")])])}],V=p(N,A,x,!1,null,"4f825433");const R=V.exports,U={name:"AppStep4Test",components:{FileSelectDrawer:g},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(){h.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 v(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=h.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(),h.send("chat",{message:e,sessionId:this.sessionId,modelName:this.modelName||void 0}))},stopGeneration(){this.sessionId&&(this.isProcessing=!1,this.stopping=!0,h.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?m(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 L=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)},K=[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("添加参考文件到上下文")])])}],O=p(U,L,K,!1,null,"63c253f0");const E=O.exports,W={name:"SubSchemeDialogApp",props:{visible:{type:Boolean,default:!1},category:{type:String,default:""},parentName:{type:String,default:""},defaultName:{type:String,default:""}},data(){return{name:""}},watch:{visible(e){e&&(this.name=this.defaultName)}},methods:{onConfirm(){const e=this.name.trim();e&&(this.$emit("confirm",e),this.$emit("update:visible",!1))},onCancel(){this.$emit("cancel"),this.$emit("update:visible",!1)}}};var H=function(){var s=this,t=s._self._c;return t("div",[t("div",{staticClass:"dialog-overlay",class:{show:s.visible},on:{click:s.onCancel}}),t("div",{staticClass:"dialog-sheet",class:{show:s.visible}},[t("div",{staticClass:"dialog-header"},[t("span",{staticClass:"dialog-title"},[s._v("新建子方案")]),t("button",{staticClass:"dialog-close",on:{click:s.onCancel}},[t("i",{staticClass:"fa-solid fa-xmark"})])]),t("div",{staticClass:"dialog-body"},[t("div",{staticClass:"form-group"},[t("label",[s._v("方案名称")]),t("input",{directives:[{name:"model",rawName:"v-model",value:s.name,expression:"name"}],staticClass:"form-input",attrs:{placeholder:"请输入子方案名称"},domProps:{value:s.name},on:{keyup:function(i){return!i.type.indexOf("key")&&s._k(i.keyCode,"enter",13,i.key,"Enter")?null:s.onConfirm.apply(null,arguments)},input:function(i){i.target.composing||(s.name=i.target.value)}}})]),t("div",{staticClass:"form-group"},[t("label",[s._v("所属大类")]),t("div",{staticClass:"form-text"},[s._v(s._s(s.category))])]),t("div",{staticClass:"form-group"},[t("label",[s._v("父方案")]),t("div",{staticClass:"form-text"},[s._v(s._s(s.parentName))])])]),t("div",{staticClass:"dialog-actions"},[t("button",{staticClass:"btn-cancel",on:{click:s.onCancel}},[s._v("取消")]),t("button",{staticClass:"btn-confirm",attrs:{disabled:!s.name.trim()},on:{click:s.onConfirm}},[s._v("确认")])])])])},G=[],J=p(W,H,G,!1,null,"d31752c1");const X=J.exports,z={name:"DevWorkflowViewApp",components:{AppWorkflowStep:$,AppStep1Req:M,AppStep2Design:B,AppStep3Code:R,AppStep4Test:E,SubSchemeDialogApp:X},data(){return{currentCategory:"",currentProject:"",currentStep:1,categories:[],projects:{},reqBasePath:"",subSchemeDialogVisible:!1,subSchemeDefaultName:""}},computed:{projectKey(){return!this.currentCategory||!this.currentProject?"":`${this.currentCategory}/${this.currentProject}`}},async created(){var r,a,n;const e=(r=this.$route.query)==null?void 0:r.category,s=(a=this.$route.query)==null?void 0:a.project,t=parseInt((n=this.$route.query)==null?void 0:n.step)||1,i=!!(e&&s);await this.loadCategories(),i?(this.currentCategory=e,this.currentProject=s,this.currentStep=t):await this.loadState()},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 c=`${this.reqBasePath}/${e}/${s}`;await o.createDirectory(c)}catch(c){console.error("Create requirement directory failed:",c)}const t=`# ${s}方案
4
6
 
5
7
  > 所属大类:${e}
6
8
 
@@ -8,4 +10,13 @@ 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
8
10
 
9
11
  ## 功能点
10
12
 
11
- `;try{const d=`${this.reqBasePath}/${e}/${s}/${s}_方案.md`;await o.writeFile(d,t)}catch(d){console.error("Write spec file failed:",d)}let i={designSessionId:"",codeSessionId:"",testSessionId:""};try{const[d,f,g]=await Promise.all([o.createSession(`workflow:${e}/${s}:design`),o.createSession(`workflow:${e}/${s}:code`),o.createSession(`workflow:${e}/${s}:test`)]);i={designSessionId:((a=d.data)==null?void 0:a.id)||"",codeSessionId:((n=f.data)==null?void 0:n.id)||"",testSessionId:((l=g.data)==null?void 0:l.id)||""};const v=`${this.reqBasePath}/${e}/${s}/session.json`;await o.writeFile(v,JSON.stringify(i,null,2))}catch(d){console.error("Create sessions failed:",d)}const r=`${e}/${s}`;this.$set(this.projects,r,{name:s,stepStatus:{}}),this.currentCategory=e,this.currentProject=s,this.currentStep=2,await this.saveState()},async onSaveSpec(e){if(!this.projectKey)return;const s=`${this.reqBasePath}/${this.currentCategory}/${this.currentProject}/${this.currentProject}_方案.md`;try{await o.writeFile(s,e)}catch(t){console.error("Save spec failed:",t)}},async refreshSpec(){this.currentCategory&&this.currentProject&&await this.loadProjectsForCategory(this.currentCategory)}}};var H=function(){var s=this,t=s._self._c;return t("div",{staticClass:"dev-workflow-view"},[t("AppWorkflowStep",{attrs:{"current-step":s.currentStep},on:{"step-change":s.onStepChange}}),t("div",{staticClass:"step-content"},[s.currentStep===1?t("AppStep1Req",{attrs:{categories:s.categories,projects:s.projects,"req-base-path":s.reqBasePath,"current-category":s.currentCategory,"current-project":s.currentProject},on:{"category-change":s.onCategoryChange,"project-change":s.onProjectChange,"create-category":s.createCategory,"create-requirement":s.createRequirement}}):s.currentStep===2?t("AppStep2Design",{attrs:{category:s.currentCategory,name:s.currentProject,"req-base-path":s.reqBasePath},on:{"save-spec":s.onSaveSpec,"spec-updated":s.refreshSpec}}):s.currentStep===3?t("AppStep3Code",{attrs:{category:s.currentCategory,name:s.currentProject,"req-base-path":s.reqBasePath}}):s.currentStep===4?t("AppStep4Test",{attrs:{category:s.currentCategory,name:s.currentProject,"req-base-path":s.reqBasePath}}):s._e()],1),t("div",{staticClass:"status-bar"},[s.projectKey?t("span",[s._v(s._s(s.projectKey))]):t("span",[s._v("选择需求开始")])])],1)},E=[],W=h(O,H,E,!1,null,"af782b5c");const J=W.exports;export{J as default};
13
+ `;try{const c=`${this.reqBasePath}/${e}/${s}/${s}_方案.md`;await o.writeFile(c,t)}catch(c){console.error("Write spec file failed:",c)}let i={designSessionId:"",codeSessionId:"",testSessionId:""};try{const[c,u,d]=await Promise.all([o.createSession(`workflow:${e}/${s}:design`),o.createSession(`workflow:${e}/${s}:code`),o.createSession(`workflow:${e}/${s}:test`)]);i={designSessionId:((a=c.data)==null?void 0:a.id)||"",codeSessionId:((n=u.data)==null?void 0:n.id)||"",testSessionId:((l=d.data)==null?void 0:l.id)||""};const f=`${this.reqBasePath}/${e}/${s}/session.json`;await o.writeFile(f,JSON.stringify(i,null,2))}catch(c){console.error("Create sessions failed:",c)}const r=`${e}/${s}`;this.$set(this.projects,r,{name:s,stepStatus:{}}),this.currentCategory=e,this.currentProject=s,this.currentStep=2,await this.saveState()},async createSubScheme(){var s;if(!this.currentProject||!this.currentCategory)return;const e=this.currentProject;try{const t=`${this.reqBasePath}/${this.currentCategory}`,r=((s=(await o.browseFilesystem(t)).data)==null?void 0:s.items)||[];let a=0;const n=new RegExp(`^${e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}_(\\d+)$`);r.filter(c=>c.is_directory).forEach(c=>{const u=c.name.match(n);if(u){const d=parseInt(u[1],10);d>a&&(a=d)}});const l=String(a+1).padStart(2,"0");this.subSchemeDefaultName=`${e}_${l}`,this.subSchemeDialogVisible=!0}catch(t){console.error("Browse category failed:",t)}},async onSubSchemeConfirm(e){var l,c,u;this.subSchemeDialogVisible=!1;const s=this.currentProject,t=this.currentCategory;try{const d=`${this.reqBasePath}/${t}/${e}`;await o.createDirectory(d)}catch(d){console.error("Create sub-scheme directory failed:",d);return}const i=`${this.reqBasePath}/${t}/${s}/${s}_方案.md`,r=`# ${e}_方案
14
+
15
+ > 所属大类:${t}
16
+ > 父方案:[../${s}/${s}_方案.md](../${s}/${s}_方案.md)
17
+
18
+ ## 业务目标
19
+
20
+ ## 功能点
21
+
22
+ `;try{const d=`${this.reqBasePath}/${t}/${e}/${e}_方案.md`;await o.writeFile(d,r)}catch(d){console.error("Write spec file failed:",d)}let a={designSessionId:"",codeSessionId:"",testSessionId:""};try{const[d,f,C]=await Promise.all([o.createSession(`workflow:${t}/${e}:design`),o.createSession(`workflow:${t}/${e}:code`),o.createSession(`workflow:${t}/${e}:test`)]);a={designSessionId:((l=d.data)==null?void 0:l.id)||"",codeSessionId:((c=f.data)==null?void 0:c.id)||"",testSessionId:((u=C.data)==null?void 0:u.id)||"",parent:{name:s,specPath:i}};const _=`${this.reqBasePath}/${t}/${e}/session.json`;await o.writeFile(_,JSON.stringify(a,null,2))}catch(d){console.error("Create sessions failed:",d)}const n=`${t}/${e}`;this.$set(this.projects,n,{name:e,stepStatus:{}}),this.$router.push({path:"/views/app/DevWorkflowViewApp",query:{category:t,project:e,step:2}})},async onSaveSpec(e){if(!this.projectKey)return;const s=`${this.reqBasePath}/${this.currentCategory}/${this.currentProject}/${this.currentProject}_方案.md`;try{await o.writeFile(s,e)}catch(t){console.error("Save spec failed:",t)}},async refreshSpec(){this.currentCategory&&this.currentProject&&await this.loadProjectsForCategory(this.currentCategory)}}};var Q=function(){var s=this,t=s._self._c;return t("div",{staticClass:"dev-workflow-view"},[t("AppWorkflowStep",{attrs:{"current-step":s.currentStep},on:{"step-change":s.onStepChange}}),s.currentStep===2&&s.currentProject?t("div",{staticClass:"step-toolbar"},[t("button",{staticClass:"btn-sub-scheme",on:{click:s.createSubScheme}},[t("i",{staticClass:"fa-solid fa-plus"}),s._v(" 新建子方案 ")])]):s._e(),t("div",{staticClass:"step-content"},[s.currentStep===1?t("AppStep1Req",{attrs:{categories:s.categories,projects:s.projects,"req-base-path":s.reqBasePath,"current-category":s.currentCategory,"current-project":s.currentProject},on:{"category-change":s.onCategoryChange,"project-change":s.onProjectChange,"create-category":s.createCategory,"create-requirement":s.createRequirement}}):s.currentStep===2?t("AppStep2Design",{attrs:{category:s.currentCategory,name:s.currentProject,"req-base-path":s.reqBasePath},on:{"save-spec":s.onSaveSpec,"spec-updated":s.refreshSpec}}):s.currentStep===3?t("AppStep3Code",{attrs:{category:s.currentCategory,name:s.currentProject,"req-base-path":s.reqBasePath}}):s.currentStep===4?t("AppStep4Test",{attrs:{category:s.currentCategory,name:s.currentProject,"req-base-path":s.reqBasePath}}):s._e()],1),t("div",{staticClass:"status-bar"},[s.projectKey?t("span",[s._v(s._s(s.projectKey))]):t("span",[s._v("选择需求开始")])]),t("SubSchemeDialogApp",{attrs:{visible:s.subSchemeDialogVisible,category:s.currentCategory,"parent-name":s.currentProject,"default-name":s.subSchemeDefaultName},on:{"update:visible":function(i){s.subSchemeDialogVisible=i},confirm:s.onSubSchemeConfirm,cancel:function(i){s.subSchemeDialogVisible=!1}}})],1)},Y=[],Z=p(z,Q,Y,!1,null,"a8b9d6a2");const es=Z.exports;export{es as default};
@@ -1,2 +1,2 @@
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(`
1
+ import{n,e as o,K as c,c as d,a as r}from"./index-Ch_-1SCN.js";import{C as f}from"./ConfirmDialog-i764Fe1J.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-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(`
1
+ import{n as r,a as n}from"./index-Ch_-1SCN.js";import{C as c}from"./ConfirmDialog-i764Fe1J.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};
@@ -1 +1 @@
1
- import{n as l,a as r}from"./index-Dtkc_ka-.js";const n={name:"SelectProjectDialog",props:{visible:{type:Boolean,default:!1}},data(){return{dialogVisible:!1,drives:[],currentPath:"",parentPath:null,items:[],selectedPath:"",projectName:"",loading:!1}},watch:{visible(s){this.dialogVisible=s,s&&this.loadDrives()},dialogVisible(s){this.$emit("update:visible",s)}},methods:{async loadDrives(){console.log("[SelectProjectDialog] loading drives...");try{const s=await r.getDrives();if(console.log("[SelectProjectDialog] drives response:",s),this.drives=s.data.items||[],console.log("[SelectProjectDialog] drives:",this.drives),this.drives.length>0){const e=this.drives[0];console.log("[SelectProjectDialog] firstDrive:",e),await this.browse(e.path||"/")}else await this.browse("/")}catch(s){console.error("加载盘符失败:",s),this.$message.error("加载盘符失败: "+s.message)}},async browse(s){try{const t=(await r.browseFilesystem(s)).data;this.currentPath=t.current_path,this.parentPath=t.parent_path,this.items=t.items||[]}catch(e){console.error("浏览目录失败:",e),this.$message.error("浏览目录失败: "+e.message)}},async selectDrive(s){await this.browse(s)},async selectFolder(s){if(s.is_directory){this.selectedPath=s.path;const e=s.path.replace(/\\/g,"/").split("/");this.projectName=e.filter(t=>t).pop()||"",await this.browse(s.path)}},async goToParent(){this.parentPath&&await this.browse(this.parentPath)},handleClose(){this.dialogVisible=!1,this.resetState()},resetState(){this.selectedPath="",this.projectName="",this.items=[],this.currentPath="",this.parentPath=null},async handleConfirm(){var s;if(!(!this.selectedPath||!this.projectName)){this.loading=!0;try{const e=await r.createProject(this.projectName,this.selectedPath,""),t=(s=e.data)==null?void 0:s.id;t&&(await r.setCurrentProject(t),this.$message.success("项目创建并切换成功"),this.$emit("success",e.data),this.handleClose())}catch(e){console.error("创建项目失败:",e),this.$message.error("创建项目失败: "+e.message)}finally{this.loading=!1}}}}};var c=function(){var e=this,t=e._self._c;return t("el-dialog",{attrs:{title:"选择项目文件夹",visible:e.dialogVisible,width:"600px","close-on-click-modal":!1,"append-to-body":""},on:{"update:visible":function(a){e.dialogVisible=a},close:e.handleClose}},[t("div",{staticClass:"select-project-dialog"},[e.drives.length>0?t("div",{staticClass:"drive-nav"},e._l(e.drives,function(a){return t("el-button",{key:a.path,attrs:{size:"mini",type:e.currentPath.startsWith(a.path)?"primary":""},on:{click:function(i){return e.selectDrive(a.path)}}},[e._v(" "+e._s(a.name)+" ")])}),1):e._e(),t("div",{staticClass:"file-list-container"},[t("div",{staticClass:"current-path"},[t("span",{staticClass:"path-label"},[e._v("当前路径:")]),t("span",{staticClass:"path-value"},[e._v(e._s(e.currentPath))])]),e.items.length>0?t("div",{staticClass:"file-list"},[e.parentPath?t("div",{staticClass:"file-item parent",on:{click:e.goToParent}},[t("i",{staticClass:"fa-solid fa-arrow-up"}),t("span",[e._v("上一级")])]):e._e(),e._l(e.items.filter(a=>a.is_directory),function(a){return t("div",{key:a.path,staticClass:"file-item",class:{selected:e.selectedPath===a.path},on:{click:function(i){return e.selectFolder(a)}}},[t("i",{staticClass:"fa-solid fa-folder"}),t("span",{staticClass:"file-name"},[e._v(e._s(a.name))])])}),e._l(e.items.filter(a=>!a.is_directory),function(a){return t("div",{key:a.path,staticClass:"file-item file-only"},[t("i",{staticClass:"fa-solid fa-file"}),t("span",{staticClass:"file-name"},[e._v(e._s(a.name))])])})],2):t("div",{staticClass:"empty-tip"},[t("span",[e._v("该目录为空")])])]),t("div",{staticClass:"底部状态栏"},[t("div",{staticClass:"selected-info"},[t("span",[e._v("已选择: "+e._s(e.selectedPath||"未选择"))])]),t("div",{staticClass:"project-name-input"},[t("span",[e._v("项目名称:")]),t("el-input",{staticStyle:{width:"200px"},attrs:{placeholder:"请输入项目名称",size:"small"},model:{value:e.projectName,callback:function(a){e.projectName=a},expression:"projectName"}})],1)])]),t("span",{staticClass:"dialog-footer",attrs:{slot:"footer"},slot:"footer"},[t("el-button",{on:{click:e.handleClose}},[e._v("取 消")]),t("el-button",{attrs:{type:"primary",disabled:!e.selectedPath||!e.projectName,loading:e.loading},on:{click:e.handleConfirm}},[e._v(" 确 定 ")])],1)])},d=[],h=l(n,c,d,!1,null,"e30d3bc8");const f=h.exports,u={name:"Layout",components:{SelectProjectDialog:f},data(){return{sidebarVisible:!0,showSessionDropdown:!1,sessions:[],currentSessionId:null,currentSessionName:"",projects:[],currentProject:null,selectProjectDialogVisible:!1,systemVersion:""}},methods:{toggleSidebar(){this.sidebarVisible=!this.sidebarVisible},toggleSessionDropdown(){this.showSessionDropdown=!this.showSessionDropdown},async switchSession(s){this.currentSessionId=s.id,this.currentSessionName=s.title,this.showSessionDropdown=!1,this.$route.params.id!==s.id&&this.$router.push({name:"chat-session",params:{id:s.id}}).catch(()=>{})},async createNewSession(){try{const s=await r.createSession("新会话");this.sessions.unshift(s.data),this.switchSession(s.data),this.showSessionDropdown=!1}catch(s){this.$message.error("创建会话失败: "+s.message)}},async loadSessions(){try{const s=await r.getSessions();this.sessions=s.data||[],this.sessions.length>0&&!this.currentSessionId&&(this.currentSessionId=this.sessions[0].id,this.currentSessionName=this.sessions[0].title)}catch(s){console.error("加载会话失败:",s)}},async loadProjects(){try{const s=await r.getProjects();this.projects=s.data||[];const e=await r.getCurrentProject();this.currentProject=e.data||null}catch(s){console.error("加载项目失败:",s)}},async handleProjectChange(s){if(s==="__open__"){const e=this.$el.querySelector(".el-dropdown");e&&e.click(),this.selectProjectDialogVisible=!0;return}try{await r.setCurrentProject(s);const e=this.projects.find(t=>t.id===s);e&&(this.currentProject=e),location.reload()}catch(e){this.$message.error("切换项目失败: "+e.message)}},handleProjectDialogSuccess(s){this.currentProject=s,this.loadProjects().then(()=>{location.reload()})},async loadSystemVersion(){var s;try{const e=await r.getSystemInfo();this.systemVersion=((s=e.data)==null?void 0:s.version)||""}catch(e){console.error("获取版本号失败:",e)}}},async created(){await this.loadProjects(),await this.loadSessions(),this.loadSystemVersion(),document.addEventListener("click",s=>{this.$el.contains(s.target)||(this.showSessionDropdown=!1)})}};var b=function(){var a;var e=this,t=e._self._c;return t("div",{staticClass:"flex flex-col h-screen overflow-hidden"},[t("header",{staticClass:"h-10 bg-sidebar border-b border-black flex items-center justify-between px-4 shrink-0 z-20"},[t("div",{staticClass:"flex items-center gap-4"},[e._m(0),t("div",{staticClass:"relative"},[t("a",{staticClass:"hover:text-white px-3 py-1 rounded border border-transparent hover:border-accent transition-colors cursor-pointer",class:e.$route.name==="devWorkflow"?"text-accent border-accent":"text-gray-400",attrs:{href:"/#/views/pc/devWorkflow",target:"_blank"}},[t("i",{staticClass:"fa-solid fa-laptop-code mr-1"}),e._v(" 软件研发 ")])]),t("div",{staticClass:"relative"},[t("router-link",{staticClass:"hover:text-white px-3 py-1 rounded border border-transparent hover:border-accent transition-colors cursor-pointer",class:e.$route.name==="deploy"?"text-accent border-accent":"text-gray-400",attrs:{to:"/views/pc/deploy"}},[t("i",{staticClass:"fa-solid fa-rocket mr-1"}),e._v(" 部署 ")])],1)]),t("div",{staticClass:"flex items-center gap-3"},[e.projects.length>0?t("el-dropdown",{attrs:{trigger:"click"},on:{command:e.handleProjectChange}},[t("span",{staticClass:"text-white text-sm cursor-pointer hover:text-accent"},[t("i",{staticClass:"fa-solid fa-folder mr-1"}),e._v(" "+e._s(((a=e.currentProject)==null?void 0:a.name)||"选择项目")+" "),t("i",{staticClass:"fa-solid fa-chevron-down ml-1 text-xs"})]),t("el-dropdown-menu",{attrs:{slot:"dropdown"},slot:"dropdown"},[e._l(e.projects,function(i){var o;return t("el-dropdown-item",{key:i.id,attrs:{command:i.id}},[t("span",{class:i.id===((o=e.currentProject)==null?void 0:o.id)?"text-accent":""},[e._v(e._s(i.name))])])}),t("el-dropdown-item",{attrs:{divided:"",command:"__open__"}},[t("i",{staticClass:"fa-solid fa-folder-open mr-1"}),e._v(" 打开项目文件夹 ")])],2)],1):e._e(),t("SelectProjectDialog",{attrs:{visible:e.selectProjectDialogVisible},on:{"update:visible":function(i){e.selectProjectDialogVisible=i},success:e.handleProjectDialogSuccess}}),e.systemVersion?t("span",{staticClass:"text-xs text-textMuted"},[e._v("v"+e._s(e.systemVersion))]):e._e(),e._m(1),t("button",{directives:[{name:"show",rawName:"v-show",value:e.$route.name==="chat",expression:"$route.name === 'chat'"}],staticClass:"hover:text-white",attrs:{title:e.sidebarVisible?"关闭侧栏":"显示侧栏"},on:{click:e.toggleSidebar}},[t("i",{staticClass:"fa-solid fa-columns"})])],1)]),t("div",{staticClass:"flex-1 flex overflow-hidden"},[t("nav",{staticClass:"w-12 bg-activityBar flex flex-col items-center py-2 shrink-0 border-r border-black z-10 justify-between"},[t("div",{staticClass:"flex flex-col items-center w-full"},[t("router-link",{staticClass:"w-10 h-10 mb-2 rounded flex items-center justify-center relative",class:e.$route.name==="codeView"||e.$route.name==="codeView-session"?"text-white border-l-2 border-accent bg-sidebar":"text-textMuted hover:text-white border-l-2 border-transparent",attrs:{to:"/views/pc/codeView",title:"工作台"}},[t("i",{staticClass:"fa-regular fa-comments text-xl"})]),t("router-link",{staticClass:"w-10 h-10 mb-2 rounded flex items-center justify-center",class:e.$route.name==="files"?"text-white border-l-2 border-accent bg-sidebar":"text-textMuted hover:text-white border-l-2 border-transparent",attrs:{to:"/views/pc/files",title:"文件"}},[t("i",{staticClass:"fa-solid fa-folder-open text-xl"})]),t("router-link",{staticClass:"w-10 h-10 mb-2 rounded flex items-center justify-center",class:e.$route.name==="gitChanges"?"text-white border-l-2 border-accent bg-sidebar":"text-textMuted hover:text-white border-l-2 border-transparent",attrs:{to:"/views/pc/git-changes",title:"Git 变更"}},[t("i",{staticClass:"fa-brands fa-git-alt text-xl"})]),t("router-link",{staticClass:"w-10 h-10 mb-2 rounded flex items-center justify-center",class:e.$route.name==="terminal"||e.$route.name==="terminal-session"?"text-white border-l-2 border-accent bg-sidebar":"text-textMuted hover:text-white border-l-2 border-transparent",attrs:{to:"/views/pc/terminal",title:"终端"}},[t("i",{staticClass:"fa-solid fa-terminal text-xl"})]),t("router-link",{staticClass:"w-10 h-10 mb-2 rounded flex items-center justify-center relative",class:e.$route.name==="skills"?"text-white border-l-2 border-accent bg-sidebar":"text-textMuted hover:text-white border-l-2 border-transparent",attrs:{to:"/views/pc/skills",title:"Skill 管理"}},[t("i",{staticClass:"fa-solid fa-shapes text-xl"})]),t("router-link",{staticClass:"w-10 h-10 mb-2 rounded flex items-center justify-center",class:e.$route.name==="db"?"text-white border-l-2 border-accent bg-sidebar":"text-textMuted hover:text-white border-l-2 border-transparent",attrs:{to:"/views/pc/db",title:"数据库"}},[t("i",{staticClass:"fa-solid fa-database text-xl"})]),t("router-link",{staticClass:"w-10 h-10 mb-2 rounded flex items-center justify-center",class:e.$route.name==="tasks"?"text-white border-l-2 border-accent bg-sidebar":"text-textMuted hover:text-white border-l-2 border-transparent",attrs:{to:"/views/pc/tasks",title:"任务"}},[t("i",{staticClass:"fa-solid fa-clock text-xl"})]),t("router-link",{staticClass:"w-10 h-10 mb-2 rounded flex items-center justify-center",class:e.$route.name==="aiLogs"?"text-white border-l-2 border-accent bg-sidebar":"text-textMuted hover:text-white border-l-2 border-transparent",attrs:{to:"/views/pc/aiLogs",title:"AI 日志"}},[t("i",{staticClass:"fa-solid fa-robot text-xl"})]),t("router-link",{staticClass:"w-10 h-10 mb-2 rounded flex items-center justify-center",class:e.$route.name==="wiki"?"text-white border-l-2 border-accent bg-sidebar":"text-textMuted hover:text-white border-l-2 border-transparent",attrs:{to:"/views/pc/wiki",title:"文档"}},[t("i",{staticClass:"fa-solid fa-book text-xl"})]),t("router-link",{staticClass:"w-10 h-10 mb-2 rounded flex items-center justify-center",class:e.$route.name==="fileZihao"?"text-white border-l-2 border-accent bg-sidebar":"text-textMuted hover:text-white border-l-2 border-transparent",attrs:{to:"/views/pc/fileZihao",title:"文件梓豪"}},[t("i",{staticClass:"fa-solid fa-server text-xl"})])],1),t("div",{staticClass:"flex flex-col items-center w-full mb-2"},[t("router-link",{staticClass:"w-10 h-10 mb-2 rounded flex items-center justify-center",class:e.$route.name==="settings"?"text-white border-l-2 border-accent bg-sidebar":"text-textMuted hover:text-white border-l-2 border-transparent hover:bg-white/5",attrs:{to:"/views/pc/settings",title:"设置"}},[t("i",{staticClass:"fa-solid fa-gear text-xl"})])],1)]),t("keep-alive",{attrs:{include:["CodeView","TerminalView","Files"]}},[t("router-view",{staticClass:"flex-1 flex overflow-hidden",attrs:{"sidebar-visible":e.sidebarVisible},on:{"toggle-sidebar":e.toggleSidebar}})],1)],1),e._m(2)])},p=[function(){var s=this,e=s._self._c;return e("div",{staticClass:"font-bold text-white flex items-center gap-2"},[e("i",{staticClass:"fa-solid fa-robot text-accent"}),e("span",[s._v("TXCode Agent")])])},function(){var s=this,e=s._self._c;return e("span",{staticClass:"text-xs text-textMuted mr-2"},[e("i",{staticClass:"fa-solid fa-circle text-green-500 text-[8px]"}),s._v(" Server Connected")])},function(){var s=this,e=s._self._c;return e("footer",{staticClass:"h-6 bg-accent text-white text-xs flex items-center justify-between px-3 shrink-0 z-20"},[e("div",{staticClass:"flex items-center gap-4"},[e("span",[e("i",{staticClass:"fa-solid fa-code-branch"}),s._v(" main")])]),e("div",{staticClass:"flex items-center gap-4"},[e("span",[s._v("TXCode")]),e("span",[s._v("UTF-8")])])])}],m=l(u,b,p,!1,null,null);const x=m.exports;export{x as default};
1
+ import{n as l,a as r}from"./index-Ch_-1SCN.js";const n={name:"SelectProjectDialog",props:{visible:{type:Boolean,default:!1}},data(){return{dialogVisible:!1,drives:[],currentPath:"",parentPath:null,items:[],selectedPath:"",projectName:"",loading:!1}},watch:{visible(s){this.dialogVisible=s,s&&this.loadDrives()},dialogVisible(s){this.$emit("update:visible",s)}},methods:{async loadDrives(){console.log("[SelectProjectDialog] loading drives...");try{const s=await r.getDrives();if(console.log("[SelectProjectDialog] drives response:",s),this.drives=s.data.items||[],console.log("[SelectProjectDialog] drives:",this.drives),this.drives.length>0){const e=this.drives[0];console.log("[SelectProjectDialog] firstDrive:",e),await this.browse(e.path||"/")}else await this.browse("/")}catch(s){console.error("加载盘符失败:",s),this.$message.error("加载盘符失败: "+s.message)}},async browse(s){try{const t=(await r.browseFilesystem(s)).data;this.currentPath=t.current_path,this.parentPath=t.parent_path,this.items=t.items||[]}catch(e){console.error("浏览目录失败:",e),this.$message.error("浏览目录失败: "+e.message)}},async selectDrive(s){await this.browse(s)},async selectFolder(s){if(s.is_directory){this.selectedPath=s.path;const e=s.path.replace(/\\/g,"/").split("/");this.projectName=e.filter(t=>t).pop()||"",await this.browse(s.path)}},async goToParent(){this.parentPath&&await this.browse(this.parentPath)},handleClose(){this.dialogVisible=!1,this.resetState()},resetState(){this.selectedPath="",this.projectName="",this.items=[],this.currentPath="",this.parentPath=null},async handleConfirm(){var s;if(!(!this.selectedPath||!this.projectName)){this.loading=!0;try{const e=await r.createProject(this.projectName,this.selectedPath,""),t=(s=e.data)==null?void 0:s.id;t&&(await r.setCurrentProject(t),this.$message.success("项目创建并切换成功"),this.$emit("success",e.data),this.handleClose())}catch(e){console.error("创建项目失败:",e),this.$message.error("创建项目失败: "+e.message)}finally{this.loading=!1}}}}};var c=function(){var e=this,t=e._self._c;return t("el-dialog",{attrs:{title:"选择项目文件夹",visible:e.dialogVisible,width:"600px","close-on-click-modal":!1,"append-to-body":""},on:{"update:visible":function(a){e.dialogVisible=a},close:e.handleClose}},[t("div",{staticClass:"select-project-dialog"},[e.drives.length>0?t("div",{staticClass:"drive-nav"},e._l(e.drives,function(a){return t("el-button",{key:a.path,attrs:{size:"mini",type:e.currentPath.startsWith(a.path)?"primary":""},on:{click:function(i){return e.selectDrive(a.path)}}},[e._v(" "+e._s(a.name)+" ")])}),1):e._e(),t("div",{staticClass:"file-list-container"},[t("div",{staticClass:"current-path"},[t("span",{staticClass:"path-label"},[e._v("当前路径:")]),t("span",{staticClass:"path-value"},[e._v(e._s(e.currentPath))])]),e.items.length>0?t("div",{staticClass:"file-list"},[e.parentPath?t("div",{staticClass:"file-item parent",on:{click:e.goToParent}},[t("i",{staticClass:"fa-solid fa-arrow-up"}),t("span",[e._v("上一级")])]):e._e(),e._l(e.items.filter(a=>a.is_directory),function(a){return t("div",{key:a.path,staticClass:"file-item",class:{selected:e.selectedPath===a.path},on:{click:function(i){return e.selectFolder(a)}}},[t("i",{staticClass:"fa-solid fa-folder"}),t("span",{staticClass:"file-name"},[e._v(e._s(a.name))])])}),e._l(e.items.filter(a=>!a.is_directory),function(a){return t("div",{key:a.path,staticClass:"file-item file-only"},[t("i",{staticClass:"fa-solid fa-file"}),t("span",{staticClass:"file-name"},[e._v(e._s(a.name))])])})],2):t("div",{staticClass:"empty-tip"},[t("span",[e._v("该目录为空")])])]),t("div",{staticClass:"底部状态栏"},[t("div",{staticClass:"selected-info"},[t("span",[e._v("已选择: "+e._s(e.selectedPath||"未选择"))])]),t("div",{staticClass:"project-name-input"},[t("span",[e._v("项目名称:")]),t("el-input",{staticStyle:{width:"200px"},attrs:{placeholder:"请输入项目名称",size:"small"},model:{value:e.projectName,callback:function(a){e.projectName=a},expression:"projectName"}})],1)])]),t("span",{staticClass:"dialog-footer",attrs:{slot:"footer"},slot:"footer"},[t("el-button",{on:{click:e.handleClose}},[e._v("取 消")]),t("el-button",{attrs:{type:"primary",disabled:!e.selectedPath||!e.projectName,loading:e.loading},on:{click:e.handleConfirm}},[e._v(" 确 定 ")])],1)])},d=[],h=l(n,c,d,!1,null,"e30d3bc8");const f=h.exports,u={name:"Layout",components:{SelectProjectDialog:f},data(){return{sidebarVisible:!0,showSessionDropdown:!1,sessions:[],currentSessionId:null,currentSessionName:"",projects:[],currentProject:null,selectProjectDialogVisible:!1,systemVersion:""}},methods:{toggleSidebar(){this.sidebarVisible=!this.sidebarVisible},toggleSessionDropdown(){this.showSessionDropdown=!this.showSessionDropdown},async switchSession(s){this.currentSessionId=s.id,this.currentSessionName=s.title,this.showSessionDropdown=!1,this.$route.params.id!==s.id&&this.$router.push({name:"chat-session",params:{id:s.id}}).catch(()=>{})},async createNewSession(){try{const s=await r.createSession("新会话");this.sessions.unshift(s.data),this.switchSession(s.data),this.showSessionDropdown=!1}catch(s){this.$message.error("创建会话失败: "+s.message)}},async loadSessions(){try{const s=await r.getSessions();this.sessions=s.data||[],this.sessions.length>0&&!this.currentSessionId&&(this.currentSessionId=this.sessions[0].id,this.currentSessionName=this.sessions[0].title)}catch(s){console.error("加载会话失败:",s)}},async loadProjects(){try{const s=await r.getProjects();this.projects=s.data||[];const e=await r.getCurrentProject();this.currentProject=e.data||null}catch(s){console.error("加载项目失败:",s)}},async handleProjectChange(s){if(s==="__open__"){const e=this.$el.querySelector(".el-dropdown");e&&e.click(),this.selectProjectDialogVisible=!0;return}try{await r.setCurrentProject(s);const e=this.projects.find(t=>t.id===s);e&&(this.currentProject=e),location.reload()}catch(e){this.$message.error("切换项目失败: "+e.message)}},handleProjectDialogSuccess(s){this.currentProject=s,this.loadProjects().then(()=>{location.reload()})},async loadSystemVersion(){var s;try{const e=await r.getSystemInfo();this.systemVersion=((s=e.data)==null?void 0:s.version)||""}catch(e){console.error("获取版本号失败:",e)}}},async created(){await this.loadProjects(),await this.loadSessions(),this.loadSystemVersion(),document.addEventListener("click",s=>{this.$el.contains(s.target)||(this.showSessionDropdown=!1)})}};var b=function(){var a;var e=this,t=e._self._c;return t("div",{staticClass:"flex flex-col h-screen overflow-hidden"},[t("header",{staticClass:"h-10 bg-sidebar border-b border-black flex items-center justify-between px-4 shrink-0 z-20"},[t("div",{staticClass:"flex items-center gap-4"},[e._m(0),t("div",{staticClass:"relative"},[t("a",{staticClass:"hover:text-white px-3 py-1 rounded border border-transparent hover:border-accent transition-colors cursor-pointer",class:e.$route.name==="devWorkflow"?"text-accent border-accent":"text-gray-400",attrs:{href:"/#/views/pc/devWorkflow",target:"_blank"}},[t("i",{staticClass:"fa-solid fa-laptop-code mr-1"}),e._v(" 软件研发 ")])]),t("div",{staticClass:"relative"},[t("router-link",{staticClass:"hover:text-white px-3 py-1 rounded border border-transparent hover:border-accent transition-colors cursor-pointer",class:e.$route.name==="deploy"?"text-accent border-accent":"text-gray-400",attrs:{to:"/views/pc/deploy"}},[t("i",{staticClass:"fa-solid fa-rocket mr-1"}),e._v(" 部署 ")])],1)]),t("div",{staticClass:"flex items-center gap-3"},[e.projects.length>0?t("el-dropdown",{attrs:{trigger:"click"},on:{command:e.handleProjectChange}},[t("span",{staticClass:"text-white text-sm cursor-pointer hover:text-accent"},[t("i",{staticClass:"fa-solid fa-folder mr-1"}),e._v(" "+e._s(((a=e.currentProject)==null?void 0:a.name)||"选择项目")+" "),t("i",{staticClass:"fa-solid fa-chevron-down ml-1 text-xs"})]),t("el-dropdown-menu",{attrs:{slot:"dropdown"},slot:"dropdown"},[e._l(e.projects,function(i){var o;return t("el-dropdown-item",{key:i.id,attrs:{command:i.id}},[t("span",{class:i.id===((o=e.currentProject)==null?void 0:o.id)?"text-accent":""},[e._v(e._s(i.name))])])}),t("el-dropdown-item",{attrs:{divided:"",command:"__open__"}},[t("i",{staticClass:"fa-solid fa-folder-open mr-1"}),e._v(" 打开项目文件夹 ")])],2)],1):e._e(),t("SelectProjectDialog",{attrs:{visible:e.selectProjectDialogVisible},on:{"update:visible":function(i){e.selectProjectDialogVisible=i},success:e.handleProjectDialogSuccess}}),e.systemVersion?t("span",{staticClass:"text-xs text-textMuted"},[e._v("v"+e._s(e.systemVersion))]):e._e(),e._m(1),t("button",{directives:[{name:"show",rawName:"v-show",value:e.$route.name==="chat",expression:"$route.name === 'chat'"}],staticClass:"hover:text-white",attrs:{title:e.sidebarVisible?"关闭侧栏":"显示侧栏"},on:{click:e.toggleSidebar}},[t("i",{staticClass:"fa-solid fa-columns"})])],1)]),t("div",{staticClass:"flex-1 flex overflow-hidden"},[t("nav",{staticClass:"w-12 bg-activityBar flex flex-col items-center py-2 shrink-0 border-r border-black z-10 justify-between"},[t("div",{staticClass:"flex flex-col items-center w-full"},[t("router-link",{staticClass:"w-10 h-10 mb-2 rounded flex items-center justify-center relative",class:e.$route.name==="codeView"||e.$route.name==="codeView-session"?"text-white border-l-2 border-accent bg-sidebar":"text-textMuted hover:text-white border-l-2 border-transparent",attrs:{to:"/views/pc/codeView",title:"工作台"}},[t("i",{staticClass:"fa-regular fa-comments text-xl"})]),t("router-link",{staticClass:"w-10 h-10 mb-2 rounded flex items-center justify-center",class:e.$route.name==="files"?"text-white border-l-2 border-accent bg-sidebar":"text-textMuted hover:text-white border-l-2 border-transparent",attrs:{to:"/views/pc/files",title:"文件"}},[t("i",{staticClass:"fa-solid fa-folder-open text-xl"})]),t("router-link",{staticClass:"w-10 h-10 mb-2 rounded flex items-center justify-center",class:e.$route.name==="gitChanges"?"text-white border-l-2 border-accent bg-sidebar":"text-textMuted hover:text-white border-l-2 border-transparent",attrs:{to:"/views/pc/git-changes",title:"Git 变更"}},[t("i",{staticClass:"fa-brands fa-git-alt text-xl"})]),t("router-link",{staticClass:"w-10 h-10 mb-2 rounded flex items-center justify-center",class:e.$route.name==="terminal"||e.$route.name==="terminal-session"?"text-white border-l-2 border-accent bg-sidebar":"text-textMuted hover:text-white border-l-2 border-transparent",attrs:{to:"/views/pc/terminal",title:"终端"}},[t("i",{staticClass:"fa-solid fa-terminal text-xl"})]),t("router-link",{staticClass:"w-10 h-10 mb-2 rounded flex items-center justify-center relative",class:e.$route.name==="skills"?"text-white border-l-2 border-accent bg-sidebar":"text-textMuted hover:text-white border-l-2 border-transparent",attrs:{to:"/views/pc/skills",title:"Skill 管理"}},[t("i",{staticClass:"fa-solid fa-shapes text-xl"})]),t("router-link",{staticClass:"w-10 h-10 mb-2 rounded flex items-center justify-center",class:e.$route.name==="db"?"text-white border-l-2 border-accent bg-sidebar":"text-textMuted hover:text-white border-l-2 border-transparent",attrs:{to:"/views/pc/db",title:"数据库"}},[t("i",{staticClass:"fa-solid fa-database text-xl"})]),t("router-link",{staticClass:"w-10 h-10 mb-2 rounded flex items-center justify-center",class:e.$route.name==="tasks"?"text-white border-l-2 border-accent bg-sidebar":"text-textMuted hover:text-white border-l-2 border-transparent",attrs:{to:"/views/pc/tasks",title:"任务"}},[t("i",{staticClass:"fa-solid fa-clock text-xl"})]),t("router-link",{staticClass:"w-10 h-10 mb-2 rounded flex items-center justify-center",class:e.$route.name==="aiLogs"?"text-white border-l-2 border-accent bg-sidebar":"text-textMuted hover:text-white border-l-2 border-transparent",attrs:{to:"/views/pc/aiLogs",title:"AI 日志"}},[t("i",{staticClass:"fa-solid fa-robot text-xl"})]),t("router-link",{staticClass:"w-10 h-10 mb-2 rounded flex items-center justify-center",class:e.$route.name==="wiki"?"text-white border-l-2 border-accent bg-sidebar":"text-textMuted hover:text-white border-l-2 border-transparent",attrs:{to:"/views/pc/wiki",title:"文档"}},[t("i",{staticClass:"fa-solid fa-book text-xl"})]),t("router-link",{staticClass:"w-10 h-10 mb-2 rounded flex items-center justify-center",class:e.$route.name==="fileZihao"?"text-white border-l-2 border-accent bg-sidebar":"text-textMuted hover:text-white border-l-2 border-transparent",attrs:{to:"/views/pc/fileZihao",title:"文件梓豪"}},[t("i",{staticClass:"fa-solid fa-server text-xl"})])],1),t("div",{staticClass:"flex flex-col items-center w-full mb-2"},[t("router-link",{staticClass:"w-10 h-10 mb-2 rounded flex items-center justify-center",class:e.$route.name==="settings"?"text-white border-l-2 border-accent bg-sidebar":"text-textMuted hover:text-white border-l-2 border-transparent hover:bg-white/5",attrs:{to:"/views/pc/settings",title:"设置"}},[t("i",{staticClass:"fa-solid fa-gear text-xl"})])],1)]),t("keep-alive",{attrs:{include:["CodeView","TerminalView","Files"]}},[t("router-view",{staticClass:"flex-1 flex overflow-hidden",attrs:{"sidebar-visible":e.sidebarVisible},on:{"toggle-sidebar":e.toggleSidebar}})],1)],1),e._m(2)])},p=[function(){var s=this,e=s._self._c;return e("div",{staticClass:"font-bold text-white flex items-center gap-2"},[e("i",{staticClass:"fa-solid fa-robot text-accent"}),e("span",[s._v("TXCode Agent")])])},function(){var s=this,e=s._self._c;return e("span",{staticClass:"text-xs text-textMuted mr-2"},[e("i",{staticClass:"fa-solid fa-circle text-green-500 text-[8px]"}),s._v(" Server Connected")])},function(){var s=this,e=s._self._c;return e("footer",{staticClass:"h-6 bg-accent text-white text-xs flex items-center justify-between px-3 shrink-0 z-20"},[e("div",{staticClass:"flex items-center gap-4"},[e("span",[e("i",{staticClass:"fa-solid fa-code-branch"}),s._v(" main")])]),e("div",{staticClass:"flex items-center gap-4"},[e("span",[s._v("TXCode")]),e("span",[s._v("UTF-8")])])])}],m=l(u,b,p,!1,null,null);const x=m.exports;export{x as default};
@@ -1 +1 @@
1
- import{n as x,a as i}from"./index-Dtkc_ka-.js";const b={"*/5 * * * *":"每5分钟","*/30 * * * *":"每30分钟","0 * * * *":"每小时","0 */2 * * *":"每2小时","0 */12 * * *":"每12小时","0 0 * * *":"每天0点","0 0 1 * *":"每月1日0点"},p={name:"TasksView",data(){return{tasks:[],models:[],availableSkills:[],showDialog:!1,showLogDialog:!1,isEditing:!1,currentTask:null,logs:[],form:{name:"",model:"gpt-4",scheduleType:"0 * * * *",notifyType:"message",skills:[],content:"",enabled:!0}}},async created(){await this.loadTasks(),await this.loadModels(),await this.loadSkills()},methods:{async loadTasks(){try{const s=await i.getScheduledTasks();this.tasks=s.data||[]}catch(s){console.error("Load tasks failed:",s),this.$message.error("加载任务失败")}},async loadModels(){try{const s=await i.getModels();this.models=s.data||[],this.models.length>0&&!this.form.model&&(this.form.model=this.models[0].name)}catch(s){console.error("Load models failed:",s)}},async loadSkills(){var s;try{const e=await i.getSkills();this.availableSkills=((s=e.data)==null?void 0:s.map(t=>t.name))||[]}catch(e){console.error("Load skills failed:",e)}},formatSchedule(s){return b[s]||s},formatTime(s){return s?new Date(s).toLocaleString("zh-CN"):"-"},formatDuration(s){return s?s<1e3?`${s}ms`:`${(s/1e3).toFixed(2)}s`:"0ms"},openCreateDialog(){var s;this.isEditing=!1,this.form={name:"",model:((s=this.models[0])==null?void 0:s.name)||"gpt-4",scheduleType:"0 * * * *",notifyType:"message",skills:[],content:"",enabled:!0},this.showDialog=!0},openEditDialog(s){this.isEditing=!0,this.currentTask=s,this.form={name:s.name,model:s.model,scheduleType:s.scheduleType,notifyType:s.notifyType,skills:[...s.skills||[]],content:s.content,enabled:s.enabled},this.showDialog=!0},closeDialog(){this.showDialog=!1,this.currentTask=null},async saveTask(){if(!this.form.name||!this.form.content){this.$message.error("请填写必填项");return}try{this.isEditing&&this.currentTask?(await i.updateScheduledTask(this.currentTask.id,this.form),this.$message.success("任务已更新")):(await i.createScheduledTask(this.form),this.$message.success("任务已创建")),this.closeDialog(),await this.loadTasks()}catch(s){this.$message.error("保存失败: "+s.message)}},async deleteTask(s){if(confirm(`确定删除任务 "${s.name}" 吗?`))try{await i.deleteScheduledTask(s.id),this.$message.success("任务已删除"),await this.loadTasks()}catch(e){this.$message.error("删除失败: "+e.message)}},async startTask(s){try{await i.startScheduledTask(s.id),this.$message.success("任务已启动"),await this.loadTasks()}catch(e){this.$message.error("启动失败: "+e.message)}},async stopTask(s){try{await i.stopScheduledTask(s.id),this.$message.success("任务已停用"),await this.loadTasks()}catch(e){this.$message.error("停用失败: "+e.message)}},async runTask(s){try{await i.runTaskNow(s.id),this.$message.success("任务已开始执行")}catch(e){this.$message.error("执行失败: "+e.message)}},async openLogDialog(s){this.currentTask=s,this.showLogDialog=!0;try{const e=await i.getTaskLogs(s.id);this.logs=e.data||[]}catch(e){console.error("Load logs failed:",e),this.logs=[]}}}};var m=function(){var u;var e=this,t=e._self._c;return t("div",{staticClass:"flex-1 flex flex-col overflow-hidden bg-[#1e1e1e]"},[t("div",{staticClass:"px-4 py-3 border-b border-border bg-sidebar shrink-0"},[t("div",{staticClass:"flex items-center justify-between"},[t("div",{staticClass:"flex items-center gap-2"},[t("i",{staticClass:"fa-solid fa-clock text-accent"}),t("span",{staticClass:"text-white font-medium"},[e._v("定时任务")]),t("span",{staticClass:"text-xs text-textMuted"},[e._v(e._s(e.tasks.length)+" 个任务")])]),t("button",{staticClass:"px-3 py-1 bg-accent text-white text-xs rounded hover:bg-accent/80",on:{click:e.openCreateDialog}},[t("i",{staticClass:"fa-solid fa-plus mr-1"}),e._v(" 新建任务 ")])])]),t("div",{staticClass:"flex-1 overflow-auto p-4"},[t("table",{staticClass:"w-full text-sm"},[e._m(0),t("tbody",[e._l(e.tasks,function(a){return t("tr",{key:a.id,staticClass:"hover:bg-white/5"},[t("td",{staticClass:"px-3 py-2 border-b border-border/30"},[a.enabled?t("span",{staticClass:"text-xs px-2 py-0.5 rounded bg-green-500/20 text-green-400"},[e._v("启用")]):t("span",{staticClass:"text-xs px-2 py-0.5 rounded bg-gray-500/20 text-gray-400"},[e._v("停用")])]),t("td",{staticClass:"px-3 py-2 text-gray-200 border-b border-border/30"},[e._v(e._s(a.name))]),t("td",{staticClass:"px-3 py-2 text-gray-300 border-b border-border/30"},[e._v(e._s(a.model))]),t("td",{staticClass:"px-3 py-2 text-gray-300 border-b border-border/30"},[e._v(e._s(e.formatSchedule(a.scheduleType)))]),t("td",{staticClass:"px-3 py-2 text-gray-300 border-b border-border/30"},e._l(a.skills,function(o){var r;return(r=a.skills)!=null&&r.length?t("span",{key:o,staticClass:"text-xs px-1 py-0.5 bg-blue-500/20 text-blue-400 rounded mr-1"},[e._v(e._s(o))]):t("span",{staticClass:"text-textMuted"},[e._v("-")])}),0),t("td",{staticClass:"px-3 py-2 border-b border-border/30"},[t("div",{staticClass:"flex items-center gap-2"},[a.enabled?t("button",{staticClass:"text-xs px-2 py-1 text-yellow-400 hover:bg-yellow-500/20 rounded",on:{click:function(o){return e.stopTask(a)}}},[e._v("停用")]):t("button",{staticClass:"text-xs px-2 py-1 text-green-400 hover:bg-green-500/20 rounded",on:{click:function(o){return e.startTask(a)}}},[e._v("启动")]),t("button",{staticClass:"text-xs px-2 py-1 text-blue-400 hover:bg-blue-500/20 rounded",on:{click:function(o){return e.runTask(a)}}},[e._v("执行")]),t("button",{staticClass:"text-xs px-2 py-1 text-gray-400 hover:bg-white/10 rounded",on:{click:function(o){return e.openLogDialog(a)}}},[e._v("日志")]),t("button",{staticClass:"text-xs px-2 py-1 text-gray-400 hover:bg-white/10 rounded",on:{click:function(o){return e.openEditDialog(a)}}},[e._v("编辑")]),t("button",{staticClass:"text-xs px-2 py-1 text-red-400 hover:bg-red-500/20 rounded",on:{click:function(o){return e.deleteTask(a)}}},[e._v("删除")])])])])}),e.tasks.length===0?t("tr",[t("td",{staticClass:"px-3 py-8 text-center text-textMuted",attrs:{colspan:"6"}},[e._v('暂无任务,点击"新建任务"创建')])]):e._e()],2)])]),e.showDialog?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-lg w-[600px] max-h-[80vh] overflow-auto"},[t("div",{staticClass:"px-4 py-3 border-b border-border flex items-center justify-between"},[t("h3",{staticClass:"text-white font-medium"},[e._v(e._s(e.isEditing?"编辑任务":"新建任务"))]),t("button",{staticClass:"text-textMuted hover:text-white text-sm",on:{click:e.closeDialog}},[e._v("关闭")])]),t("div",{staticClass:"p-4 space-y-4"},[t("div",[e._m(1),t("input",{directives:[{name:"model",rawName:"v-model",value:e.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:e.form.name},on:{input:function(a){a.target.composing||e.$set(e.form,"name",a.target.value)}}})]),t("div",[e._m(2),t("select",{directives:[{name:"model",rawName:"v-model",value:e.form.model,expression:"form.model"}],staticClass:"w-full bg-black/20 border border-white/10 text-white text-sm px-3 py-2 rounded",on:{change:function(a){var o=Array.prototype.filter.call(a.target.options,function(r){return r.selected}).map(function(r){var l="_value"in r?r._value:r.value;return l});e.$set(e.form,"model",a.target.multiple?o:o[0])}}},e._l(e.models,function(a){return t("option",{key:a.id,domProps:{value:a.name}},[e._v(e._s(a.name))])}),0)]),t("div",[e._m(3),t("select",{directives:[{name:"model",rawName:"v-model",value:e.form.scheduleType,expression:"form.scheduleType"}],staticClass:"w-full bg-black/20 border border-white/10 text-white text-sm px-3 py-2 rounded",on:{change:function(a){var o=Array.prototype.filter.call(a.target.options,function(r){return r.selected}).map(function(r){var l="_value"in r?r._value:r.value;return l});e.$set(e.form,"scheduleType",a.target.multiple?o:o[0])}}},[t("option",{attrs:{value:"*/5 * * * *"}},[e._v("每5分钟")]),t("option",{attrs:{value:"*/30 * * * *"}},[e._v("每30分钟")]),t("option",{attrs:{value:"0 * * * *"}},[e._v("每小时")]),t("option",{attrs:{value:"0 */2 * * *"}},[e._v("每2小时")]),t("option",{attrs:{value:"0 */12 * * *"}},[e._v("每12小时")]),t("option",{attrs:{value:"0 0 * * *"}},[e._v("每天0点")]),t("option",{attrs:{value:"0 0 1 * *"}},[e._v("每月1日0点")])])]),t("div",[t("label",{staticClass:"block text-xs text-textMuted mb-1"},[e._v("通知方式")]),t("select",{directives:[{name:"model",rawName:"v-model",value:e.form.notifyType,expression:"form.notifyType"}],staticClass:"w-full bg-black/20 border border-white/10 text-white text-sm px-3 py-2 rounded",on:{change:function(a){var o=Array.prototype.filter.call(a.target.options,function(r){return r.selected}).map(function(r){var l="_value"in r?r._value:r.value;return l});e.$set(e.form,"notifyType",a.target.multiple?o:o[0])}}},[t("option",{attrs:{value:"message"}},[e._v("消息")]),t("option",{attrs:{value:"email"}},[e._v("邮件")])])]),t("div",[t("label",{staticClass:"block text-xs text-textMuted mb-1"},[e._v("关联技能")]),t("div",{staticClass:"flex flex-wrap gap-2"},e._l(e.availableSkills,function(a){return t("label",{key:a,staticClass:"flex items-center gap-1 text-xs text-textMuted cursor-pointer"},[t("input",{directives:[{name:"model",rawName:"v-model",value:e.form.skills,expression:"form.skills"}],staticClass:"accent-accent",attrs:{type:"checkbox"},domProps:{value:a,checked:Array.isArray(e.form.skills)?e._i(e.form.skills,a)>-1:e.form.skills},on:{change:function(o){var r=e.form.skills,l=o.target,d=!!l.checked;if(Array.isArray(r)){var n=a,c=e._i(r,n);l.checked?c<0&&e.$set(e.form,"skills",r.concat([n])):c>-1&&e.$set(e.form,"skills",r.slice(0,c).concat(r.slice(c+1)))}else e.$set(e.form,"skills",d)}}}),e._v(" "+e._s(a)+" ")])}),0)]),t("div",[e._m(4),t("textarea",{directives:[{name:"model",rawName:"v-model",value:e.form.content,expression:"form.content"}],staticClass:"w-full bg-black/20 border border-white/10 text-white text-sm px-3 py-2 rounded resize-none",attrs:{rows:"5",placeholder:"请描述任务内容..."},domProps:{value:e.form.content},on:{input:function(a){a.target.composing||e.$set(e.form,"content",a.target.value)}}})]),t("div",{staticClass:"flex items-center gap-2"},[t("input",{directives:[{name:"model",rawName:"v-model",value:e.form.enabled,expression:"form.enabled"}],staticClass:"accent-accent",attrs:{type:"checkbox",id:"taskEnabled"},domProps:{checked:Array.isArray(e.form.enabled)?e._i(e.form.enabled,null)>-1:e.form.enabled},on:{change:function(a){var o=e.form.enabled,r=a.target,l=!!r.checked;if(Array.isArray(o)){var d=null,n=e._i(o,d);r.checked?n<0&&e.$set(e.form,"enabled",o.concat([d])):n>-1&&e.$set(e.form,"enabled",o.slice(0,n).concat(o.slice(n+1)))}else e.$set(e.form,"enabled",l)}}}),t("label",{staticClass:"text-xs text-textMuted",attrs:{for:"taskEnabled"}},[e._v("立即启用")])])]),t("div",{staticClass:"px-4 py-3 border-t border-border flex justify-end gap-2"},[t("button",{staticClass:"px-4 py-1 text-textMuted text-sm rounded hover:bg-white/10",on:{click:e.closeDialog}},[e._v("取消")]),t("button",{staticClass:"px-4 py-1 bg-accent text-white text-sm rounded hover:bg-accent/80",on:{click:e.saveTask}},[e._v(" "+e._s(e.isEditing?"保存":"创建")+" ")])])])]):e._e(),e.showLogDialog?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-lg w-[900px] max-h-[80vh] overflow-hidden flex flex-col"},[t("div",{staticClass:"px-4 py-3 border-b border-border flex items-center justify-between shrink-0"},[t("h3",{staticClass:"text-white font-medium"},[e._v(e._s((u=e.currentTask)==null?void 0:u.name)+" - 执行日志")]),t("button",{staticClass:"text-textMuted hover:text-white text-sm",on:{click:function(a){e.showLogDialog=!1}}},[e._v("关闭")])]),t("div",{staticClass:"flex-1 overflow-auto p-4"},[t("table",{staticClass:"w-full text-sm"},[e._m(5),t("tbody",[e._l(e.logs,function(a){return t("tr",{key:a.id,staticClass:"hover:bg-white/5"},[t("td",{staticClass:"px-3 py-2 border-b border-border/30"},[t("span",{staticClass:"text-xs px-2 py-0.5 rounded",class:a.status==="success"?"bg-green-500/20 text-green-400":"bg-red-500/20 text-red-400"},[e._v(" "+e._s(a.status==="success"?"成功":"失败")+" ")])]),t("td",{staticClass:"px-3 py-2 text-gray-300 border-b border-border/30"},[e._v(e._s(e.formatTime(a.executedAt)))]),t("td",{staticClass:"px-3 py-2 text-gray-300 border-b border-border/30"},[e._v(e._s(e.formatDuration(a.duration)))]),t("td",{staticClass:"px-3 py-2 text-gray-300 border-b border-border/30 truncate max-w-[400px]",attrs:{title:a.result}},[e._v(e._s(a.result||a.error||"-"))])])}),e.logs.length===0?t("tr",[t("td",{staticClass:"px-3 py-8 text-center text-textMuted",attrs:{colspan:"4"}},[e._v("暂无执行记录")])]):e._e()],2)])])])]):e._e()])},f=[function(){var s=this,e=s._self._c;return e("thead",{staticClass:"bg-sidebar sticky top-0"},[e("tr",[e("th",{staticClass:"px-3 py-2 text-left text-xs font-bold text-textMuted uppercase border-b border-border"},[s._v("状态")]),e("th",{staticClass:"px-3 py-2 text-left text-xs font-bold text-textMuted uppercase border-b border-border"},[s._v("名称")]),e("th",{staticClass:"px-3 py-2 text-left text-xs font-bold text-textMuted uppercase border-b border-border"},[s._v("模型")]),e("th",{staticClass:"px-3 py-2 text-left text-xs font-bold text-textMuted uppercase border-b border-border"},[s._v("调度")]),e("th",{staticClass:"px-3 py-2 text-left text-xs font-bold text-textMuted uppercase border-b border-border"},[s._v("技能")]),e("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,e=s._self._c;return e("label",{staticClass:"block text-xs text-textMuted mb-1"},[s._v("任务名称 "),e("span",{staticClass:"text-red-400"},[s._v("*")])])},function(){var s=this,e=s._self._c;return e("label",{staticClass:"block text-xs text-textMuted mb-1"},[s._v("AI 模型 "),e("span",{staticClass:"text-red-400"},[s._v("*")])])},function(){var s=this,e=s._self._c;return e("label",{staticClass:"block text-xs text-textMuted mb-1"},[s._v("调度周期 "),e("span",{staticClass:"text-red-400"},[s._v("*")])])},function(){var s=this,e=s._self._c;return e("label",{staticClass:"block text-xs text-textMuted mb-1"},[s._v("任务内容 "),e("span",{staticClass:"text-red-400"},[s._v("*")])])},function(){var s=this,e=s._self._c;return e("thead",{staticClass:"bg-sidebar sticky top-0"},[e("tr",[e("th",{staticClass:"px-3 py-2 text-left text-xs font-bold text-textMuted uppercase border-b border-border"},[s._v("状态")]),e("th",{staticClass:"px-3 py-2 text-left text-xs font-bold text-textMuted uppercase border-b border-border"},[s._v("时间")]),e("th",{staticClass:"px-3 py-2 text-left text-xs font-bold text-textMuted uppercase border-b border-border"},[s._v("耗时")]),e("th",{staticClass:"px-3 py-2 text-left text-xs font-bold text-textMuted uppercase border-b border-border"},[s._v("结果")])])])}],v=x(p,m,f,!1,null,null);const g=v.exports;export{g as default};
1
+ import{n as x,a as i}from"./index-Ch_-1SCN.js";const b={"*/5 * * * *":"每5分钟","*/30 * * * *":"每30分钟","0 * * * *":"每小时","0 */2 * * *":"每2小时","0 */12 * * *":"每12小时","0 0 * * *":"每天0点","0 0 1 * *":"每月1日0点"},p={name:"TasksView",data(){return{tasks:[],models:[],availableSkills:[],showDialog:!1,showLogDialog:!1,isEditing:!1,currentTask:null,logs:[],form:{name:"",model:"gpt-4",scheduleType:"0 * * * *",notifyType:"message",skills:[],content:"",enabled:!0}}},async created(){await this.loadTasks(),await this.loadModels(),await this.loadSkills()},methods:{async loadTasks(){try{const s=await i.getScheduledTasks();this.tasks=s.data||[]}catch(s){console.error("Load tasks failed:",s),this.$message.error("加载任务失败")}},async loadModels(){try{const s=await i.getModels();this.models=s.data||[],this.models.length>0&&!this.form.model&&(this.form.model=this.models[0].name)}catch(s){console.error("Load models failed:",s)}},async loadSkills(){var s;try{const e=await i.getSkills();this.availableSkills=((s=e.data)==null?void 0:s.map(t=>t.name))||[]}catch(e){console.error("Load skills failed:",e)}},formatSchedule(s){return b[s]||s},formatTime(s){return s?new Date(s).toLocaleString("zh-CN"):"-"},formatDuration(s){return s?s<1e3?`${s}ms`:`${(s/1e3).toFixed(2)}s`:"0ms"},openCreateDialog(){var s;this.isEditing=!1,this.form={name:"",model:((s=this.models[0])==null?void 0:s.name)||"gpt-4",scheduleType:"0 * * * *",notifyType:"message",skills:[],content:"",enabled:!0},this.showDialog=!0},openEditDialog(s){this.isEditing=!0,this.currentTask=s,this.form={name:s.name,model:s.model,scheduleType:s.scheduleType,notifyType:s.notifyType,skills:[...s.skills||[]],content:s.content,enabled:s.enabled},this.showDialog=!0},closeDialog(){this.showDialog=!1,this.currentTask=null},async saveTask(){if(!this.form.name||!this.form.content){this.$message.error("请填写必填项");return}try{this.isEditing&&this.currentTask?(await i.updateScheduledTask(this.currentTask.id,this.form),this.$message.success("任务已更新")):(await i.createScheduledTask(this.form),this.$message.success("任务已创建")),this.closeDialog(),await this.loadTasks()}catch(s){this.$message.error("保存失败: "+s.message)}},async deleteTask(s){if(confirm(`确定删除任务 "${s.name}" 吗?`))try{await i.deleteScheduledTask(s.id),this.$message.success("任务已删除"),await this.loadTasks()}catch(e){this.$message.error("删除失败: "+e.message)}},async startTask(s){try{await i.startScheduledTask(s.id),this.$message.success("任务已启动"),await this.loadTasks()}catch(e){this.$message.error("启动失败: "+e.message)}},async stopTask(s){try{await i.stopScheduledTask(s.id),this.$message.success("任务已停用"),await this.loadTasks()}catch(e){this.$message.error("停用失败: "+e.message)}},async runTask(s){try{await i.runTaskNow(s.id),this.$message.success("任务已开始执行")}catch(e){this.$message.error("执行失败: "+e.message)}},async openLogDialog(s){this.currentTask=s,this.showLogDialog=!0;try{const e=await i.getTaskLogs(s.id);this.logs=e.data||[]}catch(e){console.error("Load logs failed:",e),this.logs=[]}}}};var m=function(){var u;var e=this,t=e._self._c;return t("div",{staticClass:"flex-1 flex flex-col overflow-hidden bg-[#1e1e1e]"},[t("div",{staticClass:"px-4 py-3 border-b border-border bg-sidebar shrink-0"},[t("div",{staticClass:"flex items-center justify-between"},[t("div",{staticClass:"flex items-center gap-2"},[t("i",{staticClass:"fa-solid fa-clock text-accent"}),t("span",{staticClass:"text-white font-medium"},[e._v("定时任务")]),t("span",{staticClass:"text-xs text-textMuted"},[e._v(e._s(e.tasks.length)+" 个任务")])]),t("button",{staticClass:"px-3 py-1 bg-accent text-white text-xs rounded hover:bg-accent/80",on:{click:e.openCreateDialog}},[t("i",{staticClass:"fa-solid fa-plus mr-1"}),e._v(" 新建任务 ")])])]),t("div",{staticClass:"flex-1 overflow-auto p-4"},[t("table",{staticClass:"w-full text-sm"},[e._m(0),t("tbody",[e._l(e.tasks,function(a){return t("tr",{key:a.id,staticClass:"hover:bg-white/5"},[t("td",{staticClass:"px-3 py-2 border-b border-border/30"},[a.enabled?t("span",{staticClass:"text-xs px-2 py-0.5 rounded bg-green-500/20 text-green-400"},[e._v("启用")]):t("span",{staticClass:"text-xs px-2 py-0.5 rounded bg-gray-500/20 text-gray-400"},[e._v("停用")])]),t("td",{staticClass:"px-3 py-2 text-gray-200 border-b border-border/30"},[e._v(e._s(a.name))]),t("td",{staticClass:"px-3 py-2 text-gray-300 border-b border-border/30"},[e._v(e._s(a.model))]),t("td",{staticClass:"px-3 py-2 text-gray-300 border-b border-border/30"},[e._v(e._s(e.formatSchedule(a.scheduleType)))]),t("td",{staticClass:"px-3 py-2 text-gray-300 border-b border-border/30"},e._l(a.skills,function(o){var r;return(r=a.skills)!=null&&r.length?t("span",{key:o,staticClass:"text-xs px-1 py-0.5 bg-blue-500/20 text-blue-400 rounded mr-1"},[e._v(e._s(o))]):t("span",{staticClass:"text-textMuted"},[e._v("-")])}),0),t("td",{staticClass:"px-3 py-2 border-b border-border/30"},[t("div",{staticClass:"flex items-center gap-2"},[a.enabled?t("button",{staticClass:"text-xs px-2 py-1 text-yellow-400 hover:bg-yellow-500/20 rounded",on:{click:function(o){return e.stopTask(a)}}},[e._v("停用")]):t("button",{staticClass:"text-xs px-2 py-1 text-green-400 hover:bg-green-500/20 rounded",on:{click:function(o){return e.startTask(a)}}},[e._v("启动")]),t("button",{staticClass:"text-xs px-2 py-1 text-blue-400 hover:bg-blue-500/20 rounded",on:{click:function(o){return e.runTask(a)}}},[e._v("执行")]),t("button",{staticClass:"text-xs px-2 py-1 text-gray-400 hover:bg-white/10 rounded",on:{click:function(o){return e.openLogDialog(a)}}},[e._v("日志")]),t("button",{staticClass:"text-xs px-2 py-1 text-gray-400 hover:bg-white/10 rounded",on:{click:function(o){return e.openEditDialog(a)}}},[e._v("编辑")]),t("button",{staticClass:"text-xs px-2 py-1 text-red-400 hover:bg-red-500/20 rounded",on:{click:function(o){return e.deleteTask(a)}}},[e._v("删除")])])])])}),e.tasks.length===0?t("tr",[t("td",{staticClass:"px-3 py-8 text-center text-textMuted",attrs:{colspan:"6"}},[e._v('暂无任务,点击"新建任务"创建')])]):e._e()],2)])]),e.showDialog?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-lg w-[600px] max-h-[80vh] overflow-auto"},[t("div",{staticClass:"px-4 py-3 border-b border-border flex items-center justify-between"},[t("h3",{staticClass:"text-white font-medium"},[e._v(e._s(e.isEditing?"编辑任务":"新建任务"))]),t("button",{staticClass:"text-textMuted hover:text-white text-sm",on:{click:e.closeDialog}},[e._v("关闭")])]),t("div",{staticClass:"p-4 space-y-4"},[t("div",[e._m(1),t("input",{directives:[{name:"model",rawName:"v-model",value:e.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:e.form.name},on:{input:function(a){a.target.composing||e.$set(e.form,"name",a.target.value)}}})]),t("div",[e._m(2),t("select",{directives:[{name:"model",rawName:"v-model",value:e.form.model,expression:"form.model"}],staticClass:"w-full bg-black/20 border border-white/10 text-white text-sm px-3 py-2 rounded",on:{change:function(a){var o=Array.prototype.filter.call(a.target.options,function(r){return r.selected}).map(function(r){var l="_value"in r?r._value:r.value;return l});e.$set(e.form,"model",a.target.multiple?o:o[0])}}},e._l(e.models,function(a){return t("option",{key:a.id,domProps:{value:a.name}},[e._v(e._s(a.name))])}),0)]),t("div",[e._m(3),t("select",{directives:[{name:"model",rawName:"v-model",value:e.form.scheduleType,expression:"form.scheduleType"}],staticClass:"w-full bg-black/20 border border-white/10 text-white text-sm px-3 py-2 rounded",on:{change:function(a){var o=Array.prototype.filter.call(a.target.options,function(r){return r.selected}).map(function(r){var l="_value"in r?r._value:r.value;return l});e.$set(e.form,"scheduleType",a.target.multiple?o:o[0])}}},[t("option",{attrs:{value:"*/5 * * * *"}},[e._v("每5分钟")]),t("option",{attrs:{value:"*/30 * * * *"}},[e._v("每30分钟")]),t("option",{attrs:{value:"0 * * * *"}},[e._v("每小时")]),t("option",{attrs:{value:"0 */2 * * *"}},[e._v("每2小时")]),t("option",{attrs:{value:"0 */12 * * *"}},[e._v("每12小时")]),t("option",{attrs:{value:"0 0 * * *"}},[e._v("每天0点")]),t("option",{attrs:{value:"0 0 1 * *"}},[e._v("每月1日0点")])])]),t("div",[t("label",{staticClass:"block text-xs text-textMuted mb-1"},[e._v("通知方式")]),t("select",{directives:[{name:"model",rawName:"v-model",value:e.form.notifyType,expression:"form.notifyType"}],staticClass:"w-full bg-black/20 border border-white/10 text-white text-sm px-3 py-2 rounded",on:{change:function(a){var o=Array.prototype.filter.call(a.target.options,function(r){return r.selected}).map(function(r){var l="_value"in r?r._value:r.value;return l});e.$set(e.form,"notifyType",a.target.multiple?o:o[0])}}},[t("option",{attrs:{value:"message"}},[e._v("消息")]),t("option",{attrs:{value:"email"}},[e._v("邮件")])])]),t("div",[t("label",{staticClass:"block text-xs text-textMuted mb-1"},[e._v("关联技能")]),t("div",{staticClass:"flex flex-wrap gap-2"},e._l(e.availableSkills,function(a){return t("label",{key:a,staticClass:"flex items-center gap-1 text-xs text-textMuted cursor-pointer"},[t("input",{directives:[{name:"model",rawName:"v-model",value:e.form.skills,expression:"form.skills"}],staticClass:"accent-accent",attrs:{type:"checkbox"},domProps:{value:a,checked:Array.isArray(e.form.skills)?e._i(e.form.skills,a)>-1:e.form.skills},on:{change:function(o){var r=e.form.skills,l=o.target,d=!!l.checked;if(Array.isArray(r)){var n=a,c=e._i(r,n);l.checked?c<0&&e.$set(e.form,"skills",r.concat([n])):c>-1&&e.$set(e.form,"skills",r.slice(0,c).concat(r.slice(c+1)))}else e.$set(e.form,"skills",d)}}}),e._v(" "+e._s(a)+" ")])}),0)]),t("div",[e._m(4),t("textarea",{directives:[{name:"model",rawName:"v-model",value:e.form.content,expression:"form.content"}],staticClass:"w-full bg-black/20 border border-white/10 text-white text-sm px-3 py-2 rounded resize-none",attrs:{rows:"5",placeholder:"请描述任务内容..."},domProps:{value:e.form.content},on:{input:function(a){a.target.composing||e.$set(e.form,"content",a.target.value)}}})]),t("div",{staticClass:"flex items-center gap-2"},[t("input",{directives:[{name:"model",rawName:"v-model",value:e.form.enabled,expression:"form.enabled"}],staticClass:"accent-accent",attrs:{type:"checkbox",id:"taskEnabled"},domProps:{checked:Array.isArray(e.form.enabled)?e._i(e.form.enabled,null)>-1:e.form.enabled},on:{change:function(a){var o=e.form.enabled,r=a.target,l=!!r.checked;if(Array.isArray(o)){var d=null,n=e._i(o,d);r.checked?n<0&&e.$set(e.form,"enabled",o.concat([d])):n>-1&&e.$set(e.form,"enabled",o.slice(0,n).concat(o.slice(n+1)))}else e.$set(e.form,"enabled",l)}}}),t("label",{staticClass:"text-xs text-textMuted",attrs:{for:"taskEnabled"}},[e._v("立即启用")])])]),t("div",{staticClass:"px-4 py-3 border-t border-border flex justify-end gap-2"},[t("button",{staticClass:"px-4 py-1 text-textMuted text-sm rounded hover:bg-white/10",on:{click:e.closeDialog}},[e._v("取消")]),t("button",{staticClass:"px-4 py-1 bg-accent text-white text-sm rounded hover:bg-accent/80",on:{click:e.saveTask}},[e._v(" "+e._s(e.isEditing?"保存":"创建")+" ")])])])]):e._e(),e.showLogDialog?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-lg w-[900px] max-h-[80vh] overflow-hidden flex flex-col"},[t("div",{staticClass:"px-4 py-3 border-b border-border flex items-center justify-between shrink-0"},[t("h3",{staticClass:"text-white font-medium"},[e._v(e._s((u=e.currentTask)==null?void 0:u.name)+" - 执行日志")]),t("button",{staticClass:"text-textMuted hover:text-white text-sm",on:{click:function(a){e.showLogDialog=!1}}},[e._v("关闭")])]),t("div",{staticClass:"flex-1 overflow-auto p-4"},[t("table",{staticClass:"w-full text-sm"},[e._m(5),t("tbody",[e._l(e.logs,function(a){return t("tr",{key:a.id,staticClass:"hover:bg-white/5"},[t("td",{staticClass:"px-3 py-2 border-b border-border/30"},[t("span",{staticClass:"text-xs px-2 py-0.5 rounded",class:a.status==="success"?"bg-green-500/20 text-green-400":"bg-red-500/20 text-red-400"},[e._v(" "+e._s(a.status==="success"?"成功":"失败")+" ")])]),t("td",{staticClass:"px-3 py-2 text-gray-300 border-b border-border/30"},[e._v(e._s(e.formatTime(a.executedAt)))]),t("td",{staticClass:"px-3 py-2 text-gray-300 border-b border-border/30"},[e._v(e._s(e.formatDuration(a.duration)))]),t("td",{staticClass:"px-3 py-2 text-gray-300 border-b border-border/30 truncate max-w-[400px]",attrs:{title:a.result}},[e._v(e._s(a.result||a.error||"-"))])])}),e.logs.length===0?t("tr",[t("td",{staticClass:"px-3 py-8 text-center text-textMuted",attrs:{colspan:"4"}},[e._v("暂无执行记录")])]):e._e()],2)])])])]):e._e()])},f=[function(){var s=this,e=s._self._c;return e("thead",{staticClass:"bg-sidebar sticky top-0"},[e("tr",[e("th",{staticClass:"px-3 py-2 text-left text-xs font-bold text-textMuted uppercase border-b border-border"},[s._v("状态")]),e("th",{staticClass:"px-3 py-2 text-left text-xs font-bold text-textMuted uppercase border-b border-border"},[s._v("名称")]),e("th",{staticClass:"px-3 py-2 text-left text-xs font-bold text-textMuted uppercase border-b border-border"},[s._v("模型")]),e("th",{staticClass:"px-3 py-2 text-left text-xs font-bold text-textMuted uppercase border-b border-border"},[s._v("调度")]),e("th",{staticClass:"px-3 py-2 text-left text-xs font-bold text-textMuted uppercase border-b border-border"},[s._v("技能")]),e("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,e=s._self._c;return e("label",{staticClass:"block text-xs text-textMuted mb-1"},[s._v("任务名称 "),e("span",{staticClass:"text-red-400"},[s._v("*")])])},function(){var s=this,e=s._self._c;return e("label",{staticClass:"block text-xs text-textMuted mb-1"},[s._v("AI 模型 "),e("span",{staticClass:"text-red-400"},[s._v("*")])])},function(){var s=this,e=s._self._c;return e("label",{staticClass:"block text-xs text-textMuted mb-1"},[s._v("调度周期 "),e("span",{staticClass:"text-red-400"},[s._v("*")])])},function(){var s=this,e=s._self._c;return e("label",{staticClass:"block text-xs text-textMuted mb-1"},[s._v("任务内容 "),e("span",{staticClass:"text-red-400"},[s._v("*")])])},function(){var s=this,e=s._self._c;return e("thead",{staticClass:"bg-sidebar sticky top-0"},[e("tr",[e("th",{staticClass:"px-3 py-2 text-left text-xs font-bold text-textMuted uppercase border-b border-border"},[s._v("状态")]),e("th",{staticClass:"px-3 py-2 text-left text-xs font-bold text-textMuted uppercase border-b border-border"},[s._v("时间")]),e("th",{staticClass:"px-3 py-2 text-left text-xs font-bold text-textMuted uppercase border-b border-border"},[s._v("耗时")]),e("th",{staticClass:"px-3 py-2 text-left text-xs font-bold text-textMuted uppercase border-b border-border"},[s._v("结果")])])])}],v=x(p,m,f,!1,null,null);const g=v.exports;export{g as default};