tianxincode 1.0.53 → 1.0.55

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 (82) hide show
  1. package/dist/core/ai/agents/caller/caller.agent.d.ts.map +1 -1
  2. package/dist/core/ai/agents/caller/caller.agent.js +10 -3
  3. package/dist/core/ai/agents/caller/caller.agent.js.map +1 -1
  4. package/dist/core/ai/agents/chat/chat.agent.d.ts.map +1 -1
  5. package/dist/core/ai/agents/chat/chat.agent.js +34 -32
  6. package/dist/core/ai/agents/chat/chat.agent.js.map +1 -1
  7. package/dist/core/ai/agents/code/code.agent.d.ts.map +1 -1
  8. package/dist/core/ai/agents/code/code.agent.js +14 -2
  9. package/dist/core/ai/agents/code/code.agent.js.map +1 -1
  10. package/dist/core/ai/agents/common/common.agent.d.ts.map +1 -1
  11. package/dist/core/ai/agents/common/common.agent.js +4 -2
  12. package/dist/core/ai/agents/common/common.agent.js.map +1 -1
  13. package/dist/core/ai/agents/design/design.agent.d.ts.map +1 -1
  14. package/dist/core/ai/agents/design/design.agent.js +21 -3
  15. package/dist/core/ai/agents/design/design.agent.js.map +1 -1
  16. package/dist/core/ai/agents/discuss/discuss.agent.d.ts.map +1 -1
  17. package/dist/core/ai/agents/discuss/discuss.agent.js +14 -2
  18. package/dist/core/ai/agents/discuss/discuss.agent.js.map +1 -1
  19. package/dist/core/ai/agents/discuss/prompts/role.txt +4 -0
  20. package/dist/core/ai/agents/plan/plan.agent.d.ts.map +1 -1
  21. package/dist/core/ai/agents/plan/plan.agent.js +14 -2
  22. package/dist/core/ai/agents/plan/plan.agent.js.map +1 -1
  23. package/dist/core/ai/agents/task/task.agent.d.ts.map +1 -1
  24. package/dist/core/ai/agents/task/task.agent.js +34 -32
  25. package/dist/core/ai/agents/task/task.agent.js.map +1 -1
  26. package/dist/core/ai/helpers/abort.helper.d.ts +5 -0
  27. package/dist/core/ai/helpers/abort.helper.d.ts.map +1 -0
  28. package/dist/core/ai/helpers/abort.helper.js +16 -0
  29. package/dist/core/ai/helpers/abort.helper.js.map +1 -0
  30. package/dist/core/ai/provider/base.d.ts +1 -0
  31. package/dist/core/ai/provider/base.d.ts.map +1 -1
  32. package/dist/core/tools/provider/grep.d.ts.map +1 -1
  33. package/dist/core/tools/provider/grep.js +144 -57
  34. package/dist/core/tools/provider/grep.js.map +1 -1
  35. package/dist/index.js +2 -0
  36. package/dist/index.js.map +1 -1
  37. package/dist/services/callerChat/callerChat.service.d.ts.map +1 -1
  38. package/dist/services/callerChat/callerChat.service.js +13 -8
  39. package/dist/services/callerChat/callerChat.service.js.map +1 -1
  40. package/dist/services/codeChat/codeChat.service.d.ts.map +1 -1
  41. package/dist/services/codeChat/codeChat.service.js +13 -8
  42. package/dist/services/codeChat/codeChat.service.js.map +1 -1
  43. package/package.json +1 -1
  44. package/test_tool_notify.py +72 -0
  45. package/web/dist/assets/{PcLayout-ZXjT7WP9.js → PcLayout-VYsyVBrJ.js} +1 -1
  46. package/web/dist/assets/{aiLogsView-B1Xv86FO.js → aiLogsView-CjK-4w6L.js} +1 -1
  47. package/web/dist/assets/{cssMode-BFNigYrU.js → cssMode-Bz3_SIxu.js} +1 -1
  48. package/web/dist/assets/{customActionsView-BFZzvWXk.js → customActionsView-DxcLN9fW.js} +1 -1
  49. package/web/dist/assets/{deployView-BV8JVWE5.js → deployView-oEXnY-wu.js} +1 -1
  50. package/web/dist/assets/designView-DVXodexG.js +18 -0
  51. package/web/dist/assets/designView-nhuIbLbR.css +1 -0
  52. package/web/dist/assets/devWorkflowView-BPZbuxwY.js +36 -0
  53. package/web/dist/assets/devWorkflowView-D3m_4wV_.css +1 -0
  54. package/web/dist/assets/{devWorkflowViewApp-394d9AlG.js → devWorkflowViewApp-cs-d7Rc9.js} +1 -1
  55. package/web/dist/assets/{fileZihao-Chayeahb.js → fileZihao-Csc-Faj1.js} +1 -1
  56. package/web/dist/assets/{freemarker2-ByywVFhB.js → freemarker2-B3WSvyrT.js} +1 -1
  57. package/web/dist/assets/{gitChanges-Bcc9Ioc7.js → gitChanges-DUyN3wIN.js} +1 -1
  58. package/web/dist/assets/{gitChangesApp-CRVkFMef.js → gitChangesApp-CN9CHcC3.js} +1 -1
  59. package/web/dist/assets/{handlebars-D-MvnLHF.js → handlebars-mTMeC4Oc.js} +1 -1
  60. package/web/dist/assets/{html-D5CJVQpa.js → html-WUa4rZYN.js} +1 -1
  61. package/web/dist/assets/{htmlMode-DaRvRPXz.js → htmlMode-COIW7lYT.js} +1 -1
  62. package/web/dist/assets/{index-BXyZNXwi.js → index-B6eYD1o1.js} +11 -11
  63. package/web/dist/assets/{index-BkRJ6vX6.css → index-BBSf9cWO.css} +1 -1
  64. package/web/dist/assets/{javascript-qiZQrKCd.js → javascript-D9FoZIU1.js} +1 -1
  65. package/web/dist/assets/{jsonMode-BNOK_Lb2.js → jsonMode-6Z6qatea.js} +1 -1
  66. package/web/dist/assets/{liquid-Cn4Vm_pv.js → liquid-3352HGaR.js} +1 -1
  67. package/web/dist/assets/{mdx-BZzvCzBz.js → mdx-BPNckn7l.js} +1 -1
  68. package/web/dist/assets/{mediaChat-Cb8y-RVH.js → mediaChat-DPuTKoES.js} +1 -1
  69. package/web/dist/assets/{python-BLKhgdt7.js → python-DQiiQ2Vy.js} +1 -1
  70. package/web/dist/assets/{razor-DAh-8Vt3.js → razor-dq-vvWcQ.js} +1 -1
  71. package/web/dist/assets/{taskView-CJ1d1bfR.js → taskView-DMExluwY.js} +1 -1
  72. package/web/dist/assets/{terminalView-0Gixm1yH.js → terminalView-M3q2Crff.js} +1 -1
  73. package/web/dist/assets/{tsMode-Ctez2MnL.js → tsMode-B6syUqLO.js} +1 -1
  74. package/web/dist/assets/{typescript-uKzlDE9T.js → typescript-Bg5dJUAo.js} +1 -1
  75. package/web/dist/assets/{wikiView-BAnnCorX.js → wikiView-DLEBqcbo.js} +1 -1
  76. package/web/dist/assets/{xml-1Z_L4vw8.js → xml-ugV0sfBz.js} +1 -1
  77. package/web/dist/assets/{yaml-Cf9kIOyW.js → yaml-JrfRlZkP.js} +1 -1
  78. package/web/dist/index.html +2 -2
  79. package/web/dist/assets/designView-BjjT_eB5.css +0 -1
  80. package/web/dist/assets/designView-_qXRJlPw.js +0 -18
  81. package/web/dist/assets/devWorkflowView-CPJuckoU.js +0 -36
  82. package/web/dist/assets/devWorkflowView-TXy6mQ6E.css +0 -1
@@ -1 +1 @@
1
- import{n as c,a as d,e as _,K as m,d as y,R as v,g}from"./index-BXyZNXwi.js";const C="/api";async function h(s,t,e=null,a=!1){const n={method:s,headers:a?{}:{"Content-Type":"application/json"}};e&&s!=="GET"&&(n.body=a?e:JSON.stringify(e));const i=await(await fetch(`${C}${t}`,n)).json();if(i.success===!1)throw new Error(i.error||i.message||"请求失败");return i}const p={checkRelease(s){const t=s?`?projectPath=${encodeURIComponent(s)}`:"";return h("GET",`/deploy/check-release${t}`)},downloadUrl(s,t){return h("POST","/deploy/download-url",{url:s,projectPath:t})},async uploadArchive(s,t){const e=new FormData;return e.append("file",s),t&&e.append("projectPath",t),h("POST","/deploy/upload-archive",e,!0)}},w={name:"DeployEditor",props:{content:{type:String,default:""},filePath:{type:String,default:""}},data(){return{editor:null,saved:!0}},computed:{displayPath(){return this.filePath||"RELEASE.md"}},watch:{content(s){this.editor&&s!==this.editor.getValue()&&(this.editor.setValue(s),this.saved=!0)}},mounted(){this.$nextTick(()=>this.initEditor())},beforeDestroy(){this.editor&&(this.editor.dispose(),this.editor=null)},methods:{initEditor(){this.editor||(this.editor=_.create(this.$refs.editorContainer,{value:this.content||"",language:"markdown",theme:"vs-dark",fontSize:14,fontFamily:"ui-monospace, SFMono-Regular, 'JetBrains Mono', Menlo, Monaco, Consolas, monospace",minimap:{enabled:!1},lineNumbers:"on",wordWrap:"on",scrollBeyondLastLine:!1,automaticLayout:!0,padding:{top:16}}),this.editor.addCommand(m.CtrlCmd|y.KeyS,()=>{this.save()}),this.editor.onDidChangeModelContent(()=>{this.saved=!1,this.$emit("content-change",this.editor.getValue())}))},getContent(){return this.editor?this.editor.getValue():this.content},async save(){if(!this.editor||!this.filePath)return;const s=this.editor.getValue();try{await d.writeFile(this.filePath,s),this.saved=!0,this.$emit("saved",s)}catch(t){this.$message.error("保存失败: "+t.message)}}}};var b=function(){var t=this,e=t._self._c;return e("div",{staticClass:"editor-panel"},[e("div",{staticClass:"editor-header"},[e("i",{staticClass:"fa-solid fa-file-lines"}),e("span",[t._v(t._s(t.displayPath))]),e("span",{staticClass:"save-status",class:t.saved?"saved":""},[t._v(" "+t._s(t.saved?"已保存":"未保存")+" ")])]),e("div",{ref:"editorContainer",staticClass:"editor-container"})])},k=[],S=c(w,b,k,!1,null,"6615be35");const x=S.exports,M={name:"DeployAssistant",components:{ResizableTextarea:v},props:{hasContent:{type:Boolean,default:!1},docContent:{type:String,default:""},projectPath:{type:String,default:""},releasePath:{type:String,default:""}},data(){return{ws:null,sessionId:"",inputMessage:"",messages:[],disabled:!1,stopping:!1,modelName:"",promptTokens:0,sessionStatus:"idle",heartbeatTimer:null}},computed:{displaySessionId(){return this.sessionId?this.sessionId.slice(0,8):"--------"}},async mounted(){const s=await this.loadSavedSession();s&&(this.sessionId=s),this.connect()},beforeDestroy(){this.disconnect(),this.heartbeatTimer&&clearInterval(this.heartbeatTimer)},methods:{connect(){const t=`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/ws/caller`;this.ws=new WebSocket(t),this.ws.onopen=()=>{this.sessionId||(this.sessionId="deploy-"+Date.now()+"-"+Math.random().toString(36).slice(2,8)),this.ws.send(JSON.stringify({type:"init",data:{callbackUrl:"http://localhost:40000",projectPath:this.projectPath||"",tools:[],sessionId:this.sessionId,title:"部署助手"}})),this.heartbeatTimer=setInterval(()=>{this.ws&&this.ws.readyState===WebSocket.OPEN&&this.ws.send(JSON.stringify({type:"ping"}))},3e4)},this.ws.onmessage=e=>{try{const a=JSON.parse(e.data);this.handleMessage(a)}catch(a){console.error("Parse WS message error:",a)}},this.ws.onclose=()=>{this.sessionStatus="idle",this.disabled=!1,this.heartbeatTimer&&clearInterval(this.heartbeatTimer)},this.ws.onerror=e=>{console.error("WS error:",e),this.sessionStatus="idle",this.disabled=!1}},disconnect(){this.heartbeatTimer&&(clearInterval(this.heartbeatTimer),this.heartbeatTimer=null),this.ws&&(this.ws.close(),this.ws=null)},handleMessage(s){var t,e,a,n,o,i,r,l,u,f;switch(s.type){case"connected":break;case"init_ready":this.sessionId=((t=s.data)==null?void 0:t.sessionId)||this.sessionId,this.saveSessionId(this.sessionId),this.loadHistoryMessages();break;case"step":this.messages.push({type:"step",thought:(e=s.data)==null?void 0:e.thought,toolCalls:((a=s.data)==null?void 0:a.toolCalls)||[],success:(n=s.data)==null?void 0:n.success}),(i=(o=s.data)==null?void 0:o.usage)!=null&&i.promptTokens&&(this.promptTokens=s.data.usage.promptTokens),this.scrollToBottom();break;case"done":this.disabled=!1,this.stopping=!1,this.sessionStatus="completed",this.messages.push({type:"done",content:((r=s.data)==null?void 0:r.response)||""}),(l=s.data)!=null&&l.modelName&&(this.modelName=s.data.modelName),(f=(u=s.data)==null?void 0:u.usage)!=null&&f.promptTokens&&(this.promptTokens=s.data.usage.promptTokens),this.scrollToBottom();break;case"error":this.disabled=!1,this.stopping=!1,this.sessionStatus="idle",this.messages.push({type:"error",content:s.error||"发生错误"}),this.scrollToBottom();break}},sendMessage(s){s&&s.preventDefault();const t=this.inputMessage.trim();!t||this.disabled||!this.ws||(this.messages.push({type:"user",content:t}),this.inputMessage="",this.disabled=!0,this.stopping=!1,this.sessionStatus="processing",this.ws.send(JSON.stringify({type:"chat",data:{sessionId:this.sessionId,message:t}})),this.scrollToBottom())},deployByDoc(){this.disabled||(this.inputMessage=`请按 ${this.releasePath} 文档进行部署`)},stopChat(){!this.sessionId||this.stopping||!this.ws||(this.stopping=!0,this.ws.send(JSON.stringify({type:"stop",data:{sessionId:this.sessionId}})))},handleKeydown(s){if(s.key==="Enter"){if(s.ctrlKey)return;s.preventDefault(),this.sendMessage()}},scrollToBottom(){this.$nextTick(()=>{const s=this.$refs.messagesContainer;s&&(s.scrollTop=s.scrollHeight)})},async loadSavedSession(){var s;if(!this.projectPath)return null;try{const t=`${this.projectPath}/.txcode/release/deploy.json`,e=await d.getFileContent(t);if((s=e==null?void 0:e.data)!=null&&s.content)return JSON.parse(e.data.content).sessionId||null}catch{}return null},async saveSessionId(s){if(this.projectPath)try{const t=`${this.projectPath}/.txcode/release/deploy.json`;await d.writeFile(t,JSON.stringify({sessionId:s},null,2))}catch(t){console.error("保存 sessionId 失败:",t)}},async loadHistoryMessages(){if(this.sessionId)try{const s=await d.getMessages(this.sessionId),t=(s==null?void 0:s.data)||[];t.length>0&&(this.messages=t.map(e=>e.type==="chat"&&e.role==="user"?{type:"user",content:e.content}:e.role==="assistant"?{type:"done",content:e.content}:e))}catch(s){console.error("加载历史消息失败:",s)}},renderMarkdown(s){return s?g(s):""},formatArgs(s,t){try{const e=JSON.parse(t);return s==="bash"||s==="execute_bash"?e.command+(e.workdir?` (${e.workdir})`:""):s==="read_file"?e.file_path+(e.offset?`:${e.offset}`:""):s==="edit_file"||s==="write_file"?e.file_path:s==="glob"?e.pattern:s==="grep"?`"${e.pattern}"`:t}catch{return t}}}};var P=function(){var t=this,e=t._self._c;return e("div",{staticClass:"chat-panel"},[t._m(0),e("div",{ref:"messagesContainer",staticClass:"chat-messages"},[t.messages.length?t._e():e("div",{staticClass:"empty-state"},[e("i",{staticClass:"fa-solid fa-rocket text-3xl text-textMuted opacity-30 mb-4"}),e("p",[t._v('点击"按部署文档部署"开始自动化部署')])]),t._l(t.messages,function(a,n){return[a.type==="user"?e("div",{staticClass:"user-message"},[t._v(" "+t._s(a.content)+" ")]):a.type==="step"?e("div",{staticClass:"ai-step"},[a.thought?e("div",{staticClass:"ai-thought",domProps:{innerHTML:t._s(t.renderMarkdown(a.thought))}}):t._e(),t._l(a.toolCalls,function(o,i){var r,l;return e("div",{key:i,staticClass:"log-mute"},[e("span",{class:a.success!==!1?"tool-success":"tool-fail"},[t._v(" "+t._s(a.success!==!1?"✓":"✗")+" ")]),t._v(" "+t._s(((r=o.function)==null?void 0:r.name)||"")+" "),(l=o.function)!=null&&l.arguments?e("span",{staticClass:"tool-input"},[t._v(" "+t._s(t.formatArgs(o.function.name,o.function.arguments))+" ")]):t._e()])})],2):a.type==="done"?e("div",{staticClass:"ai-done",domProps:{innerHTML:t._s(t.renderMarkdown(a.content))}}):a.type==="error"?e("div",{staticClass:"ai-error"},[t._v(" "+t._s(a.content)+" ")]):t._e()]}),t.modelName?e("div",{staticClass:"build-info"},[e("span",[t._v("▣")]),t._v(" Build · "+t._s(t.modelName)+" ")]):t._e()],2),e("div",{staticClass:"chat-input-area"},[e("div",{staticClass:"input-row"},[e("ResizableTextarea",{staticClass:"input-area",attrs:{rows:5,"min-rows":2,"max-rows":15,placeholder:"输入消息... (Enter 发送, Ctrl+Enter 换行)",disabled:t.disabled&&!t.stopping},nativeOn:{keydown:function(a){return!a.type.indexOf("key")&&t._k(a.keyCode,"enter",13,a.key,"Enter")?null:t.handleKeydown.apply(null,arguments)}},model:{value:t.inputMessage,callback:function(a){t.inputMessage=a},expression:"inputMessage"}}),e("div",{staticClass:"input-actions"},[t.disabled&&!t.stopping?e("el-button",{attrs:{type:"danger",size:"small"},on:{click:t.stopChat}},[t._v(" ■ 停止 ")]):t.stopping?e("el-button",{attrs:{type:"info",disabled:"",size:"small"}},[t._v(" 停止中... ")]):e("el-button",{attrs:{type:"default",disabled:!t.inputMessage.trim()||t.disabled,size:"small"},on:{click:t.sendMessage}},[t._v(" 发送 ")])],1)],1),e("div",{staticClass:"deploy-doc-link",on:{click:t.deployByDoc}},[e("i",{staticClass:"fa-solid fa-file-arrow-up"}),t._v(" 按部署文档部署 ")])]),e("div",{staticClass:"status-bar"},[e("span",{class:t.sessionStatus==="processing"?"status-thinking":"status-ready"},[t.sessionStatus==="processing"?e("span",{staticClass:"thinking-spinner"}):t._e(),t._v(" "+t._s(t.sessionStatus==="processing"?"思考中":"✓ 就绪")+" ")]),e("span",{staticClass:"separator"},[t._v("|")]),e("span",[t._v("模型:"+t._s(t.modelName||"-"))]),e("span",{staticClass:"separator"},[t._v("|")]),e("span",[t._v("会话:"+t._s(t.displaySessionId))]),e("span",{staticClass:"separator"},[t._v("|")]),e("span",[t._v("token:"+t._s(t.promptTokens))])])])},T=[function(){var s=this,t=s._self._c;return t("div",{staticClass:"panel-header"},[t("span",[t("i",{staticClass:"fa-solid fa-robot"}),s._v(" AI 部署助手")])])}],I=c(M,P,T,!1,null,"58b0f9d9");const $=I.exports,j={name:"DeployImport",props:{projectPath:{type:String,default:""}},data(){return{downloadUrl:"",downloading:!1,fileList:[],statusMessage:"",statusType:"info"}},methods:{async handleDownload(){if(this.downloadUrl.trim()){this.downloading=!0,this.statusMessage="";try{const s=await p.downloadUrl(this.downloadUrl.trim(),this.projectPath);this.statusMessage="部署文档已导入成功!",this.statusType="success",this.$emit("imported",s.data)}catch(s){this.statusMessage="下载失败: "+s.message,this.statusType="error"}finally{this.downloading=!1}}},async handleFileChange(s){this.statusMessage="";try{const t=await p.uploadArchive(s.raw,this.projectPath);this.statusMessage="部署文档已导入成功!",this.statusType="success",this.fileList=[],this.$emit("imported",t.data)}catch(t){this.statusMessage="上传失败: "+t.message,this.statusType="error"}}}};var E=function(){var t=this,e=t._self._c;return e("div",{staticClass:"deploy-import"},[e("div",{staticClass:"import-container"},[t._m(0),e("h2",{staticClass:"text-xl font-bold text-white mb-2"},[t._v("未找到部署文档")]),e("p",{staticClass:"text-textMuted mb-8"},[t._v("请导入部署文档到 .txcode/release/ 目录")]),e("div",{staticClass:"import-card"},[t._m(1),e("div",{staticClass:"import-card-body"},[e("div",{staticClass:"flex gap-2"},[e("el-input",{staticClass:"flex-1",attrs:{placeholder:"https://...",disabled:t.downloading},model:{value:t.downloadUrl,callback:function(a){t.downloadUrl=a},expression:"downloadUrl"}}),e("el-button",{attrs:{type:"primary",loading:t.downloading,disabled:!t.downloadUrl.trim()},on:{click:t.handleDownload}},[t._v(" "+t._s(t.downloading?"下载中...":"下载")+" ")])],1)])]),t._m(2),e("div",{staticClass:"import-card"},[t._m(3),e("div",{staticClass:"import-card-body"},[e("el-upload",{attrs:{drag:"","auto-upload":!1,"show-file-list":!0,accept:".tar.gz,.tgz,.zip","on-change":t.handleFileChange,"file-list":t.fileList,limit:1}},[e("i",{staticClass:"el-icon-upload"}),e("div",{staticClass:"el-upload__text"},[t._v("将 tar.gz / zip 文件拖到此处,或"),e("em",[t._v("点击上传")])]),e("div",{staticClass:"el-upload__tip",attrs:{slot:"tip"},slot:"tip"},[t._v("上传后自动解压到 .txcode/release/ 目录")])])],1)]),t.statusMessage?e("div",{staticClass:"import-status",class:t.statusType},[t._v(" "+t._s(t.statusMessage)+" ")]):t._e()])])},D=[function(){var s=this,t=s._self._c;return t("div",{staticClass:"import-icon"},[t("i",{staticClass:"fa-solid fa-cloud-arrow-down text-5xl text-textMuted opacity-50"})])},function(){var s=this,t=s._self._c;return t("div",{staticClass:"import-card-title"},[t("i",{staticClass:"fa-solid fa-link"}),s._v(" 输入链接下载部署文档 ")])},function(){var s=this,t=s._self._c;return t("div",{staticClass:"import-divider"},[t("span",[s._v("—— 或 ——")])])},function(){var s=this,t=s._self._c;return t("div",{staticClass:"import-card-title"},[t("i",{staticClass:"fa-solid fa-upload"}),s._v(" 选择压缩包上传(tar.gz / zip) ")])}],N=c(j,E,D,!1,null,"0cc389d3");const R=N.exports,z={name:"deployView",components:{DeployEditor:x,DeployAssistant:$,DeployImport:R},data(){return{loading:!0,releaseExists:!1,releaseContent:"",releasePath:"",editorContent:"",projectPath:""}},async mounted(){await this.loadProjectPath(),await this.checkRelease()},methods:{async loadProjectPath(){try{const s=await d.getCurrentProject();s.data&&s.data.path&&(this.projectPath=s.data.path)}catch(s){console.error("获取项目路径失败:",s)}},async checkRelease(){this.loading=!0;try{const s=await p.checkRelease(this.projectPath);s.data&&s.data.exists?(this.releaseExists=!0,this.releaseContent=s.data.content||"",this.editorContent=this.releaseContent,this.releasePath=s.data.path||""):this.releaseExists=!1}catch(s){console.error("检查部署文档失败:",s),this.releaseExists=!1}finally{this.loading=!1}},onContentChange(s){this.editorContent=s},onImported(){this.checkRelease()}}};var O=function(){var t=this,e=t._self._c;return e("div",{staticClass:"deploy-container"},[t.loading?e("div",{staticClass:"loading-state"},[e("i",{staticClass:"fa-solid fa-spinner fa-spin text-2xl text-textMuted"})]):t.releaseExists?[e("div",{staticClass:"deploy-main"},[e("DeployEditor",{ref:"editorRef",attrs:{content:t.releaseContent,"file-path":t.releasePath},on:{"content-change":t.onContentChange}}),e("DeployAssistant",{ref:"assistantRef",attrs:{"has-content":!!t.editorContent,"doc-content":t.editorContent,"project-path":t.projectPath,"release-path":t.releasePath}})],1)]:[e("DeployImport",{attrs:{"project-path":t.projectPath},on:{imported:t.onImported}})]],2)},A=[],B=c(z,O,A,!1,null,"a81ff1a6");const U=B.exports;export{U as default};
1
+ import{n as c,a as d,e as _,K as m,d as y,R as v,g}from"./index-B6eYD1o1.js";const C="/api";async function h(s,t,e=null,a=!1){const n={method:s,headers:a?{}:{"Content-Type":"application/json"}};e&&s!=="GET"&&(n.body=a?e:JSON.stringify(e));const i=await(await fetch(`${C}${t}`,n)).json();if(i.success===!1)throw new Error(i.error||i.message||"请求失败");return i}const p={checkRelease(s){const t=s?`?projectPath=${encodeURIComponent(s)}`:"";return h("GET",`/deploy/check-release${t}`)},downloadUrl(s,t){return h("POST","/deploy/download-url",{url:s,projectPath:t})},async uploadArchive(s,t){const e=new FormData;return e.append("file",s),t&&e.append("projectPath",t),h("POST","/deploy/upload-archive",e,!0)}},w={name:"DeployEditor",props:{content:{type:String,default:""},filePath:{type:String,default:""}},data(){return{editor:null,saved:!0}},computed:{displayPath(){return this.filePath||"RELEASE.md"}},watch:{content(s){this.editor&&s!==this.editor.getValue()&&(this.editor.setValue(s),this.saved=!0)}},mounted(){this.$nextTick(()=>this.initEditor())},beforeDestroy(){this.editor&&(this.editor.dispose(),this.editor=null)},methods:{initEditor(){this.editor||(this.editor=_.create(this.$refs.editorContainer,{value:this.content||"",language:"markdown",theme:"vs-dark",fontSize:14,fontFamily:"ui-monospace, SFMono-Regular, 'JetBrains Mono', Menlo, Monaco, Consolas, monospace",minimap:{enabled:!1},lineNumbers:"on",wordWrap:"on",scrollBeyondLastLine:!1,automaticLayout:!0,padding:{top:16}}),this.editor.addCommand(m.CtrlCmd|y.KeyS,()=>{this.save()}),this.editor.onDidChangeModelContent(()=>{this.saved=!1,this.$emit("content-change",this.editor.getValue())}))},getContent(){return this.editor?this.editor.getValue():this.content},async save(){if(!this.editor||!this.filePath)return;const s=this.editor.getValue();try{await d.writeFile(this.filePath,s),this.saved=!0,this.$emit("saved",s)}catch(t){this.$message.error("保存失败: "+t.message)}}}};var b=function(){var t=this,e=t._self._c;return e("div",{staticClass:"editor-panel"},[e("div",{staticClass:"editor-header"},[e("i",{staticClass:"fa-solid fa-file-lines"}),e("span",[t._v(t._s(t.displayPath))]),e("span",{staticClass:"save-status",class:t.saved?"saved":""},[t._v(" "+t._s(t.saved?"已保存":"未保存")+" ")])]),e("div",{ref:"editorContainer",staticClass:"editor-container"})])},k=[],S=c(w,b,k,!1,null,"6615be35");const x=S.exports,M={name:"DeployAssistant",components:{ResizableTextarea:v},props:{hasContent:{type:Boolean,default:!1},docContent:{type:String,default:""},projectPath:{type:String,default:""},releasePath:{type:String,default:""}},data(){return{ws:null,sessionId:"",inputMessage:"",messages:[],disabled:!1,stopping:!1,modelName:"",promptTokens:0,sessionStatus:"idle",heartbeatTimer:null}},computed:{displaySessionId(){return this.sessionId?this.sessionId.slice(0,8):"--------"}},async mounted(){const s=await this.loadSavedSession();s&&(this.sessionId=s),this.connect()},beforeDestroy(){this.disconnect(),this.heartbeatTimer&&clearInterval(this.heartbeatTimer)},methods:{connect(){const t=`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/ws/caller`;this.ws=new WebSocket(t),this.ws.onopen=()=>{this.sessionId||(this.sessionId="deploy-"+Date.now()+"-"+Math.random().toString(36).slice(2,8)),this.ws.send(JSON.stringify({type:"init",data:{callbackUrl:"http://localhost:40000",projectPath:this.projectPath||"",tools:[],sessionId:this.sessionId,title:"部署助手"}})),this.heartbeatTimer=setInterval(()=>{this.ws&&this.ws.readyState===WebSocket.OPEN&&this.ws.send(JSON.stringify({type:"ping"}))},3e4)},this.ws.onmessage=e=>{try{const a=JSON.parse(e.data);this.handleMessage(a)}catch(a){console.error("Parse WS message error:",a)}},this.ws.onclose=()=>{this.sessionStatus="idle",this.disabled=!1,this.heartbeatTimer&&clearInterval(this.heartbeatTimer)},this.ws.onerror=e=>{console.error("WS error:",e),this.sessionStatus="idle",this.disabled=!1}},disconnect(){this.heartbeatTimer&&(clearInterval(this.heartbeatTimer),this.heartbeatTimer=null),this.ws&&(this.ws.close(),this.ws=null)},handleMessage(s){var t,e,a,n,o,i,r,l,u,f;switch(s.type){case"connected":break;case"init_ready":this.sessionId=((t=s.data)==null?void 0:t.sessionId)||this.sessionId,this.saveSessionId(this.sessionId),this.loadHistoryMessages();break;case"step":this.messages.push({type:"step",thought:(e=s.data)==null?void 0:e.thought,toolCalls:((a=s.data)==null?void 0:a.toolCalls)||[],success:(n=s.data)==null?void 0:n.success}),(i=(o=s.data)==null?void 0:o.usage)!=null&&i.promptTokens&&(this.promptTokens=s.data.usage.promptTokens),this.scrollToBottom();break;case"done":this.disabled=!1,this.stopping=!1,this.sessionStatus="completed",this.messages.push({type:"done",content:((r=s.data)==null?void 0:r.response)||""}),(l=s.data)!=null&&l.modelName&&(this.modelName=s.data.modelName),(f=(u=s.data)==null?void 0:u.usage)!=null&&f.promptTokens&&(this.promptTokens=s.data.usage.promptTokens),this.scrollToBottom();break;case"error":this.disabled=!1,this.stopping=!1,this.sessionStatus="idle",this.messages.push({type:"error",content:s.error||"发生错误"}),this.scrollToBottom();break}},sendMessage(s){s&&s.preventDefault();const t=this.inputMessage.trim();!t||this.disabled||!this.ws||(this.messages.push({type:"user",content:t}),this.inputMessage="",this.disabled=!0,this.stopping=!1,this.sessionStatus="processing",this.ws.send(JSON.stringify({type:"chat",data:{sessionId:this.sessionId,message:t}})),this.scrollToBottom())},deployByDoc(){this.disabled||(this.inputMessage=`请按 ${this.releasePath} 文档进行部署`)},stopChat(){!this.sessionId||this.stopping||!this.ws||(this.stopping=!0,this.ws.send(JSON.stringify({type:"stop",data:{sessionId:this.sessionId}})))},handleKeydown(s){if(s.key==="Enter"){if(s.ctrlKey)return;s.preventDefault(),this.sendMessage()}},scrollToBottom(){this.$nextTick(()=>{const s=this.$refs.messagesContainer;s&&(s.scrollTop=s.scrollHeight)})},async loadSavedSession(){var s;if(!this.projectPath)return null;try{const t=`${this.projectPath}/.txcode/release/deploy.json`,e=await d.getFileContent(t);if((s=e==null?void 0:e.data)!=null&&s.content)return JSON.parse(e.data.content).sessionId||null}catch{}return null},async saveSessionId(s){if(this.projectPath)try{const t=`${this.projectPath}/.txcode/release/deploy.json`;await d.writeFile(t,JSON.stringify({sessionId:s},null,2))}catch(t){console.error("保存 sessionId 失败:",t)}},async loadHistoryMessages(){if(this.sessionId)try{const s=await d.getMessages(this.sessionId),t=(s==null?void 0:s.data)||[];t.length>0&&(this.messages=t.map(e=>e.type==="chat"&&e.role==="user"?{type:"user",content:e.content}:e.role==="assistant"?{type:"done",content:e.content}:e))}catch(s){console.error("加载历史消息失败:",s)}},renderMarkdown(s){return s?g(s):""},formatArgs(s,t){try{const e=JSON.parse(t);return s==="bash"||s==="execute_bash"?e.command+(e.workdir?` (${e.workdir})`:""):s==="read_file"?e.file_path+(e.offset?`:${e.offset}`:""):s==="edit_file"||s==="write_file"?e.file_path:s==="glob"?e.pattern:s==="grep"?`"${e.pattern}"`:t}catch{return t}}}};var P=function(){var t=this,e=t._self._c;return e("div",{staticClass:"chat-panel"},[t._m(0),e("div",{ref:"messagesContainer",staticClass:"chat-messages"},[t.messages.length?t._e():e("div",{staticClass:"empty-state"},[e("i",{staticClass:"fa-solid fa-rocket text-3xl text-textMuted opacity-30 mb-4"}),e("p",[t._v('点击"按部署文档部署"开始自动化部署')])]),t._l(t.messages,function(a,n){return[a.type==="user"?e("div",{staticClass:"user-message"},[t._v(" "+t._s(a.content)+" ")]):a.type==="step"?e("div",{staticClass:"ai-step"},[a.thought?e("div",{staticClass:"ai-thought",domProps:{innerHTML:t._s(t.renderMarkdown(a.thought))}}):t._e(),t._l(a.toolCalls,function(o,i){var r,l;return e("div",{key:i,staticClass:"log-mute"},[e("span",{class:a.success!==!1?"tool-success":"tool-fail"},[t._v(" "+t._s(a.success!==!1?"✓":"✗")+" ")]),t._v(" "+t._s(((r=o.function)==null?void 0:r.name)||"")+" "),(l=o.function)!=null&&l.arguments?e("span",{staticClass:"tool-input"},[t._v(" "+t._s(t.formatArgs(o.function.name,o.function.arguments))+" ")]):t._e()])})],2):a.type==="done"?e("div",{staticClass:"ai-done",domProps:{innerHTML:t._s(t.renderMarkdown(a.content))}}):a.type==="error"?e("div",{staticClass:"ai-error"},[t._v(" "+t._s(a.content)+" ")]):t._e()]}),t.modelName?e("div",{staticClass:"build-info"},[e("span",[t._v("▣")]),t._v(" Build · "+t._s(t.modelName)+" ")]):t._e()],2),e("div",{staticClass:"chat-input-area"},[e("div",{staticClass:"input-row"},[e("ResizableTextarea",{staticClass:"input-area",attrs:{rows:5,"min-rows":2,"max-rows":15,placeholder:"输入消息... (Enter 发送, Ctrl+Enter 换行)",disabled:t.disabled&&!t.stopping},nativeOn:{keydown:function(a){return!a.type.indexOf("key")&&t._k(a.keyCode,"enter",13,a.key,"Enter")?null:t.handleKeydown.apply(null,arguments)}},model:{value:t.inputMessage,callback:function(a){t.inputMessage=a},expression:"inputMessage"}}),e("div",{staticClass:"input-actions"},[t.disabled&&!t.stopping?e("el-button",{attrs:{type:"danger",size:"small"},on:{click:t.stopChat}},[t._v(" ■ 停止 ")]):t.stopping?e("el-button",{attrs:{type:"info",disabled:"",size:"small"}},[t._v(" 停止中... ")]):e("el-button",{attrs:{type:"default",disabled:!t.inputMessage.trim()||t.disabled,size:"small"},on:{click:t.sendMessage}},[t._v(" 发送 ")])],1)],1),e("div",{staticClass:"deploy-doc-link",on:{click:t.deployByDoc}},[e("i",{staticClass:"fa-solid fa-file-arrow-up"}),t._v(" 按部署文档部署 ")])]),e("div",{staticClass:"status-bar"},[e("span",{class:t.sessionStatus==="processing"?"status-thinking":"status-ready"},[t.sessionStatus==="processing"?e("span",{staticClass:"thinking-spinner"}):t._e(),t._v(" "+t._s(t.sessionStatus==="processing"?"思考中":"✓ 就绪")+" ")]),e("span",{staticClass:"separator"},[t._v("|")]),e("span",[t._v("模型:"+t._s(t.modelName||"-"))]),e("span",{staticClass:"separator"},[t._v("|")]),e("span",[t._v("会话:"+t._s(t.displaySessionId))]),e("span",{staticClass:"separator"},[t._v("|")]),e("span",[t._v("token:"+t._s(t.promptTokens))])])])},T=[function(){var s=this,t=s._self._c;return t("div",{staticClass:"panel-header"},[t("span",[t("i",{staticClass:"fa-solid fa-robot"}),s._v(" AI 部署助手")])])}],I=c(M,P,T,!1,null,"58b0f9d9");const $=I.exports,j={name:"DeployImport",props:{projectPath:{type:String,default:""}},data(){return{downloadUrl:"",downloading:!1,fileList:[],statusMessage:"",statusType:"info"}},methods:{async handleDownload(){if(this.downloadUrl.trim()){this.downloading=!0,this.statusMessage="";try{const s=await p.downloadUrl(this.downloadUrl.trim(),this.projectPath);this.statusMessage="部署文档已导入成功!",this.statusType="success",this.$emit("imported",s.data)}catch(s){this.statusMessage="下载失败: "+s.message,this.statusType="error"}finally{this.downloading=!1}}},async handleFileChange(s){this.statusMessage="";try{const t=await p.uploadArchive(s.raw,this.projectPath);this.statusMessage="部署文档已导入成功!",this.statusType="success",this.fileList=[],this.$emit("imported",t.data)}catch(t){this.statusMessage="上传失败: "+t.message,this.statusType="error"}}}};var E=function(){var t=this,e=t._self._c;return e("div",{staticClass:"deploy-import"},[e("div",{staticClass:"import-container"},[t._m(0),e("h2",{staticClass:"text-xl font-bold text-white mb-2"},[t._v("未找到部署文档")]),e("p",{staticClass:"text-textMuted mb-8"},[t._v("请导入部署文档到 .txcode/release/ 目录")]),e("div",{staticClass:"import-card"},[t._m(1),e("div",{staticClass:"import-card-body"},[e("div",{staticClass:"flex gap-2"},[e("el-input",{staticClass:"flex-1",attrs:{placeholder:"https://...",disabled:t.downloading},model:{value:t.downloadUrl,callback:function(a){t.downloadUrl=a},expression:"downloadUrl"}}),e("el-button",{attrs:{type:"primary",loading:t.downloading,disabled:!t.downloadUrl.trim()},on:{click:t.handleDownload}},[t._v(" "+t._s(t.downloading?"下载中...":"下载")+" ")])],1)])]),t._m(2),e("div",{staticClass:"import-card"},[t._m(3),e("div",{staticClass:"import-card-body"},[e("el-upload",{attrs:{drag:"","auto-upload":!1,"show-file-list":!0,accept:".tar.gz,.tgz,.zip","on-change":t.handleFileChange,"file-list":t.fileList,limit:1}},[e("i",{staticClass:"el-icon-upload"}),e("div",{staticClass:"el-upload__text"},[t._v("将 tar.gz / zip 文件拖到此处,或"),e("em",[t._v("点击上传")])]),e("div",{staticClass:"el-upload__tip",attrs:{slot:"tip"},slot:"tip"},[t._v("上传后自动解压到 .txcode/release/ 目录")])])],1)]),t.statusMessage?e("div",{staticClass:"import-status",class:t.statusType},[t._v(" "+t._s(t.statusMessage)+" ")]):t._e()])])},D=[function(){var s=this,t=s._self._c;return t("div",{staticClass:"import-icon"},[t("i",{staticClass:"fa-solid fa-cloud-arrow-down text-5xl text-textMuted opacity-50"})])},function(){var s=this,t=s._self._c;return t("div",{staticClass:"import-card-title"},[t("i",{staticClass:"fa-solid fa-link"}),s._v(" 输入链接下载部署文档 ")])},function(){var s=this,t=s._self._c;return t("div",{staticClass:"import-divider"},[t("span",[s._v("—— 或 ——")])])},function(){var s=this,t=s._self._c;return t("div",{staticClass:"import-card-title"},[t("i",{staticClass:"fa-solid fa-upload"}),s._v(" 选择压缩包上传(tar.gz / zip) ")])}],N=c(j,E,D,!1,null,"0cc389d3");const R=N.exports,z={name:"deployView",components:{DeployEditor:x,DeployAssistant:$,DeployImport:R},data(){return{loading:!0,releaseExists:!1,releaseContent:"",releasePath:"",editorContent:"",projectPath:""}},async mounted(){await this.loadProjectPath(),await this.checkRelease()},methods:{async loadProjectPath(){try{const s=await d.getCurrentProject();s.data&&s.data.path&&(this.projectPath=s.data.path)}catch(s){console.error("获取项目路径失败:",s)}},async checkRelease(){this.loading=!0;try{const s=await p.checkRelease(this.projectPath);s.data&&s.data.exists?(this.releaseExists=!0,this.releaseContent=s.data.content||"",this.editorContent=this.releaseContent,this.releasePath=s.data.path||""):this.releaseExists=!1}catch(s){console.error("检查部署文档失败:",s),this.releaseExists=!1}finally{this.loading=!1}},onContentChange(s){this.editorContent=s},onImported(){this.checkRelease()}}};var O=function(){var t=this,e=t._self._c;return e("div",{staticClass:"deploy-container"},[t.loading?e("div",{staticClass:"loading-state"},[e("i",{staticClass:"fa-solid fa-spinner fa-spin text-2xl text-textMuted"})]):t.releaseExists?[e("div",{staticClass:"deploy-main"},[e("DeployEditor",{ref:"editorRef",attrs:{content:t.releaseContent,"file-path":t.releasePath},on:{"content-change":t.onContentChange}}),e("DeployAssistant",{ref:"assistantRef",attrs:{"has-content":!!t.editorContent,"doc-content":t.editorContent,"project-path":t.projectPath,"release-path":t.releasePath}})],1)]:[e("DeployImport",{attrs:{"project-path":t.projectPath},on:{imported:t.onImported}})]],2)},A=[],B=c(z,O,A,!1,null,"a81ff1a6");const U=B.exports;export{U as default};
@@ -0,0 +1,18 @@
1
+ import{n as o,a as l,C as h,k as u,R as p,I as f,S as m,F as g,c as v,M as b,g as x,s as C,b as _,e as y,K as w,d as P,f as S}from"./index-B6eYD1o1.js";import{m as k}from"./mediaChat-DPuTKoES.js";const D={name:"CreatePageDialog",props:{visible:{type:Boolean,default:!1},targetPath:{type:String,default:""}},data(){return{pageName:"",pageType:"web",deviceTypes:[{value:"app",label:"App",icon:"fa-solid fa-mobile-screen"},{value:"web",label:"Web",icon:"fa-solid fa-desktop"},{value:"pad",label:"Pad",icon:"fa-solid fa-tablet-screen-button"}]}},computed:{previewFilename(){return`${this.pageName.trim()||"untitled"}_${this.pageType}.html`}},watch:{visible(s){s&&(this.pageName="",this.pageType="web",this.$nextTick(()=>{var e;return(e=this.$refs.nameInput)==null?void 0:e.focus()}))}},methods:{async confirm(){const s=this.pageName.trim();if(!s)return;const e=`${s}_${this.pageType}.html`,t=this.targetPath.includes("\\")?"\\":"/",i=this.targetPath+t+e,a=`<!DOCTYPE html>
2
+ <html lang="zh-CN">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>${s}</title>
7
+ <style>
8
+ * { margin: 0; padding: 0; box-sizing: border-box; }
9
+ body { font-family: system-ui, sans-serif; padding: 20px; }
10
+ </style>
11
+ </head>
12
+ <body>
13
+ <h1>${s}</h1>
14
+ </body>
15
+ </html>`;try{await l.writeFile(i,a),this.$message.success("网页创建成功"),this.$emit("created"),this.$emit("update:visible",!1)}catch(n){console.error("Create page failed:",n),this.$message.error("创建网页失败: "+(n.message||"未知错误"))}},cancel(){this.$emit("update:visible",!1)}}};var $=function(){var e=this,t=e._self._c;return e.visible?t("div",{staticClass:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",on:{click:function(i){return i.target!==i.currentTarget?null:e.cancel.apply(null,arguments)}}},[t("div",{staticClass:"bg-sidebar border border-border rounded p-5 w-96"},[t("p",{staticClass:"text-white text-sm font-medium mb-4"},[e._v("新建网页")]),t("div",{staticClass:"mb-3"},[t("label",{staticClass:"text-textMuted text-xs block mb-1"},[e._v("名称")]),t("input",{directives:[{name:"model",rawName:"v-model",value:e.pageName,expression:"pageName"}],ref:"nameInput",staticClass:"w-full px-3 py-2 bg-[#1e1e1e] border border-border rounded text-white text-sm focus:outline-none focus:border-accent",attrs:{placeholder:"输入网页名称"},domProps:{value:e.pageName},on:{keyup:[function(i){return!i.type.indexOf("key")&&e._k(i.keyCode,"enter",13,i.key,"Enter")?null:e.confirm.apply(null,arguments)},function(i){return!i.type.indexOf("key")&&e._k(i.keyCode,"escape",void 0,i.key,void 0)?null:e.cancel.apply(null,arguments)}],input:function(i){i.target.composing||(e.pageName=i.target.value)}}})]),t("div",{staticClass:"mb-3"},[t("label",{staticClass:"text-textMuted text-xs block mb-2"},[e._v("类型")]),t("div",{staticClass:"flex gap-2"},e._l(e.deviceTypes,function(i){return t("label",{key:i.value,staticClass:"flex items-center gap-1 px-3 py-2 rounded border text-sm cursor-pointer transition-colors",class:e.pageType===i.value?"border-accent bg-accent/10 text-white":"border-border text-textMuted hover:border-gray-500"},[t("input",{directives:[{name:"model",rawName:"v-model",value:e.pageType,expression:"pageType"}],staticClass:"hidden",attrs:{type:"radio"},domProps:{value:i.value,checked:e._q(e.pageType,i.value)},on:{change:function(a){e.pageType=i.value}}}),t("i",{staticClass:"text-xs",class:i.icon}),e._v(" "+e._s(i.label)+" ")])}),0)]),t("div",{staticClass:"mb-4 p-3 bg-[#1e1e1e] rounded border border-border"},[t("p",{staticClass:"text-xs text-textMuted mb-1"},[e._v("文件名预览")]),t("p",{staticClass:"text-xs text-textMain font-mono"},[e._v(e._s(e.previewFilename))])]),t("div",{staticClass:"flex justify-end gap-2"},[t("button",{staticClass:"px-3 py-1 text-xs text-textMuted hover:text-white",on:{click:e.cancel}},[e._v("取消")]),t("button",{staticClass:"px-3 py-1 text-xs bg-accent text-white rounded hover:bg-blue-600 disabled:opacity-50 disabled:cursor-not-allowed",attrs:{disabled:!e.pageName.trim()},on:{click:e.confirm}},[e._v("确定")])])])]):e._e()},F=[],T=o(D,$,F,!1,null,null);const M=T.exports,I={name:"DesignPageTree",components:{FileTreeNode:u,CreatePageDialog:M,CopyPathDialog:h},props:{basePath:{type:String,default:".txcode/design"}},data(){return{browseResult:{current_path:"",parent_path:null,items:[]},selectedPath:"",loading:!1,expandedPaths:new Set,contextMenu:{visible:!1,x:0,y:0,target:null},renameDialog:{visible:!1,title:"",value:"",placeholder:"",target:null,action:"rename"},createPageDialogVisible:!1,createPageTargetPath:""}},computed:{fileTreeData(){return this.browseResult.items.filter(e=>e.name!=="session.json"&&e.name!==".template").map(e=>({name:e.name,path:e.path,is_directory:e.is_directory,is_drive:e.is_drive||!1,size:e.size,has_children:e.is_directory,expanded:!1,children:[]})).sort((e,t)=>e.is_directory===t.is_directory?e.name.localeCompare(t.name):e.is_directory?-1:1)}},async created(){await this.initBrowse(),document.addEventListener("click",this.hideContextMenu)},beforeDestroy(){document.removeEventListener("click",this.hideContextMenu)},methods:{async initBrowse(){this.loading=!0;try{const s=await l.browseFilesystem(this.basePath);this.browseResult=s.data}catch{try{await l.createDirectory(this.basePath);const e=await l.browseFilesystem(this.basePath);this.browseResult=e.data}catch(e){console.error("Init design directory failed:",e),this.browseResult={current_path:this.basePath,parent_path:"",items:[]}}}finally{this.loading=!1}},async browse(s){this.loading=!0;try{const e=await l.browseFilesystem(s);this.browseResult=e.data}catch(e){console.error("Browse failed:",e)}finally{this.loading=!1}},refresh(){this.browse(this.browseResult.current_path||this.basePath)},createRootFolder(){this.renameDialog={visible:!0,title:"新建文件夹",value:"",placeholder:"输入文件夹名",target:{path:this.browseResult.current_path||this.basePath,is_directory:!0},action:"createFolder"},this.$nextTick(()=>{var s;return(s=this.$refs.renameInput)==null?void 0:s.focus()})},handleSelect(s){this.selectedPath=s.path;let e=s.path;e.startsWith(this.basePath+"/")?e=e.slice(this.basePath.length+1):e===this.basePath&&(e=""),!s.is_directory&&e.endsWith(".html")?(console.log("[DesignPageTree] handleSelect emitting current-page:",e),this.$emit("current-page",e),this.$emit("open-file",s)):console.log("[DesignPageTree] handleSelect skipping (dir or non-html):",s.name,"isDir:",s.is_directory)},handleOpenFile(s){if(this.$emit("open-file",s),!s.is_directory&&s.name.endsWith(".html")){let e=s.path;e.startsWith(this.basePath+"/")&&(e=e.slice(this.basePath.length+1)),this.$emit("current-page",e)}},async handleLoadChildren({path:s,callback:e}){try{const i=((await l.browseFilesystem(s)).data.items||[]).filter(a=>a.name!=="session.json"&&a.name!==".template").map(a=>({name:a.name,path:a.path,is_directory:a.is_directory,is_drive:!1,size:a.size,has_children:a.is_directory,expanded:!1,children:[]}));e(i.sort((a,n)=>a.is_directory===n.is_directory?a.name.localeCompare(n.name):a.is_directory?-1:1))}catch(t){console.error("Load children failed:",t),e([])}},showContextMenu(s,e){e&&(s.preventDefault(),this.contextMenu={visible:!0,x:s.pageX,y:s.pageY,target:e},this.selectedPath=e.path)},hideContextMenu(){this.contextMenu.visible=!1},copyPath(){this.hideContextMenu(),this.$refs.copyPathDialog.open(this.contextMenu.target.path)},createNewPage(){this.hideContextMenu(),this.createPageTargetPath=this.contextMenu.target.path,this.createPageDialogVisible=!0},createNewFolder(){this.hideContextMenu();const s=this.contextMenu.target;this.renameDialog={visible:!0,title:"新建文件夹",value:"",placeholder:"输入文件夹名",target:s,action:"createFolder"},this.$nextTick(()=>{var e;return(e=this.$refs.renameInput)==null?void 0:e.focus()})},renameItem(){this.hideContextMenu();const s=this.contextMenu.target;s.is_directory?this.renameDialog={visible:!0,title:"重命名文件夹",value:s.name,placeholder:"输入新名称",target:s,action:"rename"}:this.renameDialog={visible:!0,title:"重命名文件",value:s.name,placeholder:"输入新名称",target:s,action:"rename"},this.$nextTick(()=>{var e,t;(e=this.$refs.renameInput)==null||e.focus(),(t=this.$refs.renameInput)==null||t.select()})},confirmRename(){const{value:s,target:e,action:t}=this.renameDialog;if(!s.trim()){this.renameDialog.visible=!1;return}const i=e.path.includes("\\")?"\\":"/";let a,n;t==="createFolder"?(a=e.path+i+s.trim(),n=l.createDirectory(a)):(a=e.path.substring(0,e.path.lastIndexOf(i))+i+s.trim(),n=l.renameFile(e.path,a)),n.then(()=>{this.refresh(),this.$emit("file-changed")}).catch(r=>{console.error("Operation failed:",r),this.$message.error(t==="createFolder"?"创建文件夹失败":"重命名失败")}),this.renameDialog.visible=!1},cancelRename(){this.renameDialog.visible=!1},async deleteItem(){this.hideContextMenu();try{await this.$confirm(`确定要删除 "${this.contextMenu.target.name}" 吗?`,"确认删除",{confirmButtonText:"删除",cancelButtonText:"取消",type:"warning"}),await l.deleteFile(this.contextMenu.target.path),this.$message.success("删除成功"),this.refresh(),this.$emit("file-changed")}catch(s){s!=="cancel"&&(console.error("Delete failed:",s),this.$message.error("删除失败"))}},downloadFile(){this.hideContextMenu();const s=this.contextMenu.target;s&&l.downloadFilesystemWithProgress(s.path,s.name,()=>{}).catch(e=>this.$message.error("下载失败: "+e.message))},onPageCreated(){this.createPageDialogVisible=!1,this.refresh(),this.$emit("file-changed")},onExpandPath(s){const e=new Set(this.expandedPaths);e.add(s),this.expandedPaths=e},onCollapsePath(s){const e=new Set(this.expandedPaths);e.delete(s),this.expandedPaths=e},selectByPath(s){if(!s)return;const e=s.replace(/\\/g,"/"),t=e.split("/");let i=this.basePath;const a=new Set(this.expandedPaths);for(let r=0;r<t.length-1;r++)i=i+"/"+t[r],a.add(i);this.expandedPaths=a;const n=this.basePath+"/"+e;this.selectedPath=n}}};var N=function(){var i;var e=this,t=e._self._c;return t("div",{staticClass:"flex flex-col flex-1 min-h-0"},[t("div",{staticClass:"flex items-center gap-1 px-2 py-2 border-b border-border"},[t("button",{staticClass:"p-1 text-textMuted hover:text-white",attrs:{title:"刷新"},on:{click:e.refresh}},[t("i",{staticClass:"fa-solid fa-refresh"})]),t("button",{staticClass:"p-1 text-textMuted hover:text-white",attrs:{title:"新建文件夹"},on:{click:e.createRootFolder}},[t("i",{staticClass:"fa-solid fa-folder-plus"})])]),t("div",{staticClass:"flex-1 overflow-y-auto py-1 pb-8 sidebar-scroll",staticStyle:{"padding-bottom":"60px"}},[e.loading?t("div",{staticClass:"flex items-center justify-center py-8 text-textMuted"},[t("i",{staticClass:"fa-solid fa-spinner fa-spin mr-2"}),e._v(" 加载中... ")]):e.fileTreeData.length===0?t("div",{staticClass:"flex flex-col items-center justify-center py-12 text-textMuted text-sm"},[t("i",{staticClass:"fa-solid fa-folder-open text-4xl mb-3 opacity-20"}),t("p",[e._v("设计目录为空")]),t("p",{staticClass:"text-xs mt-1"},[e._v("右键文件夹创建网页")])]):e._l(e.fileTreeData,function(a){return t("file-tree-node",{key:a.path,attrs:{node:a,level:0,"selected-path":e.selectedPath,"expanded-paths":e.expandedPaths},on:{select:e.handleSelect,"open-file":e.handleOpenFile,"load-children":e.handleLoadChildren,contextmenu:e.showContextMenu,"expand-path":e.onExpandPath,"collapse-path":e.onCollapsePath}})})],2),t("div",{directives:[{name:"show",rawName:"v-show",value:e.contextMenu.visible,expression:"contextMenu.visible"}],staticClass:"fixed bg-sidebar border border-border rounded shadow-lg py-1 z-50 min-w-[160px]",style:{left:e.contextMenu.x+"px",top:e.contextMenu.y+"px"}},[(i=e.contextMenu.target)!=null&&i.is_directory?[t("button",{staticClass:"w-full text-left px-4 py-2 text-sm text-textMain hover:bg-active flex items-center gap-2",on:{click:e.createNewPage}},[t("i",{staticClass:"fa-solid fa-file-lines text-xs"}),e._v(" 新建网页 ")]),t("button",{staticClass:"w-full text-left px-4 py-2 text-sm text-textMain hover:bg-active flex items-center gap-2",on:{click:e.createNewFolder}},[t("i",{staticClass:"fa-solid fa-folder-plus text-xs"}),e._v(" 新建文件夹 ")]),t("div",{staticClass:"border-t border-border my-1"}),t("button",{staticClass:"w-full text-left px-4 py-2 text-sm text-textMain hover:bg-active flex items-center gap-2",on:{click:e.renameItem}},[t("i",{staticClass:"fa-solid fa-pen text-xs"}),e._v(" 重命名 ")]),t("button",{staticClass:"w-full text-left px-4 py-2 text-sm text-red-400 hover:bg-active flex items-center gap-2",on:{click:e.deleteItem}},[t("i",{staticClass:"fa-solid fa-trash text-xs"}),e._v(" 删除 ")])]:[t("button",{staticClass:"w-full text-left px-4 py-2 text-sm text-textMain hover:bg-active flex items-center gap-2",on:{click:e.copyPath}},[t("i",{staticClass:"fa-solid fa-copy text-xs"}),e._v(" 复制路径 ")]),t("button",{staticClass:"w-full text-left px-4 py-2 text-sm text-textMain hover:bg-active flex items-center gap-2",on:{click:e.downloadFile}},[t("i",{staticClass:"fa-solid fa-download text-xs"}),e._v(" 下载 ")]),t("button",{staticClass:"w-full text-left px-4 py-2 text-sm text-textMain hover:bg-active flex items-center gap-2",on:{click:e.renameItem}},[t("i",{staticClass:"fa-solid fa-pen text-xs"}),e._v(" 重命名 ")]),t("button",{staticClass:"w-full text-left px-4 py-2 text-sm text-red-400 hover:bg-active flex items-center gap-2",on:{click:e.deleteItem}},[t("i",{staticClass:"fa-solid fa-trash text-xs"}),e._v(" 删除 ")])]],2),t("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(a){return a.target!==a.currentTarget?null:e.cancelRename.apply(null,arguments)}}},[t("div",{staticClass:"bg-sidebar border border-border rounded p-4 w-80"},[t("p",{staticClass:"text-white text-sm mb-3"},[e._v(e._s(e.renameDialog.title))]),t("input",{directives:[{name:"model",rawName:"v-model",value:e.renameDialog.value,expression:"renameDialog.value"}],ref:"renameInput",staticClass:"w-full px-3 py-2 bg-contentBg border border-border rounded text-white text-sm focus:outline-none focus:border-accent",attrs:{placeholder:e.renameDialog.placeholder},domProps:{value:e.renameDialog.value},on:{keyup:[function(a){return!a.type.indexOf("key")&&e._k(a.keyCode,"enter",13,a.key,"Enter")?null:e.confirmRename.apply(null,arguments)},function(a){return!a.type.indexOf("key")&&e._k(a.keyCode,"escape",void 0,a.key,void 0)?null:e.cancelRename.apply(null,arguments)}],input:function(a){a.target.composing||e.$set(e.renameDialog,"value",a.target.value)}}}),t("div",{staticClass:"flex justify-end gap-2 mt-4"},[t("button",{staticClass:"px-3 py-1 text-xs text-textMuted hover:text-white",on:{click:e.cancelRename}},[e._v("取消")]),t("button",{staticClass:"px-3 py-1 text-xs bg-accent text-white rounded hover:bg-blue-600",on:{click:e.confirmRename}},[e._v("确定")])])])]),t("CreatePageDialog",{attrs:{visible:e.createPageDialogVisible,"target-path":e.createPageTargetPath},on:{"update:visible":function(a){e.createPageDialogVisible=a},created:e.onPageCreated}}),t("CopyPathDialog",{ref:"copyPathDialog"})],1)},V=[],R=o(I,N,V,!1,null,"d033f82c");const z=R.exports,B={name:"TemplateSelectDialog",props:{visible:{type:Boolean,default:!1},basePath:{type:String,default:".txcode/design"}},data(){return{loading:!1,templates:[],selectedTemplate:"",searchText:""}},computed:{filteredTemplates(){if(!this.searchText)return this.templates;const s=this.searchText.toLowerCase();return this.templates.filter(e=>e.name.toLowerCase().includes(s))},selectedName(){const s=this.templates.find(e=>e.path===this.selectedTemplate);return s?s.name:""}},watch:{visible(s){s&&(this.loadTemplates(),this.selectedTemplate="",this.searchText="")}},methods:{async loadTemplates(){var s;this.loading=!0;try{const e=`${this.basePath}/.template`,i=((s=(await l.browseFilesystem(e)).data)==null?void 0:s.items)||[];this.templates=i.filter(a=>!a.is_directory&&a.name.endsWith(".html")).map(a=>({name:a.name,path:a.path}))}catch(e){console.error("Load templates failed:",e),this.templates=[]}finally{this.loading=!1,this.$nextTick(()=>{const e=this.$refs.searchInput;e&&e.focus()})}},handleConfirm(){this.selectedTemplate&&(this.$emit("select",this.selectedTemplate),this.$emit("update:visible",!1))},handleClose(){this.$emit("close")},handleVisibleChange(s){this.$emit("update:visible",s)}}};var E=function(){var e=this,t=e._self._c;return t("el-dialog",{attrs:{visible:e.visible,title:"选择模版",width:"420px","close-on-click-modal":!1},on:{"update:visible":e.handleVisibleChange,close:e.handleClose}},[t("div",{staticClass:"template-select-content"},[t("div",{staticClass:"template-search"},[t("input",{directives:[{name:"model",rawName:"v-model",value:e.searchText,expression:"searchText"}],ref:"searchInput",staticClass:"search-input",attrs:{placeholder:"搜索模版..."},domProps:{value:e.searchText},on:{input:function(i){i.target.composing||(e.searchText=i.target.value)}}})]),t("div",{staticClass:"template-list-container"},[e.loading?t("div",{staticClass:"empty-state"},[t("i",{staticClass:"fa-solid fa-spinner fa-spin mr-2"}),e._v(" 加载中... ")]):e.filteredTemplates.length===0?t("div",{staticClass:"empty-state"},[e._v(" "+e._s(e.searchText?"无匹配模版":"暂无模版,请先保存模版")+" ")]):e._e(),e._l(e.filteredTemplates,function(i){return t("div",{key:i.path,staticClass:"template-item",class:{"template-selected":e.selectedTemplate===i.path},on:{click:function(a){e.selectedTemplate=i.path},dblclick:e.handleConfirm}},[t("div",{staticClass:"template-name"},[e._v(e._s(i.name))]),t("div",{staticClass:"template-path"},[e._v(e._s(i.path))])])})],2),t("div",{staticClass:"template-select-footer"},[t("span",{staticClass:"selected-template"},[e._v(e._s(e.selectedName||"未选择"))]),t("button",{staticClass:"confirm-btn",attrs:{disabled:!e.selectedTemplate},on:{click:e.handleConfirm}},[e._v("选择")])])])])},q=[],L=o(B,E,q,!1,null,"2152b684");const A=L.exports,O={name:"DesignAiChat",components:{ModelSelectDialog:b,CommandDialog:v,FileSelectDialog:g,SkillSelectDialog:m,TemplateSelectDialog:A,ImagePreviewList:f,ResizableTextarea:p},mixins:[k()],props:{basePath:{type:String,default:".txcode/design"},currentPage:{type:String,default:""}},data(){return{inputMessage:"",disabled:!1,stopping:!1,promptTokens:0,logItems:[],modelName:"",modelSelectVisible:!1,commandDialogVisible:!1,fileSelectVisible:!1,skillSelectVisible:!1,templateSelectVisible:!1,skillCursorPos:-1,sessionId:"",sessionStatus:"idle",wsUnsubscribe:null,requestSeq:0}},watch:{currentPage:{immediate:!1,handler(s){this.loadSessionForPage(s)}}},async mounted(){await this.loadDefaultModel(),l.ws.init(),this.currentPage&&await this.loadSessionForPage(this.currentPage)},beforeDestroy(){this.wsUnsubscribe&&this.wsUnsubscribe()},methods:{getSessionJsonPath(){return this.basePath+"/session.json"},async readSessionJson(){var s;try{const e=await l.getFileContent(this.getSessionJsonPath());if(e&&((s=e.data)!=null&&s.content)){const t=JSON.parse(e.data.content);if(t.pageSessions){const i={};for(const[a,n]of Object.entries(t.pageSessions))a.endsWith(".html")&&a!=="session.json"&&(i[a]=n);Object.keys(i).length!==Object.keys(t.pageSessions).length&&(t.pageSessions=i,this.writeSessionJson(t).catch(()=>{}))}return t}}catch{}return{pageSessions:{}}},async writeSessionJson(s){await l.writeFile(this.getSessionJsonPath(),JSON.stringify(s,null,2))},async loadSessionForPage(s){var n;const e=++this.requestSeq;console.log("[DesignAiChat] loadSessionForPage called:",s,"seq:",e);const t=performance.now();if(!s||!s.endsWith(".html")){this.wsUnsubscribe&&(this.wsUnsubscribe(),this.wsUnsubscribe=null),this.sessionId="",this.logItems=[],this.promptTokens=0,this.sessionStatus="idle",this.$emit("status-change","idle"),console.log("[DesignAiChat] loadSessionForPage skipped (not html):",s);return}const i=await this.readSessionJson();if(this.requestSeq!==e)return;console.log("[DesignAiChat] sessionData loaded:",Object.keys(i.pageSessions||{}));const a=(n=i.pageSessions)==null?void 0:n[s];if(console.log("[DesignAiChat] pageSession for",s,":",!!a),a!=null&&a.sessionId)try{console.log("[DesignAiChat] loading existing session:",a.sessionId);const r=performance.now(),c=await l.getSession(a.sessionId);if(this.requestSeq!==e)return;if(console.log("[DesignAiChat] getSession took:",(performance.now()-r).toFixed(1),"ms"),c&&c.data){this.sessionId=a.sessionId,this.subscribeSession();const d=performance.now();if(await this.loadMessages(),this.requestSeq!==e)return;console.log("[DesignAiChat] loadMessages took:",(performance.now()-d).toFixed(1),"ms"),console.log("[DesignAiChat] loadSessionForPage done (existing), total:",(performance.now()-t).toFixed(1),"ms");return}}catch(r){console.error("[DesignAiChat] getSession failed:",r)}try{console.log("[DesignAiChat] creating new session for:",s);const r=await l.createSession(`设计页面: ${s}`);if(this.requestSeq!==e||(this.sessionId=r.data.id,i.pageSessions[s]={sessionId:this.sessionId},await this.writeSessionJson(i),this.requestSeq!==e))return;this.logItems=[],this.promptTokens=0,this.subscribeSession(),console.log("[DesignAiChat] loadSessionForPage done (new), total:",(performance.now()-t).toFixed(1),"ms")}catch(r){console.error("Create session failed:",r)}},async loadDefaultModel(){var s;try{const e=await l.getConfig("defaultModel");this.modelName=((s=e.data)==null?void 0:s.value)||""}catch(e){console.error("Load model failed:",e)}},async loadMessages(){if(this.sessionId)try{const s=await l.getMessages(this.sessionId);this.logItems=s.data||[],this.$nextTick(()=>this.scrollChatToBottom(!0))}catch(s){console.error("Load messages failed:",s)}},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)+`
16
+ `+a.substring(i),this.$nextTick(()=>{e.selectionStart=e.selectionEnd=t+1})}else s.preventDefault(),this.sendMessage()},async sendMessage(){const s=this.inputMessage.trim(),e=this.mediaFiles&&this.mediaFiles.length>0;if(!s&&!e||this.disabled)return;if(!this.sessionId){this.$message.error("请在左侧选择设计页面");return}this.wsUnsubscribe||this.subscribeSession();let t=s;this.currentPage&&(t=`当前设计页面:${this.currentPage}
17
+ 用户需求:${s}
18
+ 请基于以上设计页面路径,对该页面进行设计或修改。`),this.inputMessage="",this.disabled=!0,this.stopping=!1;const i=(this.mediaFiles||[]).filter(a=>!a.uploading&&a.filePath).map(a=>({filePath:a.filePath,type:a.type,dataUrl:a.dataUrl}));this.logItems.push({type:"chat",content:s,mediaFiles:i}),this.scrollChatToBottom(!0),l.sessionWsSend(this.sessionId,"chat",{message:t,sessionId:this.sessionId,modelName:this.modelName||void 0,agent:"design",mediaFiles:i.map(a=>({filePath:a.filePath,type:a.type}))}),this.mediaFiles=[]},stopChat(){!this.sessionId||this.stopping||(this.stopping=!0,l.sessionWsSend(this.sessionId,"stop",{sessionId:this.sessionId}))},subscribeSession(){this.sessionId&&(this.wsUnsubscribe&&this.wsUnsubscribe(),this.wsUnsubscribe=l.wsSubscribe(this.sessionId,{running_sessions:s=>{const t=((s==null?void 0:s.runningSessionIds)||[]).includes(this.sessionId);this.sessionStatus=t?"processing":"idle",this.disabled=t,this.$emit("status-change",this.sessionStatus)},step:s=>{var t,i;((t=s.toolCalls)==null?void 0:t.some(a=>a.status==="executing"))?(this.logItems=this.logItems.filter(a=>!(a.type==="step"&&a.iteration===s.iteration&&a._executing)),this.logItems.push({type:"step",thought:s.reasoning||s.thought,toolCalls:s.toolCalls,success:s.success,iteration:s.iteration,_executing:!0})):(this.logItems=this.logItems.filter(a=>!(a.type==="step"&&a.iteration===s.iteration&&a._executing)),this.logItems.push({type:"step",thought:s.thought,toolCalls:s.toolCalls,success:s.success})),(i=s.usage)!=null&&i.promptTokens&&(this.promptTokens=s.usage.promptTokens),this.scrollChatToBottom()},compact:()=>{this.logItems.push({type:"system",content:"【会话已压缩】"}),this.loadMessages()},done:s=>{var e;this.logItems=this.logItems.filter(t=>!(t.type==="step"&&t._executing)),this.disabled=!1,this.stopping=!1,this.sessionStatus="completed",this.$emit("status-change","completed"),s!=null&&s.modelName&&(this.modelName=s.modelName),(e=s==null?void 0:s.usage)!=null&&e.promptTokens&&(this.promptTokens=s.usage.promptTokens),s!=null&&s.response&&this.logItems.push({type:"think",content:s.response}),this.scrollChatToBottom(),this.$emit("design-updated")},stopped:()=>{this.logItems=this.logItems.filter(s=>!(s.type==="step"&&s._executing)),this.disabled=!1,this.stopping=!1,this.sessionStatus="idle",this.$emit("status-change","idle"),this.logItems.push({type:"think",content:"【已停止】"}),this.scrollChatToBottom()},error:s=>{this.logItems=this.logItems.filter(e=>!(e.type==="step"&&e._executing)),this.$message.error((s==null?void 0:s.error)||"发生错误"),this.disabled=!1,this.stopping=!1,this.sessionStatus="idle",this.$emit("status-change","idle")}}))},scrollChatToBottom(s=!1){const e=C(this.$refs.messagesContainer);this.$nextTick(()=>_(this.$refs.messagesContainer,{force:s,prevSnapshot:e}))},renderMarkdown(s){return s?x(s,{breaks:!0}):""},formatInput(s,e){try{const t=typeof e=="string"?JSON.parse(e):e;return s==="bash"||s==="execute_bash"?t.command+(t.workdir?` (${t.workdir})`:""):s==="read_file"?t.file_path+(t.offset?`:${t.offset}`:""):s==="edit_file"||s==="write_file"?t.file_path:s==="glob"||s==="find_files"?t.pattern+(t.directory?` (${t.directory})`:""):s==="grep"||s==="search_content"?`"${t.pattern}" (${t.directory||""})`:JSON.stringify(t)}catch{return e}},openModelSelector(){this.modelSelectVisible=!0},onModelSelected(s){const e=s.name.split("/");this.modelName=e.length>2?e.slice(1).join("/"):s.name,l.setConfig("defaultModel",this.modelName)},openCommandDialog(){this.commandDialogVisible=!0},handleExecuteCommand(s){this.inputMessage=s+" ",this.$nextTick(()=>{const e=this.$el.querySelector(".input-area textarea");e&&e.focus()})},openFileSelect(){this.fileSelectVisible=!0},onFileSelected(s){const e=this.inputMessage.lastIndexOf("@");e!==-1?this.inputMessage=this.inputMessage.slice(0,e)+s+" ":this.inputMessage+=s+" ",this.cancelFileSelect()},cancelFileSelect(){this.fileSelectVisible=!1},openSkillSelect(){const s=this.$el.querySelector(".input-area textarea");this.skillCursorPos=s?s.selectionStart:-1,this.skillSelectVisible=!0},onSkillSelected(s){const e=`[${s}] `,t=this.skillCursorPos>=0?this.skillCursorPos:0;this.inputMessage=this.inputMessage.slice(0,t)+e+this.inputMessage.slice(t),this.cancelSkillSelect()},cancelSkillSelect(){this.skillSelectVisible=!1},openTemplateSelect(){const s=this.$el.querySelector(".input-area textarea");this.skillCursorPos=s?s.selectionStart:-1,this.templateSelectVisible=!0},onTemplateSelected(s){const e=`【设计基础模版】${s} `,t=this.skillCursorPos>=0?this.skillCursorPos:0;this.inputMessage=this.inputMessage.slice(0,t)+e+this.inputMessage.slice(t)}}};var j=function(){var e=this,t=e._self._c;return t("div",{staticClass:"flex flex-col flex-1 min-h-0"},[t("div",{ref:"messagesContainer",staticClass:"chat-messages flex-1 overflow-y-auto px-3 py-2 min-h-0"},[e.logItems.length?e._e():t("div",{staticClass:"empty-state"},[t("i",{staticClass:"fa-solid fa-robot text-4xl mb-3 opacity-20 block text-center"}),t("p",{staticClass:"text-sm text-textMuted text-center"},[e._v("AI设计助手可协助您分析和优化设计")]),t("p",{staticClass:"text-xs text-textMuted text-center mt-1"},[e._v("Enter 发送,Ctrl+Enter 换行")])]),e._l(e.logItems,function(i,a){return[i.type==="chat"?t("div",{key:a,staticClass:"flex justify-end mb-3"},[t("div",{staticClass:"user-question"},[i.mediaFiles&&i.mediaFiles.length>0?t("div",{staticClass:"chat-images mb-1"},e._l(i.mediaFiles,function(n){return t("img",{key:n.filePath,staticClass:"chat-image-thumb",attrs:{src:n.url||n.dataUrl||n.filePath},on:{click:function(r){return r.stopPropagation(),e.openImagePreview(n)}}})}),0):e._e(),t("div",{staticClass:"text-sm"},[e._v(e._s(i.content))])])]):i.type==="system"?t("div",{key:a,staticClass:"system-message mb-2",domProps:{innerHTML:e._s(e.renderMarkdown(i.content))}}):i.type==="step"?[i.thought?t("div",{staticClass:"ai-thought mb-2",domProps:{innerHTML:e._s(e.renderMarkdown(i.thought))}}):e._e(),e._l(i.toolCalls,function(n,r){return t("div",{key:r,staticClass:"log-mute text-xs text-textMuted mb-1"},[n.status==="executing"?[t("span",{staticClass:"tool-spinner"}),e._v(" "+e._s(n.function.name)+" "),n.function.arguments?t("span",{staticClass:"tool-input"},[e._v(e._s(e.formatInput(n.function.name,n.function.arguments)))]):e._e()]:[t("span",{class:i.success!==!1?"text-green-400":"text-red-400"},[e._v(" "+e._s(i.success!==!1?"✓":"✗")+" ")]),e._v(" "+e._s(n.function.name)+" "),n.function.arguments?t("span",{staticClass:"tool-input"},[e._v(e._s(e.formatInput(n.function.name,n.function.arguments)))]):e._e()]],2)})]:i.type==="think"?t("div",{key:a,staticClass:"ai-thought mb-2",domProps:{innerHTML:e._s(e.renderMarkdown(i.content))}}):e._e()]}),e.modelName?t("div",{staticClass:"build-info"},[t("span",{staticClass:"icon"},[e._v("▣")]),e._v(" Build · "+e._s(e.modelName)+" ")]):e._e()],2),t("div",{staticClass:"chat-input-area flex-shrink-0"},[e.mediaFiles&&e.mediaFiles.length>0?t("ImagePreviewList",{attrs:{files:e.mediaFiles,disabled:e.disabled},on:{remove:e.removeMedia}}):e._e(),t("div",{staticClass:"input-panel"},[t("div",{staticClass:"input-wrapper"},[t("ResizableTextarea",{staticClass:"input-area",attrs:{rows:5,placeholder:"输入消息... (Enter 发送, Ctrl+Enter 换行, @ 选择文件)",disabled:e.disabled&&!e.stopping},on:{"paste-image":e.handlePasteImages},nativeOn:{keydown:function(i){return!i.type.indexOf("key")&&e._k(i.keyCode,"enter",13,i.key,"Enter")?null:e.handleKeydown.apply(null,arguments)}},model:{value:e.inputMessage,callback:function(i){e.inputMessage=i},expression:"inputMessage"}}),t("input",{ref:"mediaInput",staticStyle:{display:"none"},attrs:{type:"file",accept:"image/*",multiple:""},on:{change:e.handleImageSelected}})],1),t("div",{staticClass:"input-actions"},[t("div",{staticClass:"input-actions-left"},[t("span",{staticClass:"status-action",on:{click:e.openFileSelect,mousedown:function(i){i.preventDefault()}}},[e._v("选择文件")]),t("span",{staticClass:"separator"},[e._v("|")]),t("span",{staticClass:"status-action",on:{click:e.openSkillSelect,mousedown:function(i){i.preventDefault()}}},[e._v("选择Skill")]),t("span",{staticClass:"separator"},[e._v("|")]),t("span",{staticClass:"status-action",on:{click:e.openTemplateSelect,mousedown:function(i){i.preventDefault()}}},[e._v("选择模版")]),t("span",{staticClass:"separator"},[e._v("|")]),t("span",{staticClass:"status-action",on:{click:e.openCommandDialog,mousedown:function(i){i.preventDefault()}}},[e._v("命令")])]),t("div",{staticClass:"input-actions-right"},[t("el-button",{staticClass:"upload-btn",attrs:{disabled:e.disabled,size:"small"},on:{click:e.handleImageUpload}},[e._v("图片")]),e.disabled&&!e.stopping?t("el-button",{staticClass:"stop-btn",attrs:{type:"danger",size:"small"},on:{click:e.stopChat}},[e._v(" ■ 停止 ")]):e.stopping?t("el-button",{staticClass:"stop-btn",attrs:{type:"info",disabled:"",size:"small"}},[e._v(" 停止中... ")]):t("el-button",{staticClass:"send-btn",attrs:{type:"primary",disabled:!e.inputMessage.trim()&&(!e.mediaFiles||e.mediaFiles.length===0),size:"small"},on:{click:e.sendMessage}},[e._v(" 发送 ")])],1)])]),t("div",{staticClass:"status-bar"},[t("span",{class:e.sessionStatus==="processing"?"status-thinking":"status-ready"},[e.sessionStatus==="processing"?t("span",{staticClass:"thinking-spinner"}):e._e(),e._v(" "+e._s(e.sessionStatus==="processing"?"思考中":"✓ 就绪")+" ")]),t("span",{staticClass:"separator"},[e._v("|")]),t("span",{staticClass:"model-selector",on:{click:e.openModelSelector,mousedown:function(i){i.preventDefault()}}},[e._v(" 模型:"+e._s(e.modelName||"-")+" ▾ ")]),t("span",{staticClass:"separator"},[e._v("|")]),t("span",[e._v("会话:"+e._s(e.sessionId?e.sessionId.slice(0,8):"--------"))]),t("span",{staticClass:"separator"},[e._v("|")]),t("span",[e._v("token:"+e._s(e.promptTokens||0))])])],1),e.previewImage?t("div",{staticClass:"fixed inset-0 bg-black/50 z-50 flex items-center justify-center",on:{click:e.closeImagePreview}},[t("span",{staticClass:"absolute top-4 right-4 text-white text-2xl cursor-pointer"},[e._v("×")]),t("img",{staticClass:"max-w-[90vw] max-h-[90vh]",attrs:{src:e.previewImage.url||e.previewImage.dataUrl||e.previewImage.filePath},on:{click:function(i){i.stopPropagation()}}})]):e._e(),t("ModelSelectDialog",{attrs:{visible:e.modelSelectVisible,"current-model":e.modelName},on:{"update:visible":function(i){e.modelSelectVisible=i},select:e.onModelSelected}}),t("CommandDialog",{attrs:{visible:e.commandDialogVisible},on:{"update:visible":function(i){e.commandDialogVisible=i},execute:e.handleExecuteCommand}}),t("FileSelectDialog",{attrs:{visible:e.fileSelectVisible},on:{"update:visible":function(i){e.fileSelectVisible=i},select:e.onFileSelected,close:e.cancelFileSelect}}),t("SkillSelectDialog",{attrs:{visible:e.skillSelectVisible},on:{"update:visible":function(i){e.skillSelectVisible=i},select:e.onSkillSelected,close:e.cancelSkillSelect}}),t("TemplateSelectDialog",{attrs:{visible:e.templateSelectVisible,"base-path":".txcode/design"},on:{"update:visible":function(i){e.templateSelectVisible=i},select:e.onTemplateSelected}})],1)},W=[],U=o(O,j,W,!1,null,"604068dd");const J=U.exports,K={name:"DesignSidebar",components:{DesignPageTree:z,DesignAiChat:J},props:{basePath:{type:String,default:".txcode/design"}},data(){return{activeTab:"pages",currentPage:""}},methods:{setCurrentPage(s){this.currentPage=s,this.$refs.pageTree&&this.$refs.pageTree.selectByPath(s)}}};var H=function(){var e=this,t=e._self._c;return t("aside",{staticClass:"bg-panelHeader border border-contentBg flex flex-col shrink-0 overflow-hidden",staticStyle:{width:"480px"}},[t("div",{staticClass:"flex border-b border-contentBg bg-panelHeader"},[t("div",{staticClass:"flex-1 text-center px-3 py-2.5 cursor-pointer text-sm border-b-2 transition-colors",class:e.activeTab==="pages"?"border-accent text-white":"border-transparent text-textMuted hover:text-white",on:{click:function(i){e.activeTab="pages"}}},[t("i",{staticClass:"fa-solid fa-file-code mr-1"}),e._v(" 设计页面 ")]),t("div",{staticClass:"flex-1 text-center px-3 py-2.5 cursor-pointer text-sm border-b-2 transition-colors",class:e.activeTab==="ai"?"border-accent text-white":"border-transparent text-textMuted hover:text-white",on:{click:function(i){e.activeTab="ai"}}},[t("i",{staticClass:"fa-solid fa-robot mr-1"}),e._v(" AI设计助手 ")])]),t("DesignPageTree",{directives:[{name:"show",rawName:"v-show",value:e.activeTab==="pages",expression:"activeTab === 'pages'"}],ref:"pageTree",attrs:{"base-path":e.basePath},on:{"open-file":function(i){return e.$emit("open-file",i)},"current-page":function(i){e.currentPage=i},"file-changed":function(i){return e.$emit("file-changed")}}}),t("keep-alive",[e.activeTab==="ai"?t("DesignAiChat",{attrs:{"base-path":e.basePath,"current-page":e.currentPage},on:{"design-updated":function(i){return e.$emit("file-changed")},"status-change":function(i){return e.$emit("ai-status-change",i)}}}):e._e()],1)],1)},X=[],Y=o(K,H,X,!1,null,null);const G=Y.exports,Q={name:"DesignPreview",props:{fileContent:{type:String,default:""},fileName:{type:String,default:""},relativePath:{type:String,default:""}},data(){return{activeDevice:"web",refreshKey:0,renderIframe:!1,_relativePathVersion:0,deviceSizes:[{value:"app",label:"App",icon:"fa-solid fa-mobile-screen",width:375},{value:"web",label:"Web",icon:"fa-solid fa-desktop",width:0},{value:"pad",label:"Pad",icon:"fa-solid fa-tablet-screen-button",width:768}]}},computed:{previewSrc(){if(!this.relativePath)return"";const s=`/design_html/${encodeURI(this.relativePath)}?_=${this._relativePathVersion}`;return console.log("[DesignPreview] previewSrc computed:",s),s},iframeStyle(){return{width:"100%",height:"100%"}},frameStyle(){switch(this.activeDevice){case"app":return{width:"390px"};case"pad":return{width:"800px"};default:return{}}}},watch:{fileName:{immediate:!0,handler(s){s&&(s.includes("_app.html")?this.activeDevice="app":s.includes("_web.html")?this.activeDevice="web":s.includes("_pad.html")?this.activeDevice="pad":this.activeDevice="web",console.log("[DesignPreview] fileName changed:",s,"→ activeDevice:",this.activeDevice))}},relativePath(s,e){console.log("[DesignPreview] relativePath changed:",e,"→",s),s?(this._relativePathVersion++,console.log("[DesignPreview] _relativePathVersion:",this._relativePathVersion),this.renderIframe=!1,console.log("[DesignPreview] renderIframe set to false, scheduling recreate"),this.$nextTick(()=>{this.renderIframe=!0,console.log("[DesignPreview] renderIframe set to true, iframe should be created with src:",this.previewSrc)})):(this.renderIframe=!1,console.log("[DesignPreview] renderIframe set to false (no file)"))}},mounted(){console.log("[DesignPreview] mounted, relativePath:",this.relativePath)},updated(){console.log("[DesignPreview] updated, relativePath:",this.relativePath,"previewSrc:",this.previewSrc)},beforeDestroy(){console.log("[DesignPreview] beforeDestroy")},methods:{refreshPreview(){this.refreshKey++,this._relativePathVersion++,this.renderIframe=!1,this.$nextTick(()=>{this.renderIframe=!0,console.log("[DesignPreview] refreshPreview, iframe recreated")})},openInNewTab(){this.previewSrc&&window.open(this.previewSrc,"_blank")},onIframeLoad(){var s,e;console.log("[DesignPreview] iframe onload, src:",this.previewSrc);try{const t=this.$refs.previewFrame;if(!t)return;let i=null;try{i=(e=(s=t.contentWindow)==null?void 0:s.location)==null?void 0:e.pathname}catch{return}if(i&&i!=="/"){const a=i.match(/\/design_html\/(.+)$/);if(a){const n=decodeURIComponent(a[1]);n.endsWith(".html")&&!n.includes("..")&&!n.includes("~")&&n!==this.relativePath&&this.$emit("navigate",n)}}}catch(t){console.warn("[DesignPreview] onIframeLoad error:",t)}}}};var Z=function(){var e=this,t=e._self._c;return t("div",{staticClass:"flex flex-col h-full"},[t("div",{staticClass:"flex items-center gap-2 px-3 py-2 border-b border-border bg-sidebar"},[t("span",{staticClass:"text-xs text-textMuted mr-2"},[e._v("视口:")]),e._l(e.deviceSizes,function(i){return t("button",{key:i.value,staticClass:"px-3 py-1 text-xs rounded border transition-colors",class:e.activeDevice===i.value?"border-accent bg-accent/10 text-white":"border-transparent text-textMuted hover:border-gray-500",attrs:{title:i.label},on:{click:function(a){e.activeDevice=i.value}}},[t("i",{staticClass:"mr-1",class:i.icon}),e._v(e._s(i.label)+" ")])})],2),t("div",{staticClass:"flex-1 flex items-center justify-center overflow-auto bg-[#f5f5f5] p-4"},[e.relativePath?t("div",{staticClass:"device-frame flex flex-col self-stretch",class:`device-frame-${e.activeDevice}`,style:e.frameStyle},[t("div",{staticClass:"flex justify-end mb-2 shrink-0 gap-1"},[t("button",{staticClass:"px-2 py-0.5 text-textMuted hover:text-white text-xs rounded hover:bg-white/10 transition-colors",attrs:{title:"保存为模版"},on:{click:function(i){return e.$emit("save-template")}}},[e._v("保存模版")]),t("button",{staticClass:"p-1 text-textMuted hover:text-white text-xs rounded hover:bg-white/10 transition-colors",attrs:{title:"新窗口打开"},on:{click:e.openInNewTab}},[t("i",{staticClass:"fa-solid fa-up-right-from-square"})]),t("button",{staticClass:"p-1 text-textMuted hover:text-white text-xs rounded hover:bg-white/10 transition-colors",attrs:{title:"刷新预览"},on:{click:e.refreshPreview}},[t("i",{staticClass:"fa-solid fa-refresh"})])]),e.renderIframe?t("iframe",{ref:"previewFrame",staticClass:"w-full border-0",style:e.iframeStyle,attrs:{src:e.previewSrc,sandbox:"allow-scripts allow-same-origin allow-forms allow-modals allow-popups"},on:{load:e.onIframeLoad}}):e._e()]):t("div",{staticClass:"text-textMuted text-center mt-20"},[t("i",{staticClass:"fa-solid fa-eye text-6xl mb-4 opacity-20 block"}),t("p",[e._v("双击左侧 HTML 文件预览")])])])])},ee=[],te=o(Q,Z,ee,!1,null,"39c9eda3");const se=te.exports,ie={name:"DesignEditor",props:{fileContent:{type:String,default:""},fileName:{type:String,default:""},filePath:{type:String,default:""}},data(){return{editor:null,originalContent:"",contentChanged:!1,saving:!1}},watch:{fileContent:{immediate:!0,handler(s){if(!this.fileName||!this.editor&&(this.initEditor(),!this.editor))return;const e=s||"";this.editor.getValue()!==e&&(this.originalContent=e,this.editor.setValue(e),this.contentChanged=!1)}}},mounted(){this.$nextTick(()=>this.initEditor())},beforeDestroy(){this.editor&&(this.editor.dispose(),this.editor=null)},methods:{initEditor(){this.editor||this.$refs.editorContainer&&this.fileName&&(this.editor=y.create(this.$refs.editorContainer,{value:this.fileContent||"",language:"html",theme:"vs-dark",automaticLayout:!0,minimap:{enabled:!1},scrollBeyondLastLine:!1,fontSize:14,fontFamily:'Consolas, Monaco, "Courier New", monospace',lineNumbers:"on",scrollbar:{useShadows:!1,vertical:"auto",horizontal:"auto"}}),this.originalContent=this.fileContent||"",this.editor.onDidChangeModelContent(()=>{this.editor&&(this.contentChanged=this.editor.getValue()!==this.originalContent,this.$emit("content-changed",this.contentChanged))}),this.editor.addCommand(w.CtrlCmd|P.KeyS,()=>{this.saveFile()}))},updateContent(s){if(!this.editor){this.initEditor(),this.$nextTick(()=>this.updateContent(s));return}this.originalContent=s,this.editor.setValue(s),this.contentChanged=!1},layout(){!this.editor&&this.fileName&&this.initEditor(),this.editor&&this.$nextTick(()=>this.editor.layout())},async saveFile(){if(!(!this.editor||!this.filePath)){this.saving=!0;try{const s=this.editor.getValue();await l.writeFile(this.filePath,s),this.originalContent=s,this.contentChanged=!1,this.$emit("content-saved",s),this.$emit("content-changed",!1),this.$message.success("文件已保存")}catch(s){console.error("Save failed:",s),this.$message.error("保存文件失败")}finally{this.saving=!1}}}}};var ae=function(){var e=this,t=e._self._c;return t("div",{staticClass:"flex flex-col h-full"},[e.fileName?e._e():t("div",{staticClass:"flex-1 flex items-center justify-center text-textMuted"},[e._m(0)]),t("div",{directives:[{name:"show",rawName:"v-show",value:e.fileName,expression:"fileName"}],ref:"editorContainer",staticClass:"monaco-editor-container flex-1"}),e.fileName?t("div",{staticClass:"h-8 bg-sidebar border-t border-border flex items-center justify-between px-3 shrink-0"},[t("div",{staticClass:"flex items-center gap-4 text-xs text-textMuted"},[t("span",[e._v(e._s(e.fileName))]),e.contentChanged?t("span",{staticClass:"text-yellow-500"},[e._v("已修改")]):e._e()]),t("div",{staticClass:"flex items-center gap-2"},[t("button",{staticClass:"p-1 text-textMuted hover:text-white text-xs rounded hover:bg-white/10 transition-colors",attrs:{title:"刷新内容"},on:{click:function(i){return e.$emit("refresh")}}},[t("i",{staticClass:"fa-solid fa-refresh"})]),t("button",{staticClass:"px-3 py-1 text-xs bg-accent text-white rounded hover:bg-blue-600 disabled:opacity-50 disabled:cursor-not-allowed",attrs:{disabled:!e.contentChanged||e.saving},on:{click:e.saveFile}},[e.saving?t("i",{staticClass:"fa-solid fa-spinner fa-spin mr-1"}):t("i",{staticClass:"fa-solid fa-save mr-1"}),e._v(" 保存 ")])])]):e._e()])},ne=[function(){var s=this,e=s._self._c;return e("div",{staticClass:"text-center"},[e("i",{staticClass:"fa-solid fa-file-code text-6xl mb-4 opacity-20 block"}),e("p",[s._v("双击左侧 HTML 文件编辑")])])}],le=o(ie,ae,ne,!1,null,"f53b2118");const re=le.exports,oe={name:"SaveTemplateDialog",props:{visible:{type:Boolean,default:!1},currentFilePath:{type:String,default:""},currentFileName:{type:String,default:""}},data(){return{templateName:"",saving:!1}},computed:{defaultName(){return this.currentFileName||""}},watch:{visible(s){s&&(this.templateName=this.currentFileName?this.currentFileName.replace(/\.html$/i,"")+"_模版":"",this.$nextTick(()=>{const e=this.$refs.nameInput;e&&(e.focus(),e.select())}))}},methods:{async handleConfirm(){var e;const s=this.templateName.trim();if(!(!s||this.saving)){this.saving=!0;try{let t=s;t.endsWith(".html")||(t+=".html");const a=((e=(await l.getFileContent(this.currentFilePath)).data)==null?void 0:e.content)||"",n=`.txcode/design/.template/${t}`;await l.writeFile(n,a),this.$message.success("模版保存成功"),this.$emit("success"),this.$emit("update:visible",!1)}catch(t){console.error("Save template failed:",t),this.$message.error("模版保存失败: "+(t.message||"未知错误"))}finally{this.saving=!1}}},handleClose(){this.$emit("update:visible",!1),this.$emit("close")},handleCancel(){this.$emit("update:visible",!1)},handleVisibleChange(s){this.$emit("update:visible",s)}}};var ce=function(){var e=this,t=e._self._c;return t("el-dialog",{attrs:{visible:e.visible,title:"保存为模版",width:"420px","close-on-click-modal":!1},on:{"update:visible":e.handleVisibleChange,close:e.handleClose}},[t("div",{staticClass:"save-template-content"},[t("div",{staticClass:"form-item"},[t("label",{staticClass:"form-label"},[e._v("模版名称")]),t("input",{directives:[{name:"model",rawName:"v-model",value:e.templateName,expression:"templateName"}],ref:"nameInput",staticClass:"form-input",attrs:{placeholder:e.defaultName||"输入模版名称"},domProps:{value:e.templateName},on:{keyup:function(i){return!i.type.indexOf("key")&&e._k(i.keyCode,"enter",13,i.key,"Enter")?null:e.handleConfirm.apply(null,arguments)},input:function(i){i.target.composing||(e.templateName=i.target.value)}}}),e.currentFileName?t("p",{staticClass:"form-hint"},[e._v("当前页面:"+e._s(e.currentFileName))]):e._e()]),t("div",{staticClass:"save-template-footer"},[t("button",{staticClass:"confirm-btn",attrs:{disabled:!e.templateName.trim()||e.saving},on:{click:e.handleConfirm}},[e._v(e._s(e.saving?"保存中...":"确定"))]),t("button",{staticClass:"cancel-btn",on:{click:e.handleCancel}},[e._v("取消")])])])])},de=[],he=o(oe,ce,de,!1,null,"30bde40e");const ue=he.exports,pe={name:"DesignView",components:{DesignSidebar:G,DesignPreview:se,DesignEditor:re,SaveTemplateDialog:ue},data(){return{rightTab:"preview",designBasePath:".txcode/design",fileContent:"",activeFileName:"",activeFilePath:"",relativePath:"",hasChanges:!1,templateDialogVisible:!1,isResizing:!1,aiStatus:"idle",unsubFileChanged:null}},mounted(){document.addEventListener("mousemove",this.handleResize),document.addEventListener("mouseup",this.stopResize),this.updateTitle(),this.initFromRoute(),this.unsubFileChanged=S.on("file:changed",s=>{this.onFileChanged(s)}),console.log("[DesignView][mounted] subscribed to file:changed")},watch:{rightTab(s){console.log("[DesignView] rightTab changed:",s),s==="editor"&&this.activeFilePath&&!this.fileContent&&(console.log("[DesignView] switching to editor, loading file content for:",this.activeFilePath),this.loadFileContent()),s==="editor"&&this.$nextTick(()=>{this.$refs.editor&&this.$refs.editor.layout()})},aiStatus(){this.updateTitle()},"$route.query.page":{handler(s){s&&s.endsWith(".html")&&s!==this.relativePath&&this.openDesignPage(s)}}},beforeDestroy(){document.removeEventListener("mousemove",this.handleResize),document.removeEventListener("mouseup",this.stopResize),this.unsubFileChanged&&(this.unsubFileChanged(),this.unsubFileChanged=null)},methods:{updateTitle(){var t;const s=((t=this.$route.meta)==null?void 0:t.title)||"AI设计";let e="";this.aiStatus==="processing"?e="⏳ ":this.aiStatus==="completed"&&(e="✅ "),document.title=`${e}${s} - TXCode`},initFromRoute(){const s=this.$route.query.page;s&&s.endsWith(".html")&&this.$nextTick(()=>{this.openDesignPage(s)})},onPreviewNavigate(s){this.openDesignPage(s)},onAiStatusChange(s){this.aiStatus=s,this.updateTitle()},openDesignPage(s){!s||!s.endsWith(".html")||(console.log("[DesignView] openDesignPage:",s),this.relativePath=s,this.activeFileName=s.split("/").pop(),this.activeFilePath=this.designBasePath+"/"+s,this.fileContent="",this.hasChanges=!1,this.rightTab="preview",this.$refs.sidebar&&this.$refs.sidebar.setCurrentPage(s),this.$route.query.page!==s&&this.$router.replace({query:{page:s}}).catch(()=>{}))},async openFile(s){if(console.log("[DesignView] openFile called, node:",s.name,"path:",s.path,"is_dir:",s.is_directory),s.is_directory)return;this.activeFilePath=s.path;const e=this.extractRelativePath(s.path);console.log("[DesignView] extractRelativePath result:",e),this.openDesignPage(e),console.log("[DesignView] openFile done, relativePath:",this.relativePath)},async loadFileContent(){var s;if(this.activeFilePath){console.log("[DesignView] loadFileContent:",this.activeFilePath);try{const e=performance.now(),t=await l.getFileContent(this.activeFilePath);console.log("[DesignView] getFileContent took:",(performance.now()-e).toFixed(1),"ms"),this.fileContent=((s=t.data)==null?void 0:s.content)||""}catch(e){console.error("[DesignView] loadFileContent failed:",e),this.fileContent=""}}},onContentChanged(s){this.hasChanges=s},onContentSaved(s){this.fileContent=s,this.hasChanges=!1},async refreshCurrentFile(){this.activeFilePath&&(console.log("[DesignView] refreshCurrentFile:",this.activeFilePath),await this.loadFileContent(),this.$refs.editor&&this.rightTab==="editor"&&this.$refs.editor.updateContent(this.fileContent))},onFileChanged(s){if(console.log("[DesignView] file:changed received",s),!s.filePath||!this.activeFilePath){console.log("[DesignView] file:changed skipped (no filePath or activeFilePath)");return}const e=s.filePath.replace(/\\/g,"/"),t=this.activeFilePath.replace(/\\/g,"/"),i=(this.designBasePath||".txcode/design").replace(/\\/g,"/");if(e.indexOf(i)===-1&&t.indexOf(e)===-1){console.log("[DesignView] file:changed skipped (not in designBasePath)");return}console.log("[DesignView] file:changed → refreshCurrentFile()"),this.$refs.preview&&this.$refs.preview.refreshPreview()},saveAsTemplate(){if(!this.activeFilePath){this.$message.warning("请先打开一个设计页面");return}this.templateDialogVisible=!0},onTemplateSaved(){},extractRelativePath(s){const e=["/.txcode/design/",".txcode/design/","\\.txcode\\design\\",".txcode\\design\\"];for(const t of e){const i=s.indexOf(t);if(i!==-1)return s.slice(i+t.length).replace(/\\/g,"/")}return""},startResize(s){this.isResizing=!0,document.body.style.cursor="col-resize",document.body.style.userSelect="none"},handleResize(s){if(!this.isResizing)return;const e=this.$refs.sidebar;if(!e)return;const t=s.clientX;t>=150&&t<=800&&(e.$el.style.width=t+"px")},stopResize(){this.isResizing=!1,document.body.style.cursor="",document.body.style.userSelect=""}}};var fe=function(){var e=this,t=e._self._c;return t("div",{staticClass:"flex-1 flex overflow-hidden"},[t("DesignSidebar",{ref:"sidebar",attrs:{"base-path":e.designBasePath},on:{"open-file":e.openFile,"file-changed":e.refreshCurrentFile,"ai-status-change":e.onAiStatusChange}}),t("div",{staticClass:"w-1 bg-border hover:bg-accent cursor-col-resize transition-colors",on:{mousedown:e.startResize}}),t("main",{staticClass:"flex-1 flex flex-col min-w-0 bg-contentBg"},[t("div",{staticClass:"flex border-b border-border bg-sidebar"},[t("div",{staticClass:"flex items-center"},[t("div",{staticClass:"px-4 py-2 cursor-pointer border-r border-border text-sm",class:e.rightTab==="preview"?"bg-contentBg text-white border-t-2 border-t-accent":"text-textMuted hover:bg-hoverBg",on:{click:function(i){e.rightTab="preview"}}},[t("i",{staticClass:"fa-solid fa-eye mr-1"}),e._v(" 预览 ")]),t("div",{staticClass:"px-4 py-2 cursor-pointer border-r border-border text-sm",class:e.rightTab==="editor"?"bg-contentBg text-white border-t-2 border-t-accent":"text-textMuted hover:bg-hoverBg",on:{click:function(i){e.rightTab="editor"}}},[t("i",{staticClass:"fa-solid fa-code mr-1"}),e._v(" 编辑 ")])])]),t("div",{staticClass:"flex-1 overflow-hidden"},[t("DesignPreview",{directives:[{name:"show",rawName:"v-show",value:e.rightTab==="preview",expression:"rightTab === 'preview'"}],ref:"preview",attrs:{"file-content":e.fileContent,"file-name":e.activeFileName,"relative-path":e.relativePath},on:{navigate:e.onPreviewNavigate,"save-template":e.saveAsTemplate}}),t("DesignEditor",{directives:[{name:"show",rawName:"v-show",value:e.rightTab==="editor",expression:"rightTab === 'editor'"}],ref:"editor",attrs:{"file-content":e.fileContent,"file-name":e.activeFileName,"file-path":e.activeFilePath},on:{"content-changed":e.onContentChanged,"content-saved":e.onContentSaved,refresh:e.refreshCurrentFile}})],1),t("div",{staticClass:"h-8 bg-sidebar border-t border-border flex items-center px-3"},[t("div",{staticClass:"flex items-center gap-4 text-xs text-textMuted"},[e.activeFilePath?t("span",[e._v(e._s(e.activeFilePath))]):t("span",{staticClass:"text-textMuted"},[e._v("双击左侧文件打开")]),e.hasChanges?t("span",{staticClass:"text-yellow-500"},[e._v("已修改")]):e._e()])])]),t("SaveTemplateDialog",{attrs:{visible:e.templateDialogVisible,"current-file-path":e.activeFilePath,"current-file-name":e.activeFileName},on:{"update:visible":function(i){e.templateDialogVisible=i},success:e.onTemplateSaved}})],1)},me=[],ge=o(pe,fe,me,!1,null,null);const xe=ge.exports;export{xe as default};
@@ -0,0 +1 @@
1
+ .sidebar-scroll[data-v-d033f82c]::-webkit-scrollbar{width:8px}.sidebar-scroll[data-v-d033f82c]::-webkit-scrollbar-track{background:transparent}.sidebar-scroll[data-v-d033f82c]::-webkit-scrollbar-thumb{background:var(--color-border);border-radius:4px}.sidebar-scroll[data-v-d033f82c]::-webkit-scrollbar-thumb:hover{background:#505050}.template-select-content[data-v-2152b684]{height:360px;display:flex;flex-direction:column}.template-search[data-v-2152b684]{margin-bottom:10px}.search-input[data-v-2152b684]{width:100%;padding:8px 12px;background:#27272a;border:1px solid #3f3f46;border-radius:4px;color:#d4d4d8;font-size:13px;outline:none;box-sizing:border-box}.search-input[data-v-2152b684]:focus{border-color:#3b82f6}.template-list-container[data-v-2152b684]{flex:1;overflow-y:auto;border:1px solid #3f3f46;border-radius:4px}.empty-state[data-v-2152b684]{padding:30px;text-align:center;color:#71717a;font-size:13px}.template-item[data-v-2152b684]{padding:10px 12px;cursor:pointer;border-bottom:1px solid #27272a}.template-item[data-v-2152b684]:hover{background:#27272a}.template-item.template-selected[data-v-2152b684]{background:#1e3a5f;border-left:2px solid #3b82f6}.template-name[data-v-2152b684]{color:#d4d4d8;font-size:13px;font-weight:500}.template-path[data-v-2152b684]{color:#71717a;font-size:11px;margin-top:2px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.template-select-footer[data-v-2152b684]{margin-top:10px;display:flex;gap:8px;align-items:center}.selected-template[data-v-2152b684]{flex:1;padding:8px 12px;background:#27272a;color:#a1a1aa;font-size:13px;border-radius:4px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.confirm-btn[data-v-2152b684]{padding:8px 16px;background:#3b82f6;border:none;border-radius:4px;color:#fff;font-size:13px;cursor:pointer}.confirm-btn[data-v-2152b684]:hover{background:#2563eb}.confirm-btn[data-v-2152b684]:disabled{opacity:.5;cursor:not-allowed}[data-v-2152b684] .el-dialog{background:#18181b;border:1px solid #3f3f46}[data-v-2152b684] .el-dialog__header{background:#18181b;border-bottom:1px solid #3f3f46;padding:16px 20px}[data-v-2152b684] .el-dialog__title{color:#d4d4d8;font-size:15px;font-weight:500}[data-v-2152b684] .el-dialog__headerbtn{top:16px;right:16px}[data-v-2152b684] .el-dialog__headerbtn .el-dialog__close{color:#71717a}[data-v-2152b684] .el-dialog__headerbtn:hover .el-dialog__close{color:#fff}[data-v-2152b684] .el-dialog__body{background:#18181b;padding:20px;color:#d4d4d8}.chat-messages[data-v-604068dd]::-webkit-scrollbar{width:6px}.chat-messages[data-v-604068dd]::-webkit-scrollbar-track{background:transparent}.chat-messages[data-v-604068dd]::-webkit-scrollbar-thumb{background:#404040;border-radius:3px}.chat-messages[data-v-604068dd]::-webkit-scrollbar-thumb:hover{background:#505050}.chat-messages[data-v-604068dd]{padding:0 16px 16px;font-size:14px;line-height:1.6}.user-question[data-v-604068dd]{color:#60a5fa;font-weight:700;border:1px solid #60a5fa;padding:15px;margin:15px;border-radius:10px;display:inline-block;max-width:80%;text-align:left}.ai-thought[data-v-604068dd]{color:#d4d4d8;margin-bottom:16px}.log-mute[data-v-604068dd]{color:#84848a;margin-bottom:16px;white-space:pre}.tool-input[data-v-604068dd]{color:#60a5fa;margin-left:8px}.build-info[data-v-604068dd]{color:#84848a;display:flex;align-items:center;gap:8px;margin-bottom:16px}.chat-images[data-v-604068dd]{display:flex;gap:8px;flex-wrap:wrap;margin-bottom:10px}.chat-image-thumb[data-v-604068dd]{width:120px;height:120px;-o-object-fit:cover;object-fit:cover;border-radius:6px;border:1px solid #3f3f46;cursor:zoom-in;transition:border-color .2s}.chat-image-thumb[data-v-604068dd]:hover{border-color:#60a5fa}.chat-input-area[data-v-604068dd]{padding:12px 16px;background:#121212;border-top:1px solid #1e1e1e}.input-panel[data-v-604068dd]{background:#fff;border-radius:6px;border:1px solid #e0e0e0;overflow:hidden}.input-wrapper[data-v-604068dd]{position:relative}.input-area[data-v-604068dd]{flex:1}.input-area[data-v-604068dd] .el-textarea__inner{border:none;border-radius:0;background:#fff;color:#4b5563;resize:none}.input-area[data-v-604068dd] .el-textarea__inner:focus{box-shadow:none}.input-panel .input-actions[data-v-604068dd]{display:flex;justify-content:space-between;align-items:center;padding:6px 12px;gap:6px;background:#fff}.input-actions-left[data-v-604068dd],.input-actions-right[data-v-604068dd]{display:flex;align-items:center;gap:6px}.input-panel .status-action[data-v-604068dd]{cursor:pointer;font-size:12px;color:#6b7280}.input-panel .status-action[data-v-604068dd]:hover{color:#60a5fa}.input-panel .separator[data-v-604068dd]{color:#d1d5db;font-size:12px}.status-bar[data-v-604068dd]{display:flex;gap:8px;align-items:center;padding:6px 16px;font-size:12px;color:#84848a;border-top:1px solid #1e1e1e;flex-shrink:0;flex-wrap:wrap;background:#0a0a09}.status-bar .separator[data-v-604068dd]{color:#3f3f46}.status-ready[data-v-604068dd]{color:#22c55e}.status-thinking[data-v-604068dd]{color:#60a5fa}.model-selector[data-v-604068dd]{cursor:pointer}.model-selector[data-v-604068dd]:hover{color:#60a5fa}.thinking-spinner[data-v-604068dd]{display:inline-block;width:12px;height:12px;border:2px solid #60a5fa;border-top-color:transparent;border-radius:50%;animation:spin-604068dd .8s linear infinite}@keyframes spin-604068dd{to{transform:rotate(360deg)}}.tool-spinner[data-v-604068dd]{display:inline-block;width:12px;height:12px;border:2px solid var(--color-border);border-top-color:var(--color-accent);border-radius:50%;animation:spin-604068dd .8s linear infinite;margin-right:6px;vertical-align:middle}.device-frame[data-v-39c9eda3]{height:100%;max-width:100%}.device-frame>iframe[data-v-39c9eda3]{flex:1;min-height:0}.device-frame-app[data-v-39c9eda3]{position:relative;background:#1a1a1a;border-radius:36px;padding:8px;box-shadow:0 0 0 2px #333,0 0 0 4px #1a1a1a,0 0 0 6px #444,0 20px 40px #00000080}.device-frame-app[data-v-39c9eda3]:before{content:"";position:absolute;top:4px;left:50%;transform:translate(-50%);width:120px;height:25px;background:#1a1a1a;border-radius:0 0 16px 16px;z-index:10}.device-frame-app[data-v-39c9eda3]:after{content:"";position:absolute;bottom:4px;left:50%;transform:translate(-50%);width:100px;height:4px;background:#444;border-radius:2px;z-index:10}.device-frame-web[data-v-39c9eda3]{width:100%;background:#2d2d2d;border-radius:12px;padding:12px;box-shadow:0 4px 20px #0006}.device-frame-pad[data-v-39c9eda3]{background:#1a1a1a;border-radius:16px;padding:10px;box-shadow:0 0 0 2px #444,0 0 0 4px #2a2a2a,0 0 0 6px #555,0 20px 40px #00000080}.monaco-editor-container[data-v-f53b2118]{width:100%;overflow:hidden}.monaco-editor-container[data-v-f53b2118] .monaco-editor{padding-top:8px}.monaco-editor-container[data-v-f53b2118] .monaco-editor .overflow-guard{overflow:hidden!important}.save-template-content[data-v-30bde40e]{display:flex;flex-direction:column;gap:16px}.form-item[data-v-30bde40e]{display:flex;flex-direction:column;gap:6px}.form-label[data-v-30bde40e]{color:#d4d4d8;font-size:13px}.form-input[data-v-30bde40e]{width:100%;padding:8px 12px;background:#27272a;border:1px solid #3f3f46;border-radius:4px;color:#d4d4d8;font-size:13px;outline:none;box-sizing:border-box}.form-input[data-v-30bde40e]:focus{border-color:#3b82f6}.form-hint[data-v-30bde40e]{color:#71717a;font-size:12px;margin:0}.save-template-footer[data-v-30bde40e]{display:flex;justify-content:flex-end;gap:8px}.cancel-btn[data-v-30bde40e]{padding:8px 16px;background:#27272a;border:1px solid #3f3f46;border-radius:4px;color:#d4d4d8;font-size:13px;cursor:pointer}.cancel-btn[data-v-30bde40e]:hover{background:#3f3f46}.confirm-btn[data-v-30bde40e]{padding:8px 16px;background:#3b82f6;border:none;border-radius:4px;color:#fff;font-size:13px;cursor:pointer}.confirm-btn[data-v-30bde40e]:hover{background:#2563eb}.confirm-btn[data-v-30bde40e]:disabled{opacity:.5;cursor:not-allowed}[data-v-30bde40e] .el-dialog{background:#18181b;border:1px solid #3f3f46}[data-v-30bde40e] .el-dialog__header{background:#18181b;border-bottom:1px solid #3f3f46;padding:16px 20px}[data-v-30bde40e] .el-dialog__title{color:#d4d4d8;font-size:15px;font-weight:500}[data-v-30bde40e] .el-dialog__headerbtn{top:16px;right:16px}[data-v-30bde40e] .el-dialog__headerbtn .el-dialog__close{color:#71717a}[data-v-30bde40e] .el-dialog__headerbtn:hover .el-dialog__close{color:#fff}[data-v-30bde40e] .el-dialog__body{background:#18181b;padding:20px;color:#d4d4d8}
@@ -0,0 +1,36 @@
1
+ import{n as d,I as g,R as m,D as f,S as v,M as C,g as p,a,s as y,b as S,F as k,c as I,e as D,K as P,d as x,f as M}from"./index-B6eYD1o1.js";import{m as _}from"./mediaChat-DPuTKoES.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(o){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:[_()],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,o=this.inputMessage;this.inputMessage=o.substring(0,t)+`
2
+ `+o.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 a.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 a.getFileContent(this.sessionFilePath);let t={};e&&((s=e.data)!=null&&s.content)&&(t=JSON.parse(e.data.content)),t.designDiscussions=this.discussions,await a.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 o=`探讨${this.discussions.length+1}`,n=await a.createSession(o),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:o,createdAt:new Date().toISOString()};this.discussions.push(l),await this.saveDiscussions(),this.dropdownOpen=!1,await this.switchDiscussion(l)}catch(o){console.error("Create discussion failed:",o),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 a.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
+
4
+ 这个是对这个方案的探讨 你只需要回答用户的问题即可 不需要修改方案 也不要修改代码
5
+
6
+ 用户输入: ${s}`;this.inputMessage="",this.disabled=!0,this.stopping=!1;const i=(this.mediaFiles||[]).filter(o=>!o.uploading&&o.filePath).map(o=>({filePath:o.filePath,type:o.type,dataUrl:o.dataUrl}));this.logItems.push({type:"chat",content:s,mediaFiles:i}),this.scrollChatToBottom(!0),a.sessionWsSend(this.currentDiscussion.sessionId,"chat",{message:t,sessionId:this.currentDiscussion.sessionId,modelName:this.modelName||void 0,agent:"discuss",mediaFiles:i.map(o=>({filePath:o.filePath,type:o.type}))}),this.mediaFiles=[]},stopChat(){!this.currentDiscussion||!this.currentDiscussion.sessionId||this.stopping||(this.stopping=!0,a.sessionWsSend(this.currentDiscussion.sessionId,"stop",{sessionId:this.currentDiscussion.sessionId}))},subscribeSession(){!this.currentDiscussion||!this.currentDiscussion.sessionId||(this.wsUnsubscribe&&this.wsUnsubscribe(),this.wsUnsubscribe=a.wsSubscribe(this.currentDiscussion.sessionId,{running_sessions:s=>{const t=((s==null?void 0:s.runningSessionIds)||[]).includes(this.currentDiscussion.sessionId);this.sessionStatus=t?"processing":"idle",this.disabled=t},todos:s=>{s!=null&&s.todos&&this.logItems.push({type:"todos",todos:s.todos}),this.scrollChatToBottom()},step:s=>{var t,i;((t=s.toolCalls)==null?void 0:t.some(o=>o.status==="executing"))?(this.logItems=this.logItems.filter(o=>!(o.type==="step"&&o.iteration===s.iteration&&o._executing)),this.logItems.push({type:"step",thought:s.reasoning||s.thought,toolCalls:s.toolCalls,success:s.success,iteration:s.iteration,_executing:!0})):(this.logItems=this.logItems.filter(o=>!(o.type==="step"&&o.iteration===s.iteration&&o._executing)),this.logItems.push({type:"step",thought:s.thought,toolCalls:s.toolCalls,success:s.success})),(i=s.usage)!=null&&i.promptTokens&&(this.promptTokens=s.usage.promptTokens),this.scrollChatToBottom()},compact:s=>{this.logItems.push({type:"system",content:`【压缩完成】${s.summary||""}`}),this.loadMessages()},done:s=>{var e;this.logItems=this.logItems.filter(t=>!(t.type==="step"&&t._executing)),this.disabled=!1,this.stopping=!1,this.sessionStatus="completed",s!=null&&s.modelName&&(this.modelName=s.modelName),(e=s==null?void 0:s.usage)!=null&&e.promptTokens&&(this.promptTokens=s.usage.promptTokens),s!=null&&s.response&&this.logItems.push({type:"think",content:s.response}),this.scrollChatToBottom()},stopped:()=>{this.logItems=this.logItems.filter(s=>!(s.type==="step"&&s._executing)),this.disabled=!1,this.stopping=!1,this.sessionStatus="idle",this.logItems.push({type:"think",content:"【已停止】"}),this.scrollChatToBottom()},error:s=>{this.logItems=this.logItems.filter(e=>!(e.type==="step"&&e._executing)),this.$message.error((s==null?void 0:s.error)||"发生错误"),this.disabled=!1,this.stopping=!1,this.sessionStatus="idle"}}))},scrollChatToBottom(s=!1){const e=y(this.$refs.messagesContainer);this.$nextTick(()=>{S(this.$refs.messagesContainer,{force:s,prevSnapshot:e})})},async loadMessages(){if(!(!this.currentDiscussion||!this.currentDiscussion.sessionId))try{const s=await a.getMessages(this.currentDiscussion.sessionId);this.logItems=s.data||[],this.scrollChatToBottom(!0)}catch(s){console.error("Load messages failed:",s)}},async loadDefaultModel(){var s;try{const e=await a.getConfig("defaultModel");(s=e.data)!=null&&s.value&&(this.modelName=e.data.value)}catch(e){console.error("Load default model failed:",e)}},openModelSelector(){this.modelSelectVisible=!0},onModelSelected(s){const e=s.name.split("/");this.modelName=e.length>2?e.slice(1).join("/"):s.name,a.setConfig("defaultModel",this.modelName)},openSkillSelect(){const s=this.$el.querySelector(".input-area textarea");this.skillCursorPos=s?s.selectionStart:-1,this.skillSelectVisible=!0},onSkillSelected(s){const e=`[${s}] `,t=this.skillCursorPos>=0?this.skillCursorPos:0;this.inputMessage=this.inputMessage.slice(0,t)+e+this.inputMessage.slice(t),this.skillSelectVisible=!1},openDesignSelect(){this.designSelectVisible=!0},onDesignSelected(s){const e=`[设计:${s.name}](${s.path}) `;this.inputMessage+=e,this.designSelectVisible=!1},getTodoStatusIcon(s){return{completed:"✅",in_progress:"🔄",pending:"⬜",cancelled:"❌"}[s]||"⬜"},formatInput(s,e){try{const t=JSON.parse(e);return s==="bash"||s==="execute_bash"?t.command+(t.workdir?` (${t.workdir})`:""):s==="read_file"?t.file_path+(t.offset?`:${t.offset}`:""):s==="edit_file"||s==="write_file"?t.file_path:s==="glob"||s==="find_files"?t.pattern+(t.directory?` (${t.directory})`:""):s==="grep"||s==="search_content"?`"${t.pattern}" (${t.directory||""})`:e}catch{return e}},renderMarkdown(s){return s?p(s):""}}};var E=function(){var e=this,t=e._self._c;return t("div",{staticClass:"discuss-container"},[e.discussions.length>0?t("div",{staticClass:"discuss-dropdown"},[t("div",{staticClass:"dropdown-trigger",on:{click:function(i){e.dropdownOpen=!e.dropdownOpen}}},[t("span",{staticClass:"dropdown-title"},[e._v(e._s(e.currentDiscussion?e.currentDiscussion.title:"选择探讨"))]),t("i",{staticClass:"el-icon-arrow-down",class:{rotated:e.dropdownOpen}})]),e.dropdownOpen?t("div",{staticClass:"dropdown-menu"},[e._l(e.discussions,function(i){return t("div",{key:i.id,staticClass:"dropdown-item",class:{active:e.currentDiscussion&&e.currentDiscussion.id===i.id}},[t("span",{staticClass:"item-title",on:{click:function(o){return e.switchDiscussion(i)}}},[e._v(e._s(i.title))]),t("span",{staticClass:"item-actions",on:{click:function(o){o.stopPropagation()}}},[t("span",{staticClass:"menu-trigger",on:{click:function(o){o.stopPropagation(),e.activeMenuId=e.activeMenuId===i.id?null:i.id}}},[e._v("⋮")]),e.activeMenuId===i.id?t("div",{staticClass:"menu-popup"},[t("div",{staticClass:"menu-item",on:{click:function(o){return o.stopPropagation(),e.startRename(i)}}},[e._v("重命名")]),t("div",{staticClass:"menu-item danger",on:{click:function(o){return o.stopPropagation(),e.confirmDelete(i)}}},[e._v("删除")])]):e._e()])])}),t("div",{staticClass:"dropdown-item add-item",on:{click:e.createDiscussion}},[t("i",{staticClass:"el-icon-plus"}),e._v(" 新建探讨 ")])],2):e._e()]):e._e(),!e.currentDiscussion&&e.discussions.length===0?t("div",{staticClass:"empty-discuss"},[t("div",{staticClass:"empty-card",on:{click:e.createDiscussion}},[t("i",{staticClass:"el-icon-chat-dot-round"}),t("p",[e._v("新建探讨")]),t("span",[e._v("点击创建第一个方案探讨会话")])])]):e._e(),e.currentDiscussion?[t("div",{ref:"messagesContainer",staticClass:"chat-messages"},[e.logItems.length?e._e():t("div",{staticClass:"empty-state"},[t("i",{staticClass:"el-icon-chat-dot-round"}),t("p",[e._v("与AI探讨方案内容,不会修改方案文件")])]),e._l(e.logItems,function(i,o){return[i.type==="todos"?t("div",{staticClass:"todos-list"},e._l(i.todos,function(n,l){return t("div",{key:l,staticClass:"todo-item"},[t("span",{staticClass:"todo-status"},[e._v(e._s(e.getTodoStatusIcon(n.status)))]),t("span",{staticClass:"todo-name"},[e._v(e._s(n.name))])])}),0):e._e(),i.type==="chat"?t("div",{staticClass:"flex justify-end"},[t("div",{staticClass:"user-question"},[i.mediaFiles&&i.mediaFiles.length>0?t("div",{staticClass:"chat-images"},e._l(i.mediaFiles,function(n){return t("img",{key:n.filePath,staticClass:"chat-image-thumb",attrs:{src:n.url||n.dataUrl||n.filePath},on:{click:function(l){return l.stopPropagation(),e.openImagePreview(n)}}})}),0):e._e(),t("div",[e._v(e._s(i.content))])])]):i.type==="system"?t("div",{staticClass:"system-message",domProps:{innerHTML:e._s(e.renderMarkdown(i.content))}}):i.type==="step"?[i.thought?t("div",{staticClass:"ai-thought",domProps:{innerHTML:e._s(e.renderMarkdown(i.thought))}}):e._e(),e._l(i.toolCalls,function(n,l){return t("div",{key:l,staticClass:"log-mute"},[n.status==="executing"?[t("span",{staticClass:"tool-spinner"}),e._v(" "+e._s(n.function.name)+" "),n.function.arguments?t("span",{staticClass:"tool-input"},[e._v(e._s(e.formatInput(n.function.name,n.function.arguments)))]):e._e()]:[t("span",{class:i.success!==!1?"tool-success":"tool-fail"},[e._v(" "+e._s(i.success!==!1?"✓":"✗")+" ")]),e._v(" "+e._s(n.function.name)+" "),n.function.arguments?t("span",{staticClass:"tool-input"},[e._v(e._s(e.formatInput(n.function.name,n.function.arguments)))]):e._e()]],2)})]:i.type==="think"?t("div",{staticClass:"ai-thought",domProps:{innerHTML:e._s(e.renderMarkdown(i.content))}}):e._e()]}),e.modelName?t("div",{staticClass:"build-info"},[t("span",{staticClass:"icon"},[e._v("▣")]),e._v(" Build · "+e._s(e.modelName)+" ")]):e._e()],2),t("div",{staticClass:"chat-input-area"},[e.mediaFiles&&e.mediaFiles.length>0?t("ImagePreviewList",{attrs:{files:e.mediaFiles,disabled:e.disabled},on:{remove:e.removeMedia}}):e._e(),t("div",{staticClass:"input-panel"},[t("div",{staticClass:"input-wrapper"},[t("ResizableTextarea",{staticClass:"input-area",attrs:{rows:5,placeholder:"输入探讨内容... (Enter 发送, Ctrl+Enter 换行)",disabled:e.disabled&&!e.stopping},on:{"paste-image":e.handlePasteImages},nativeOn:{keydown:function(i){return!i.type.indexOf("key")&&e._k(i.keyCode,"enter",13,i.key,"Enter")?null:e.handleKeydown.apply(null,arguments)}},model:{value:e.inputMessage,callback:function(i){e.inputMessage=i},expression:"inputMessage"}}),t("input",{ref:"mediaInput",staticStyle:{display:"none"},attrs:{type:"file",accept:"image/*",multiple:""},on:{change:e.handleImageSelected}})],1),t("div",{staticClass:"input-actions"},[t("span",{staticClass:"status-action",on:{click:e.openSkillSelect,mousedown:function(i){i.preventDefault()}}},[e._v("选择Skill")]),t("span",{staticClass:"separator"},[e._v("|")]),t("span",{staticClass:"status-action",on:{click:e.openDesignSelect,mousedown:function(i){i.preventDefault()}}},[e._v("选择设计")]),t("span",{staticClass:"separator"},[e._v("|")]),t("el-button",{staticClass:"upload-btn",attrs:{disabled:e.disabled,size:"small"},on:{click:e.handleImageUpload}},[e._v("图片")]),e.disabled&&!e.stopping?t("el-button",{staticClass:"stop-btn",attrs:{type:"danger",size:"small"},on:{click:e.stopChat}},[e._v(" ■ 停止 ")]):e.stopping?t("el-button",{staticClass:"stop-btn",attrs:{type:"info",disabled:"",size:"small"}},[e._v(" 停止中... ")]):t("el-button",{staticClass:"send-btn",attrs:{type:"primary",disabled:!e.inputMessage.trim()&&e.mediaFiles.length===0,size:"small"},on:{click:e.sendMessage}},[e._v(" 发送 ")])],1)])],1),t("div",{staticClass:"status-bar"},[t("span",{class:e.sessionStatus==="processing"?"status-thinking":"status-ready"},[e.sessionStatus==="processing"?t("span",{staticClass:"thinking-spinner"}):e._e(),e._v(" "+e._s(e.sessionStatus==="processing"?"思考中":"✓ 就绪")+" ")]),t("span",{staticClass:"separator"},[e._v("|")]),t("span",{staticClass:"model-selector",on:{click:e.openModelSelector,mousedown:function(i){i.preventDefault()}}},[e._v(" 模型:"+e._s(e.modelName||"-")+" ▾ ")]),t("span",{staticClass:"separator"},[e._v("|")]),t("span",[e._v("会话:"+e._s(e.currentDiscussion.sessionId?e.currentDiscussion.sessionId.slice(0,8):"--------"))]),t("span",{staticClass:"separator"},[e._v("|")]),t("span",[e._v("token:"+e._s(e.promptTokens||0))])])]:e._e(),t("el-dialog",{attrs:{visible:e.deleteDialogVisible,title:"确认删除",width:"360px","close-on-click-modal":!1},on:{"update:visible":function(i){e.deleteDialogVisible=i}}},[t("p",[e._v("确定要删除探讨「"+e._s(e.deleteTarget?e.deleteTarget.title:"")+"」吗?此操作不可恢复。")]),t("span",{attrs:{slot:"footer"},slot:"footer"},[t("el-button",{on:{click:function(i){e.deleteDialogVisible=!1}}},[e._v("取消")]),t("el-button",{attrs:{type:"danger"},on:{click:e.doDelete}},[e._v("删除")])],1)]),t("ModelSelectDialog",{attrs:{visible:e.modelSelectVisible,"current-model":e.modelName},on:{"update:visible":function(i){e.modelSelectVisible=i},select:e.onModelSelected}}),t("SkillSelectDialog",{attrs:{visible:e.skillSelectVisible},on:{"update:visible":function(i){e.skillSelectVisible=i},select:e.onSkillSelected,close:function(i){e.skillSelectVisible=!1}}}),t("DesignSelectDialog",{attrs:{visible:e.designSelectVisible},on:{"update:visible":function(i){e.designSelectVisible=i},select:e.onDesignSelected,close:function(i){e.designSelectVisible=!1}}}),e.previewImage?t("div",{staticClass:"image-lightbox",on:{click:e.closeImagePreview}},[t("span",{staticClass:"lightbox-close",on:{click:e.closeImagePreview}},[e._v("×")]),t("img",{staticClass:"lightbox-image",attrs:{src:e.previewImage.url||e.previewImage.dataUrl||e.previewImage.filePath},on:{click:function(i){i.stopPropagation()}}})]):e._e()],2)},U=[],O=d(N,E,U,!1,null,"84c5f5eb");const A=O.exports,K={name:"Step2Design",components:{ModelSelectDialog:C,CommandDialog:I,FileSelectDialog:k,SkillSelectDialog:v,DesignSelectDialog:f,ResizableTextarea:m,ImagePreviewList:g,DesignDiscuss:A},mixins:[_()],props:{category:{type:String,default:""},name:{type:String,default:""},reqBasePath:{type:String,default:""}},data(){return{editor:null,specContent:"",inputMessage:"",disabled:!1,stopping:!1,promptTokens:0,logItems:[],modelName:"",modelSelectVisible:!1,commandDialogVisible:!1,fileSelectVisible:!1,skillSelectVisible:!1,designSelectVisible:!1,skillCursorPos:-1,sessionId:"",sessionStatus:"idle",customActions:[],chatTab:"assistant",parentInfo:null,chatPanelWidth:480,isResizing:!1,startX:0,startWidth:0,minChatWidth:320,maxChatWidthRatio:.6}},computed:{specFilePath(){return!this.category||!this.name?"等待选择需求...":`${this.reqBasePath}/${this.category}/${this.name}/${this.name}_方案.md`}},watch:{category:{handler(){this.loadData()}},name:{handler(){this.loadData()}},reqBasePath:{handler(s){s&&this.loadData()}}},async mounted(){document.addEventListener("mousemove",this.handleResize),document.addEventListener("mouseup",this.stopResize),this.initMonacoEditor(),await this.loadData(),await this.loadDefaultModel(),await this.loadCustomActions(),a.ws.init()},beforeDestroy(){document.removeEventListener("mousemove",this.handleResize),document.removeEventListener("mouseup",this.stopResize),this.editor&&(this.editor.dispose(),this.editor=null),this.wsUnsubscribe&&this.wsUnsubscribe()},methods:{handleKeydown(s){if(s.key==="Enter")if(s.ctrlKey){const e=s.target,t=e.selectionStart,i=e.selectionEnd,o=this.inputMessage;this.inputMessage=o.substring(0,t)+`
7
+ `+o.substring(i),this.$nextTick(()=>{e.selectionStart=e.selectionEnd=t+1})}else s.preventDefault(),this.sendMessage()},async loadData(){this.reqBasePath&&await Promise.all([this.loadSpec(),this.loadSession()])},async loadSpec(){var s;if(!this.category||!this.name){this.specContent=`# 选择或创建需求项目开始设计
8
+ `,this.syncEditorContent(this.specContent);return}try{const e=this.specFilePath,t=await a.getFileContent(e);this.specContent=((s=t.data)==null?void 0:s.content)||"",this.syncEditorContent(this.specContent)}catch(e){console.error("Load spec failed:",e),this.specContent="",this.syncEditorContent("")}},async loadSession(){var s;if(!this.category||!this.name){this.sessionId="",this.$emit("update:sessionId",""),this.parentInfo=null;return}try{const e=`${this.reqBasePath}/${this.category}/${this.name}/session.json`,t=await a.getFileContent(e);if(t&&((s=t.data)!=null&&s.content)){const i=JSON.parse(t.data.content);this.sessionId=i.designSessionId||"",this.parentInfo=i.parent||null}else this.sessionId="",this.parentInfo=null;this.$emit("update:sessionId",this.sessionId),this.sessionId?(await this.loadMessages(),this.subscribeSession()):this.logItems=[]}catch(e){console.error("Load session failed:",e),this.sessionId="",this.$emit("update:sessionId",""),this.parentInfo=null,this.logItems=[]}},syncEditorContent(s){if(!this.editor||s===void 0||s===null)return;const e=String(s);this.editor.getValue()!==e&&this.editor.setValue(e)},initMonacoEditor(){this.editor||this.$nextTick(()=>{this.createEditor()})},createEditor(){this.editor||(this.editor=D.create(this.$refs.editorContainer,{value:this.specContent||`# 选择或创建需求项目开始设计
9
+ `,language:"markdown",theme:"vs-dark",fontSize:14,fontFamily:"ui-monospace, SFMono-Regular, 'JetBrains Mono', Menlo, Monaco, Consolas, monospace",minimap:{enabled:!1},lineNumbers:"on",wordWrap:"on",scrollBeyondLastLine:!1,automaticLayout:!0,padding:{top:16},scrollbar:{verticalScrollbarSize:6,horizontalScrollbarSize:6,useShadows:!1}}),this.editor.addCommand(P.CtrlCmd|x.KeyS,()=>{this.saveSpec()}),this.syncEditorContent(this.specContent))},saveSpec(){if(!this.editor)return;const s=this.editor.getValue();this.$emit("save-spec",s)},async refreshSpec(){await this.loadSpec(),this.$message.success("方案已刷新")},exportScheme(){if(!this.category||!this.name){this.$message.warning("请先选择方案");return}const s=`${this.name}_方案.md`;a.downloadFilesystemWithProgress(this.specFilePath,s)},async sendMessage(){const s=this.inputMessage.trim(),e=this.mediaFiles&&this.mediaFiles.length>0;if(!s&&!e||this.disabled)return;if(!this.sessionId){this.$message.error("会话不存在,请刷新页面");return}this.wsUnsubscribe||this.subscribeSession();let t="";this.logItems.length===0&&this.parentInfo&&(t=`
10
+
11
+ 注意:当前方案是「${this.parentInfo.name}」的子方案,请参考父方案内容。父方案路径:${this.parentInfo.specPath}`);const i=`${t?t+`
12
+
13
+ `:""}用户输入: ${s}`;this.inputMessage="",this.disabled=!0,this.stopping=!1;const o=(this.mediaFiles||[]).filter(n=>!n.uploading&&n.filePath).map(n=>({filePath:n.filePath,type:n.type,dataUrl:n.dataUrl}));this.logItems.push({type:"chat",content:s,mediaFiles:o}),this.scrollChatToBottom(!0),a.sessionWsSend(this.sessionId,"chat",{message:i,sessionId:this.sessionId,modelName:this.modelName||void 0,agent:"plan",planFilePath:this.specFilePath,mediaFiles:o.map(n=>({filePath:n.filePath,type:n.type}))}),this.mediaFiles=[]},stopChat(){!this.sessionId||this.stopping||(this.stopping=!0,a.sessionWsSend(this.sessionId,"stop",{sessionId:this.sessionId}))},subscribeSession(){this.sessionId&&(this.wsUnsubscribe&&this.wsUnsubscribe(),this.wsUnsubscribe=a.wsSubscribe(this.sessionId,{running_sessions:s=>{const t=((s==null?void 0:s.runningSessionIds)||[]).includes(this.sessionId);this.sessionStatus=t?"processing":"idle",this.disabled=t},todos:s=>{var e;console.log("[Step2Design] WS todos event, todos count:",(e=s==null?void 0:s.todos)==null?void 0:e.length),s!=null&&s.todos&&this.logItems.push({type:"todos",todos:s.todos}),this.scrollChatToBottom()},step:s=>{var t,i,o;console.log("[Step2Design] WS step event, has thought:",!!s.thought,"toolCalls:",(t=s==null?void 0:s.toolCalls)==null?void 0:t.length),((i=s.toolCalls)==null?void 0:i.some(n=>n.status==="executing"))?(this.logItems=this.logItems.filter(n=>!(n.type==="step"&&n.iteration===s.iteration&&n._executing)),this.logItems.push({type:"step",thought:s.reasoning||s.thought,toolCalls:s.toolCalls,success:s.success,iteration:s.iteration,_executing:!0})):(this.logItems=this.logItems.filter(n=>!(n.type==="step"&&n.iteration===s.iteration&&n._executing)),this.logItems.push({type:"step",thought:s.thought,toolCalls:s.toolCalls,success:s.success})),(o=s.usage)!=null&&o.promptTokens&&(this.promptTokens=s.usage.promptTokens),this.scrollChatToBottom()},compact:s=>{this.logItems.push({type:"system",content:`【压缩完成】${s.summary||""}`}),this.loadMessages()},done:s=>{var e;console.log("[Step2Design] WS done event"),this.logItems=this.logItems.filter(t=>!(t.type==="step"&&t._executing)),this.disabled=!1,this.stopping=!1,this.sessionStatus="completed",s!=null&&s.modelName&&(this.modelName=s.modelName),(e=s==null?void 0:s.usage)!=null&&e.promptTokens&&(this.promptTokens=s.usage.promptTokens),s!=null&&s.response&&this.logItems.push({type:"think",content:s.response}),this.$emit("spec-updated"),this.scrollChatToBottom()},stopped:()=>{console.log("[Step2Design] WS stopped event"),this.logItems=this.logItems.filter(s=>!(s.type==="step"&&s._executing)),this.disabled=!1,this.stopping=!1,this.sessionStatus="idle",this.logItems.push({type:"think",content:"【已停止】"}),this.scrollChatToBottom()},error:s=>{this.logItems=this.logItems.filter(e=>!(e.type==="step"&&e._executing)),this.$message.error((s==null?void 0:s.error)||"发生错误"),this.disabled=!1,this.stopping=!1,this.sessionStatus="idle"}}))},scrollChatToBottom(s=!1){const e=y(this.$refs.messagesContainer);console.log("[Step2Design] scrollChatToBottom called, force:",s,"snap:",JSON.stringify(e)),this.$nextTick(()=>{S(this.$refs.messagesContainer,{force:s,prevSnapshot:e})})},async loadMessages(){if(this.sessionId)try{const s=await a.getMessages(this.sessionId);this.logItems=s.data||[],this.scrollChatToBottom(!0)}catch(s){console.error("Load messages failed:",s)}},async loadDefaultModel(){var s;try{const e=await a.getConfig("defaultModel");(s=e.data)!=null&&s.value&&(this.modelName=e.data.value)}catch(e){console.error("Load default model failed:",e)}},openModelSelector(){this.modelSelectVisible=!0},onModelSelected(s){const e=s.name.split("/");this.modelName=e.length>2?e.slice(1).join("/"):s.name,a.setConfig("defaultModel",this.modelName)},openCommandDialog(){this.commandDialogVisible=!0},handleExecuteCommand(s){this.inputMessage=s+" ",this.$nextTick(()=>{const e=this.$el.querySelector(".input-area textarea");e&&e.focus()})},openFileSelect(){this.fileSelectVisible=!0},onFileSelected(s){const e=this.inputMessage.lastIndexOf("@");e!==-1?this.inputMessage=this.inputMessage.slice(0,e)+s+" ":this.inputMessage+=s+" ",this.cancelFileSelect()},cancelFileSelect(){this.fileSelectVisible=!1},openSkillSelect(){const s=this.$el.querySelector(".input-area textarea");this.skillCursorPos=s?s.selectionStart:-1,this.skillSelectVisible=!0},onSkillSelected(s){const e=`[${s}] `,t=this.skillCursorPos>=0?this.skillCursorPos:0;this.inputMessage=this.inputMessage.slice(0,t)+e+this.inputMessage.slice(t),this.cancelSkillSelect()},cancelSkillSelect(){this.skillSelectVisible=!1},openDesignSelect(){this.designSelectVisible=!0},onDesignSelected(s){const e=`[设计:${s.name}](${s.path}) `;this.inputMessage+=e,this.designSelectVisible=!1},getTodoStatusIcon(s){return{completed:"✅",in_progress:"🔄",pending:"⬜",cancelled:"❌"}[s]||"⬜"},formatInput(s,e){try{const t=JSON.parse(e);return s==="bash"||s==="execute_bash"?t.command+(t.workdir?` (${t.workdir})`:""):s==="read_file"?t.file_path+(t.offset?`:${t.offset}`:""):s==="edit_file"||s==="write_file"?t.file_path:s==="glob"||s==="find_files"?t.pattern+(t.directory?` (${t.directory})`:""):s==="grep"||s==="search_content"?`"${t.pattern}" (${t.directory||""})`:e}catch{return e}},renderMarkdown(s){return s?p(s):""},openCustomActions(){window.open("/#/views/pc/custom-actions","_blank")},async loadCustomActions(){try{const s=await a.getCustomActions("design");this.customActions=s.data||[]}catch(s){console.error("Load custom actions failed:",s)}},executeCustomAction(s){this.inputMessage=s.prompt,this.$nextTick(()=>{const e=this.$el.querySelector(".input-area textarea");e&&e.focus(),s.auto_send&&this.sendMessage()})},startResize(s){this.isResizing=!0,this.startX=s.clientX,this.startWidth=this.chatPanelWidth,document.body.style.cursor="col-resize",document.body.style.userSelect="none"},handleResize(s){if(!this.isResizing)return;const e=this.startX-s.clientX;let t=this.startWidth+e;const i=this.$el.querySelector(".step2-main"),o=i?i.clientWidth*this.maxChatWidthRatio:800;t<this.minChatWidth&&(t=this.minChatWidth),t>o&&(t=o),this.chatPanelWidth=t},stopResize(){this.isResizing=!1,document.body.style.cursor="",document.body.style.userSelect=""}}};var J=function(){var e=this,t=e._self._c;return t("div",{staticClass:"step2-container"},[t("div",{staticClass:"step2-main"},[t("div",{staticClass:"editor-panel"},[t("div",{staticClass:"editor-header"},[t("span",{staticClass:"editor-title"},[t("i",{staticClass:"el-icon-document"}),t("span",[e._v(e._s(e.specFilePath))])]),t("div",{staticClass:"editor-actions"},[t("el-button",{attrs:{size:"small",type:"text",title:"保存方案"},on:{click:e.saveSpec}},[t("i",{staticClass:"el-icon-check"})]),t("el-button",{attrs:{size:"small",type:"text",title:"刷新方案"},on:{click:e.refreshSpec}},[t("i",{staticClass:"el-icon-refresh"})]),t("el-button",{attrs:{size:"small",type:"text",title:"导出方案"},on:{click:e.exportScheme}},[t("i",{staticClass:"el-icon-download"})]),t("el-button",{attrs:{size:"small",type:"text",title:"新建子方案"},on:{click:function(i){return e.$emit("create-sub-scheme")}}},[t("i",{staticClass:"el-icon-plus"})])],1)]),t("div",{ref:"editorContainer",staticClass:"editor-container"})]),t("div",{staticClass:"resize-handle",on:{mousedown:e.startResize}}),t("div",{ref:"chatPanel",staticClass:"chat-panel",style:{width:e.chatPanelWidth+"px"}},[t("div",{staticClass:"panel-header panel-tabs"},[t("div",{staticClass:"panel-tab",class:{active:e.chatTab==="assistant"},on:{click:function(i){e.chatTab="assistant"}}},[t("i",{staticClass:"el-icon-chat-dot-round"}),e._v(" AI生成方案 ")]),t("div",{staticClass:"panel-tab",class:{active:e.chatTab==="discuss"},on:{click:function(i){e.chatTab="discuss"}}},[t("i",{staticClass:"el-icon-chat-dot-square"}),e._v(" AI方案交流 ")])]),e.chatTab==="assistant"?[t("div",{ref:"messagesContainer",staticClass:"chat-messages"},[e.logItems.length?e._e():t("div",{staticClass:"empty-state"},[t("i",{staticClass:"el-icon-chat-dot-round"}),t("p",[e._v("输入需求描述,AI将协助您完善方案")])]),e._l(e.logItems,function(i,o){return[i.type==="todos"?t("div",{staticClass:"todos-list"},e._l(i.todos,function(n,l){return t("div",{key:l,staticClass:"todo-item"},[t("span",{staticClass:"todo-status"},[e._v(e._s(e.getTodoStatusIcon(n.status)))]),t("span",{staticClass:"todo-name"},[e._v(e._s(n.name))])])}),0):e._e(),i.type==="chat"?t("div",{staticClass:"flex justify-end"},[t("div",{staticClass:"user-question"},[i.mediaFiles&&i.mediaFiles.length>0?t("div",{staticClass:"chat-images"},e._l(i.mediaFiles,function(n){return t("img",{key:n.filePath,staticClass:"chat-image-thumb",attrs:{src:n.url||n.dataUrl||n.filePath},on:{click:function(l){return l.stopPropagation(),e.openImagePreview(n)}}})}),0):e._e(),t("div",[e._v(e._s(i.content))])])]):i.type==="system"?t("div",{staticClass:"system-message",domProps:{innerHTML:e._s(e.renderMarkdown(i.content))}}):i.type==="step"?[i.thought?t("div",{staticClass:"ai-thought",domProps:{innerHTML:e._s(e.renderMarkdown(i.thought))}}):e._e(),e._l(i.toolCalls,function(n,l){return t("div",{key:l,staticClass:"log-mute"},[n.status==="executing"?[t("span",{staticClass:"tool-spinner"}),e._v(" "+e._s(n.function.name)+" "),n.function.arguments?t("span",{staticClass:"tool-input"},[e._v(e._s(e.formatInput(n.function.name,n.function.arguments)))]):e._e()]:[t("span",{class:i.success!==!1?"tool-success":"tool-fail"},[e._v(" "+e._s(i.success!==!1?"✓":"✗")+" ")]),e._v(" "+e._s(n.function.name)+" "),n.function.arguments?t("span",{staticClass:"tool-input"},[e._v(e._s(e.formatInput(n.function.name,n.function.arguments)))]):e._e()]],2)})]:i.type==="think"?t("div",{staticClass:"ai-thought",domProps:{innerHTML:e._s(e.renderMarkdown(i.content))}}):e._e()]}),e.modelName?t("div",{staticClass:"build-info"},[t("span",{staticClass:"icon"},[e._v("▣")]),e._v(" Build · "+e._s(e.modelName)+" ")]):e._e()],2),t("div",{staticClass:"chat-input-area"},[e.mediaFiles&&e.mediaFiles.length>0?t("ImagePreviewList",{attrs:{files:e.mediaFiles,disabled:e.disabled},on:{remove:e.removeMedia}}):e._e(),t("div",{staticClass:"input-panel"},[t("div",{staticClass:"input-wrapper"},[t("ResizableTextarea",{staticClass:"input-area",attrs:{rows:5,placeholder:"输入消息... (Enter 发送, Ctrl+Enter 换行, @ 选择文件)",disabled:e.disabled&&!e.stopping},on:{"paste-image":e.handlePasteImages},nativeOn:{keydown:function(i){return!i.type.indexOf("key")&&e._k(i.keyCode,"enter",13,i.key,"Enter")?null:e.handleKeydown.apply(null,arguments)}},model:{value:e.inputMessage,callback:function(i){e.inputMessage=i},expression:"inputMessage"}}),t("input",{ref:"mediaInput",staticStyle:{display:"none"},attrs:{type:"file",accept:"image/*",multiple:""},on:{change:e.handleImageSelected}})],1),t("div",{staticClass:"input-actions"},[t("div",{staticClass:"input-actions-left"},[t("span",{staticClass:"status-action",on:{click:e.openFileSelect,mousedown:function(i){i.preventDefault()}}},[e._v("选择文件")]),t("span",{staticClass:"separator"},[e._v("|")]),t("span",{staticClass:"status-action",on:{click:e.openSkillSelect,mousedown:function(i){i.preventDefault()}}},[e._v("选择Skill")]),t("span",{staticClass:"separator"},[e._v("|")]),t("span",{staticClass:"status-action",on:{click:e.openDesignSelect,mousedown:function(i){i.preventDefault()}}},[e._v("选择设计")]),t("span",{staticClass:"separator"},[e._v("|")]),t("span",{staticClass:"status-action",on:{click:e.openCommandDialog,mousedown:function(i){i.preventDefault()}}},[e._v("命令")])]),t("div",{staticClass:"input-actions-right"},[t("el-button",{staticClass:"upload-btn",attrs:{disabled:e.disabled,size:"small"},on:{click:e.handleImageUpload}},[e._v("图片")]),e._l(e.customActions,function(i){return t("el-button",{key:i.id,attrs:{type:"info",size:"small",disabled:e.disabled},on:{click:function(o){return e.executeCustomAction(i)}}},[e._v(" "+e._s(i.name)+" ")])}),e.disabled&&!e.stopping?t("el-button",{staticClass:"stop-btn",attrs:{type:"danger",size:"small"},on:{click:e.stopChat}},[e._v(" ■ 停止 ")]):e.stopping?t("el-button",{staticClass:"stop-btn",attrs:{type:"info",disabled:"",size:"small"}},[e._v(" 停止中... ")]):t("el-button",{staticClass:"send-btn",attrs:{type:"primary",disabled:!e.inputMessage.trim()&&e.mediaFiles.length===0,size:"small"},on:{click:e.sendMessage}},[e._v(" 发送 ")])],2)])]),t("div",{staticClass:"status-bar"},[t("span",{class:e.sessionStatus==="processing"?"status-thinking":"status-ready"},[e.sessionStatus==="processing"?t("span",{staticClass:"thinking-spinner"}):e._e(),e._v(" "+e._s(e.sessionStatus==="processing"?"思考中":"✓ 就绪")+" ")]),t("span",{staticClass:"separator"},[e._v("|")]),t("span",{staticClass:"model-selector",on:{click:e.openModelSelector,mousedown:function(i){i.preventDefault()}}},[e._v(" 模型:"+e._s(e.modelName||"-")+" ▾ ")]),t("span",{staticClass:"separator"},[e._v("|")]),t("span",[e._v("会话:"+e._s(e.sessionId?e.sessionId.slice(0,8):"--------"))]),t("span",{staticClass:"separator"},[e._v("|")]),t("span",[e._v("token:"+e._s(e.promptTokens||0))])])],1)]:e._e(),e.chatTab==="discuss"?t("DesignDiscuss",{attrs:{category:e.category,name:e.name,reqBasePath:e.reqBasePath}}):e._e()],2)]),t("ModelSelectDialog",{attrs:{visible:e.modelSelectVisible,"current-model":e.modelName},on:{"update:visible":function(i){e.modelSelectVisible=i},select:e.onModelSelected}}),t("CommandDialog",{attrs:{visible:e.commandDialogVisible},on:{"update:visible":function(i){e.commandDialogVisible=i},execute:e.handleExecuteCommand}}),t("FileSelectDialog",{attrs:{visible:e.fileSelectVisible},on:{"update:visible":function(i){e.fileSelectVisible=i},select:e.onFileSelected,close:e.cancelFileSelect}}),t("SkillSelectDialog",{attrs:{visible:e.skillSelectVisible},on:{"update:visible":function(i){e.skillSelectVisible=i},select:e.onSkillSelected,close:e.cancelSkillSelect}}),t("DesignSelectDialog",{attrs:{visible:e.designSelectVisible},on:{"update:visible":function(i){e.designSelectVisible=i},select:e.onDesignSelected,close:function(i){e.designSelectVisible=!1}}}),e.previewImage?t("div",{staticClass:"image-lightbox",on:{click:e.closeImagePreview}},[t("span",{staticClass:"lightbox-close",on:{click:e.closeImagePreview}},[e._v("×")]),t("img",{staticClass:"lightbox-image",attrs:{src:e.previewImage.url||e.previewImage.dataUrl||e.previewImage.filePath},on:{click:function(i){i.stopPropagation()}}})]):e._e()],1)},H=[],X=d(K,J,H,!1,null,"82dc01c7");const G=X.exports,Q={name:"Step3CodeGen",components:{ModelSelectDialog:C,CommandDialog:I,FileSelectDialog:k,SkillSelectDialog:v,DesignSelectDialog:f,ResizableTextarea:m,ImagePreviewList:g},mixins:[_()],props:{category:{type:String,default:""},name:{type:String,default:""},reqBasePath:{type:String,default:""}},data(){return{inputMessage:"",disabled:!1,stopping:!1,promptTokens:0,dotAnimation:"",dotInterval:null,dots:["⠋","⠙","⠹","⠸","⠼","⠴","⠦","⠧"],logItems:[],modelName:"",modelSelectVisible:!1,commandDialogVisible:!1,fileSelectVisible:!1,skillSelectVisible:!1,designSelectVisible:!1,skillCursorPos:-1,sessionId:"",sessionStatus:"idle",customActions:[],devLogContent:"",devLogLoading:!1,devlogPanelWidth:400,isResizing:!1,startX:0,startWidth:0,minDevlogWidth:250,maxDevlogWidthRatio:.6}},computed:{specFilePath(){return!this.category||!this.name?"":`${this.reqBasePath}/${this.category}/${this.name}/${this.name}_方案.md`},renderedDevLog(){return this.devLogContent?p(this.devLogContent):'<p style="color: var(--color-textMuted);">暂无记录</p>'}},watch:{category:{handler(){this.loadSession()}},name:{handler(){this.loadSession()}}},async mounted(){document.addEventListener("mousemove",this.handleResize),document.addEventListener("mouseup",this.stopResize),await this.loadSession(),await this.loadDefaultModel(),await this.loadCustomActions(),a.ws.init()},beforeDestroy(){document.removeEventListener("mousemove",this.handleResize),document.removeEventListener("mouseup",this.stopResize),this.dotInterval&&clearInterval(this.dotInterval),this.wsUnsubscribe&&this.wsUnsubscribe()},methods:{handleKeydown(s){if(s.key==="Enter")if(s.ctrlKey){const e=s.target,t=e.selectionStart,i=e.selectionEnd,o=this.inputMessage;this.inputMessage=o.substring(0,t)+`
14
+ `+o.substring(i),this.$nextTick(()=>{e.selectionStart=e.selectionEnd=t+1})}else s.preventDefault(),this.sendMessage()},async loadSession(){var s;if(!this.category||!this.name){this.sessionId="",this.$emit("update:sessionId","");return}try{const e=`${this.reqBasePath}/${this.category}/${this.name}/session.json`,t=await a.getFileContent(e);if(t&&((s=t.data)!=null&&s.content)){const i=JSON.parse(t.data.content);this.sessionId=i.codeSessionId||""}else this.sessionId="";this.$emit("update:sessionId",this.sessionId),this.sessionId?(await this.loadMessages(),this.subscribeSession()):this.logItems=[]}catch(e){console.error("Load session failed:",e),this.sessionId="",this.$emit("update:sessionId",""),this.logItems=[]}},insertGenerateCommand(){this.specFilePath&&(this.inputMessage=`根据 ${this.specFilePath} 方案开发相应功能,先不要修改方案文档。`)},async sendMessage(){const s=this.inputMessage.trim(),e=this.mediaFiles&&this.mediaFiles.length>0;if(!s&&!e||this.disabled)return;if(!this.sessionId){this.$message.error("会话不存在,请刷新页面");return}this.wsUnsubscribe||this.subscribeSession(),this.inputMessage="",this.disabled=!0,this.stopping=!1;const t=(this.mediaFiles||[]).filter(i=>!i.uploading&&i.filePath).map(i=>({filePath:i.filePath,type:i.type,dataUrl:i.dataUrl}));this.logItems.push({type:"chat",content:s,mediaFiles:t}),this.scrollChatToBottom(!0),a.sessionWsSend(this.sessionId,"chat",{message:s,sessionId:this.sessionId,modelName:this.modelName||void 0,enableDevLog:!0,mediaFiles:t.map(i=>({filePath:i.filePath,type:i.type}))}),this.mediaFiles=[]},stopChat(){!this.sessionId||this.stopping||(this.stopping=!0,a.sessionWsSend(this.sessionId,"stop",{sessionId:this.sessionId}))},subscribeSession(){this.sessionId&&(this.wsUnsubscribe&&this.wsUnsubscribe(),this.wsUnsubscribe=a.wsSubscribe(this.sessionId,{running_sessions:s=>{const t=((s==null?void 0:s.runningSessionIds)||[]).includes(this.sessionId);this.sessionStatus=t?"processing":"idle",this.disabled=t},todos:s=>{s!=null&&s.todos&&this.logItems.push({type:"todos",todos:s.todos}),this.scrollChatToBottom()},step:s=>{var t,i;((t=s.toolCalls)==null?void 0:t.some(o=>o.status==="executing"))?(this.logItems=this.logItems.filter(o=>!(o.type==="step"&&o.iteration===s.iteration&&o._executing)),this.logItems.push({type:"step",thought:s.reasoning||s.thought,toolCalls:s.toolCalls,success:s.success,iteration:s.iteration,_executing:!0})):(this.logItems=this.logItems.filter(o=>!(o.type==="step"&&o.iteration===s.iteration&&o._executing)),this.logItems.push({type:"step",thought:s.thought,toolCalls:s.toolCalls,success:s.success})),(i=s.usage)!=null&&i.promptTokens&&(this.promptTokens=s.usage.promptTokens),this.scrollChatToBottom()},compact:s=>{this.logItems.push({type:"system",content:`【压缩完成】${s.summary||""}`}),this.loadMessages()},done:s=>{var e;this.logItems=this.logItems.filter(t=>!(t.type==="step"&&t._executing)),this.disabled=!1,this.stopping=!1,this.sessionStatus="completed",s!=null&&s.modelName&&(this.modelName=s.modelName),(e=s==null?void 0:s.usage)!=null&&e.promptTokens&&(this.promptTokens=s.usage.promptTokens),s!=null&&s.response&&this.logItems.push({type:"think",content:s.response}),this.loadDevLog(),this.scrollChatToBottom()},stopped:()=>{this.logItems=this.logItems.filter(s=>!(s.type==="step"&&s._executing)),this.disabled=!1,this.stopping=!1,this.sessionStatus="idle",this.logItems.push({type:"think",content:"【已停止】"}),this.scrollChatToBottom()},error:s=>{this.logItems=this.logItems.filter(e=>!(e.type==="step"&&e._executing)),this.$message.error((s==null?void 0:s.error)||"发生错误"),this.disabled=!1,this.stopping=!1,this.sessionStatus="idle"}}))},scrollChatToBottom(s=!1){const e=y(this.$refs.messagesContainer);console.log("[Step3CodeGen] scrollChatToBottom called, force:",s,"snap:",JSON.stringify(e)),this.$nextTick(()=>{S(this.$refs.messagesContainer,{force:s,prevSnapshot:e})})},async loadMessages(){if(this.sessionId)try{const s=await a.getMessages(this.sessionId);this.logItems=s.data||[],this.scrollChatToBottom(!0)}catch(s){console.error("Load messages failed:",s)}},async loadDefaultModel(){var s;try{const e=await a.getConfig("defaultModel");(s=e.data)!=null&&s.value&&(this.modelName=e.data.value)}catch(e){console.error("Load default model failed:",e)}},openModelSelector(){this.modelSelectVisible=!0},onModelSelected(s){const e=s.name.split("/");this.modelName=e.length>2?e.slice(1).join("/"):s.name,a.setConfig("defaultModel",this.modelName)},openCommandDialog(){this.commandDialogVisible=!0},handleExecuteCommand(s){this.inputMessage=s+" ",this.$nextTick(()=>{const e=this.$el.querySelector(".input-area textarea");e&&e.focus()})},openFileSelect(){this.fileSelectVisible=!0},onFileSelected(s){const e=this.inputMessage.lastIndexOf("@");e!==-1?this.inputMessage=this.inputMessage.slice(0,e)+s+" ":this.inputMessage+=s+" ",this.cancelFileSelect()},cancelFileSelect(){this.fileSelectVisible=!1},openSkillSelect(){const s=this.$el.querySelector(".input-area textarea");this.skillCursorPos=s?s.selectionStart:-1,this.skillSelectVisible=!0},onSkillSelected(s){const e=`[${s}] `,t=this.skillCursorPos>=0?this.skillCursorPos:0;this.inputMessage=this.inputMessage.slice(0,t)+e+this.inputMessage.slice(t),this.cancelSkillSelect()},cancelSkillSelect(){this.skillSelectVisible=!1},openDesignSelect(){this.designSelectVisible=!0},onDesignSelected(s){const e=`[设计:${s.name}](${s.path}) `;this.inputMessage+=e,this.designSelectVisible=!1},getTodoStatusIcon(s){return{completed:"✅",in_progress:"🔄",pending:"⬜",cancelled:"❌"}[s]||"⬜"},formatInput(s,e){try{const t=JSON.parse(e);return s==="bash"||s==="execute_bash"?t.command+(t.workdir?` (${t.workdir})`:""):s==="read_file"?t.file_path+(t.offset?`:${t.offset}`:""):s==="edit_file"||s==="write_file"?t.file_path:s==="glob"||s==="find_files"?t.pattern+(t.directory?` (${t.directory})`:""):s==="grep"||s==="search_content"?`"${t.pattern}" (${t.directory||""})`:e}catch{return e}},renderMarkdown(s){return s?p(s):""},async loadCustomActions(){try{const s=await a.getCustomActions("code");this.customActions=s.data||[]}catch(s){console.error("Load custom actions failed:",s),this.customActions=[]}},executeCustomAction(s){this.inputMessage=s.prompt,this.$nextTick(()=>{const e=this.$el.querySelector(".input-area textarea");e&&e.focus(),s.auto_send&&this.sendMessage()})},openCustomActions(){window.open("/#/views/pc/custom-actions","_blank")},async loadDevLog(){var s;if(this.sessionId){this.devLogLoading=!0;try{const t=await(await fetch(`/api/devlog/list_devlog?sessionId=${this.sessionId}`)).json();t.success&&(this.devLogContent=((s=t.data)==null?void 0:s.content)||"")}catch(e){console.error("加载开发日志失败:",e)}finally{this.devLogLoading=!1}}},async refreshDevLog(){await this.loadDevLog()},startResize(s){this.isResizing=!0,this.startX=s.clientX,this.startWidth=this.devlogPanelWidth,document.body.style.cursor="col-resize",document.body.style.userSelect="none"},handleResize(s){if(!this.isResizing)return;const e=this.startX-s.clientX;let t=this.startWidth+e;const i=this.$el.querySelector(".step3-main"),o=i?i.clientWidth*this.maxDevlogWidthRatio:800;t<this.minDevlogWidth&&(t=this.minDevlogWidth),t>o&&(t=o),this.devlogPanelWidth=t},stopResize(){this.isResizing=!1,document.body.style.cursor="",document.body.style.userSelect=""}}};var Y=function(){var e=this,t=e._self._c;return t("div",{staticClass:"step3-container"},[t("div",{staticClass:"step3-main"},[t("div",{staticClass:"code-chat-panel"},[t("div",{staticClass:"panel-header"},[e._m(0),t("div",{staticClass:"header-actions"},[t("el-button",{attrs:{type:"primary",size:"small",disabled:e.disabled},on:{click:e.insertGenerateCommand}},[t("i",{staticClass:"el-icon-document"}),e._v(" 根据方案生成代码 ")]),t("el-button",{attrs:{type:"warning",size:"small"},on:{click:e.openCustomActions}},[t("i",{staticClass:"el-icon-setting"}),e._v(" 动作配置 ")])],1)]),t("div",{ref:"messagesContainer",staticClass:"chat-messages"},[e.logItems.length?e._e():t("div",{staticClass:"empty-state"},[t("i",{staticClass:"el-icon-chat-dot-round"}),t("p",[e._v("点击上方按钮或输入需求生成代码")])]),e._l(e.logItems,function(i,o){return[i.type==="todos"?t("div",{staticClass:"todos-list"},e._l(i.todos,function(n,l){return t("div",{key:l,staticClass:"todo-item"},[t("span",{staticClass:"todo-status"},[e._v(e._s(e.getTodoStatusIcon(n.status)))]),t("span",{staticClass:"todo-name"},[e._v(e._s(n.name))])])}),0):e._e(),i.type==="chat"?t("div",{staticClass:"flex justify-end"},[t("div",{staticClass:"user-question"},[i.mediaFiles&&i.mediaFiles.length>0?t("div",{staticClass:"chat-images"},e._l(i.mediaFiles,function(n){return t("img",{key:n.filePath,staticClass:"chat-image-thumb",attrs:{src:n.url||n.dataUrl||n.filePath},on:{click:function(l){return l.stopPropagation(),e.openImagePreview(n)}}})}),0):e._e(),t("div",[e._v(e._s(i.content))])])]):i.type==="think"?t("div",{staticClass:"ai-thought",domProps:{innerHTML:e._s(e.renderMarkdown(i.content))}}):i.type==="system"?t("div",{staticClass:"system-message",domProps:{innerHTML:e._s(e.renderMarkdown(i.content))}}):i.type==="step"?[i.thought?t("div",{staticClass:"ai-thought",domProps:{innerHTML:e._s(e.renderMarkdown(i.thought))}}):e._e(),e._l(i.toolCalls,function(n,l){return t("div",{key:l,staticClass:"log-mute"},[n.status==="executing"?[t("span",{staticClass:"tool-spinner"}),e._v(" "+e._s(n.function.name)+" "),n.function.arguments?t("span",{staticClass:"tool-input"},[e._v(e._s(e.formatInput(n.function.name,n.function.arguments)))]):e._e()]:[t("span",{class:i.success!==!1?"tool-success":"tool-fail"},[e._v(" "+e._s(i.success!==!1?"✓":"✗")+" ")]),e._v(" "+e._s(n.function.name)+" "),n.function.arguments?t("span",{staticClass:"tool-input"},[e._v(e._s(e.formatInput(n.function.name,n.function.arguments)))]):e._e()]],2)})]:e._e()]}),e.modelName?t("div",{staticClass:"build-info"},[t("span",{staticClass:"icon"},[e._v("▣")]),e._v(" Build · "+e._s(e.modelName)+" ")]):e._e()],2),t("div",{staticClass:"chat-input-area"},[e.mediaFiles&&e.mediaFiles.length>0?t("ImagePreviewList",{attrs:{files:e.mediaFiles,disabled:e.disabled},on:{remove:e.removeMedia}}):e._e(),t("div",{staticClass:"input-wrapper"},[t("ResizableTextarea",{staticClass:"input-area",attrs:{rows:5,placeholder:"输入代码修改要求... (Enter 发送, Ctrl+Enter 换行, @ 选择文件)",disabled:e.disabled&&!e.stopping},on:{"paste-image":e.handlePasteImages},nativeOn:{keydown:function(i){return!i.type.indexOf("key")&&e._k(i.keyCode,"enter",13,i.key,"Enter")?null:e.handleKeydown.apply(null,arguments)}},model:{value:e.inputMessage,callback:function(i){e.inputMessage=i},expression:"inputMessage"}}),t("input",{ref:"mediaInput",staticStyle:{display:"none"},attrs:{type:"file",accept:"image/*",multiple:""},on:{change:e.handleImageSelected}}),t("div",{staticClass:"input-actions"},[t("el-button",{staticClass:"upload-btn",attrs:{disabled:e.disabled,size:"small"},on:{click:e.handleImageUpload}},[e._v("图片")]),e._l(e.customActions,function(i){return t("el-button",{key:i.id,attrs:{type:"info",size:"small",disabled:e.disabled},on:{click:function(o){return e.executeCustomAction(i)}}},[e._v(" "+e._s(i.name)+" ")])}),e.disabled&&!e.stopping?t("el-button",{staticClass:"stop-btn",attrs:{type:"danger",size:"small"},on:{click:e.stopChat}},[e._v(" ■ 停止 ")]):e.stopping?t("el-button",{staticClass:"stop-btn",attrs:{type:"info",disabled:"",size:"small"}},[e._v(" 停止中... ")]):t("el-button",{staticClass:"send-btn",attrs:{type:"primary",disabled:!e.inputMessage.trim()&&e.mediaFiles.length===0,size:"small"},on:{click:e.sendMessage}},[e._v(" 发送 ")])],2)],1)],1),t("div",{staticClass:"status-bar"},[t("span",{class:e.sessionStatus==="processing"?"status-thinking":"status-ready"},[e.sessionStatus==="processing"?t("span",{staticClass:"thinking-spinner"}):e._e(),e._v(" "+e._s(e.sessionStatus==="processing"?"思考中":"✓ 就绪")+" ")]),t("span",{staticClass:"separator"},[e._v("|")]),t("span",{staticClass:"model-selector",on:{click:e.openModelSelector,mousedown:function(i){i.preventDefault()}}},[e._v(" 模型:"+e._s(e.modelName||"-")+" ▾ ")]),t("span",{staticClass:"separator"},[e._v("|")]),t("span",[e._v("会话:"+e._s(e.sessionId?e.sessionId.slice(0,8):"--------"))]),t("span",{staticClass:"separator"},[e._v("|")]),t("span",[e._v("token:"+e._s(e.promptTokens||0))]),t("span",{staticClass:"separator"},[e._v("|")]),t("span",{staticClass:"status-action",on:{click:e.openCommandDialog,mousedown:function(i){i.preventDefault()}}},[e._v("命令")]),t("span",{staticClass:"separator"},[e._v("|")]),t("span",{staticClass:"status-action",on:{click:e.openFileSelect,mousedown:function(i){i.preventDefault()}}},[e._v("选择文件")]),t("span",{staticClass:"separator"},[e._v("|")]),t("span",{staticClass:"status-action",on:{click:e.openSkillSelect,mousedown:function(i){i.preventDefault()}}},[e._v("选择Skill")]),t("span",{staticClass:"separator"},[e._v("|")]),t("span",{staticClass:"status-action",on:{click:e.openDesignSelect,mousedown:function(i){i.preventDefault()}}},[e._v("选择设计")])])]),t("div",{staticClass:"resize-handle",on:{mousedown:e.startResize}}),t("div",{ref:"devlogPanel",staticClass:"devlog-panel",style:{width:e.devlogPanelWidth+"px"}},[t("div",{staticClass:"panel-header"},[e._m(1),t("el-button",{attrs:{size:"small"},on:{click:e.refreshDevLog}},[t("i",{staticClass:"el-icon-refresh"}),e._v(" 刷新 ")])],1),t("div",{staticClass:"devlog-content",domProps:{innerHTML:e._s(e.renderedDevLog)}})])]),t("ModelSelectDialog",{attrs:{visible:e.modelSelectVisible,"current-model":e.modelName},on:{"update:visible":function(i){e.modelSelectVisible=i},select:e.onModelSelected}}),t("CommandDialog",{attrs:{visible:e.commandDialogVisible},on:{"update:visible":function(i){e.commandDialogVisible=i},execute:e.handleExecuteCommand}}),t("FileSelectDialog",{attrs:{visible:e.fileSelectVisible},on:{"update:visible":function(i){e.fileSelectVisible=i},select:e.onFileSelected,close:e.cancelFileSelect}}),t("SkillSelectDialog",{attrs:{visible:e.skillSelectVisible},on:{"update:visible":function(i){e.skillSelectVisible=i},select:e.onSkillSelected,close:e.cancelSkillSelect}}),t("DesignSelectDialog",{attrs:{visible:e.designSelectVisible},on:{"update:visible":function(i){e.designSelectVisible=i},select:e.onDesignSelected,close:function(i){e.designSelectVisible=!1}}}),e.previewImage?t("div",{staticClass:"image-lightbox",on:{click:e.closeImagePreview}},[t("span",{staticClass:"lightbox-close",on:{click:e.closeImagePreview}},[e._v("×")]),t("img",{staticClass:"lightbox-image",attrs:{src:e.previewImage.url||e.previewImage.dataUrl||e.previewImage.filePath},on:{click:function(i){i.stopPropagation()}}})]):e._e()],1)},Z=[function(){var s=this,e=s._self._c;return e("span",[e("i",{staticClass:"el-icon-code"}),s._v(" 代码生成对话")])},function(){var s=this,e=s._self._c;return e("span",[e("i",{staticClass:"el-icon-document"}),s._v(" 开发记录")])}],ee=d(Q,Y,Z,!1,null,"77efd6ae");const se=ee.exports,te={name:"Step4Test",components:{ModelSelectDialog:C,CommandDialog:I,FileSelectDialog:k,SkillSelectDialog:v,DesignSelectDialog:f,ResizableTextarea:m,ImagePreviewList:g},mixins:[_()],props:{category:{type:String,default:""},name:{type:String,default:""},reqBasePath:{type:String,default:""}},data(){return{inputMessage:"",disabled:!1,stopping:!1,promptTokens:0,dotAnimation:"",dotInterval:null,dots:["⠋","⠙","⠹","⠸","⠼","⠴","⠦","⠧"],logItems:[],modelName:"",modelSelectVisible:!1,commandDialogVisible:!1,fileSelectVisible:!1,skillSelectVisible:!1,designSelectVisible:!1,skillCursorPos:-1,sessionId:"",sessionStatus:"idle",customActions:[]}},computed:{specFilePath(){return!this.category||!this.name?"":`${this.reqBasePath}/${this.category}/${this.name}/${this.name}_方案.md`}},watch:{category:{handler(){this.loadSession()}},name:{handler(){this.loadSession()}}},async mounted(){await this.loadSession(),await this.loadDefaultModel(),await this.loadCustomActions(),a.ws.init()},beforeDestroy(){this.dotInterval&&clearInterval(this.dotInterval),this.wsUnsubscribe&&this.wsUnsubscribe()},methods:{handleKeydown(s){if(s.key==="Enter")if(s.ctrlKey){const e=s.target,t=e.selectionStart,i=e.selectionEnd,o=this.inputMessage;this.inputMessage=o.substring(0,t)+`
15
+ `+o.substring(i),this.$nextTick(()=>{e.selectionStart=e.selectionEnd=t+1})}else s.preventDefault(),this.sendMessage()},async loadSession(){var s;if(!this.category||!this.name){this.sessionId="",this.$emit("update:sessionId","");return}try{const e=`${this.reqBasePath}/${this.category}/${this.name}/session.json`,t=await a.getFileContent(e);if(t&&((s=t.data)!=null&&s.content)){const i=JSON.parse(t.data.content);this.sessionId=i.testSessionId||""}else this.sessionId="";this.$emit("update:sessionId",this.sessionId),this.sessionId?(await this.loadMessages(),this.subscribeSession()):this.logItems=[]}catch(e){console.error("Load session failed:",e),this.sessionId="",this.$emit("update:sessionId",""),this.logItems=[]}},insertTestCommand(){this.specFilePath&&(this.inputMessage=`根据 ${this.specFilePath} 方案测试相应功能是否实现。`)},async sendMessage(){const s=this.inputMessage.trim(),e=this.mediaFiles&&this.mediaFiles.length>0;if(!s&&!e||this.disabled)return;if(!this.sessionId){this.$message.error("会话不存在,请刷新页面");return}this.wsUnsubscribe||this.subscribeSession(),this.inputMessage="",this.disabled=!0,this.stopping=!1;const t=(this.mediaFiles||[]).filter(i=>!i.uploading&&i.filePath).map(i=>({filePath:i.filePath,type:i.type,dataUrl:i.dataUrl}));this.logItems.push({type:"chat",content:s,mediaFiles:t}),this.scrollChatToBottom(!0),a.sessionWsSend(this.sessionId,"chat",{message:s,sessionId:this.sessionId,modelName:this.modelName||void 0,mediaFiles:t.map(i=>({filePath:i.filePath,type:i.type}))}),this.mediaFiles=[]},stopChat(){!this.sessionId||this.stopping||(this.stopping=!0,a.sessionWsSend(this.sessionId,"stop",{sessionId:this.sessionId}))},subscribeSession(){this.sessionId&&(this.wsUnsubscribe&&this.wsUnsubscribe(),this.wsUnsubscribe=a.wsSubscribe(this.sessionId,{running_sessions:s=>{const t=((s==null?void 0:s.runningSessionIds)||[]).includes(this.sessionId);this.sessionStatus=t?"processing":"idle",this.disabled=t},todos:s=>{s!=null&&s.todos&&this.logItems.push({type:"todos",todos:s.todos}),this.scrollChatToBottom()},step:s=>{var t,i;((t=s.toolCalls)==null?void 0:t.some(o=>o.status==="executing"))?(this.logItems=this.logItems.filter(o=>!(o.type==="step"&&o.iteration===s.iteration&&o._executing)),this.logItems.push({type:"step",thought:s.reasoning||s.thought,toolCalls:s.toolCalls,success:s.success,iteration:s.iteration,_executing:!0})):(this.logItems=this.logItems.filter(o=>!(o.type==="step"&&o.iteration===s.iteration&&o._executing)),this.logItems.push({type:"step",thought:s.thought,toolCalls:s.toolCalls,success:s.success})),(i=s.usage)!=null&&i.promptTokens&&(this.promptTokens=s.usage.promptTokens),this.scrollChatToBottom()},compact:s=>{this.logItems.push({type:"system",content:`【压缩完成】${s.summary||""}`}),this.loadMessages()},done:s=>{var e;this.logItems=this.logItems.filter(t=>!(t.type==="step"&&t._executing)),this.disabled=!1,this.stopping=!1,this.sessionStatus="completed",s!=null&&s.modelName&&(this.modelName=s.modelName),(e=s==null?void 0:s.usage)!=null&&e.promptTokens&&(this.promptTokens=s.usage.promptTokens),s!=null&&s.response&&this.logItems.push({type:"think",content:s.response}),this.scrollChatToBottom()},stopped:()=>{this.logItems=this.logItems.filter(s=>!(s.type==="step"&&s._executing)),this.disabled=!1,this.stopping=!1,this.sessionStatus="idle",this.logItems.push({type:"think",content:"【已停止】"}),this.scrollChatToBottom()},error:s=>{this.logItems=this.logItems.filter(e=>!(e.type==="step"&&e._executing)),this.$message.error((s==null?void 0:s.error)||"发生错误"),this.disabled=!1,this.stopping=!1,this.sessionStatus="idle"}}))},scrollChatToBottom(s=!1){const e=y(this.$refs.messagesContainer);console.log("[Step4Test] scrollChatToBottom called, force:",s,"snap:",JSON.stringify(e)),this.$nextTick(()=>{S(this.$refs.messagesContainer,{force:s,prevSnapshot:e})})},async loadMessages(){if(this.sessionId)try{const s=await a.getMessages(this.sessionId);this.logItems=s.data||[],this.scrollChatToBottom(!0)}catch(s){console.error("Load messages failed:",s)}},async loadDefaultModel(){var s;try{const e=await a.getConfig("defaultModel");(s=e.data)!=null&&s.value&&(this.modelName=e.data.value)}catch(e){console.error("Load default model failed:",e)}},openModelSelector(){this.modelSelectVisible=!0},onModelSelected(s){const e=s.name.split("/");this.modelName=e.length>2?e.slice(1).join("/"):s.name,a.setConfig("defaultModel",this.modelName)},openCommandDialog(){this.commandDialogVisible=!0},handleExecuteCommand(s){this.inputMessage=s+" ",this.$nextTick(()=>{const e=this.$el.querySelector(".input-area textarea");e&&e.focus()})},openFileSelect(){this.fileSelectVisible=!0},onFileSelected(s){const e=this.inputMessage.lastIndexOf("@");e!==-1?this.inputMessage=this.inputMessage.slice(0,e)+s+" ":this.inputMessage+=s+" ",this.cancelFileSelect()},cancelFileSelect(){this.fileSelectVisible=!1},openSkillSelect(){const s=this.$el.querySelector(".input-area textarea");this.skillCursorPos=s?s.selectionStart:-1,this.skillSelectVisible=!0},onSkillSelected(s){const e=`[${s}] `,t=this.skillCursorPos>=0?this.skillCursorPos:0;this.inputMessage=this.inputMessage.slice(0,t)+e+this.inputMessage.slice(t),this.cancelSkillSelect()},cancelSkillSelect(){this.skillSelectVisible=!1},openDesignSelect(){this.designSelectVisible=!0},onDesignSelected(s){const e=`[设计:${s.name}](${s.path}) `;this.inputMessage+=e,this.designSelectVisible=!1},getTodoStatusIcon(s){return{completed:"✅",in_progress:"🔄",pending:"⬜",cancelled:"❌"}[s]||"⬜"},formatInput(s,e){try{const t=JSON.parse(e);return s==="bash"||s==="execute_bash"?t.command+(t.workdir?` (${t.workdir})`:""):s==="read_file"?t.file_path+(t.offset?`:${t.offset}`:""):s==="edit_file"||s==="write_file"?t.file_path:s==="glob"||s==="find_files"?t.pattern+(t.directory?` (${t.directory})`:""):s==="grep"||s==="search_content"?`"${t.pattern}" (${t.directory||""})`:e}catch{return e}},renderMarkdown(s){return s?p(s):""},async loadCustomActions(){try{const s=await a.getCustomActions("test");this.customActions=s.data||[]}catch(s){console.error("Load custom actions failed:",s),this.customActions=[]}},executeCustomAction(s){this.inputMessage=s.prompt,this.$nextTick(()=>{const e=this.$el.querySelector(".input-area textarea");e&&e.focus(),s.auto_send&&this.sendMessage()})}}};var ie=function(){var e=this,t=e._self._c;return t("div",{staticClass:"step4-container"},[t("div",{staticClass:"step4-main"},[t("div",{staticClass:"code-chat-panel"},[t("div",{staticClass:"panel-header"},[e._m(0),t("el-button",{attrs:{type:"primary",size:"small",disabled:e.disabled},on:{click:e.insertTestCommand}},[t("i",{staticClass:"el-icon-s-claim"}),e._v(" 根据方案测试 ")])],1),t("div",{ref:"messagesContainer",staticClass:"chat-messages"},[e.logItems.length?e._e():t("div",{staticClass:"empty-state"},[t("i",{staticClass:"el-icon-chat-dot-round"}),t("p",[e._v("点击上方按钮或输入测试要求进行验收")])]),e._l(e.logItems,function(i,o){return[i.type==="todos"?t("div",{staticClass:"todos-list"},e._l(i.todos,function(n,l){return t("div",{key:l,staticClass:"todo-item"},[t("span",{staticClass:"todo-status"},[e._v(e._s(e.getTodoStatusIcon(n.status)))]),t("span",{staticClass:"todo-name"},[e._v(e._s(n.name))])])}),0):e._e(),i.type==="chat"?t("div",{staticClass:"flex justify-end"},[t("div",{staticClass:"user-question"},[i.mediaFiles&&i.mediaFiles.length>0?t("div",{staticClass:"chat-images"},e._l(i.mediaFiles,function(n){return t("img",{key:n.filePath,staticClass:"chat-image-thumb",attrs:{src:n.url||n.dataUrl||n.filePath},on:{click:function(l){return l.stopPropagation(),e.openImagePreview(n)}}})}),0):e._e(),t("div",[e._v(e._s(i.content))])])]):i.type==="think"?t("div",{staticClass:"ai-thought",domProps:{innerHTML:e._s(e.renderMarkdown(i.content))}}):i.type==="system"?t("div",{staticClass:"system-message",domProps:{innerHTML:e._s(e.renderMarkdown(i.content))}}):i.type==="step"?[i.thought?t("div",{staticClass:"ai-thought",domProps:{innerHTML:e._s(e.renderMarkdown(i.thought))}}):e._e(),e._l(i.toolCalls,function(n,l){return t("div",{key:l,staticClass:"log-mute"},[n.status==="executing"?[t("span",{staticClass:"tool-spinner"}),e._v(" "+e._s(n.function.name)+" "),n.function.arguments?t("span",{staticClass:"tool-input"},[e._v(e._s(e.formatInput(n.function.name,n.function.arguments)))]):e._e()]:[t("span",{class:i.success!==!1?"tool-success":"tool-fail"},[e._v(" "+e._s(i.success!==!1?"✓":"✗")+" ")]),e._v(" "+e._s(n.function.name)+" "),n.function.arguments?t("span",{staticClass:"tool-input"},[e._v(e._s(e.formatInput(n.function.name,n.function.arguments)))]):e._e()]],2)})]:e._e()]}),e.modelName?t("div",{staticClass:"build-info"},[t("span",{staticClass:"icon"},[e._v("▣")]),e._v(" Build · "+e._s(e.modelName)+" ")]):e._e()],2),t("div",{staticClass:"chat-input-area"},[e.mediaFiles&&e.mediaFiles.length>0?t("ImagePreviewList",{attrs:{files:e.mediaFiles,disabled:e.disabled},on:{remove:e.removeMedia}}):e._e(),t("div",{staticClass:"input-wrapper"},[t("ResizableTextarea",{staticClass:"input-area",attrs:{rows:5,placeholder:"输入测试要求... (Enter 发送, Ctrl+Enter 换行, @ 选择文件)",disabled:e.disabled&&!e.stopping},on:{"paste-image":e.handlePasteImages},nativeOn:{keydown:function(i){return!i.type.indexOf("key")&&e._k(i.keyCode,"enter",13,i.key,"Enter")?null:e.handleKeydown.apply(null,arguments)}},model:{value:e.inputMessage,callback:function(i){e.inputMessage=i},expression:"inputMessage"}}),t("input",{ref:"mediaInput",staticStyle:{display:"none"},attrs:{type:"file",accept:"image/*",multiple:""},on:{change:e.handleImageSelected}}),t("div",{staticClass:"input-actions"},[t("el-button",{staticClass:"upload-btn",attrs:{disabled:e.disabled,size:"small"},on:{click:e.handleImageUpload}},[e._v("图片")]),e._l(e.customActions,function(i){return t("el-button",{key:i.id,attrs:{type:"info",size:"small",disabled:e.disabled},on:{click:function(o){return e.executeCustomAction(i)}}},[e._v(" "+e._s(i.name)+" ")])}),e.disabled&&!e.stopping?t("el-button",{staticClass:"stop-btn",attrs:{type:"danger",size:"small"},on:{click:e.stopChat}},[e._v(" ■ 停止 ")]):e.stopping?t("el-button",{staticClass:"stop-btn",attrs:{type:"info",disabled:"",size:"small"}},[e._v(" 停止中... ")]):t("el-button",{staticClass:"send-btn",attrs:{type:"primary",disabled:!e.inputMessage.trim()&&e.mediaFiles.length===0,size:"small"},on:{click:e.sendMessage}},[e._v(" 发送 ")])],2)],1)],1),t("div",{staticClass:"status-bar"},[t("span",{class:e.sessionStatus==="processing"?"status-thinking":"status-ready"},[e.sessionStatus==="processing"?t("span",{staticClass:"thinking-spinner"}):e._e(),e._v(" "+e._s(e.sessionStatus==="processing"?"思考中":"✓ 就绪")+" ")]),t("span",{staticClass:"separator"},[e._v("|")]),t("span",{staticClass:"model-selector",on:{click:e.openModelSelector,mousedown:function(i){i.preventDefault()}}},[e._v(" 模型:"+e._s(e.modelName||"-")+" ▾ ")]),t("span",{staticClass:"separator"},[e._v("|")]),t("span",[e._v("会话:"+e._s(e.sessionId?e.sessionId.slice(0,8):"--------"))]),t("span",{staticClass:"separator"},[e._v("|")]),t("span",[e._v("token:"+e._s(e.promptTokens||0))]),t("span",{staticClass:"separator"},[e._v("|")]),t("span",{staticClass:"status-action",on:{click:e.openCommandDialog,mousedown:function(i){i.preventDefault()}}},[e._v("命令")]),t("span",{staticClass:"separator"},[e._v("|")]),t("span",{staticClass:"status-action",on:{click:e.openFileSelect,mousedown:function(i){i.preventDefault()}}},[e._v("选择文件")]),t("span",{staticClass:"separator"},[e._v("|")]),t("span",{staticClass:"status-action",on:{click:e.openSkillSelect,mousedown:function(i){i.preventDefault()}}},[e._v("选择Skill")]),t("span",{staticClass:"separator"},[e._v("|")]),t("span",{staticClass:"status-action",on:{click:e.openDesignSelect,mousedown:function(i){i.preventDefault()}}},[e._v("选择设计")])])])]),t("ModelSelectDialog",{attrs:{visible:e.modelSelectVisible,"current-model":e.modelName},on:{"update:visible":function(i){e.modelSelectVisible=i},select:e.onModelSelected}}),t("CommandDialog",{attrs:{visible:e.commandDialogVisible},on:{"update:visible":function(i){e.commandDialogVisible=i},execute:e.handleExecuteCommand}}),t("FileSelectDialog",{attrs:{visible:e.fileSelectVisible},on:{"update:visible":function(i){e.fileSelectVisible=i},select:e.onFileSelected,close:e.cancelFileSelect}}),t("SkillSelectDialog",{attrs:{visible:e.skillSelectVisible},on:{"update:visible":function(i){e.skillSelectVisible=i},select:e.onSkillSelected,close:e.cancelSkillSelect}}),t("DesignSelectDialog",{attrs:{visible:e.designSelectVisible},on:{"update:visible":function(i){e.designSelectVisible=i},select:e.onDesignSelected,close:function(i){e.designSelectVisible=!1}}}),e.previewImage?t("div",{staticClass:"image-lightbox",on:{click:e.closeImagePreview}},[t("span",{staticClass:"lightbox-close",on:{click:e.closeImagePreview}},[e._v("×")]),t("img",{staticClass:"lightbox-image",attrs:{src:e.previewImage.url||e.previewImage.dataUrl||e.previewImage.filePath},on:{click:function(i){i.stopPropagation()}}})]):e._e()],1)},ne=[function(){var s=this,e=s._self._c;return e("span",[e("i",{staticClass:"el-icon-s-check"}),s._v(" 测试验收对话")])}],oe=d(te,ie,ne,!1,null,"6d77d64b");const ae=oe.exports,le={name:"SubSchemeDialog",props:{visible:{type:Boolean,default:!1},category:{type:String,default:""},parentName:{type:String,default:""},defaultName:{type:String,default:""}},data(){return{name:""}},watch:{visible(s){s&&(this.name=this.defaultName)}},methods:{handleVisibleChange(s){this.$emit("update:visible",s)},handleClose(){this.$emit("cancel")},onConfirm(){const s=this.name.trim();s&&(this.$emit("confirm",s),this.$emit("update:visible",!1))},onCancel(){this.$emit("cancel"),this.$emit("update:visible",!1)}}};var re=function(){var e=this,t=e._self._c;return t("el-dialog",{attrs:{visible:e.visible,title:"新建子方案",width:"420px"},on:{"update:visible":e.handleVisibleChange,close:e.handleClose}},[t("el-form",{attrs:{"label-width":"80px"}},[t("el-form-item",{attrs:{label:"方案名称"}},[t("el-input",{attrs:{placeholder:"请输入子方案名称"},nativeOn:{keyup:function(i){return!i.type.indexOf("key")&&e._k(i.keyCode,"enter",13,i.key,"Enter")?null:e.onConfirm.apply(null,arguments)}},model:{value:e.name,callback:function(i){e.name=i},expression:"name"}})],1),t("el-form-item",{attrs:{label:"所属大类"}},[t("span",[e._v(e._s(e.category))])]),t("el-form-item",{attrs:{label:"父方案"}},[t("span",[e._v(e._s(e.parentName))])])],1),t("span",{attrs:{slot:"footer"},slot:"footer"},[t("el-button",{on:{click:e.onCancel}},[e._v("取消")]),t("el-button",{attrs:{type:"primary",disabled:!e.name.trim()},on:{click:e.onConfirm}},[e._v("确认")])],1)],1)},ce=[],de=d(le,re,ce,!1,null,null);const ue=de.exports,he={name:"DevWorkflowView",components:{WorkflowSidebar:R,Step1NewReq:z,Step2Design:G,Step3CodeGen:se,Step4Test:ae,SubSchemeDialog:ue},props:{sidebarVisible:{type:Boolean,default:!0}},data(){return{currentCategory:"",currentProject:"",currentStep:1,categories:[],projects:{},reqBasePath:"",isLoadingProjects:!1,designSessionId:"",codeSessionId:"",testSessionId:"",taskStatus:"idle",unsubRunning:null,subSchemeDialogVisible:!1,subSchemeDefaultName:"",unsubFileChanged:null}},computed:{projectKey(){return!this.currentCategory||!this.currentProject?"":`${this.currentCategory}/${this.currentProject}`},hasSelectedProject(){return!!this.currentProject},stepTitle(){return{1:"新建需求",2:"方案设计",3:"代码生成",4:"测试验收"}[this.currentStep]||""},statusText(){return this.projectKey?`步骤 ${this.currentStep} / 4`:"就绪"}},created(){var o,n,l;const s=(o=this.$route.query)==null?void 0:o.category,e=(n=this.$route.query)==null?void 0:n.project,t=parseInt((l=this.$route.query)==null?void 0:l.step)||1,i=!!(s&&e);this.loadCategories(),i?(this.currentCategory=s,this.currentProject=e,this.currentStep=t):this.loadState()},mounted(){console.log("[DevWorkflow][mounted] subscribing to running_sessions"),a.ws.init(),this.unsubRunning=a.ws.on("running_sessions",s=>{var t;const e=((t=s.data)==null?void 0:t.runningSessionIds)||[];console.log("[DevWorkflow][ws] running_sessions event:",e),this.updateTaskStatus(e)}),this.unsubFileChanged=M.on("file:changed",s=>{this.onFileChanged(s)}),console.log("[DevWorkflow][mounted] subscribed to file:changed")},beforeDestroy(){this.unsubRunning&&(this.unsubRunning(),this.unsubRunning=null),this.unsubFileChanged&&(this.unsubFileChanged(),this.unsubFileChanged=null)},watch:{currentProject(){this.updateTitle()},taskStatus(){this.updateTitle()}},methods:{updateDesignSessionId(s){console.log("[DevWorkflow][sessionId] design:",s),this.designSessionId=s},updateCodeSessionId(s){console.log("[DevWorkflow][sessionId] code:",s),this.codeSessionId=s},updateTestSessionId(s){console.log("[DevWorkflow][sessionId] test:",s),this.testSessionId=s},updateTaskStatus(s){const e=[this.designSessionId,this.codeSessionId,this.testSessionId].filter(Boolean);if(console.log("[DevWorkflow][taskStatus] mySessions:",e,"runningIds:",s),e.length===0){console.log("[DevWorkflow][taskStatus] -> idle (no sessions)"),this.taskStatus="idle";return}const t=e.some(i=>s.includes(i));console.log("[DevWorkflow][taskStatus] isRunning:",t,"prevStatus:",this.taskStatus),t?(console.log("[DevWorkflow][taskStatus] -> running"),this.taskStatus="running"):this.taskStatus==="running"&&(console.log("[DevWorkflow][taskStatus] -> completed"),this.taskStatus="completed")},updateTitle(){var t;const s=((t=this.$route.meta)==null?void 0:t.title)||"软件研发";if(!this.currentProject){document.title=`${s} - TXCode`;return}let e="";this.taskStatus==="running"?e="⏳ ":this.taskStatus==="completed"&&(e="✅ "),console.log("[DevWorkflow][updateTitle] status:",this.taskStatus,"title:",`${e}${this.currentProject} · ${s} - TXCode`),document.title=`${e}${this.currentProject} · ${s} - TXCode`},async loadState(){try{const e=(await a.getWorkflowState()).data;e&&(this.currentCategory=e.currentCategory||"",this.currentProject=e.currentProject||"",this.currentStep=e.currentStep||1)}catch(s){console.error("Load workflow state failed:",s)}},async saveState(){try{await a.updateWorkflowState(this.currentCategory,this.currentProject,this.currentStep)}catch(s){console.error("Save workflow state failed:",s)}},async loadCategories(){var s,e;try{const i=((s=(await a.getCwd()).data)==null?void 0:s.current_path)||"";this.reqBasePath=i?`${i}/.txcode/req`:"";const n=((e=(await a.browseFilesystem(this.reqBasePath)).data)==null?void 0:e.items)||[];this.categories=n.filter(l=>l.is_directory).map(l=>l.name),this.categories.sort(),this.currentCategory&&this.categories.includes(this.currentCategory)&&await this.loadProjectsForCategory(this.currentCategory)}catch(t){console.error("Load categories failed:",t),this.categories=[]}},async loadProjectsForCategory(s){var e;if(s){this.isLoadingProjects=!0;try{const t=`${this.reqBasePath}/${s}`,o=((e=(await a.browseFilesystem(t)).data)==null?void 0:e.items)||[];this.projects={},o.filter(n=>n.is_directory).forEach(n=>{const l=`${s}/${n.name}`;this.projects[l]={name:n.name,stepStatus:{}}})}catch(t){console.error("Load projects failed:",t)}finally{this.isLoadingProjects=!1}}},async onCategoryChange(s){this.currentCategory=s,this.currentProject="",this.currentStep=1,this.updateUrlQuery(),s?await this.loadProjectsForCategory(s):this.projects={}},onProjectChange(s){this.currentProject=s,!this.currentProject&&this.currentStep>1&&(this.currentStep=1),this.updateUrlQuery()},onStepChange(s){!this.currentProject&&s>1||(this.currentStep=s,this.updateUrlQuery())},updateUrlQuery(){const s={};this.currentCategory&&(s.category=this.currentCategory),this.currentProject&&(s.project=this.currentProject),this.currentStep>1&&(s.step=String(this.currentStep)),this.$router.replace({query:s}).catch(()=>{})},async createCategory(s){if(this.categories.includes(s)){this.$message.warning("大类已存在");return}try{const e=`${this.reqBasePath}/${s}`;await a.createDirectory(e),this.categories.push(s),this.categories.sort(),this.$message.success(`大类「${s}」创建成功`)}catch(e){console.error("Create category failed:",e),this.$message.error("创建大类失败")}},async renameCategory({oldName:s,newName:e}){if(this.categories.includes(e)){this.$message.warning("名称已存在");return}try{const t=`${this.reqBasePath}/${s}`,i=`${this.reqBasePath}/${e}`;await a.renameFile(t,i);const o=this.categories.indexOf(s);o>-1&&(this.categories[o]=e),this.categories.sort(),this.currentCategory===s&&(this.currentCategory=e,await this.loadProjectsForCategory(e)),await this.saveState(),this.$message.success(`已重命名为「${e}」`)}catch(t){console.error("Rename category failed:",t),this.$message.error("重命名大类失败")}},async deleteCategory(s){try{const e=`${this.reqBasePath}/${s}`;await a.deleteFile(e),this.categories=this.categories.filter(t=>t!==s),this.currentCategory===s&&(this.currentCategory="",this.currentProject="",this.currentStep=1,this.projects={}),await this.saveState(),this.$message.success(`大类「${s}」已删除`)}catch(e){console.error("Delete category failed:",e),this.$message.error("删除大类失败")}},async createRequirement({category:s,name:e}){var n,l,u;if(this.projects[e]){this.$message.warning("需求已存在");return}try{const r=`${this.reqBasePath}/${s}/${e}`;await a.createDirectory(r)}catch(r){console.error("Create requirement directory failed:",r)}const t=`# ${e}方案
16
+
17
+ > 所属大类:${s}
18
+
19
+ ## 用户原始需求
20
+
21
+ ## 业务目标
22
+
23
+ ## 功能点
24
+
25
+ `;try{const r=`${this.reqBasePath}/${s}/${e}/${e}_方案.md`;await a.writeFile(r,t)}catch(r){console.error("Write spec file failed:",r)}let i={designSessionId:"",codeSessionId:"",testSessionId:""};try{const[r,h,c]=await Promise.all([a.createSession(`workflow:${s}/${e}:design`),a.createSession(`workflow:${s}/${e}:code`),a.createSession(`workflow:${s}/${e}:test`)]);i={designSessionId:((n=r.data)==null?void 0:n.id)||"",codeSessionId:((l=h.data)==null?void 0:l.id)||"",testSessionId:((u=c.data)==null?void 0:u.id)||""};const b=`${this.reqBasePath}/${s}/${e}/session.json`;await a.writeFile(b,JSON.stringify(i,null,2))}catch(r){console.error("Create sessions failed:",r)}const o=`${s}/${e}`;this.$set(this.projects,o,{name:e,stepStatus:{}}),this.currentCategory=s,this.currentProject=e,this.$message.success(`需求「${e}」创建成功`),this.$nextTick(()=>{this.currentStep=2})},async createSubScheme(){var e;if(!this.currentProject||!this.currentCategory){this.$message.warning("请先选择一个方案");return}const s=this.currentProject;try{const t=`${this.reqBasePath}/${this.currentCategory}`,o=((e=(await a.browseFilesystem(t)).data)==null?void 0:e.items)||[];let n=0;const l=new RegExp(`^${this.escapeRegex(s)}_(\\d+)$`);o.filter(r=>r.is_directory).forEach(r=>{const h=r.name.match(l);if(h){const c=parseInt(h[1],10);c>n&&(n=c)}});const u=String(n+1).padStart(2,"0");this.subSchemeDefaultName=`${s}_${u}`,this.subSchemeDialogVisible=!0}catch(t){console.error("Browse category failed:",t),this.$message.error("获取子方案列表失败")}},escapeRegex(s){return s.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")},async onSubSchemeConfirm(s){var u,r,h;this.subSchemeDialogVisible=!1;const e=this.currentProject,t=this.currentCategory;try{const c=`${this.reqBasePath}/${t}/${s}`;await a.createDirectory(c)}catch(c){console.error("Create sub-scheme directory failed:",c),this.$message.error("创建子方案目录失败");return}const i=`${this.reqBasePath}/${t}/${e}/${e}_方案.md`,o=`# ${s}_方案
26
+
27
+ > 所属大类:${t}
28
+ > 父方案:[../${e}/${e}_方案.md](../${e}/${e}_方案.md)
29
+
30
+ ## 用户原始需求
31
+
32
+ ## 业务目标
33
+
34
+ ## 功能点
35
+
36
+ `;try{const c=`${this.reqBasePath}/${t}/${s}/${s}_方案.md`;await a.writeFile(c,o)}catch(c){console.error("Write spec file failed:",c)}let n={designSessionId:"",codeSessionId:"",testSessionId:""};try{const[c,b,w]=await Promise.all([a.createSession(`workflow:${t}/${s}:design`),a.createSession(`workflow:${t}/${s}:code`),a.createSession(`workflow:${t}/${s}:test`)]);n={designSessionId:((u=c.data)==null?void 0:u.id)||"",codeSessionId:((r=b.data)==null?void 0:r.id)||"",testSessionId:((h=w.data)==null?void 0:h.id)||"",parent:{name:e,specPath:i}};const $=`${this.reqBasePath}/${t}/${s}/session.json`;await a.writeFile($,JSON.stringify(n,null,2))}catch(c){console.error("Create sessions failed:",c)}const l=`${t}/${s}`;this.$set(this.projects,l,{name:s,stepStatus:{}}),this.$message.success(`子方案「${s}」创建成功`),window.open(`#/views/pc/devWorkflow?category=${encodeURIComponent(t)}&project=${encodeURIComponent(s)}&step=2`,"_blank")},async onSaveSpec(s){if(!this.projectKey)return;const e=`${this.reqBasePath}/${this.currentCategory}/${this.currentProject}/${this.currentProject}_方案.md`;try{await a.writeFile(e,s),this.$message.success("方案已保存")}catch(t){console.error("Save spec failed:",t),this.$message.error("保存方案失败")}},async refreshSpec(){var s;(s=this.$refs.step2Ref)!=null&&s.loadSpec&&await this.$refs.step2Ref.loadSpec()},onFileChanged(s){var n;if(console.log("[DevWorkflow] file:changed received",s),!this.projectKey||!s.filePath){console.log("[DevWorkflow] file:changed skipped (no projectKey or filePath)");return}const e=`${this.reqBasePath}/${this.currentCategory}/${this.currentProject}/${this.currentProject}_方案.md`.replace(/\\/g,"/"),t=(this.reqBasePath||".txcode/req").replace(/\\/g,"/"),i=s.filePath.replace(/\\/g,"/");if(!(i.indexOf(t)!==-1||i===e)){console.log("[DevWorkflow] file:changed skipped (not related to current project)");return}console.log("[DevWorkflow] file:changed triggering refresh, step:",this.currentStep),this.currentStep===2&&(console.log("[DevWorkflow] file:changed → refreshSpec()"),this.refreshSpec()),this.currentStep===3&&((n=this.$refs.step3Ref)!=null&&n.refreshDevLog)&&(console.log("[DevWorkflow] file:changed → refreshDevLog()"),this.$refs.step3Ref.refreshDevLog())}}};var pe=function(){var e=this,t=e._self._c;return t("div",{staticClass:"dev-workflow-view"},[t("WorkflowSidebar",{ref:"sidebar",attrs:{categories:e.categories,projects:e.projects,"current-category":e.currentCategory,"current-project":e.currentProject,"current-step":e.currentStep,"is-loading":e.isLoadingProjects},on:{"category-change":e.onCategoryChange,"project-change":e.onProjectChange,"step-change":e.onStepChange,"delete-category":e.deleteCategory,"rename-category":e.renameCategory}}),t("div",{staticClass:"main-content"},[t("div",{staticClass:"step-content"},[t("Step1NewReq",{directives:[{name:"show",rawName:"v-show",value:e.currentStep===1,expression:"currentStep === 1"}],attrs:{categories:e.categories,projects:e.projects,"base-path":e.reqBasePath,"current-category":e.currentCategory,"current-project":e.currentProject},on:{"category-change":e.onCategoryChange,"project-change":e.onProjectChange,"create-category":e.createCategory,"create-requirement":e.createRequirement}}),e.currentStep===2&&e.hasSelectedProject?t("Step2Design",{ref:"step2Ref",attrs:{category:e.currentCategory,name:e.currentProject,"req-base-path":e.reqBasePath},on:{"update:sessionId":e.updateDesignSessionId,"save-spec":e.onSaveSpec,"spec-updated":e.refreshSpec,"create-sub-scheme":e.createSubScheme}}):e._e(),e.currentStep===3&&e.hasSelectedProject?t("Step3CodeGen",{ref:"step3Ref",attrs:{category:e.currentCategory,name:e.currentProject,"req-base-path":e.reqBasePath},on:{"update:sessionId":e.updateCodeSessionId}}):e._e(),e.currentStep===4&&e.hasSelectedProject?t("Step4Test",{ref:"step4Ref",attrs:{category:e.currentCategory,name:e.currentProject,"req-base-path":e.reqBasePath},on:{"update:sessionId":e.updateTestSessionId}}):e._e(),t("SubSchemeDialog",{attrs:{visible:e.subSchemeDialogVisible,category:e.currentCategory,"parent-name":e.currentProject,"default-name":e.subSchemeDefaultName},on:{"update:visible":function(i){e.subSchemeDialogVisible=i},confirm:e.onSubSchemeConfirm,cancel:function(i){e.subSchemeDialogVisible=!1}}})],1),t("div",{staticClass:"status-bar"},[t("span",[t("i",{staticClass:"el-icon-info"}),e._v(" "+e._s(e.statusText)+" ")]),t("span",[e._v(e._s(e.projectKey||"未选择项目"))])])])],1)},ge=[],me=d(he,pe,ge,!1,null,"fa541c1b");const Ce=me.exports;export{Ce as default};