tianxincode 1.0.49 → 1.0.50
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/config/tx.config.d.ts.map +1 -1
- package/dist/config/tx.config.js +3 -1
- package/dist/config/tx.config.js.map +1 -1
- package/dist/core/db/db.service.d.ts +1 -0
- package/dist/core/db/db.service.d.ts.map +1 -1
- package/dist/core/db/db.service.js +7 -0
- package/dist/core/db/db.service.js.map +1 -1
- package/dist/core/db/init_sql/system.init.d.ts +3 -0
- package/dist/core/db/init_sql/system.init.d.ts.map +1 -0
- package/dist/core/db/init_sql/system.init.js +15 -0
- package/dist/core/db/init_sql/system.init.js.map +1 -0
- package/dist/entity/tx-config.entity.d.ts +1 -0
- package/dist/entity/tx-config.entity.d.ts.map +1 -1
- package/dist/gateway/api/skill/categories_skill.d.ts +3 -0
- package/dist/gateway/api/skill/categories_skill.d.ts.map +1 -0
- package/dist/gateway/api/skill/categories_skill.js +11 -0
- package/dist/gateway/api/skill/categories_skill.js.map +1 -0
- package/dist/gateway/api/skill/detail_skill.js +2 -2
- package/dist/gateway/api/skill/detail_skill.js.map +1 -1
- package/dist/gateway/api/skill/install_skill.d.ts +3 -0
- package/dist/gateway/api/skill/install_skill.d.ts.map +1 -0
- package/dist/gateway/api/skill/install_skill.js +26 -0
- package/dist/gateway/api/skill/install_skill.js.map +1 -0
- package/dist/gateway/api/skill/published_skill.d.ts +3 -0
- package/dist/gateway/api/skill/published_skill.d.ts.map +1 -0
- package/dist/gateway/api/skill/published_skill.js +15 -0
- package/dist/gateway/api/skill/published_skill.js.map +1 -0
- package/dist/gateway/api/skill/skill_routes.d.ts.map +1 -1
- package/dist/gateway/api/skill/skill_routes.js +8 -12
- package/dist/gateway/api/skill/skill_routes.js.map +1 -1
- package/dist/gateway/api/skill/uninstall_skill.d.ts +3 -0
- package/dist/gateway/api/skill/uninstall_skill.d.ts.map +1 -0
- package/dist/gateway/api/skill/uninstall_skill.js +20 -0
- package/dist/gateway/api/skill/uninstall_skill.js.map +1 -0
- package/dist/gateway/api/songbing/auth_cancel_songbing.d.ts +3 -0
- package/dist/gateway/api/songbing/auth_cancel_songbing.d.ts.map +1 -0
- package/dist/gateway/api/songbing/auth_cancel_songbing.js +11 -0
- package/dist/gateway/api/songbing/auth_cancel_songbing.js.map +1 -0
- package/dist/gateway/api/songbing/auth_start_songbing.d.ts +3 -0
- package/dist/gateway/api/songbing/auth_start_songbing.d.ts.map +1 -0
- package/dist/gateway/api/songbing/auth_start_songbing.js +15 -0
- package/dist/gateway/api/songbing/auth_start_songbing.js.map +1 -0
- package/dist/gateway/api/songbing/auth_verify_songbing.d.ts +3 -0
- package/dist/gateway/api/songbing/auth_verify_songbing.d.ts.map +1 -0
- package/dist/gateway/api/songbing/auth_verify_songbing.js +15 -0
- package/dist/gateway/api/songbing/auth_verify_songbing.js.map +1 -0
- package/dist/gateway/api/songbing/config_songbing.d.ts +3 -0
- package/dist/gateway/api/songbing/config_songbing.d.ts.map +1 -0
- package/dist/gateway/api/songbing/config_songbing.js +6 -0
- package/dist/gateway/api/songbing/config_songbing.js.map +1 -0
- package/dist/gateway/api/songbing/save_config_songbing.d.ts +3 -0
- package/dist/gateway/api/songbing/save_config_songbing.d.ts.map +1 -0
- package/dist/gateway/api/songbing/save_config_songbing.js +12 -0
- package/dist/gateway/api/songbing/save_config_songbing.js.map +1 -0
- package/dist/gateway/api/songbing/songbing_routes.d.ts +3 -0
- package/dist/gateway/api/songbing/songbing_routes.d.ts.map +1 -0
- package/dist/gateway/api/songbing/songbing_routes.js +15 -0
- package/dist/gateway/api/songbing/songbing_routes.js.map +1 -0
- package/dist/gateway/api/songbing/sync_models_songbing.d.ts +3 -0
- package/dist/gateway/api/songbing/sync_models_songbing.d.ts.map +1 -0
- package/dist/gateway/api/songbing/sync_models_songbing.js +11 -0
- package/dist/gateway/api/songbing/sync_models_songbing.js.map +1 -0
- package/dist/gateway/api/spec/categories_spec.d.ts +3 -0
- package/dist/gateway/api/spec/categories_spec.d.ts.map +1 -0
- package/dist/gateway/api/spec/categories_spec.js +11 -0
- package/dist/gateway/api/spec/categories_spec.js.map +1 -0
- package/dist/gateway/api/spec/install_spec.d.ts +3 -0
- package/dist/gateway/api/spec/install_spec.d.ts.map +1 -0
- package/dist/gateway/api/spec/install_spec.js +26 -0
- package/dist/gateway/api/spec/install_spec.js.map +1 -0
- package/dist/gateway/api/spec/published_spec.d.ts +3 -0
- package/dist/gateway/api/spec/published_spec.d.ts.map +1 -0
- package/dist/gateway/api/spec/published_spec.js +18 -0
- package/dist/gateway/api/spec/published_spec.js.map +1 -0
- package/dist/gateway/api/spec/spec_routes.d.ts.map +1 -1
- package/dist/gateway/api/spec/spec_routes.js +9 -19
- package/dist/gateway/api/spec/spec_routes.js.map +1 -1
- package/dist/gateway/api/spec/uninstall_spec.d.ts +3 -0
- package/dist/gateway/api/spec/uninstall_spec.d.ts.map +1 -0
- package/dist/gateway/api/spec/uninstall_spec.js +20 -0
- package/dist/gateway/api/spec/uninstall_spec.js.map +1 -0
- package/dist/gateway/api/system/system_routes.d.ts.map +1 -1
- package/dist/gateway/api/system/system_routes.js +2 -0
- package/dist/gateway/api/system/system_routes.js.map +1 -1
- package/dist/gateway/api/system/version_check.d.ts +3 -0
- package/dist/gateway/api/system/version_check.d.ts.map +1 -0
- package/dist/gateway/api/system/version_check.js +47 -0
- package/dist/gateway/api/system/version_check.js.map +1 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/modules/spec/index.d.ts +0 -1
- package/dist/modules/spec/index.d.ts.map +1 -1
- package/dist/modules/spec/index.js +0 -1
- package/dist/modules/spec/index.js.map +1 -1
- package/dist/modules/spec/spec.injector.d.ts.map +1 -1
- package/dist/modules/spec/spec.injector.js +2 -24
- package/dist/modules/spec/spec.injector.js.map +1 -1
- package/dist/repository/index.d.ts +2 -0
- package/dist/repository/index.d.ts.map +1 -1
- package/dist/repository/index.js +1 -0
- package/dist/repository/index.js.map +1 -1
- package/dist/repository/system.repository.d.ts +18 -0
- package/dist/repository/system.repository.d.ts.map +1 -0
- package/dist/repository/system.repository.js +14 -0
- package/dist/repository/system.repository.js.map +1 -0
- package/dist/services/hub/txcode_hub.service.d.ts +98 -0
- package/dist/services/hub/txcode_hub.service.d.ts.map +1 -0
- package/dist/services/hub/txcode_hub.service.js +173 -0
- package/dist/services/hub/txcode_hub.service.js.map +1 -0
- package/dist/services/songbing/songbing.service.d.ts +30 -0
- package/dist/services/songbing/songbing.service.d.ts.map +1 -0
- package/dist/services/songbing/songbing.service.js +155 -0
- package/dist/services/songbing/songbing.service.js.map +1 -0
- package/dist/services/system/device-sync.service.d.ts +2 -0
- package/dist/services/system/device-sync.service.d.ts.map +1 -0
- package/dist/services/system/device-sync.service.js +51 -0
- package/dist/services/system/device-sync.service.js.map +1 -0
- package/package.json +2 -1
- package/web/dist/assets/{ConfirmDialog-B03GcCHQ.js → ConfirmDialog-CINqhvEA.js} +1 -1
- package/web/dist/assets/PcLayout-DEl_7OzB.js +1 -0
- package/web/dist/assets/{aiLogsView-Bt8Xg1Qx.js → aiLogsView-m_EDQ3Z2.js} +1 -1
- package/web/dist/assets/{cssMode-CBb6D87U.js → cssMode-4Nt4dQN8.js} +1 -1
- package/web/dist/assets/{customActionsView-DdjnHzwm.js → customActionsView-CqA23zc4.js} +1 -1
- package/web/dist/assets/{deployView-Cj51_Job.js → deployView-CZIOYWpA.js} +1 -1
- package/web/dist/assets/{designView-RT8tKEN9.js → designView-vScFop-k.js} +1 -1
- package/web/dist/assets/{devWorkflowView-BTozmaiN.js → devWorkflowView-BBDYiAz5.js} +1 -1
- package/web/dist/assets/{devWorkflowViewApp-DLslXEq9.js → devWorkflowViewApp-DA-U7e-D.js} +1 -1
- package/web/dist/assets/{fileZihao-CtZ4bUIH.js → fileZihao-D2TT5yyQ.js} +1 -1
- package/web/dist/assets/{freemarker2-CX3jc3l2.js → freemarker2-BIItB8xo.js} +1 -1
- package/web/dist/assets/{gitChanges-DFRvzL5I.js → gitChanges-Bl5ksKLW.js} +1 -1
- package/web/dist/assets/{gitChangesApp-ZI7-V8oB.js → gitChangesApp-dzIfGmtz.js} +1 -1
- package/web/dist/assets/{handlebars-CTaQD6FN.js → handlebars-BsyQEHQy.js} +1 -1
- package/web/dist/assets/{html-BruJsfYv.js → html-BhwQtsug.js} +1 -1
- package/web/dist/assets/{htmlMode-wewroXLr.js → htmlMode-DWCjFBRw.js} +1 -1
- package/web/dist/assets/{index-Cn73hS12.js → index-BWmvR_0d.js} +150 -150
- package/web/dist/assets/{index-C0xmVTIn.css → index-DzNPtEQX.css} +1 -1
- package/web/dist/assets/{javascript-B4ku8P1-.js → javascript-DXwUJSTZ.js} +1 -1
- package/web/dist/assets/{jsonMode-BIvVuBMG.js → jsonMode-BnmFmR-Q.js} +1 -1
- package/web/dist/assets/{liquid-Bo3G0Ep7.js → liquid-DDyzdvJI.js} +1 -1
- package/web/dist/assets/{mdx-Duv0ylZz.js → mdx-BmcHTEVO.js} +1 -1
- package/web/dist/assets/{mediaChat-RT7iqqYb.js → mediaChat-BAOZIeJr.js} +1 -1
- package/web/dist/assets/{python-CEhCctGm.js → python-CS2xzwXn.js} +1 -1
- package/web/dist/assets/{razor-DPK8nTD7.js → razor-DmA5x3s1.js} +1 -1
- package/web/dist/assets/{taskView-sOyebRqn.js → taskView-BaKz6N0T.js} +1 -1
- package/web/dist/assets/{terminalView-GTYtDlus.js → terminalView-ByU-IRop.js} +1 -1
- package/web/dist/assets/{tsMode-BZvUU1nf.js → tsMode-BzdGwv1C.js} +1 -1
- package/web/dist/assets/{typescript-CmEn-k1B.js → typescript-DqgHOT1h.js} +1 -1
- package/web/dist/assets/{wikiView-CRjg-cZ8.js → wikiView-CH95iVWL.js} +1 -1
- package/web/dist/assets/{xml-bjvdKeyy.js → xml-DBiYZn44.js} +1 -1
- package/web/dist/assets/{yaml-N5RXWxJk.js → yaml-CTPYHtxL.js} +1 -1
- package/web/dist/index.html +2 -2
- package/web/dist/assets/PcLayout-ZTdJNg7G.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{n as d,a as n}from"./index-
|
|
1
|
+
import{n as d,a as n}from"./index-BWmvR_0d.js";const u={name:"CustomActionsView",data(){return{actions:[],currentType:"design",showDialog:!1,isEditing:!1,currentAction:null,form:{action_type:"design",name:"",prompt:"",auto_send:!1,sort_order:0},actionTypes:[{value:"design",label:"方案设计"},{value:"code",label:"代码生成"},{value:"test",label:"测试验收"}]}},computed:{filteredActions(){return this.actions.filter(s=>s.action_type===this.currentType)}},async created(){await this.loadActions();const s=this.$route.query.type;s&&["design","code","test"].includes(s)&&(this.currentType=s)},methods:{async loadActions(){try{const s=await n.getCustomActions();this.actions=s.data||[]}catch(s){console.error("Load actions failed:",s),this.$message.error("加载动作失败")}},selectType(s){this.currentType=s},getCountByType(s){return this.actions.filter(t=>t.action_type===s).length},openCreateDialog(){this.isEditing=!1,this.form={action_type:this.currentType,name:"",prompt:"",auto_send:!1,sort_order:0},this.showDialog=!0},openEditDialog(s){this.isEditing=!0,this.currentAction=s,this.form={action_type:s.action_type,name:s.name,prompt:s.prompt,auto_send:!!s.auto_send,sort_order:s.sort_order||0},this.showDialog=!0},closeDialog(){this.showDialog=!1,this.currentAction=null},async saveAction(){if(!this.form.name||!this.form.prompt){this.$message.error("请填写必填项");return}try{this.isEditing&&this.currentAction?(await n.updateCustomAction(this.currentAction.id,this.form),this.$message.success("动作已更新")):(await n.createCustomAction(this.form),this.$message.success("动作已创建")),this.closeDialog(),await this.loadActions()}catch(s){this.$message.error("保存失败: "+s.message)}},async deleteAction(s){if(confirm(`确定删除动作 "${s.name}" 吗?`))try{await n.deleteCustomAction(s.id),this.$message.success("动作已删除"),await this.loadActions()}catch(t){this.$message.error("删除失败: "+t.message)}},getTypeLabel(s){return{design:"方案设计",code:"代码生成",test:"测试验收"}[s]||s}}};var p=function(){var t=this,e=t._self._c;return e("div",{staticClass:"flex-1 flex overflow-hidden bg-[#1e1e1e]"},[e("div",{staticClass:"w-48 border-r border-border bg-sidebar shrink-0 flex flex-col"},[t._m(0),e("div",{staticClass:"flex-1 overflow-auto py-2"},t._l(t.actionTypes,function(r){return e("div",{key:r.value,staticClass:"px-4 py-2 cursor-pointer flex items-center justify-between",class:t.currentType===r.value?"bg-accent/20 text-accent":"text-textMuted hover:bg-white/5",on:{click:function(a){return t.selectType(r.value)}}},[e("span",{staticClass:"text-sm"},[t._v(t._s(r.label))]),e("span",{staticClass:"text-xs opacity-60"},[t._v("("+t._s(t.getCountByType(r.value))+")")])])}),0)]),e("div",{staticClass:"flex-1 flex flex-col overflow-hidden"},[e("div",{staticClass:"px-4 py-3 border-b border-border bg-sidebar shrink-0"},[e("div",{staticClass:"flex items-center justify-between"},[e("div",{staticClass:"flex items-center gap-2"},[e("i",{staticClass:"fa-solid fa-bolt text-accent"}),e("span",{staticClass:"text-white font-medium"},[t._v("自定义动作")]),e("span",{staticClass:"text-xs text-textMuted"},[t._v("("+t._s(t.getTypeLabel(t.currentType))+")")]),e("span",{staticClass:"text-xs text-textMuted"},[t._v(t._s(t.filteredActions.length)+" 个动作")])]),e("button",{staticClass:"px-3 py-1 bg-accent text-white text-xs rounded hover:bg-accent/80",on:{click:t.openCreateDialog}},[e("i",{staticClass:"fa-solid fa-plus mr-1"}),t._v(" 新增动作 ")])])]),e("div",{staticClass:"flex-1 overflow-auto p-4"},[e("table",{staticClass:"w-full text-sm"},[t._m(1),e("tbody",[t._l(t.filteredActions,function(r){return e("tr",{key:r.id,staticClass:"hover:bg-white/5"},[e("td",{staticClass:"px-3 py-2 border-b border-border/30 text-gray-200"},[t._v(t._s(r.name))]),e("td",{staticClass:"px-3 py-2 border-b border-border/30 text-gray-300 max-w-[300px] truncate",attrs:{title:r.prompt}},[t._v(t._s(r.prompt))]),e("td",{staticClass:"px-3 py-2 border-b border-border/30"},[r.auto_send?e("span",{staticClass:"text-xs px-2 py-0.5 rounded bg-green-500/20 text-green-400"},[t._v("是")]):e("span",{staticClass:"text-xs px-2 py-0.5 rounded bg-gray-500/20 text-gray-400"},[t._v("否")])]),e("td",{staticClass:"px-3 py-2 border-b border-border/30 text-gray-300"},[t._v(t._s(r.sort_order))]),e("td",{staticClass:"px-3 py-2 border-b border-border/30"},[e("div",{staticClass:"flex items-center gap-2"},[e("button",{staticClass:"text-xs px-2 py-1 text-blue-400 hover:bg-blue-500/20 rounded",on:{click:function(a){return t.openEditDialog(r)}}},[t._v("编辑")]),e("button",{staticClass:"text-xs px-2 py-1 text-red-400 hover:bg-red-500/20 rounded",on:{click:function(a){return t.deleteAction(r)}}},[t._v("删除")])])])])}),t.filteredActions.length===0?e("tr",[e("td",{staticClass:"px-3 py-8 text-center text-textMuted",attrs:{colspan:"5"}},[t._v('暂无动作,点击"新增动作"创建')])]):t._e()],2)])])]),t.showDialog?e("div",{staticClass:"fixed inset-0 bg-black/50 flex items-center justify-center z-50"},[e("div",{staticClass:"bg-sidebar border border-border rounded-lg w-[500px] max-h-[80vh] overflow-auto"},[e("div",{staticClass:"px-4 py-3 border-b border-border flex items-center justify-between"},[e("h3",{staticClass:"text-white font-medium"},[t._v(t._s(t.isEditing?"编辑动作":"新增动作"))]),e("button",{staticClass:"text-textMuted hover:text-white text-sm",on:{click:t.closeDialog}},[t._v("关闭")])]),e("div",{staticClass:"p-4 space-y-4"},[e("div",[t._m(2),e("select",{directives:[{name:"model",rawName:"v-model",value:t.form.action_type,expression:"form.action_type"}],staticClass:"w-full bg-black/20 border border-white/10 text-white text-sm px-3 py-2 rounded",attrs:{disabled:t.isEditing},on:{change:function(r){var a=Array.prototype.filter.call(r.target.options,function(o){return o.selected}).map(function(o){var l="_value"in o?o._value:o.value;return l});t.$set(t.form,"action_type",r.target.multiple?a:a[0])}}},[e("option",{attrs:{value:"design"}},[t._v("方案设计")]),e("option",{attrs:{value:"code"}},[t._v("代码生成")]),e("option",{attrs:{value:"test"}},[t._v("测试验收")])])]),e("div",[t._m(3),e("input",{directives:[{name:"model",rawName:"v-model",value:t.form.name,expression:"form.name"}],staticClass:"w-full bg-black/20 border border-white/10 text-white text-sm px-3 py-2 rounded",attrs:{type:"text",placeholder:"按钮显示名称"},domProps:{value:t.form.name},on:{input:function(r){r.target.composing||t.$set(t.form,"name",r.target.value)}}})]),e("div",[t._m(4),e("textarea",{directives:[{name:"model",rawName:"v-model",value:t.form.prompt,expression:"form.prompt"}],staticClass:"w-full bg-black/20 border border-white/10 text-white text-sm px-3 py-2 rounded resize-none",attrs:{rows:"4",placeholder:"点击按钮后填入输入框的内容"},domProps:{value:t.form.prompt},on:{input:function(r){r.target.composing||t.$set(t.form,"prompt",r.target.value)}}})]),e("div",[e("label",{staticClass:"block text-xs text-textMuted mb-1"},[t._v("排序")]),e("input",{directives:[{name:"model",rawName:"v-model.number",value:t.form.sort_order,expression:"form.sort_order",modifiers:{number:!0}}],staticClass:"w-full bg-black/20 border border-white/10 text-white text-sm px-3 py-2 rounded",attrs:{type:"number",placeholder:"数字越小越靠前"},domProps:{value:t.form.sort_order},on:{input:function(r){r.target.composing||t.$set(t.form,"sort_order",t._n(r.target.value))},blur:function(r){return t.$forceUpdate()}}})]),e("div",{staticClass:"flex items-center gap-2"},[e("input",{directives:[{name:"model",rawName:"v-model",value:t.form.auto_send,expression:"form.auto_send"}],staticClass:"accent-accent",attrs:{type:"checkbox",id:"autoSend"},domProps:{checked:Array.isArray(t.form.auto_send)?t._i(t.form.auto_send,null)>-1:t.form.auto_send},on:{change:function(r){var a=t.form.auto_send,o=r.target,l=!!o.checked;if(Array.isArray(a)){var c=null,i=t._i(a,c);o.checked?i<0&&t.$set(t.form,"auto_send",a.concat([c])):i>-1&&t.$set(t.form,"auto_send",a.slice(0,i).concat(a.slice(i+1)))}else t.$set(t.form,"auto_send",l)}}}),e("label",{staticClass:"text-xs text-textMuted",attrs:{for:"autoSend"}},[t._v("点击后自动发送(无需手动确认)")])])]),e("div",{staticClass:"px-4 py-3 border-t border-border flex justify-end gap-2"},[e("button",{staticClass:"px-4 py-1 text-textMuted text-sm rounded hover:bg-white/10",on:{click:t.closeDialog}},[t._v("取消")]),e("button",{staticClass:"px-4 py-1 bg-accent text-white text-sm rounded hover:bg-accent/80",on:{click:t.saveAction}},[t._v(" "+t._s(t.isEditing?"保存":"创建")+" ")])])])]):t._e()])},x=[function(){var s=this,t=s._self._c;return t("div",{staticClass:"px-4 py-3 border-b border-border"},[t("span",{staticClass:"text-white text-sm font-medium"},[s._v("类型")])])},function(){var s=this,t=s._self._c;return t("thead",{staticClass:"bg-sidebar sticky top-0"},[t("tr",[t("th",{staticClass:"px-3 py-2 text-left text-xs font-bold text-textMuted uppercase border-b border-border"},[s._v("名称")]),t("th",{staticClass:"px-3 py-2 text-left text-xs font-bold text-textMuted uppercase border-b border-border"},[s._v("提示词")]),t("th",{staticClass:"px-3 py-2 text-left text-xs font-bold text-textMuted uppercase border-b border-border"},[s._v("自动发送")]),t("th",{staticClass:"px-3 py-2 text-left text-xs font-bold text-textMuted uppercase border-b border-border"},[s._v("排序")]),t("th",{staticClass:"px-3 py-2 text-left text-xs font-bold text-textMuted uppercase border-b border-border"},[s._v("操作")])])])},function(){var s=this,t=s._self._c;return t("label",{staticClass:"block text-xs text-textMuted mb-1"},[s._v("类型 "),t("span",{staticClass:"text-red-400"},[s._v("*")])])},function(){var s=this,t=s._self._c;return t("label",{staticClass:"block text-xs text-textMuted mb-1"},[s._v("名称 "),t("span",{staticClass:"text-red-400"},[s._v("*")])])},function(){var s=this,t=s._self._c;return t("label",{staticClass:"block text-xs text-textMuted mb-1"},[s._v("提示词 "),t("span",{staticClass:"text-red-400"},[s._v("*")])])}],m=d(u,p,x,!1,null,null);const f=m.exports;export{f as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{n as c,a as d,e as _,K as m,d as y,R as v,g}from"./index-Cn73hS12.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-BWmvR_0d.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,4 +1,4 @@
|
|
|
1
|
-
import{n as l,a as r,C as h,f as u,R as f,I as p,S as m,F as g,c as v,M as b,g as x,s as C,b as w,e as y,K as _,d as S}from"./index-
|
|
1
|
+
import{n as l,a as r,C as h,f as u,R as f,I as p,S as m,F as g,c as v,M as b,g as x,s as C,b as w,e as y,K as _,d as S}from"./index-BWmvR_0d.js";import{m as P}from"./mediaChat-BAOZIeJr.js";const k={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
2
|
<html lang="zh-CN">
|
|
3
3
|
<head>
|
|
4
4
|
<meta charset="UTF-8">
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{n as d,I as m,R as g,S as f,M as v,g as p,a as o,s as C,b as y,F as _,c as k,e as $,K as P,d as D}from"./index-
|
|
1
|
+
import{n as d,I as m,R as g,S as f,M as v,g as p,a as o,s as C,b as y,F as _,c as k,e as $,K as P,d as D}from"./index-BWmvR_0d.js";import{m as S}from"./mediaChat-BAOZIeJr.js";const M={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 x=function(){var e=this,t=e._self._c;return t("div",{staticClass:"workflow-sidebar"},[t("div",{staticClass:"sidebar-header"},[t("h3",[e._v("当前项目")]),t("div",{staticClass:"project-display-row"},[t("span",{staticClass:"label"},[e._v("大类")]),t("span",{staticClass:"value"},[e._v(e._s(e.currentCategory||"-"))])]),t("div",{staticClass:"project-display-row"},[t("span",{staticClass:"label"},[e._v("需求")]),t("span",{staticClass:"value"},[e._v(e._s(e.currentProject||"-"))])])]),t("div",{staticClass:"step-list"},e._l(e.visibleSteps,function(i){return t("div",{key:i.id,class:["step-item",{active:e.currentStep===i.id,completed:e.isStepCompleted(i.id)}],on:{click:function(a){return e.onStepClick(i.id)}}},[t("div",{staticClass:"step-icon"},[t("i",{class:i.icon})]),t("div",{staticClass:"step-info"},[t("div",{staticClass:"step-title"},[e._v(e._s(i.title))]),t("div",{staticClass:"step-desc"},[e._v(e._s(i.desc))])]),t("div",{staticClass:"step-status"},[e.isStepCompleted(i.id)?t("i",{staticClass:"el-icon-circle-check",staticStyle:{color:"#22c55e"}}):e._e()])])}),0)])},T=[],F=d(M,x,T,!1,null,"2e87f0c0");const j=F.exports,R={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 V=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)},q=[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(" 创建新需求")])])}],B=d(R,V,q,!1,null,"30b4a46d");const L=B.exports,z={name:"DesignDiscuss",components:{ModelSelectDialog:v,SkillSelectDialog:f,ResizableTextarea:g,ImagePreviewList:m},mixins:[S()],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,skillCursorPos:-1,sessionStatus:"idle",wsUnsubscribe:null}},computed:{specFilePath(){return!this.category||!this.name?"":`${this.reqBasePath}/${this.category}/${this.name}/${this.name}_方案.md`},sessionFilePath(){return!this.category||!this.name?"":`${this.reqBasePath}/${this.category}/${this.name}/session.json`}},watch:{category:{handler(){this.loadData()}},name:{handler(){this.loadData()}}},async mounted(){document.addEventListener("mousedown",this.onDocumentMouseDown),await this.loadData(),await this.loadDefaultModel()},beforeDestroy(){document.removeEventListener("mousedown",this.onDocumentMouseDown),this.wsUnsubscribe&&this.wsUnsubscribe()},methods:{handleKeydown(s){if(s.key==="Enter")if(s.ctrlKey){const e=s.target,t=e.selectionStart,i=e.selectionEnd,a=this.inputMessage;this.inputMessage=a.substring(0,t)+`
|
|
2
2
|
`+a.substring(i),this.$nextTick(()=>{e.selectionStart=e.selectionEnd=t+1})}else s.preventDefault(),this.sendMessage()},onDocumentMouseDown(s){this.activeMenuId&&!s.target.closest(".item-actions")&&(this.activeMenuId=null),this.dropdownOpen&&!s.target.closest(".discuss-dropdown")&&(this.dropdownOpen=!1)},async loadData(){await this.loadDiscussions()},async loadDiscussions(){var s;if(!this.category||!this.name){this.discussions=[],this.currentDiscussion=null;return}try{const e=await o.getFileContent(this.sessionFilePath);if(e&&((s=e.data)!=null&&s.content)){const t=JSON.parse(e.data.content);this.discussions=t.designDiscussions||[]}else this.discussions=[];this.discussions.length>0&&!this.currentDiscussion&&await this.switchDiscussion(this.discussions[0])}catch(e){console.error("Load discussions failed:",e),this.discussions=[],this.currentDiscussion=null}},async saveDiscussions(){var s;if(!(!this.category||!this.name))try{const e=await o.getFileContent(this.sessionFilePath);let t={};e&&((s=e.data)!=null&&s.content)&&(t=JSON.parse(e.data.content)),t.designDiscussions=this.discussions,await o.writeFile(this.sessionFilePath,JSON.stringify(t,null,2))}catch(e){console.error("Save discussions failed:",e)}},async createDiscussion(){var s,e,t,i;try{const a=`探讨${this.discussions.length+1}`,n=await o.createSession(a),l={id:((s=n.data)==null?void 0:s.id)||((e=n.data)==null?void 0:e.sessionId)||Date.now().toString(),sessionId:((t=n.data)==null?void 0:t.id)||((i=n.data)==null?void 0:i.sessionId),title:a,createdAt:new Date().toISOString()};this.discussions.push(l),await this.saveDiscussions(),this.dropdownOpen=!1,await this.switchDiscussion(l)}catch(a){console.error("Create discussion failed:",a),this.$message.error("创建探讨失败")}},async switchDiscussion(s){this.wsUnsubscribe&&(this.wsUnsubscribe(),this.wsUnsubscribe=null),this.currentDiscussion=s,this.dropdownOpen=!1,this.activeMenuId=null,this.logItems=[],this.inputMessage="",this.disabled=!1,this.stopping=!1,this.promptTokens=0,this.sessionStatus="idle",this.mediaFiles=[],s&&s.sessionId&&(await this.loadMessages(),this.subscribeSession())},startRename(s){this.activeMenuId=null,this.$prompt("请输入新名称","重命名探讨",{confirmButtonText:"确定",cancelButtonText:"取消",inputValue:s.title}).then(async({value:e})=>{e&&e.trim()&&(s.title=e.trim(),await this.saveDiscussions())}).catch(()=>{})},confirmDelete(s){this.activeMenuId=null,this.deleteTarget=s,this.deleteDialogVisible=!0},async doDelete(){const s=this.deleteTarget;if(this.deleteDialogVisible=!1,this.deleteTarget=null,!!s)try{await o.deleteSession(s.sessionId);const e=this.discussions.findIndex(t=>t.id===s.id);e!==-1&&this.discussions.splice(e,1),await this.saveDiscussions(),this.currentDiscussion&&this.currentDiscussion.id===s.id&&(this.discussions.length>0?await this.switchDiscussion(this.discussions[0]):(this.wsUnsubscribe&&(this.wsUnsubscribe(),this.wsUnsubscribe=null),this.currentDiscussion=null,this.logItems=[],this.promptTokens=0,this.sessionStatus="idle"))}catch(e){console.error("Delete discussion failed:",e),this.$message.error("删除探讨失败")}},async sendMessage(){const s=this.inputMessage.trim(),e=this.mediaFiles&&this.mediaFiles.length>0;if(!s&&!e||this.disabled)return;if(!this.currentDiscussion||!this.currentDiscussion.sessionId){this.$message.error("会话不存在,请刷新页面");return}this.wsUnsubscribe||this.subscribeSession();const t=`方案路径:${this.specFilePath}
|
|
3
3
|
|
|
4
4
|
这个是对这个方案的探讨 你只需要回答用户的问题即可 不需要修改方案 也不要修改代码
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{n as p,h as g,g as m,w as h,i as v,a as o}from"./index-Cn73hS12.js";const w={name:"AppWorkflowStep",props:{currentStep:{type:Number,default:1}},data(){return{steps:[{id:1,label:"需求"},{id:2,label:"设计"},{id:3,label:"代码"},{id:4,label:"测试"}]}}};var y=function(){var s=this,t=s._self._c;return t("div",{staticClass:"workflow-step-bar"},s._l(s.steps,function(i){return t("div",{key:i.id,staticClass:"step-item",class:{active:s.currentStep>=i.id,current:s.currentStep===i.id},on:{click:function(r){return s.$emit("step-change",i.id)}}},[t("div",{staticClass:"step-number"},[s._v(s._s(i.id))]),t("div",{staticClass:"step-label"},[s._v(s._s(i.label))])])}),0)},b=[],S=p(w,y,b,!1,null,"1cf39c0c");const $=S.exports,k={name:"AppStep1Req",props:{categories:{type:Array,default:()=>[]},projects:{type:Object,default:()=>({})},reqBasePath:{type:String,default:""},currentCategory:{type:String,default:""},currentProject:{type:String,default:""}},data(){return{selectedCategory:"",selectedProject:"",dialogVisible:!1,dialogInput:"",requirementDialogVisible:!1,requirementDialogInput:""}},computed:{requirementList(){if(!this.selectedCategory)return[];const e=`${this.selectedCategory}/`;return Object.keys(this.projects).filter(s=>s.startsWith(e)).map(s=>s.split("/")[1]).sort()}},watch:{currentCategory:{immediate:!0,handler(e){this.selectedCategory=e||""}},currentProject:{immediate:!0,handler(e){this.selectedProject=e||""}},selectedCategory(e){e||(this.selectedProject="")}},methods:{selectCategory(e){this.selectedCategory=e,this.$emit("category-change",e),this.$emit("project-change","")},selectProject(e){this.selectedProject=e,this.$emit("project-change",e)},showCreateCategoryDialog(){this.dialogInput="",this.dialogVisible=!0},handleDialogConfirm(){const e=this.dialogInput.trim();e&&(this.$emit("create-category",e),this.dialogVisible=!1)},showCreateRequirementDialog(){this.selectedCategory&&(this.requirementDialogInput="",this.requirementDialogVisible=!0)},handleCreateRequirementConfirm(){const e=this.requirementDialogInput.trim();e&&(this.requirementList.includes(e)||(this.$emit("create-requirement",{category:this.selectedCategory,name:e}),this.requirementDialogVisible=!1))}}};var P=function(){var s=this,t=s._self._c;return t("div",{staticClass:"step1-req"},[t("div",{staticClass:"category-section"},[s._m(0),t("div",{staticClass:"category-list"},[s._l(s.categories,function(i){return t("div",{key:i,staticClass:"category-item",class:{active:s.selectedCategory===i},on:{click:function(r){return s.selectCategory(i)}}},[t("i",{staticClass:"fa-solid fa-folder"}),t("span",[s._v(s._s(i))])])}),t("div",{staticClass:"category-item add-btn",on:{click:s.showCreateCategoryDialog}},[t("i",{staticClass:"fa-solid fa-plus"}),t("span",[s._v("新建大类")])])],2)]),t("div",{staticClass:"divider"}),t("div",{staticClass:"project-section"},[t("div",{staticClass:"section-header"},[t("span",[s._v("选择需求")]),t("button",{staticClass:"btn-primary",attrs:{disabled:!s.selectedCategory},on:{click:s.showCreateRequirementDialog}},[t("i",{staticClass:"fa-solid fa-plus"}),s._v(" 新建 ")])]),t("div",{staticClass:"project-list"},[s._l(s.requirementList,function(i){return t("div",{key:i,staticClass:"project-item",on:{click:function(r){return s.selectProject(i)}}},[t("div",{staticClass:"project-info"},[t("i",{staticClass:"fa-solid fa-folder-open"}),t("span",[s._v(s._s(i))])]),t("i",{staticClass:"fa-solid fa-chevron-right"})])}),!s.requirementList.length&&s.selectedCategory?t("div",{staticClass:"empty-hint"},[s._v(" 暂无需求,请点击新建 ")]):s._e(),s.selectedCategory?s._e():t("div",{staticClass:"empty-hint"},[s._v(" 请先选择大类 ")])],2)]),s.dialogVisible?t("div",{staticClass:"dialog-overlay",on:{click:function(i){if(i.target!==i.currentTarget)return null;s.dialogVisible=!1}}},[t("div",{staticClass:"dialog"},[t("div",{staticClass:"dialog-header"},[t("span",[s._v("新建大类")]),t("button",{staticClass:"close-btn",on:{click:function(i){s.dialogVisible=!1}}},[t("i",{staticClass:"fa-solid fa-xmark"})])]),t("div",{staticClass:"dialog-body"},[t("input",{directives:[{name:"model",rawName:"v-model",value:s.dialogInput,expression:"dialogInput"}],attrs:{type:"text",placeholder:"输入大类名称"},domProps:{value:s.dialogInput},on:{keydown:function(i){return!i.type.indexOf("key")&&s._k(i.keyCode,"enter",13,i.key,"Enter")?null:s.handleDialogConfirm.apply(null,arguments)},input:function(i){i.target.composing||(s.dialogInput=i.target.value)}}})]),t("div",{staticClass:"dialog-footer"},[t("button",{staticClass:"btn-cancel",on:{click:function(i){s.dialogVisible=!1}}},[s._v("取消")]),t("button",{staticClass:"btn-confirm",on:{click:s.handleDialogConfirm}},[s._v("确定")])])])]):s._e(),s.requirementDialogVisible?t("div",{staticClass:"dialog-overlay",on:{click:function(i){if(i.target!==i.currentTarget)return null;s.requirementDialogVisible=!1}}},[t("div",{staticClass:"dialog"},[t("div",{staticClass:"dialog-header"},[t("span",[s._v("新建需求")]),t("button",{staticClass:"close-btn",on:{click:function(i){s.requirementDialogVisible=!1}}},[t("i",{staticClass:"fa-solid fa-xmark"})])]),t("div",{staticClass:"dialog-body"},[t("input",{directives:[{name:"model",rawName:"v-model",value:s.requirementDialogInput,expression:"requirementDialogInput"}],attrs:{type:"text",placeholder:"输入需求名称"},domProps:{value:s.requirementDialogInput},on:{keydown:function(i){return!i.type.indexOf("key")&&s._k(i.keyCode,"enter",13,i.key,"Enter")?null:s.handleCreateRequirementConfirm.apply(null,arguments)},input:function(i){i.target.composing||(s.requirementDialogInput=i.target.value)}}})]),t("div",{staticClass:"dialog-footer"},[t("button",{staticClass:"btn-cancel",on:{click:function(i){s.requirementDialogVisible=!1}}},[s._v("取消")]),t("button",{staticClass:"btn-confirm",on:{click:s.handleCreateRequirementConfirm}},[s._v("确定")])])])]):s._e()])},D=[function(){var e=this,s=e._self._c;return s("div",{staticClass:"section-header"},[s("span",[e._v("选择大类")])])}],I=p(k,P,D,!1,null,"ff2d2605");const M=I.exports,q={name:"AppStep2Design",components:{FileSelectDrawer:g},props:{category:{type:String,default:""},name:{type:String,default:""},reqBasePath:{type:String,default:""}},data(){return{mode:"chat",specView:"edit",specContent:"",inputMessage:"",isProcessing:!1,stopping:!1,logItems:[],sessionId:"",modelName:"",promptTokens:0,showModelDrawer:!1,showCommandDrawer:!1,showFileDrawer:!1,models:[],logSeq:0,wsUnsubscribe:null,parentInfo:null}},computed:{specFilePath(){return!this.category||!this.name?"":`${this.reqBasePath}/${this.category}/${this.name}/${this.name}_方案.md`},renderedContent(){return m(this.specContent||"")}},watch:{category:{handler(){this.loadData()}},name:{handler(){this.loadData()}},reqBasePath:{handler(e){e&&this.loadData()}}},async mounted(){h.init(),await this.loadModels(),await this.loadDefaultModel(),await this.loadData()},beforeDestroy(){this.wsUnsubscribe&&this.wsUnsubscribe()},methods:{async loadData(){this.reqBasePath&&await Promise.all([this.loadSpec(),this.loadSession()])},async loadSpec(){var e;if(!this.category||!this.name){this.specContent="";return}try{const s=await o.getFileContent(this.specFilePath);this.specContent=((e=s.data)==null?void 0:e.content)||""}catch{this.specContent=""}},async loadSession(){var e;if(!this.category||!this.name){this.sessionId="",this.parentInfo=null;return}try{const s=`${this.reqBasePath}/${this.category}/${this.name}/session.json`,t=await o.getFileContent(s);if(t&&((e=t.data)!=null&&e.content)){const i=JSON.parse(t.data.content);this.sessionId=i.designSessionId||"",this.parentInfo=i.parent||null}else this.sessionId="",this.parentInfo=null;this.sessionId&&(await this.loadMessages(),this.subscribeSession())}catch{this.sessionId="",this.parentInfo=null}},async saveSpec(){if(this.specFilePath)try{await o.writeFile(this.specFilePath,this.specContent),this.$emit("save-spec",this.specContent),this.$emit("spec-updated"),this.$message.success("方案已保存")}catch{this.$message.error("保存失败")}},async loadModels(){try{const e=await o.getModels();this.models=e.data||[]}catch(e){console.error("Load models failed:",e)}},async loadDefaultModel(){var e;try{const s=await o.getConfig("defaultModel");(e=s.data)!=null&&e.value&&(this.modelName=s.data.value)}catch{this.modelName="gpt-4o"}},selectModel(e){const s=e.name.split("/");this.modelName=s.length>2?s.slice(1).join("/"):e.name,o.setConfig("defaultModel",this.modelName),this.showModelDrawer=!1},async loadMessages(){if(this.sessionId)try{const e=await v(this.sessionId);this.logItems=(e.data||[]).map(s=>s.type==="think"?{type:"think",content:s.content||"",_id:`log-${++this.logSeq}`}:s.type==="step"?{type:"step",thought:s.thought,toolCalls:s.toolCalls||[],success:s.success,_id:`log-${++this.logSeq}`}:s.type==="chat"?{type:"chat",content:s.content,_id:`log-${++this.logSeq}`}:s.type==="todos"?{type:"todos",todos:s.todos||[],_id:`log-${++this.logSeq}`}:{type:"system",content:String(s),_id:`log-${++this.logSeq}`}),this.scrollToBottom()}catch(e){console.error("Load messages failed:",e)}},subscribeSession(){this.sessionId&&(this.wsUnsubscribe&&this.wsUnsubscribe(),this.wsUnsubscribe=h.subscribe(this.sessionId,{running_sessions:e=>{const s=(e==null?void 0:e.runningSessionIds)||[];this.isProcessing=s.includes(this.sessionId)},todos:e=>{this.logItems.push({type:"todos",todos:e.todos,_id:`log-${++this.logSeq}`}),this.scrollToBottom()},step:e=>{var s;this.logItems.push({type:"step",thought:e==null?void 0:e.thought,toolCalls:(e==null?void 0:e.toolCalls)||[],success:e==null?void 0:e.success,_id:`log-${++this.logSeq}`}),(s=e==null?void 0:e.usage)!=null&&s.promptTokens&&(this.promptTokens=e.usage.promptTokens),this.scrollToBottom()},compact:e=>{this.logItems.push({type:"system",content:`【压缩完成】${e.summary||""}`,_id:`log-${++this.logSeq}`}),this.loadMessages()},done:e=>{var s;this.isProcessing=!1,this.stopping=!1,e!=null&&e.modelName&&(this.modelName=e.modelName),(s=e==null?void 0:e.usage)!=null&&s.promptTokens&&(this.promptTokens=e.usage.promptTokens),e!=null&&e.response&&this.logItems.push({type:"think",content:e.response,_id:`log-${++this.logSeq}`}),this.$emit("spec-updated"),this.loadSpec(),this.scrollToBottom()},stopped:()=>{this.isProcessing=!1,this.stopping=!1,this.logItems.push({type:"think",content:"【已停止】",_id:`log-${++this.logSeq}`}),this.scrollToBottom()},error:e=>{this.isProcessing=!1,this.stopping=!1,this.$message.error((e==null?void 0:e.error)||"发生错误")}}))},async sendMessage(){const e=this.inputMessage.trim();if(!e||this.isProcessing||!this.sessionId)return;this.wsUnsubscribe||this.subscribeSession();let s="";this.logItems.length===0&&this.parentInfo&&(s=`
|
|
1
|
+
import{n as p,h as g,g as m,w as h,i as v,a as o}from"./index-BWmvR_0d.js";const w={name:"AppWorkflowStep",props:{currentStep:{type:Number,default:1}},data(){return{steps:[{id:1,label:"需求"},{id:2,label:"设计"},{id:3,label:"代码"},{id:4,label:"测试"}]}}};var y=function(){var s=this,t=s._self._c;return t("div",{staticClass:"workflow-step-bar"},s._l(s.steps,function(i){return t("div",{key:i.id,staticClass:"step-item",class:{active:s.currentStep>=i.id,current:s.currentStep===i.id},on:{click:function(r){return s.$emit("step-change",i.id)}}},[t("div",{staticClass:"step-number"},[s._v(s._s(i.id))]),t("div",{staticClass:"step-label"},[s._v(s._s(i.label))])])}),0)},b=[],S=p(w,y,b,!1,null,"1cf39c0c");const $=S.exports,k={name:"AppStep1Req",props:{categories:{type:Array,default:()=>[]},projects:{type:Object,default:()=>({})},reqBasePath:{type:String,default:""},currentCategory:{type:String,default:""},currentProject:{type:String,default:""}},data(){return{selectedCategory:"",selectedProject:"",dialogVisible:!1,dialogInput:"",requirementDialogVisible:!1,requirementDialogInput:""}},computed:{requirementList(){if(!this.selectedCategory)return[];const e=`${this.selectedCategory}/`;return Object.keys(this.projects).filter(s=>s.startsWith(e)).map(s=>s.split("/")[1]).sort()}},watch:{currentCategory:{immediate:!0,handler(e){this.selectedCategory=e||""}},currentProject:{immediate:!0,handler(e){this.selectedProject=e||""}},selectedCategory(e){e||(this.selectedProject="")}},methods:{selectCategory(e){this.selectedCategory=e,this.$emit("category-change",e),this.$emit("project-change","")},selectProject(e){this.selectedProject=e,this.$emit("project-change",e)},showCreateCategoryDialog(){this.dialogInput="",this.dialogVisible=!0},handleDialogConfirm(){const e=this.dialogInput.trim();e&&(this.$emit("create-category",e),this.dialogVisible=!1)},showCreateRequirementDialog(){this.selectedCategory&&(this.requirementDialogInput="",this.requirementDialogVisible=!0)},handleCreateRequirementConfirm(){const e=this.requirementDialogInput.trim();e&&(this.requirementList.includes(e)||(this.$emit("create-requirement",{category:this.selectedCategory,name:e}),this.requirementDialogVisible=!1))}}};var P=function(){var s=this,t=s._self._c;return t("div",{staticClass:"step1-req"},[t("div",{staticClass:"category-section"},[s._m(0),t("div",{staticClass:"category-list"},[s._l(s.categories,function(i){return t("div",{key:i,staticClass:"category-item",class:{active:s.selectedCategory===i},on:{click:function(r){return s.selectCategory(i)}}},[t("i",{staticClass:"fa-solid fa-folder"}),t("span",[s._v(s._s(i))])])}),t("div",{staticClass:"category-item add-btn",on:{click:s.showCreateCategoryDialog}},[t("i",{staticClass:"fa-solid fa-plus"}),t("span",[s._v("新建大类")])])],2)]),t("div",{staticClass:"divider"}),t("div",{staticClass:"project-section"},[t("div",{staticClass:"section-header"},[t("span",[s._v("选择需求")]),t("button",{staticClass:"btn-primary",attrs:{disabled:!s.selectedCategory},on:{click:s.showCreateRequirementDialog}},[t("i",{staticClass:"fa-solid fa-plus"}),s._v(" 新建 ")])]),t("div",{staticClass:"project-list"},[s._l(s.requirementList,function(i){return t("div",{key:i,staticClass:"project-item",on:{click:function(r){return s.selectProject(i)}}},[t("div",{staticClass:"project-info"},[t("i",{staticClass:"fa-solid fa-folder-open"}),t("span",[s._v(s._s(i))])]),t("i",{staticClass:"fa-solid fa-chevron-right"})])}),!s.requirementList.length&&s.selectedCategory?t("div",{staticClass:"empty-hint"},[s._v(" 暂无需求,请点击新建 ")]):s._e(),s.selectedCategory?s._e():t("div",{staticClass:"empty-hint"},[s._v(" 请先选择大类 ")])],2)]),s.dialogVisible?t("div",{staticClass:"dialog-overlay",on:{click:function(i){if(i.target!==i.currentTarget)return null;s.dialogVisible=!1}}},[t("div",{staticClass:"dialog"},[t("div",{staticClass:"dialog-header"},[t("span",[s._v("新建大类")]),t("button",{staticClass:"close-btn",on:{click:function(i){s.dialogVisible=!1}}},[t("i",{staticClass:"fa-solid fa-xmark"})])]),t("div",{staticClass:"dialog-body"},[t("input",{directives:[{name:"model",rawName:"v-model",value:s.dialogInput,expression:"dialogInput"}],attrs:{type:"text",placeholder:"输入大类名称"},domProps:{value:s.dialogInput},on:{keydown:function(i){return!i.type.indexOf("key")&&s._k(i.keyCode,"enter",13,i.key,"Enter")?null:s.handleDialogConfirm.apply(null,arguments)},input:function(i){i.target.composing||(s.dialogInput=i.target.value)}}})]),t("div",{staticClass:"dialog-footer"},[t("button",{staticClass:"btn-cancel",on:{click:function(i){s.dialogVisible=!1}}},[s._v("取消")]),t("button",{staticClass:"btn-confirm",on:{click:s.handleDialogConfirm}},[s._v("确定")])])])]):s._e(),s.requirementDialogVisible?t("div",{staticClass:"dialog-overlay",on:{click:function(i){if(i.target!==i.currentTarget)return null;s.requirementDialogVisible=!1}}},[t("div",{staticClass:"dialog"},[t("div",{staticClass:"dialog-header"},[t("span",[s._v("新建需求")]),t("button",{staticClass:"close-btn",on:{click:function(i){s.requirementDialogVisible=!1}}},[t("i",{staticClass:"fa-solid fa-xmark"})])]),t("div",{staticClass:"dialog-body"},[t("input",{directives:[{name:"model",rawName:"v-model",value:s.requirementDialogInput,expression:"requirementDialogInput"}],attrs:{type:"text",placeholder:"输入需求名称"},domProps:{value:s.requirementDialogInput},on:{keydown:function(i){return!i.type.indexOf("key")&&s._k(i.keyCode,"enter",13,i.key,"Enter")?null:s.handleCreateRequirementConfirm.apply(null,arguments)},input:function(i){i.target.composing||(s.requirementDialogInput=i.target.value)}}})]),t("div",{staticClass:"dialog-footer"},[t("button",{staticClass:"btn-cancel",on:{click:function(i){s.requirementDialogVisible=!1}}},[s._v("取消")]),t("button",{staticClass:"btn-confirm",on:{click:s.handleCreateRequirementConfirm}},[s._v("确定")])])])]):s._e()])},D=[function(){var e=this,s=e._self._c;return s("div",{staticClass:"section-header"},[s("span",[e._v("选择大类")])])}],I=p(k,P,D,!1,null,"ff2d2605");const M=I.exports,q={name:"AppStep2Design",components:{FileSelectDrawer:g},props:{category:{type:String,default:""},name:{type:String,default:""},reqBasePath:{type:String,default:""}},data(){return{mode:"chat",specView:"edit",specContent:"",inputMessage:"",isProcessing:!1,stopping:!1,logItems:[],sessionId:"",modelName:"",promptTokens:0,showModelDrawer:!1,showCommandDrawer:!1,showFileDrawer:!1,models:[],logSeq:0,wsUnsubscribe:null,parentInfo:null}},computed:{specFilePath(){return!this.category||!this.name?"":`${this.reqBasePath}/${this.category}/${this.name}/${this.name}_方案.md`},renderedContent(){return m(this.specContent||"")}},watch:{category:{handler(){this.loadData()}},name:{handler(){this.loadData()}},reqBasePath:{handler(e){e&&this.loadData()}}},async mounted(){h.init(),await this.loadModels(),await this.loadDefaultModel(),await this.loadData()},beforeDestroy(){this.wsUnsubscribe&&this.wsUnsubscribe()},methods:{async loadData(){this.reqBasePath&&await Promise.all([this.loadSpec(),this.loadSession()])},async loadSpec(){var e;if(!this.category||!this.name){this.specContent="";return}try{const s=await o.getFileContent(this.specFilePath);this.specContent=((e=s.data)==null?void 0:e.content)||""}catch{this.specContent=""}},async loadSession(){var e;if(!this.category||!this.name){this.sessionId="",this.parentInfo=null;return}try{const s=`${this.reqBasePath}/${this.category}/${this.name}/session.json`,t=await o.getFileContent(s);if(t&&((e=t.data)!=null&&e.content)){const i=JSON.parse(t.data.content);this.sessionId=i.designSessionId||"",this.parentInfo=i.parent||null}else this.sessionId="",this.parentInfo=null;this.sessionId&&(await this.loadMessages(),this.subscribeSession())}catch{this.sessionId="",this.parentInfo=null}},async saveSpec(){if(this.specFilePath)try{await o.writeFile(this.specFilePath,this.specContent),this.$emit("save-spec",this.specContent),this.$emit("spec-updated"),this.$message.success("方案已保存")}catch{this.$message.error("保存失败")}},async loadModels(){try{const e=await o.getModels();this.models=e.data||[]}catch(e){console.error("Load models failed:",e)}},async loadDefaultModel(){var e;try{const s=await o.getConfig("defaultModel");(e=s.data)!=null&&e.value&&(this.modelName=s.data.value)}catch{this.modelName="gpt-4o"}},selectModel(e){const s=e.name.split("/");this.modelName=s.length>2?s.slice(1).join("/"):e.name,o.setConfig("defaultModel",this.modelName),this.showModelDrawer=!1},async loadMessages(){if(this.sessionId)try{const e=await v(this.sessionId);this.logItems=(e.data||[]).map(s=>s.type==="think"?{type:"think",content:s.content||"",_id:`log-${++this.logSeq}`}:s.type==="step"?{type:"step",thought:s.thought,toolCalls:s.toolCalls||[],success:s.success,_id:`log-${++this.logSeq}`}:s.type==="chat"?{type:"chat",content:s.content,_id:`log-${++this.logSeq}`}:s.type==="todos"?{type:"todos",todos:s.todos||[],_id:`log-${++this.logSeq}`}:{type:"system",content:String(s),_id:`log-${++this.logSeq}`}),this.scrollToBottom()}catch(e){console.error("Load messages failed:",e)}},subscribeSession(){this.sessionId&&(this.wsUnsubscribe&&this.wsUnsubscribe(),this.wsUnsubscribe=h.subscribe(this.sessionId,{running_sessions:e=>{const s=(e==null?void 0:e.runningSessionIds)||[];this.isProcessing=s.includes(this.sessionId)},todos:e=>{this.logItems.push({type:"todos",todos:e.todos,_id:`log-${++this.logSeq}`}),this.scrollToBottom()},step:e=>{var s;this.logItems.push({type:"step",thought:e==null?void 0:e.thought,toolCalls:(e==null?void 0:e.toolCalls)||[],success:e==null?void 0:e.success,_id:`log-${++this.logSeq}`}),(s=e==null?void 0:e.usage)!=null&&s.promptTokens&&(this.promptTokens=e.usage.promptTokens),this.scrollToBottom()},compact:e=>{this.logItems.push({type:"system",content:`【压缩完成】${e.summary||""}`,_id:`log-${++this.logSeq}`}),this.loadMessages()},done:e=>{var s;this.isProcessing=!1,this.stopping=!1,e!=null&&e.modelName&&(this.modelName=e.modelName),(s=e==null?void 0:e.usage)!=null&&s.promptTokens&&(this.promptTokens=e.usage.promptTokens),e!=null&&e.response&&this.logItems.push({type:"think",content:e.response,_id:`log-${++this.logSeq}`}),this.$emit("spec-updated"),this.loadSpec(),this.scrollToBottom()},stopped:()=>{this.isProcessing=!1,this.stopping=!1,this.logItems.push({type:"think",content:"【已停止】",_id:`log-${++this.logSeq}`}),this.scrollToBottom()},error:e=>{this.isProcessing=!1,this.stopping=!1,this.$message.error((e==null?void 0:e.error)||"发生错误")}}))},async sendMessage(){const e=this.inputMessage.trim();if(!e||this.isProcessing||!this.sessionId)return;this.wsUnsubscribe||this.subscribeSession();let s="";this.logItems.length===0&&this.parentInfo&&(s=`
|
|
2
2
|
|
|
3
3
|
注意:当前方案是「${this.parentInfo.name}」的子方案,请参考父方案内容。父方案路径:${this.parentInfo.specPath}`);const t=`先在 ${this.specFilePath} 生成方案,先不要修改代码。${s}
|
|
4
4
|
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{n as m,C,a as u}from"./index-
|
|
1
|
+
import{n as m,C,a as u}from"./index-BWmvR_0d.js";const g="/api";async function c(t,e,a=null){const i={method:t,headers:{"Content-Type":"application/json"}};a&&t!=="GET"&&(i.body=JSON.stringify(a));const o=await(await fetch(`${g}${e}`,i)).json();if(o.success===!1)throw new Error(o.error||o.message||"请求失败");return o}const h={getZihaoConfig(){return c("GET","/zihao/config")},saveZihaoConfig(t){return c("POST","/zihao/config",t)},deleteZihaoConfig(t){return c("POST","/zihao/config/delete",{id:t})},setActiveConfig(t){return c("POST","/zihao/config/active",{id:t})},connect(){return c("POST","/zihao/connect")},browse(t="/"){return c("GET",`/zihao/browse?path=${encodeURIComponent(t)}`)},viewFile(t){return c("GET",`/zihao/view?path=${encodeURIComponent(t)}`)},create(t,e,a){return c("POST","/zihao/create",{name:t,path:e,type:a})},rename(t,e){return c("POST","/zihao/rename",{oldPath:t,newName:e})},deleteFile(t,e){return c("POST","/zihao/delete",{path:t,type:e})},saveContent(t,e){return c("POST","/zihao/save-content",{path:t,content:e})},getHomeDir(){return c("GET","/zihao/home-dir")},uploadChunk(t,e,a,i,l){const o=new FormData;return o.append("targetDir",t),o.append("fileName",encodeURIComponent(e)),o.append("chunkIndex",String(a)),o.append("totalChunks",String(i)),o.append("chunk",l),fetch(`${g}/zihao/chunk-upload`,{method:"POST",body:o}).then(n=>n.json()).then(n=>{if(n.success===!1)throw new Error(n.error||"上传分片失败");return n})},uploadWithProgress(t,e,a,i){const o=t,n=Math.ceil(o.size/1048576);return(async()=>{for(let r=0;r<n;r++){const f=r*1048576,x=Math.min(f+1048576,o.size),p=o.slice(f,x);await this.uploadChunk(a,e,r,n,p),i&&i(Math.round((r+1)/n*100))}return{success:!0}})()},async download(t,e,a){var s;const i=`${g}/zihao/download?path=${encodeURIComponent(t)}&localPath=${encodeURIComponent(e)}`,l=await fetch(i);if(!l.ok)throw new Error("下载失败");const o=(s=l.body)==null?void 0:s.getReader();if(!o)throw new Error("无法读取响应");const n=new TextDecoder;for(;;){const{done:r,value:f}=await o.read();if(r)break;const p=n.decode(f,{stream:!0}).split(`
|
|
2
2
|
`).filter(Boolean);for(const v of p)try{const d=JSON.parse(v);if(typeof d.progress=="number")a(d.progress);else if(d.done)a(100);else if(d.success===!1)throw new Error(d.error)}catch{}}}},b={name:"ZihaoConfigDialog",data(){return{dialogVisible:!1,editingConfig:null,loading:!1,form:{name:"",url:"",username:"",password:""},rules:{name:[{required:!0,message:"请输入配置名称",trigger:"blur"}],url:[{required:!0,message:"请输入服务地址",trigger:"blur"}],username:[{required:!0,message:"请输入用户名",trigger:"blur"}],password:[{required:!0,message:"请输入密码",trigger:"blur"}]}}},methods:{open(t=null){this.editingConfig=t,t?this.form={name:t.name||"",url:t.url||"",username:t.username||"",password:""}:this.form={name:"",url:"",username:"",password:""},this.dialogVisible=!0},handleClose(){var t;(t=this.$refs.formRef)==null||t.resetFields(),this.dialogVisible=!1,this.editingConfig=null},async handleSubmit(){var t;try{await this.$refs.formRef.validate()}catch{return}this.loading=!0;try{const e={...this.form};(t=this.editingConfig)!=null&&t.id&&(e.id=this.editingConfig.id,e.password||delete e.password),await h.saveZihaoConfig(e),this.$message.success("保存成功"),this.$emit("success"),this.handleClose()}catch(e){this.$message.error("保存失败: "+e.message)}finally{this.loading=!1}}}};var y=function(){var e=this,a=e._self._c;return a("el-dialog",{attrs:{title:e.editingConfig?"编辑梓豪配置":"新增梓豪配置",visible:e.dialogVisible,width:"500px","close-on-click-modal":!1},on:{"update:visible":function(i){e.dialogVisible=i},close:e.handleClose}},[a("el-form",{ref:"formRef",attrs:{model:e.form,rules:e.rules,"label-width":"100px"}},[a("el-form-item",{attrs:{label:"配置名称",prop:"name"}},[a("el-input",{attrs:{placeholder:"例如:我的梓豪服务器"},model:{value:e.form.name,callback:function(i){e.$set(e.form,"name",i)},expression:"form.name"}})],1),a("el-form-item",{attrs:{label:"服务地址",prop:"url"}},[a("el-input",{attrs:{placeholder:"例如:http://192.168.1.100:5000"},model:{value:e.form.url,callback:function(i){e.$set(e.form,"url",i)},expression:"form.url"}})],1),a("el-form-item",{attrs:{label:"用户名",prop:"username"}},[a("el-input",{attrs:{placeholder:"远程平台用户名"},model:{value:e.form.username,callback:function(i){e.$set(e.form,"username",i)},expression:"form.username"}})],1),a("el-form-item",{attrs:{label:"密码",prop:"password"}},[a("el-input",{attrs:{placeholder:"远程平台密码","show-password":""},model:{value:e.form.password,callback:function(i){e.$set(e.form,"password",i)},expression:"form.password"}})],1)],1),a("span",{attrs:{slot:"footer"},slot:"footer"},[a("el-button",{on:{click:e.handleClose}},[e._v("取消")]),a("el-button",{attrs:{type:"primary",loading:e.loading},on:{click:e.handleSubmit}},[e._v("确定")])],1)],1)},w=[],_=m(b,y,w,!1,null,null);const P=_.exports,D={name:"ZihaoContextMenu",components:{CopyPathDialog:C},data(){return{visible:!1,x:0,y:0,target:null,onRename:null,onDelete:null,onDownload:null}},methods:{show(t,e,a={}){this.target=e,this.x=t.pageX,this.y=t.pageY,this.visible=!0,this.onRename=a.onRename||null,this.onDelete=a.onDelete||null,this.onDownload=a.onDownload||null},hide(){this.visible=!1},handleRename(){this.hide(),this.onRename&&this.onRename(this.target)},handleDelete(){this.hide(),this.onDelete&&this.onDelete(this.target)},handleDownload(){this.hide(),this.onDownload&&this.onDownload(this.target)},handleCopyPath(){var t;this.hide(),(t=this.target)!=null&&t.path&&this.$refs.copyPathDialog.open(this.target.path)}}};var z=function(){var i;var e=this,a=e._self._c;return a("div",[a("div",{directives:[{name:"show",rawName:"v-show",value:e.visible,expression:"visible"}],staticClass:"fixed bg-[#252526] border border-[#3c3c3c] rounded shadow-lg py-1 z-50 min-w-[160px]",style:{left:e.x+"px",top:e.y+"px"}},[a("button",{staticClass:"w-full text-left px-4 py-2 text-sm text-[#cccccc] hover:bg-[#094771] flex items-center gap-2",on:{click:e.handleCopyPath}},[a("i",{staticClass:"fa-solid fa-copy text-xs w-4"}),e._v(" 复制路径 ")]),a("button",{staticClass:"w-full text-left px-4 py-2 text-sm text-[#cccccc] hover:bg-[#094771] flex items-center gap-2",on:{click:e.handleRename}},[a("i",{staticClass:"fa-solid fa-pen text-xs w-4"}),e._v(" 重命名 ")]),a("button",{staticClass:"w-full text-left px-4 py-2 text-sm text-red-400 hover:bg-[#094771] flex items-center gap-2",on:{click:e.handleDelete}},[a("i",{staticClass:"fa-solid fa-trash text-xs w-4"}),e._v(" 删除 ")]),((i=e.target)==null?void 0:i.type)==="file"?a("button",{staticClass:"w-full text-left px-4 py-2 text-sm text-[#cccccc] hover:bg-[#094771] flex items-center gap-2",on:{click:e.handleDownload}},[a("i",{staticClass:"fa-solid fa-download text-xs w-4"}),e._v(" 下载到本地 ")]):e._e()]),a("CopyPathDialog",{ref:"copyPathDialog"})],1)},Z=[],k=m(D,z,Z,!1,null,null);const L=k.exports,$={name:"FileZihao",components:{ZihaoConfigDialog:P,ZihaoContextMenu:L},data(){return{localItems:[],localLoading:!1,localPath:"",localCurrentPath:"",localParentPath:null,selectedLocalPath:null,localDragOver:!1,dragFile:null,zihaoConfig:null,zihaoItems:[],zihaoLoading:!1,zihaoPath:"/",zihaoPathInput:"/",selectedZihaoPath:null,isDragOver:!1,localContextMenu:{visible:!1,x:0,y:0,target:null},renameDialog:{visible:!1,title:"",value:"",target:null,isZihao:!1},uploadProgress:{visible:!1,percent:0,filename:"",isDownload:!1}}},async created(){document.addEventListener("click",this.hideLocalContextMenu),await this.loadZihaoConfig(),await this.loadLocalFiles()},beforeDestroy(){document.removeEventListener("click",this.hideLocalContextMenu)},methods:{async loadLocalFiles(){this.localLoading=!0;try{const t=await u.browseFilesystem(this.localPath);let e=t.data.items||[];this.localCurrentPath=t.data.current_path||"",this.localParentPath=t.data.parent_path,this.localParentPath!==void 0&&(e=[{name:"..",is_directory:!0,path:this.localParentPath||"",size:0},...e]),this.localItems=e.sort((a,i)=>a.name===".."?-1:i.name===".."?1:a.is_directory===i.is_directory?a.name.localeCompare(i.name):a.is_directory?-1:1)}catch(t){console.error("加载本地文件失败:",t)}finally{this.localLoading=!1}},refreshLocal(){this.loadLocalFiles()},goLocalUp(){this.localParentPath!==null&&(this.localPath=this.localParentPath===""?"":this.localParentPath,this.loadLocalFiles())},goLocalHome(){this.localPath="",this.loadLocalFiles()},selectLocalItem(t){this.selectedLocalPath=t.path},openLocalItem(t){t.name===".."?(this.localPath=t.path===""?"":t.path,this.loadLocalFiles()):t.is_directory&&(this.localPath=t.path,this.loadLocalFiles())},showLocalContextMenu(t,e){this.localContextMenu={visible:!0,x:t.pageX,y:t.pageY,target:e}},hideLocalContextMenu(){this.localContextMenu.visible=!1},copyLocalPath(){this.hideLocalContextMenu(),this.localContextMenu.target&&(navigator.clipboard.writeText(this.localContextMenu.target.path).catch(()=>{}),this.$message.success("已复制路径"))},showLocalRenameDialog(){const t=this.localContextMenu.target;!t||t.name===".."||(this.renameDialog={visible:!0,title:"重命名",value:t.name,target:t,isZihao:!1},this.hideLocalContextMenu(),this.$nextTick(()=>{var e,a;(e=this.$refs.renameInput)==null||e.focus(),(a=this.$refs.renameInput)==null||a.select()}))},async deleteLocalItem(){const t=this.localContextMenu.target;if(!(!t||t.name==="..")){try{await this.$confirm(`确定要删除 "${t.name}" 吗?`,"确认删除",{confirmButtonText:"删除",cancelButtonText:"取消",type:"warning"}),await u.deleteFile(t.path),this.$message.success("删除成功"),this.loadLocalFiles()}catch(e){e!=="cancel"&&this.$message.error("删除失败: "+e.message)}this.hideLocalContextMenu()}},async uploadToZihao(){this.hideLocalContextMenu();const t=this.localContextMenu.target;if(!t||t.is_directory||t.name==="..")return;if(!this.zihaoConfig){this.$message.warning("请先配置梓豪平台");return}const e=t.name,a=this.zihaoPath||"/";this.uploadProgress={visible:!0,percent:0,filename:e,isDownload:!1};try{const i=await fetch(`/api/file/download_file?path=${encodeURIComponent(t.path)}`);if(!i.ok)throw new Error("读取文件失败");const l=await i.blob(),o=new File([l],e);await h.uploadWithProgress(o,e,a,n=>{this.uploadProgress.percent=n}),this.$message.success("上传成功"),this.loadZihaoFiles()}catch(i){this.$message.error("上传失败: "+i.message)}finally{this.uploadProgress.visible=!1}},handleLocalDragStart(t,e){if(e.is_directory){t.preventDefault();return}this.dragFile=e,t.dataTransfer.effectAllowed="copy"},handleLocalDragOver(t){t.preventDefault(),this.localDragOver=!0,t.dataTransfer.dropEffect="copy"},handleLocalDragLeave(){this.localDragOver=!1},async handleLocalDrop(t){t.preventDefault(),this.localDragOver=!1;const e=t.dataTransfer.files;if(e.length===0)return;const a=this.localCurrentPath||this.localPath;if(!a){this.$message.warning("无法确定上传目录");return}for(const i of e){this.uploadProgress={visible:!0,percent:0,filename:i.name,isDownload:!1};try{await u.uploadFilesystemWithProgress(a,i,l=>{this.uploadProgress.percent=l})}catch(l){this.uploadProgress.visible=!1,this.$message.error(`上传 ${i.name} 失败: `+l.message);return}this.uploadProgress.visible=!1}this.$message.success(`已上传 ${e.length} 个文件`),this.loadLocalFiles()},async loadZihaoConfig(){try{const t=await h.getZihaoConfig();this.zihaoConfig=t.data.active,this.zihaoConfig&&await this.loadZihaoFiles()}catch(t){console.error("加载梓豪配置失败:",t)}},async loadZihaoFiles(){if(this.zihaoConfig){this.zihaoLoading=!0;try{let e=(await h.browse(this.zihaoPath)).data.items||[];if(this.zihaoPath!=="/"){const a=this.zihaoPath.split("/").filter(Boolean).slice(0,-1).join("/");e=[{name:"..",type:"folder",path:a?"/"+a:"/",size:0,modify_time:""},...e]}this.zihaoItems=e}catch(t){this.$message.error("加载梓豪文件失败: "+t.message)}finally{this.zihaoLoading=!1}}},refreshZihao(){this.loadZihaoFiles()},navigateZihaoPath(){let t=this.zihaoPathInput.trim();t&&(t.startsWith("/")||(t="/"+t),this.zihaoPath=t,this.zihaoPathInput=t,this.loadZihaoFiles())},goZihaoUp(){if(this.zihaoPath==="/")return;const t=this.zihaoPath.split("/").filter(Boolean);t.pop(),this.zihaoPath=t.length>0?"/"+t.join("/"):"/",this.zihaoPathInput=this.zihaoPath,this.loadZihaoFiles()},selectZihaoItem(t){this.selectedZihaoPath=t.path},openZihaoItem(t){t.type==="folder"&&(this.zihaoPath=t.path,this.zihaoPathInput=t.path,this.loadZihaoFiles())},showZihaoContextMenu(t,e){this.selectedZihaoPath=e.path,this.$refs.zihaoContextMenu.show(t,e,{onRename:this.showZihaoRenameDialog,onDelete:this.handleZihaoDelete,onDownload:e.type==="file"?this.downloadZihaoToLocal:null})},showZihaoRenameDialog(t){this.renameDialog={visible:!0,title:"重命名",value:t.name,target:t,isZihao:!0},this.$nextTick(()=>{var e,a;(e=this.$refs.renameInput)==null||e.focus(),(a=this.$refs.renameInput)==null||a.select()})},async handleZihaoDelete(t){try{await this.$confirm(`确定要删除 "${t.name}" 吗?`,"确认删除",{confirmButtonText:"删除",cancelButtonText:"取消",type:"warning"}),await h.deleteFile(t.path,t.type),this.$message.success("删除成功"),this.loadZihaoFiles()}catch(e){e!=="cancel"&&this.$message.error("删除失败: "+e.message)}},async downloadZihaoToLocal(t){const e=this.localCurrentPath||this.localPath;if(!e){this.$message.warning("请先进入一个本地文件夹");return}this.uploadProgress={visible:!0,percent:0,filename:t.name,isDownload:!0};try{const a=e.includes("\\")?"\\":"/",i=e.endsWith("/")||e.endsWith("\\")?"":a,l=e+i+t.name;await h.download(t.path,l,o=>{this.uploadProgress.percent=o}),this.$message.success("已下载到本地: "+l),this.loadLocalFiles()}catch(a){this.$message.error("下载失败: "+a.message)}finally{this.uploadProgress.visible=!1}},async confirmRename(){const{value:t,target:e,isZihao:a}=this.renameDialog;if(!t.trim()||!e){this.cancelRename();return}try{a?(await h.rename(e.path,t.trim()),this.$message.success("重命名成功"),this.loadZihaoFiles()):(await u.renameFile(e.path,t.trim()),this.$message.success("重命名成功"),this.loadLocalFiles())}catch(i){this.$message.error("重命名失败: "+i.message)}this.renameDialog.visible=!1},cancelRename(){this.renameDialog.visible=!1},handleZihaoDragOver(t){t.preventDefault(),this.isDragOver=!0,t.dataTransfer.dropEffect="copy"},handleZihaoDragLeave(){this.isDragOver=!1},async handleZihaoDrop(t){if(t.preventDefault(),this.isDragOver=!1,!this.dragFile||!this.zihaoConfig){this.$message.warning("请先从左侧拖拽文件");return}const e=this.dragFile.name,a=this.zihaoPath||"/";this.uploadProgress={visible:!0,percent:0,filename:e,isDownload:!1};try{const i=await fetch(`/api/file/download_file?path=${encodeURIComponent(this.dragFile.path)}`);if(!i.ok)throw new Error("读取文件失败");const l=await i.blob(),o=new File([l],e);await h.uploadWithProgress(o,e,a,n=>{this.uploadProgress.percent=n}),this.$message.success("上传成功"),this.loadZihaoFiles()}catch(i){this.$message.error("上传失败: "+i.message)}finally{this.uploadProgress.visible=!1,this.dragFile=null}},openZihaoConfig(){this.$refs.zihaoConfigDialog.open(this.zihaoConfig)},formatSize(t){if(!t)return"-";const e=["B","KB","MB","GB"];let a=0,i=t;for(;i>=1024&&a<e.length-1;)i/=1024,a++;return`${i.toFixed(1)}${e[a]}`},getFileIcon(t){var i;const e=(i=t.split(".").pop())==null?void 0:i.toLowerCase();return{js:"fa-brands fa-js text-yellow-400",ts:"fa-brands fa-js text-blue-400",html:"fa-brands fa-html5 text-orange-500",css:"fa-brands fa-css3 text-blue-400",json:"fa-solid fa-file-code text-yellow-300",md:"fa-solid fa-file-lines text-gray-400",py:"fa-brands fa-python text-blue-500",vue:"fa-brands fa-vuejs text-green-400",png:"fa-solid fa-image text-purple-400",jpg:"fa-solid fa-image text-purple-400",pdf:"fa-solid fa-file-pdf text-red-400"}[e]||"fa-solid fa-file text-gray-400"}}};var M=function(){var i,l,o,n;var e=this,a=e._self._c;return a("div",{staticClass:"flex-1 flex overflow-hidden"},[a("aside",{staticClass:"bg-sidebar border-r border-border flex flex-col shrink-0",staticStyle:{width:"50%"}},[e._m(0),a("div",{staticClass:"flex items-center gap-1 px-2 py-2 border-b border-border"},[a("button",{staticClass:"p-1 text-textMuted hover:text-white",attrs:{title:"上级目录"},on:{click:e.goLocalUp}},[a("i",{staticClass:"fa-solid fa-arrow-up"})]),a("button",{staticClass:"p-1 text-textMuted hover:text-white",attrs:{title:"刷新"},on:{click:e.refreshLocal}},[a("i",{staticClass:"fa-solid fa-refresh"})]),a("button",{staticClass:"p-1 text-textMuted hover:text-white",attrs:{title:"我的电脑"},on:{click:e.goLocalHome}},[a("i",{staticClass:"fa-solid fa-home"})])]),a("div",{staticClass:"flex-1 overflow-auto py-1",class:{"bg-blue-900/20":e.localDragOver},on:{dragover:function(s){return s.preventDefault(),e.handleLocalDragOver.apply(null,arguments)},dragleave:e.handleLocalDragLeave,drop:e.handleLocalDrop}},[e.localLoading?a("div",{staticClass:"flex items-center justify-center py-8 text-textMuted"},[a("i",{staticClass:"fa-solid fa-spinner fa-spin mr-2"}),e._v(" 加载中... ")]):e.localItems.length===0?a("div",{staticClass:"flex items-center justify-center py-8 text-textMuted text-sm"},[e._v(" 此目录为空 ")]):a("table",{staticClass:"w-full text-sm"},[e._m(1),a("tbody",e._l(e.localItems,function(s){return a("tr",{key:s.path,staticClass:"cursor-pointer border-b border-[#3c3c3c]/50 hover:bg-[#2a2a2a]",class:{"bg-[#094771]":e.selectedLocalPath===s.path},attrs:{draggable:!s.is_directory},on:{click:function(r){return e.selectLocalItem(s)},dblclick:function(r){return e.openLocalItem(s)},contextmenu:function(r){return r.preventDefault(),e.showLocalContextMenu(r,s)},dragstart:function(r){return e.handleLocalDragStart(r,s)}}},[a("td",{staticClass:"px-3 py-1"},[a("div",{staticClass:"flex items-center gap-2"},[a("i",{staticClass:"text-xs text-textMuted w-4",class:s.is_directory?"fa-solid fa-folder text-yellow-500":e.getFileIcon(s.name)}),a("span",{staticClass:"text-[#cccccc] truncate",attrs:{title:s.name}},[e._v(e._s(s.name))])])]),a("td",{staticClass:"px-3 py-1 text-[#808080] text-xs"},[e._v(e._s(s.is_directory?"文件夹":"文件"))]),a("td",{staticClass:"px-3 py-1 text-[#808080] text-xs text-right"},[e._v(e._s(s.is_directory?"-":e.formatSize(s.size)))]),a("td",{staticClass:"px-3 py-1 text-[#808080] text-xs"},[e._v("-")])])}),0)])]),a("div",{directives:[{name:"show",rawName:"v-show",value:e.localContextMenu.visible,expression:"localContextMenu.visible"}],staticClass:"fixed bg-[#252526] border border-[#3c3c3c] rounded shadow-lg py-1 z-50 min-w-[160px]",style:{left:e.localContextMenu.x+"px",top:e.localContextMenu.y+"px"}},[a("button",{staticClass:"w-full text-left px-4 py-2 text-sm text-[#cccccc] hover:bg-[#094771] flex items-center gap-2",on:{click:e.copyLocalPath}},[a("i",{staticClass:"fa-solid fa-copy text-xs w-4"}),e._v(" 复制路径 ")]),((i=e.localContextMenu.target)==null?void 0:i.name)!==".."?a("button",{staticClass:"w-full text-left px-4 py-2 text-sm text-[#cccccc] hover:bg-[#094771] flex items-center gap-2",on:{click:e.showLocalRenameDialog}},[a("i",{staticClass:"fa-solid fa-pen text-xs w-4"}),e._v(" 重命名 ")]):e._e(),((l=e.localContextMenu.target)==null?void 0:l.name)!==".."?a("button",{staticClass:"w-full text-left px-4 py-2 text-sm text-red-400 hover:bg-[#094771] flex items-center gap-2",on:{click:e.deleteLocalItem}},[a("i",{staticClass:"fa-solid fa-trash text-xs w-4"}),e._v(" 删除 ")]):e._e(),a("div",{staticClass:"border-t border-[#3c3c3c] my-1"}),((o=e.localContextMenu.target)==null?void 0:o.name)!==".."&&!((n=e.localContextMenu.target)!=null&&n.is_directory)?a("button",{staticClass:"w-full text-left px-4 py-2 text-sm text-[#cccccc] hover:bg-[#094771] flex items-center gap-2",on:{click:e.uploadToZihao}},[a("i",{staticClass:"fa-solid fa-server text-xs w-4"}),e._v(" 上传到梓豪 ")]):e._e()])]),a("main",{staticClass:"flex-1 flex flex-col min-w-0 bg-[#1e1e1e]"},[a("div",{staticClass:"flex border-b border-border bg-sidebar shrink-0"},[e._m(2),a("div",{staticClass:"flex-1"}),a("button",{staticClass:"p-1 mr-2 text-textMuted hover:text-white",attrs:{title:"梓豪配置"},on:{click:e.openZihaoConfig}},[a("i",{staticClass:"fa-solid fa-gear"})])]),a("div",{staticClass:"flex items-center gap-1 px-2 py-2 border-b border-border"},[a("button",{staticClass:"p-1 text-textMuted hover:text-white",attrs:{title:"上级目录"},on:{click:e.goZihaoUp}},[a("i",{staticClass:"fa-solid fa-arrow-up"})]),a("button",{staticClass:"p-1 text-textMuted hover:text-white",attrs:{title:"刷新"},on:{click:e.refreshZihao}},[a("i",{staticClass:"fa-solid fa-refresh"})]),a("input",{directives:[{name:"model",rawName:"v-model",value:e.zihaoPathInput,expression:"zihaoPathInput"}],staticClass:"flex-1 px-2 py-1 mx-1 bg-[#3c3c3c] border border-[#3c3c3c] rounded text-xs text-[#cccccc] focus:outline-none focus:border-[#0e639c]",attrs:{placeholder:"输入路径后回车跳转..."},domProps:{value:e.zihaoPathInput},on:{keyup:function(s){return!s.type.indexOf("key")&&e._k(s.keyCode,"enter",13,s.key,"Enter")?null:e.navigateZihaoPath.apply(null,arguments)},input:function(s){s.target.composing||(e.zihaoPathInput=s.target.value)}}})]),a("div",{staticClass:"flex-1 overflow-auto py-1",class:{"bg-blue-900/20":e.isDragOver},on:{dragover:function(s){return s.preventDefault(),e.handleZihaoDragOver.apply(null,arguments)},dragleave:e.handleZihaoDragLeave,drop:e.handleZihaoDrop}},[e.zihaoConfig?e.zihaoLoading?a("div",{staticClass:"flex items-center justify-center py-8 text-textMuted"},[a("i",{staticClass:"fa-solid fa-spinner fa-spin mr-2"}),e._v(" 加载中... ")]):e.zihaoItems.length===0?a("div",{staticClass:"flex items-center justify-center py-8 text-textMuted text-sm"},[e._v(" 此目录为空 ")]):a("table",{staticClass:"w-full text-sm"},[e._m(3),a("tbody",e._l(e.zihaoItems,function(s){return a("tr",{key:s.path,staticClass:"cursor-pointer border-b border-[#3c3c3c]/50 hover:bg-[#2a2a2a]",class:{"bg-[#094771]":e.selectedZihaoPath===s.path},on:{click:function(r){return e.selectZihaoItem(s)},dblclick:function(r){return e.openZihaoItem(s)},contextmenu:function(r){return r.preventDefault(),e.showZihaoContextMenu(r,s)}}},[a("td",{staticClass:"px-3 py-1"},[a("div",{staticClass:"flex items-center gap-2"},[a("i",{staticClass:"text-xs text-textMuted w-4",class:s.type==="folder"?"fa-solid fa-folder text-yellow-500":e.getFileIcon(s.name)}),a("span",{staticClass:"text-[#cccccc] truncate",attrs:{title:s.name}},[e._v(e._s(s.name))])])]),a("td",{staticClass:"px-3 py-1 text-[#808080] text-xs"},[e._v(e._s(s.type==="folder"?"文件夹":"文件"))]),a("td",{staticClass:"px-3 py-1 text-[#808080] text-xs text-right"},[e._v(e._s(s.type==="file"?e.formatSize(s.size):"-"))]),a("td",{staticClass:"px-3 py-1 text-[#808080] text-xs"},[e._v(e._s(s.modify_time||"-"))])])}),0)]):a("div",{staticClass:"flex items-center justify-center h-full text-textMuted"},[a("div",{staticClass:"text-center"},[a("i",{staticClass:"fa-solid fa-server text-4xl mb-4 opacity-30"}),a("p",{staticClass:"mb-2"},[e._v("未配置梓豪平台")]),a("button",{staticClass:"px-4 py-2 bg-[#0e639c] text-white rounded hover:bg-[#1177bb] text-sm",on:{click:e.openZihaoConfig}},[e._v(" 配置梓豪 ")])])])]),a("ZihaoConfigDialog",{ref:"zihaoConfigDialog",on:{success:e.loadZihaoConfig}}),a("ZihaoContextMenu",{ref:"zihaoContextMenu"})],1),a("div",{directives:[{name:"show",rawName:"v-show",value:e.renameDialog.visible,expression:"renameDialog.visible"}],staticClass:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",on:{click:function(s){return s.target!==s.currentTarget?null:e.cancelRename.apply(null,arguments)}}},[a("div",{staticClass:"bg-[#252526] border border-[#3c3c3c] rounded p-4 w-80"},[a("p",{staticClass:"text-[#cccccc] text-sm mb-3"},[e._v(e._s(e.renameDialog.title))]),a("input",{directives:[{name:"model",rawName:"v-model",value:e.renameDialog.value,expression:"renameDialog.value"}],ref:"renameInput",staticClass:"w-full px-3 py-2 bg-[#3c3c3c] border border-[#3c3c3c] rounded text-[#cccccc] text-sm focus:outline-none focus:border-[#0e639c]",domProps:{value:e.renameDialog.value},on:{keyup:[function(s){return!s.type.indexOf("key")&&e._k(s.keyCode,"enter",13,s.key,"Enter")?null:e.confirmRename.apply(null,arguments)},function(s){return!s.type.indexOf("key")&&e._k(s.keyCode,"escape",void 0,s.key,void 0)?null:e.cancelRename.apply(null,arguments)}],input:function(s){s.target.composing||e.$set(e.renameDialog,"value",s.target.value)}}}),a("div",{staticClass:"flex justify-end gap-2 mt-4"},[a("button",{staticClass:"px-3 py-1 text-xs text-[#808080] hover:text-white",on:{click:e.cancelRename}},[e._v("取消")]),a("button",{staticClass:"px-3 py-1 text-xs bg-[#0e639c] text-white rounded hover:bg-[#1177bb]",on:{click:e.confirmRename}},[e._v("确定")])])])]),e.uploadProgress.visible?a("div",{staticClass:"fixed inset-0 bg-black/50 flex items-center justify-center z-50"},[a("div",{staticClass:"bg-[#252526] border border-[#3c3c3c] rounded p-4 w-80"},[a("p",{staticClass:"text-[#cccccc] text-sm mb-3"},[e._v("正在 "+e._s(e.uploadProgress.isDownload?"下载":"上传")+" "+e._s(e.uploadProgress.filename))]),a("div",{staticClass:"w-full bg-[#3c3c3c] rounded-full h-2"},[a("div",{staticClass:"bg-[#0e639c] h-2 rounded-full transition-all",style:{width:e.uploadProgress.percent+"%"}})]),a("p",{staticClass:"text-[#808080] text-xs mt-2 text-center"},[e._v(e._s(e.uploadProgress.percent.toFixed(2))+"%")])])]):e._e()])},I=[function(){var t=this,e=t._self._c;return e("div",{staticClass:"flex border-b border-border"},[e("div",{staticClass:"px-4 py-2 text-xs uppercase font-bold text-white flex items-center gap-2"},[e("i",{staticClass:"fa-solid fa-folder-open text-accent"}),t._v(" 本地文件 ")])])},function(){var t=this,e=t._self._c;return e("thead",{staticClass:"sticky top-0 bg-[#252526] z-10"},[e("tr",{staticClass:"text-textMuted text-xs border-b border-[#3c3c3c]"},[e("th",{staticClass:"text-left px-3 py-1 font-medium"},[t._v("名称")]),e("th",{staticClass:"text-left px-3 py-1 w-16 font-medium"},[t._v("类型")]),e("th",{staticClass:"text-right px-3 py-1 w-20 font-medium"},[t._v("大小")]),e("th",{staticClass:"text-left px-3 py-1 w-32 font-medium"},[t._v("修改时间")])])])},function(){var t=this,e=t._self._c;return e("div",{staticClass:"px-4 py-2 text-xs uppercase font-bold text-white flex items-center gap-2"},[e("i",{staticClass:"fa-solid fa-server text-accent"}),t._v(" 梓豪远程平台 ")])},function(){var t=this,e=t._self._c;return e("thead",{staticClass:"sticky top-0 bg-[#252526] z-10"},[e("tr",{staticClass:"text-textMuted text-xs border-b border-[#3c3c3c]"},[e("th",{staticClass:"text-left px-3 py-1 font-medium"},[t._v("名称")]),e("th",{staticClass:"text-left px-3 py-1 w-16 font-medium"},[t._v("类型")]),e("th",{staticClass:"text-right px-3 py-1 w-20 font-medium"},[t._v("大小")]),e("th",{staticClass:"text-left px-3 py-1 w-32 font-medium"},[t._v("修改时间")])])])}],F=m($,M,I,!1,null,null);const T=F.exports;export{T as default};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{m as f}from"./index-
|
|
1
|
+
import{m as f}from"./index-BWmvR_0d.js";/*!-----------------------------------------------------------------------------
|
|
2
2
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
3
|
* Version: 0.52.2(404545bded1df6ffa41ea0af4e8ddb219018c6c1)
|
|
4
4
|
* Released under the MIT license
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{n,e as o,K as c,d,a as r}from"./index-
|
|
1
|
+
import{n,e as o,K as c,d,a as r}from"./index-BWmvR_0d.js";import{C as f}from"./ConfirmDialog-CINqhvEA.js";const h={name:"GitChangesSidebar",props:{changes:{type:Array,default:()=>[]},selectedPath:{type:String,default:null},isRepo:{type:Boolean,default:!1},loading:{type:Boolean,default:!1},width:{type:Number,default:320}},methods:{getStatusClass(s){return{modified:"bg-blue-600 text-white",added:"bg-green-600 text-white",deleted:"bg-red-600 text-white",untracked:"bg-gray-600 text-white",renamed:"bg-purple-600 text-white"}[s]||"bg-gray-600 text-white"},getFileName(s){return s.split("/").pop()||s.split("\\").pop()||s},getDirPath(s){const t=s.split("/");return t.pop(),t.join("/")||"."}}};var u=function(){var t=this,e=t._self._c;return e("aside",{staticClass:"bg-sidebar border-r border-border flex flex-col shrink-0",style:{width:t.width+"px"}},[e("div",{staticClass:"flex border-b border-border text-xs uppercase font-bold text-textMuted"},[t._m(0),e("button",{staticClass:"ml-auto px-3 py-2 hover:text-white text-textMuted",attrs:{title:"刷新"},on:{click:function(i){return t.$emit("refresh")}}},[e("i",{staticClass:"fa-solid fa-refresh"})]),e("button",{staticClass:"px-3 py-2 hover:text-yellow-400 text-textMuted disabled:opacity-30",attrs:{disabled:t.changes.length===0,title:"撤销全部"},on:{click:function(i){return t.$emit("revert-all")}}},[e("i",{staticClass:"fa-solid fa-undo-alt"})])]),e("div",{staticClass:"flex-1 overflow-y-auto py-1 sidebar-scroll"},[t.loading?e("div",{staticClass:"flex items-center justify-center py-8 text-textMuted"},[e("i",{staticClass:"fa-solid fa-spinner fa-spin mr-2"}),t._v(" 加载中... ")]):t.isRepo?t.changes.length===0?e("div",{staticClass:"flex items-center justify-center py-8 text-textMuted text-sm"},[t._m(2)]):e("div",t._l(t.changes,function(i){return e("div",{key:i.path,staticClass:"px-3 py-2 cursor-pointer border-b border-border/50 hover:bg-[#2a2a2a] transition-colors",class:t.selectedPath===i.path?"bg-[#2a2a2a] border-l-2 border-l-accent":"",on:{click:function(a){return t.$emit("select",i)}}},[e("div",{staticClass:"flex items-center gap-2"},[e("span",{staticClass:"text-xs font-bold px-1.5 py-0.5 rounded shrink-0",class:t.getStatusClass(i.status)},[t._v(" "+t._s(i.statusCode)+" ")]),e("div",{staticClass:"flex-1 min-w-0"},[e("div",{staticClass:"text-sm text-gray-200 truncate",attrs:{title:i.path}},[t._v(" "+t._s(t.getFileName(i.path))+" ")]),e("div",{staticClass:"text-xs text-gray-500 truncate",attrs:{title:i.path}},[t._v(" "+t._s(t.getDirPath(i.path))+" ")])]),e("div",{staticClass:"flex items-center gap-1 shrink-0",on:{click:function(a){a.stopPropagation()}}},[e("button",{staticClass:"p-1 text-gray-500 hover:text-blue-400 transition-colors",attrs:{title:"打开"},on:{click:function(a){return t.$emit("open-file",i)}}},[e("i",{staticClass:"fa-solid fa-external-link-alt text-xs"})]),e("button",{staticClass:"p-1 text-gray-500 hover:text-yellow-400 transition-colors",attrs:{title:"撤销"},on:{click:function(a){return t.$emit("revert",i)}}},[e("i",{staticClass:"fa-solid fa-undo text-xs"})])])])])}),0):e("div",{staticClass:"flex items-center justify-center py-8 text-textMuted text-sm"},[t._m(1)])]),e("div",{staticClass:"border-t border-border px-3 py-2 text-xs text-textMuted"},[e("span",[t._v(t._s(t.changes.length)+" 个文件变更")])])])},g=[function(){var s=this,t=s._self._c;return t("div",{staticClass:"px-4 py-2 border-b-2 border-accent text-white flex items-center gap-2"},[t("i",{staticClass:"fa-brands fa-git-alt"}),s._v(" Git Changes ")])},function(){var s=this,t=s._self._c;return t("div",{staticClass:"text-center"},[t("i",{staticClass:"fa-brands fa-git-alt text-4xl mb-4 opacity-30"}),t("p",[s._v("当前目录不是 Git 仓库")])])},function(){var s=this,t=s._self._c;return t("div",{staticClass:"text-center"},[t("i",{staticClass:"fa-solid fa-check-circle text-4xl mb-4 opacity-30 text-green-500"}),t("p",[s._v("没有待提交的变更")])])}],p=n(h,u,g,!1,null,"45b2ddc3");const x=p.exports,v={name:"DiffViewer",props:{change:{type:Object,default:null},diffContent:{type:String,default:""},loading:{type:Boolean,default:!1}},data(){return{oldLines:[],newLines:[]}},watch:{diffContent:{immediate:!0,handler(s){this.parseDiff(s)}}},methods:{getStatusClass(s){return{modified:"bg-blue-600 text-white",added:"bg-green-600 text-white",deleted:"bg-red-600 text-white",untracked:"bg-gray-600 text-white",renamed:"bg-purple-600 text-white"}[s]||"bg-gray-600 text-white"},getLinePrefix(s){return s.removed?"-":s.added?"+":" "},getLineClass(s){return s.type==="header"?"bg-[#1a1a1a] text-blue-400":s.removed?"bg-red-900/50 text-red-300":s.added?"bg-green-900/50 text-green-300":s.empty?"bg-[#252525]":"text-gray-200"},parseDiff(s){if(this.oldLines=[],this.newLines=[],!s)return;const t=s.split(`
|
|
2
2
|
`);let e=1,i=1;for(const a of t)if(a.startsWith("@@")){const l=a.match(/@@ -(\d+),?\d* \+(\d+),?\d* @@/);l&&(e=parseInt(l[1]),i=parseInt(l[2])),this.oldLines.push({lineNum:"",content:a,type:"header"}),this.newLines.push({lineNum:"",content:a,type:"header"})}else a.startsWith("---")||a.startsWith("+++")||a.startsWith("diff ")||a.startsWith("index ")||(a.startsWith("-")?(this.oldLines.push({lineNum:e++,content:a.substring(1),removed:!0}),this.newLines.push({lineNum:"",content:"",empty:!0})):a.startsWith("+")?(this.oldLines.push({lineNum:"",content:"",empty:!0}),this.newLines.push({lineNum:i++,content:a.substring(1),added:!0})):(this.oldLines.push({lineNum:e++,content:a}),this.newLines.push({lineNum:i++,content:a})))}}};var m=function(){var t=this,e=t._self._c;return e("div",{staticClass:"flex-1 flex flex-col overflow-hidden"},[t.change?e("div",{staticClass:"flex-1 flex flex-col overflow-hidden"},[e("div",{staticClass:"flex items-center justify-between px-4 py-2 border-b border-border bg-sidebar"},[e("div",{staticClass:"flex items-center gap-2"},[e("span",{staticClass:"text-xs font-bold px-1.5 py-0.5 rounded",class:t.getStatusClass(t.change.status)},[t._v(" "+t._s(t.change.statusCode)+" ")]),e("span",{staticClass:"text-white text-sm"},[t._v(t._s(t.change.path))])]),e("div",{staticClass:"flex items-center gap-2"},[e("button",{staticClass:"px-3 py-1 text-xs bg-blue-600 hover:bg-blue-700 text-white rounded",on:{click:function(i){return t.$emit("open-file",t.change)}}},[e("i",{staticClass:"fa-solid fa-external-link-alt mr-1"}),t._v(" 打开文件 ")]),e("button",{staticClass:"px-3 py-1 text-xs bg-yellow-600 hover:bg-yellow-700 text-white rounded",on:{click:function(i){return t.$emit("revert",t.change)}}},[e("i",{staticClass:"fa-solid fa-undo mr-1"}),t._v(" 撤销 ")])])]),t.loading?e("div",{staticClass:"flex-1 flex items-center justify-center text-textMuted"},[e("i",{staticClass:"fa-solid fa-spinner fa-spin mr-2"}),t._v(" 加载 diff 中... ")]):t.diffContent?e("div",{staticClass:"flex-1 flex overflow-hidden"},[e("div",{staticClass:"flex-1 flex flex-col overflow-hidden border-r border-border"},[e("div",{staticClass:"px-4 py-2 bg-[#3c3c3c] border-b border-border text-xs text-gray-300 font-bold"},[t._v(" 旧版本 (Original) ")]),e("div",{staticClass:"flex-1 overflow-auto bg-[#2d2d2d]"},t._l(t.oldLines,function(i,a){return e("div",{key:"old-"+a,staticClass:"flex font-mono text-sm",class:t.getLineClass(i)},[e("span",{staticClass:"w-12 shrink-0 text-right pr-2 select-none opacity-40"},[t._v(t._s(i.lineNum||""))]),e("span",{staticClass:"flex-1 whitespace-pre"},[e("span",{staticClass:"select-none font-bold w-4 inline-block"},[t._v(t._s(t.getLinePrefix(i)))]),t._v(t._s(i.content))])])}),0)]),e("div",{staticClass:"flex-1 flex flex-col overflow-hidden"},[e("div",{staticClass:"px-4 py-2 bg-[#3c3c3c] border-b border-border text-xs text-gray-300 font-bold"},[t._v(" 新版本 (Modified) ")]),e("div",{staticClass:"flex-1 overflow-auto bg-[#2d2d2d]"},t._l(t.newLines,function(i,a){return e("div",{key:"new-"+a,staticClass:"flex font-mono text-sm",class:t.getLineClass(i)},[e("span",{staticClass:"w-12 shrink-0 text-right pr-2 select-none opacity-40"},[t._v(t._s(i.lineNum||""))]),e("span",{staticClass:"flex-1 whitespace-pre"},[e("span",{staticClass:"select-none font-bold w-4 inline-block"},[t._v(t._s(t.getLinePrefix(i)))]),t._v(t._s(i.content))])])}),0)])]):e("div",{staticClass:"flex-1 flex items-center justify-center text-textMuted"},[t._m(1)])]):e("div",{staticClass:"flex-1 flex items-center justify-center text-textMuted"},[t._m(0)])])},b=[function(){var s=this,t=s._self._c;return t("div",{staticClass:"text-center"},[t("i",{staticClass:"fa-solid fa-code text-6xl mb-4 opacity-20"}),t("p",[s._v("点击文件查看变更详情")])])},function(){var s=this,t=s._self._c;return t("div",{staticClass:"text-center"},[t("i",{staticClass:"fa-solid fa-file text-4xl mb-4 opacity-30"}),t("p",[s._v("无法显示此文件的 diff")])])}],C=n(v,m,b,!1,null,null);const _=C.exports,y=console.error;console.error=(...s)=>{var t;(t=s[0])!=null&&t.toString().includes("toUrl")||y(...s)};const w={name:"FileViewerModal",data(){return{visible:!1,fullPath:"",fileStatus:null,loading:!1,saving:!1,editor:null,originalContent:""}},computed:{filePath(){if(!this.fullPath)return"";const s=this.fullPath.split("/");return s[s.length-1]},hasChanges(){return this.editor?this.editor.getValue()!==this.originalContent:!1},statusCode(){return this.fileStatus&&this.fileStatus.statusCode||""},statusClass(){return this.fileStatus&&{modified:"bg-blue-600 text-white",added:"bg-green-600 text-white",deleted:"bg-red-600 text-white",untracked:"bg-gray-600 text-white",renamed:"bg-purple-600 text-white"}[this.fileStatus.status]||"bg-gray-600 text-white"}},beforeDestroy(){this.destroyEditor()},methods:{async open(s,t=null){var e;this.fullPath=s,this.fileStatus=t,this.visible=!0,this.loading=!0;try{const i=await r.getFileContent(s);this.originalContent=((e=i.data)==null?void 0:e.content)||"",this.$nextTick(()=>{this.initEditor(this.originalContent)})}catch(i){console.error("Failed to load file:",i),this.$message.error("加载文件失败")}finally{this.loading=!1}},close(){this.visible=!1},async save(){if(!(!this.fullPath||!this.hasChanges)){this.saving=!0;try{await r.writeFile(this.fullPath,this.editor.getValue()),this.originalContent=this.editor.getValue(),this.$message.success("文件已保存")}catch(s){console.error("Save file failed:",s),this.$message.error("保存文件失败")}finally{this.saving=!1}}},initEditor(s){console.log("-----------initEditor called with content length:",s.length),this.$refs.editorContainer&&(console.log("-----------initEditor called with content length:aaaa",s.length),this.editor=o.create(this.$refs.editorContainer,{value:s||"",language:this.getLanguage(),theme:"vs-dark",automaticLayout:!0,minimap:{enabled:!1},scrollBeyondLastLine:!1,fontSize:14,fontFamily:'Consolas, Monaco, "Courier New", monospace',lineNumbers:"on",scrollbar:{useShadows:!1,vertical:"auto",horizontal:"auto"}}),this.editor.addCommand(c.CtrlCmd|d.KeyS,()=>{this.save()}))},destroyEditor(){this.editor&&(this.editor.dispose(),this.editor=null)},getLanguage(){const s=this.filePath.split(".").pop().toLowerCase();return{js:"javascript",ts:"typescript",html:"html",css:"css",vue:"html",py:"python",md:"markdown",json:"json",yaml:"yaml",yml:"yaml",xml:"xml",sql:"sql",sh:"shell",go:"go",rs:"rust",java:"java",cpp:"cpp",c:"c",jsx:"javascript",tsx:"typescript"}[s]||"plaintext"}}};var $=function(){var t=this,e=t._self._c;return t.visible?e("div",{staticClass:"fixed inset-0 bg-black/70 flex items-center justify-center z-50",on:{click:function(i){return i.target!==i.currentTarget?null:t.close.apply(null,arguments)}}},[e("div",{staticClass:"bg-sidebar border border-border rounded-lg w-[90%] h-[80%] flex flex-col overflow-hidden"},[e("div",{staticClass:"flex items-center justify-between px-4 py-3 border-b border-border"},[e("div",{staticClass:"flex items-center gap-2"},[t.fileStatus?e("span",{staticClass:"text-xs font-bold px-1.5 py-0.5 rounded",class:t.statusClass},[t._v(" "+t._s(t.statusCode)+" ")]):t._e(),e("span",{staticClass:"text-white text-sm"},[t._v(t._s(t.filePath))])]),e("button",{staticClass:"text-gray-400 hover:text-white",on:{click:t.close}},[e("i",{staticClass:"fa-solid fa-times text-lg"})])]),e("div",{staticClass:"flex-1 overflow-hidden bg-[#1e1e1e]"},[e("div",{ref:"editorContainer",staticClass:"w-full h-full"})]),e("div",{staticClass:"h-8 bg-sidebar border-t border-border flex items-center justify-between px-3"},[e("div",{staticClass:"flex items-center gap-4 text-xs text-gray-400"},[e("span",[t._v(t._s(t.fullPath))]),t.hasChanges?e("span",{staticClass:"text-yellow-500"},[t._v("已修改")]):t._e()]),e("div",{staticClass:"flex items-center gap-2"},[e("button",{staticClass:"px-3 py-1 text-xs bg-primary hover:bg-blue-600 disabled:opacity-50 disabled:cursor-not-allowed text-white rounded",attrs:{disabled:!t.hasChanges||t.saving},on:{click:t.save}},[t.saving?e("i",{staticClass:"fa-solid fa-spinner fa-spin mr-1"}):e("i",{staticClass:"fa-solid fa-save mr-1"}),t._v(" 保存 ")])])])])]):t._e()},R=[],L=n(w,$,R,!1,null,null);const k=L.exports,D={name:"GitChanges",components:{GitChangesSidebar:x,DiffViewer:_,FileViewerModal:k,ConfirmDialog:f},data(){return{isRepo:!1,gitRoot:null,changes:[],selectedChange:null,diffContent:null,loading:!1,diffLoading:!1,sidebarWidth:320,isResizing:!1,confirmDialog:{visible:!1,message:"",action:null,target:null}}},async created(){await this.checkRepo(),await this.refreshChanges(),document.addEventListener("mousemove",this.handleResize),document.addEventListener("mouseup",this.stopResize)},beforeDestroy(){document.removeEventListener("mousemove",this.handleResize),document.removeEventListener("mouseup",this.stopResize)},methods:{async checkRepo(){var s,t;try{const e=await r.gitIsRepo();this.isRepo=((s=e.data)==null?void 0:s.isRepo)||!1,this.gitRoot=((t=e.data)==null?void 0:t.gitRoot)||null}catch{this.isRepo=!1}},async refreshChanges(){if(this.isRepo){this.loading=!0;try{const s=await r.gitStatus();this.changes=s.data||[],this.selectedChange&&(this.changes.find(e=>e.path===this.selectedChange.path)||(this.selectedChange=null,this.diffContent=null))}catch(s){console.error("Failed to get git status:",s),this.$message.error("获取变更列表失败")}finally{this.loading=!1}}},async refresh(){await this.refreshChanges(),this.selectedChange&&await this.loadDiff(this.selectedChange)},selectChange(s){this.selectedChange=s,this.loadDiff(s)},async loadDiff(s){var t;this.diffLoading=!0,this.diffContent=null;try{const e=await r.gitDiff(s.path,s.isNew);this.diffContent=((t=e.data)==null?void 0:t.diff)||""}catch(e){console.error("Failed to get diff:",e),this.diffContent=""}finally{this.diffLoading=!1}},async openFile(s){var e;const t=this.gitRoot?`${this.gitRoot.replace(/\\/g,"/")}/${s.path}`:s.path;(e=this.$refs.fileModalRef)==null||e.open(t,s)},revertFile(s){const t=s.isNew?"delete":"revert",e=s.isNew?`确定要删除未跟踪的文件 "${s.path}" 吗?`:`确定要撤销对 "${s.path}" 的修改吗?`;this.confirmDialog={visible:!0,message:e,action:t,target:s}},confirmRevertAll(){this.changes.length!==0&&(this.confirmDialog={visible:!0,message:`确定要撤销所有 ${this.changes.length} 个文件的变更吗?此操作不可恢复。`,action:"revertAll",target:null})},cancelConfirm(){this.confirmDialog.visible=!1},async executeConfirm(){const{action:s,target:t}=this.confirmDialog;this.confirmDialog.visible=!1;try{s==="revertAll"?(await r.gitRevertAll(),await r.gitDiscardUntracked(),this.$message.success("所有变更已撤销")):s==="revert"?(await r.gitRevert(t.path),this.$message.success("文件已撤销")):s==="delete"&&(await r.gitDeleteFile(t.path),this.$message.success("文件已删除")),await this.refreshChanges()}catch(e){console.error("Operation failed:",e),this.$message.error("操作失败: "+(e.message||"未知错误"))}},startResize(s){this.isResizing=!0,document.body.style.cursor="col-resize",document.body.style.userSelect="none"},handleResize(s){if(!this.isResizing)return;const t=s.clientX;t>=200&&t<=500&&(this.sidebarWidth=t)},stopResize(){this.isResizing=!1,document.body.style.cursor="",document.body.style.userSelect=""}}};var S=function(){var i;var t=this,e=t._self._c;return e("div",{staticClass:"flex-1 flex overflow-hidden"},[e("git-changes-sidebar",{attrs:{width:t.sidebarWidth,changes:t.changes,"selected-path":(i=t.selectedChange)==null?void 0:i.path,"is-repo":t.isRepo,loading:t.loading},on:{refresh:t.refresh,select:t.selectChange,"open-file":t.openFile,revert:t.revertFile,"revert-all":t.confirmRevertAll}}),e("div",{staticClass:"w-1 bg-border hover:bg-accent cursor-col-resize transition-colors shrink-0",on:{mousedown:t.startResize}}),e("diff-viewer",{attrs:{change:t.selectedChange,"diff-content":t.diffContent,loading:t.diffLoading},on:{"open-file":t.openFile,revert:t.revertFile}}),e("file-viewer-modal",{ref:"fileModalRef"}),e("confirm-dialog",{attrs:{visible:t.confirmDialog.visible,message:t.confirmDialog.message},on:{confirm:t.executeConfirm,cancel:t.cancelConfirm}})],1)},F=[],j=n(D,S,F,!1,null,null);const z=j.exports;export{z as default};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{n as r,a as n}from"./index-
|
|
1
|
+
import{n as r,a as n}from"./index-BWmvR_0d.js";import{C as d}from"./ConfirmDialog-CINqhvEA.js";const f={name:"GitChangesApp",components:{ConfirmDialog:d},data(){return{isRepo:!1,branch:"",changes:[],loading:!1,selectedChange:null,diffLines:[],diffLoading:!1,currentTab:"modified",currentFilter:"all",confirmDialog:{visible:!1,message:"",action:null,target:null}}},computed:{tabs(){return[{key:"modified",label:"已修改",count:this.changes.filter(e=>e.status==="modified").length},{key:"added",label:"已添加",count:this.changes.filter(e=>e.status==="added").length},{key:"untracked",label:"未跟踪",count:this.changes.filter(e=>e.status==="untracked").length}]},filters(){return[{key:"all",label:"全部"},{key:"file",label:"仅文件"},{key:"dir",label:"仅目录"}]},stats(){return{add:this.changes.filter(e=>e.status==="added").length,mod:this.changes.filter(e=>e.status==="modified").length,del:this.changes.filter(e=>e.status==="deleted").length}},filteredChanges(){let e=this.changes;return this.currentTab==="modified"?e=e.filter(t=>t.status==="modified"):this.currentTab==="added"?e=e.filter(t=>t.status==="added"||t.status==="renamed"):this.currentTab==="untracked"&&(e=e.filter(t=>t.status==="untracked")),this.currentFilter==="file"?e=e.filter(t=>!t.path.endsWith("/")):this.currentFilter==="dir"&&(e=e.filter(t=>t.path.endsWith("/"))),e}},async created(){await this.checkRepo(),await this.refreshChanges()},methods:{async checkRepo(){var e,t;try{const s=await n.gitIsRepo();this.isRepo=((e=s.data)==null?void 0:e.isRepo)||!1,this.branch=((t=s.data)==null?void 0:t.branch)||""}catch{this.isRepo=!1}},async refreshChanges(){if(this.isRepo){this.loading=!0;try{const e=await n.gitStatus();this.changes=(e.data||[]).map(t=>{let s=t.status||"modified";return{...t,status:s}}),this.selectedChange&&(this.changes.find(s=>s.path===this.selectedChange.path)||(this.selectedChange=null))}catch(e){console.error("Failed to get git status:",e)}finally{this.loading=!1}}},async refresh(){await this.refreshChanges()},selectChange(e){this.selectedChange=e,this.loadDiff(e)},async loadDiff(e){var t;this.diffLoading=!0,this.diffLines=[];try{const s=await n.gitDiff(e.path,e.isNew);this.diffLines=this.parseDiff(((t=s.data)==null?void 0:t.diff)||"")}catch(s){console.error("Failed to get diff:",s)}finally{this.diffLoading=!1}},parseDiff(e){if(!e)return[];const t=e.split(`
|
|
2
2
|
`);let s=1,a=1;const l=[];for(const i of t)if(i.startsWith("@@")){const c=i.match(/@@ -(\d+),?\d* \+(\d+),?\d* @@/);c&&(s=parseInt(c[1]),a=parseInt(c[2])),l.push({lineNum:"",sign:"",content:i,type:"header"})}else{if(i.startsWith("---")||i.startsWith("+++")||i.startsWith("diff ")||i.startsWith("index "))continue;i.startsWith("-")?l.push({lineNum:s++,sign:"-",content:i.substring(1),type:"del"}):i.startsWith("+")?l.push({lineNum:a++,sign:"+",content:i.substring(1),type:"add"}):(l.push({lineNum:s++,sign:" ",content:i,type:"context"}),a++)}return l},getStatusClass(e){return{added:"add",modified:"mod",deleted:"del",untracked:"new",renamed:"mod"}[e]||"mod"},getStatusIcon(e){return{added:"fa-solid fa-plus",modified:"fa-solid fa-pen",deleted:"fa-solid fa-trash",untracked:"fa-solid fa-star",renamed:"fa-solid fa-pen"}[e]||"fa-solid fa-pen"},getFileName(e){const t=e.split("/");return t[t.length-1]},getFilePath(e){const t=e.split("/");return t.pop(),t.join("/")},confirmRevertAll(){this.filteredChanges.length!==0&&(this.confirmDialog={visible:!0,message:`确定要撤销所有 ${this.filteredChanges.length} 个文件的变更吗?此操作不可恢复。`,action:"revertAll",target:null})},cancelConfirm(){this.confirmDialog.visible=!1},async executeConfirm(){const{action:e,target:t}=this.confirmDialog;this.confirmDialog.visible=!1;try{e==="revertAll"?(await n.gitRevertAll(),await n.gitDiscardUntracked(),this.$message.success("所有变更已撤销")):e==="revert"?(await n.gitRevert(t.path),this.$message.success("文件已撤销")):e==="delete"&&(await n.gitDeleteFile(t.path),this.$message.success("文件已删除")),await this.refreshChanges()}catch(s){console.error("Operation failed:",s),this.$message.error("操作失败: "+(s.message||"未知错误"))}},openCommit(){this.$message.info("提交功能开发中")}}};var o=function(){var t=this,s=t._self._c;return s("div",{staticClass:"git-changes-app"},[s("header",{staticClass:"header"},[t._m(0),s("span",{staticClass:"header-title"},[t._v("Git 变更")]),s("div",{staticClass:"header-actions"},[s("button",{staticClass:"header-btn",attrs:{title:"刷新"},on:{click:t.refresh}},[s("i",{staticClass:"fa-solid fa-rotate",class:{"fa-spin":t.loading}})])])]),s("div",{staticClass:"change-summary"},[s("div",{staticClass:"summary-stats"},[s("span",{staticClass:"stat-item add"},[s("i",{staticClass:"fa-solid fa-plus"}),t._v(" "+t._s(t.stats.add)+" ")]),s("span",{staticClass:"stat-item mod"},[s("i",{staticClass:"fa-solid fa-pen"}),t._v(" "+t._s(t.stats.mod)+" ")]),s("span",{staticClass:"stat-item del"},[s("i",{staticClass:"fa-solid fa-minus"}),t._v(" "+t._s(t.stats.del)+" ")])]),t.branch?s("div",{staticClass:"branch-info"},[s("i",{staticClass:"fa-solid fa-code-branch"}),s("span",[t._v(t._s(t.branch))])]):t._e()]),s("div",{staticClass:"tab-bar"},t._l(t.tabs,function(a){return s("div",{key:a.key,staticClass:"tab-item",class:{active:t.currentTab===a.key},on:{click:function(l){t.currentTab=a.key}}},[t._v(" "+t._s(a.label)),s("span",{staticClass:"count"},[t._v(t._s(a.count))])])}),0),s("div",{staticClass:"filter-bar"},t._l(t.filters,function(a){return s("div",{key:a.key,staticClass:"filter-chip",class:{active:t.currentFilter===a.key},on:{click:function(l){t.currentFilter=a.key}}},[t._v(" "+t._s(a.label)+" ")])}),0),t.isRepo?t.filteredChanges.length>0?[t.selectedChange?s("div",{ref:"diffViewRef",staticClass:"diff-view"},[s("div",{staticClass:"diff-header"},[s("i",{staticClass:"fa-solid fa-file-code"}),s("span",[t._v(t._s(t.selectedChange.path))]),s("span",{staticStyle:{"margin-left":"auto",color:"var(--accent)"},on:{click:function(a){t.selectedChange=null}}},[t._v("收起")])]),!t.diffLoading&&t.diffLines.length>0?s("div",{staticClass:"diff-content"},t._l(t.diffLines,function(a,l){return s("div",{key:l,staticClass:"diff-line",class:a.type},[s("span",{staticClass:"line-num"},[t._v(t._s(a.lineNum))]),s("span",{staticClass:"line-sign",class:a.type},[t._v(t._s(a.sign))]),s("span",{staticClass:"line-text"},[t._v(t._s(a.content))])])}),0):t._e(),t.diffLoading?s("div",{staticClass:"diff-loading"},[s("span",{staticClass:"loading-spinner"}),t._v(" 加载中... ")]):t._e()]):s("div",{ref:"fileListRef",staticClass:"file-list"},t._l(t.filteredChanges,function(a,l){var i;return s("div",{key:l,staticClass:"change-item",class:{selected:((i=t.selectedChange)==null?void 0:i.path)===a.path},on:{click:function(c){return t.selectChange(a)}}},[s("div",{staticClass:"change-status",class:t.getStatusClass(a.status)},[s("i",{class:t.getStatusIcon(a.status)})]),s("div",{staticClass:"change-info"},[s("div",{staticClass:"change-name"},[t._v(t._s(t.getFileName(a.path)))]),s("div",{staticClass:"change-path"},[t._v(t._s(t.getFilePath(a.path)))])]),a.linesAdded!==void 0||a.linesDeleted!==void 0?s("div",{staticClass:"change-stats"},[a.linesAdded?s("span",{staticClass:"add-line"},[t._v("+"+t._s(a.linesAdded))]):t._e(),a.linesAdded&&a.linesDeleted?s("span",[t._v(" / ")]):t._e(),a.linesDeleted?s("span",{staticClass:"del-line"},[t._v("-"+t._s(a.linesDeleted))]):t._e()]):t._e()])}),0)]:s("div",{staticClass:"file-list"},[t._m(2)]):s("div",{staticClass:"file-list"},[t._m(1)]),s("div",{staticClass:"bottom-actions"},[s("button",{staticClass:"action-btn secondary",attrs:{disabled:t.filteredChanges.length===0},on:{click:t.confirmRevertAll}},[s("i",{staticClass:"fa-solid fa-arrow-rotate-left"}),t._v(" 撤销全部 ")])]),s("confirm-dialog",{attrs:{visible:t.confirmDialog.visible,message:t.confirmDialog.message},on:{confirm:t.executeConfirm,cancel:t.cancelConfirm}})],2)},h=[function(){var e=this,t=e._self._c;return t("a",{staticClass:"header-back",attrs:{href:"/app"}},[t("i",{staticClass:"fa-solid fa-chevron-left"})])},function(){var e=this,t=e._self._c;return t("div",{staticClass:"empty-state"},[t("div",{staticClass:"empty-icon"},[t("i",{staticClass:"fa-solid fa-folder-open"})]),t("div",{staticClass:"empty-title"},[e._v("非 Git 仓库")]),t("div",{staticClass:"empty-desc"},[e._v("当前目录不是 Git 仓库,无法查看变更")])])},function(){var e=this,t=e._self._c;return t("div",{staticClass:"empty-state"},[t("div",{staticClass:"empty-icon"},[t("i",{staticClass:"fa-solid fa-check"})]),t("div",{staticClass:"empty-title"},[e._v("暂无变更")]),t("div",{staticClass:"empty-desc"},[e._v("工作区干净,没有检测到变更")])])}],u=r(f,o,h,!1,null,"3818a325");const p=u.exports;export{p as default};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{m as l}from"./index-
|
|
1
|
+
import{m as l}from"./index-BWmvR_0d.js";/*!-----------------------------------------------------------------------------
|
|
2
2
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
3
|
* Version: 0.52.2(404545bded1df6ffa41ea0af4e8ddb219018c6c1)
|
|
4
4
|
* Released under the MIT license
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{m as s}from"./index-
|
|
1
|
+
import{m as s}from"./index-BWmvR_0d.js";/*!-----------------------------------------------------------------------------
|
|
2
2
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
3
|
* Version: 0.52.2(404545bded1df6ffa41ea0af4e8ddb219018c6c1)
|
|
4
4
|
* Released under the MIT license
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{m as lt}from"./index-
|
|
1
|
+
import{m as lt}from"./index-BWmvR_0d.js";/*!-----------------------------------------------------------------------------
|
|
2
2
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
3
|
* Version: 0.52.2(404545bded1df6ffa41ea0af4e8ddb219018c6c1)
|
|
4
4
|
* Released under the MIT license
|