tianxincode 1.0.52 → 1.0.53

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 (53) hide show
  1. package/dist/config/tx.config.js +1 -1
  2. package/dist/config/tx.config.js.map +1 -1
  3. package/dist/core/ai/agents/plan/plan.agent.d.ts.map +1 -1
  4. package/dist/core/ai/agents/plan/plan.agent.js +5 -27
  5. package/dist/core/ai/agents/plan/plan.agent.js.map +1 -1
  6. package/dist/core/ai/agents/plan/rewrite_user_message.d.ts +23 -0
  7. package/dist/core/ai/agents/plan/rewrite_user_message.d.ts.map +1 -0
  8. package/dist/core/ai/agents/plan/rewrite_user_message.js +54 -0
  9. package/dist/core/ai/agents/plan/rewrite_user_message.js.map +1 -0
  10. package/dist/gateway/api/project/delete_project.d.ts +3 -0
  11. package/dist/gateway/api/project/delete_project.d.ts.map +1 -0
  12. package/dist/gateway/api/project/delete_project.js +9 -0
  13. package/dist/gateway/api/project/delete_project.js.map +1 -0
  14. package/dist/gateway/api/project/project_routes.d.ts.map +1 -1
  15. package/dist/gateway/api/project/project_routes.js +2 -0
  16. package/dist/gateway/api/project/project_routes.js.map +1 -1
  17. package/package.json +1 -1
  18. package/web/dist/assets/PcLayout-ZXjT7WP9.js +1 -0
  19. package/web/dist/assets/{aiLogsView-i3_vXGdn.js → aiLogsView-B1Xv86FO.js} +1 -1
  20. package/web/dist/assets/{cssMode-tnR9zH52.js → cssMode-BFNigYrU.js} +1 -1
  21. package/web/dist/assets/{customActionsView-IPBMHLn5.js → customActionsView-BFZzvWXk.js} +1 -1
  22. package/web/dist/assets/{deployView-6_rjjo9r.js → deployView-BV8JVWE5.js} +1 -1
  23. package/web/dist/assets/{designView-cX2Hqfh8.js → designView-_qXRJlPw.js} +1 -1
  24. package/web/dist/assets/{devWorkflowView-U4v8ICoZ.js → devWorkflowView-CPJuckoU.js} +1 -1
  25. package/web/dist/assets/{devWorkflowViewApp-CKSoqveu.js → devWorkflowViewApp-394d9AlG.js} +1 -1
  26. package/web/dist/assets/{fileZihao-0UKigAgL.js → fileZihao-Chayeahb.js} +1 -1
  27. package/web/dist/assets/{freemarker2-BNOihskA.js → freemarker2-ByywVFhB.js} +1 -1
  28. package/web/dist/assets/{gitChanges-B9i4hT7g.js → gitChanges-Bcc9Ioc7.js} +1 -1
  29. package/web/dist/assets/{gitChangesApp-o1xUwMZ_.js → gitChangesApp-CRVkFMef.js} +1 -1
  30. package/web/dist/assets/{handlebars-Cb8pQLEG.js → handlebars-D-MvnLHF.js} +1 -1
  31. package/web/dist/assets/{html-dz4hh4wm.js → html-D5CJVQpa.js} +1 -1
  32. package/web/dist/assets/{htmlMode-3xfUPWXI.js → htmlMode-DaRvRPXz.js} +1 -1
  33. package/web/dist/assets/{index-D4gPOTeQ.js → index-BXyZNXwi.js} +8 -8
  34. package/web/dist/assets/{index-CGjQrgUT.css → index-BkRJ6vX6.css} +1 -1
  35. package/web/dist/assets/{javascript-uj2_iR-i.js → javascript-qiZQrKCd.js} +1 -1
  36. package/web/dist/assets/{jsonMode-BDztKq2p.js → jsonMode-BNOK_Lb2.js} +1 -1
  37. package/web/dist/assets/{liquid-DUnpHSIz.js → liquid-Cn4Vm_pv.js} +1 -1
  38. package/web/dist/assets/{mdx-WsmL_lUc.js → mdx-BZzvCzBz.js} +1 -1
  39. package/web/dist/assets/{mediaChat-D2KhvNIU.js → mediaChat-Cb8y-RVH.js} +1 -1
  40. package/web/dist/assets/{python-Wb66FUL_.js → python-BLKhgdt7.js} +1 -1
  41. package/web/dist/assets/{razor-BwputI7B.js → razor-DAh-8Vt3.js} +1 -1
  42. package/web/dist/assets/{taskView-BlSL_Dow.js → taskView-CJ1d1bfR.js} +1 -1
  43. package/web/dist/assets/{terminalView-D9LlaS3g.js → terminalView-0Gixm1yH.js} +1 -1
  44. package/web/dist/assets/{tsMode-uciq4wdD.js → tsMode-Ctez2MnL.js} +1 -1
  45. package/web/dist/assets/{typescript-wGuBgZrd.js → typescript-uKzlDE9T.js} +1 -1
  46. package/web/dist/assets/{wikiView-DDMiaAjr.js → wikiView-BAnnCorX.js} +1 -1
  47. package/web/dist/assets/{xml-D11j9Yzn.js → xml-1Z_L4vw8.js} +1 -1
  48. package/web/dist/assets/{yaml-2oQqXFU-.js → yaml-Cf9kIOyW.js} +1 -1
  49. package/web/dist/index.html +2 -2
  50. package/txcode/release/release-zihao/node-zihao.js +0 -291
  51. package/txcode/release/release-zihao/package.json +0 -3
  52. package/txcode/skills/llm-wiki/validate-menu.js +0 -148
  53. package/web/dist/assets/PcLayout-DEP-5oVL.js +0 -1
@@ -1,4 +1,4 @@
1
- import{n as d,I as g,R as m,D as f,S as v,M as C,g as p,a as o,s as S,b,F as k,c as w,e as D,K as P,d as M,f as x}from"./index-D4gPOTeQ.js";import{m as y}from"./mediaChat-D2KhvNIU.js";const F={name:"WorkflowSidebar",props:{categories:{type:Array,default:()=>[]},projects:{type:Object,default:()=>{}},currentCategory:{type:String,default:""},currentProject:{type:String,default:""},currentStep:{type:Number,default:1},isLoading:{type:Boolean,default:!1}},data(){return{selectedCategory:"",selectedProject:"",steps:[{id:1,title:"新建需求",desc:"创建新的需求项目",icon:"el-icon-folder-add"},{id:2,title:"方案设计",desc:"编写需求方案",icon:"el-icon-edit"},{id:3,title:"代码生成",desc:"根据方案生成代码",icon:"el-icon-document"},{id:4,title:"测试验收",desc:"测试验证功能",icon:"el-icon-s-check"}]}},computed:{hasAnyProject(){return Object.keys(this.projects||{}).length>0},visibleSteps(){return this.hasAnyProject?this.steps:this.steps.filter(s=>s.id===1)}},watch:{currentCategory(s){this.selectedCategory=s},currentProject(s){this.selectedProject=s}},methods:{onCategoryChange(s){this.selectedProject="",this.$emit("category-change",s)},onProjectChange(s){this.$emit("project-change",s)},onStepClick(s){this.$emit("step-change",s)},isStepCompleted(s){var i;if(!this.currentProject)return!1;const e=`${this.currentCategory}/${this.currentProject}`,t=this.projects[e];return((i=t==null?void 0:t.stepStatus)==null?void 0:i[s])===!0}}};var T=function(){var e=this,t=e._self._c;return t("div",{staticClass:"workflow-sidebar"},[t("div",{staticClass:"sidebar-header"},[t("h3",[e._v("当前项目")]),t("div",{staticClass:"project-display-row"},[t("span",{staticClass:"label"},[e._v("大类")]),t("span",{staticClass:"value"},[e._v(e._s(e.currentCategory||"-"))])]),t("div",{staticClass:"project-display-row"},[t("span",{staticClass:"label"},[e._v("需求")]),t("span",{staticClass:"value"},[e._v(e._s(e.currentProject||"-"))])])]),t("div",{staticClass:"step-list"},e._l(e.visibleSteps,function(i){return t("div",{key:i.id,class:["step-item",{active:e.currentStep===i.id,completed:e.isStepCompleted(i.id)}],on:{click:function(a){return e.onStepClick(i.id)}}},[t("div",{staticClass:"step-icon"},[t("i",{class:i.icon})]),t("div",{staticClass:"step-info"},[t("div",{staticClass:"step-title"},[e._v(e._s(i.title))]),t("div",{staticClass:"step-desc"},[e._v(e._s(i.desc))])]),t("div",{staticClass:"step-status"},[e.isStepCompleted(i.id)?t("i",{staticClass:"el-icon-circle-check",staticStyle:{color:"#22c55e"}}):e._e()])])}),0)])},j=[],V=d(F,T,j,!1,null,"86f1727d");const R=V.exports,q={name:"Step1NewReq",props:{categories:{type:Array,default:()=>[]},projects:{type:Object,default:()=>({})},basePath:{type:String,default:""},currentCategory:{type:String,default:""},currentProject:{type:String,default:""}},data(){return{selectedCategory:"",selectedProject:"",dialogVisible:!1,dialogInput:"",requirementDialogVisible:!1,requirementDialogInput:""}},computed:{existingRequirementList(){if(!this.selectedCategory)return[];const s=`${this.selectedCategory}/`;return Object.keys(this.projects).filter(e=>e.startsWith(s)).map(e=>e.split("/")[1]).sort()}},watch:{currentCategory:{immediate:!0,handler(s){this.selectedCategory=s||""}},currentProject:{immediate:!0,handler(s){this.selectedProject=s||""}},selectedCategory(s){s||(this.selectedProject="")},existingRequirementList(s){this.selectedProject&&(!Array.isArray(s)||s.length===0||s.includes(this.selectedProject)||(this.selectedProject=""))}},methods:{onCategoryChange(){this.selectedProject="",this.$emit("category-change",this.selectedCategory||""),this.$emit("project-change","")},onProjectChange(){this.$emit("project-change",this.selectedProject||"")},showCreateRequirementDialog(){if(!this.selectedCategory){this.$message.warning("请先选择大类");return}this.requirementDialogInput="",this.requirementDialogVisible=!0},handleCreateRequirementConfirm(){const s=this.requirementDialogInput.trim();if(!s){this.$message.warning("需求名称不能为空");return}if(this.existingRequirementList.includes(s)){this.$message.warning("该需求已存在");return}this.$emit("create-requirement",{category:this.selectedCategory,name:s}),this.requirementDialogVisible=!1},showCreateCategoryDialog(){this.dialogInput="",this.dialogVisible=!0},handleDialogConfirm(){const s=this.dialogInput.trim();if(!s){this.$message.warning("名称不能为空");return}this.$emit("create-category",s),this.dialogVisible=!1}}};var B=function(){var e=this,t=e._self._c;return t("div",{staticClass:"step1-container"},[t("div",{staticClass:"step1-main"},[t("div",{staticClass:"panel-section"},[e._m(0),t("div",{staticClass:"panel-section-body"},[t("el-form",{attrs:{"label-position":"top",size:"small"}},[t("el-form-item",{attrs:{label:"所属大类"}},[t("div",{staticClass:"flex gap-2"},[t("el-select",{staticStyle:{flex:"1"},attrs:{placeholder:"请选择大类"},on:{change:e.onCategoryChange},model:{value:e.selectedCategory,callback:function(i){e.selectedCategory=i},expression:"selectedCategory"}},e._l(e.categories,function(i){return t("el-option",{key:i,attrs:{label:i,value:i}})}),1),t("el-button",{on:{click:e.showCreateCategoryDialog}},[t("i",{staticClass:"el-icon-plus"}),e._v(" 新建 ")])],1)]),t("el-form-item",{attrs:{label:"选择需求"}},[t("div",{staticClass:"flex gap-2"},[t("el-select",{staticStyle:{flex:"1"},attrs:{placeholder:"选择已有需求目录",disabled:!e.selectedCategory},on:{change:e.onProjectChange},model:{value:e.selectedProject,callback:function(i){e.selectedProject=i},expression:"selectedProject"}},e._l(e.existingRequirementList,function(i){return t("el-option",{key:i,attrs:{label:i,value:i}})}),1),t("el-button",{attrs:{disabled:!e.selectedCategory},on:{click:e.showCreateRequirementDialog}},[t("i",{staticClass:"el-icon-plus"}),e._v(" 新建 ")])],1)]),t("div",{staticClass:"form-hint",staticStyle:{color:"#84848a"}},[e._v(" "+e._s(e.selectedCategory?"可直接选择已有需求,或点击“新建”创建需求目录":"请先选择大类")+" ")])],1)],1)])]),t("el-dialog",{attrs:{title:"新建大类",visible:e.dialogVisible,width:"400px"},on:{"update:visible":function(i){e.dialogVisible=i}}},[t("el-form",[t("el-form-item",{attrs:{label:"大类名称"}},[t("el-input",{attrs:{placeholder:"输入大类名称"},model:{value:e.dialogInput,callback:function(i){e.dialogInput=i},expression:"dialogInput"}})],1)],1),t("span",{attrs:{slot:"footer"},slot:"footer"},[t("el-button",{on:{click:function(i){e.dialogVisible=!1}}},[e._v("取消")]),t("el-button",{attrs:{type:"primary"},on:{click:e.handleDialogConfirm}},[e._v("确定")])],1)],1),t("el-dialog",{attrs:{title:"新建需求",visible:e.requirementDialogVisible,width:"400px"},on:{"update:visible":function(i){e.requirementDialogVisible=i}}},[t("el-form",[t("el-form-item",{attrs:{label:"需求目录名称"}},[t("el-input",{attrs:{placeholder:"输入需求名称,如:用户管理"},model:{value:e.requirementDialogInput,callback:function(i){e.requirementDialogInput=i},expression:"requirementDialogInput"}})],1)],1),t("span",{attrs:{slot:"footer"},slot:"footer"},[t("el-button",{on:{click:function(i){e.requirementDialogVisible=!1}}},[e._v("取消")]),t("el-button",{attrs:{type:"primary"},on:{click:e.handleCreateRequirementConfirm}},[e._v("确定")])],1)],1)],1)},L=[function(){var s=this,e=s._self._c;return e("div",{staticClass:"panel-section-header"},[e("span",[e("i",{staticClass:"el-icon-folder-add"}),s._v(" 创建新需求")])])}],W=d(q,B,L,!1,null,"1cbab0a8");const z=W.exports,N={name:"DesignDiscuss",components:{ModelSelectDialog:C,SkillSelectDialog:v,DesignSelectDialog:f,ResizableTextarea:m,ImagePreviewList:g},mixins:[y()],props:{category:{type:String,default:""},name:{type:String,default:""},reqBasePath:{type:String,default:""}},data(){return{discussions:[],currentDiscussion:null,dropdownOpen:!1,activeMenuId:null,renamingId:null,renameTitle:"",deleteDialogVisible:!1,deleteTarget:null,logItems:[],inputMessage:"",disabled:!1,stopping:!1,promptTokens:0,modelName:"",modelSelectVisible:!1,skillSelectVisible:!1,designSelectVisible:!1,skillCursorPos:-1,sessionStatus:"idle",wsUnsubscribe:null}},computed:{specFilePath(){return!this.category||!this.name?"":`${this.reqBasePath}/${this.category}/${this.name}/${this.name}_方案.md`},sessionFilePath(){return!this.category||!this.name?"":`${this.reqBasePath}/${this.category}/${this.name}/session.json`}},watch:{category:{handler(){this.loadData()}},name:{handler(){this.loadData()}}},async mounted(){document.addEventListener("mousedown",this.onDocumentMouseDown),await this.loadData(),await this.loadDefaultModel()},beforeDestroy(){document.removeEventListener("mousedown",this.onDocumentMouseDown),this.wsUnsubscribe&&this.wsUnsubscribe()},methods:{handleKeydown(s){if(s.key==="Enter")if(s.ctrlKey){const e=s.target,t=e.selectionStart,i=e.selectionEnd,a=this.inputMessage;this.inputMessage=a.substring(0,t)+`
1
+ import{n as d,I as g,R as m,D as f,S as v,M as C,g as p,a as o,s as S,b,F as k,c as w,e as D,K as P,d as M,f as x}from"./index-BXyZNXwi.js";import{m as y}from"./mediaChat-Cb8y-RVH.js";const F={name:"WorkflowSidebar",props:{categories:{type:Array,default:()=>[]},projects:{type:Object,default:()=>{}},currentCategory:{type:String,default:""},currentProject:{type:String,default:""},currentStep:{type:Number,default:1},isLoading:{type:Boolean,default:!1}},data(){return{selectedCategory:"",selectedProject:"",steps:[{id:1,title:"新建需求",desc:"创建新的需求项目",icon:"el-icon-folder-add"},{id:2,title:"方案设计",desc:"编写需求方案",icon:"el-icon-edit"},{id:3,title:"代码生成",desc:"根据方案生成代码",icon:"el-icon-document"},{id:4,title:"测试验收",desc:"测试验证功能",icon:"el-icon-s-check"}]}},computed:{hasAnyProject(){return Object.keys(this.projects||{}).length>0},visibleSteps(){return this.hasAnyProject?this.steps:this.steps.filter(s=>s.id===1)}},watch:{currentCategory(s){this.selectedCategory=s},currentProject(s){this.selectedProject=s}},methods:{onCategoryChange(s){this.selectedProject="",this.$emit("category-change",s)},onProjectChange(s){this.$emit("project-change",s)},onStepClick(s){this.$emit("step-change",s)},isStepCompleted(s){var i;if(!this.currentProject)return!1;const e=`${this.currentCategory}/${this.currentProject}`,t=this.projects[e];return((i=t==null?void 0:t.stepStatus)==null?void 0:i[s])===!0}}};var T=function(){var e=this,t=e._self._c;return t("div",{staticClass:"workflow-sidebar"},[t("div",{staticClass:"sidebar-header"},[t("h3",[e._v("当前项目")]),t("div",{staticClass:"project-display-row"},[t("span",{staticClass:"label"},[e._v("大类")]),t("span",{staticClass:"value"},[e._v(e._s(e.currentCategory||"-"))])]),t("div",{staticClass:"project-display-row"},[t("span",{staticClass:"label"},[e._v("需求")]),t("span",{staticClass:"value"},[e._v(e._s(e.currentProject||"-"))])])]),t("div",{staticClass:"step-list"},e._l(e.visibleSteps,function(i){return t("div",{key:i.id,class:["step-item",{active:e.currentStep===i.id,completed:e.isStepCompleted(i.id)}],on:{click:function(a){return e.onStepClick(i.id)}}},[t("div",{staticClass:"step-icon"},[t("i",{class:i.icon})]),t("div",{staticClass:"step-info"},[t("div",{staticClass:"step-title"},[e._v(e._s(i.title))]),t("div",{staticClass:"step-desc"},[e._v(e._s(i.desc))])]),t("div",{staticClass:"step-status"},[e.isStepCompleted(i.id)?t("i",{staticClass:"el-icon-circle-check",staticStyle:{color:"#22c55e"}}):e._e()])])}),0)])},j=[],V=d(F,T,j,!1,null,"86f1727d");const R=V.exports,q={name:"Step1NewReq",props:{categories:{type:Array,default:()=>[]},projects:{type:Object,default:()=>({})},basePath:{type:String,default:""},currentCategory:{type:String,default:""},currentProject:{type:String,default:""}},data(){return{selectedCategory:"",selectedProject:"",dialogVisible:!1,dialogInput:"",requirementDialogVisible:!1,requirementDialogInput:""}},computed:{existingRequirementList(){if(!this.selectedCategory)return[];const s=`${this.selectedCategory}/`;return Object.keys(this.projects).filter(e=>e.startsWith(s)).map(e=>e.split("/")[1]).sort()}},watch:{currentCategory:{immediate:!0,handler(s){this.selectedCategory=s||""}},currentProject:{immediate:!0,handler(s){this.selectedProject=s||""}},selectedCategory(s){s||(this.selectedProject="")},existingRequirementList(s){this.selectedProject&&(!Array.isArray(s)||s.length===0||s.includes(this.selectedProject)||(this.selectedProject=""))}},methods:{onCategoryChange(){this.selectedProject="",this.$emit("category-change",this.selectedCategory||""),this.$emit("project-change","")},onProjectChange(){this.$emit("project-change",this.selectedProject||"")},showCreateRequirementDialog(){if(!this.selectedCategory){this.$message.warning("请先选择大类");return}this.requirementDialogInput="",this.requirementDialogVisible=!0},handleCreateRequirementConfirm(){const s=this.requirementDialogInput.trim();if(!s){this.$message.warning("需求名称不能为空");return}if(this.existingRequirementList.includes(s)){this.$message.warning("该需求已存在");return}this.$emit("create-requirement",{category:this.selectedCategory,name:s}),this.requirementDialogVisible=!1},showCreateCategoryDialog(){this.dialogInput="",this.dialogVisible=!0},handleDialogConfirm(){const s=this.dialogInput.trim();if(!s){this.$message.warning("名称不能为空");return}this.$emit("create-category",s),this.dialogVisible=!1}}};var B=function(){var e=this,t=e._self._c;return t("div",{staticClass:"step1-container"},[t("div",{staticClass:"step1-main"},[t("div",{staticClass:"panel-section"},[e._m(0),t("div",{staticClass:"panel-section-body"},[t("el-form",{attrs:{"label-position":"top",size:"small"}},[t("el-form-item",{attrs:{label:"所属大类"}},[t("div",{staticClass:"flex gap-2"},[t("el-select",{staticStyle:{flex:"1"},attrs:{placeholder:"请选择大类"},on:{change:e.onCategoryChange},model:{value:e.selectedCategory,callback:function(i){e.selectedCategory=i},expression:"selectedCategory"}},e._l(e.categories,function(i){return t("el-option",{key:i,attrs:{label:i,value:i}})}),1),t("el-button",{on:{click:e.showCreateCategoryDialog}},[t("i",{staticClass:"el-icon-plus"}),e._v(" 新建 ")])],1)]),t("el-form-item",{attrs:{label:"选择需求"}},[t("div",{staticClass:"flex gap-2"},[t("el-select",{staticStyle:{flex:"1"},attrs:{placeholder:"选择已有需求目录",disabled:!e.selectedCategory},on:{change:e.onProjectChange},model:{value:e.selectedProject,callback:function(i){e.selectedProject=i},expression:"selectedProject"}},e._l(e.existingRequirementList,function(i){return t("el-option",{key:i,attrs:{label:i,value:i}})}),1),t("el-button",{attrs:{disabled:!e.selectedCategory},on:{click:e.showCreateRequirementDialog}},[t("i",{staticClass:"el-icon-plus"}),e._v(" 新建 ")])],1)]),t("div",{staticClass:"form-hint",staticStyle:{color:"#84848a"}},[e._v(" "+e._s(e.selectedCategory?"可直接选择已有需求,或点击“新建”创建需求目录":"请先选择大类")+" ")])],1)],1)])]),t("el-dialog",{attrs:{title:"新建大类",visible:e.dialogVisible,width:"400px"},on:{"update:visible":function(i){e.dialogVisible=i}}},[t("el-form",[t("el-form-item",{attrs:{label:"大类名称"}},[t("el-input",{attrs:{placeholder:"输入大类名称"},model:{value:e.dialogInput,callback:function(i){e.dialogInput=i},expression:"dialogInput"}})],1)],1),t("span",{attrs:{slot:"footer"},slot:"footer"},[t("el-button",{on:{click:function(i){e.dialogVisible=!1}}},[e._v("取消")]),t("el-button",{attrs:{type:"primary"},on:{click:e.handleDialogConfirm}},[e._v("确定")])],1)],1),t("el-dialog",{attrs:{title:"新建需求",visible:e.requirementDialogVisible,width:"400px"},on:{"update:visible":function(i){e.requirementDialogVisible=i}}},[t("el-form",[t("el-form-item",{attrs:{label:"需求目录名称"}},[t("el-input",{attrs:{placeholder:"输入需求名称,如:用户管理"},model:{value:e.requirementDialogInput,callback:function(i){e.requirementDialogInput=i},expression:"requirementDialogInput"}})],1)],1),t("span",{attrs:{slot:"footer"},slot:"footer"},[t("el-button",{on:{click:function(i){e.requirementDialogVisible=!1}}},[e._v("取消")]),t("el-button",{attrs:{type:"primary"},on:{click:e.handleCreateRequirementConfirm}},[e._v("确定")])],1)],1)],1)},L=[function(){var s=this,e=s._self._c;return e("div",{staticClass:"panel-section-header"},[e("span",[e("i",{staticClass:"el-icon-folder-add"}),s._v(" 创建新需求")])])}],W=d(q,B,L,!1,null,"1cbab0a8");const z=W.exports,N={name:"DesignDiscuss",components:{ModelSelectDialog:C,SkillSelectDialog:v,DesignSelectDialog:f,ResizableTextarea:m,ImagePreviewList:g},mixins:[y()],props:{category:{type:String,default:""},name:{type:String,default:""},reqBasePath:{type:String,default:""}},data(){return{discussions:[],currentDiscussion:null,dropdownOpen:!1,activeMenuId:null,renamingId:null,renameTitle:"",deleteDialogVisible:!1,deleteTarget:null,logItems:[],inputMessage:"",disabled:!1,stopping:!1,promptTokens:0,modelName:"",modelSelectVisible:!1,skillSelectVisible:!1,designSelectVisible:!1,skillCursorPos:-1,sessionStatus:"idle",wsUnsubscribe:null}},computed:{specFilePath(){return!this.category||!this.name?"":`${this.reqBasePath}/${this.category}/${this.name}/${this.name}_方案.md`},sessionFilePath(){return!this.category||!this.name?"":`${this.reqBasePath}/${this.category}/${this.name}/session.json`}},watch:{category:{handler(){this.loadData()}},name:{handler(){this.loadData()}}},async mounted(){document.addEventListener("mousedown",this.onDocumentMouseDown),await this.loadData(),await this.loadDefaultModel()},beforeDestroy(){document.removeEventListener("mousedown",this.onDocumentMouseDown),this.wsUnsubscribe&&this.wsUnsubscribe()},methods:{handleKeydown(s){if(s.key==="Enter")if(s.ctrlKey){const e=s.target,t=e.selectionStart,i=e.selectionEnd,a=this.inputMessage;this.inputMessage=a.substring(0,t)+`
2
2
  `+a.substring(i),this.$nextTick(()=>{e.selectionStart=e.selectionEnd=t+1})}else s.preventDefault(),this.sendMessage()},onDocumentMouseDown(s){this.activeMenuId&&!s.target.closest(".item-actions")&&(this.activeMenuId=null),this.dropdownOpen&&!s.target.closest(".discuss-dropdown")&&(this.dropdownOpen=!1)},async loadData(){await this.loadDiscussions()},async loadDiscussions(){var s;if(!this.category||!this.name){this.discussions=[],this.currentDiscussion=null;return}try{const e=await o.getFileContent(this.sessionFilePath);if(e&&((s=e.data)!=null&&s.content)){const t=JSON.parse(e.data.content);this.discussions=t.designDiscussions||[]}else this.discussions=[];this.discussions.length>0&&!this.currentDiscussion&&await this.switchDiscussion(this.discussions[0])}catch(e){console.error("Load discussions failed:",e),this.discussions=[],this.currentDiscussion=null}},async saveDiscussions(){var s;if(!(!this.category||!this.name))try{const e=await o.getFileContent(this.sessionFilePath);let t={};e&&((s=e.data)!=null&&s.content)&&(t=JSON.parse(e.data.content)),t.designDiscussions=this.discussions,await o.writeFile(this.sessionFilePath,JSON.stringify(t,null,2))}catch(e){console.error("Save discussions failed:",e)}},async createDiscussion(){var s,e,t,i;try{const a=`探讨${this.discussions.length+1}`,n=await o.createSession(a),l={id:((s=n.data)==null?void 0:s.id)||((e=n.data)==null?void 0:e.sessionId)||Date.now().toString(),sessionId:((t=n.data)==null?void 0:t.id)||((i=n.data)==null?void 0:i.sessionId),title:a,createdAt:new Date().toISOString()};this.discussions.push(l),await this.saveDiscussions(),this.dropdownOpen=!1,await this.switchDiscussion(l)}catch(a){console.error("Create discussion failed:",a),this.$message.error("创建探讨失败")}},async switchDiscussion(s){this.wsUnsubscribe&&(this.wsUnsubscribe(),this.wsUnsubscribe=null),this.currentDiscussion=s,this.dropdownOpen=!1,this.activeMenuId=null,this.logItems=[],this.inputMessage="",this.disabled=!1,this.stopping=!1,this.promptTokens=0,this.sessionStatus="idle",this.mediaFiles=[],s&&s.sessionId&&(await this.loadMessages(),this.subscribeSession())},startRename(s){this.activeMenuId=null,this.$prompt("请输入新名称","重命名探讨",{confirmButtonText:"确定",cancelButtonText:"取消",inputValue:s.title}).then(async({value:e})=>{e&&e.trim()&&(s.title=e.trim(),await this.saveDiscussions())}).catch(()=>{})},confirmDelete(s){this.activeMenuId=null,this.deleteTarget=s,this.deleteDialogVisible=!0},async doDelete(){const s=this.deleteTarget;if(this.deleteDialogVisible=!1,this.deleteTarget=null,!!s)try{await o.deleteSession(s.sessionId);const e=this.discussions.findIndex(t=>t.id===s.id);e!==-1&&this.discussions.splice(e,1),await this.saveDiscussions(),this.currentDiscussion&&this.currentDiscussion.id===s.id&&(this.discussions.length>0?await this.switchDiscussion(this.discussions[0]):(this.wsUnsubscribe&&(this.wsUnsubscribe(),this.wsUnsubscribe=null),this.currentDiscussion=null,this.logItems=[],this.promptTokens=0,this.sessionStatus="idle"))}catch(e){console.error("Delete discussion failed:",e),this.$message.error("删除探讨失败")}},async sendMessage(){const s=this.inputMessage.trim(),e=this.mediaFiles&&this.mediaFiles.length>0;if(!s&&!e||this.disabled)return;if(!this.currentDiscussion||!this.currentDiscussion.sessionId){this.$message.error("会话不存在,请刷新页面");return}this.wsUnsubscribe||this.subscribeSession();const t=`方案路径:${this.specFilePath}
3
3
 
4
4
  这个是对这个方案的探讨 你只需要回答用户的问题即可 不需要修改方案 也不要修改代码
@@ -1,4 +1,4 @@
1
- import{n as p,l as g,g as m,w as h,m as v,a as o}from"./index-D4gPOTeQ.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(){var e;if(!this.category||!this.name){this.specContent="";return}try{const s=await o.getFileContent(this.specFilePath);this.specContent=((e=s.data)==null?void 0:e.content)||""}catch{this.specContent=""}},async loadSession(){var e;if(!this.category||!this.name){this.sessionId="",this.parentInfo=null;return}try{const s=`${this.reqBasePath}/${this.category}/${this.name}/session.json`,t=await o.getFileContent(s);if(t&&((e=t.data)!=null&&e.content)){const i=JSON.parse(t.data.content);this.sessionId=i.designSessionId||"",this.parentInfo=i.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=`
1
+ import{n as p,l as g,g as m,w as h,m as v,a as o}from"./index-BXyZNXwi.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(){var e;if(!this.category||!this.name){this.specContent="";return}try{const s=await o.getFileContent(this.specFilePath);this.specContent=((e=s.data)==null?void 0:e.content)||""}catch{this.specContent=""}},async loadSession(){var e;if(!this.category||!this.name){this.sessionId="",this.parentInfo=null;return}try{const s=`${this.reqBasePath}/${this.category}/${this.name}/session.json`,t=await o.getFileContent(s);if(t&&((e=t.data)!=null&&e.content)){const i=JSON.parse(t.data.content);this.sessionId=i.designSessionId||"",this.parentInfo=i.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
3
  注意:当前方案是「${this.parentInfo.name}」的子方案,请参考父方案内容。父方案路径:${this.parentInfo.specPath}`);const t=`先在 ${this.specFilePath} 生成方案,先不要修改代码。${s}
4
4
 
@@ -1,2 +1,2 @@
1
- import{n as m,C,a as u}from"./index-D4gPOTeQ.js";const g="/api";async function c(t,e,a=null){const i={method:t,headers:{"Content-Type":"application/json"}};a&&t!=="GET"&&(i.body=JSON.stringify(a));const o=await(await fetch(`${g}${e}`,i)).json();if(o.success===!1)throw new Error(o.error||o.message||"请求失败");return o}const h={getZihaoConfig(){return c("GET","/zihao/config")},saveZihaoConfig(t){return c("POST","/zihao/config",t)},deleteZihaoConfig(t){return c("POST","/zihao/config/delete",{id:t})},setActiveConfig(t){return c("POST","/zihao/config/active",{id:t})},connect(){return c("POST","/zihao/connect")},browse(t="/"){return c("GET",`/zihao/browse?path=${encodeURIComponent(t)}`)},viewFile(t){return c("GET",`/zihao/view?path=${encodeURIComponent(t)}`)},create(t,e,a){return c("POST","/zihao/create",{name:t,path:e,type:a})},rename(t,e){return c("POST","/zihao/rename",{oldPath:t,newName:e})},deleteFile(t,e){return c("POST","/zihao/delete",{path:t,type:e})},saveContent(t,e){return c("POST","/zihao/save-content",{path:t,content:e})},getHomeDir(){return c("GET","/zihao/home-dir")},uploadChunk(t,e,a,i,l){const o=new FormData;return o.append("targetDir",t),o.append("fileName",encodeURIComponent(e)),o.append("chunkIndex",String(a)),o.append("totalChunks",String(i)),o.append("chunk",l),fetch(`${g}/zihao/chunk-upload`,{method:"POST",body:o}).then(n=>n.json()).then(n=>{if(n.success===!1)throw new Error(n.error||"上传分片失败");return n})},uploadWithProgress(t,e,a,i){const o=t,n=Math.ceil(o.size/1048576);return(async()=>{for(let r=0;r<n;r++){const f=r*1048576,x=Math.min(f+1048576,o.size),p=o.slice(f,x);await this.uploadChunk(a,e,r,n,p),i&&i(Math.round((r+1)/n*100))}return{success:!0}})()},async download(t,e,a){var s;const i=`${g}/zihao/download?path=${encodeURIComponent(t)}&localPath=${encodeURIComponent(e)}`,l=await fetch(i);if(!l.ok)throw new Error("下载失败");const o=(s=l.body)==null?void 0:s.getReader();if(!o)throw new Error("无法读取响应");const n=new TextDecoder;for(;;){const{done:r,value:f}=await o.read();if(r)break;const p=n.decode(f,{stream:!0}).split(`
1
+ import{n as m,C,a as u}from"./index-BXyZNXwi.js";const g="/api";async function c(t,e,a=null){const i={method:t,headers:{"Content-Type":"application/json"}};a&&t!=="GET"&&(i.body=JSON.stringify(a));const o=await(await fetch(`${g}${e}`,i)).json();if(o.success===!1)throw new Error(o.error||o.message||"请求失败");return o}const h={getZihaoConfig(){return c("GET","/zihao/config")},saveZihaoConfig(t){return c("POST","/zihao/config",t)},deleteZihaoConfig(t){return c("POST","/zihao/config/delete",{id:t})},setActiveConfig(t){return c("POST","/zihao/config/active",{id:t})},connect(){return c("POST","/zihao/connect")},browse(t="/"){return c("GET",`/zihao/browse?path=${encodeURIComponent(t)}`)},viewFile(t){return c("GET",`/zihao/view?path=${encodeURIComponent(t)}`)},create(t,e,a){return c("POST","/zihao/create",{name:t,path:e,type:a})},rename(t,e){return c("POST","/zihao/rename",{oldPath:t,newName:e})},deleteFile(t,e){return c("POST","/zihao/delete",{path:t,type:e})},saveContent(t,e){return c("POST","/zihao/save-content",{path:t,content:e})},getHomeDir(){return c("GET","/zihao/home-dir")},uploadChunk(t,e,a,i,l){const o=new FormData;return o.append("targetDir",t),o.append("fileName",encodeURIComponent(e)),o.append("chunkIndex",String(a)),o.append("totalChunks",String(i)),o.append("chunk",l),fetch(`${g}/zihao/chunk-upload`,{method:"POST",body:o}).then(n=>n.json()).then(n=>{if(n.success===!1)throw new Error(n.error||"上传分片失败");return n})},uploadWithProgress(t,e,a,i){const o=t,n=Math.ceil(o.size/1048576);return(async()=>{for(let r=0;r<n;r++){const f=r*1048576,x=Math.min(f+1048576,o.size),p=o.slice(f,x);await this.uploadChunk(a,e,r,n,p),i&&i(Math.round((r+1)/n*100))}return{success:!0}})()},async download(t,e,a){var s;const i=`${g}/zihao/download?path=${encodeURIComponent(t)}&localPath=${encodeURIComponent(e)}`,l=await fetch(i);if(!l.ok)throw new Error("下载失败");const o=(s=l.body)==null?void 0:s.getReader();if(!o)throw new Error("无法读取响应");const n=new TextDecoder;for(;;){const{done:r,value:f}=await o.read();if(r)break;const p=n.decode(f,{stream:!0}).split(`
2
2
  `).filter(Boolean);for(const v of p)try{const d=JSON.parse(v);if(typeof d.progress=="number")a(d.progress);else if(d.done)a(100);else if(d.success===!1)throw new Error(d.error)}catch{}}}},b={name:"ZihaoConfigDialog",data(){return{dialogVisible:!1,editingConfig:null,loading:!1,form:{name:"",url:"",username:"",password:""},rules:{name:[{required:!0,message:"请输入配置名称",trigger:"blur"}],url:[{required:!0,message:"请输入服务地址",trigger:"blur"}],username:[{required:!0,message:"请输入用户名",trigger:"blur"}],password:[{required:!0,message:"请输入密码",trigger:"blur"}]}}},methods:{open(t=null){this.editingConfig=t,t?this.form={name:t.name||"",url:t.url||"",username:t.username||"",password:""}:this.form={name:"",url:"",username:"",password:""},this.dialogVisible=!0},handleClose(){var t;(t=this.$refs.formRef)==null||t.resetFields(),this.dialogVisible=!1,this.editingConfig=null},async handleSubmit(){var t;try{await this.$refs.formRef.validate()}catch{return}this.loading=!0;try{const e={...this.form};(t=this.editingConfig)!=null&&t.id&&(e.id=this.editingConfig.id,e.password||delete e.password),await h.saveZihaoConfig(e),this.$message.success("保存成功"),this.$emit("success"),this.handleClose()}catch(e){this.$message.error("保存失败: "+e.message)}finally{this.loading=!1}}}};var y=function(){var e=this,a=e._self._c;return a("el-dialog",{attrs:{title:e.editingConfig?"编辑梓豪配置":"新增梓豪配置",visible:e.dialogVisible,width:"500px","close-on-click-modal":!1},on:{"update:visible":function(i){e.dialogVisible=i},close:e.handleClose}},[a("el-form",{ref:"formRef",attrs:{model:e.form,rules:e.rules,"label-width":"100px"}},[a("el-form-item",{attrs:{label:"配置名称",prop:"name"}},[a("el-input",{attrs:{placeholder:"例如:我的梓豪服务器"},model:{value:e.form.name,callback:function(i){e.$set(e.form,"name",i)},expression:"form.name"}})],1),a("el-form-item",{attrs:{label:"服务地址",prop:"url"}},[a("el-input",{attrs:{placeholder:"例如:http://192.168.1.100:5000"},model:{value:e.form.url,callback:function(i){e.$set(e.form,"url",i)},expression:"form.url"}})],1),a("el-form-item",{attrs:{label:"用户名",prop:"username"}},[a("el-input",{attrs:{placeholder:"远程平台用户名"},model:{value:e.form.username,callback:function(i){e.$set(e.form,"username",i)},expression:"form.username"}})],1),a("el-form-item",{attrs:{label:"密码",prop:"password"}},[a("el-input",{attrs:{placeholder:"远程平台密码","show-password":""},model:{value:e.form.password,callback:function(i){e.$set(e.form,"password",i)},expression:"form.password"}})],1)],1),a("span",{attrs:{slot:"footer"},slot:"footer"},[a("el-button",{on:{click:e.handleClose}},[e._v("取消")]),a("el-button",{attrs:{type:"primary",loading:e.loading},on:{click:e.handleSubmit}},[e._v("确定")])],1)],1)},w=[],_=m(b,y,w,!1,null,null);const P=_.exports,D={name:"ZihaoContextMenu",components:{CopyPathDialog:C},data(){return{visible:!1,x:0,y:0,target:null,onRename:null,onDelete:null,onDownload:null}},methods:{show(t,e,a={}){this.target=e,this.x=t.pageX,this.y=t.pageY,this.visible=!0,this.onRename=a.onRename||null,this.onDelete=a.onDelete||null,this.onDownload=a.onDownload||null},hide(){this.visible=!1},handleRename(){this.hide(),this.onRename&&this.onRename(this.target)},handleDelete(){this.hide(),this.onDelete&&this.onDelete(this.target)},handleDownload(){this.hide(),this.onDownload&&this.onDownload(this.target)},handleCopyPath(){var t;this.hide(),(t=this.target)!=null&&t.path&&this.$refs.copyPathDialog.open(this.target.path)}}};var z=function(){var i;var e=this,a=e._self._c;return a("div",[a("div",{directives:[{name:"show",rawName:"v-show",value:e.visible,expression:"visible"}],staticClass:"fixed bg-[#252526] border border-[#3c3c3c] rounded shadow-lg py-1 z-50 min-w-[160px]",style:{left:e.x+"px",top:e.y+"px"}},[a("button",{staticClass:"w-full text-left px-4 py-2 text-sm text-[#cccccc] hover:bg-[#094771] flex items-center gap-2",on:{click:e.handleCopyPath}},[a("i",{staticClass:"fa-solid fa-copy text-xs w-4"}),e._v(" 复制路径 ")]),a("button",{staticClass:"w-full text-left px-4 py-2 text-sm text-[#cccccc] hover:bg-[#094771] flex items-center gap-2",on:{click:e.handleRename}},[a("i",{staticClass:"fa-solid fa-pen text-xs w-4"}),e._v(" 重命名 ")]),a("button",{staticClass:"w-full text-left px-4 py-2 text-sm text-red-400 hover:bg-[#094771] flex items-center gap-2",on:{click:e.handleDelete}},[a("i",{staticClass:"fa-solid fa-trash text-xs w-4"}),e._v(" 删除 ")]),((i=e.target)==null?void 0:i.type)==="file"?a("button",{staticClass:"w-full text-left px-4 py-2 text-sm text-[#cccccc] hover:bg-[#094771] flex items-center gap-2",on:{click:e.handleDownload}},[a("i",{staticClass:"fa-solid fa-download text-xs w-4"}),e._v(" 下载到本地 ")]):e._e()]),a("CopyPathDialog",{ref:"copyPathDialog"})],1)},Z=[],k=m(D,z,Z,!1,null,null);const L=k.exports,$={name:"FileZihao",components:{ZihaoConfigDialog:P,ZihaoContextMenu:L},data(){return{localItems:[],localLoading:!1,localPath:"",localCurrentPath:"",localParentPath:null,selectedLocalPath:null,localDragOver:!1,dragFile:null,zihaoConfig:null,zihaoItems:[],zihaoLoading:!1,zihaoPath:"/",zihaoPathInput:"/",selectedZihaoPath:null,isDragOver:!1,localContextMenu:{visible:!1,x:0,y:0,target:null},renameDialog:{visible:!1,title:"",value:"",target:null,isZihao:!1},uploadProgress:{visible:!1,percent:0,filename:"",isDownload:!1}}},async created(){document.addEventListener("click",this.hideLocalContextMenu),await this.loadZihaoConfig(),await this.loadLocalFiles()},beforeDestroy(){document.removeEventListener("click",this.hideLocalContextMenu)},methods:{async loadLocalFiles(){this.localLoading=!0;try{const t=await u.browseFilesystem(this.localPath);let e=t.data.items||[];this.localCurrentPath=t.data.current_path||"",this.localParentPath=t.data.parent_path,this.localParentPath!==void 0&&(e=[{name:"..",is_directory:!0,path:this.localParentPath||"",size:0},...e]),this.localItems=e.sort((a,i)=>a.name===".."?-1:i.name===".."?1:a.is_directory===i.is_directory?a.name.localeCompare(i.name):a.is_directory?-1:1)}catch(t){console.error("加载本地文件失败:",t)}finally{this.localLoading=!1}},refreshLocal(){this.loadLocalFiles()},goLocalUp(){this.localParentPath!==null&&(this.localPath=this.localParentPath===""?"":this.localParentPath,this.loadLocalFiles())},goLocalHome(){this.localPath="",this.loadLocalFiles()},selectLocalItem(t){this.selectedLocalPath=t.path},openLocalItem(t){t.name===".."?(this.localPath=t.path===""?"":t.path,this.loadLocalFiles()):t.is_directory&&(this.localPath=t.path,this.loadLocalFiles())},showLocalContextMenu(t,e){this.localContextMenu={visible:!0,x:t.pageX,y:t.pageY,target:e}},hideLocalContextMenu(){this.localContextMenu.visible=!1},copyLocalPath(){this.hideLocalContextMenu(),this.localContextMenu.target&&(navigator.clipboard.writeText(this.localContextMenu.target.path).catch(()=>{}),this.$message.success("已复制路径"))},showLocalRenameDialog(){const t=this.localContextMenu.target;!t||t.name===".."||(this.renameDialog={visible:!0,title:"重命名",value:t.name,target:t,isZihao:!1},this.hideLocalContextMenu(),this.$nextTick(()=>{var e,a;(e=this.$refs.renameInput)==null||e.focus(),(a=this.$refs.renameInput)==null||a.select()}))},async deleteLocalItem(){const t=this.localContextMenu.target;if(!(!t||t.name==="..")){try{await this.$confirm(`确定要删除 "${t.name}" 吗?`,"确认删除",{confirmButtonText:"删除",cancelButtonText:"取消",type:"warning"}),await u.deleteFile(t.path),this.$message.success("删除成功"),this.loadLocalFiles()}catch(e){e!=="cancel"&&this.$message.error("删除失败: "+e.message)}this.hideLocalContextMenu()}},async uploadToZihao(){this.hideLocalContextMenu();const t=this.localContextMenu.target;if(!t||t.is_directory||t.name==="..")return;if(!this.zihaoConfig){this.$message.warning("请先配置梓豪平台");return}const e=t.name,a=this.zihaoPath||"/";this.uploadProgress={visible:!0,percent:0,filename:e,isDownload:!1};try{const i=await fetch(`/api/file/download_file?path=${encodeURIComponent(t.path)}`);if(!i.ok)throw new Error("读取文件失败");const l=await i.blob(),o=new File([l],e);await h.uploadWithProgress(o,e,a,n=>{this.uploadProgress.percent=n}),this.$message.success("上传成功"),this.loadZihaoFiles()}catch(i){this.$message.error("上传失败: "+i.message)}finally{this.uploadProgress.visible=!1}},handleLocalDragStart(t,e){if(e.is_directory){t.preventDefault();return}this.dragFile=e,t.dataTransfer.effectAllowed="copy"},handleLocalDragOver(t){t.preventDefault(),this.localDragOver=!0,t.dataTransfer.dropEffect="copy"},handleLocalDragLeave(){this.localDragOver=!1},async handleLocalDrop(t){t.preventDefault(),this.localDragOver=!1;const e=t.dataTransfer.files;if(e.length===0)return;const a=this.localCurrentPath||this.localPath;if(!a){this.$message.warning("无法确定上传目录");return}for(const i of e){this.uploadProgress={visible:!0,percent:0,filename:i.name,isDownload:!1};try{await u.uploadFilesystemWithProgress(a,i,l=>{this.uploadProgress.percent=l})}catch(l){this.uploadProgress.visible=!1,this.$message.error(`上传 ${i.name} 失败: `+l.message);return}this.uploadProgress.visible=!1}this.$message.success(`已上传 ${e.length} 个文件`),this.loadLocalFiles()},async loadZihaoConfig(){try{const t=await h.getZihaoConfig();this.zihaoConfig=t.data.active,this.zihaoConfig&&await this.loadZihaoFiles()}catch(t){console.error("加载梓豪配置失败:",t)}},async loadZihaoFiles(){if(this.zihaoConfig){this.zihaoLoading=!0;try{let e=(await h.browse(this.zihaoPath)).data.items||[];if(this.zihaoPath!=="/"){const a=this.zihaoPath.split("/").filter(Boolean).slice(0,-1).join("/");e=[{name:"..",type:"folder",path:a?"/"+a:"/",size:0,modify_time:""},...e]}this.zihaoItems=e}catch(t){this.$message.error("加载梓豪文件失败: "+t.message)}finally{this.zihaoLoading=!1}}},refreshZihao(){this.loadZihaoFiles()},navigateZihaoPath(){let t=this.zihaoPathInput.trim();t&&(t.startsWith("/")||(t="/"+t),this.zihaoPath=t,this.zihaoPathInput=t,this.loadZihaoFiles())},goZihaoUp(){if(this.zihaoPath==="/")return;const t=this.zihaoPath.split("/").filter(Boolean);t.pop(),this.zihaoPath=t.length>0?"/"+t.join("/"):"/",this.zihaoPathInput=this.zihaoPath,this.loadZihaoFiles()},selectZihaoItem(t){this.selectedZihaoPath=t.path},openZihaoItem(t){t.type==="folder"&&(this.zihaoPath=t.path,this.zihaoPathInput=t.path,this.loadZihaoFiles())},showZihaoContextMenu(t,e){this.selectedZihaoPath=e.path,this.$refs.zihaoContextMenu.show(t,e,{onRename:this.showZihaoRenameDialog,onDelete:this.handleZihaoDelete,onDownload:e.type==="file"?this.downloadZihaoToLocal:null})},showZihaoRenameDialog(t){this.renameDialog={visible:!0,title:"重命名",value:t.name,target:t,isZihao:!0},this.$nextTick(()=>{var e,a;(e=this.$refs.renameInput)==null||e.focus(),(a=this.$refs.renameInput)==null||a.select()})},async handleZihaoDelete(t){try{await this.$confirm(`确定要删除 "${t.name}" 吗?`,"确认删除",{confirmButtonText:"删除",cancelButtonText:"取消",type:"warning"}),await h.deleteFile(t.path,t.type),this.$message.success("删除成功"),this.loadZihaoFiles()}catch(e){e!=="cancel"&&this.$message.error("删除失败: "+e.message)}},async downloadZihaoToLocal(t){const e=this.localCurrentPath||this.localPath;if(!e){this.$message.warning("请先进入一个本地文件夹");return}this.uploadProgress={visible:!0,percent:0,filename:t.name,isDownload:!0};try{const a=e.includes("\\")?"\\":"/",i=e.endsWith("/")||e.endsWith("\\")?"":a,l=e+i+t.name;await h.download(t.path,l,o=>{this.uploadProgress.percent=o}),this.$message.success("已下载到本地: "+l),this.loadLocalFiles()}catch(a){this.$message.error("下载失败: "+a.message)}finally{this.uploadProgress.visible=!1}},async confirmRename(){const{value:t,target:e,isZihao:a}=this.renameDialog;if(!t.trim()||!e){this.cancelRename();return}try{a?(await h.rename(e.path,t.trim()),this.$message.success("重命名成功"),this.loadZihaoFiles()):(await u.renameFile(e.path,t.trim()),this.$message.success("重命名成功"),this.loadLocalFiles())}catch(i){this.$message.error("重命名失败: "+i.message)}this.renameDialog.visible=!1},cancelRename(){this.renameDialog.visible=!1},handleZihaoDragOver(t){t.preventDefault(),this.isDragOver=!0,t.dataTransfer.dropEffect="copy"},handleZihaoDragLeave(){this.isDragOver=!1},async handleZihaoDrop(t){if(t.preventDefault(),this.isDragOver=!1,!this.dragFile||!this.zihaoConfig){this.$message.warning("请先从左侧拖拽文件");return}const e=this.dragFile.name,a=this.zihaoPath||"/";this.uploadProgress={visible:!0,percent:0,filename:e,isDownload:!1};try{const i=await fetch(`/api/file/download_file?path=${encodeURIComponent(this.dragFile.path)}`);if(!i.ok)throw new Error("读取文件失败");const l=await i.blob(),o=new File([l],e);await h.uploadWithProgress(o,e,a,n=>{this.uploadProgress.percent=n}),this.$message.success("上传成功"),this.loadZihaoFiles()}catch(i){this.$message.error("上传失败: "+i.message)}finally{this.uploadProgress.visible=!1,this.dragFile=null}},openZihaoConfig(){this.$refs.zihaoConfigDialog.open(this.zihaoConfig)},formatSize(t){if(!t)return"-";const e=["B","KB","MB","GB"];let a=0,i=t;for(;i>=1024&&a<e.length-1;)i/=1024,a++;return`${i.toFixed(1)}${e[a]}`},getFileIcon(t){var i;const e=(i=t.split(".").pop())==null?void 0:i.toLowerCase();return{js:"fa-brands fa-js text-yellow-400",ts:"fa-brands fa-js text-blue-400",html:"fa-brands fa-html5 text-orange-500",css:"fa-brands fa-css3 text-blue-400",json:"fa-solid fa-file-code text-yellow-300",md:"fa-solid fa-file-lines text-gray-400",py:"fa-brands fa-python text-blue-500",vue:"fa-brands fa-vuejs text-green-400",png:"fa-solid fa-image text-purple-400",jpg:"fa-solid fa-image text-purple-400",pdf:"fa-solid fa-file-pdf text-red-400"}[e]||"fa-solid fa-file text-gray-400"}}};var M=function(){var i,l,o,n;var e=this,a=e._self._c;return a("div",{staticClass:"flex-1 flex overflow-hidden"},[a("aside",{staticClass:"bg-sidebar border-r border-border flex flex-col shrink-0",staticStyle:{width:"50%"}},[e._m(0),a("div",{staticClass:"flex items-center gap-1 px-2 py-2 border-b border-border"},[a("button",{staticClass:"p-1 text-textMuted hover:text-white",attrs:{title:"上级目录"},on:{click:e.goLocalUp}},[a("i",{staticClass:"fa-solid fa-arrow-up"})]),a("button",{staticClass:"p-1 text-textMuted hover:text-white",attrs:{title:"刷新"},on:{click:e.refreshLocal}},[a("i",{staticClass:"fa-solid fa-refresh"})]),a("button",{staticClass:"p-1 text-textMuted hover:text-white",attrs:{title:"我的电脑"},on:{click:e.goLocalHome}},[a("i",{staticClass:"fa-solid fa-home"})])]),a("div",{staticClass:"flex-1 overflow-auto py-1",class:{"bg-blue-900/20":e.localDragOver},on:{dragover:function(s){return s.preventDefault(),e.handleLocalDragOver.apply(null,arguments)},dragleave:e.handleLocalDragLeave,drop:e.handleLocalDrop}},[e.localLoading?a("div",{staticClass:"flex items-center justify-center py-8 text-textMuted"},[a("i",{staticClass:"fa-solid fa-spinner fa-spin mr-2"}),e._v(" 加载中... ")]):e.localItems.length===0?a("div",{staticClass:"flex items-center justify-center py-8 text-textMuted text-sm"},[e._v(" 此目录为空 ")]):a("table",{staticClass:"w-full text-sm"},[e._m(1),a("tbody",e._l(e.localItems,function(s){return a("tr",{key:s.path,staticClass:"cursor-pointer border-b border-[#3c3c3c]/50 hover:bg-[#2a2a2a]",class:{"bg-[#094771]":e.selectedLocalPath===s.path},attrs:{draggable:!s.is_directory},on:{click:function(r){return e.selectLocalItem(s)},dblclick:function(r){return e.openLocalItem(s)},contextmenu:function(r){return r.preventDefault(),e.showLocalContextMenu(r,s)},dragstart:function(r){return e.handleLocalDragStart(r,s)}}},[a("td",{staticClass:"px-3 py-1"},[a("div",{staticClass:"flex items-center gap-2"},[a("i",{staticClass:"text-xs text-textMuted w-4",class:s.is_directory?"fa-solid fa-folder text-yellow-500":e.getFileIcon(s.name)}),a("span",{staticClass:"text-[#cccccc] truncate",attrs:{title:s.name}},[e._v(e._s(s.name))])])]),a("td",{staticClass:"px-3 py-1 text-[#808080] text-xs"},[e._v(e._s(s.is_directory?"文件夹":"文件"))]),a("td",{staticClass:"px-3 py-1 text-[#808080] text-xs text-right"},[e._v(e._s(s.is_directory?"-":e.formatSize(s.size)))]),a("td",{staticClass:"px-3 py-1 text-[#808080] text-xs"},[e._v("-")])])}),0)])]),a("div",{directives:[{name:"show",rawName:"v-show",value:e.localContextMenu.visible,expression:"localContextMenu.visible"}],staticClass:"fixed bg-[#252526] border border-[#3c3c3c] rounded shadow-lg py-1 z-50 min-w-[160px]",style:{left:e.localContextMenu.x+"px",top:e.localContextMenu.y+"px"}},[a("button",{staticClass:"w-full text-left px-4 py-2 text-sm text-[#cccccc] hover:bg-[#094771] flex items-center gap-2",on:{click:e.copyLocalPath}},[a("i",{staticClass:"fa-solid fa-copy text-xs w-4"}),e._v(" 复制路径 ")]),((i=e.localContextMenu.target)==null?void 0:i.name)!==".."?a("button",{staticClass:"w-full text-left px-4 py-2 text-sm text-[#cccccc] hover:bg-[#094771] flex items-center gap-2",on:{click:e.showLocalRenameDialog}},[a("i",{staticClass:"fa-solid fa-pen text-xs w-4"}),e._v(" 重命名 ")]):e._e(),((l=e.localContextMenu.target)==null?void 0:l.name)!==".."?a("button",{staticClass:"w-full text-left px-4 py-2 text-sm text-red-400 hover:bg-[#094771] flex items-center gap-2",on:{click:e.deleteLocalItem}},[a("i",{staticClass:"fa-solid fa-trash text-xs w-4"}),e._v(" 删除 ")]):e._e(),a("div",{staticClass:"border-t border-[#3c3c3c] my-1"}),((o=e.localContextMenu.target)==null?void 0:o.name)!==".."&&!((n=e.localContextMenu.target)!=null&&n.is_directory)?a("button",{staticClass:"w-full text-left px-4 py-2 text-sm text-[#cccccc] hover:bg-[#094771] flex items-center gap-2",on:{click:e.uploadToZihao}},[a("i",{staticClass:"fa-solid fa-server text-xs w-4"}),e._v(" 上传到梓豪 ")]):e._e()])]),a("main",{staticClass:"flex-1 flex flex-col min-w-0 bg-[#1e1e1e]"},[a("div",{staticClass:"flex border-b border-border bg-sidebar shrink-0"},[e._m(2),a("div",{staticClass:"flex-1"}),a("button",{staticClass:"p-1 mr-2 text-textMuted hover:text-white",attrs:{title:"梓豪配置"},on:{click:e.openZihaoConfig}},[a("i",{staticClass:"fa-solid fa-gear"})])]),a("div",{staticClass:"flex items-center gap-1 px-2 py-2 border-b border-border"},[a("button",{staticClass:"p-1 text-textMuted hover:text-white",attrs:{title:"上级目录"},on:{click:e.goZihaoUp}},[a("i",{staticClass:"fa-solid fa-arrow-up"})]),a("button",{staticClass:"p-1 text-textMuted hover:text-white",attrs:{title:"刷新"},on:{click:e.refreshZihao}},[a("i",{staticClass:"fa-solid fa-refresh"})]),a("input",{directives:[{name:"model",rawName:"v-model",value:e.zihaoPathInput,expression:"zihaoPathInput"}],staticClass:"flex-1 px-2 py-1 mx-1 bg-[#3c3c3c] border border-[#3c3c3c] rounded text-xs text-[#cccccc] focus:outline-none focus:border-[#0e639c]",attrs:{placeholder:"输入路径后回车跳转..."},domProps:{value:e.zihaoPathInput},on:{keyup:function(s){return!s.type.indexOf("key")&&e._k(s.keyCode,"enter",13,s.key,"Enter")?null:e.navigateZihaoPath.apply(null,arguments)},input:function(s){s.target.composing||(e.zihaoPathInput=s.target.value)}}})]),a("div",{staticClass:"flex-1 overflow-auto py-1",class:{"bg-blue-900/20":e.isDragOver},on:{dragover:function(s){return s.preventDefault(),e.handleZihaoDragOver.apply(null,arguments)},dragleave:e.handleZihaoDragLeave,drop:e.handleZihaoDrop}},[e.zihaoConfig?e.zihaoLoading?a("div",{staticClass:"flex items-center justify-center py-8 text-textMuted"},[a("i",{staticClass:"fa-solid fa-spinner fa-spin mr-2"}),e._v(" 加载中... ")]):e.zihaoItems.length===0?a("div",{staticClass:"flex items-center justify-center py-8 text-textMuted text-sm"},[e._v(" 此目录为空 ")]):a("table",{staticClass:"w-full text-sm"},[e._m(3),a("tbody",e._l(e.zihaoItems,function(s){return a("tr",{key:s.path,staticClass:"cursor-pointer border-b border-[#3c3c3c]/50 hover:bg-[#2a2a2a]",class:{"bg-[#094771]":e.selectedZihaoPath===s.path},on:{click:function(r){return e.selectZihaoItem(s)},dblclick:function(r){return e.openZihaoItem(s)},contextmenu:function(r){return r.preventDefault(),e.showZihaoContextMenu(r,s)}}},[a("td",{staticClass:"px-3 py-1"},[a("div",{staticClass:"flex items-center gap-2"},[a("i",{staticClass:"text-xs text-textMuted w-4",class:s.type==="folder"?"fa-solid fa-folder text-yellow-500":e.getFileIcon(s.name)}),a("span",{staticClass:"text-[#cccccc] truncate",attrs:{title:s.name}},[e._v(e._s(s.name))])])]),a("td",{staticClass:"px-3 py-1 text-[#808080] text-xs"},[e._v(e._s(s.type==="folder"?"文件夹":"文件"))]),a("td",{staticClass:"px-3 py-1 text-[#808080] text-xs text-right"},[e._v(e._s(s.type==="file"?e.formatSize(s.size):"-"))]),a("td",{staticClass:"px-3 py-1 text-[#808080] text-xs"},[e._v(e._s(s.modify_time||"-"))])])}),0)]):a("div",{staticClass:"flex items-center justify-center h-full text-textMuted"},[a("div",{staticClass:"text-center"},[a("i",{staticClass:"fa-solid fa-server text-4xl mb-4 opacity-30"}),a("p",{staticClass:"mb-2"},[e._v("未配置梓豪平台")]),a("button",{staticClass:"px-4 py-2 bg-[#0e639c] text-white rounded hover:bg-[#1177bb] text-sm",on:{click:e.openZihaoConfig}},[e._v(" 配置梓豪 ")])])])]),a("ZihaoConfigDialog",{ref:"zihaoConfigDialog",on:{success:e.loadZihaoConfig}}),a("ZihaoContextMenu",{ref:"zihaoContextMenu"})],1),a("div",{directives:[{name:"show",rawName:"v-show",value:e.renameDialog.visible,expression:"renameDialog.visible"}],staticClass:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",on:{click:function(s){return s.target!==s.currentTarget?null:e.cancelRename.apply(null,arguments)}}},[a("div",{staticClass:"bg-[#252526] border border-[#3c3c3c] rounded p-4 w-80"},[a("p",{staticClass:"text-[#cccccc] text-sm mb-3"},[e._v(e._s(e.renameDialog.title))]),a("input",{directives:[{name:"model",rawName:"v-model",value:e.renameDialog.value,expression:"renameDialog.value"}],ref:"renameInput",staticClass:"w-full px-3 py-2 bg-[#3c3c3c] border border-[#3c3c3c] rounded text-[#cccccc] text-sm focus:outline-none focus:border-[#0e639c]",domProps:{value:e.renameDialog.value},on:{keyup:[function(s){return!s.type.indexOf("key")&&e._k(s.keyCode,"enter",13,s.key,"Enter")?null:e.confirmRename.apply(null,arguments)},function(s){return!s.type.indexOf("key")&&e._k(s.keyCode,"escape",void 0,s.key,void 0)?null:e.cancelRename.apply(null,arguments)}],input:function(s){s.target.composing||e.$set(e.renameDialog,"value",s.target.value)}}}),a("div",{staticClass:"flex justify-end gap-2 mt-4"},[a("button",{staticClass:"px-3 py-1 text-xs text-[#808080] hover:text-white",on:{click:e.cancelRename}},[e._v("取消")]),a("button",{staticClass:"px-3 py-1 text-xs bg-[#0e639c] text-white rounded hover:bg-[#1177bb]",on:{click:e.confirmRename}},[e._v("确定")])])])]),e.uploadProgress.visible?a("div",{staticClass:"fixed inset-0 bg-black/50 flex items-center justify-center z-50"},[a("div",{staticClass:"bg-[#252526] border border-[#3c3c3c] rounded p-4 w-80"},[a("p",{staticClass:"text-[#cccccc] text-sm mb-3"},[e._v("正在 "+e._s(e.uploadProgress.isDownload?"下载":"上传")+" "+e._s(e.uploadProgress.filename))]),a("div",{staticClass:"w-full bg-[#3c3c3c] rounded-full h-2"},[a("div",{staticClass:"bg-[#0e639c] h-2 rounded-full transition-all",style:{width:e.uploadProgress.percent+"%"}})]),a("p",{staticClass:"text-[#808080] text-xs mt-2 text-center"},[e._v(e._s(e.uploadProgress.percent.toFixed(2))+"%")])])]):e._e()])},I=[function(){var t=this,e=t._self._c;return e("div",{staticClass:"flex border-b border-border"},[e("div",{staticClass:"px-4 py-2 text-xs uppercase font-bold text-white flex items-center gap-2"},[e("i",{staticClass:"fa-solid fa-folder-open text-accent"}),t._v(" 本地文件 ")])])},function(){var t=this,e=t._self._c;return e("thead",{staticClass:"sticky top-0 bg-[#252526] z-10"},[e("tr",{staticClass:"text-textMuted text-xs border-b border-[#3c3c3c]"},[e("th",{staticClass:"text-left px-3 py-1 font-medium"},[t._v("名称")]),e("th",{staticClass:"text-left px-3 py-1 w-16 font-medium"},[t._v("类型")]),e("th",{staticClass:"text-right px-3 py-1 w-20 font-medium"},[t._v("大小")]),e("th",{staticClass:"text-left px-3 py-1 w-32 font-medium"},[t._v("修改时间")])])])},function(){var t=this,e=t._self._c;return e("div",{staticClass:"px-4 py-2 text-xs uppercase font-bold text-white flex items-center gap-2"},[e("i",{staticClass:"fa-solid fa-server text-accent"}),t._v(" 梓豪远程平台 ")])},function(){var t=this,e=t._self._c;return e("thead",{staticClass:"sticky top-0 bg-[#252526] z-10"},[e("tr",{staticClass:"text-textMuted text-xs border-b border-[#3c3c3c]"},[e("th",{staticClass:"text-left px-3 py-1 font-medium"},[t._v("名称")]),e("th",{staticClass:"text-left px-3 py-1 w-16 font-medium"},[t._v("类型")]),e("th",{staticClass:"text-right px-3 py-1 w-20 font-medium"},[t._v("大小")]),e("th",{staticClass:"text-left px-3 py-1 w-32 font-medium"},[t._v("修改时间")])])])}],F=m($,M,I,!1,null,null);const T=F.exports;export{T as default};
@@ -1,4 +1,4 @@
1
- import{o as f}from"./index-D4gPOTeQ.js";/*!-----------------------------------------------------------------------------
1
+ import{o as f}from"./index-BXyZNXwi.js";/*!-----------------------------------------------------------------------------
2
2
  * Copyright (c) Microsoft Corporation. All rights reserved.
3
3
  * Version: 0.52.2(404545bded1df6ffa41ea0af4e8ddb219018c6c1)
4
4
  * Released under the MIT license
@@ -1 +1 @@
1
- import{n,h as o,i as r,j as l,G as c,a as i}from"./index-D4gPOTeQ.js";const f={name:"GitChanges",components:{GitChangesSidebar:c,DiffViewer:l,FileViewerModal:r,ConfirmDialog:o},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(){var t,e;try{const s=await i.gitIsRepo();this.isRepo=((t=s.data)==null?void 0:t.isRepo)||!1,this.gitRoot=((e=s.data)==null?void 0:e.gitRoot)||null}catch{this.isRepo=!1}},async refreshChanges(){if(this.isRepo){this.loading=!0;try{const t=await i.gitStatus();this.changes=t.data||[],this.selectedChange&&(this.changes.find(s=>s.path===this.selectedChange.path)||(this.selectedChange=null,this.diffContent=null))}catch(t){console.error("Failed to get git status:",t),this.$message.error("获取变更列表失败")}finally{this.loading=!1}}},async refresh(){await this.refreshChanges(),this.selectedChange&&await this.loadDiff(this.selectedChange)},selectChange(t){this.selectedChange=t,this.loadDiff(t)},async loadDiff(t){var e;this.diffLoading=!0,this.diffContent=null;try{const s=await i.gitDiff(t.path,t.isNew);this.diffContent=((e=s.data)==null?void 0:e.diff)||""}catch(s){console.error("Failed to get diff:",s),this.diffContent=""}finally{this.diffLoading=!1}},async openFile(t){var s;const e=this.gitRoot?`${this.gitRoot.replace(/\\/g,"/")}/${t.path}`:t.path;(s=this.$refs.fileModalRef)==null||s.open(e,t)},revertFile(t){const e=t.isNew?"delete":"revert",s=t.isNew?`确定要删除未跟踪的文件 "${t.path}" 吗?`:`确定要撤销对 "${t.path}" 的修改吗?`;this.confirmDialog={visible:!0,message:s,action:e,target:t}},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:t,target:e}=this.confirmDialog;this.confirmDialog.visible=!1;try{t==="revertAll"?(await i.gitRevertAll(),await i.gitDiscardUntracked(),this.$message.success("所有变更已撤销")):t==="revert"?(await i.gitRevert(e.path),this.$message.success("文件已撤销")):t==="delete"&&(await i.gitDeleteFile(e.path),this.$message.success("文件已删除")),await this.refreshChanges()}catch(s){console.error("Operation failed:",s),this.$message.error("操作失败: "+(s.message||"未知错误"))}},startResize(t){this.isResizing=!0,document.body.style.cursor="col-resize",document.body.style.userSelect="none"},handleResize(t){if(!this.isResizing)return;const e=t.clientX;e>=200&&e<=500&&(this.sidebarWidth=e)},stopResize(){this.isResizing=!1,document.body.style.cursor="",document.body.style.userSelect=""}}};var h=function(){var a;var e=this,s=e._self._c;return s("div",{staticClass:"flex-1 flex overflow-hidden"},[s("git-changes-sidebar",{attrs:{width:e.sidebarWidth,changes:e.changes,"selected-path":(a=e.selectedChange)==null?void 0:a.path,"is-repo":e.isRepo,loading:e.loading},on:{refresh:e.refresh,select:e.selectChange,"open-file":e.openFile,revert:e.revertFile,"revert-all":e.confirmRevertAll}}),s("div",{staticClass:"w-1 bg-border hover:bg-accent cursor-col-resize transition-colors shrink-0",on:{mousedown:e.startResize}}),s("diff-viewer",{attrs:{change:e.selectedChange,"diff-content":e.diffContent,loading:e.diffLoading},on:{"open-file":e.openFile,revert:e.revertFile}}),s("file-viewer-modal",{ref:"fileModalRef"}),s("confirm-dialog",{attrs:{visible:e.confirmDialog.visible,message:e.confirmDialog.message},on:{confirm:e.executeConfirm,cancel:e.cancelConfirm}})],1)},d=[],g=n(f,h,d,!1,null,null);const u=g.exports;export{u as default};
1
+ import{n,h as o,i as r,j as l,G as c,a as i}from"./index-BXyZNXwi.js";const f={name:"GitChanges",components:{GitChangesSidebar:c,DiffViewer:l,FileViewerModal:r,ConfirmDialog:o},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(){var t,e;try{const s=await i.gitIsRepo();this.isRepo=((t=s.data)==null?void 0:t.isRepo)||!1,this.gitRoot=((e=s.data)==null?void 0:e.gitRoot)||null}catch{this.isRepo=!1}},async refreshChanges(){if(this.isRepo){this.loading=!0;try{const t=await i.gitStatus();this.changes=t.data||[],this.selectedChange&&(this.changes.find(s=>s.path===this.selectedChange.path)||(this.selectedChange=null,this.diffContent=null))}catch(t){console.error("Failed to get git status:",t),this.$message.error("获取变更列表失败")}finally{this.loading=!1}}},async refresh(){await this.refreshChanges(),this.selectedChange&&await this.loadDiff(this.selectedChange)},selectChange(t){this.selectedChange=t,this.loadDiff(t)},async loadDiff(t){var e;this.diffLoading=!0,this.diffContent=null;try{const s=await i.gitDiff(t.path,t.isNew);this.diffContent=((e=s.data)==null?void 0:e.diff)||""}catch(s){console.error("Failed to get diff:",s),this.diffContent=""}finally{this.diffLoading=!1}},async openFile(t){var s;const e=this.gitRoot?`${this.gitRoot.replace(/\\/g,"/")}/${t.path}`:t.path;(s=this.$refs.fileModalRef)==null||s.open(e,t)},revertFile(t){const e=t.isNew?"delete":"revert",s=t.isNew?`确定要删除未跟踪的文件 "${t.path}" 吗?`:`确定要撤销对 "${t.path}" 的修改吗?`;this.confirmDialog={visible:!0,message:s,action:e,target:t}},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:t,target:e}=this.confirmDialog;this.confirmDialog.visible=!1;try{t==="revertAll"?(await i.gitRevertAll(),await i.gitDiscardUntracked(),this.$message.success("所有变更已撤销")):t==="revert"?(await i.gitRevert(e.path),this.$message.success("文件已撤销")):t==="delete"&&(await i.gitDeleteFile(e.path),this.$message.success("文件已删除")),await this.refreshChanges()}catch(s){console.error("Operation failed:",s),this.$message.error("操作失败: "+(s.message||"未知错误"))}},startResize(t){this.isResizing=!0,document.body.style.cursor="col-resize",document.body.style.userSelect="none"},handleResize(t){if(!this.isResizing)return;const e=t.clientX;e>=200&&e<=500&&(this.sidebarWidth=e)},stopResize(){this.isResizing=!1,document.body.style.cursor="",document.body.style.userSelect=""}}};var h=function(){var a;var e=this,s=e._self._c;return s("div",{staticClass:"flex-1 flex overflow-hidden"},[s("git-changes-sidebar",{attrs:{width:e.sidebarWidth,changes:e.changes,"selected-path":(a=e.selectedChange)==null?void 0:a.path,"is-repo":e.isRepo,loading:e.loading},on:{refresh:e.refresh,select:e.selectChange,"open-file":e.openFile,revert:e.revertFile,"revert-all":e.confirmRevertAll}}),s("div",{staticClass:"w-1 bg-border hover:bg-accent cursor-col-resize transition-colors shrink-0",on:{mousedown:e.startResize}}),s("diff-viewer",{attrs:{change:e.selectedChange,"diff-content":e.diffContent,loading:e.diffLoading},on:{"open-file":e.openFile,revert:e.revertFile}}),s("file-viewer-modal",{ref:"fileModalRef"}),s("confirm-dialog",{attrs:{visible:e.confirmDialog.visible,message:e.confirmDialog.message},on:{confirm:e.executeConfirm,cancel:e.cancelConfirm}})],1)},d=[],g=n(f,h,d,!1,null,null);const u=g.exports;export{u as default};
@@ -1,2 +1,2 @@
1
- import{n as r,h as d,a as n}from"./index-D4gPOTeQ.js";const f={name:"GitChangesApp",components:{ConfirmDialog:d},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:"added",label:"已添加",count:this.changes.filter(e=>e.status==="added").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==="added").length,mod:this.changes.filter(e=>e.status==="modified").length,del:this.changes.filter(e=>e.status==="deleted").length}},filteredChanges(){let e=this.changes;return this.currentTab==="modified"?e=e.filter(t=>t.status==="modified"):this.currentTab==="added"?e=e.filter(t=>t.status==="added"||t.status==="renamed"):this.currentTab==="untracked"&&(e=e.filter(t=>t.status==="untracked")),this.currentFilter==="file"?e=e.filter(t=>!t.path.endsWith("/")):this.currentFilter==="dir"&&(e=e.filter(t=>t.path.endsWith("/"))),e}},async created(){await this.checkRepo(),await this.refreshChanges()},methods:{async checkRepo(){var e,t;try{const s=await n.gitIsRepo();this.isRepo=((e=s.data)==null?void 0:e.isRepo)||!1,this.branch=((t=s.data)==null?void 0:t.branch)||""}catch{this.isRepo=!1}},async refreshChanges(){if(this.isRepo){this.loading=!0;try{const e=await n.gitStatus();this.changes=(e.data||[]).map(t=>{let s=t.status||"modified";return{...t,status:s}}),this.selectedChange&&(this.changes.find(s=>s.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){var t;this.diffLoading=!0,this.diffLines=[];try{const s=await n.gitDiff(e.path,e.isNew);this.diffLines=this.parseDiff(((t=s.data)==null?void 0:t.diff)||"")}catch(s){console.error("Failed to get diff:",s)}finally{this.diffLoading=!1}},parseDiff(e){if(!e)return[];const t=e.split(`
1
+ import{n as r,h as d,a as n}from"./index-BXyZNXwi.js";const f={name:"GitChangesApp",components:{ConfirmDialog:d},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:"added",label:"已添加",count:this.changes.filter(e=>e.status==="added").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==="added").length,mod:this.changes.filter(e=>e.status==="modified").length,del:this.changes.filter(e=>e.status==="deleted").length}},filteredChanges(){let e=this.changes;return this.currentTab==="modified"?e=e.filter(t=>t.status==="modified"):this.currentTab==="added"?e=e.filter(t=>t.status==="added"||t.status==="renamed"):this.currentTab==="untracked"&&(e=e.filter(t=>t.status==="untracked")),this.currentFilter==="file"?e=e.filter(t=>!t.path.endsWith("/")):this.currentFilter==="dir"&&(e=e.filter(t=>t.path.endsWith("/"))),e}},async created(){await this.checkRepo(),await this.refreshChanges()},methods:{async checkRepo(){var e,t;try{const s=await n.gitIsRepo();this.isRepo=((e=s.data)==null?void 0:e.isRepo)||!1,this.branch=((t=s.data)==null?void 0:t.branch)||""}catch{this.isRepo=!1}},async refreshChanges(){if(this.isRepo){this.loading=!0;try{const e=await n.gitStatus();this.changes=(e.data||[]).map(t=>{let s=t.status||"modified";return{...t,status:s}}),this.selectedChange&&(this.changes.find(s=>s.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){var t;this.diffLoading=!0,this.diffLines=[];try{const s=await n.gitDiff(e.path,e.isNew);this.diffLines=this.parseDiff(((t=s.data)==null?void 0:t.diff)||"")}catch(s){console.error("Failed to get diff:",s)}finally{this.diffLoading=!1}},parseDiff(e){if(!e)return[];const t=e.split(`
2
2
  `);let s=1,a=1;const l=[];for(const i of t)if(i.startsWith("@@")){const c=i.match(/@@ -(\d+),?\d* \+(\d+),?\d* @@/);c&&(s=parseInt(c[1]),a=parseInt(c[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:s++,sign:"-",content:i.substring(1),type:"del"}):i.startsWith("+")?l.push({lineNum:a++,sign:"+",content:i.substring(1),type:"add"}):(l.push({lineNum:s++,sign:" ",content:i,type:"context"}),a++)}return l},getStatusClass(e){return{added:"add",modified:"mod",deleted:"del",untracked:"new",renamed:"mod"}[e]||"mod"},getStatusIcon(e){return{added:"fa-solid fa-plus",modified:"fa-solid fa-pen",deleted:"fa-solid fa-trash",untracked:"fa-solid fa-star",renamed:"fa-solid fa-pen"}[e]||"fa-solid fa-pen"},getFileName(e){const t=e.split("/");return t[t.length-1]},getFilePath(e){const t=e.split("/");return t.pop(),t.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:t}=this.confirmDialog;this.confirmDialog.visible=!1;try{e==="revertAll"?(await n.gitRevertAll(),await n.gitDiscardUntracked(),this.$message.success("所有变更已撤销")):e==="revert"?(await n.gitRevert(t.path),this.$message.success("文件已撤销")):e==="delete"&&(await n.gitDeleteFile(t.path),this.$message.success("文件已删除")),await this.refreshChanges()}catch(s){console.error("Operation failed:",s),this.$message.error("操作失败: "+(s.message||"未知错误"))}},openCommit(){this.$message.info("提交功能开发中")}}};var o=function(){var t=this,s=t._self._c;return s("div",{staticClass:"git-changes-app"},[s("header",{staticClass:"header"},[t._m(0),s("span",{staticClass:"header-title"},[t._v("Git 变更")]),s("div",{staticClass:"header-actions"},[s("button",{staticClass:"header-btn",attrs:{title:"刷新"},on:{click:t.refresh}},[s("i",{staticClass:"fa-solid fa-rotate",class:{"fa-spin":t.loading}})])])]),s("div",{staticClass:"change-summary"},[s("div",{staticClass:"summary-stats"},[s("span",{staticClass:"stat-item add"},[s("i",{staticClass:"fa-solid fa-plus"}),t._v(" "+t._s(t.stats.add)+" ")]),s("span",{staticClass:"stat-item mod"},[s("i",{staticClass:"fa-solid fa-pen"}),t._v(" "+t._s(t.stats.mod)+" ")]),s("span",{staticClass:"stat-item del"},[s("i",{staticClass:"fa-solid fa-minus"}),t._v(" "+t._s(t.stats.del)+" ")])]),t.branch?s("div",{staticClass:"branch-info"},[s("i",{staticClass:"fa-solid fa-code-branch"}),s("span",[t._v(t._s(t.branch))])]):t._e()]),s("div",{staticClass:"tab-bar"},t._l(t.tabs,function(a){return s("div",{key:a.key,staticClass:"tab-item",class:{active:t.currentTab===a.key},on:{click:function(l){t.currentTab=a.key}}},[t._v(" "+t._s(a.label)),s("span",{staticClass:"count"},[t._v(t._s(a.count))])])}),0),s("div",{staticClass:"filter-bar"},t._l(t.filters,function(a){return s("div",{key:a.key,staticClass:"filter-chip",class:{active:t.currentFilter===a.key},on:{click:function(l){t.currentFilter=a.key}}},[t._v(" "+t._s(a.label)+" ")])}),0),t.isRepo?t.filteredChanges.length>0?[t.selectedChange?s("div",{ref:"diffViewRef",staticClass:"diff-view"},[s("div",{staticClass:"diff-header"},[s("i",{staticClass:"fa-solid fa-file-code"}),s("span",[t._v(t._s(t.selectedChange.path))]),s("span",{staticStyle:{"margin-left":"auto",color:"var(--accent)"},on:{click:function(a){t.selectedChange=null}}},[t._v("收起")])]),!t.diffLoading&&t.diffLines.length>0?s("div",{staticClass:"diff-content"},t._l(t.diffLines,function(a,l){return s("div",{key:l,staticClass:"diff-line",class:a.type},[s("span",{staticClass:"line-num"},[t._v(t._s(a.lineNum))]),s("span",{staticClass:"line-sign",class:a.type},[t._v(t._s(a.sign))]),s("span",{staticClass:"line-text"},[t._v(t._s(a.content))])])}),0):t._e(),t.diffLoading?s("div",{staticClass:"diff-loading"},[s("span",{staticClass:"loading-spinner"}),t._v(" 加载中... ")]):t._e()]):s("div",{ref:"fileListRef",staticClass:"file-list"},t._l(t.filteredChanges,function(a,l){var i;return s("div",{key:l,staticClass:"change-item",class:{selected:((i=t.selectedChange)==null?void 0:i.path)===a.path},on:{click:function(c){return t.selectChange(a)}}},[s("div",{staticClass:"change-status",class:t.getStatusClass(a.status)},[s("i",{class:t.getStatusIcon(a.status)})]),s("div",{staticClass:"change-info"},[s("div",{staticClass:"change-name"},[t._v(t._s(t.getFileName(a.path)))]),s("div",{staticClass:"change-path"},[t._v(t._s(t.getFilePath(a.path)))])]),a.linesAdded!==void 0||a.linesDeleted!==void 0?s("div",{staticClass:"change-stats"},[a.linesAdded?s("span",{staticClass:"add-line"},[t._v("+"+t._s(a.linesAdded))]):t._e(),a.linesAdded&&a.linesDeleted?s("span",[t._v(" / ")]):t._e(),a.linesDeleted?s("span",{staticClass:"del-line"},[t._v("-"+t._s(a.linesDeleted))]):t._e()]):t._e()])}),0)]:s("div",{staticClass:"file-list"},[t._m(2)]):s("div",{staticClass:"file-list"},[t._m(1)]),s("div",{staticClass:"bottom-actions"},[s("button",{staticClass:"action-btn secondary",attrs:{disabled:t.filteredChanges.length===0},on:{click:t.confirmRevertAll}},[s("i",{staticClass:"fa-solid fa-arrow-rotate-left"}),t._v(" 撤销全部 ")])]),s("confirm-dialog",{attrs:{visible:t.confirmDialog.visible,message:t.confirmDialog.message},on:{confirm:t.executeConfirm,cancel:t.cancelConfirm}})],2)},h=[function(){var e=this,t=e._self._c;return t("a",{staticClass:"header-back",attrs:{href:"/app"}},[t("i",{staticClass:"fa-solid fa-chevron-left"})])},function(){var e=this,t=e._self._c;return t("div",{staticClass:"empty-state"},[t("div",{staticClass:"empty-icon"},[t("i",{staticClass:"fa-solid fa-folder-open"})]),t("div",{staticClass:"empty-title"},[e._v("非 Git 仓库")]),t("div",{staticClass:"empty-desc"},[e._v("当前目录不是 Git 仓库,无法查看变更")])])},function(){var e=this,t=e._self._c;return t("div",{staticClass:"empty-state"},[t("div",{staticClass:"empty-icon"},[t("i",{staticClass:"fa-solid fa-check"})]),t("div",{staticClass:"empty-title"},[e._v("暂无变更")]),t("div",{staticClass:"empty-desc"},[e._v("工作区干净,没有检测到变更")])])}],u=r(f,o,h,!1,null,"3818a325");const g=u.exports;export{g as default};
@@ -1,4 +1,4 @@
1
- import{o as l}from"./index-D4gPOTeQ.js";/*!-----------------------------------------------------------------------------
1
+ import{o as l}from"./index-BXyZNXwi.js";/*!-----------------------------------------------------------------------------
2
2
  * Copyright (c) Microsoft Corporation. All rights reserved.
3
3
  * Version: 0.52.2(404545bded1df6ffa41ea0af4e8ddb219018c6c1)
4
4
  * Released under the MIT license
@@ -1,4 +1,4 @@
1
- import{o as s}from"./index-D4gPOTeQ.js";/*!-----------------------------------------------------------------------------
1
+ import{o as s}from"./index-BXyZNXwi.js";/*!-----------------------------------------------------------------------------
2
2
  * Copyright (c) Microsoft Corporation. All rights reserved.
3
3
  * Version: 0.52.2(404545bded1df6ffa41ea0af4e8ddb219018c6c1)
4
4
  * Released under the MIT license
@@ -1,4 +1,4 @@
1
- import{o as lt}from"./index-D4gPOTeQ.js";/*!-----------------------------------------------------------------------------
1
+ import{o as lt}from"./index-BXyZNXwi.js";/*!-----------------------------------------------------------------------------
2
2
  * Copyright (c) Microsoft Corporation. All rights reserved.
3
3
  * Version: 0.52.2(404545bded1df6ffa41ea0af4e8ddb219018c6c1)
4
4
  * Released under the MIT license