tianxincode 1.0.47 → 1.0.49
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/README.md +200 -200
- package/dist/cli/commands.js +18 -18
- package/dist/core/ai/agents/caller/prompts/role.txt +50 -50
- package/dist/core/ai/agents/chat/chat.agent.js +30 -30
- package/dist/core/ai/agents/chat/prompts/role.txt +30 -30
- package/dist/core/ai/agents/code/code.agent.js +6 -6
- package/dist/core/ai/agents/code/prompts/role.txt +50 -50
- package/dist/core/ai/agents/common/prompt/role.txt +51 -51
- package/dist/core/ai/agents/common/prompts.js +26 -26
- package/dist/core/ai/agents/design/design.agent.js +6 -6
- package/dist/core/ai/agents/design/prompts/role.txt +36 -36
- package/dist/core/ai/agents/dream/prompts/init.txt +20 -20
- package/dist/core/ai/agents/mem/mem.agent.js +5 -5
- package/dist/core/ai/agents/mem/prompts/role.txt +35 -35
- package/dist/core/ai/agents/skill/prompts/role.txt +61 -61
- package/dist/core/ai/agents/skill/skill.agent.js +26 -26
- package/dist/core/ai/agents/summarizer/prompts/role.txt +30 -30
- package/dist/core/ai/agents/task/prompts/role.txt +50 -50
- package/dist/core/ai/agents/task/task.agent.js +30 -30
- package/dist/core/ai/provider/deepseek.provider.js +1 -1
- package/dist/core/ai/provider/deepseek.provider.js.map +1 -1
- package/dist/core/ai/provider/openai.provider.js +1 -1
- package/dist/core/ai/provider/openai.provider.js.map +1 -1
- package/dist/core/db/db.service.d.ts.map +1 -1
- package/dist/core/db/db.service.js +3 -1
- package/dist/core/db/db.service.js.map +1 -1
- package/dist/core/db/init_sql/ai_log.init.js +15 -15
- package/dist/core/db/init_sql/code_snippet.init.js +11 -11
- package/dist/core/db/init_sql/config.init.js +15 -15
- package/dist/core/db/init_sql/custom_action.init.js +10 -10
- package/dist/core/db/init_sql/dingding.init.js +9 -9
- package/dist/core/db/init_sql/email.init.js +14 -14
- package/dist/core/db/init_sql/lsp.init.js +8 -8
- package/dist/core/db/init_sql/message_file.init.js +11 -11
- package/dist/core/db/init_sql/project.init.js +20 -20
- package/dist/core/db/init_sql/provider.init.js +35 -35
- package/dist/core/db/init_sql/scheduler.init.js +32 -32
- package/dist/core/db/init_sql/session.init.js +23 -23
- package/dist/core/db/init_sql/spec.init.js +15 -15
- package/dist/core/db/init_sql/waf_gateway.init.js +9 -9
- package/dist/core/db/init_sql/zihao.init.js +11 -11
- package/dist/core/lsp/sql.js +11 -11
- package/dist/core/tools/provider/bash.txt +47 -47
- package/dist/core/tools/provider/code_search.txt +20 -20
- package/dist/core/tools/provider/edit_file.txt +13 -13
- package/dist/core/tools/provider/glob.txt +12 -12
- package/dist/core/tools/provider/grep.txt +14 -14
- package/dist/core/tools/provider/lsp.txt +19 -19
- package/dist/core/tools/provider/memory.txt +21 -21
- package/dist/core/tools/provider/read_file.txt +17 -17
- package/dist/core/tools/provider/todo_read.txt +16 -16
- package/dist/core/tools/provider/todo_write.txt +48 -48
- package/dist/core/tools/provider/web_fetch.txt +17 -17
- package/dist/core/tools/provider/web_search.txt +18 -18
- package/dist/core/tools/provider/write_file.txt +11 -11
- package/dist/gateway/api/skill/detail_skill.d.ts.map +1 -1
- package/dist/gateway/api/skill/detail_skill.js +7 -5
- package/dist/gateway/api/skill/detail_skill.js.map +1 -1
- package/dist/gateway/cli/commands.js +18 -18
- package/dist/modules/ai/agents/chat/prompts/role.txt +30 -30
- package/dist/modules/ai/agents/code/prompts/role.txt +50 -50
- package/dist/modules/ai/agents/mem/prompts/role.txt +35 -35
- package/dist/modules/ai/agents/skill/prompts/role.txt +61 -61
- package/dist/modules/ai/agents/task/prompts/role.txt +50 -50
- package/dist/modules/ai/ai-log.service.js +10 -10
- package/dist/modules/ai/provider/openai/prompt/role.txt +51 -51
- package/dist/modules/ai/summarizer/summarizer.prompts.js +30 -30
- package/dist/modules/config/config.service.js +5 -5
- package/dist/modules/db/db.service.js +252 -252
- package/dist/modules/email/email.config.repository.js +1 -1
- package/dist/modules/repositories/project.repository.d.ts +28 -0
- package/dist/modules/repositories/project.repository.d.ts.map +1 -0
- package/dist/modules/repositories/project.repository.js +47 -0
- package/dist/modules/repositories/project.repository.js.map +1 -0
- package/dist/modules/scheduler/task-log.service.js +1 -1
- package/dist/modules/services/project/project.service.d.ts +14 -0
- package/dist/modules/services/project/project.service.d.ts.map +1 -0
- package/dist/modules/services/project/project.service.js +47 -0
- package/dist/modules/services/project/project.service.js.map +1 -0
- package/dist/modules/skill/skill.txt +36 -36
- package/dist/modules/spec/spec.injector.js +24 -24
- package/dist/modules/tools/provider/bash.txt +47 -47
- package/dist/modules/tools/provider/code_search.txt +20 -20
- package/dist/modules/tools/provider/edit_file.txt +13 -13
- package/dist/modules/tools/provider/glob.txt +12 -12
- package/dist/modules/tools/provider/grep.txt +14 -14
- package/dist/modules/tools/provider/lsp.txt +19 -19
- package/dist/modules/tools/provider/memory.txt +21 -21
- package/dist/modules/tools/provider/read_file.txt +17 -17
- package/dist/modules/tools/provider/todo_read.txt +16 -16
- package/dist/modules/tools/provider/todo_write.txt +48 -48
- package/dist/modules/tools/provider/web_fetch.txt +17 -17
- package/dist/modules/tools/provider/web_search.txt +18 -18
- package/dist/modules/tools/provider/write_file.txt +11 -11
- package/dist/modules/waf-gateway/waf-gateway.module.js +8 -8
- package/dist/modules/waf-gateway/waf-gateway.service.js +12 -12
- package/dist/repositories/project.repository.d.ts +28 -0
- package/dist/repositories/project.repository.d.ts.map +1 -0
- package/dist/repositories/project.repository.js +47 -0
- package/dist/repositories/project.repository.js.map +1 -0
- package/dist/repository/ai_log.repository.js +1 -1
- package/dist/repository/config.repository.js +5 -5
- package/dist/repository/email.repository.js +1 -1
- package/dist/repository/memory.repository.js +1 -1
- package/dist/repository/project.repository.js +3 -3
- package/dist/repository/scheduler.repository.js +2 -2
- package/dist/repository/session.repository.js +1 -1
- package/dist/repository/zihao-config.repository.js +1 -1
- package/dist/services/skill/skill.tool.d.ts.map +1 -1
- package/dist/services/skill/skill.tool.js +6 -1
- package/dist/services/skill/skill.tool.js.map +1 -1
- package/dist/services/skill/skill.txt +36 -36
- package/package.json +76 -76
- package/scripts/copy-txt.js +31 -31
- package/scripts/ink-scroll-demo.tsx +147 -147
- package/tsconfig.test.json +9 -9
- package/web/dist/assets/{ConfirmDialog-B2bVsPFI.js → ConfirmDialog-B03GcCHQ.js} +1 -1
- package/web/dist/assets/PcLayout-CYW3zqcs.css +1 -0
- package/web/dist/assets/{PcLayout-DeXNBHu2.js → PcLayout-ZTdJNg7G.js} +1 -1
- package/web/dist/assets/{aiLogsView-JvjhLmyo.js → aiLogsView-Bt8Xg1Qx.js} +1 -1
- package/web/dist/assets/{cssMode-sYHhwUZh.js → cssMode-CBb6D87U.js} +1 -1
- package/web/dist/assets/{customActionsView-Cvmzxvl4.js → customActionsView-DdjnHzwm.js} +1 -1
- package/web/dist/assets/deployView-CD7ji9IS.css +1 -0
- package/web/dist/assets/{deployView-CjV4ySrf.js → deployView-Cj51_Job.js} +1 -1
- package/web/dist/assets/designView-C3pSX4nP.css +1 -0
- package/web/dist/assets/designView-RT8tKEN9.js +18 -0
- package/web/dist/assets/devWorkflowView-BTozmaiN.js +36 -0
- package/web/dist/assets/devWorkflowView-DYhIfbCB.css +1 -0
- package/web/dist/assets/devWorkflowViewApp-CErbhC2s.css +1 -0
- package/web/dist/assets/{devWorkflowViewApp-DPlFgiS_.js → devWorkflowViewApp-DLslXEq9.js} +3 -3
- package/web/dist/assets/{fileZihao-DvZmuTYu.js → fileZihao-CtZ4bUIH.js} +1 -1
- package/web/dist/assets/{freemarker2-DTyAQBBj.js → freemarker2-CX3jc3l2.js} +1 -1
- package/web/dist/assets/gitChanges-D6QxPcii.css +1 -0
- package/web/dist/assets/{gitChanges-Cpf4HHoF.js → gitChanges-DFRvzL5I.js} +1 -1
- package/web/dist/assets/gitChangesApp-Bjn-MCmr.css +1 -0
- package/web/dist/assets/{gitChangesApp-BOURDd_l.js → gitChangesApp-ZI7-V8oB.js} +2 -2
- package/web/dist/assets/{handlebars-DiWIXxOG.js → handlebars-CTaQD6FN.js} +1 -1
- package/web/dist/assets/{html-BCQWkFzH.js → html-BruJsfYv.js} +1 -1
- package/web/dist/assets/{htmlMode-BbMA34cR.js → htmlMode-wewroXLr.js} +1 -1
- package/web/dist/assets/{index-C_tz4Wda.css → index-C0xmVTIn.css} +1 -1
- package/web/dist/assets/{index-C7axH05o.js → index-Cn73hS12.js} +9 -9
- package/web/dist/assets/{javascript-By4MYHaO.js → javascript-B4ku8P1-.js} +1 -1
- package/web/dist/assets/{jsonMode-5JIz7tDN.js → jsonMode-BIvVuBMG.js} +1 -1
- package/web/dist/assets/{liquid-BQBVii4f.js → liquid-Bo3G0Ep7.js} +1 -1
- package/web/dist/assets/{mdx-Cwk7nqzM.js → mdx-Duv0ylZz.js} +1 -1
- package/web/dist/assets/{mediaChat-DivTDoIv.js → mediaChat-RT7iqqYb.js} +1 -1
- package/web/dist/assets/{python-L_kGfe1T.js → python-CEhCctGm.js} +1 -1
- package/web/dist/assets/{razor-XGuHliMI.js → razor-DPK8nTD7.js} +1 -1
- package/web/dist/assets/{taskView-BcJ3LAxp.js → taskView-sOyebRqn.js} +1 -1
- package/web/dist/assets/{terminalView-q-UKzK0M.js → terminalView-GTYtDlus.js} +2 -2
- package/web/dist/assets/{terminalView-CQVYh6D3.css → terminalView-eZ0agsPP.css} +1 -1
- package/web/dist/assets/{tsMode-SuiD3mJa.js → tsMode-BZvUU1nf.js} +1 -1
- package/web/dist/assets/{typescript-DJcyqRjT.js → typescript-CmEn-k1B.js} +1 -1
- package/web/dist/assets/{wikiView-ygHSGyPp.css → wikiView-C-oqMnJM.css} +1 -1
- package/web/dist/assets/{wikiView-B3GIPUlD.js → wikiView-CRjg-cZ8.js} +1 -1
- package/web/dist/assets/{xml-DQgCzk55.js → xml-bjvdKeyy.js} +1 -1
- package/web/dist/assets/{yaml-DBdEYBPA.js → yaml-N5RXWxJk.js} +1 -1
- package/web/dist/index.html +2 -2
- package/web/package.json +28 -28
- package/dist/modules/ai/react/index.d.ts +0 -5
- package/dist/modules/ai/react/index.d.ts.map +0 -1
- package/dist/modules/ai/react/index.js +0 -4
- package/dist/modules/ai/react/index.js.map +0 -1
- package/dist/modules/ai/react/prompt/role.txt +0 -51
- package/dist/modules/ai/react/provider.parser.d.ts +0 -20
- package/dist/modules/ai/react/provider.parser.d.ts.map +0 -1
- package/dist/modules/ai/react/provider.parser.js +0 -88
- package/dist/modules/ai/react/provider.parser.js.map +0 -1
- package/dist/modules/ai/react/react.parser.d.ts +0 -80
- package/dist/modules/ai/react/react.parser.d.ts.map +0 -1
- package/dist/modules/ai/react/react.parser.js +0 -365
- package/dist/modules/ai/react/react.parser.js.map +0 -1
- package/dist/modules/ai/react/react.prompts.d.ts +0 -26
- package/dist/modules/ai/react/react.prompts.d.ts.map +0 -1
- package/dist/modules/ai/react/react.prompts.js +0 -170
- package/dist/modules/ai/react/react.prompts.js.map +0 -1
- package/dist/modules/ai/react/react.types.d.ts +0 -50
- package/dist/modules/ai/react/react.types.d.ts.map +0 -1
- package/dist/modules/ai/react/react.types.js +0 -2
- package/dist/modules/ai/react/react.types.js.map +0 -1
- package/dist/modules/ai/react/react.validator.d.ts +0 -14
- package/dist/modules/ai/react/react.validator.d.ts.map +0 -1
- package/dist/modules/ai/react/react.validator.js +0 -53
- package/dist/modules/ai/react/react.validator.js.map +0 -1
- package/dist/modules/ai/react.agent.d.ts +0 -82
- package/dist/modules/ai/react.agent.d.ts.map +0 -1
- package/dist/modules/ai/react.agent.js +0 -220
- package/dist/modules/ai/react.agent.js.map +0 -1
- package/dist/modules/skill/skill.service.d.ts +0 -72
- package/dist/modules/skill/skill.service.d.ts.map +0 -1
- package/dist/modules/skill/skill.service.js +0 -283
- package/dist/modules/skill/skill.service.js.map +0 -1
- package/dist/modules/tools/builtin/bash.d.ts +0 -3
- package/dist/modules/tools/builtin/bash.d.ts.map +0 -1
- package/dist/modules/tools/builtin/bash.js +0 -126
- package/dist/modules/tools/builtin/bash.js.map +0 -1
- package/dist/modules/tools/builtin/bash.tool.d.ts +0 -6
- package/dist/modules/tools/builtin/bash.tool.d.ts.map +0 -1
- package/dist/modules/tools/builtin/bash.tool.js +0 -52
- package/dist/modules/tools/builtin/bash.tool.js.map +0 -1
- package/dist/modules/tools/builtin/bash.txt +0 -69
- package/dist/modules/tools/builtin/code_search.d.ts +0 -3
- package/dist/modules/tools/builtin/code_search.d.ts.map +0 -1
- package/dist/modules/tools/builtin/code_search.js +0 -86
- package/dist/modules/tools/builtin/code_search.js.map +0 -1
- package/dist/modules/tools/builtin/code_search.txt +0 -41
- package/dist/modules/tools/builtin/edit-file.tool.d.ts +0 -6
- package/dist/modules/tools/builtin/edit-file.tool.d.ts.map +0 -1
- package/dist/modules/tools/builtin/edit-file.tool.js +0 -58
- package/dist/modules/tools/builtin/edit-file.tool.js.map +0 -1
- package/dist/modules/tools/builtin/edit_file.d.ts +0 -3
- package/dist/modules/tools/builtin/edit_file.d.ts.map +0 -1
- package/dist/modules/tools/builtin/edit_file.js +0 -105
- package/dist/modules/tools/builtin/edit_file.js.map +0 -1
- package/dist/modules/tools/builtin/edit_file.txt +0 -61
- package/dist/modules/tools/builtin/glob.d.ts +0 -3
- package/dist/modules/tools/builtin/glob.d.ts.map +0 -1
- package/dist/modules/tools/builtin/glob.js +0 -85
- package/dist/modules/tools/builtin/glob.js.map +0 -1
- package/dist/modules/tools/builtin/glob.tool.d.ts +0 -6
- package/dist/modules/tools/builtin/glob.tool.d.ts.map +0 -1
- package/dist/modules/tools/builtin/glob.tool.js +0 -81
- package/dist/modules/tools/builtin/glob.tool.js.map +0 -1
- package/dist/modules/tools/builtin/glob.txt +0 -33
- package/dist/modules/tools/builtin/grep.d.ts +0 -3
- package/dist/modules/tools/builtin/grep.d.ts.map +0 -1
- package/dist/modules/tools/builtin/grep.js +0 -94
- package/dist/modules/tools/builtin/grep.js.map +0 -1
- package/dist/modules/tools/builtin/grep.tool.d.ts +0 -6
- package/dist/modules/tools/builtin/grep.tool.d.ts.map +0 -1
- package/dist/modules/tools/builtin/grep.tool.js +0 -96
- package/dist/modules/tools/builtin/grep.tool.js.map +0 -1
- package/dist/modules/tools/builtin/grep.txt +0 -37
- package/dist/modules/tools/builtin/index.d.ts +0 -8
- package/dist/modules/tools/builtin/index.d.ts.map +0 -1
- package/dist/modules/tools/builtin/index.js +0 -80
- package/dist/modules/tools/builtin/index.js.map +0 -1
- package/dist/modules/tools/builtin/lsp.d.ts +0 -7
- package/dist/modules/tools/builtin/lsp.d.ts.map +0 -1
- package/dist/modules/tools/builtin/lsp.js +0 -126
- package/dist/modules/tools/builtin/lsp.js.map +0 -1
- package/dist/modules/tools/builtin/lsp.txt +0 -45
- package/dist/modules/tools/builtin/memory.d.ts +0 -3
- package/dist/modules/tools/builtin/memory.d.ts.map +0 -1
- package/dist/modules/tools/builtin/memory.js +0 -77
- package/dist/modules/tools/builtin/memory.js.map +0 -1
- package/dist/modules/tools/builtin/memory.txt +0 -58
- package/dist/modules/tools/builtin/read-file.tool.d.ts +0 -6
- package/dist/modules/tools/builtin/read-file.tool.d.ts.map +0 -1
- package/dist/modules/tools/builtin/read-file.tool.js +0 -46
- package/dist/modules/tools/builtin/read-file.tool.js.map +0 -1
- package/dist/modules/tools/builtin/read_file.d.ts +0 -3
- package/dist/modules/tools/builtin/read_file.d.ts.map +0 -1
- package/dist/modules/tools/builtin/read_file.js +0 -107
- package/dist/modules/tools/builtin/read_file.js.map +0 -1
- package/dist/modules/tools/builtin/read_file.txt +0 -38
- package/dist/modules/tools/builtin/todo_read.d.ts +0 -6
- package/dist/modules/tools/builtin/todo_read.d.ts.map +0 -1
- package/dist/modules/tools/builtin/todo_read.js +0 -25
- package/dist/modules/tools/builtin/todo_read.js.map +0 -1
- package/dist/modules/tools/builtin/todo_read.txt +0 -34
- package/dist/modules/tools/builtin/todo_write.d.ts +0 -6
- package/dist/modules/tools/builtin/todo_write.d.ts.map +0 -1
- package/dist/modules/tools/builtin/todo_write.js +0 -46
- package/dist/modules/tools/builtin/todo_write.js.map +0 -1
- package/dist/modules/tools/builtin/todo_write.txt +0 -67
- package/dist/modules/tools/builtin/web_fetch.d.ts +0 -3
- package/dist/modules/tools/builtin/web_fetch.d.ts.map +0 -1
- package/dist/modules/tools/builtin/web_fetch.js +0 -52
- package/dist/modules/tools/builtin/web_fetch.js.map +0 -1
- package/dist/modules/tools/builtin/web_fetch.txt +0 -38
- package/dist/modules/tools/builtin/web_search.d.ts +0 -3
- package/dist/modules/tools/builtin/web_search.d.ts.map +0 -1
- package/dist/modules/tools/builtin/web_search.js +0 -100
- package/dist/modules/tools/builtin/web_search.js.map +0 -1
- package/dist/modules/tools/builtin/web_search.txt +0 -43
- package/dist/modules/tools/builtin/write-file.tool.d.ts +0 -6
- package/dist/modules/tools/builtin/write-file.tool.d.ts.map +0 -1
- package/dist/modules/tools/builtin/write-file.tool.js +0 -38
- package/dist/modules/tools/builtin/write-file.tool.js.map +0 -1
- package/dist/modules/tools/builtin/write_file.d.ts +0 -3
- package/dist/modules/tools/builtin/write_file.d.ts.map +0 -1
- package/dist/modules/tools/builtin/write_file.js +0 -61
- package/dist/modules/tools/builtin/write_file.js.map +0 -1
- package/dist/modules/tools/builtin/write_file.txt +0 -58
- package/dist/modules/tools/provider/openai/tools.d.ts +0 -3
- package/dist/modules/tools/provider/openai/tools.d.ts.map +0 -1
- package/dist/modules/tools/provider/openai/tools.js +0 -212
- package/dist/modules/tools/provider/openai/tools.js.map +0 -1
- package/dist/modules/tools/provider/skill.d.ts +0 -6
- package/dist/modules/tools/provider/skill.d.ts.map +0 -1
- package/dist/modules/tools/provider/skill.js +0 -64
- package/dist/modules/tools/provider/skill.js.map +0 -1
- package/web/dist/assets/PcLayout-L-XuK1oQ.css +0 -1
- package/web/dist/assets/deployView-hCh3_M8H.css +0 -1
- package/web/dist/assets/designView-CqZ75hOS.css +0 -1
- package/web/dist/assets/designView-DrUNRVEE.js +0 -18
- package/web/dist/assets/devWorkflowView-BpdJTMEb.js +0 -36
- package/web/dist/assets/devWorkflowView-D7EKjoLj.css +0 -1
- package/web/dist/assets/devWorkflowViewApp-BYYMIdCm.css +0 -1
- package/web/dist/assets/gitChanges-BYj-Y2K-.css +0 -1
- package/web/dist/assets/gitChangesApp-Btw-XKcP.css +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{n as x,a as n}from"./index-
|
|
1
|
+
import{n as x,a as n}from"./index-Cn73hS12.js";const c=[{key:"ai_call_logs",name:"AI 日志",icon:"fa-solid fa-robot text-xs"}],p={name:"AiLogsView",data(){return{logTypes:c,selectedLogType:c[0],logs:[],page:1,pageSize:20,total:0,totalPages:1,sessions:[],loading:!1,filters:{callType:"",sessionId:"",startTime:"",endTime:""}}},async created(){await this.loadSessions(),await this.loadLogs()},methods:{async loadSessions(){try{const s=await n.getSessions(100,0);this.sessions=s.data||[]}catch(s){console.error("Load sessions failed:",s)}},selectLogType(s){this.selectedLogType=s,this.resetFilters()},async loadLogs(){this.loading=!0;try{const s=await n.getAiCallLogs(this.page,this.pageSize);let t=s.data.rows||[];if(this.filters.callType&&(t=t.filter(e=>e.call_type===this.filters.callType)),this.filters.sessionId&&(t=t.filter(e=>e.session_id&&e.session_id.includes(this.filters.sessionId))),this.filters.startTime){const e=new Date(this.filters.startTime).getTime();t=t.filter(l=>new Date(l.request_time).getTime()>=e)}if(this.filters.endTime){const e=new Date(this.filters.endTime).getTime();t=t.filter(l=>new Date(l.request_time).getTime()<=e)}this.logs=t,this.total=s.data.total,this.totalPages=s.data.totalPages}catch(s){console.error("Load logs failed:",s),this.logs=[]}finally{this.loading=!1}},resetFilters(){this.filters.callType="",this.filters.sessionId="",this.filters.startTime="",this.filters.endTime="",this.page=1,this.loadLogs()},async prevPage(){this.page>1&&(this.page--,await this.loadLogs())},async nextPage(){this.page<this.totalPages&&(this.page++,await this.loadLogs())},formatTime(s){return s?new Date(s).toLocaleString("zh-CN"):"-"},getSessionTitle(s){if(!s)return"-";const t=this.sessions.find(e=>e.id===s);return t?t.title:s.substring(0,8)},formatDuration(s){return s?s<1e3?`${s}ms`:`${(s/1e3).toFixed(2)}s`:"0ms"}}};var b=function(){var l,d;var t=this,e=t._self._c;return e("div",{staticClass:"flex-1 flex overflow-hidden"},[e("aside",{staticClass:"w-[260px] bg-sidebar border-r border-border flex flex-col shrink-0"},[t._m(0),e("div",{staticClass:"flex-1 overflow-y-auto py-1"},t._l(t.logTypes,function(a){var i;return e("div",{key:a.key,staticClass:"flex items-center gap-2 px-3 py-1.5 cursor-pointer text-sm",class:((i=t.selectedLogType)==null?void 0:i.key)===a.key?"bg-active text-white border-l-2 border-accent":"text-textMuted hover:text-white hover:bg-white/5 border-l-2 border-transparent",on:{click:function(r){return t.selectLogType(a)}}},[e("i",{class:a.icon}),e("span",{staticClass:"truncate"},[t._v(t._s(a.name))])])}),0)]),e("main",{staticClass:"flex-1 flex flex-col min-w-0 bg-[#1e1e1e]"},[e("div",{staticClass:"px-4 py-3 border-b border-border bg-sidebar"},[e("div",{staticClass:"flex items-center gap-4 mb-3"},[e("div",{staticClass:"flex items-center gap-2"},[e("i",{class:(l=t.selectedLogType)==null?void 0:l.icon}),e("span",{staticClass:"text-white font-medium"},[t._v(t._s((d=t.selectedLogType)==null?void 0:d.name))])]),e("span",{staticClass:"text-xs text-textMuted"},[t._v(t._s(t.total)+" 条记录")])]),e("div",{staticClass:"flex items-center gap-4 flex-wrap"},[e("div",{staticClass:"flex items-center gap-2"},[e("label",{staticClass:"text-xs text-textMuted"},[t._v("调用类型:")]),e("select",{directives:[{name:"model",rawName:"v-model",value:t.filters.callType,expression:"filters.callType"}],staticClass:"bg-black/20 border border-white/10 text-white text-xs px-2 py-1 rounded",on:{change:[function(a){var i=Array.prototype.filter.call(a.target.options,function(r){return r.selected}).map(function(r){var o="_value"in r?r._value:r.value;return o});t.$set(t.filters,"callType",a.target.multiple?i:i[0])},t.loadLogs]}},[e("option",{attrs:{value:""}},[t._v("全部")]),e("option",{attrs:{value:"tool_call"}},[t._v("工具调用")]),e("option",{attrs:{value:"normal"}},[t._v("普通对话")])])]),e("div",{staticClass:"flex items-center gap-2"},[e("label",{staticClass:"text-xs text-textMuted"},[t._v("会话:")]),e("select",{directives:[{name:"model",rawName:"v-model",value:t.filters.sessionId,expression:"filters.sessionId"}],staticClass:"bg-black/20 border border-white/10 text-white text-xs px-2 py-1 rounded",on:{change:[function(a){var i=Array.prototype.filter.call(a.target.options,function(r){return r.selected}).map(function(r){var o="_value"in r?r._value:r.value;return o});t.$set(t.filters,"sessionId",a.target.multiple?i:i[0])},t.loadLogs]}},[e("option",{attrs:{value:""}},[t._v("全部会话")]),t._l(t.sessions,function(a){return e("option",{key:a.id,domProps:{value:a.id}},[t._v(t._s(a.title))])})],2)]),e("div",{staticClass:"flex items-center gap-2"},[e("label",{staticClass:"text-xs text-textMuted"},[t._v("开始时间:")]),e("input",{directives:[{name:"model",rawName:"v-model",value:t.filters.startTime,expression:"filters.startTime"}],staticClass:"bg-black/20 border border-white/10 text-white text-xs px-2 py-1 rounded",attrs:{type:"datetime-local"},domProps:{value:t.filters.startTime},on:{change:t.loadLogs,input:function(a){a.target.composing||t.$set(t.filters,"startTime",a.target.value)}}})]),e("div",{staticClass:"flex items-center gap-2"},[e("label",{staticClass:"text-xs text-textMuted"},[t._v("结束时间:")]),e("input",{directives:[{name:"model",rawName:"v-model",value:t.filters.endTime,expression:"filters.endTime"}],staticClass:"bg-black/20 border border-white/10 text-white text-xs px-2 py-1 rounded",attrs:{type:"datetime-local"},domProps:{value:t.filters.endTime},on:{change:t.loadLogs,input:function(a){a.target.composing||t.$set(t.filters,"endTime",a.target.value)}}})]),e("button",{staticClass:"px-3 py-1 bg-accent text-white text-xs rounded hover:bg-accent/80",on:{click:t.loadLogs}},[t._v(" 查询 ")]),e("button",{staticClass:"px-3 py-1 text-textMuted text-xs rounded hover:bg-white/10",on:{click:t.resetFilters}},[t._v(" 重置 ")])])]),e("div",{staticClass:"flex-1 overflow-auto p-4"},[e("table",{staticClass:"w-full text-sm"},[t._m(1),e("tbody",[t._l(t.logs,function(a){return e("tr",{key:a.id,staticClass:"hover:bg-white/5"},[e("td",{staticClass:"px-3 py-2 text-gray-300 border-b border-border/30"},[t._v(t._s(a.id))]),e("td",{staticClass:"px-3 py-2 text-gray-300 border-b border-border/30"},[t._v(t._s(t.formatTime(a.request_time)))]),e("td",{staticClass:"px-3 py-2 border-b border-border/30"},[e("span",{staticClass:"text-xs px-2 py-0.5 rounded",class:a.call_type==="tool_call"?"bg-blue-500/20 text-blue-400":"bg-green-500/20 text-green-400"},[t._v(" "+t._s(a.call_type==="tool_call"?"工具调用":"普通对话")+" ")])]),e("td",{staticClass:"px-3 py-2 text-gray-300 border-b border-border/30"},[t._v(t._s(a.model_name))]),e("td",{staticClass:"px-3 py-2 text-gray-300 border-b border-border/30"},[t._v(t._s(t.formatDuration(a.duration_ms)))]),e("td",{staticClass:"px-3 py-2 text-gray-300 border-b border-border/30"},[t._v(t._s(a.input_tokens||0))]),e("td",{staticClass:"px-3 py-2 text-gray-300 border-b border-border/30"},[t._v(t._s(a.output_tokens||0))]),e("td",{staticClass:"px-3 py-2 text-gray-300 border-b border-border/30"},[t._v("$"+t._s((a.cost||0).toFixed(4)))]),e("td",{staticClass:"px-3 py-2 text-gray-300 border-b border-border/30 truncate max-w-[150px]",attrs:{title:a.session_id}},[t._v(t._s(t.getSessionTitle(a.session_id)))])])}),t.logs.length===0?e("tr",[e("td",{staticClass:"px-3 py-8 text-center text-textMuted",attrs:{colspan:"9"}},[t._v("暂无数据")])]):t._e()],2)])]),e("div",{staticClass:"flex items-center justify-between px-4 py-2 border-t border-border bg-sidebar"},[e("span",{staticClass:"text-xs text-textMuted"},[t._v("共 "+t._s(t.total)+" 条")]),e("div",{staticClass:"flex items-center gap-2"},[e("button",{staticClass:"px-2 py-1 text-xs text-textMuted hover:text-white disabled:opacity-30 disabled:cursor-not-allowed",attrs:{disabled:t.page<=1},on:{click:t.prevPage}},[e("i",{staticClass:"fa-solid fa-chevron-left"}),t._v(" 上一页 ")]),e("span",{staticClass:"text-xs text-textMuted"},[t._v(t._s(t.page)+" / "+t._s(t.totalPages||1))]),e("button",{staticClass:"px-2 py-1 text-xs text-textMuted hover:text-white disabled:opacity-30 disabled:cursor-not-allowed",attrs:{disabled:t.page>=t.totalPages},on:{click:t.nextPage}},[t._v(" 下一页 "),e("i",{staticClass:"fa-solid fa-chevron-right"})])])])])])},f=[function(){var s=this,t=s._self._c;return t("div",{staticClass:"flex border-b border-border text-xs uppercase font-bold text-textMuted"},[t("div",{staticClass:"px-4 py-2 border-b-2 border-accent text-white flex items-center gap-2"},[t("i",{staticClass:"fa-solid fa-list"}),s._v(" 日志 ")])])},function(){var s=this,t=s._self._c;return t("thead",{staticClass:"bg-sidebar sticky top-0"},[t("tr",[t("th",{staticClass:"px-3 py-2 text-left text-xs font-bold text-textMuted uppercase border-b border-border"},[s._v("ID")]),t("th",{staticClass:"px-3 py-2 text-left text-xs font-bold text-textMuted uppercase border-b border-border"},[s._v("时间")]),t("th",{staticClass:"px-3 py-2 text-left text-xs font-bold text-textMuted uppercase border-b border-border"},[s._v("类型")]),t("th",{staticClass:"px-3 py-2 text-left text-xs font-bold text-textMuted uppercase border-b border-border"},[s._v("模型")]),t("th",{staticClass:"px-3 py-2 text-left text-xs font-bold text-textMuted uppercase border-b border-border"},[s._v("耗时")]),t("th",{staticClass:"px-3 py-2 text-left text-xs font-bold text-textMuted uppercase border-b border-border"},[s._v("输入Token")]),t("th",{staticClass:"px-3 py-2 text-left text-xs font-bold text-textMuted uppercase border-b border-border"},[s._v("输出Token")]),t("th",{staticClass:"px-3 py-2 text-left text-xs font-bold text-textMuted uppercase border-b border-border"},[s._v("费用")]),t("th",{staticClass:"px-3 py-2 text-left text-xs font-bold text-textMuted uppercase border-b border-border"},[s._v("会话ID")])])])}],u=x(p,b,f,!1,null,null);const _=u.exports;export{_ as default};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{m as et}from"./index-
|
|
1
|
+
import{m as et}from"./index-Cn73hS12.js";/*!-----------------------------------------------------------------------------
|
|
2
2
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
3
|
* Version: 0.52.2(404545bded1df6ffa41ea0af4e8ddb219018c6c1)
|
|
4
4
|
* Released under the MIT license
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{n as d,a as n}from"./index-
|
|
1
|
+
import{n as d,a as n}from"./index-Cn73hS12.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};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.editor-panel[data-v-6615be35]{flex:1;min-width:300px;background:#121212;border:1px solid #1e1e1e;border-radius:8px;overflow:hidden;display:flex;flex-direction:column}.editor-header[data-v-6615be35]{background:#121212;border-bottom:1px solid #1e1e1e;padding:12px 16px;font-size:13px;color:#84848a;display:flex;align-items:center;gap:8px;flex-shrink:0}.save-status[data-v-6615be35]{margin-left:auto;font-size:12px;color:#f59e0b}.save-status.saved[data-v-6615be35]{color:#22c55e}.editor-container[data-v-6615be35]{flex:1;min-height:0}.chat-panel[data-v-58b0f9d9]{width:480px;background:#121212;border:1px solid #1e1e1e;border-radius:8px;overflow:hidden;display:flex;flex-direction:column;flex-shrink:0}.panel-header[data-v-58b0f9d9]{background:#121212;border-bottom:1px solid #1e1e1e;padding:12px 16px;font-size:14px;font-weight:500;color:#f4f4f5;flex-shrink:0}.chat-messages[data-v-58b0f9d9]{flex:1;overflow-y:auto;padding:0 16px 16px;font-size:14px;line-height:1.6;min-height:0}.empty-state[data-v-58b0f9d9]{display:flex;flex-direction:column;align-items:center;justify-content:center;height:100%;color:#84848a}.user-message[data-v-58b0f9d9]{color:#60a5fa;font-weight:700;border:1px solid #60a5fa;padding:15px;margin:15px;border-radius:10px;display:inline-block;max-width:80%;text-align:left}.ai-thought[data-v-58b0f9d9],.ai-done[data-v-58b0f9d9]{color:#d4d4d8;margin-bottom:16px}.ai-error[data-v-58b0f9d9]{color:#ef4444;margin-bottom:16px}.log-mute[data-v-58b0f9d9]{color:#84848a;margin-bottom:16px;white-space:pre}.tool-success[data-v-58b0f9d9]{color:#22c55e}.tool-fail[data-v-58b0f9d9]{color:#ef4444}.tool-input[data-v-58b0f9d9]{color:#60a5fa;margin-left:8px}.build-info[data-v-58b0f9d9]{color:#84848a;display:flex;align-items:center;gap:8px;margin-bottom:16px}.chat-input-area[data-v-58b0f9d9]{padding:12px 16px;background:#121212;border-top:1px solid #1e1e1e}.input-row[data-v-58b0f9d9]{display:flex;gap:12px;align-items:flex-start}.input-area[data-v-58b0f9d9]{flex:1;background:#18191b;border:1px solid #27272a;border-radius:6px;padding:8px 12px;color:#f4f4f5;font-size:13px;resize:none;outline:none;font-family:inherit}.input-area[data-v-58b0f9d9]:focus{border-color:#60a5fa}.input-area[data-v-58b0f9d9]::-moz-placeholder{color:#52525b}.input-area[data-v-58b0f9d9]::placeholder{color:#52525b}.deploy-doc-link[data-v-58b0f9d9]{color:#60a5fa;font-size:12px;cursor:pointer;-webkit-user-select:none;-moz-user-select:none;user-select:none;margin-top:8px;display:inline-flex;align-items:center;gap:4px}.deploy-doc-link[data-v-58b0f9d9]:hover{color:#93c5fd;text-decoration:underline}.input-actions[data-v-58b0f9d9]{display:flex;flex-direction:column;gap:6px;align-items:flex-end;flex-shrink:0}.status-bar[data-v-58b0f9d9]{display:flex;gap:8px;align-items:center;padding:6px 16px;font-size:12px;color:#84848a;border-top:1px solid #1e1e1e;flex-shrink:0;flex-wrap:wrap;background:#0a0a09}.status-bar .separator[data-v-58b0f9d9]{color:#3f3f46}.status-ready[data-v-58b0f9d9]{color:#22c55e}.status-thinking[data-v-58b0f9d9]{color:#60a5fa}.thinking-spinner[data-v-58b0f9d9]{display:inline-block;width:12px;height:12px;border:2px solid #60a5fa;border-top-color:transparent;border-radius:50%;animation:spin-58b0f9d9 .8s linear infinite}@keyframes spin-58b0f9d9{to{transform:rotate(360deg)}}.deploy-import[data-v-0cc389d3]{display:flex;align-items:center;justify-content:center;height:100%;flex:1}.import-container[data-v-0cc389d3]{text-align:center;max-width:520px;width:100%;padding:40px}.import-icon[data-v-0cc389d3]{margin-bottom:16px}.import-card[data-v-0cc389d3]{background:#121212;border:1px solid #1e1e1e;border-radius:8px;margin-bottom:16px;text-align:left}.import-card-title[data-v-0cc389d3]{background:#121212;border-bottom:1px solid #1e1e1e;padding:12px 16px;font-size:14px;color:#f4f4f5;display:flex;align-items:center;gap:8px}.import-card-body[data-v-0cc389d3]{padding:16px}.import-divider[data-v-0cc389d3]{display:flex;align-items:center;color:#84848a;margin:16px 0}.import-divider[data-v-0cc389d3]:before,.import-divider[data-v-0cc389d3]:after{content:"";flex:1;border-top:1px solid #1e1e1e}.import-divider span[data-v-0cc389d3]{padding:0 16px;font-size:13px}.import-status[data-v-0cc389d3]{margin-top:16px;padding:10px 16px;border-radius:6px;font-size:13px}.import-status.success[data-v-0cc389d3]{background:#22c55e1a;color:#22c55e;border:1px solid rgba(34,197,94,.2)}.import-status.error[data-v-0cc389d3]{background:#ef44441a;color:#ef4444;border:1px solid rgba(239,68,68,.2)}.deploy-container[data-v-a81ff1a6]{height:100%;display:flex;flex-direction:column;background:#0a0a09}.loading-state[data-v-a81ff1a6]{display:flex;align-items:center;justify-content:center;height:100%}.deploy-main[data-v-a81ff1a6]{display:flex;flex:1;gap:16px;overflow:hidden;padding:16px}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{n as c,a as d,e as _,K as m,d as y,R as v,g}from"./index-C7axH05o.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,"1827f0cf");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,"2388f7f1");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,"7e734348");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-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};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.sidebar-scroll[data-v-77cb22d9]::-webkit-scrollbar{width:8px}.sidebar-scroll[data-v-77cb22d9]::-webkit-scrollbar-track{background:transparent}.sidebar-scroll[data-v-77cb22d9]::-webkit-scrollbar-thumb{background:#404040;border-radius:4px}.sidebar-scroll[data-v-77cb22d9]::-webkit-scrollbar-thumb:hover{background:#505050}.chat-messages[data-v-9073ba4e]::-webkit-scrollbar{width:6px}.chat-messages[data-v-9073ba4e]::-webkit-scrollbar-track{background:transparent}.chat-messages[data-v-9073ba4e]::-webkit-scrollbar-thumb{background:#404040;border-radius:3px}.chat-messages[data-v-9073ba4e]::-webkit-scrollbar-thumb:hover{background:#505050}.chat-messages[data-v-9073ba4e]{padding:0 16px 16px;font-size:14px;line-height:1.6}.user-question[data-v-9073ba4e]{color:#60a5fa;font-weight:700;border:1px solid #60a5fa;padding:15px;margin:15px;border-radius:10px;display:inline-block;max-width:80%;text-align:left}.ai-thought[data-v-9073ba4e]{color:#d4d4d8;margin-bottom:16px}.log-mute[data-v-9073ba4e]{color:#84848a;margin-bottom:16px;white-space:pre}.tool-input[data-v-9073ba4e]{color:#60a5fa;margin-left:8px}.build-info[data-v-9073ba4e]{color:#84848a;display:flex;align-items:center;gap:8px;margin-bottom:16px}.chat-images[data-v-9073ba4e]{display:flex;gap:8px;flex-wrap:wrap;margin-bottom:10px}.chat-image-thumb[data-v-9073ba4e]{width:120px;height:120px;-o-object-fit:cover;object-fit:cover;border-radius:6px;border:1px solid #3f3f46;cursor:zoom-in;transition:border-color .2s}.chat-image-thumb[data-v-9073ba4e]:hover{border-color:#60a5fa}.chat-input-area[data-v-9073ba4e]{padding:12px 16px;background:#121212;border-top:1px solid #1e1e1e}.input-panel[data-v-9073ba4e]{background:#fff;border-radius:6px;border:1px solid #e0e0e0;overflow:hidden}.input-wrapper[data-v-9073ba4e]{position:relative}.input-area[data-v-9073ba4e]{flex:1}.input-area[data-v-9073ba4e] .el-textarea__inner{border:none;border-radius:0;background:#fff;color:#4b5563;resize:none}.input-area[data-v-9073ba4e] .el-textarea__inner:focus{box-shadow:none}.input-panel .input-actions[data-v-9073ba4e]{display:flex;justify-content:space-between;align-items:center;padding:6px 12px;gap:6px;background:#fff}.input-actions-left[data-v-9073ba4e],.input-actions-right[data-v-9073ba4e]{display:flex;align-items:center;gap:6px}.input-panel .status-action[data-v-9073ba4e]{cursor:pointer;font-size:12px;color:#6b7280}.input-panel .status-action[data-v-9073ba4e]:hover{color:#60a5fa}.input-panel .separator[data-v-9073ba4e]{color:#d1d5db;font-size:12px}.status-bar[data-v-9073ba4e]{display:flex;gap:8px;align-items:center;padding:6px 16px;font-size:12px;color:#84848a;border-top:1px solid #1e1e1e;flex-shrink:0;flex-wrap:wrap;background:#0a0a09}.status-bar .separator[data-v-9073ba4e]{color:#3f3f46}.status-ready[data-v-9073ba4e]{color:#22c55e}.status-thinking[data-v-9073ba4e]{color:#60a5fa}.model-selector[data-v-9073ba4e]{cursor:pointer}.model-selector[data-v-9073ba4e]:hover{color:#60a5fa}.thinking-spinner[data-v-9073ba4e]{display:inline-block;width:12px;height:12px;border:2px solid #60a5fa;border-top-color:transparent;border-radius:50%;animation:spin-9073ba4e .8s linear infinite}@keyframes spin-9073ba4e{to{transform:rotate(360deg)}}.device-frame[data-v-18d9a9df]{height:100%;max-width:100%}.device-frame>iframe[data-v-18d9a9df]{flex:1;min-height:0}.device-frame-app[data-v-18d9a9df]{position:relative;background:#1a1a1a;border-radius:36px;padding:8px;box-shadow:0 0 0 2px #333,0 0 0 4px #1a1a1a,0 0 0 6px #444,0 20px 40px #00000080}.device-frame-app[data-v-18d9a9df]:before{content:"";position:absolute;top:4px;left:50%;transform:translate(-50%);width:120px;height:25px;background:#1a1a1a;border-radius:0 0 16px 16px;z-index:10}.device-frame-app[data-v-18d9a9df]:after{content:"";position:absolute;bottom:4px;left:50%;transform:translate(-50%);width:100px;height:4px;background:#444;border-radius:2px;z-index:10}.device-frame-web[data-v-18d9a9df]{width:100%;background:#2d2d2d;border-radius:12px;padding:12px;box-shadow:0 4px 20px #0006}.device-frame-pad[data-v-18d9a9df]{background:#1a1a1a;border-radius:16px;padding:10px;box-shadow:0 0 0 2px #444,0 0 0 4px #2a2a2a,0 0 0 6px #555,0 20px 40px #00000080}.monaco-editor-container[data-v-f53b2118]{width:100%;overflow:hidden}.monaco-editor-container[data-v-f53b2118] .monaco-editor{padding-top:8px}.monaco-editor-container[data-v-f53b2118] .monaco-editor .overflow-guard{overflow:hidden!important}
|
|
@@ -0,0 +1,18 @@
|
|
|
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-Cn73hS12.js";import{m as P}from"./mediaChat-RT7iqqYb.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
|
+
<html lang="zh-CN">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8">
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
6
|
+
<title>${s}</title>
|
|
7
|
+
<style>
|
|
8
|
+
* { margin: 0; padding: 0; box-sizing: border-box; }
|
|
9
|
+
body { font-family: system-ui, sans-serif; padding: 20px; }
|
|
10
|
+
</style>
|
|
11
|
+
</head>
|
|
12
|
+
<body>
|
|
13
|
+
<h1>${s}</h1>
|
|
14
|
+
</body>
|
|
15
|
+
</html>`;try{await r.writeFile(i,a),this.$message.success("网页创建成功"),this.$emit("created"),this.$emit("update:visible",!1)}catch(n){console.error("Create page failed:",n),this.$message.error("创建网页失败: "+(n.message||"未知错误"))}},cancel(){this.$emit("update:visible",!1)}}};var D=function(){var e=this,t=e._self._c;return e.visible?t("div",{staticClass:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",on:{click:function(i){return i.target!==i.currentTarget?null:e.cancel.apply(null,arguments)}}},[t("div",{staticClass:"bg-sidebar border border-border rounded p-5 w-96"},[t("p",{staticClass:"text-white text-sm font-medium mb-4"},[e._v("新建网页")]),t("div",{staticClass:"mb-3"},[t("label",{staticClass:"text-textMuted text-xs block mb-1"},[e._v("名称")]),t("input",{directives:[{name:"model",rawName:"v-model",value:e.pageName,expression:"pageName"}],ref:"nameInput",staticClass:"w-full px-3 py-2 bg-[#1e1e1e] border border-border rounded text-white text-sm focus:outline-none focus:border-accent",attrs:{placeholder:"输入网页名称"},domProps:{value:e.pageName},on:{keyup:[function(i){return!i.type.indexOf("key")&&e._k(i.keyCode,"enter",13,i.key,"Enter")?null:e.confirm.apply(null,arguments)},function(i){return!i.type.indexOf("key")&&e._k(i.keyCode,"escape",void 0,i.key,void 0)?null:e.cancel.apply(null,arguments)}],input:function(i){i.target.composing||(e.pageName=i.target.value)}}})]),t("div",{staticClass:"mb-3"},[t("label",{staticClass:"text-textMuted text-xs block mb-2"},[e._v("类型")]),t("div",{staticClass:"flex gap-2"},e._l(e.deviceTypes,function(i){return t("label",{key:i.value,staticClass:"flex items-center gap-1 px-3 py-2 rounded border text-sm cursor-pointer transition-colors",class:e.pageType===i.value?"border-accent bg-accent/10 text-white":"border-border text-textMuted hover:border-gray-500"},[t("input",{directives:[{name:"model",rawName:"v-model",value:e.pageType,expression:"pageType"}],staticClass:"hidden",attrs:{type:"radio"},domProps:{value:i.value,checked:e._q(e.pageType,i.value)},on:{change:function(a){e.pageType=i.value}}}),t("i",{staticClass:"text-xs",class:i.icon}),e._v(" "+e._s(i.label)+" ")])}),0)]),t("div",{staticClass:"mb-4 p-3 bg-[#1e1e1e] rounded border border-border"},[t("p",{staticClass:"text-xs text-textMuted mb-1"},[e._v("文件名预览")]),t("p",{staticClass:"text-xs text-textMain font-mono"},[e._v(e._s(e.previewFilename))])]),t("div",{staticClass:"flex justify-end gap-2"},[t("button",{staticClass:"px-3 py-1 text-xs text-textMuted hover:text-white",on:{click:e.cancel}},[e._v("取消")]),t("button",{staticClass:"px-3 py-1 text-xs bg-accent text-white rounded hover:bg-blue-600 disabled:opacity-50 disabled:cursor-not-allowed",attrs:{disabled:!e.pageName.trim()},on:{click:e.confirm}},[e._v("确定")])])])]):e._e()},M=[],F=l(k,D,M,!1,null,null);const $=F.exports,T={name:"DesignPageTree",components:{FileTreeNode:u,CreatePageDialog:$,CopyPathDialog:h},props:{basePath:{type:String,default:".txcode/design"}},data(){return{browseResult:{current_path:"",parent_path:null,items:[]},selectedPath:"",loading:!1,expandedPaths:new Set,contextMenu:{visible:!1,x:0,y:0,target:null},renameDialog:{visible:!1,title:"",value:"",placeholder:"",target:null,action:"rename"},createPageDialogVisible:!1,createPageTargetPath:""}},computed:{fileTreeData(){return this.browseResult.items.filter(e=>e.name!=="session.json").map(e=>({name:e.name,path:e.path,is_directory:e.is_directory,is_drive:e.is_drive||!1,size:e.size,has_children:e.is_directory,expanded:!1,children:[]})).sort((e,t)=>e.is_directory===t.is_directory?e.name.localeCompare(t.name):e.is_directory?-1:1)}},async created(){await this.initBrowse(),document.addEventListener("click",this.hideContextMenu)},beforeDestroy(){document.removeEventListener("click",this.hideContextMenu)},methods:{async initBrowse(){this.loading=!0;try{const s=await r.browseFilesystem(this.basePath);this.browseResult=s.data}catch{try{await r.createDirectory(this.basePath);const e=await r.browseFilesystem(this.basePath);this.browseResult=e.data}catch(e){console.error("Init design directory failed:",e),this.browseResult={current_path:this.basePath,parent_path:"",items:[]}}}finally{this.loading=!1}},async browse(s){this.loading=!0;try{const e=await r.browseFilesystem(s);this.browseResult=e.data}catch(e){console.error("Browse failed:",e)}finally{this.loading=!1}},refresh(){this.browse(this.browseResult.current_path||this.basePath)},createRootFolder(){this.renameDialog={visible:!0,title:"新建文件夹",value:"",placeholder:"输入文件夹名",target:{path:this.browseResult.current_path||this.basePath,is_directory:!0},action:"createFolder"},this.$nextTick(()=>{var s;return(s=this.$refs.renameInput)==null?void 0:s.focus()})},handleSelect(s){this.selectedPath=s.path;let e=s.path;e.startsWith(this.basePath+"/")?e=e.slice(this.basePath.length+1):e===this.basePath&&(e=""),!s.is_directory&&e.endsWith(".html")?(console.log("[DesignPageTree] handleSelect emitting current-page:",e),this.$emit("current-page",e)):console.log("[DesignPageTree] handleSelect skipping (dir or non-html):",s.name,"isDir:",s.is_directory)},handleOpenFile(s){this.$emit("open-file",s)},async handleLoadChildren({path:s,callback:e}){try{const i=((await r.browseFilesystem(s)).data.items||[]).filter(a=>a.name!=="session.json").map(a=>({name:a.name,path:a.path,is_directory:a.is_directory,is_drive:!1,size:a.size,has_children:a.is_directory,expanded:!1,children:[]}));e(i.sort((a,n)=>a.is_directory===n.is_directory?a.name.localeCompare(n.name):a.is_directory?-1:1))}catch(t){console.error("Load children failed:",t),e([])}},showContextMenu(s,e){e&&(s.preventDefault(),this.contextMenu={visible:!0,x:s.pageX,y:s.pageY,target:e},this.selectedPath=e.path)},hideContextMenu(){this.contextMenu.visible=!1},copyPath(){this.hideContextMenu(),this.$refs.copyPathDialog.open(this.contextMenu.target.path)},createNewPage(){this.hideContextMenu(),this.createPageTargetPath=this.contextMenu.target.path,this.createPageDialogVisible=!0},createNewFolder(){this.hideContextMenu();const s=this.contextMenu.target;this.renameDialog={visible:!0,title:"新建文件夹",value:"",placeholder:"输入文件夹名",target:s,action:"createFolder"},this.$nextTick(()=>{var e;return(e=this.$refs.renameInput)==null?void 0:e.focus()})},renameItem(){this.hideContextMenu();const s=this.contextMenu.target;s.is_directory?this.renameDialog={visible:!0,title:"重命名文件夹",value:s.name,placeholder:"输入新名称",target:s,action:"rename"}:this.renameDialog={visible:!0,title:"重命名文件",value:s.name,placeholder:"输入新名称",target:s,action:"rename"},this.$nextTick(()=>{var e,t;(e=this.$refs.renameInput)==null||e.focus(),(t=this.$refs.renameInput)==null||t.select()})},confirmRename(){const{value:s,target:e,action:t}=this.renameDialog;if(!s.trim()){this.renameDialog.visible=!1;return}const i=e.path.includes("\\")?"\\":"/";let a,n;t==="createFolder"?(a=e.path+i+s.trim(),n=r.createDirectory(a)):(a=e.path.substring(0,e.path.lastIndexOf(i))+i+s.trim(),n=r.renameFile(e.path,a)),n.then(()=>{this.refresh(),this.$emit("file-changed")}).catch(o=>{console.error("Operation failed:",o),this.$message.error(t==="createFolder"?"创建文件夹失败":"重命名失败")}),this.renameDialog.visible=!1},cancelRename(){this.renameDialog.visible=!1},async deleteItem(){this.hideContextMenu();try{await this.$confirm(`确定要删除 "${this.contextMenu.target.name}" 吗?`,"确认删除",{confirmButtonText:"删除",cancelButtonText:"取消",type:"warning"}),await r.deleteFile(this.contextMenu.target.path),this.$message.success("删除成功"),this.refresh(),this.$emit("file-changed")}catch(s){s!=="cancel"&&(console.error("Delete failed:",s),this.$message.error("删除失败"))}},downloadFile(){this.hideContextMenu();const s=this.contextMenu.target;s&&r.downloadFilesystemWithProgress(s.path,s.name,()=>{}).catch(e=>this.$message.error("下载失败: "+e.message))},onPageCreated(){this.createPageDialogVisible=!1,this.refresh(),this.$emit("file-changed")},onExpandPath(s){const e=new Set(this.expandedPaths);e.add(s),this.expandedPaths=e},onCollapsePath(s){const e=new Set(this.expandedPaths);e.delete(s),this.expandedPaths=e}}};var I=function(){var i;var e=this,t=e._self._c;return t("div",{staticClass:"flex flex-col flex-1 min-h-0"},[t("div",{staticClass:"flex items-center gap-1 px-2 py-2 border-b border-border"},[t("button",{staticClass:"p-1 text-textMuted hover:text-white",attrs:{title:"刷新"},on:{click:e.refresh}},[t("i",{staticClass:"fa-solid fa-refresh"})]),t("button",{staticClass:"p-1 text-textMuted hover:text-white",attrs:{title:"新建文件夹"},on:{click:e.createRootFolder}},[t("i",{staticClass:"fa-solid fa-folder-plus"})])]),t("div",{staticClass:"flex-1 overflow-y-auto py-1 pb-8 sidebar-scroll",staticStyle:{"padding-bottom":"60px"}},[e.loading?t("div",{staticClass:"flex items-center justify-center py-8 text-textMuted"},[t("i",{staticClass:"fa-solid fa-spinner fa-spin mr-2"}),e._v(" 加载中... ")]):e.fileTreeData.length===0?t("div",{staticClass:"flex flex-col items-center justify-center py-12 text-textMuted text-sm"},[t("i",{staticClass:"fa-solid fa-folder-open text-4xl mb-3 opacity-20"}),t("p",[e._v("设计目录为空")]),t("p",{staticClass:"text-xs mt-1"},[e._v("右键文件夹创建网页")])]):e._l(e.fileTreeData,function(a){return t("file-tree-node",{key:a.path,attrs:{node:a,level:0,"selected-path":e.selectedPath,"expanded-paths":e.expandedPaths},on:{select:e.handleSelect,"open-file":e.handleOpenFile,"load-children":e.handleLoadChildren,contextmenu:e.showContextMenu,"expand-path":e.onExpandPath,"collapse-path":e.onCollapsePath}})})],2),t("div",{directives:[{name:"show",rawName:"v-show",value:e.contextMenu.visible,expression:"contextMenu.visible"}],staticClass:"fixed bg-sidebar border border-border rounded shadow-lg py-1 z-50 min-w-[160px]",style:{left:e.contextMenu.x+"px",top:e.contextMenu.y+"px"}},[(i=e.contextMenu.target)!=null&&i.is_directory?[t("button",{staticClass:"w-full text-left px-4 py-2 text-sm text-textMain hover:bg-active flex items-center gap-2",on:{click:e.createNewPage}},[t("i",{staticClass:"fa-solid fa-file-lines text-xs"}),e._v(" 新建网页 ")]),t("button",{staticClass:"w-full text-left px-4 py-2 text-sm text-textMain hover:bg-active flex items-center gap-2",on:{click:e.createNewFolder}},[t("i",{staticClass:"fa-solid fa-folder-plus text-xs"}),e._v(" 新建文件夹 ")]),t("div",{staticClass:"border-t border-border my-1"}),t("button",{staticClass:"w-full text-left px-4 py-2 text-sm text-textMain hover:bg-active flex items-center gap-2",on:{click:e.renameItem}},[t("i",{staticClass:"fa-solid fa-pen text-xs"}),e._v(" 重命名 ")]),t("button",{staticClass:"w-full text-left px-4 py-2 text-sm text-red-400 hover:bg-active flex items-center gap-2",on:{click:e.deleteItem}},[t("i",{staticClass:"fa-solid fa-trash text-xs"}),e._v(" 删除 ")])]:[t("button",{staticClass:"w-full text-left px-4 py-2 text-sm text-textMain hover:bg-active flex items-center gap-2",on:{click:e.copyPath}},[t("i",{staticClass:"fa-solid fa-copy text-xs"}),e._v(" 复制路径 ")]),t("button",{staticClass:"w-full text-left px-4 py-2 text-sm text-textMain hover:bg-active flex items-center gap-2",on:{click:e.downloadFile}},[t("i",{staticClass:"fa-solid fa-download text-xs"}),e._v(" 下载 ")]),t("button",{staticClass:"w-full text-left px-4 py-2 text-sm text-textMain hover:bg-active flex items-center gap-2",on:{click:e.renameItem}},[t("i",{staticClass:"fa-solid fa-pen text-xs"}),e._v(" 重命名 ")]),t("button",{staticClass:"w-full text-left px-4 py-2 text-sm text-red-400 hover:bg-active flex items-center gap-2",on:{click:e.deleteItem}},[t("i",{staticClass:"fa-solid fa-trash text-xs"}),e._v(" 删除 ")])]],2),t("div",{directives:[{name:"show",rawName:"v-show",value:e.renameDialog.visible,expression:"renameDialog.visible"}],staticClass:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",on:{click:function(a){return a.target!==a.currentTarget?null:e.cancelRename.apply(null,arguments)}}},[t("div",{staticClass:"bg-sidebar border border-border rounded p-4 w-80"},[t("p",{staticClass:"text-white text-sm mb-3"},[e._v(e._s(e.renameDialog.title))]),t("input",{directives:[{name:"model",rawName:"v-model",value:e.renameDialog.value,expression:"renameDialog.value"}],ref:"renameInput",staticClass:"w-full px-3 py-2 bg-[#1e1e1e] border border-border rounded text-white text-sm focus:outline-none focus:border-accent",attrs:{placeholder:e.renameDialog.placeholder},domProps:{value:e.renameDialog.value},on:{keyup:[function(a){return!a.type.indexOf("key")&&e._k(a.keyCode,"enter",13,a.key,"Enter")?null:e.confirmRename.apply(null,arguments)},function(a){return!a.type.indexOf("key")&&e._k(a.keyCode,"escape",void 0,a.key,void 0)?null:e.cancelRename.apply(null,arguments)}],input:function(a){a.target.composing||e.$set(e.renameDialog,"value",a.target.value)}}}),t("div",{staticClass:"flex justify-end gap-2 mt-4"},[t("button",{staticClass:"px-3 py-1 text-xs text-textMuted hover:text-white",on:{click:e.cancelRename}},[e._v("取消")]),t("button",{staticClass:"px-3 py-1 text-xs bg-accent text-white rounded hover:bg-blue-600",on:{click:e.confirmRename}},[e._v("确定")])])])]),t("CreatePageDialog",{attrs:{visible:e.createPageDialogVisible,"target-path":e.createPageTargetPath},on:{"update:visible":function(a){e.createPageDialogVisible=a},created:e.onPageCreated}}),t("CopyPathDialog",{ref:"copyPathDialog"})],1)},N=[],V=l(T,I,N,!1,null,"77cb22d9");const R=V.exports,z={name:"DesignAiChat",components:{ModelSelectDialog:b,CommandDialog:v,FileSelectDialog:g,SkillSelectDialog:m,ImagePreviewList:p,ResizableTextarea:f},mixins:[P()],props:{basePath:{type:String,default:".txcode/design"},currentPage:{type:String,default:""}},data(){return{inputMessage:"",disabled:!1,stopping:!1,promptTokens:0,logItems:[],modelName:"",modelSelectVisible:!1,commandDialogVisible:!1,fileSelectVisible:!1,skillSelectVisible:!1,skillCursorPos:-1,sessionId:"",sessionStatus:"idle",wsUnsubscribe:null,requestSeq:0}},watch:{currentPage:{immediate:!1,handler(s){this.loadSessionForPage(s)}}},async mounted(){await this.loadDefaultModel(),r.ws.init(),this.currentPage&&await this.loadSessionForPage(this.currentPage)},beforeDestroy(){this.wsUnsubscribe&&this.wsUnsubscribe()},methods:{getSessionJsonPath(){return this.basePath+"/session.json"},async readSessionJson(){var s;try{const e=await r.getFileContent(this.getSessionJsonPath());if(e&&((s=e.data)!=null&&s.content)){const t=JSON.parse(e.data.content);if(t.pageSessions){const i={};for(const[a,n]of Object.entries(t.pageSessions))a.endsWith(".html")&&a!=="session.json"&&(i[a]=n);Object.keys(i).length!==Object.keys(t.pageSessions).length&&(t.pageSessions=i,this.writeSessionJson(t).catch(()=>{}))}return t}}catch{}return{pageSessions:{}}},async writeSessionJson(s){await r.writeFile(this.getSessionJsonPath(),JSON.stringify(s,null,2))},async loadSessionForPage(s){var n;const e=++this.requestSeq;console.log("[DesignAiChat] loadSessionForPage called:",s,"seq:",e);const t=performance.now();if(!s||!s.endsWith(".html")){this.wsUnsubscribe&&(this.wsUnsubscribe(),this.wsUnsubscribe=null),this.sessionId="",this.logItems=[],this.promptTokens=0,this.sessionStatus="idle",this.$emit("status-change","idle"),console.log("[DesignAiChat] loadSessionForPage skipped (not html):",s);return}const i=await this.readSessionJson();if(this.requestSeq!==e)return;console.log("[DesignAiChat] sessionData loaded:",Object.keys(i.pageSessions||{}));const a=(n=i.pageSessions)==null?void 0:n[s];if(console.log("[DesignAiChat] pageSession for",s,":",!!a),a!=null&&a.sessionId)try{console.log("[DesignAiChat] loading existing session:",a.sessionId);const o=performance.now(),c=await r.getSession(a.sessionId);if(this.requestSeq!==e)return;if(console.log("[DesignAiChat] getSession took:",(performance.now()-o).toFixed(1),"ms"),c&&c.data){this.sessionId=a.sessionId,this.subscribeSession();const d=performance.now();if(await this.loadMessages(),this.requestSeq!==e)return;console.log("[DesignAiChat] loadMessages took:",(performance.now()-d).toFixed(1),"ms"),console.log("[DesignAiChat] loadSessionForPage done (existing), total:",(performance.now()-t).toFixed(1),"ms");return}}catch(o){console.error("[DesignAiChat] getSession failed:",o)}try{console.log("[DesignAiChat] creating new session for:",s);const o=await r.createSession(`设计页面: ${s}`);if(this.requestSeq!==e||(this.sessionId=o.data.id,i.pageSessions[s]={sessionId:this.sessionId},await this.writeSessionJson(i),this.requestSeq!==e))return;this.logItems=[],this.promptTokens=0,this.subscribeSession(),console.log("[DesignAiChat] loadSessionForPage done (new), total:",(performance.now()-t).toFixed(1),"ms")}catch(o){console.error("Create session failed:",o)}},async loadDefaultModel(){var s;try{const e=await r.getConfig("defaultModel");this.modelName=((s=e.data)==null?void 0:s.value)||""}catch(e){console.error("Load model failed:",e)}},async loadMessages(){if(this.sessionId)try{const s=await r.getMessages(this.sessionId);this.logItems=s.data||[],this.$nextTick(()=>this.scrollChatToBottom(!0))}catch(s){console.error("Load messages failed:",s)}},handleKeydown(s){if(s.key==="Enter")if(s.ctrlKey){const e=s.target,t=e.selectionStart,i=e.selectionEnd,a=this.inputMessage;this.inputMessage=a.substring(0,t)+`
|
|
16
|
+
`+a.substring(i),this.$nextTick(()=>{e.selectionStart=e.selectionEnd=t+1})}else s.preventDefault(),this.sendMessage()},async sendMessage(){const s=this.inputMessage.trim(),e=this.mediaFiles&&this.mediaFiles.length>0;if(!s&&!e||this.disabled)return;if(!this.sessionId){this.$message.error("请在左侧选择设计页面");return}this.wsUnsubscribe||this.subscribeSession();let t=s;this.currentPage&&(t=`当前设计页面:${this.currentPage}
|
|
17
|
+
用户需求:${s}
|
|
18
|
+
请基于以上设计页面路径,对该页面进行设计或修改。`),this.inputMessage="",this.disabled=!0,this.stopping=!1;const i=(this.mediaFiles||[]).filter(a=>!a.uploading&&a.filePath).map(a=>({filePath:a.filePath,type:a.type,dataUrl:a.dataUrl}));this.logItems.push({type:"chat",content:s,mediaFiles:i}),this.scrollChatToBottom(!0),r.sessionWsSend(this.sessionId,"chat",{message:t,sessionId:this.sessionId,modelName:this.modelName||void 0,agent:"design",mediaFiles:i.map(a=>({filePath:a.filePath,type:a.type}))}),this.mediaFiles=[]},stopChat(){!this.sessionId||this.stopping||(this.stopping=!0,r.sessionWsSend(this.sessionId,"stop",{sessionId:this.sessionId}))},subscribeSession(){this.sessionId&&(this.wsUnsubscribe&&this.wsUnsubscribe(),this.wsUnsubscribe=r.wsSubscribe(this.sessionId,{running_sessions:s=>{const t=((s==null?void 0:s.runningSessionIds)||[]).includes(this.sessionId);this.sessionStatus=t?"processing":"idle",this.disabled=t,this.$emit("status-change",this.sessionStatus)},step:s=>{var e;this.logItems.push({type:"step",thought:s.thought,toolCalls:s.toolCalls,success:s.success}),(e=s.usage)!=null&&e.promptTokens&&(this.promptTokens=s.usage.promptTokens),this.scrollChatToBottom()},compact:()=>{this.logItems.push({type:"system",content:"【会话已压缩】"}),this.loadMessages()},done:s=>{var e;this.disabled=!1,this.stopping=!1,this.sessionStatus="completed",this.$emit("status-change","completed"),s!=null&&s.modelName&&(this.modelName=s.modelName),(e=s==null?void 0:s.usage)!=null&&e.promptTokens&&(this.promptTokens=s.usage.promptTokens),s!=null&&s.response&&this.logItems.push({type:"think",content:s.response}),this.scrollChatToBottom(),this.$emit("design-updated")},stopped:()=>{this.disabled=!1,this.stopping=!1,this.sessionStatus="idle",this.$emit("status-change","idle"),this.logItems.push({type:"think",content:"【已停止】"}),this.scrollChatToBottom()},error:s=>{this.$message.error((s==null?void 0:s.error)||"发生错误"),this.disabled=!1,this.stopping=!1,this.sessionStatus="idle",this.$emit("status-change","idle")}}))},scrollChatToBottom(s=!1){const e=C(this.$refs.messagesContainer);this.$nextTick(()=>w(this.$refs.messagesContainer,{force:s,prevSnapshot:e}))},renderMarkdown(s){return s?x(s,{breaks:!0}):""},formatInput(s,e){try{const t=typeof e=="string"?JSON.parse(e):e;return s==="bash"||s==="execute_bash"?t.command+(t.workdir?` (${t.workdir})`:""):s==="read_file"?t.file_path+(t.offset?`:${t.offset}`:""):s==="edit_file"||s==="write_file"?t.file_path:s==="glob"||s==="find_files"?t.pattern+(t.directory?` (${t.directory})`:""):s==="grep"||s==="search_content"?`"${t.pattern}" (${t.directory||""})`:JSON.stringify(t)}catch{return e}},openModelSelector(){this.modelSelectVisible=!0},onModelSelected(s){const e=s.name.split("/");this.modelName=e.length>2?e.slice(1).join("/"):s.name,r.setConfig("defaultModel",this.modelName)},openCommandDialog(){this.commandDialogVisible=!0},handleExecuteCommand(s){this.inputMessage=s+" ",this.$nextTick(()=>{const e=this.$el.querySelector(".input-area textarea");e&&e.focus()})},openFileSelect(){this.fileSelectVisible=!0},onFileSelected(s){const e=this.inputMessage.lastIndexOf("@");e!==-1?this.inputMessage=this.inputMessage.slice(0,e)+s+" ":this.inputMessage+=s+" ",this.cancelFileSelect()},cancelFileSelect(){this.fileSelectVisible=!1},openSkillSelect(){const s=this.$el.querySelector(".input-area textarea");this.skillCursorPos=s?s.selectionStart:-1,this.skillSelectVisible=!0},onSkillSelected(s){const e=`[${s}] `,t=this.skillCursorPos>=0?this.skillCursorPos:0;this.inputMessage=this.inputMessage.slice(0,t)+e+this.inputMessage.slice(t),this.cancelSkillSelect()},cancelSkillSelect(){this.skillSelectVisible=!1}}};var E=function(){var e=this,t=e._self._c;return t("div",{staticClass:"flex flex-col flex-1 min-h-0"},[t("div",{ref:"messagesContainer",staticClass:"chat-messages flex-1 overflow-y-auto px-3 py-2 min-h-0"},[e.logItems.length?e._e():t("div",{staticClass:"empty-state"},[t("i",{staticClass:"fa-solid fa-robot text-4xl mb-3 opacity-20 block text-center"}),t("p",{staticClass:"text-sm text-textMuted text-center"},[e._v("AI设计助手可协助您分析和优化设计")]),t("p",{staticClass:"text-xs text-textMuted text-center mt-1"},[e._v("Enter 发送,Ctrl+Enter 换行")])]),e._l(e.logItems,function(i,a){return[i.type==="chat"?t("div",{key:a,staticClass:"flex justify-end mb-3"},[t("div",{staticClass:"user-question"},[i.mediaFiles&&i.mediaFiles.length>0?t("div",{staticClass:"chat-images mb-1"},e._l(i.mediaFiles,function(n){return t("img",{key:n.filePath,staticClass:"chat-image-thumb",attrs:{src:n.url||n.dataUrl||n.filePath},on:{click:function(o){return o.stopPropagation(),e.openImagePreview(n)}}})}),0):e._e(),t("div",{staticClass:"text-sm"},[e._v(e._s(i.content))])])]):i.type==="system"?t("div",{key:a,staticClass:"system-message mb-2",domProps:{innerHTML:e._s(e.renderMarkdown(i.content))}}):i.type==="step"?[i.thought?t("div",{staticClass:"ai-thought mb-2",domProps:{innerHTML:e._s(e.renderMarkdown(i.thought))}}):e._e(),e._l(i.toolCalls,function(n,o){return t("div",{key:o,staticClass:"log-mute text-xs text-textMuted mb-1"},[t("span",{class:i.success!==!1?"text-green-400":"text-red-400"},[e._v(" "+e._s(i.success!==!1?"✓":"✗")+" ")]),e._v(" "+e._s(n.function.name)+" "),n.function.arguments?t("span",{staticClass:"tool-input"},[e._v(e._s(e.formatInput(n.function.name,n.function.arguments)))]):e._e()])})]:i.type==="think"?t("div",{key:a,staticClass:"ai-thought mb-2",domProps:{innerHTML:e._s(e.renderMarkdown(i.content))}}):e._e()]}),e.modelName?t("div",{staticClass:"build-info"},[t("span",{staticClass:"icon"},[e._v("▣")]),e._v(" Build · "+e._s(e.modelName)+" ")]):e._e()],2),t("div",{staticClass:"chat-input-area flex-shrink-0"},[e.mediaFiles&&e.mediaFiles.length>0?t("ImagePreviewList",{attrs:{files:e.mediaFiles,disabled:e.disabled},on:{remove:e.removeMedia}}):e._e(),t("div",{staticClass:"input-panel"},[t("div",{staticClass:"input-wrapper"},[t("ResizableTextarea",{staticClass:"input-area",attrs:{rows:5,placeholder:"输入消息... (Enter 发送, Ctrl+Enter 换行, @ 选择文件)",disabled:e.disabled&&!e.stopping},on:{"paste-image":e.handlePasteImages},nativeOn:{keydown:function(i){return!i.type.indexOf("key")&&e._k(i.keyCode,"enter",13,i.key,"Enter")?null:e.handleKeydown.apply(null,arguments)}},model:{value:e.inputMessage,callback:function(i){e.inputMessage=i},expression:"inputMessage"}}),t("input",{ref:"mediaInput",staticStyle:{display:"none"},attrs:{type:"file",accept:"image/*",multiple:""},on:{change:e.handleImageSelected}})],1),t("div",{staticClass:"input-actions"},[t("div",{staticClass:"input-actions-left"},[t("span",{staticClass:"status-action",on:{click:e.openFileSelect,mousedown:function(i){i.preventDefault()}}},[e._v("选择文件")]),t("span",{staticClass:"separator"},[e._v("|")]),t("span",{staticClass:"status-action",on:{click:e.openSkillSelect,mousedown:function(i){i.preventDefault()}}},[e._v("选择Skill")]),t("span",{staticClass:"separator"},[e._v("|")]),t("span",{staticClass:"status-action",on:{click:e.openCommandDialog,mousedown:function(i){i.preventDefault()}}},[e._v("命令")])]),t("div",{staticClass:"input-actions-right"},[t("el-button",{staticClass:"upload-btn",attrs:{disabled:e.disabled,size:"small"},on:{click:e.handleImageUpload}},[e._v("图片")]),e.disabled&&!e.stopping?t("el-button",{staticClass:"stop-btn",attrs:{type:"danger",size:"small"},on:{click:e.stopChat}},[e._v(" ■ 停止 ")]):e.stopping?t("el-button",{staticClass:"stop-btn",attrs:{type:"info",disabled:"",size:"small"}},[e._v(" 停止中... ")]):t("el-button",{staticClass:"send-btn",attrs:{type:"primary",disabled:!e.inputMessage.trim()&&(!e.mediaFiles||e.mediaFiles.length===0),size:"small"},on:{click:e.sendMessage}},[e._v(" 发送 ")])],1)])]),t("div",{staticClass:"status-bar"},[t("span",{class:e.sessionStatus==="processing"?"status-thinking":"status-ready"},[e.sessionStatus==="processing"?t("span",{staticClass:"thinking-spinner"}):e._e(),e._v(" "+e._s(e.sessionStatus==="processing"?"思考中":"✓ 就绪")+" ")]),t("span",{staticClass:"separator"},[e._v("|")]),t("span",{staticClass:"model-selector",on:{click:e.openModelSelector,mousedown:function(i){i.preventDefault()}}},[e._v(" 模型:"+e._s(e.modelName||"-")+" ▾ ")]),t("span",{staticClass:"separator"},[e._v("|")]),t("span",[e._v("会话:"+e._s(e.sessionId?e.sessionId.slice(0,8):"--------"))]),t("span",{staticClass:"separator"},[e._v("|")]),t("span",[e._v("token:"+e._s(e.promptTokens||0))])])],1),e.previewImage?t("div",{staticClass:"fixed inset-0 bg-black/50 z-50 flex items-center justify-center",on:{click:e.closeImagePreview}},[t("span",{staticClass:"absolute top-4 right-4 text-white text-2xl cursor-pointer"},[e._v("×")]),t("img",{staticClass:"max-w-[90vw] max-h-[90vh]",attrs:{src:e.previewImage.url||e.previewImage.dataUrl||e.previewImage.filePath},on:{click:function(i){i.stopPropagation()}}})]):e._e(),t("ModelSelectDialog",{attrs:{visible:e.modelSelectVisible,"current-model":e.modelName},on:{"update:visible":function(i){e.modelSelectVisible=i},select:e.onModelSelected}}),t("CommandDialog",{attrs:{visible:e.commandDialogVisible},on:{"update:visible":function(i){e.commandDialogVisible=i},execute:e.handleExecuteCommand}}),t("FileSelectDialog",{attrs:{visible:e.fileSelectVisible},on:{"update:visible":function(i){e.fileSelectVisible=i},select:e.onFileSelected,close:e.cancelFileSelect}}),t("SkillSelectDialog",{attrs:{visible:e.skillSelectVisible},on:{"update:visible":function(i){e.skillSelectVisible=i},select:e.onSkillSelected,close:e.cancelSkillSelect}})],1)},L=[],j=l(z,E,L,!1,null,"9073ba4e");const q=j.exports,A={name:"DesignSidebar",components:{DesignPageTree:R,DesignAiChat:q},props:{basePath:{type:String,default:".txcode/design"}},data(){return{activeTab:"pages",currentPage:""}}};var O=function(){var e=this,t=e._self._c;return t("aside",{staticClass:"bg-[#121212] border border-[#1e1e1e] flex flex-col shrink-0 overflow-hidden",staticStyle:{width:"480px"}},[t("div",{staticClass:"flex border-b border-[#1e1e1e] bg-[#121212]"},[t("div",{staticClass:"flex-1 text-center px-3 py-2.5 cursor-pointer text-sm border-b-2 transition-colors",class:e.activeTab==="pages"?"border-[#60a5fa] text-[#f4f4f5]":"border-transparent text-[#84848a] hover:text-[#f4f4f5]",on:{click:function(i){e.activeTab="pages"}}},[t("i",{staticClass:"fa-solid fa-file-code mr-1"}),e._v(" 设计页面 ")]),t("div",{staticClass:"flex-1 text-center px-3 py-2.5 cursor-pointer text-sm border-b-2 transition-colors",class:e.activeTab==="ai"?"border-[#60a5fa] text-[#f4f4f5]":"border-transparent text-[#84848a] hover:text-[#f4f4f5]",on:{click:function(i){e.activeTab="ai"}}},[t("i",{staticClass:"fa-solid fa-robot mr-1"}),e._v(" AI设计助手 ")])]),t("DesignPageTree",{directives:[{name:"show",rawName:"v-show",value:e.activeTab==="pages",expression:"activeTab === 'pages'"}],attrs:{"base-path":e.basePath},on:{"open-file":function(i){return e.$emit("open-file",i)},"current-page":function(i){e.currentPage=i},"file-changed":function(i){return e.$emit("file-changed")}}}),e.activeTab==="ai"?t("DesignAiChat",{attrs:{"base-path":e.basePath,"current-page":e.currentPage},on:{"design-updated":function(i){return e.$emit("file-changed")},"status-change":function(i){return e.$emit("ai-status-change",i)}}}):e._e()],1)},B=[],U=l(A,O,B,!1,null,null);const J=U.exports,W={name:"DesignPreview",props:{fileContent:{type:String,default:""},fileName:{type:String,default:""},relativePath:{type:String,default:""}},data(){return{activeDevice:"web",refreshKey:0,renderIframe:!1,_relativePathVersion:0,deviceSizes:[{value:"app",label:"App",icon:"fa-solid fa-mobile-screen",width:375},{value:"web",label:"Web",icon:"fa-solid fa-desktop",width:0},{value:"pad",label:"Pad",icon:"fa-solid fa-tablet-screen-button",width:768}]}},computed:{previewSrc(){if(!this.relativePath)return"";const s=`/design_html/${encodeURI(this.relativePath)}?_=${this._relativePathVersion}`;return console.log("[DesignPreview] previewSrc computed:",s),s},iframeStyle(){return{width:"100%",height:"100%"}},frameStyle(){switch(this.activeDevice){case"app":return{width:"390px"};case"pad":return{width:"800px"};default:return{}}}},watch:{fileName:{immediate:!0,handler(s){s&&(s.includes("_app.html")?this.activeDevice="app":s.includes("_web.html")?this.activeDevice="web":s.includes("_pad.html")?this.activeDevice="pad":this.activeDevice="web",console.log("[DesignPreview] fileName changed:",s,"→ activeDevice:",this.activeDevice))}},relativePath(s,e){console.log("[DesignPreview] relativePath changed:",e,"→",s),s?(this._relativePathVersion++,console.log("[DesignPreview] _relativePathVersion:",this._relativePathVersion),this.renderIframe=!1,console.log("[DesignPreview] renderIframe set to false, scheduling recreate"),this.$nextTick(()=>{this.renderIframe=!0,console.log("[DesignPreview] renderIframe set to true, iframe should be created with src:",this.previewSrc)})):(this.renderIframe=!1,console.log("[DesignPreview] renderIframe set to false (no file)"))}},mounted(){console.log("[DesignPreview] mounted, relativePath:",this.relativePath)},updated(){console.log("[DesignPreview] updated, relativePath:",this.relativePath,"previewSrc:",this.previewSrc)},beforeDestroy(){console.log("[DesignPreview] beforeDestroy")},methods:{refreshPreview(){this.refreshKey++,this._relativePathVersion++,this.renderIframe=!1,this.$nextTick(()=>{this.renderIframe=!0,console.log("[DesignPreview] refreshPreview, iframe recreated")})},openInNewTab(){this.previewSrc&&window.open(this.previewSrc,"_blank")},onIframeLoad(){console.log("[DesignPreview] iframe onload, src:",this.previewSrc)}}};var K=function(){var e=this,t=e._self._c;return t("div",{staticClass:"flex flex-col h-full"},[t("div",{staticClass:"flex items-center gap-2 px-3 py-2 border-b border-border bg-sidebar"},[t("span",{staticClass:"text-xs text-textMuted mr-2"},[e._v("视口:")]),e._l(e.deviceSizes,function(i){return t("button",{key:i.value,staticClass:"px-3 py-1 text-xs rounded border transition-colors",class:e.activeDevice===i.value?"border-accent bg-accent/10 text-white":"border-transparent text-textMuted hover:border-gray-500",attrs:{title:i.label},on:{click:function(a){e.activeDevice=i.value}}},[t("i",{staticClass:"mr-1",class:i.icon}),e._v(e._s(i.label)+" ")])})],2),t("div",{staticClass:"flex-1 flex items-center justify-center overflow-auto bg-[#f5f5f5] p-4"},[e.relativePath?t("div",{staticClass:"device-frame flex flex-col self-stretch",class:`device-frame-${e.activeDevice}`,style:e.frameStyle},[t("div",{staticClass:"flex justify-end mb-2 shrink-0 gap-1"},[t("button",{staticClass:"p-1 text-textMuted hover:text-white text-xs rounded hover:bg-white/10 transition-colors",attrs:{title:"新窗口打开"},on:{click:e.openInNewTab}},[t("i",{staticClass:"fa-solid fa-up-right-from-square"})]),t("button",{staticClass:"p-1 text-textMuted hover:text-white text-xs rounded hover:bg-white/10 transition-colors",attrs:{title:"刷新预览"},on:{click:e.refreshPreview}},[t("i",{staticClass:"fa-solid fa-refresh"})])]),e.renderIframe?t("iframe",{ref:"previewFrame",staticClass:"w-full border-0",style:e.iframeStyle,attrs:{src:e.previewSrc,sandbox:"allow-scripts allow-same-origin allow-forms allow-modals allow-popups"},on:{load:e.onIframeLoad}}):e._e()]):t("div",{staticClass:"text-textMuted text-center mt-20"},[t("i",{staticClass:"fa-solid fa-eye text-6xl mb-4 opacity-20 block"}),t("p",[e._v("双击左侧 HTML 文件预览")])])])])},H=[],X=l(W,K,H,!1,null,"18d9a9df");const Y=X.exports,G={name:"DesignEditor",props:{fileContent:{type:String,default:""},fileName:{type:String,default:""},filePath:{type:String,default:""}},data(){return{editor:null,originalContent:"",contentChanged:!1,saving:!1}},watch:{fileContent:{immediate:!0,handler(s){if(!this.fileName||!this.editor&&(this.initEditor(),!this.editor))return;const e=s||"";this.editor.getValue()!==e&&(this.originalContent=e,this.editor.setValue(e),this.contentChanged=!1)}}},mounted(){this.$nextTick(()=>this.initEditor())},beforeDestroy(){this.editor&&(this.editor.dispose(),this.editor=null)},methods:{initEditor(){this.editor||this.$refs.editorContainer&&this.fileName&&(this.editor=y.create(this.$refs.editorContainer,{value:this.fileContent||"",language:"html",theme:"vs-dark",automaticLayout:!0,minimap:{enabled:!1},scrollBeyondLastLine:!1,fontSize:14,fontFamily:'Consolas, Monaco, "Courier New", monospace',lineNumbers:"on",scrollbar:{useShadows:!1,vertical:"auto",horizontal:"auto"}}),this.originalContent=this.fileContent||"",this.editor.onDidChangeModelContent(()=>{this.editor&&(this.contentChanged=this.editor.getValue()!==this.originalContent,this.$emit("content-changed",this.contentChanged))}),this.editor.addCommand(_.CtrlCmd|S.KeyS,()=>{this.saveFile()}))},updateContent(s){if(!this.editor){this.initEditor(),this.$nextTick(()=>this.updateContent(s));return}this.originalContent=s,this.editor.setValue(s),this.contentChanged=!1},layout(){!this.editor&&this.fileName&&this.initEditor(),this.editor&&this.$nextTick(()=>this.editor.layout())},async saveFile(){if(!(!this.editor||!this.filePath)){this.saving=!0;try{const s=this.editor.getValue();await r.writeFile(this.filePath,s),this.originalContent=s,this.contentChanged=!1,this.$emit("content-saved",s),this.$emit("content-changed",!1),this.$message.success("文件已保存")}catch(s){console.error("Save failed:",s),this.$message.error("保存文件失败")}finally{this.saving=!1}}}}};var Q=function(){var e=this,t=e._self._c;return t("div",{staticClass:"flex flex-col h-full"},[e.fileName?e._e():t("div",{staticClass:"flex-1 flex items-center justify-center text-textMuted"},[e._m(0)]),t("div",{directives:[{name:"show",rawName:"v-show",value:e.fileName,expression:"fileName"}],ref:"editorContainer",staticClass:"monaco-editor-container flex-1"}),e.fileName?t("div",{staticClass:"h-8 bg-sidebar border-t border-border flex items-center justify-between px-3 shrink-0"},[t("div",{staticClass:"flex items-center gap-4 text-xs text-textMuted"},[t("span",[e._v(e._s(e.fileName))]),e.contentChanged?t("span",{staticClass:"text-yellow-500"},[e._v("已修改")]):e._e()]),t("div",{staticClass:"flex items-center gap-2"},[t("button",{staticClass:"p-1 text-textMuted hover:text-white text-xs rounded hover:bg-white/10 transition-colors",attrs:{title:"刷新内容"},on:{click:function(i){return e.$emit("refresh")}}},[t("i",{staticClass:"fa-solid fa-refresh"})]),t("button",{staticClass:"px-3 py-1 text-xs bg-accent text-white rounded hover:bg-blue-600 disabled:opacity-50 disabled:cursor-not-allowed",attrs:{disabled:!e.contentChanged||e.saving},on:{click:e.saveFile}},[e.saving?t("i",{staticClass:"fa-solid fa-spinner fa-spin mr-1"}):t("i",{staticClass:"fa-solid fa-save mr-1"}),e._v(" 保存 ")])])]):e._e()])},Z=[function(){var s=this,e=s._self._c;return e("div",{staticClass:"text-center"},[e("i",{staticClass:"fa-solid fa-file-code text-6xl mb-4 opacity-20 block"}),e("p",[s._v("双击左侧 HTML 文件编辑")])])}],ee=l(G,Q,Z,!1,null,"f53b2118");const te=ee.exports,se={name:"DesignView",components:{DesignSidebar:J,DesignPreview:Y,DesignEditor:te},data(){return{rightTab:"preview",designBasePath:".txcode/design",fileContent:"",activeFileName:"",activeFilePath:"",relativePath:"",hasChanges:!1,isResizing:!1,aiStatus:"idle"}},mounted(){document.addEventListener("mousemove",this.handleResize),document.addEventListener("mouseup",this.stopResize),this.updateTitle()},watch:{rightTab(s){console.log("[DesignView] rightTab changed:",s),s==="editor"&&this.activeFilePath&&!this.fileContent&&(console.log("[DesignView] switching to editor, loading file content for:",this.activeFilePath),this.loadFileContent()),s==="editor"&&this.$nextTick(()=>{this.$refs.editor&&this.$refs.editor.layout()})},aiStatus(){this.updateTitle()}},beforeDestroy(){document.removeEventListener("mousemove",this.handleResize),document.removeEventListener("mouseup",this.stopResize)},methods:{updateTitle(){var t;const s=((t=this.$route.meta)==null?void 0:t.title)||"AI设计";let e="";this.aiStatus==="processing"?e="⏳ ":this.aiStatus==="completed"&&(e="✅ "),document.title=`${e}${s} - TXCode`},onAiStatusChange(s){this.aiStatus=s,this.updateTitle()},async openFile(s){if(console.log("[DesignView] openFile called, node:",s.name,"path:",s.path,"is_dir:",s.is_directory),s.is_directory)return;this.activeFileName=s.name,this.activeFilePath=s.path;const e=this.extractRelativePath(s.path);console.log("[DesignView] extractRelativePath result:",e),this.relativePath=e,this.fileContent="",this.hasChanges=!1,this.rightTab="preview",console.log("[DesignView] openFile done, relativePath:",this.relativePath,"fileContent deferred to editor tab")},async loadFileContent(){var s;if(this.activeFilePath){console.log("[DesignView] loadFileContent:",this.activeFilePath);try{const e=performance.now(),t=await r.getFileContent(this.activeFilePath);console.log("[DesignView] getFileContent took:",(performance.now()-e).toFixed(1),"ms"),this.fileContent=((s=t.data)==null?void 0:s.content)||""}catch(e){console.error("[DesignView] loadFileContent failed:",e),this.fileContent=""}}},onContentChanged(s){this.hasChanges=s},onContentSaved(s){this.fileContent=s,this.hasChanges=!1},async refreshCurrentFile(){this.activeFilePath&&(console.log("[DesignView] refreshCurrentFile:",this.activeFilePath),await this.loadFileContent(),this.$refs.editor&&this.$refs.editor.updateContent(this.fileContent))},extractRelativePath(s){const e=["/.txcode/design/",".txcode/design/","\\.txcode\\design\\",".txcode\\design\\"];for(const t of e){const i=s.indexOf(t);if(i!==-1)return s.slice(i+t.length).replace(/\\/g,"/")}return""},startResize(s){this.isResizing=!0,document.body.style.cursor="col-resize",document.body.style.userSelect="none"},handleResize(s){if(!this.isResizing)return;const e=this.$refs.sidebar;if(!e)return;const t=s.clientX;t>=150&&t<=800&&(e.$el.style.width=t+"px")},stopResize(){this.isResizing=!1,document.body.style.cursor="",document.body.style.userSelect=""}}};var ie=function(){var e=this,t=e._self._c;return t("div",{staticClass:"flex-1 flex overflow-hidden"},[t("DesignSidebar",{ref:"sidebar",attrs:{"base-path":e.designBasePath},on:{"open-file":e.openFile,"file-changed":e.refreshCurrentFile,"ai-status-change":e.onAiStatusChange}}),t("div",{staticClass:"w-1 bg-border hover:bg-accent cursor-col-resize transition-colors",on:{mousedown:e.startResize}}),t("main",{staticClass:"flex-1 flex flex-col min-w-0 bg-[#1e1e1e]"},[t("div",{staticClass:"flex border-b border-border bg-sidebar"},[t("div",{staticClass:"flex items-center"},[t("div",{staticClass:"px-4 py-2 cursor-pointer border-r border-border text-sm",class:e.rightTab==="preview"?"bg-[#1e1e1e] text-white border-t-2 border-t-accent":"text-textMuted hover:bg-[#2a2a2a]",on:{click:function(i){e.rightTab="preview"}}},[t("i",{staticClass:"fa-solid fa-eye mr-1"}),e._v(" 预览 ")]),t("div",{staticClass:"px-4 py-2 cursor-pointer border-r border-border text-sm",class:e.rightTab==="editor"?"bg-[#1e1e1e] text-white border-t-2 border-t-accent":"text-textMuted hover:bg-[#2a2a2a]",on:{click:function(i){e.rightTab="editor"}}},[t("i",{staticClass:"fa-solid fa-code mr-1"}),e._v(" 编辑 ")])])]),t("div",{staticClass:"flex-1 overflow-hidden"},[t("DesignPreview",{directives:[{name:"show",rawName:"v-show",value:e.rightTab==="preview",expression:"rightTab === 'preview'"}],attrs:{"file-content":e.fileContent,"file-name":e.activeFileName,"relative-path":e.relativePath}}),t("DesignEditor",{directives:[{name:"show",rawName:"v-show",value:e.rightTab==="editor",expression:"rightTab === 'editor'"}],ref:"editor",attrs:{"file-content":e.fileContent,"file-name":e.activeFileName,"file-path":e.activeFilePath},on:{"content-changed":e.onContentChanged,"content-saved":e.onContentSaved,refresh:e.refreshCurrentFile}})],1),t("div",{staticClass:"h-8 bg-sidebar border-t border-border flex items-center justify-between px-3"},[t("div",{staticClass:"flex items-center gap-4 text-xs text-textMuted"},[e.activeFilePath?t("span",[e._v(e._s(e.activeFilePath))]):t("span",{staticClass:"text-textMuted"},[e._v("双击左侧文件打开")]),e.hasChanges?t("span",{staticClass:"text-yellow-500"},[e._v("已修改")]):e._e()]),t("div",{staticClass:"flex items-center gap-2"},[t("button",{staticClass:"p-1 text-textMuted hover:text-white text-xs",attrs:{title:"刷新"},on:{click:e.refreshCurrentFile}},[t("i",{staticClass:"fa-solid fa-refresh"})])])])])],1)},ae=[],ne=l(se,ie,ae,!1,null,null);const le=ne.exports;export{le as default};
|