tianxincode 1.0.49 → 1.0.51

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (180) hide show
  1. package/dist/config/tx.config.d.ts.map +1 -1
  2. package/dist/config/tx.config.js +3 -1
  3. package/dist/config/tx.config.js.map +1 -1
  4. package/dist/core/db/db.service.d.ts +2 -0
  5. package/dist/core/db/db.service.d.ts.map +1 -1
  6. package/dist/core/db/db.service.js +11 -0
  7. package/dist/core/db/db.service.js.map +1 -1
  8. package/dist/core/db/init_sql/system.init.d.ts +3 -0
  9. package/dist/core/db/init_sql/system.init.d.ts.map +1 -0
  10. package/dist/core/db/init_sql/system.init.js +15 -0
  11. package/dist/core/db/init_sql/system.init.js.map +1 -0
  12. package/dist/entity/tx-config.entity.d.ts +1 -0
  13. package/dist/entity/tx-config.entity.d.ts.map +1 -1
  14. package/dist/gateway/api/file/download_file.js +1 -1
  15. package/dist/gateway/api/file/download_file.js.map +1 -1
  16. package/dist/gateway/api/skill/categories_skill.d.ts +3 -0
  17. package/dist/gateway/api/skill/categories_skill.d.ts.map +1 -0
  18. package/dist/gateway/api/skill/categories_skill.js +11 -0
  19. package/dist/gateway/api/skill/categories_skill.js.map +1 -0
  20. package/dist/gateway/api/skill/detail_skill.js +2 -2
  21. package/dist/gateway/api/skill/detail_skill.js.map +1 -1
  22. package/dist/gateway/api/skill/install_skill.d.ts +3 -0
  23. package/dist/gateway/api/skill/install_skill.d.ts.map +1 -0
  24. package/dist/gateway/api/skill/install_skill.js +26 -0
  25. package/dist/gateway/api/skill/install_skill.js.map +1 -0
  26. package/dist/gateway/api/skill/published_skill.d.ts +3 -0
  27. package/dist/gateway/api/skill/published_skill.d.ts.map +1 -0
  28. package/dist/gateway/api/skill/published_skill.js +15 -0
  29. package/dist/gateway/api/skill/published_skill.js.map +1 -0
  30. package/dist/gateway/api/skill/skill_routes.d.ts.map +1 -1
  31. package/dist/gateway/api/skill/skill_routes.js +8 -12
  32. package/dist/gateway/api/skill/skill_routes.js.map +1 -1
  33. package/dist/gateway/api/skill/uninstall_skill.d.ts +3 -0
  34. package/dist/gateway/api/skill/uninstall_skill.d.ts.map +1 -0
  35. package/dist/gateway/api/skill/uninstall_skill.js +20 -0
  36. package/dist/gateway/api/skill/uninstall_skill.js.map +1 -0
  37. package/dist/gateway/api/songbing/auth_cancel_songbing.d.ts +3 -0
  38. package/dist/gateway/api/songbing/auth_cancel_songbing.d.ts.map +1 -0
  39. package/dist/gateway/api/songbing/auth_cancel_songbing.js +11 -0
  40. package/dist/gateway/api/songbing/auth_cancel_songbing.js.map +1 -0
  41. package/dist/gateway/api/songbing/auth_start_songbing.d.ts +3 -0
  42. package/dist/gateway/api/songbing/auth_start_songbing.d.ts.map +1 -0
  43. package/dist/gateway/api/songbing/auth_start_songbing.js +15 -0
  44. package/dist/gateway/api/songbing/auth_start_songbing.js.map +1 -0
  45. package/dist/gateway/api/songbing/auth_verify_songbing.d.ts +3 -0
  46. package/dist/gateway/api/songbing/auth_verify_songbing.d.ts.map +1 -0
  47. package/dist/gateway/api/songbing/auth_verify_songbing.js +15 -0
  48. package/dist/gateway/api/songbing/auth_verify_songbing.js.map +1 -0
  49. package/dist/gateway/api/songbing/config_songbing.d.ts +3 -0
  50. package/dist/gateway/api/songbing/config_songbing.d.ts.map +1 -0
  51. package/dist/gateway/api/songbing/config_songbing.js +6 -0
  52. package/dist/gateway/api/songbing/config_songbing.js.map +1 -0
  53. package/dist/gateway/api/songbing/save_config_songbing.d.ts +3 -0
  54. package/dist/gateway/api/songbing/save_config_songbing.d.ts.map +1 -0
  55. package/dist/gateway/api/songbing/save_config_songbing.js +12 -0
  56. package/dist/gateway/api/songbing/save_config_songbing.js.map +1 -0
  57. package/dist/gateway/api/songbing/songbing_routes.d.ts +3 -0
  58. package/dist/gateway/api/songbing/songbing_routes.d.ts.map +1 -0
  59. package/dist/gateway/api/songbing/songbing_routes.js +15 -0
  60. package/dist/gateway/api/songbing/songbing_routes.js.map +1 -0
  61. package/dist/gateway/api/songbing/sync_models_songbing.d.ts +3 -0
  62. package/dist/gateway/api/songbing/sync_models_songbing.d.ts.map +1 -0
  63. package/dist/gateway/api/songbing/sync_models_songbing.js +11 -0
  64. package/dist/gateway/api/songbing/sync_models_songbing.js.map +1 -0
  65. package/dist/gateway/api/spec/categories_spec.d.ts +3 -0
  66. package/dist/gateway/api/spec/categories_spec.d.ts.map +1 -0
  67. package/dist/gateway/api/spec/categories_spec.js +11 -0
  68. package/dist/gateway/api/spec/categories_spec.js.map +1 -0
  69. package/dist/gateway/api/spec/install_spec.d.ts +3 -0
  70. package/dist/gateway/api/spec/install_spec.d.ts.map +1 -0
  71. package/dist/gateway/api/spec/install_spec.js +26 -0
  72. package/dist/gateway/api/spec/install_spec.js.map +1 -0
  73. package/dist/gateway/api/spec/published_spec.d.ts +3 -0
  74. package/dist/gateway/api/spec/published_spec.d.ts.map +1 -0
  75. package/dist/gateway/api/spec/published_spec.js +18 -0
  76. package/dist/gateway/api/spec/published_spec.js.map +1 -0
  77. package/dist/gateway/api/spec/spec_routes.d.ts.map +1 -1
  78. package/dist/gateway/api/spec/spec_routes.js +9 -19
  79. package/dist/gateway/api/spec/spec_routes.js.map +1 -1
  80. package/dist/gateway/api/spec/uninstall_spec.d.ts +3 -0
  81. package/dist/gateway/api/spec/uninstall_spec.d.ts.map +1 -0
  82. package/dist/gateway/api/spec/uninstall_spec.js +20 -0
  83. package/dist/gateway/api/spec/uninstall_spec.js.map +1 -0
  84. package/dist/gateway/api/system/system_routes.d.ts.map +1 -1
  85. package/dist/gateway/api/system/system_routes.js +2 -0
  86. package/dist/gateway/api/system/system_routes.js.map +1 -1
  87. package/dist/gateway/api/system/version_check.d.ts +3 -0
  88. package/dist/gateway/api/system/version_check.d.ts.map +1 -0
  89. package/dist/gateway/api/system/version_check.js +47 -0
  90. package/dist/gateway/api/system/version_check.js.map +1 -0
  91. package/dist/index.js +2 -0
  92. package/dist/index.js.map +1 -1
  93. package/dist/modules/spec/index.d.ts +0 -1
  94. package/dist/modules/spec/index.d.ts.map +1 -1
  95. package/dist/modules/spec/index.js +0 -1
  96. package/dist/modules/spec/index.js.map +1 -1
  97. package/dist/modules/spec/spec.injector.d.ts.map +1 -1
  98. package/dist/modules/spec/spec.injector.js +2 -24
  99. package/dist/modules/spec/spec.injector.js.map +1 -1
  100. package/dist/queue/dream/dream.service.d.ts.map +1 -1
  101. package/dist/queue/dream/dream.service.js +8 -0
  102. package/dist/queue/dream/dream.service.js.map +1 -1
  103. package/dist/queue/dream/handlers/clear-session.handler.d.ts +6 -0
  104. package/dist/queue/dream/handlers/clear-session.handler.d.ts.map +1 -0
  105. package/dist/queue/dream/handlers/clear-session.handler.js +50 -0
  106. package/dist/queue/dream/handlers/clear-session.handler.js.map +1 -0
  107. package/dist/queue/dream/handlers/init.handler.d.ts.map +1 -1
  108. package/dist/queue/dream/handlers/init.handler.js +4 -2
  109. package/dist/queue/dream/handlers/init.handler.js.map +1 -1
  110. package/dist/repository/index.d.ts +2 -0
  111. package/dist/repository/index.d.ts.map +1 -1
  112. package/dist/repository/index.js +1 -0
  113. package/dist/repository/index.js.map +1 -1
  114. package/dist/repository/message.repository.d.ts +2 -0
  115. package/dist/repository/message.repository.d.ts.map +1 -1
  116. package/dist/repository/message.repository.js +8 -0
  117. package/dist/repository/message.repository.js.map +1 -1
  118. package/dist/repository/system.repository.d.ts +18 -0
  119. package/dist/repository/system.repository.d.ts.map +1 -0
  120. package/dist/repository/system.repository.js +14 -0
  121. package/dist/repository/system.repository.js.map +1 -0
  122. package/dist/services/hub/txcode_hub.service.d.ts +98 -0
  123. package/dist/services/hub/txcode_hub.service.d.ts.map +1 -0
  124. package/dist/services/hub/txcode_hub.service.js +173 -0
  125. package/dist/services/hub/txcode_hub.service.js.map +1 -0
  126. package/dist/services/songbing/songbing.service.d.ts +30 -0
  127. package/dist/services/songbing/songbing.service.d.ts.map +1 -0
  128. package/dist/services/songbing/songbing.service.js +155 -0
  129. package/dist/services/songbing/songbing.service.js.map +1 -0
  130. package/dist/services/system/device-sync.service.d.ts +2 -0
  131. package/dist/services/system/device-sync.service.d.ts.map +1 -0
  132. package/dist/services/system/device-sync.service.js +51 -0
  133. package/dist/services/system/device-sync.service.js.map +1 -0
  134. package/package.json +2 -1
  135. package/web/dist/assets/{ConfirmDialog-B03GcCHQ.js → ConfirmDialog-IKK1F-1U.js} +1 -1
  136. package/web/dist/assets/PcLayout-CLW13hCk.js +1 -0
  137. package/web/dist/assets/{aiLogsView-Bt8Xg1Qx.js → aiLogsView-D6QEk_U9.js} +1 -1
  138. package/web/dist/assets/{cssMode-CBb6D87U.js → cssMode-QPobA5wX.js} +1 -1
  139. package/web/dist/assets/{customActionsView-DdjnHzwm.js → customActionsView-ClRg3U7-.js} +1 -1
  140. package/web/dist/assets/{deployView-Cj51_Job.js → deployView-DUWf2jhH.js} +1 -1
  141. package/web/dist/assets/designView-BjjT_eB5.css +1 -0
  142. package/web/dist/assets/designView-DKuJizPM.js +18 -0
  143. package/web/dist/assets/devWorkflowView-CNmKhVZJ.js +36 -0
  144. package/web/dist/assets/devWorkflowView-CiSrMRlP.css +1 -0
  145. package/web/dist/assets/{devWorkflowViewApp-DLslXEq9.js → devWorkflowViewApp-C61Ulpxv.js} +1 -1
  146. package/web/dist/assets/{fileZihao-CtZ4bUIH.js → fileZihao-BTpK560o.js} +1 -1
  147. package/web/dist/assets/{freemarker2-CX3jc3l2.js → freemarker2-DvYwU7jd.js} +1 -1
  148. package/web/dist/assets/gitChanges-5Yut6NPa.css +1 -0
  149. package/web/dist/assets/gitChanges-CRoMAiCZ.js +2 -0
  150. package/web/dist/assets/{gitChangesApp-ZI7-V8oB.js → gitChangesApp-DWWUQkP3.js} +1 -1
  151. package/web/dist/assets/{handlebars-CTaQD6FN.js → handlebars-CK4TZqgf.js} +1 -1
  152. package/web/dist/assets/{html-BruJsfYv.js → html-Dyb2cBd1.js} +1 -1
  153. package/web/dist/assets/{htmlMode-wewroXLr.js → htmlMode-BgucwytQ.js} +1 -1
  154. package/web/dist/assets/{index-C0xmVTIn.css → index-CLl7xUVM.css} +1 -1
  155. package/web/dist/assets/{index-Cn73hS12.js → index-CUBJZpK-.js} +195 -195
  156. package/web/dist/assets/{javascript-B4ku8P1-.js → javascript-C2N5q77q.js} +1 -1
  157. package/web/dist/assets/{jsonMode-BIvVuBMG.js → jsonMode-CROJscjh.js} +1 -1
  158. package/web/dist/assets/{liquid-Bo3G0Ep7.js → liquid-BbMQX3iL.js} +1 -1
  159. package/web/dist/assets/{mdx-Duv0ylZz.js → mdx-DJKFF9Ub.js} +1 -1
  160. package/web/dist/assets/{mediaChat-RT7iqqYb.js → mediaChat-DHxUlCTa.js} +1 -1
  161. package/web/dist/assets/{python-CEhCctGm.js → python-DVBiUABc.js} +1 -1
  162. package/web/dist/assets/{razor-DPK8nTD7.js → razor-BFkZw5AO.js} +1 -1
  163. package/web/dist/assets/taskView-Bg6voWmj.js +1 -0
  164. package/web/dist/assets/{terminalView-GTYtDlus.js → terminalView-DJPI44tU.js} +1 -1
  165. package/web/dist/assets/{tsMode-BZvUU1nf.js → tsMode-CQoCUTDo.js} +1 -1
  166. package/web/dist/assets/{typescript-CmEn-k1B.js → typescript-DrsQGMkk.js} +1 -1
  167. package/web/dist/assets/wikiView-B-OhVpHv.css +1 -0
  168. package/web/dist/assets/{wikiView-CRjg-cZ8.js → wikiView-DyH2kquo.js} +1 -1
  169. package/web/dist/assets/{xml-bjvdKeyy.js → xml-BtAJQIGO.js} +1 -1
  170. package/web/dist/assets/{yaml-N5RXWxJk.js → yaml-vvMVX3ro.js} +1 -1
  171. package/web/dist/index.html +2 -2
  172. package/web/dist/assets/PcLayout-ZTdJNg7G.js +0 -1
  173. package/web/dist/assets/designView-C3pSX4nP.css +0 -1
  174. package/web/dist/assets/designView-RT8tKEN9.js +0 -18
  175. package/web/dist/assets/devWorkflowView-BTozmaiN.js +0 -36
  176. package/web/dist/assets/devWorkflowView-DYhIfbCB.css +0 -1
  177. package/web/dist/assets/gitChanges-D6QxPcii.css +0 -1
  178. package/web/dist/assets/gitChanges-DFRvzL5I.js +0 -2
  179. package/web/dist/assets/taskView-sOyebRqn.js +0 -1
  180. package/web/dist/assets/wikiView-C-oqMnJM.css +0 -1
@@ -0,0 +1,51 @@
1
+ import { v4 as uuidv4 } from 'uuid';
2
+ import * as os from 'os';
3
+ import { systemRepository } from '../../repository/system.repository.js';
4
+ import { txcodeHubService } from '../hub/txcode_hub.service.js';
5
+ function getDeviceType() {
6
+ const platform = os.platform();
7
+ switch (platform) {
8
+ case 'win32':
9
+ return 'windows';
10
+ case 'darwin':
11
+ return 'mac';
12
+ case 'linux':
13
+ return 'linux';
14
+ default:
15
+ return 'linux';
16
+ }
17
+ }
18
+ function getMacAddress() {
19
+ const interfaces = os.networkInterfaces();
20
+ for (const [, addrs] of Object.entries(interfaces)) {
21
+ if (!addrs)
22
+ continue;
23
+ for (const addr of addrs) {
24
+ if (addr.internal || !addr.mac || addr.mac === '00:00:00:00:00:00')
25
+ continue;
26
+ return addr.mac.toLowerCase();
27
+ }
28
+ }
29
+ return '00:00:00:00:00:00';
30
+ }
31
+ export function syncOnStartup() {
32
+ (async () => {
33
+ try {
34
+ let info = systemRepository.getSystemInfo();
35
+ if (!info) {
36
+ const deviceId = uuidv4();
37
+ const deviceType = getDeviceType();
38
+ const macAddress = getMacAddress();
39
+ systemRepository.insertSystemInfo(deviceId, deviceType, macAddress);
40
+ info = systemRepository.getSystemInfo();
41
+ }
42
+ if (info) {
43
+ await txcodeHubService.reportUsage(info.device_id, info.device_type);
44
+ }
45
+ }
46
+ catch {
47
+ // 静默失败
48
+ }
49
+ })();
50
+ }
51
+ //# sourceMappingURL=device-sync.service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"device-sync.service.js","sourceRoot":"","sources":["../../../src/services/system/device-sync.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,IAAI,MAAM,EAAE,MAAM,MAAM,CAAC;AACpC,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AACzB,OAAO,EAAE,gBAAgB,EAAE,MAAM,uCAAuC,CAAC;AACzE,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAEhE,SAAS,aAAa;IACpB,MAAM,QAAQ,GAAG,EAAE,CAAC,QAAQ,EAAE,CAAC;IAC/B,QAAQ,QAAQ,EAAE,CAAC;QACjB,KAAK,OAAO;YACV,OAAO,SAAS,CAAC;QACnB,KAAK,QAAQ;YACX,OAAO,KAAK,CAAC;QACf,KAAK,OAAO;YACV,OAAO,OAAO,CAAC;QACjB;YACE,OAAO,OAAO,CAAC;IACnB,CAAC;AACH,CAAC;AAED,SAAS,aAAa;IACpB,MAAM,UAAU,GAAG,EAAE,CAAC,iBAAiB,EAAE,CAAC;IAC1C,KAAK,MAAM,CAAC,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE,CAAC;QACnD,IAAI,CAAC,KAAK;YAAE,SAAS;QACrB,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;YACzB,IAAI,IAAI,CAAC,QAAQ,IAAI,CAAC,IAAI,CAAC,GAAG,IAAI,IAAI,CAAC,GAAG,KAAK,mBAAmB;gBAAE,SAAS;YAC7E,OAAO,IAAI,CAAC,GAAG,CAAC,WAAW,EAAE,CAAC;QAChC,CAAC;IACH,CAAC;IACD,OAAO,mBAAmB,CAAC;AAC7B,CAAC;AAED,MAAM,UAAU,aAAa;IAC3B,CAAC,KAAK,IAAI,EAAE;QACV,IAAI,CAAC;YACH,IAAI,IAAI,GAAG,gBAAgB,CAAC,aAAa,EAAE,CAAC;YAE5C,IAAI,CAAC,IAAI,EAAE,CAAC;gBACV,MAAM,QAAQ,GAAG,MAAM,EAAE,CAAC;gBAC1B,MAAM,UAAU,GAAG,aAAa,EAAE,CAAC;gBACnC,MAAM,UAAU,GAAG,aAAa,EAAE,CAAC;gBACnC,gBAAgB,CAAC,gBAAgB,CAAC,QAAQ,EAAE,UAAU,EAAE,UAAU,CAAC,CAAC;gBACpE,IAAI,GAAG,gBAAgB,CAAC,aAAa,EAAE,CAAC;YAC1C,CAAC;YAED,IAAI,IAAI,EAAE,CAAC;gBACT,MAAM,gBAAgB,CAAC,WAAW,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC;YACvE,CAAC;QACH,CAAC;QAAC,MAAM,CAAC;YACP,OAAO;QACT,CAAC;IACH,CAAC,CAAC,EAAE,CAAC;AACP,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tianxincode",
3
- "version": "1.0.49",
3
+ "version": "1.0.51",
4
4
  "type": "module",
5
5
  "description": "AI Coding Assistant",
6
6
  "main": "dist/index.js",
@@ -31,6 +31,7 @@
31
31
  "@lydell/node-pty": "^1.0.0",
32
32
  "@types/diff": "^7.0.2",
33
33
  "@types/nodemailer": "^7.0.11",
34
+ "adm-zip": "^0.5.18",
34
35
  "cors": "^2.8.6",
35
36
  "diff": "^7.0.0",
36
37
  "dingtalk-stream-sdk-nodejs": "^2.0.4",
@@ -1 +1 @@
1
- import{n}from"./index-Cn73hS12.js";const r={name:"ConfirmDialog",props:{visible:{type:Boolean,default:!1},message:{type:String,default:""}}};var i=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"},[t("div",{staticClass:"bg-sidebar border border-border rounded p-4 w-96"},[t("p",{staticClass:"text-gray-200 text-sm mb-4"},[e._v(e._s(e.message))]),t("div",{staticClass:"flex justify-end gap-2"},[t("button",{staticClass:"px-3 py-1 text-xs text-gray-400 hover:text-white",on:{click:function(s){return e.$emit("cancel")}}},[e._v("取消")]),t("button",{staticClass:"px-3 py-1 text-xs bg-red-600 text-white rounded hover:bg-red-700",on:{click:function(s){return e.$emit("confirm")}}},[e._v("确定")])])])]):e._e()},a=[],o=n(r,i,a,!1,null,null);const d=o.exports;export{d as C};
1
+ import{n}from"./index-CUBJZpK-.js";const r={name:"ConfirmDialog",props:{visible:{type:Boolean,default:!1},message:{type:String,default:""}}};var i=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"},[t("div",{staticClass:"bg-sidebar border border-border rounded p-4 w-96"},[t("p",{staticClass:"text-gray-200 text-sm mb-4"},[e._v(e._s(e.message))]),t("div",{staticClass:"flex justify-end gap-2"},[t("button",{staticClass:"px-3 py-1 text-xs text-gray-400 hover:text-white",on:{click:function(s){return e.$emit("cancel")}}},[e._v("取消")]),t("button",{staticClass:"px-3 py-1 text-xs bg-red-600 text-white rounded hover:bg-red-700",on:{click:function(s){return e.$emit("confirm")}}},[e._v("确定")])])])]):e._e()},a=[],o=n(r,i,a,!1,null,null);const d=o.exports;export{d as C};
@@ -0,0 +1 @@
1
+ import{n,a as i}from"./index-CUBJZpK-.js";const f={name:"SelectProjectDialog",props:{visible:{type:Boolean,default:!1}},data(){return{dialogVisible:!1,drives:[],currentPath:"",parentPath:null,items:[],selectedPath:"",projectName:"",loading:!1}},watch:{visible(s){this.dialogVisible=s,s&&this.loadDrives()},dialogVisible(s){this.$emit("update:visible",s)}},methods:{async loadDrives(){console.log("[SelectProjectDialog] loading drives...");try{const s=await i.getDrives();if(console.log("[SelectProjectDialog] drives response:",s),this.drives=s.data.items||[],console.log("[SelectProjectDialog] drives:",this.drives),this.drives.length>0){const e=this.drives[0];console.log("[SelectProjectDialog] firstDrive:",e),await this.browse(e.path||"/")}else await this.browse("/")}catch(s){console.error("加载盘符失败:",s),this.$message.error("加载盘符失败: "+s.message)}},async browse(s){try{const t=(await i.browseFilesystem(s)).data;this.currentPath=t.current_path,this.parentPath=t.parent_path,this.items=t.items||[]}catch(e){console.error("浏览目录失败:",e),this.$message.error("浏览目录失败: "+e.message)}},async selectDrive(s){await this.browse(s)},selectItem(s){if(s.is_directory){this.selectedPath=s.path;const e=s.path.replace(/\\/g,"/").split("/");this.projectName=e.filter(t=>t).pop()||""}},async enterFolder(s){s.is_directory&&await this.browse(s.path)},async goToParent(){this.parentPath&&await this.browse(this.parentPath)},handleClose(){this.dialogVisible=!1,this.resetState()},resetState(){this.selectedPath="",this.projectName="",this.items=[],this.currentPath="",this.parentPath=null},async handleConfirm(){var s;if(!(!this.selectedPath||!this.projectName)){this.loading=!0;try{const e=await i.createProject(this.projectName,this.selectedPath,""),t=(s=e.data)==null?void 0:s.id;t&&(await i.setCurrentProject(t),this.$message.success("项目创建并切换成功"),this.$emit("success",e.data),this.handleClose())}catch(e){console.error("创建项目失败:",e),this.$message.error("创建项目失败: "+e.message)}finally{this.loading=!1}}}}};var p=function(){var e=this,t=e._self._c;return t("el-dialog",{attrs:{title:"选择项目文件夹",visible:e.dialogVisible,width:"600px","close-on-click-modal":!1,"append-to-body":""},on:{"update:visible":function(a){e.dialogVisible=a},close:e.handleClose}},[t("div",{staticClass:"select-project-dialog"},[e.drives.length>0?t("div",{staticClass:"drive-nav"},e._l(e.drives,function(a){return t("el-button",{key:a.path,attrs:{size:"mini",type:e.currentPath.startsWith(a.path)?"primary":""},on:{click:function(r){return e.selectDrive(a.path)}}},[e._v(" "+e._s(a.name)+" ")])}),1):e._e(),t("div",{staticClass:"file-list-container"},[t("div",{staticClass:"current-path"},[t("span",{staticClass:"path-label"},[e._v("当前路径:")]),t("span",{staticClass:"path-value"},[e._v(e._s(e.currentPath))])]),e.items.length>0?t("div",{staticClass:"file-list"},[e.parentPath?t("div",{staticClass:"file-item parent",on:{click:e.goToParent}},[t("i",{staticClass:"fa-solid fa-arrow-up"}),t("span",[e._v("上一级")])]):e._e(),e._l(e.items.filter(a=>a.is_directory),function(a){return t("div",{key:a.path,staticClass:"file-item",class:{selected:e.selectedPath===a.path},on:{click:function(r){return e.selectItem(a)},dblclick:function(r){return e.enterFolder(a)}}},[t("i",{staticClass:"fa-solid fa-folder"}),t("span",{staticClass:"file-name"},[e._v(e._s(a.name))])])})],2):t("div",{staticClass:"empty-tip"},[t("span",[e._v("该目录为空")])])]),t("div",{staticClass:"底部状态栏"},[t("div",{staticClass:"selected-info"},[t("span",[e._v("已选择: "+e._s(e.selectedPath||"未选择"))])]),t("div",{staticClass:"project-name-input"},[t("span",[e._v("项目名称:")]),t("el-input",{staticStyle:{width:"200px"},attrs:{placeholder:"请输入项目名称",size:"small"},model:{value:e.projectName,callback:function(a){e.projectName=a},expression:"projectName"}})],1)])]),t("span",{staticClass:"dialog-footer",attrs:{slot:"footer"},slot:"footer"},[t("el-button",{on:{click:e.handleClose}},[e._v("取 消")]),t("el-button",{attrs:{type:"primary",disabled:!e.selectedPath||!e.projectName,loading:e.loading},on:{click:e.handleConfirm}},[e._v(" 确 定 ")])],1)])},u=[],v=n(f,p,u,!1,null,"e90f8022");const b=v.exports,m={name:"VersionUpgradeDialog",props:{visible:{type:Boolean,default:!1},localVersion:{type:String,default:""},latestInfo:{type:Object,default:null}},computed:{latestVersion(){return this.latestInfo&&this.latestInfo.version?this.latestInfo.version.replace(/^v/i,""):""}}};var x=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"},[t("div",{staticClass:"bg-sidebar border border-border rounded p-6 w-96"},[t("h3",{staticClass:"text-white text-base font-bold mb-4"},[e._v("发现新版本")]),t("div",{staticClass:"text-sm text-gray-300 space-y-2 mb-4"},[t("div",[t("span",{staticClass:"text-textMuted"},[e._v("当前版本:")]),t("span",[e._v("v"+e._s(e.localVersion))])]),t("div",[t("span",{staticClass:"text-textMuted"},[e._v("最新版本:")]),t("span",{staticClass:"text-green-400 font-bold"},[e._v("v"+e._s(e.latestVersion))])]),e.latestInfo?t("div",[t("span",{staticClass:"text-textMuted"},[e._v("版本类型:")]),t("span",[e._v(e._s(e.latestInfo.version_type))])]):e._e(),e.latestInfo&&e.latestInfo.release_date?t("div",[t("span",{staticClass:"text-textMuted"},[e._v("发布日期:")]),t("span",[e._v(e._s(e.latestInfo.release_date))])]):e._e(),e.latestInfo&&e.latestInfo.description?t("div",[t("span",{staticClass:"text-textMuted"},[e._v("更新说明:")]),t("span",[e._v(e._s(e.latestInfo.description))])]):e._e(),e._m(0)]),t("div",{staticClass:"flex justify-end"},[t("button",{staticClass:"px-4 py-1 text-xs bg-accent text-white rounded hover:bg-accent/80",on:{click:function(a){return e.$emit("close")}}},[e._v("知道了")])])])]):e._e()},g=[function(){var s=this,e=s._self._c;return e("div",{staticClass:"mt-3"},[e("span",{staticClass:"text-textMuted"},[s._v("升级方式:")]),e("div",{staticClass:"bg-gray-800 border border-border rounded px-3 py-2 mt-1 font-mono text-green-400 text-xs select-all"},[s._v(" npm install -g tianxincode ")])])}],_=n(m,x,g,!1,null,null);const w=_.exports,d=[{id:"default-dark",name:"默认暗色",desc:"经典蓝 · VS Code 风格",colors:{accent:"#409EFF",sidebar:"#2d2d2d",activityBar:"#333333",active:"rgba(64,158,255,0.125)",border:"#404040",textMain:"#cccccc",textMuted:"#858585",primary:"#409EFF",panel:"#0a0a09",panelHeader:"#121212",inputBg:"#18191b",contentBg:"#1e1e1e",hoverBg:"#2a2a2a"}},{id:"emerald-dark",name:"翡翠暗绿",desc:"护眼绿 · 长时间编码",colors:{accent:"#27ae60",sidebar:"#1a2420",activityBar:"#121a16",active:"rgba(39,174,96,0.125)",border:"#2d3d33",textMain:"#c8d6ce",textMuted:"#7d9a85",primary:"#27ae60",panel:"#080e0b",panelHeader:"#0f1613",inputBg:"#151b17",contentBg:"#1a221d",hoverBg:"#242e28"}},{id:"sunset-dark",name:"日落暖橙",desc:"温暖活力 · 创意编码",colors:{accent:"#e67e22",sidebar:"#2a2520",activityBar:"#1e1a16",active:"rgba(230,126,34,0.125)",border:"#4a3d30",textMain:"#d4cec3",textMuted:"#9a8c78",primary:"#e67e22",panel:"#0e0a06",panelHeader:"#15110c",inputBg:"#1b1712",contentBg:"#211c17",hoverBg:"#2d2823"}},{id:"lavender-dark",name:"薰衣草紫",desc:"优雅紫调 · 设计感",colors:{accent:"#8e44ad",sidebar:"#241f2a",activityBar:"#19151f",active:"rgba(142,68,173,0.125)",border:"#3d3350",textMain:"#cfc7db",textMuted:"#8a7ea0",primary:"#8e44ad",panel:"#0c0810",panelHeader:"#130f17",inputBg:"#19151d",contentBg:"#1f1b23",hoverBg:"#2b2730"}},{id:"ocean-dark",name:"深海蓝调",desc:"沉稳深邃 · 专注模式",colors:{accent:"#2980b9",sidebar:"#1a2632",activityBar:"#111820",active:"rgba(41,128,185,0.125)",border:"#2d3f52",textMain:"#c4d0db",textMuted:"#6d8299",primary:"#2980b9",panel:"#080e14",panelHeader:"#0f151b",inputBg:"#151b21",contentBg:"#1b2128",hoverBg:"#272e35"}},{id:"forest-dark",name:"森林深色",desc:"自然舒适 · 低对比度",colors:{accent:"#4a8c5c",sidebar:"#1c221e",activityBar:"#131815",active:"rgba(74,140,92,0.125)",border:"#314035",textMain:"#c2cdc5",textMuted:"#6b8a73",primary:"#4a8c5c",panel:"#080d0a",panelHeader:"#0f1410",inputBg:"#151a16",contentBg:"#1b201c",hoverBg:"#262b27"}},{id:"monokai",name:"Monokai",desc:"经典黄绿 · Sublime 风",colors:{accent:"#a6e22e",sidebar:"#272822",activityBar:"#1e1f1a",active:"rgba(166,226,46,0.125)",border:"#49483e",textMain:"#f8f8f2",textMuted:"#75715e",primary:"#a6e22e",panel:"#0d0e09",panelHeader:"#14150f",inputBg:"#1a1b15",contentBg:"#20211b",hoverBg:"#2c2d27"}}],h="txcode-theme";function y(s){const e=parseInt(s.slice(1,3),16),t=parseInt(s.slice(3,5),16),a=parseInt(s.slice(5,7),16);return`rgba(${e},${t},${a},0.125)`}function l(s){const e=d.find(r=>r.id===s);if(!e)return;const t=document.documentElement;document.body.classList.add("transition-theme"),setTimeout(()=>document.body.classList.remove("transition-theme"),400),Object.entries({accent:"--color-accent",sidebar:"--color-sidebar",activityBar:"--color-activityBar",active:"--color-active",border:"--color-border",textMain:"--color-textMain",textMuted:"--color-textMuted",primary:"--color-primary",panel:"--color-panel",panelHeader:"--color-panelHeader",inputBg:"--color-inputBg",contentBg:"--color-contentBg",hoverBg:"--color-hoverBg"}).forEach(([r,o])=>{const c=e.colors[r];c&&t.style.setProperty(o,c)}),e.colors.active||t.style.setProperty("--color-active",y(e.colors.accent))}function C(){try{const s=localStorage.getItem(h);if(s){const e=JSON.parse(s);return e.preset||e}}catch{}return null}function k(s){localStorage.setItem(h,JSON.stringify({preset:s}))}const j={name:"ThemeSelector",data(){return{activeTheme:C()||"default-dark",themes:d}},computed:{currentThemeName(){const s=this.themes.find(e=>e.id===this.activeTheme);return s?s.name:"默认暗色"}},methods:{handleSelect(s){this.activeTheme=s,l(s),k(s)}},mounted(){l(this.activeTheme)}};var S=function(){var e=this,t=e._self._c;return t("el-dropdown",{attrs:{trigger:"click"},on:{command:e.handleSelect}},[t("span",{staticClass:"text-xs text-textMuted cursor-pointer hover:text-white"},[t("i",{staticClass:"fa-solid fa-palette mr-1 text-accent"}),e._v(" "+e._s(e.currentThemeName)+" "),t("i",{staticClass:"el-icon-arrow-down el-icon--right"})]),t("el-dropdown-menu",{attrs:{slot:"dropdown"},slot:"dropdown"},e._l(e.themes,function(a){return t("el-dropdown-item",{key:a.id,class:{"text-accent":a.id===e.activeTheme},attrs:{command:a.id}},[t("span",{staticClass:"inline-block w-3 h-3 rounded mr-2",style:{background:a.colors.accent}}),e._v(" "+e._s(a.name)+" ")])}),1)],1)},P=[],$=n(j,S,P,!1,null,null);const V=$.exports,M={name:"Layout",components:{SelectProjectDialog:b,VersionUpgradeDialog:w,ThemeSelector:V},data(){return{sidebarVisible:!0,showSessionDropdown:!1,sessions:[],currentSessionId:null,currentSessionName:"",projects:[],currentProject:null,selectProjectDialogVisible:!1,systemVersion:"",hasNewVersion:!1,latestVersionInfo:null,showUpgradeDialog:!1}},methods:{toggleSidebar(){this.sidebarVisible=!this.sidebarVisible},toggleSessionDropdown(){this.showSessionDropdown=!this.showSessionDropdown},async switchSession(s){this.currentSessionId=s.id,this.currentSessionName=s.title,this.showSessionDropdown=!1,this.$route.params.id!==s.id&&this.$router.push({name:"chat-session",params:{id:s.id}}).catch(()=>{})},async createNewSession(){try{const s=await i.createSession("新会话");this.sessions.unshift(s.data),this.switchSession(s.data),this.showSessionDropdown=!1}catch(s){this.$message.error("创建会话失败: "+s.message)}},async loadSessions(){try{const s=await i.getSessions();this.sessions=s.data||[],this.sessions.length>0&&!this.currentSessionId&&(this.currentSessionId=this.sessions[0].id,this.currentSessionName=this.sessions[0].title)}catch(s){console.error("加载会话失败:",s)}},async loadProjects(){try{const s=await i.getProjects();this.projects=s.data||[];const e=await i.getCurrentProject();this.currentProject=e.data||null}catch(s){console.error("加载项目失败:",s)}},async handleProjectChange(s){if(s==="__open__"){const e=this.$el.querySelector(".el-dropdown");e&&e.click(),this.selectProjectDialogVisible=!0;return}try{await i.setCurrentProject(s);const e=this.projects.find(t=>t.id===s);e&&(this.currentProject=e),location.reload()}catch(e){this.$message.error("切换项目失败: "+e.message)}},handleProjectDialogSuccess(s){this.currentProject=s,this.loadProjects().then(()=>{location.reload()})},async loadSystemVersion(){var s;try{const e=await i.getSystemInfo();this.systemVersion=((s=e.data)==null?void 0:s.version)||""}catch(e){console.error("获取版本号失败:",e)}},async checkVersion(){try{const e=(await i.checkVersion()).data||{};e.hasUpdate&&(this.hasNewVersion=!0,this.latestVersionInfo=e.latestInfo)}catch(s){console.error("版本检查失败:",s)}}},async created(){await this.loadProjects(),await this.loadSessions(),this.loadSystemVersion(),this.checkVersion(),document.addEventListener("click",s=>{this.$el.contains(s.target)||(this.showSessionDropdown=!1)})}};var B=function(){var a;var e=this,t=e._self._c;return t("div",{staticClass:"flex flex-col h-screen overflow-hidden"},[t("header",{staticClass:"h-10 bg-sidebar border-b border-black flex items-center justify-between px-4 shrink-0 z-20"},[t("div",{staticClass:"flex items-center gap-4"},[e._m(0),t("div",{staticClass:"relative"},[t("a",{staticClass:"hover:text-white px-3 py-1 rounded border border-transparent hover:border-accent transition-colors cursor-pointer",class:e.$route.name==="devWorkflow"?"text-accent border-accent":"text-gray-400",attrs:{href:"/#/views/pc/devWorkflow",target:"_blank"}},[t("i",{staticClass:"fa-solid fa-laptop-code mr-1"}),e._v(" 软件研发 ")])]),t("div",{staticClass:"relative"},[t("a",{staticClass:"hover:text-white px-3 py-1 rounded border border-transparent hover:border-accent transition-colors cursor-pointer",class:e.$route.name==="designView"?"text-accent border-accent":"text-gray-400",attrs:{href:"/#/views/pc/designView",target:"_blank"}},[t("i",{staticClass:"fa-solid fa-pen-ruler mr-1"}),e._v(" 软件设计 ")])]),t("div",{staticClass:"relative"},[t("router-link",{staticClass:"hover:text-white px-3 py-1 rounded border border-transparent hover:border-accent transition-colors cursor-pointer",class:e.$route.name==="deploy"?"text-accent border-accent":"text-gray-400",attrs:{to:"/views/pc/deploy"}},[t("i",{staticClass:"fa-solid fa-rocket mr-1"}),e._v(" 部署 ")])],1)]),t("div",{staticClass:"flex items-center gap-3"},[t("el-dropdown",{attrs:{trigger:"click"},on:{command:e.handleProjectChange}},[t("span",{staticClass:"text-white text-sm cursor-pointer hover:text-accent"},[t("i",{staticClass:"fa-solid fa-folder mr-1"}),e._v(" "+e._s(((a=e.currentProject)==null?void 0:a.name)||"选择项目")+" "),t("i",{staticClass:"fa-solid fa-chevron-down ml-1 text-xs"})]),t("el-dropdown-menu",{attrs:{slot:"dropdown"},slot:"dropdown"},[e._l(e.projects,function(r){var o;return t("el-dropdown-item",{key:r.id,attrs:{command:r.id}},[t("span",{class:r.id===((o=e.currentProject)==null?void 0:o.id)?"text-accent":""},[e._v(e._s(r.name))])])}),t("el-dropdown-item",{attrs:{divided:"",command:"__open__"}},[t("i",{staticClass:"fa-solid fa-folder-open mr-1"}),e._v(" 打开项目文件夹 ")])],2)],1),t("SelectProjectDialog",{attrs:{visible:e.selectProjectDialogVisible},on:{"update:visible":function(r){e.selectProjectDialogVisible=r},success:e.handleProjectDialogSuccess}}),e.systemVersion?t("span",{staticClass:"text-xs text-textMuted"},[e._v("v"+e._s(e.systemVersion))]):e._e(),e.hasNewVersion?t("span",{staticClass:"text-xs text-accent cursor-pointer ml-1 hover:underline",on:{click:function(r){e.showUpgradeDialog=!0}}},[t("i",{staticClass:"fa-solid fa-circle-up"}),e._v(" 有新版本 ")]):e._e(),t("ThemeSelector"),t("button",{directives:[{name:"show",rawName:"v-show",value:e.$route.name==="chat",expression:"$route.name === 'chat'"}],staticClass:"hover:text-white",attrs:{title:e.sidebarVisible?"关闭侧栏":"显示侧栏"},on:{click:e.toggleSidebar}},[t("i",{staticClass:"fa-solid fa-columns"})])],1)]),t("div",{staticClass:"flex-1 flex overflow-hidden"},[t("nav",{staticClass:"w-12 bg-activityBar flex flex-col items-center py-2 shrink-0 border-r border-black z-10 justify-between"},[t("div",{staticClass:"flex flex-col items-center w-full"},[t("router-link",{staticClass:"w-10 h-10 mb-2 rounded flex items-center justify-center relative",class:e.$route.name==="codeView"||e.$route.name==="codeView-session"?"text-white border-l-2 border-accent bg-sidebar":"text-textMuted hover:text-white border-l-2 border-transparent",attrs:{to:"/views/pc/codeView",title:"工作台"}},[t("i",{staticClass:"fa-regular fa-comments text-xl"})]),t("router-link",{staticClass:"w-10 h-10 mb-2 rounded flex items-center justify-center",class:e.$route.name==="files"?"text-white border-l-2 border-accent bg-sidebar":"text-textMuted hover:text-white border-l-2 border-transparent",attrs:{to:"/views/pc/files",title:"文件"}},[t("i",{staticClass:"fa-solid fa-folder-open text-xl"})]),t("router-link",{staticClass:"w-10 h-10 mb-2 rounded flex items-center justify-center",class:e.$route.name==="gitChanges"?"text-white border-l-2 border-accent bg-sidebar":"text-textMuted hover:text-white border-l-2 border-transparent",attrs:{to:"/views/pc/git-changes",title:"Git 变更"}},[t("i",{staticClass:"fa-brands fa-git-alt text-xl"})]),t("router-link",{staticClass:"w-10 h-10 mb-2 rounded flex items-center justify-center",class:e.$route.name==="terminal"||e.$route.name==="terminal-session"?"text-white border-l-2 border-accent bg-sidebar":"text-textMuted hover:text-white border-l-2 border-transparent",attrs:{to:"/views/pc/terminal",title:"终端"}},[t("i",{staticClass:"fa-solid fa-terminal text-xl"})]),t("router-link",{staticClass:"w-10 h-10 mb-2 rounded flex items-center justify-center relative",class:e.$route.name==="skills"?"text-white border-l-2 border-accent bg-sidebar":"text-textMuted hover:text-white border-l-2 border-transparent",attrs:{to:"/views/pc/skills",title:"Skill 管理"}},[t("i",{staticClass:"fa-solid fa-shapes text-xl"})]),t("router-link",{staticClass:"w-10 h-10 mb-2 rounded flex items-center justify-center",class:e.$route.name==="db"?"text-white border-l-2 border-accent bg-sidebar":"text-textMuted hover:text-white border-l-2 border-transparent",attrs:{to:"/views/pc/db",title:"数据库"}},[t("i",{staticClass:"fa-solid fa-database text-xl"})]),t("router-link",{staticClass:"w-10 h-10 mb-2 rounded flex items-center justify-center",class:e.$route.name==="tasks"?"text-white border-l-2 border-accent bg-sidebar":"text-textMuted hover:text-white border-l-2 border-transparent",attrs:{to:"/views/pc/tasks",title:"任务"}},[t("i",{staticClass:"fa-solid fa-clock text-xl"})]),t("router-link",{staticClass:"w-10 h-10 mb-2 rounded flex items-center justify-center",class:e.$route.name==="aiLogs"?"text-white border-l-2 border-accent bg-sidebar":"text-textMuted hover:text-white border-l-2 border-transparent",attrs:{to:"/views/pc/aiLogs",title:"AI 日志"}},[t("i",{staticClass:"fa-solid fa-robot text-xl"})]),t("router-link",{staticClass:"w-10 h-10 mb-2 rounded flex items-center justify-center",class:e.$route.name==="wiki"?"text-white border-l-2 border-accent bg-sidebar":"text-textMuted hover:text-white border-l-2 border-transparent",attrs:{to:"/views/pc/wiki",title:"文档"}},[t("i",{staticClass:"fa-solid fa-book text-xl"})]),t("router-link",{staticClass:"w-10 h-10 mb-2 rounded flex items-center justify-center",class:e.$route.name==="fileZihao"?"text-white border-l-2 border-accent bg-sidebar":"text-textMuted hover:text-white border-l-2 border-transparent",attrs:{to:"/views/pc/fileZihao",title:"文件互联"}},[t("i",{staticClass:"fa-solid fa-server text-xl"})])],1),t("div",{staticClass:"flex flex-col items-center w-full mb-2"},[t("router-link",{staticClass:"w-10 h-10 mb-2 rounded flex items-center justify-center",class:e.$route.name==="settings"?"text-white border-l-2 border-accent bg-sidebar":"text-textMuted hover:text-white border-l-2 border-transparent hover:bg-white/5",attrs:{to:"/views/pc/settings",title:"设置"}},[t("i",{staticClass:"fa-solid fa-gear text-xl"})])],1)]),t("keep-alive",{attrs:{include:["CodeView","TerminalView","Files"]}},[t("router-view",{staticClass:"flex-1 flex overflow-hidden",attrs:{"sidebar-visible":e.sidebarVisible},on:{"toggle-sidebar":e.toggleSidebar}})],1)],1),e._m(1),t("VersionUpgradeDialog",{attrs:{visible:e.showUpgradeDialog,localVersion:e.systemVersion,latestInfo:e.latestVersionInfo},on:{close:function(r){e.showUpgradeDialog=!1}}})],1)},D=[function(){var s=this,e=s._self._c;return e("div",{staticClass:"font-bold text-white flex items-center gap-2"},[e("i",{staticClass:"fa-solid fa-robot text-accent"}),e("span",[s._v("TXCode Agent")])])},function(){var s=this,e=s._self._c;return e("footer",{staticClass:"h-6 bg-accent text-white text-xs flex items-center justify-between px-3 shrink-0 z-20"},[e("div",{staticClass:"flex items-center gap-4"},[e("span",[e("i",{staticClass:"fa-solid fa-code-branch"}),s._v(" main")])]),e("div",{staticClass:"flex items-center gap-4"},[e("span",[s._v("TXCode")]),e("span",[s._v("UTF-8")])])])}],I=n(M,B,D,!1,null,null);const N=I.exports;export{N as default};
@@ -1 +1 @@
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
+ import{n as x,a as n}from"./index-CUBJZpK-.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-contentBg"},[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-Cn73hS12.js";/*!-----------------------------------------------------------------------------
1
+ import{m as et}from"./index-CUBJZpK-.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-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};
1
+ import{n as d,a as n}from"./index-CUBJZpK-.js";const u={name:"CustomActionsView",data(){return{actions:[],currentType:"design",showDialog:!1,isEditing:!1,currentAction:null,form:{action_type:"design",name:"",prompt:"",auto_send:!1,sort_order:0},actionTypes:[{value:"design",label:"方案设计"},{value:"code",label:"代码生成"},{value:"test",label:"测试验收"}]}},computed:{filteredActions(){return this.actions.filter(s=>s.action_type===this.currentType)}},async created(){await this.loadActions();const s=this.$route.query.type;s&&["design","code","test"].includes(s)&&(this.currentType=s)},methods:{async loadActions(){try{const s=await n.getCustomActions();this.actions=s.data||[]}catch(s){console.error("Load actions failed:",s),this.$message.error("加载动作失败")}},selectType(s){this.currentType=s},getCountByType(s){return this.actions.filter(t=>t.action_type===s).length},openCreateDialog(){this.isEditing=!1,this.form={action_type:this.currentType,name:"",prompt:"",auto_send:!1,sort_order:0},this.showDialog=!0},openEditDialog(s){this.isEditing=!0,this.currentAction=s,this.form={action_type:s.action_type,name:s.name,prompt:s.prompt,auto_send:!!s.auto_send,sort_order:s.sort_order||0},this.showDialog=!0},closeDialog(){this.showDialog=!1,this.currentAction=null},async saveAction(){if(!this.form.name||!this.form.prompt){this.$message.error("请填写必填项");return}try{this.isEditing&&this.currentAction?(await n.updateCustomAction(this.currentAction.id,this.form),this.$message.success("动作已更新")):(await n.createCustomAction(this.form),this.$message.success("动作已创建")),this.closeDialog(),await this.loadActions()}catch(s){this.$message.error("保存失败: "+s.message)}},async deleteAction(s){if(confirm(`确定删除动作 "${s.name}" 吗?`))try{await n.deleteCustomAction(s.id),this.$message.success("动作已删除"),await this.loadActions()}catch(t){this.$message.error("删除失败: "+t.message)}},getTypeLabel(s){return{design:"方案设计",code:"代码生成",test:"测试验收"}[s]||s}}};var p=function(){var t=this,e=t._self._c;return e("div",{staticClass:"flex-1 flex overflow-hidden bg-[#1e1e1e]"},[e("div",{staticClass:"w-48 border-r border-border bg-sidebar shrink-0 flex flex-col"},[t._m(0),e("div",{staticClass:"flex-1 overflow-auto py-2"},t._l(t.actionTypes,function(r){return e("div",{key:r.value,staticClass:"px-4 py-2 cursor-pointer flex items-center justify-between",class:t.currentType===r.value?"bg-accent/20 text-accent":"text-textMuted hover:bg-white/5",on:{click:function(a){return t.selectType(r.value)}}},[e("span",{staticClass:"text-sm"},[t._v(t._s(r.label))]),e("span",{staticClass:"text-xs opacity-60"},[t._v("("+t._s(t.getCountByType(r.value))+")")])])}),0)]),e("div",{staticClass:"flex-1 flex flex-col overflow-hidden"},[e("div",{staticClass:"px-4 py-3 border-b border-border bg-sidebar shrink-0"},[e("div",{staticClass:"flex items-center justify-between"},[e("div",{staticClass:"flex items-center gap-2"},[e("i",{staticClass:"fa-solid fa-bolt text-accent"}),e("span",{staticClass:"text-white font-medium"},[t._v("自定义动作")]),e("span",{staticClass:"text-xs text-textMuted"},[t._v("("+t._s(t.getTypeLabel(t.currentType))+")")]),e("span",{staticClass:"text-xs text-textMuted"},[t._v(t._s(t.filteredActions.length)+" 个动作")])]),e("button",{staticClass:"px-3 py-1 bg-accent text-white text-xs rounded hover:bg-accent/80",on:{click:t.openCreateDialog}},[e("i",{staticClass:"fa-solid fa-plus mr-1"}),t._v(" 新增动作 ")])])]),e("div",{staticClass:"flex-1 overflow-auto p-4"},[e("table",{staticClass:"w-full text-sm"},[t._m(1),e("tbody",[t._l(t.filteredActions,function(r){return e("tr",{key:r.id,staticClass:"hover:bg-white/5"},[e("td",{staticClass:"px-3 py-2 border-b border-border/30 text-gray-200"},[t._v(t._s(r.name))]),e("td",{staticClass:"px-3 py-2 border-b border-border/30 text-gray-300 max-w-[300px] truncate",attrs:{title:r.prompt}},[t._v(t._s(r.prompt))]),e("td",{staticClass:"px-3 py-2 border-b border-border/30"},[r.auto_send?e("span",{staticClass:"text-xs px-2 py-0.5 rounded bg-green-500/20 text-green-400"},[t._v("是")]):e("span",{staticClass:"text-xs px-2 py-0.5 rounded bg-gray-500/20 text-gray-400"},[t._v("否")])]),e("td",{staticClass:"px-3 py-2 border-b border-border/30 text-gray-300"},[t._v(t._s(r.sort_order))]),e("td",{staticClass:"px-3 py-2 border-b border-border/30"},[e("div",{staticClass:"flex items-center gap-2"},[e("button",{staticClass:"text-xs px-2 py-1 text-blue-400 hover:bg-blue-500/20 rounded",on:{click:function(a){return t.openEditDialog(r)}}},[t._v("编辑")]),e("button",{staticClass:"text-xs px-2 py-1 text-red-400 hover:bg-red-500/20 rounded",on:{click:function(a){return t.deleteAction(r)}}},[t._v("删除")])])])])}),t.filteredActions.length===0?e("tr",[e("td",{staticClass:"px-3 py-8 text-center text-textMuted",attrs:{colspan:"5"}},[t._v('暂无动作,点击"新增动作"创建')])]):t._e()],2)])])]),t.showDialog?e("div",{staticClass:"fixed inset-0 bg-black/50 flex items-center justify-center z-50"},[e("div",{staticClass:"bg-sidebar border border-border rounded-lg w-[500px] max-h-[80vh] overflow-auto"},[e("div",{staticClass:"px-4 py-3 border-b border-border flex items-center justify-between"},[e("h3",{staticClass:"text-white font-medium"},[t._v(t._s(t.isEditing?"编辑动作":"新增动作"))]),e("button",{staticClass:"text-textMuted hover:text-white text-sm",on:{click:t.closeDialog}},[t._v("关闭")])]),e("div",{staticClass:"p-4 space-y-4"},[e("div",[t._m(2),e("select",{directives:[{name:"model",rawName:"v-model",value:t.form.action_type,expression:"form.action_type"}],staticClass:"w-full bg-black/20 border border-white/10 text-white text-sm px-3 py-2 rounded",attrs:{disabled:t.isEditing},on:{change:function(r){var a=Array.prototype.filter.call(r.target.options,function(o){return o.selected}).map(function(o){var l="_value"in o?o._value:o.value;return l});t.$set(t.form,"action_type",r.target.multiple?a:a[0])}}},[e("option",{attrs:{value:"design"}},[t._v("方案设计")]),e("option",{attrs:{value:"code"}},[t._v("代码生成")]),e("option",{attrs:{value:"test"}},[t._v("测试验收")])])]),e("div",[t._m(3),e("input",{directives:[{name:"model",rawName:"v-model",value:t.form.name,expression:"form.name"}],staticClass:"w-full bg-black/20 border border-white/10 text-white text-sm px-3 py-2 rounded",attrs:{type:"text",placeholder:"按钮显示名称"},domProps:{value:t.form.name},on:{input:function(r){r.target.composing||t.$set(t.form,"name",r.target.value)}}})]),e("div",[t._m(4),e("textarea",{directives:[{name:"model",rawName:"v-model",value:t.form.prompt,expression:"form.prompt"}],staticClass:"w-full bg-black/20 border border-white/10 text-white text-sm px-3 py-2 rounded resize-none",attrs:{rows:"4",placeholder:"点击按钮后填入输入框的内容"},domProps:{value:t.form.prompt},on:{input:function(r){r.target.composing||t.$set(t.form,"prompt",r.target.value)}}})]),e("div",[e("label",{staticClass:"block text-xs text-textMuted mb-1"},[t._v("排序")]),e("input",{directives:[{name:"model",rawName:"v-model.number",value:t.form.sort_order,expression:"form.sort_order",modifiers:{number:!0}}],staticClass:"w-full bg-black/20 border border-white/10 text-white text-sm px-3 py-2 rounded",attrs:{type:"number",placeholder:"数字越小越靠前"},domProps:{value:t.form.sort_order},on:{input:function(r){r.target.composing||t.$set(t.form,"sort_order",t._n(r.target.value))},blur:function(r){return t.$forceUpdate()}}})]),e("div",{staticClass:"flex items-center gap-2"},[e("input",{directives:[{name:"model",rawName:"v-model",value:t.form.auto_send,expression:"form.auto_send"}],staticClass:"accent-accent",attrs:{type:"checkbox",id:"autoSend"},domProps:{checked:Array.isArray(t.form.auto_send)?t._i(t.form.auto_send,null)>-1:t.form.auto_send},on:{change:function(r){var a=t.form.auto_send,o=r.target,l=!!o.checked;if(Array.isArray(a)){var c=null,i=t._i(a,c);o.checked?i<0&&t.$set(t.form,"auto_send",a.concat([c])):i>-1&&t.$set(t.form,"auto_send",a.slice(0,i).concat(a.slice(i+1)))}else t.$set(t.form,"auto_send",l)}}}),e("label",{staticClass:"text-xs text-textMuted",attrs:{for:"autoSend"}},[t._v("点击后自动发送(无需手动确认)")])])]),e("div",{staticClass:"px-4 py-3 border-t border-border flex justify-end gap-2"},[e("button",{staticClass:"px-4 py-1 text-textMuted text-sm rounded hover:bg-white/10",on:{click:t.closeDialog}},[t._v("取消")]),e("button",{staticClass:"px-4 py-1 bg-accent text-white text-sm rounded hover:bg-accent/80",on:{click:t.saveAction}},[t._v(" "+t._s(t.isEditing?"保存":"创建")+" ")])])])]):t._e()])},x=[function(){var s=this,t=s._self._c;return t("div",{staticClass:"px-4 py-3 border-b border-border"},[t("span",{staticClass:"text-white text-sm font-medium"},[s._v("类型")])])},function(){var s=this,t=s._self._c;return t("thead",{staticClass:"bg-sidebar sticky top-0"},[t("tr",[t("th",{staticClass:"px-3 py-2 text-left text-xs font-bold text-textMuted uppercase border-b border-border"},[s._v("名称")]),t("th",{staticClass:"px-3 py-2 text-left text-xs font-bold text-textMuted uppercase border-b border-border"},[s._v("提示词")]),t("th",{staticClass:"px-3 py-2 text-left text-xs font-bold text-textMuted uppercase border-b border-border"},[s._v("自动发送")]),t("th",{staticClass:"px-3 py-2 text-left text-xs font-bold text-textMuted uppercase border-b border-border"},[s._v("排序")]),t("th",{staticClass:"px-3 py-2 text-left text-xs font-bold text-textMuted uppercase border-b border-border"},[s._v("操作")])])])},function(){var s=this,t=s._self._c;return t("label",{staticClass:"block text-xs text-textMuted mb-1"},[s._v("类型 "),t("span",{staticClass:"text-red-400"},[s._v("*")])])},function(){var s=this,t=s._self._c;return t("label",{staticClass:"block text-xs text-textMuted mb-1"},[s._v("名称 "),t("span",{staticClass:"text-red-400"},[s._v("*")])])},function(){var s=this,t=s._self._c;return t("label",{staticClass:"block text-xs text-textMuted mb-1"},[s._v("提示词 "),t("span",{staticClass:"text-red-400"},[s._v("*")])])}],m=d(u,p,x,!1,null,null);const f=m.exports;export{f as default};
@@ -1 +1 @@
1
- import{n as c,a as d,e as _,K as m,d as y,R as v,g}from"./index-Cn73hS12.js";const C="/api";async function h(s,t,e=null,a=!1){const n={method:s,headers:a?{}:{"Content-Type":"application/json"}};e&&s!=="GET"&&(n.body=a?e:JSON.stringify(e));const i=await(await fetch(`${C}${t}`,n)).json();if(i.success===!1)throw new Error(i.error||i.message||"请求失败");return i}const p={checkRelease(s){const t=s?`?projectPath=${encodeURIComponent(s)}`:"";return h("GET",`/deploy/check-release${t}`)},downloadUrl(s,t){return h("POST","/deploy/download-url",{url:s,projectPath:t})},async uploadArchive(s,t){const e=new FormData;return e.append("file",s),t&&e.append("projectPath",t),h("POST","/deploy/upload-archive",e,!0)}},w={name:"DeployEditor",props:{content:{type:String,default:""},filePath:{type:String,default:""}},data(){return{editor:null,saved:!0}},computed:{displayPath(){return this.filePath||"RELEASE.md"}},watch:{content(s){this.editor&&s!==this.editor.getValue()&&(this.editor.setValue(s),this.saved=!0)}},mounted(){this.$nextTick(()=>this.initEditor())},beforeDestroy(){this.editor&&(this.editor.dispose(),this.editor=null)},methods:{initEditor(){this.editor||(this.editor=_.create(this.$refs.editorContainer,{value:this.content||"",language:"markdown",theme:"vs-dark",fontSize:14,fontFamily:"ui-monospace, SFMono-Regular, 'JetBrains Mono', Menlo, Monaco, Consolas, monospace",minimap:{enabled:!1},lineNumbers:"on",wordWrap:"on",scrollBeyondLastLine:!1,automaticLayout:!0,padding:{top:16}}),this.editor.addCommand(m.CtrlCmd|y.KeyS,()=>{this.save()}),this.editor.onDidChangeModelContent(()=>{this.saved=!1,this.$emit("content-change",this.editor.getValue())}))},getContent(){return this.editor?this.editor.getValue():this.content},async save(){if(!this.editor||!this.filePath)return;const s=this.editor.getValue();try{await d.writeFile(this.filePath,s),this.saved=!0,this.$emit("saved",s)}catch(t){this.$message.error("保存失败: "+t.message)}}}};var b=function(){var t=this,e=t._self._c;return e("div",{staticClass:"editor-panel"},[e("div",{staticClass:"editor-header"},[e("i",{staticClass:"fa-solid fa-file-lines"}),e("span",[t._v(t._s(t.displayPath))]),e("span",{staticClass:"save-status",class:t.saved?"saved":""},[t._v(" "+t._s(t.saved?"已保存":"未保存")+" ")])]),e("div",{ref:"editorContainer",staticClass:"editor-container"})])},k=[],S=c(w,b,k,!1,null,"6615be35");const x=S.exports,M={name:"DeployAssistant",components:{ResizableTextarea:v},props:{hasContent:{type:Boolean,default:!1},docContent:{type:String,default:""},projectPath:{type:String,default:""},releasePath:{type:String,default:""}},data(){return{ws:null,sessionId:"",inputMessage:"",messages:[],disabled:!1,stopping:!1,modelName:"",promptTokens:0,sessionStatus:"idle",heartbeatTimer:null}},computed:{displaySessionId(){return this.sessionId?this.sessionId.slice(0,8):"--------"}},async mounted(){const s=await this.loadSavedSession();s&&(this.sessionId=s),this.connect()},beforeDestroy(){this.disconnect(),this.heartbeatTimer&&clearInterval(this.heartbeatTimer)},methods:{connect(){const t=`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/ws/caller`;this.ws=new WebSocket(t),this.ws.onopen=()=>{this.sessionId||(this.sessionId="deploy-"+Date.now()+"-"+Math.random().toString(36).slice(2,8)),this.ws.send(JSON.stringify({type:"init",data:{callbackUrl:"http://localhost:40000",projectPath:this.projectPath||"",tools:[],sessionId:this.sessionId,title:"部署助手"}})),this.heartbeatTimer=setInterval(()=>{this.ws&&this.ws.readyState===WebSocket.OPEN&&this.ws.send(JSON.stringify({type:"ping"}))},3e4)},this.ws.onmessage=e=>{try{const a=JSON.parse(e.data);this.handleMessage(a)}catch(a){console.error("Parse WS message error:",a)}},this.ws.onclose=()=>{this.sessionStatus="idle",this.disabled=!1,this.heartbeatTimer&&clearInterval(this.heartbeatTimer)},this.ws.onerror=e=>{console.error("WS error:",e),this.sessionStatus="idle",this.disabled=!1}},disconnect(){this.heartbeatTimer&&(clearInterval(this.heartbeatTimer),this.heartbeatTimer=null),this.ws&&(this.ws.close(),this.ws=null)},handleMessage(s){var t,e,a,n,o,i,r,l,u,f;switch(s.type){case"connected":break;case"init_ready":this.sessionId=((t=s.data)==null?void 0:t.sessionId)||this.sessionId,this.saveSessionId(this.sessionId),this.loadHistoryMessages();break;case"step":this.messages.push({type:"step",thought:(e=s.data)==null?void 0:e.thought,toolCalls:((a=s.data)==null?void 0:a.toolCalls)||[],success:(n=s.data)==null?void 0:n.success}),(i=(o=s.data)==null?void 0:o.usage)!=null&&i.promptTokens&&(this.promptTokens=s.data.usage.promptTokens),this.scrollToBottom();break;case"done":this.disabled=!1,this.stopping=!1,this.sessionStatus="completed",this.messages.push({type:"done",content:((r=s.data)==null?void 0:r.response)||""}),(l=s.data)!=null&&l.modelName&&(this.modelName=s.data.modelName),(f=(u=s.data)==null?void 0:u.usage)!=null&&f.promptTokens&&(this.promptTokens=s.data.usage.promptTokens),this.scrollToBottom();break;case"error":this.disabled=!1,this.stopping=!1,this.sessionStatus="idle",this.messages.push({type:"error",content:s.error||"发生错误"}),this.scrollToBottom();break}},sendMessage(s){s&&s.preventDefault();const t=this.inputMessage.trim();!t||this.disabled||!this.ws||(this.messages.push({type:"user",content:t}),this.inputMessage="",this.disabled=!0,this.stopping=!1,this.sessionStatus="processing",this.ws.send(JSON.stringify({type:"chat",data:{sessionId:this.sessionId,message:t}})),this.scrollToBottom())},deployByDoc(){this.disabled||(this.inputMessage=`请按 ${this.releasePath} 文档进行部署`)},stopChat(){!this.sessionId||this.stopping||!this.ws||(this.stopping=!0,this.ws.send(JSON.stringify({type:"stop",data:{sessionId:this.sessionId}})))},handleKeydown(s){if(s.key==="Enter"){if(s.ctrlKey)return;s.preventDefault(),this.sendMessage()}},scrollToBottom(){this.$nextTick(()=>{const s=this.$refs.messagesContainer;s&&(s.scrollTop=s.scrollHeight)})},async loadSavedSession(){var s;if(!this.projectPath)return null;try{const t=`${this.projectPath}/.txcode/release/deploy.json`,e=await d.getFileContent(t);if((s=e==null?void 0:e.data)!=null&&s.content)return JSON.parse(e.data.content).sessionId||null}catch{}return null},async saveSessionId(s){if(this.projectPath)try{const t=`${this.projectPath}/.txcode/release/deploy.json`;await d.writeFile(t,JSON.stringify({sessionId:s},null,2))}catch(t){console.error("保存 sessionId 失败:",t)}},async loadHistoryMessages(){if(this.sessionId)try{const s=await d.getMessages(this.sessionId),t=(s==null?void 0:s.data)||[];t.length>0&&(this.messages=t.map(e=>e.type==="chat"&&e.role==="user"?{type:"user",content:e.content}:e.role==="assistant"?{type:"done",content:e.content}:e))}catch(s){console.error("加载历史消息失败:",s)}},renderMarkdown(s){return s?g(s):""},formatArgs(s,t){try{const e=JSON.parse(t);return s==="bash"||s==="execute_bash"?e.command+(e.workdir?` (${e.workdir})`:""):s==="read_file"?e.file_path+(e.offset?`:${e.offset}`:""):s==="edit_file"||s==="write_file"?e.file_path:s==="glob"?e.pattern:s==="grep"?`"${e.pattern}"`:t}catch{return t}}}};var P=function(){var t=this,e=t._self._c;return e("div",{staticClass:"chat-panel"},[t._m(0),e("div",{ref:"messagesContainer",staticClass:"chat-messages"},[t.messages.length?t._e():e("div",{staticClass:"empty-state"},[e("i",{staticClass:"fa-solid fa-rocket text-3xl text-textMuted opacity-30 mb-4"}),e("p",[t._v('点击"按部署文档部署"开始自动化部署')])]),t._l(t.messages,function(a,n){return[a.type==="user"?e("div",{staticClass:"user-message"},[t._v(" "+t._s(a.content)+" ")]):a.type==="step"?e("div",{staticClass:"ai-step"},[a.thought?e("div",{staticClass:"ai-thought",domProps:{innerHTML:t._s(t.renderMarkdown(a.thought))}}):t._e(),t._l(a.toolCalls,function(o,i){var r,l;return e("div",{key:i,staticClass:"log-mute"},[e("span",{class:a.success!==!1?"tool-success":"tool-fail"},[t._v(" "+t._s(a.success!==!1?"✓":"✗")+" ")]),t._v(" "+t._s(((r=o.function)==null?void 0:r.name)||"")+" "),(l=o.function)!=null&&l.arguments?e("span",{staticClass:"tool-input"},[t._v(" "+t._s(t.formatArgs(o.function.name,o.function.arguments))+" ")]):t._e()])})],2):a.type==="done"?e("div",{staticClass:"ai-done",domProps:{innerHTML:t._s(t.renderMarkdown(a.content))}}):a.type==="error"?e("div",{staticClass:"ai-error"},[t._v(" "+t._s(a.content)+" ")]):t._e()]}),t.modelName?e("div",{staticClass:"build-info"},[e("span",[t._v("▣")]),t._v(" Build · "+t._s(t.modelName)+" ")]):t._e()],2),e("div",{staticClass:"chat-input-area"},[e("div",{staticClass:"input-row"},[e("ResizableTextarea",{staticClass:"input-area",attrs:{rows:5,"min-rows":2,"max-rows":15,placeholder:"输入消息... (Enter 发送, Ctrl+Enter 换行)",disabled:t.disabled&&!t.stopping},nativeOn:{keydown:function(a){return!a.type.indexOf("key")&&t._k(a.keyCode,"enter",13,a.key,"Enter")?null:t.handleKeydown.apply(null,arguments)}},model:{value:t.inputMessage,callback:function(a){t.inputMessage=a},expression:"inputMessage"}}),e("div",{staticClass:"input-actions"},[t.disabled&&!t.stopping?e("el-button",{attrs:{type:"danger",size:"small"},on:{click:t.stopChat}},[t._v(" ■ 停止 ")]):t.stopping?e("el-button",{attrs:{type:"info",disabled:"",size:"small"}},[t._v(" 停止中... ")]):e("el-button",{attrs:{type:"default",disabled:!t.inputMessage.trim()||t.disabled,size:"small"},on:{click:t.sendMessage}},[t._v(" 发送 ")])],1)],1),e("div",{staticClass:"deploy-doc-link",on:{click:t.deployByDoc}},[e("i",{staticClass:"fa-solid fa-file-arrow-up"}),t._v(" 按部署文档部署 ")])]),e("div",{staticClass:"status-bar"},[e("span",{class:t.sessionStatus==="processing"?"status-thinking":"status-ready"},[t.sessionStatus==="processing"?e("span",{staticClass:"thinking-spinner"}):t._e(),t._v(" "+t._s(t.sessionStatus==="processing"?"思考中":"✓ 就绪")+" ")]),e("span",{staticClass:"separator"},[t._v("|")]),e("span",[t._v("模型:"+t._s(t.modelName||"-"))]),e("span",{staticClass:"separator"},[t._v("|")]),e("span",[t._v("会话:"+t._s(t.displaySessionId))]),e("span",{staticClass:"separator"},[t._v("|")]),e("span",[t._v("token:"+t._s(t.promptTokens))])])])},T=[function(){var s=this,t=s._self._c;return t("div",{staticClass:"panel-header"},[t("span",[t("i",{staticClass:"fa-solid fa-robot"}),s._v(" AI 部署助手")])])}],I=c(M,P,T,!1,null,"58b0f9d9");const $=I.exports,j={name:"DeployImport",props:{projectPath:{type:String,default:""}},data(){return{downloadUrl:"",downloading:!1,fileList:[],statusMessage:"",statusType:"info"}},methods:{async handleDownload(){if(this.downloadUrl.trim()){this.downloading=!0,this.statusMessage="";try{const s=await p.downloadUrl(this.downloadUrl.trim(),this.projectPath);this.statusMessage="部署文档已导入成功!",this.statusType="success",this.$emit("imported",s.data)}catch(s){this.statusMessage="下载失败: "+s.message,this.statusType="error"}finally{this.downloading=!1}}},async handleFileChange(s){this.statusMessage="";try{const t=await p.uploadArchive(s.raw,this.projectPath);this.statusMessage="部署文档已导入成功!",this.statusType="success",this.fileList=[],this.$emit("imported",t.data)}catch(t){this.statusMessage="上传失败: "+t.message,this.statusType="error"}}}};var E=function(){var t=this,e=t._self._c;return e("div",{staticClass:"deploy-import"},[e("div",{staticClass:"import-container"},[t._m(0),e("h2",{staticClass:"text-xl font-bold text-white mb-2"},[t._v("未找到部署文档")]),e("p",{staticClass:"text-textMuted mb-8"},[t._v("请导入部署文档到 .txcode/release/ 目录")]),e("div",{staticClass:"import-card"},[t._m(1),e("div",{staticClass:"import-card-body"},[e("div",{staticClass:"flex gap-2"},[e("el-input",{staticClass:"flex-1",attrs:{placeholder:"https://...",disabled:t.downloading},model:{value:t.downloadUrl,callback:function(a){t.downloadUrl=a},expression:"downloadUrl"}}),e("el-button",{attrs:{type:"primary",loading:t.downloading,disabled:!t.downloadUrl.trim()},on:{click:t.handleDownload}},[t._v(" "+t._s(t.downloading?"下载中...":"下载")+" ")])],1)])]),t._m(2),e("div",{staticClass:"import-card"},[t._m(3),e("div",{staticClass:"import-card-body"},[e("el-upload",{attrs:{drag:"","auto-upload":!1,"show-file-list":!0,accept:".tar.gz,.tgz,.zip","on-change":t.handleFileChange,"file-list":t.fileList,limit:1}},[e("i",{staticClass:"el-icon-upload"}),e("div",{staticClass:"el-upload__text"},[t._v("将 tar.gz / zip 文件拖到此处,或"),e("em",[t._v("点击上传")])]),e("div",{staticClass:"el-upload__tip",attrs:{slot:"tip"},slot:"tip"},[t._v("上传后自动解压到 .txcode/release/ 目录")])])],1)]),t.statusMessage?e("div",{staticClass:"import-status",class:t.statusType},[t._v(" "+t._s(t.statusMessage)+" ")]):t._e()])])},D=[function(){var s=this,t=s._self._c;return t("div",{staticClass:"import-icon"},[t("i",{staticClass:"fa-solid fa-cloud-arrow-down text-5xl text-textMuted opacity-50"})])},function(){var s=this,t=s._self._c;return t("div",{staticClass:"import-card-title"},[t("i",{staticClass:"fa-solid fa-link"}),s._v(" 输入链接下载部署文档 ")])},function(){var s=this,t=s._self._c;return t("div",{staticClass:"import-divider"},[t("span",[s._v("—— 或 ——")])])},function(){var s=this,t=s._self._c;return t("div",{staticClass:"import-card-title"},[t("i",{staticClass:"fa-solid fa-upload"}),s._v(" 选择压缩包上传(tar.gz / zip) ")])}],N=c(j,E,D,!1,null,"0cc389d3");const R=N.exports,z={name:"deployView",components:{DeployEditor:x,DeployAssistant:$,DeployImport:R},data(){return{loading:!0,releaseExists:!1,releaseContent:"",releasePath:"",editorContent:"",projectPath:""}},async mounted(){await this.loadProjectPath(),await this.checkRelease()},methods:{async loadProjectPath(){try{const s=await d.getCurrentProject();s.data&&s.data.path&&(this.projectPath=s.data.path)}catch(s){console.error("获取项目路径失败:",s)}},async checkRelease(){this.loading=!0;try{const s=await p.checkRelease(this.projectPath);s.data&&s.data.exists?(this.releaseExists=!0,this.releaseContent=s.data.content||"",this.editorContent=this.releaseContent,this.releasePath=s.data.path||""):this.releaseExists=!1}catch(s){console.error("检查部署文档失败:",s),this.releaseExists=!1}finally{this.loading=!1}},onContentChange(s){this.editorContent=s},onImported(){this.checkRelease()}}};var O=function(){var t=this,e=t._self._c;return e("div",{staticClass:"deploy-container"},[t.loading?e("div",{staticClass:"loading-state"},[e("i",{staticClass:"fa-solid fa-spinner fa-spin text-2xl text-textMuted"})]):t.releaseExists?[e("div",{staticClass:"deploy-main"},[e("DeployEditor",{ref:"editorRef",attrs:{content:t.releaseContent,"file-path":t.releasePath},on:{"content-change":t.onContentChange}}),e("DeployAssistant",{ref:"assistantRef",attrs:{"has-content":!!t.editorContent,"doc-content":t.editorContent,"project-path":t.projectPath,"release-path":t.releasePath}})],1)]:[e("DeployImport",{attrs:{"project-path":t.projectPath},on:{imported:t.onImported}})]],2)},A=[],B=c(z,O,A,!1,null,"a81ff1a6");const U=B.exports;export{U as default};
1
+ import{n as c,a as d,e as _,K as m,d as y,R as v,g}from"./index-CUBJZpK-.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-d033f82c]::-webkit-scrollbar{width:8px}.sidebar-scroll[data-v-d033f82c]::-webkit-scrollbar-track{background:transparent}.sidebar-scroll[data-v-d033f82c]::-webkit-scrollbar-thumb{background:var(--color-border);border-radius:4px}.sidebar-scroll[data-v-d033f82c]::-webkit-scrollbar-thumb:hover{background:#505050}.template-select-content[data-v-2152b684]{height:360px;display:flex;flex-direction:column}.template-search[data-v-2152b684]{margin-bottom:10px}.search-input[data-v-2152b684]{width:100%;padding:8px 12px;background:#27272a;border:1px solid #3f3f46;border-radius:4px;color:#d4d4d8;font-size:13px;outline:none;box-sizing:border-box}.search-input[data-v-2152b684]:focus{border-color:#3b82f6}.template-list-container[data-v-2152b684]{flex:1;overflow-y:auto;border:1px solid #3f3f46;border-radius:4px}.empty-state[data-v-2152b684]{padding:30px;text-align:center;color:#71717a;font-size:13px}.template-item[data-v-2152b684]{padding:10px 12px;cursor:pointer;border-bottom:1px solid #27272a}.template-item[data-v-2152b684]:hover{background:#27272a}.template-item.template-selected[data-v-2152b684]{background:#1e3a5f;border-left:2px solid #3b82f6}.template-name[data-v-2152b684]{color:#d4d4d8;font-size:13px;font-weight:500}.template-path[data-v-2152b684]{color:#71717a;font-size:11px;margin-top:2px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.template-select-footer[data-v-2152b684]{margin-top:10px;display:flex;gap:8px;align-items:center}.selected-template[data-v-2152b684]{flex:1;padding:8px 12px;background:#27272a;color:#a1a1aa;font-size:13px;border-radius:4px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.confirm-btn[data-v-2152b684]{padding:8px 16px;background:#3b82f6;border:none;border-radius:4px;color:#fff;font-size:13px;cursor:pointer}.confirm-btn[data-v-2152b684]:hover{background:#2563eb}.confirm-btn[data-v-2152b684]:disabled{opacity:.5;cursor:not-allowed}[data-v-2152b684] .el-dialog{background:#18181b;border:1px solid #3f3f46}[data-v-2152b684] .el-dialog__header{background:#18181b;border-bottom:1px solid #3f3f46;padding:16px 20px}[data-v-2152b684] .el-dialog__title{color:#d4d4d8;font-size:15px;font-weight:500}[data-v-2152b684] .el-dialog__headerbtn{top:16px;right:16px}[data-v-2152b684] .el-dialog__headerbtn .el-dialog__close{color:#71717a}[data-v-2152b684] .el-dialog__headerbtn:hover .el-dialog__close{color:#fff}[data-v-2152b684] .el-dialog__body{background:#18181b;padding:20px;color:#d4d4d8}.chat-messages[data-v-7d70ef43]::-webkit-scrollbar{width:6px}.chat-messages[data-v-7d70ef43]::-webkit-scrollbar-track{background:transparent}.chat-messages[data-v-7d70ef43]::-webkit-scrollbar-thumb{background:#404040;border-radius:3px}.chat-messages[data-v-7d70ef43]::-webkit-scrollbar-thumb:hover{background:#505050}.chat-messages[data-v-7d70ef43]{padding:0 16px 16px;font-size:14px;line-height:1.6}.user-question[data-v-7d70ef43]{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-7d70ef43]{color:#d4d4d8;margin-bottom:16px}.log-mute[data-v-7d70ef43]{color:#84848a;margin-bottom:16px;white-space:pre}.tool-input[data-v-7d70ef43]{color:#60a5fa;margin-left:8px}.build-info[data-v-7d70ef43]{color:#84848a;display:flex;align-items:center;gap:8px;margin-bottom:16px}.chat-images[data-v-7d70ef43]{display:flex;gap:8px;flex-wrap:wrap;margin-bottom:10px}.chat-image-thumb[data-v-7d70ef43]{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-7d70ef43]:hover{border-color:#60a5fa}.chat-input-area[data-v-7d70ef43]{padding:12px 16px;background:#121212;border-top:1px solid #1e1e1e}.input-panel[data-v-7d70ef43]{background:#fff;border-radius:6px;border:1px solid #e0e0e0;overflow:hidden}.input-wrapper[data-v-7d70ef43]{position:relative}.input-area[data-v-7d70ef43]{flex:1}.input-area[data-v-7d70ef43] .el-textarea__inner{border:none;border-radius:0;background:#fff;color:#4b5563;resize:none}.input-area[data-v-7d70ef43] .el-textarea__inner:focus{box-shadow:none}.input-panel .input-actions[data-v-7d70ef43]{display:flex;justify-content:space-between;align-items:center;padding:6px 12px;gap:6px;background:#fff}.input-actions-left[data-v-7d70ef43],.input-actions-right[data-v-7d70ef43]{display:flex;align-items:center;gap:6px}.input-panel .status-action[data-v-7d70ef43]{cursor:pointer;font-size:12px;color:#6b7280}.input-panel .status-action[data-v-7d70ef43]:hover{color:#60a5fa}.input-panel .separator[data-v-7d70ef43]{color:#d1d5db;font-size:12px}.status-bar[data-v-7d70ef43]{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-7d70ef43]{color:#3f3f46}.status-ready[data-v-7d70ef43]{color:#22c55e}.status-thinking[data-v-7d70ef43]{color:#60a5fa}.model-selector[data-v-7d70ef43]{cursor:pointer}.model-selector[data-v-7d70ef43]:hover{color:#60a5fa}.thinking-spinner[data-v-7d70ef43]{display:inline-block;width:12px;height:12px;border:2px solid #60a5fa;border-top-color:transparent;border-radius:50%;animation:spin-7d70ef43 .8s linear infinite}@keyframes spin-7d70ef43{to{transform:rotate(360deg)}}.device-frame[data-v-39c9eda3]{height:100%;max-width:100%}.device-frame>iframe[data-v-39c9eda3]{flex:1;min-height:0}.device-frame-app[data-v-39c9eda3]{position:relative;background:#1a1a1a;border-radius:36px;padding:8px;box-shadow:0 0 0 2px #333,0 0 0 4px #1a1a1a,0 0 0 6px #444,0 20px 40px #00000080}.device-frame-app[data-v-39c9eda3]:before{content:"";position:absolute;top:4px;left:50%;transform:translate(-50%);width:120px;height:25px;background:#1a1a1a;border-radius:0 0 16px 16px;z-index:10}.device-frame-app[data-v-39c9eda3]:after{content:"";position:absolute;bottom:4px;left:50%;transform:translate(-50%);width:100px;height:4px;background:#444;border-radius:2px;z-index:10}.device-frame-web[data-v-39c9eda3]{width:100%;background:#2d2d2d;border-radius:12px;padding:12px;box-shadow:0 4px 20px #0006}.device-frame-pad[data-v-39c9eda3]{background:#1a1a1a;border-radius:16px;padding:10px;box-shadow:0 0 0 2px #444,0 0 0 4px #2a2a2a,0 0 0 6px #555,0 20px 40px #00000080}.monaco-editor-container[data-v-f53b2118]{width:100%;overflow:hidden}.monaco-editor-container[data-v-f53b2118] .monaco-editor{padding-top:8px}.monaco-editor-container[data-v-f53b2118] .monaco-editor .overflow-guard{overflow:hidden!important}.save-template-content[data-v-30bde40e]{display:flex;flex-direction:column;gap:16px}.form-item[data-v-30bde40e]{display:flex;flex-direction:column;gap:6px}.form-label[data-v-30bde40e]{color:#d4d4d8;font-size:13px}.form-input[data-v-30bde40e]{width:100%;padding:8px 12px;background:#27272a;border:1px solid #3f3f46;border-radius:4px;color:#d4d4d8;font-size:13px;outline:none;box-sizing:border-box}.form-input[data-v-30bde40e]:focus{border-color:#3b82f6}.form-hint[data-v-30bde40e]{color:#71717a;font-size:12px;margin:0}.save-template-footer[data-v-30bde40e]{display:flex;justify-content:flex-end;gap:8px}.cancel-btn[data-v-30bde40e]{padding:8px 16px;background:#27272a;border:1px solid #3f3f46;border-radius:4px;color:#d4d4d8;font-size:13px;cursor:pointer}.cancel-btn[data-v-30bde40e]:hover{background:#3f3f46}.confirm-btn[data-v-30bde40e]{padding:8px 16px;background:#3b82f6;border:none;border-radius:4px;color:#fff;font-size:13px;cursor:pointer}.confirm-btn[data-v-30bde40e]:hover{background:#2563eb}.confirm-btn[data-v-30bde40e]:disabled{opacity:.5;cursor:not-allowed}[data-v-30bde40e] .el-dialog{background:#18181b;border:1px solid #3f3f46}[data-v-30bde40e] .el-dialog__header{background:#18181b;border-bottom:1px solid #3f3f46;padding:16px 20px}[data-v-30bde40e] .el-dialog__title{color:#d4d4d8;font-size:15px;font-weight:500}[data-v-30bde40e] .el-dialog__headerbtn{top:16px;right:16px}[data-v-30bde40e] .el-dialog__headerbtn .el-dialog__close{color:#71717a}[data-v-30bde40e] .el-dialog__headerbtn:hover .el-dialog__close{color:#fff}[data-v-30bde40e] .el-dialog__body{background:#18181b;padding:20px;color:#d4d4d8}
@@ -0,0 +1,18 @@
1
+ import{n as o,a as l,C as h,h as u,R as p,I as f,S as m,F as g,c as v,M as b,g as x,s as C,b as _,e as w,K as y,d as P,f as S}from"./index-CUBJZpK-.js";import{m as k}from"./mediaChat-DHxUlCTa.js";const D={name:"CreatePageDialog",props:{visible:{type:Boolean,default:!1},targetPath:{type:String,default:""}},data(){return{pageName:"",pageType:"web",deviceTypes:[{value:"app",label:"App",icon:"fa-solid fa-mobile-screen"},{value:"web",label:"Web",icon:"fa-solid fa-desktop"},{value:"pad",label:"Pad",icon:"fa-solid fa-tablet-screen-button"}]}},computed:{previewFilename(){return`${this.pageName.trim()||"untitled"}_${this.pageType}.html`}},watch:{visible(s){s&&(this.pageName="",this.pageType="web",this.$nextTick(()=>{var e;return(e=this.$refs.nameInput)==null?void 0:e.focus()}))}},methods:{async confirm(){const s=this.pageName.trim();if(!s)return;const e=`${s}_${this.pageType}.html`,t=this.targetPath.includes("\\")?"\\":"/",i=this.targetPath+t+e,a=`<!DOCTYPE html>
2
+ <html lang="zh-CN">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>${s}</title>
7
+ <style>
8
+ * { margin: 0; padding: 0; box-sizing: border-box; }
9
+ body { font-family: system-ui, sans-serif; padding: 20px; }
10
+ </style>
11
+ </head>
12
+ <body>
13
+ <h1>${s}</h1>
14
+ </body>
15
+ </html>`;try{await l.writeFile(i,a),this.$message.success("网页创建成功"),this.$emit("created"),this.$emit("update:visible",!1)}catch(n){console.error("Create page failed:",n),this.$message.error("创建网页失败: "+(n.message||"未知错误"))}},cancel(){this.$emit("update:visible",!1)}}};var $=function(){var e=this,t=e._self._c;return e.visible?t("div",{staticClass:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",on:{click:function(i){return i.target!==i.currentTarget?null:e.cancel.apply(null,arguments)}}},[t("div",{staticClass:"bg-sidebar border border-border rounded p-5 w-96"},[t("p",{staticClass:"text-white text-sm font-medium mb-4"},[e._v("新建网页")]),t("div",{staticClass:"mb-3"},[t("label",{staticClass:"text-textMuted text-xs block mb-1"},[e._v("名称")]),t("input",{directives:[{name:"model",rawName:"v-model",value:e.pageName,expression:"pageName"}],ref:"nameInput",staticClass:"w-full px-3 py-2 bg-[#1e1e1e] border border-border rounded text-white text-sm focus:outline-none focus:border-accent",attrs:{placeholder:"输入网页名称"},domProps:{value:e.pageName},on:{keyup:[function(i){return!i.type.indexOf("key")&&e._k(i.keyCode,"enter",13,i.key,"Enter")?null:e.confirm.apply(null,arguments)},function(i){return!i.type.indexOf("key")&&e._k(i.keyCode,"escape",void 0,i.key,void 0)?null:e.cancel.apply(null,arguments)}],input:function(i){i.target.composing||(e.pageName=i.target.value)}}})]),t("div",{staticClass:"mb-3"},[t("label",{staticClass:"text-textMuted text-xs block mb-2"},[e._v("类型")]),t("div",{staticClass:"flex gap-2"},e._l(e.deviceTypes,function(i){return t("label",{key:i.value,staticClass:"flex items-center gap-1 px-3 py-2 rounded border text-sm cursor-pointer transition-colors",class:e.pageType===i.value?"border-accent bg-accent/10 text-white":"border-border text-textMuted hover:border-gray-500"},[t("input",{directives:[{name:"model",rawName:"v-model",value:e.pageType,expression:"pageType"}],staticClass:"hidden",attrs:{type:"radio"},domProps:{value:i.value,checked:e._q(e.pageType,i.value)},on:{change:function(a){e.pageType=i.value}}}),t("i",{staticClass:"text-xs",class:i.icon}),e._v(" "+e._s(i.label)+" ")])}),0)]),t("div",{staticClass:"mb-4 p-3 bg-[#1e1e1e] rounded border border-border"},[t("p",{staticClass:"text-xs text-textMuted mb-1"},[e._v("文件名预览")]),t("p",{staticClass:"text-xs text-textMain font-mono"},[e._v(e._s(e.previewFilename))])]),t("div",{staticClass:"flex justify-end gap-2"},[t("button",{staticClass:"px-3 py-1 text-xs text-textMuted hover:text-white",on:{click:e.cancel}},[e._v("取消")]),t("button",{staticClass:"px-3 py-1 text-xs bg-accent text-white rounded hover:bg-blue-600 disabled:opacity-50 disabled:cursor-not-allowed",attrs:{disabled:!e.pageName.trim()},on:{click:e.confirm}},[e._v("确定")])])])]):e._e()},F=[],T=o(D,$,F,!1,null,null);const M=T.exports,I={name:"DesignPageTree",components:{FileTreeNode:u,CreatePageDialog:M,CopyPathDialog:h},props:{basePath:{type:String,default:".txcode/design"}},data(){return{browseResult:{current_path:"",parent_path:null,items:[]},selectedPath:"",loading:!1,expandedPaths:new Set,contextMenu:{visible:!1,x:0,y:0,target:null},renameDialog:{visible:!1,title:"",value:"",placeholder:"",target:null,action:"rename"},createPageDialogVisible:!1,createPageTargetPath:""}},computed:{fileTreeData(){return this.browseResult.items.filter(e=>e.name!=="session.json"&&e.name!==".template").map(e=>({name:e.name,path:e.path,is_directory:e.is_directory,is_drive:e.is_drive||!1,size:e.size,has_children:e.is_directory,expanded:!1,children:[]})).sort((e,t)=>e.is_directory===t.is_directory?e.name.localeCompare(t.name):e.is_directory?-1:1)}},async created(){await this.initBrowse(),document.addEventListener("click",this.hideContextMenu)},beforeDestroy(){document.removeEventListener("click",this.hideContextMenu)},methods:{async initBrowse(){this.loading=!0;try{const s=await l.browseFilesystem(this.basePath);this.browseResult=s.data}catch{try{await l.createDirectory(this.basePath);const e=await l.browseFilesystem(this.basePath);this.browseResult=e.data}catch(e){console.error("Init design directory failed:",e),this.browseResult={current_path:this.basePath,parent_path:"",items:[]}}}finally{this.loading=!1}},async browse(s){this.loading=!0;try{const e=await l.browseFilesystem(s);this.browseResult=e.data}catch(e){console.error("Browse failed:",e)}finally{this.loading=!1}},refresh(){this.browse(this.browseResult.current_path||this.basePath)},createRootFolder(){this.renameDialog={visible:!0,title:"新建文件夹",value:"",placeholder:"输入文件夹名",target:{path:this.browseResult.current_path||this.basePath,is_directory:!0},action:"createFolder"},this.$nextTick(()=>{var s;return(s=this.$refs.renameInput)==null?void 0:s.focus()})},handleSelect(s){this.selectedPath=s.path;let e=s.path;e.startsWith(this.basePath+"/")?e=e.slice(this.basePath.length+1):e===this.basePath&&(e=""),!s.is_directory&&e.endsWith(".html")?(console.log("[DesignPageTree] handleSelect emitting current-page:",e),this.$emit("current-page",e),this.$emit("open-file",s)):console.log("[DesignPageTree] handleSelect skipping (dir or non-html):",s.name,"isDir:",s.is_directory)},handleOpenFile(s){if(this.$emit("open-file",s),!s.is_directory&&s.name.endsWith(".html")){let e=s.path;e.startsWith(this.basePath+"/")&&(e=e.slice(this.basePath.length+1)),this.$emit("current-page",e)}},async handleLoadChildren({path:s,callback:e}){try{const i=((await l.browseFilesystem(s)).data.items||[]).filter(a=>a.name!=="session.json"&&a.name!==".template").map(a=>({name:a.name,path:a.path,is_directory:a.is_directory,is_drive:!1,size:a.size,has_children:a.is_directory,expanded:!1,children:[]}));e(i.sort((a,n)=>a.is_directory===n.is_directory?a.name.localeCompare(n.name):a.is_directory?-1:1))}catch(t){console.error("Load children failed:",t),e([])}},showContextMenu(s,e){e&&(s.preventDefault(),this.contextMenu={visible:!0,x:s.pageX,y:s.pageY,target:e},this.selectedPath=e.path)},hideContextMenu(){this.contextMenu.visible=!1},copyPath(){this.hideContextMenu(),this.$refs.copyPathDialog.open(this.contextMenu.target.path)},createNewPage(){this.hideContextMenu(),this.createPageTargetPath=this.contextMenu.target.path,this.createPageDialogVisible=!0},createNewFolder(){this.hideContextMenu();const s=this.contextMenu.target;this.renameDialog={visible:!0,title:"新建文件夹",value:"",placeholder:"输入文件夹名",target:s,action:"createFolder"},this.$nextTick(()=>{var e;return(e=this.$refs.renameInput)==null?void 0:e.focus()})},renameItem(){this.hideContextMenu();const s=this.contextMenu.target;s.is_directory?this.renameDialog={visible:!0,title:"重命名文件夹",value:s.name,placeholder:"输入新名称",target:s,action:"rename"}:this.renameDialog={visible:!0,title:"重命名文件",value:s.name,placeholder:"输入新名称",target:s,action:"rename"},this.$nextTick(()=>{var e,t;(e=this.$refs.renameInput)==null||e.focus(),(t=this.$refs.renameInput)==null||t.select()})},confirmRename(){const{value:s,target:e,action:t}=this.renameDialog;if(!s.trim()){this.renameDialog.visible=!1;return}const i=e.path.includes("\\")?"\\":"/";let a,n;t==="createFolder"?(a=e.path+i+s.trim(),n=l.createDirectory(a)):(a=e.path.substring(0,e.path.lastIndexOf(i))+i+s.trim(),n=l.renameFile(e.path,a)),n.then(()=>{this.refresh(),this.$emit("file-changed")}).catch(r=>{console.error("Operation failed:",r),this.$message.error(t==="createFolder"?"创建文件夹失败":"重命名失败")}),this.renameDialog.visible=!1},cancelRename(){this.renameDialog.visible=!1},async deleteItem(){this.hideContextMenu();try{await this.$confirm(`确定要删除 "${this.contextMenu.target.name}" 吗?`,"确认删除",{confirmButtonText:"删除",cancelButtonText:"取消",type:"warning"}),await l.deleteFile(this.contextMenu.target.path),this.$message.success("删除成功"),this.refresh(),this.$emit("file-changed")}catch(s){s!=="cancel"&&(console.error("Delete failed:",s),this.$message.error("删除失败"))}},downloadFile(){this.hideContextMenu();const s=this.contextMenu.target;s&&l.downloadFilesystemWithProgress(s.path,s.name,()=>{}).catch(e=>this.$message.error("下载失败: "+e.message))},onPageCreated(){this.createPageDialogVisible=!1,this.refresh(),this.$emit("file-changed")},onExpandPath(s){const e=new Set(this.expandedPaths);e.add(s),this.expandedPaths=e},onCollapsePath(s){const e=new Set(this.expandedPaths);e.delete(s),this.expandedPaths=e},selectByPath(s){if(!s)return;const e=s.replace(/\\/g,"/"),t=e.split("/");let i=this.basePath;const a=new Set(this.expandedPaths);for(let r=0;r<t.length-1;r++)i=i+"/"+t[r],a.add(i);this.expandedPaths=a;const n=this.basePath+"/"+e;this.selectedPath=n}}};var N=function(){var i;var e=this,t=e._self._c;return t("div",{staticClass:"flex flex-col flex-1 min-h-0"},[t("div",{staticClass:"flex items-center gap-1 px-2 py-2 border-b border-border"},[t("button",{staticClass:"p-1 text-textMuted hover:text-white",attrs:{title:"刷新"},on:{click:e.refresh}},[t("i",{staticClass:"fa-solid fa-refresh"})]),t("button",{staticClass:"p-1 text-textMuted hover:text-white",attrs:{title:"新建文件夹"},on:{click:e.createRootFolder}},[t("i",{staticClass:"fa-solid fa-folder-plus"})])]),t("div",{staticClass:"flex-1 overflow-y-auto py-1 pb-8 sidebar-scroll",staticStyle:{"padding-bottom":"60px"}},[e.loading?t("div",{staticClass:"flex items-center justify-center py-8 text-textMuted"},[t("i",{staticClass:"fa-solid fa-spinner fa-spin mr-2"}),e._v(" 加载中... ")]):e.fileTreeData.length===0?t("div",{staticClass:"flex flex-col items-center justify-center py-12 text-textMuted text-sm"},[t("i",{staticClass:"fa-solid fa-folder-open text-4xl mb-3 opacity-20"}),t("p",[e._v("设计目录为空")]),t("p",{staticClass:"text-xs mt-1"},[e._v("右键文件夹创建网页")])]):e._l(e.fileTreeData,function(a){return t("file-tree-node",{key:a.path,attrs:{node:a,level:0,"selected-path":e.selectedPath,"expanded-paths":e.expandedPaths},on:{select:e.handleSelect,"open-file":e.handleOpenFile,"load-children":e.handleLoadChildren,contextmenu:e.showContextMenu,"expand-path":e.onExpandPath,"collapse-path":e.onCollapsePath}})})],2),t("div",{directives:[{name:"show",rawName:"v-show",value:e.contextMenu.visible,expression:"contextMenu.visible"}],staticClass:"fixed bg-sidebar border border-border rounded shadow-lg py-1 z-50 min-w-[160px]",style:{left:e.contextMenu.x+"px",top:e.contextMenu.y+"px"}},[(i=e.contextMenu.target)!=null&&i.is_directory?[t("button",{staticClass:"w-full text-left px-4 py-2 text-sm text-textMain hover:bg-active flex items-center gap-2",on:{click:e.createNewPage}},[t("i",{staticClass:"fa-solid fa-file-lines text-xs"}),e._v(" 新建网页 ")]),t("button",{staticClass:"w-full text-left px-4 py-2 text-sm text-textMain hover:bg-active flex items-center gap-2",on:{click:e.createNewFolder}},[t("i",{staticClass:"fa-solid fa-folder-plus text-xs"}),e._v(" 新建文件夹 ")]),t("div",{staticClass:"border-t border-border my-1"}),t("button",{staticClass:"w-full text-left px-4 py-2 text-sm text-textMain hover:bg-active flex items-center gap-2",on:{click:e.renameItem}},[t("i",{staticClass:"fa-solid fa-pen text-xs"}),e._v(" 重命名 ")]),t("button",{staticClass:"w-full text-left px-4 py-2 text-sm text-red-400 hover:bg-active flex items-center gap-2",on:{click:e.deleteItem}},[t("i",{staticClass:"fa-solid fa-trash text-xs"}),e._v(" 删除 ")])]:[t("button",{staticClass:"w-full text-left px-4 py-2 text-sm text-textMain hover:bg-active flex items-center gap-2",on:{click:e.copyPath}},[t("i",{staticClass:"fa-solid fa-copy text-xs"}),e._v(" 复制路径 ")]),t("button",{staticClass:"w-full text-left px-4 py-2 text-sm text-textMain hover:bg-active flex items-center gap-2",on:{click:e.downloadFile}},[t("i",{staticClass:"fa-solid fa-download text-xs"}),e._v(" 下载 ")]),t("button",{staticClass:"w-full text-left px-4 py-2 text-sm text-textMain hover:bg-active flex items-center gap-2",on:{click:e.renameItem}},[t("i",{staticClass:"fa-solid fa-pen text-xs"}),e._v(" 重命名 ")]),t("button",{staticClass:"w-full text-left px-4 py-2 text-sm text-red-400 hover:bg-active flex items-center gap-2",on:{click:e.deleteItem}},[t("i",{staticClass:"fa-solid fa-trash text-xs"}),e._v(" 删除 ")])]],2),t("div",{directives:[{name:"show",rawName:"v-show",value:e.renameDialog.visible,expression:"renameDialog.visible"}],staticClass:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",on:{click:function(a){return a.target!==a.currentTarget?null:e.cancelRename.apply(null,arguments)}}},[t("div",{staticClass:"bg-sidebar border border-border rounded p-4 w-80"},[t("p",{staticClass:"text-white text-sm mb-3"},[e._v(e._s(e.renameDialog.title))]),t("input",{directives:[{name:"model",rawName:"v-model",value:e.renameDialog.value,expression:"renameDialog.value"}],ref:"renameInput",staticClass:"w-full px-3 py-2 bg-contentBg border border-border rounded text-white text-sm focus:outline-none focus:border-accent",attrs:{placeholder:e.renameDialog.placeholder},domProps:{value:e.renameDialog.value},on:{keyup:[function(a){return!a.type.indexOf("key")&&e._k(a.keyCode,"enter",13,a.key,"Enter")?null:e.confirmRename.apply(null,arguments)},function(a){return!a.type.indexOf("key")&&e._k(a.keyCode,"escape",void 0,a.key,void 0)?null:e.cancelRename.apply(null,arguments)}],input:function(a){a.target.composing||e.$set(e.renameDialog,"value",a.target.value)}}}),t("div",{staticClass:"flex justify-end gap-2 mt-4"},[t("button",{staticClass:"px-3 py-1 text-xs text-textMuted hover:text-white",on:{click:e.cancelRename}},[e._v("取消")]),t("button",{staticClass:"px-3 py-1 text-xs bg-accent text-white rounded hover:bg-blue-600",on:{click:e.confirmRename}},[e._v("确定")])])])]),t("CreatePageDialog",{attrs:{visible:e.createPageDialogVisible,"target-path":e.createPageTargetPath},on:{"update:visible":function(a){e.createPageDialogVisible=a},created:e.onPageCreated}}),t("CopyPathDialog",{ref:"copyPathDialog"})],1)},V=[],R=o(I,N,V,!1,null,"d033f82c");const z=R.exports,B={name:"TemplateSelectDialog",props:{visible:{type:Boolean,default:!1},basePath:{type:String,default:".txcode/design"}},data(){return{loading:!1,templates:[],selectedTemplate:"",searchText:""}},computed:{filteredTemplates(){if(!this.searchText)return this.templates;const s=this.searchText.toLowerCase();return this.templates.filter(e=>e.name.toLowerCase().includes(s))},selectedName(){const s=this.templates.find(e=>e.path===this.selectedTemplate);return s?s.name:""}},watch:{visible(s){s&&(this.loadTemplates(),this.selectedTemplate="",this.searchText="")}},methods:{async loadTemplates(){var s;this.loading=!0;try{const e=`${this.basePath}/.template`,i=((s=(await l.browseFilesystem(e)).data)==null?void 0:s.items)||[];this.templates=i.filter(a=>!a.is_directory&&a.name.endsWith(".html")).map(a=>({name:a.name,path:a.path}))}catch(e){console.error("Load templates failed:",e),this.templates=[]}finally{this.loading=!1,this.$nextTick(()=>{const e=this.$refs.searchInput;e&&e.focus()})}},handleConfirm(){this.selectedTemplate&&(this.$emit("select",this.selectedTemplate),this.$emit("update:visible",!1))},handleClose(){this.$emit("close")},handleVisibleChange(s){this.$emit("update:visible",s)}}};var E=function(){var e=this,t=e._self._c;return t("el-dialog",{attrs:{visible:e.visible,title:"选择模版",width:"420px","close-on-click-modal":!1},on:{"update:visible":e.handleVisibleChange,close:e.handleClose}},[t("div",{staticClass:"template-select-content"},[t("div",{staticClass:"template-search"},[t("input",{directives:[{name:"model",rawName:"v-model",value:e.searchText,expression:"searchText"}],ref:"searchInput",staticClass:"search-input",attrs:{placeholder:"搜索模版..."},domProps:{value:e.searchText},on:{input:function(i){i.target.composing||(e.searchText=i.target.value)}}})]),t("div",{staticClass:"template-list-container"},[e.loading?t("div",{staticClass:"empty-state"},[t("i",{staticClass:"fa-solid fa-spinner fa-spin mr-2"}),e._v(" 加载中... ")]):e.filteredTemplates.length===0?t("div",{staticClass:"empty-state"},[e._v(" "+e._s(e.searchText?"无匹配模版":"暂无模版,请先保存模版")+" ")]):e._e(),e._l(e.filteredTemplates,function(i){return t("div",{key:i.path,staticClass:"template-item",class:{"template-selected":e.selectedTemplate===i.path},on:{click:function(a){e.selectedTemplate=i.path},dblclick:e.handleConfirm}},[t("div",{staticClass:"template-name"},[e._v(e._s(i.name))]),t("div",{staticClass:"template-path"},[e._v(e._s(i.path))])])})],2),t("div",{staticClass:"template-select-footer"},[t("span",{staticClass:"selected-template"},[e._v(e._s(e.selectedName||"未选择"))]),t("button",{staticClass:"confirm-btn",attrs:{disabled:!e.selectedTemplate},on:{click:e.handleConfirm}},[e._v("选择")])])])])},q=[],L=o(B,E,q,!1,null,"2152b684");const A=L.exports,O={name:"DesignAiChat",components:{ModelSelectDialog:b,CommandDialog:v,FileSelectDialog:g,SkillSelectDialog:m,TemplateSelectDialog:A,ImagePreviewList:f,ResizableTextarea:p},mixins:[k()],props:{basePath:{type:String,default:".txcode/design"},currentPage:{type:String,default:""}},data(){return{inputMessage:"",disabled:!1,stopping:!1,promptTokens:0,logItems:[],modelName:"",modelSelectVisible:!1,commandDialogVisible:!1,fileSelectVisible:!1,skillSelectVisible:!1,templateSelectVisible:!1,skillCursorPos:-1,sessionId:"",sessionStatus:"idle",wsUnsubscribe:null,requestSeq:0}},watch:{currentPage:{immediate:!1,handler(s){this.loadSessionForPage(s)}}},async mounted(){await this.loadDefaultModel(),l.ws.init(),this.currentPage&&await this.loadSessionForPage(this.currentPage)},beforeDestroy(){this.wsUnsubscribe&&this.wsUnsubscribe()},methods:{getSessionJsonPath(){return this.basePath+"/session.json"},async readSessionJson(){var s;try{const e=await l.getFileContent(this.getSessionJsonPath());if(e&&((s=e.data)!=null&&s.content)){const t=JSON.parse(e.data.content);if(t.pageSessions){const i={};for(const[a,n]of Object.entries(t.pageSessions))a.endsWith(".html")&&a!=="session.json"&&(i[a]=n);Object.keys(i).length!==Object.keys(t.pageSessions).length&&(t.pageSessions=i,this.writeSessionJson(t).catch(()=>{}))}return t}}catch{}return{pageSessions:{}}},async writeSessionJson(s){await l.writeFile(this.getSessionJsonPath(),JSON.stringify(s,null,2))},async loadSessionForPage(s){var n;const e=++this.requestSeq;console.log("[DesignAiChat] loadSessionForPage called:",s,"seq:",e);const t=performance.now();if(!s||!s.endsWith(".html")){this.wsUnsubscribe&&(this.wsUnsubscribe(),this.wsUnsubscribe=null),this.sessionId="",this.logItems=[],this.promptTokens=0,this.sessionStatus="idle",this.$emit("status-change","idle"),console.log("[DesignAiChat] loadSessionForPage skipped (not html):",s);return}const i=await this.readSessionJson();if(this.requestSeq!==e)return;console.log("[DesignAiChat] sessionData loaded:",Object.keys(i.pageSessions||{}));const a=(n=i.pageSessions)==null?void 0:n[s];if(console.log("[DesignAiChat] pageSession for",s,":",!!a),a!=null&&a.sessionId)try{console.log("[DesignAiChat] loading existing session:",a.sessionId);const r=performance.now(),c=await l.getSession(a.sessionId);if(this.requestSeq!==e)return;if(console.log("[DesignAiChat] getSession took:",(performance.now()-r).toFixed(1),"ms"),c&&c.data){this.sessionId=a.sessionId,this.subscribeSession();const d=performance.now();if(await this.loadMessages(),this.requestSeq!==e)return;console.log("[DesignAiChat] loadMessages took:",(performance.now()-d).toFixed(1),"ms"),console.log("[DesignAiChat] loadSessionForPage done (existing), total:",(performance.now()-t).toFixed(1),"ms");return}}catch(r){console.error("[DesignAiChat] getSession failed:",r)}try{console.log("[DesignAiChat] creating new session for:",s);const r=await l.createSession(`设计页面: ${s}`);if(this.requestSeq!==e||(this.sessionId=r.data.id,i.pageSessions[s]={sessionId:this.sessionId},await this.writeSessionJson(i),this.requestSeq!==e))return;this.logItems=[],this.promptTokens=0,this.subscribeSession(),console.log("[DesignAiChat] loadSessionForPage done (new), total:",(performance.now()-t).toFixed(1),"ms")}catch(r){console.error("Create session failed:",r)}},async loadDefaultModel(){var s;try{const e=await l.getConfig("defaultModel");this.modelName=((s=e.data)==null?void 0:s.value)||""}catch(e){console.error("Load model failed:",e)}},async loadMessages(){if(this.sessionId)try{const s=await l.getMessages(this.sessionId);this.logItems=s.data||[],this.$nextTick(()=>this.scrollChatToBottom(!0))}catch(s){console.error("Load messages failed:",s)}},handleKeydown(s){if(s.key==="Enter")if(s.ctrlKey){const e=s.target,t=e.selectionStart,i=e.selectionEnd,a=this.inputMessage;this.inputMessage=a.substring(0,t)+`
16
+ `+a.substring(i),this.$nextTick(()=>{e.selectionStart=e.selectionEnd=t+1})}else s.preventDefault(),this.sendMessage()},async sendMessage(){const s=this.inputMessage.trim(),e=this.mediaFiles&&this.mediaFiles.length>0;if(!s&&!e||this.disabled)return;if(!this.sessionId){this.$message.error("请在左侧选择设计页面");return}this.wsUnsubscribe||this.subscribeSession();let t=s;this.currentPage&&(t=`当前设计页面:${this.currentPage}
17
+ 用户需求:${s}
18
+ 请基于以上设计页面路径,对该页面进行设计或修改。`),this.inputMessage="",this.disabled=!0,this.stopping=!1;const i=(this.mediaFiles||[]).filter(a=>!a.uploading&&a.filePath).map(a=>({filePath:a.filePath,type:a.type,dataUrl:a.dataUrl}));this.logItems.push({type:"chat",content:s,mediaFiles:i}),this.scrollChatToBottom(!0),l.sessionWsSend(this.sessionId,"chat",{message:t,sessionId:this.sessionId,modelName:this.modelName||void 0,agent:"design",mediaFiles:i.map(a=>({filePath:a.filePath,type:a.type}))}),this.mediaFiles=[]},stopChat(){!this.sessionId||this.stopping||(this.stopping=!0,l.sessionWsSend(this.sessionId,"stop",{sessionId:this.sessionId}))},subscribeSession(){this.sessionId&&(this.wsUnsubscribe&&this.wsUnsubscribe(),this.wsUnsubscribe=l.wsSubscribe(this.sessionId,{running_sessions:s=>{const t=((s==null?void 0:s.runningSessionIds)||[]).includes(this.sessionId);this.sessionStatus=t?"processing":"idle",this.disabled=t,this.$emit("status-change",this.sessionStatus)},step:s=>{var 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(()=>_(this.$refs.messagesContainer,{force:s,prevSnapshot:e}))},renderMarkdown(s){return s?x(s,{breaks:!0}):""},formatInput(s,e){try{const t=typeof e=="string"?JSON.parse(e):e;return s==="bash"||s==="execute_bash"?t.command+(t.workdir?` (${t.workdir})`:""):s==="read_file"?t.file_path+(t.offset?`:${t.offset}`:""):s==="edit_file"||s==="write_file"?t.file_path:s==="glob"||s==="find_files"?t.pattern+(t.directory?` (${t.directory})`:""):s==="grep"||s==="search_content"?`"${t.pattern}" (${t.directory||""})`:JSON.stringify(t)}catch{return e}},openModelSelector(){this.modelSelectVisible=!0},onModelSelected(s){const e=s.name.split("/");this.modelName=e.length>2?e.slice(1).join("/"):s.name,l.setConfig("defaultModel",this.modelName)},openCommandDialog(){this.commandDialogVisible=!0},handleExecuteCommand(s){this.inputMessage=s+" ",this.$nextTick(()=>{const e=this.$el.querySelector(".input-area textarea");e&&e.focus()})},openFileSelect(){this.fileSelectVisible=!0},onFileSelected(s){const e=this.inputMessage.lastIndexOf("@");e!==-1?this.inputMessage=this.inputMessage.slice(0,e)+s+" ":this.inputMessage+=s+" ",this.cancelFileSelect()},cancelFileSelect(){this.fileSelectVisible=!1},openSkillSelect(){const s=this.$el.querySelector(".input-area textarea");this.skillCursorPos=s?s.selectionStart:-1,this.skillSelectVisible=!0},onSkillSelected(s){const e=`[${s}] `,t=this.skillCursorPos>=0?this.skillCursorPos:0;this.inputMessage=this.inputMessage.slice(0,t)+e+this.inputMessage.slice(t),this.cancelSkillSelect()},cancelSkillSelect(){this.skillSelectVisible=!1},openTemplateSelect(){const s=this.$el.querySelector(".input-area textarea");this.skillCursorPos=s?s.selectionStart:-1,this.templateSelectVisible=!0},onTemplateSelected(s){const e=`【设计基础模版】${s} `,t=this.skillCursorPos>=0?this.skillCursorPos:0;this.inputMessage=this.inputMessage.slice(0,t)+e+this.inputMessage.slice(t)}}};var j=function(){var e=this,t=e._self._c;return t("div",{staticClass:"flex flex-col flex-1 min-h-0"},[t("div",{ref:"messagesContainer",staticClass:"chat-messages flex-1 overflow-y-auto px-3 py-2 min-h-0"},[e.logItems.length?e._e():t("div",{staticClass:"empty-state"},[t("i",{staticClass:"fa-solid fa-robot text-4xl mb-3 opacity-20 block text-center"}),t("p",{staticClass:"text-sm text-textMuted text-center"},[e._v("AI设计助手可协助您分析和优化设计")]),t("p",{staticClass:"text-xs text-textMuted text-center mt-1"},[e._v("Enter 发送,Ctrl+Enter 换行")])]),e._l(e.logItems,function(i,a){return[i.type==="chat"?t("div",{key:a,staticClass:"flex justify-end mb-3"},[t("div",{staticClass:"user-question"},[i.mediaFiles&&i.mediaFiles.length>0?t("div",{staticClass:"chat-images mb-1"},e._l(i.mediaFiles,function(n){return t("img",{key:n.filePath,staticClass:"chat-image-thumb",attrs:{src:n.url||n.dataUrl||n.filePath},on:{click:function(r){return r.stopPropagation(),e.openImagePreview(n)}}})}),0):e._e(),t("div",{staticClass:"text-sm"},[e._v(e._s(i.content))])])]):i.type==="system"?t("div",{key:a,staticClass:"system-message mb-2",domProps:{innerHTML:e._s(e.renderMarkdown(i.content))}}):i.type==="step"?[i.thought?t("div",{staticClass:"ai-thought mb-2",domProps:{innerHTML:e._s(e.renderMarkdown(i.thought))}}):e._e(),e._l(i.toolCalls,function(n,r){return t("div",{key:r,staticClass:"log-mute text-xs text-textMuted mb-1"},[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.openTemplateSelect,mousedown:function(i){i.preventDefault()}}},[e._v("选择模版")]),t("span",{staticClass:"separator"},[e._v("|")]),t("span",{staticClass:"status-action",on:{click:e.openCommandDialog,mousedown:function(i){i.preventDefault()}}},[e._v("命令")])]),t("div",{staticClass:"input-actions-right"},[t("el-button",{staticClass:"upload-btn",attrs:{disabled:e.disabled,size:"small"},on:{click:e.handleImageUpload}},[e._v("图片")]),e.disabled&&!e.stopping?t("el-button",{staticClass:"stop-btn",attrs:{type:"danger",size:"small"},on:{click:e.stopChat}},[e._v(" ■ 停止 ")]):e.stopping?t("el-button",{staticClass:"stop-btn",attrs:{type:"info",disabled:"",size:"small"}},[e._v(" 停止中... ")]):t("el-button",{staticClass:"send-btn",attrs:{type:"primary",disabled:!e.inputMessage.trim()&&(!e.mediaFiles||e.mediaFiles.length===0),size:"small"},on:{click:e.sendMessage}},[e._v(" 发送 ")])],1)])]),t("div",{staticClass:"status-bar"},[t("span",{class:e.sessionStatus==="processing"?"status-thinking":"status-ready"},[e.sessionStatus==="processing"?t("span",{staticClass:"thinking-spinner"}):e._e(),e._v(" "+e._s(e.sessionStatus==="processing"?"思考中":"✓ 就绪")+" ")]),t("span",{staticClass:"separator"},[e._v("|")]),t("span",{staticClass:"model-selector",on:{click:e.openModelSelector,mousedown:function(i){i.preventDefault()}}},[e._v(" 模型:"+e._s(e.modelName||"-")+" ▾ ")]),t("span",{staticClass:"separator"},[e._v("|")]),t("span",[e._v("会话:"+e._s(e.sessionId?e.sessionId.slice(0,8):"--------"))]),t("span",{staticClass:"separator"},[e._v("|")]),t("span",[e._v("token:"+e._s(e.promptTokens||0))])])],1),e.previewImage?t("div",{staticClass:"fixed inset-0 bg-black/50 z-50 flex items-center justify-center",on:{click:e.closeImagePreview}},[t("span",{staticClass:"absolute top-4 right-4 text-white text-2xl cursor-pointer"},[e._v("×")]),t("img",{staticClass:"max-w-[90vw] max-h-[90vh]",attrs:{src:e.previewImage.url||e.previewImage.dataUrl||e.previewImage.filePath},on:{click:function(i){i.stopPropagation()}}})]):e._e(),t("ModelSelectDialog",{attrs:{visible:e.modelSelectVisible,"current-model":e.modelName},on:{"update:visible":function(i){e.modelSelectVisible=i},select:e.onModelSelected}}),t("CommandDialog",{attrs:{visible:e.commandDialogVisible},on:{"update:visible":function(i){e.commandDialogVisible=i},execute:e.handleExecuteCommand}}),t("FileSelectDialog",{attrs:{visible:e.fileSelectVisible},on:{"update:visible":function(i){e.fileSelectVisible=i},select:e.onFileSelected,close:e.cancelFileSelect}}),t("SkillSelectDialog",{attrs:{visible:e.skillSelectVisible},on:{"update:visible":function(i){e.skillSelectVisible=i},select:e.onSkillSelected,close:e.cancelSkillSelect}}),t("TemplateSelectDialog",{attrs:{visible:e.templateSelectVisible,"base-path":".txcode/design"},on:{"update:visible":function(i){e.templateSelectVisible=i},select:e.onTemplateSelected}})],1)},W=[],U=o(O,j,W,!1,null,"7d70ef43");const J=U.exports,K={name:"DesignSidebar",components:{DesignPageTree:z,DesignAiChat:J},props:{basePath:{type:String,default:".txcode/design"}},data(){return{activeTab:"pages",currentPage:""}},methods:{setCurrentPage(s){this.currentPage=s,this.$refs.pageTree&&this.$refs.pageTree.selectByPath(s)}}};var H=function(){var e=this,t=e._self._c;return t("aside",{staticClass:"bg-panelHeader border border-contentBg flex flex-col shrink-0 overflow-hidden",staticStyle:{width:"480px"}},[t("div",{staticClass:"flex border-b border-contentBg bg-panelHeader"},[t("div",{staticClass:"flex-1 text-center px-3 py-2.5 cursor-pointer text-sm border-b-2 transition-colors",class:e.activeTab==="pages"?"border-accent text-white":"border-transparent text-textMuted hover:text-white",on:{click:function(i){e.activeTab="pages"}}},[t("i",{staticClass:"fa-solid fa-file-code mr-1"}),e._v(" 设计页面 ")]),t("div",{staticClass:"flex-1 text-center px-3 py-2.5 cursor-pointer text-sm border-b-2 transition-colors",class:e.activeTab==="ai"?"border-accent text-white":"border-transparent text-textMuted hover:text-white",on:{click:function(i){e.activeTab="ai"}}},[t("i",{staticClass:"fa-solid fa-robot mr-1"}),e._v(" AI设计助手 ")])]),t("DesignPageTree",{directives:[{name:"show",rawName:"v-show",value:e.activeTab==="pages",expression:"activeTab === 'pages'"}],ref:"pageTree",attrs:{"base-path":e.basePath},on:{"open-file":function(i){return e.$emit("open-file",i)},"current-page":function(i){e.currentPage=i},"file-changed":function(i){return e.$emit("file-changed")}}}),t("keep-alive",[e.activeTab==="ai"?t("DesignAiChat",{attrs:{"base-path":e.basePath,"current-page":e.currentPage},on:{"design-updated":function(i){return e.$emit("file-changed")},"status-change":function(i){return e.$emit("ai-status-change",i)}}}):e._e()],1)],1)},X=[],Y=o(K,H,X,!1,null,null);const G=Y.exports,Q={name:"DesignPreview",props:{fileContent:{type:String,default:""},fileName:{type:String,default:""},relativePath:{type:String,default:""}},data(){return{activeDevice:"web",refreshKey:0,renderIframe:!1,_relativePathVersion:0,deviceSizes:[{value:"app",label:"App",icon:"fa-solid fa-mobile-screen",width:375},{value:"web",label:"Web",icon:"fa-solid fa-desktop",width:0},{value:"pad",label:"Pad",icon:"fa-solid fa-tablet-screen-button",width:768}]}},computed:{previewSrc(){if(!this.relativePath)return"";const s=`/design_html/${encodeURI(this.relativePath)}?_=${this._relativePathVersion}`;return console.log("[DesignPreview] previewSrc computed:",s),s},iframeStyle(){return{width:"100%",height:"100%"}},frameStyle(){switch(this.activeDevice){case"app":return{width:"390px"};case"pad":return{width:"800px"};default:return{}}}},watch:{fileName:{immediate:!0,handler(s){s&&(s.includes("_app.html")?this.activeDevice="app":s.includes("_web.html")?this.activeDevice="web":s.includes("_pad.html")?this.activeDevice="pad":this.activeDevice="web",console.log("[DesignPreview] fileName changed:",s,"→ activeDevice:",this.activeDevice))}},relativePath(s,e){console.log("[DesignPreview] relativePath changed:",e,"→",s),s?(this._relativePathVersion++,console.log("[DesignPreview] _relativePathVersion:",this._relativePathVersion),this.renderIframe=!1,console.log("[DesignPreview] renderIframe set to false, scheduling recreate"),this.$nextTick(()=>{this.renderIframe=!0,console.log("[DesignPreview] renderIframe set to true, iframe should be created with src:",this.previewSrc)})):(this.renderIframe=!1,console.log("[DesignPreview] renderIframe set to false (no file)"))}},mounted(){console.log("[DesignPreview] mounted, relativePath:",this.relativePath)},updated(){console.log("[DesignPreview] updated, relativePath:",this.relativePath,"previewSrc:",this.previewSrc)},beforeDestroy(){console.log("[DesignPreview] beforeDestroy")},methods:{refreshPreview(){this.refreshKey++,this._relativePathVersion++,this.renderIframe=!1,this.$nextTick(()=>{this.renderIframe=!0,console.log("[DesignPreview] refreshPreview, iframe recreated")})},openInNewTab(){this.previewSrc&&window.open(this.previewSrc,"_blank")},onIframeLoad(){var s,e;console.log("[DesignPreview] iframe onload, src:",this.previewSrc);try{const t=this.$refs.previewFrame;if(!t)return;let i=null;try{i=(e=(s=t.contentWindow)==null?void 0:s.location)==null?void 0:e.pathname}catch{return}if(i&&i!=="/"){const a=i.match(/\/design_html\/(.+)$/);if(a){const n=decodeURIComponent(a[1]);n.endsWith(".html")&&!n.includes("..")&&!n.includes("~")&&n!==this.relativePath&&this.$emit("navigate",n)}}}catch(t){console.warn("[DesignPreview] onIframeLoad error:",t)}}}};var Z=function(){var e=this,t=e._self._c;return t("div",{staticClass:"flex flex-col h-full"},[t("div",{staticClass:"flex items-center gap-2 px-3 py-2 border-b border-border bg-sidebar"},[t("span",{staticClass:"text-xs text-textMuted mr-2"},[e._v("视口:")]),e._l(e.deviceSizes,function(i){return t("button",{key:i.value,staticClass:"px-3 py-1 text-xs rounded border transition-colors",class:e.activeDevice===i.value?"border-accent bg-accent/10 text-white":"border-transparent text-textMuted hover:border-gray-500",attrs:{title:i.label},on:{click:function(a){e.activeDevice=i.value}}},[t("i",{staticClass:"mr-1",class:i.icon}),e._v(e._s(i.label)+" ")])})],2),t("div",{staticClass:"flex-1 flex items-center justify-center overflow-auto bg-[#f5f5f5] p-4"},[e.relativePath?t("div",{staticClass:"device-frame flex flex-col self-stretch",class:`device-frame-${e.activeDevice}`,style:e.frameStyle},[t("div",{staticClass:"flex justify-end mb-2 shrink-0 gap-1"},[t("button",{staticClass:"px-2 py-0.5 text-textMuted hover:text-white text-xs rounded hover:bg-white/10 transition-colors",attrs:{title:"保存为模版"},on:{click:function(i){return e.$emit("save-template")}}},[e._v("保存模版")]),t("button",{staticClass:"p-1 text-textMuted hover:text-white text-xs rounded hover:bg-white/10 transition-colors",attrs:{title:"新窗口打开"},on:{click:e.openInNewTab}},[t("i",{staticClass:"fa-solid fa-up-right-from-square"})]),t("button",{staticClass:"p-1 text-textMuted hover:text-white text-xs rounded hover:bg-white/10 transition-colors",attrs:{title:"刷新预览"},on:{click:e.refreshPreview}},[t("i",{staticClass:"fa-solid fa-refresh"})])]),e.renderIframe?t("iframe",{ref:"previewFrame",staticClass:"w-full border-0",style:e.iframeStyle,attrs:{src:e.previewSrc,sandbox:"allow-scripts allow-same-origin allow-forms allow-modals allow-popups"},on:{load:e.onIframeLoad}}):e._e()]):t("div",{staticClass:"text-textMuted text-center mt-20"},[t("i",{staticClass:"fa-solid fa-eye text-6xl mb-4 opacity-20 block"}),t("p",[e._v("双击左侧 HTML 文件预览")])])])])},ee=[],te=o(Q,Z,ee,!1,null,"39c9eda3");const se=te.exports,ie={name:"DesignEditor",props:{fileContent:{type:String,default:""},fileName:{type:String,default:""},filePath:{type:String,default:""}},data(){return{editor:null,originalContent:"",contentChanged:!1,saving:!1}},watch:{fileContent:{immediate:!0,handler(s){if(!this.fileName||!this.editor&&(this.initEditor(),!this.editor))return;const e=s||"";this.editor.getValue()!==e&&(this.originalContent=e,this.editor.setValue(e),this.contentChanged=!1)}}},mounted(){this.$nextTick(()=>this.initEditor())},beforeDestroy(){this.editor&&(this.editor.dispose(),this.editor=null)},methods:{initEditor(){this.editor||this.$refs.editorContainer&&this.fileName&&(this.editor=w.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(y.CtrlCmd|P.KeyS,()=>{this.saveFile()}))},updateContent(s){if(!this.editor){this.initEditor(),this.$nextTick(()=>this.updateContent(s));return}this.originalContent=s,this.editor.setValue(s),this.contentChanged=!1},layout(){!this.editor&&this.fileName&&this.initEditor(),this.editor&&this.$nextTick(()=>this.editor.layout())},async saveFile(){if(!(!this.editor||!this.filePath)){this.saving=!0;try{const s=this.editor.getValue();await l.writeFile(this.filePath,s),this.originalContent=s,this.contentChanged=!1,this.$emit("content-saved",s),this.$emit("content-changed",!1),this.$message.success("文件已保存")}catch(s){console.error("Save failed:",s),this.$message.error("保存文件失败")}finally{this.saving=!1}}}}};var ae=function(){var e=this,t=e._self._c;return t("div",{staticClass:"flex flex-col h-full"},[e.fileName?e._e():t("div",{staticClass:"flex-1 flex items-center justify-center text-textMuted"},[e._m(0)]),t("div",{directives:[{name:"show",rawName:"v-show",value:e.fileName,expression:"fileName"}],ref:"editorContainer",staticClass:"monaco-editor-container flex-1"}),e.fileName?t("div",{staticClass:"h-8 bg-sidebar border-t border-border flex items-center justify-between px-3 shrink-0"},[t("div",{staticClass:"flex items-center gap-4 text-xs text-textMuted"},[t("span",[e._v(e._s(e.fileName))]),e.contentChanged?t("span",{staticClass:"text-yellow-500"},[e._v("已修改")]):e._e()]),t("div",{staticClass:"flex items-center gap-2"},[t("button",{staticClass:"p-1 text-textMuted hover:text-white text-xs rounded hover:bg-white/10 transition-colors",attrs:{title:"刷新内容"},on:{click:function(i){return e.$emit("refresh")}}},[t("i",{staticClass:"fa-solid fa-refresh"})]),t("button",{staticClass:"px-3 py-1 text-xs bg-accent text-white rounded hover:bg-blue-600 disabled:opacity-50 disabled:cursor-not-allowed",attrs:{disabled:!e.contentChanged||e.saving},on:{click:e.saveFile}},[e.saving?t("i",{staticClass:"fa-solid fa-spinner fa-spin mr-1"}):t("i",{staticClass:"fa-solid fa-save mr-1"}),e._v(" 保存 ")])])]):e._e()])},ne=[function(){var s=this,e=s._self._c;return e("div",{staticClass:"text-center"},[e("i",{staticClass:"fa-solid fa-file-code text-6xl mb-4 opacity-20 block"}),e("p",[s._v("双击左侧 HTML 文件编辑")])])}],le=o(ie,ae,ne,!1,null,"f53b2118");const re=le.exports,oe={name:"SaveTemplateDialog",props:{visible:{type:Boolean,default:!1},currentFilePath:{type:String,default:""},currentFileName:{type:String,default:""}},data(){return{templateName:"",saving:!1}},computed:{defaultName(){return this.currentFileName||""}},watch:{visible(s){s&&(this.templateName=this.currentFileName?this.currentFileName.replace(/\.html$/i,"")+"_模版":"",this.$nextTick(()=>{const e=this.$refs.nameInput;e&&(e.focus(),e.select())}))}},methods:{async handleConfirm(){var e;const s=this.templateName.trim();if(!(!s||this.saving)){this.saving=!0;try{let t=s;t.endsWith(".html")||(t+=".html");const a=((e=(await l.getFileContent(this.currentFilePath)).data)==null?void 0:e.content)||"",n=`.txcode/design/.template/${t}`;await l.writeFile(n,a),this.$message.success("模版保存成功"),this.$emit("success"),this.$emit("update:visible",!1)}catch(t){console.error("Save template failed:",t),this.$message.error("模版保存失败: "+(t.message||"未知错误"))}finally{this.saving=!1}}},handleClose(){this.$emit("update:visible",!1),this.$emit("close")},handleCancel(){this.$emit("update:visible",!1)},handleVisibleChange(s){this.$emit("update:visible",s)}}};var ce=function(){var e=this,t=e._self._c;return t("el-dialog",{attrs:{visible:e.visible,title:"保存为模版",width:"420px","close-on-click-modal":!1},on:{"update:visible":e.handleVisibleChange,close:e.handleClose}},[t("div",{staticClass:"save-template-content"},[t("div",{staticClass:"form-item"},[t("label",{staticClass:"form-label"},[e._v("模版名称")]),t("input",{directives:[{name:"model",rawName:"v-model",value:e.templateName,expression:"templateName"}],ref:"nameInput",staticClass:"form-input",attrs:{placeholder:e.defaultName||"输入模版名称"},domProps:{value:e.templateName},on:{keyup:function(i){return!i.type.indexOf("key")&&e._k(i.keyCode,"enter",13,i.key,"Enter")?null:e.handleConfirm.apply(null,arguments)},input:function(i){i.target.composing||(e.templateName=i.target.value)}}}),e.currentFileName?t("p",{staticClass:"form-hint"},[e._v("当前页面:"+e._s(e.currentFileName))]):e._e()]),t("div",{staticClass:"save-template-footer"},[t("button",{staticClass:"confirm-btn",attrs:{disabled:!e.templateName.trim()||e.saving},on:{click:e.handleConfirm}},[e._v(e._s(e.saving?"保存中...":"确定"))]),t("button",{staticClass:"cancel-btn",on:{click:e.handleCancel}},[e._v("取消")])])])])},de=[],he=o(oe,ce,de,!1,null,"30bde40e");const ue=he.exports,pe={name:"DesignView",components:{DesignSidebar:G,DesignPreview:se,DesignEditor:re,SaveTemplateDialog:ue},data(){return{rightTab:"preview",designBasePath:".txcode/design",fileContent:"",activeFileName:"",activeFilePath:"",relativePath:"",hasChanges:!1,templateDialogVisible:!1,isResizing:!1,aiStatus:"idle",unsubFileChanged:null}},mounted(){document.addEventListener("mousemove",this.handleResize),document.addEventListener("mouseup",this.stopResize),this.updateTitle(),this.initFromRoute(),this.unsubFileChanged=S.on("file:changed",s=>{this.onFileChanged(s)}),console.log("[DesignView][mounted] subscribed to file:changed")},watch:{rightTab(s){console.log("[DesignView] rightTab changed:",s),s==="editor"&&this.activeFilePath&&!this.fileContent&&(console.log("[DesignView] switching to editor, loading file content for:",this.activeFilePath),this.loadFileContent()),s==="editor"&&this.$nextTick(()=>{this.$refs.editor&&this.$refs.editor.layout()})},aiStatus(){this.updateTitle()},"$route.query.page":{handler(s){s&&s.endsWith(".html")&&s!==this.relativePath&&this.openDesignPage(s)}}},beforeDestroy(){document.removeEventListener("mousemove",this.handleResize),document.removeEventListener("mouseup",this.stopResize),this.unsubFileChanged&&(this.unsubFileChanged(),this.unsubFileChanged=null)},methods:{updateTitle(){var t;const s=((t=this.$route.meta)==null?void 0:t.title)||"AI设计";let e="";this.aiStatus==="processing"?e="⏳ ":this.aiStatus==="completed"&&(e="✅ "),document.title=`${e}${s} - TXCode`},initFromRoute(){const s=this.$route.query.page;s&&s.endsWith(".html")&&this.$nextTick(()=>{this.openDesignPage(s)})},onPreviewNavigate(s){this.openDesignPage(s)},onAiStatusChange(s){this.aiStatus=s,this.updateTitle()},openDesignPage(s){!s||!s.endsWith(".html")||(console.log("[DesignView] openDesignPage:",s),this.relativePath=s,this.activeFileName=s.split("/").pop(),this.activeFilePath=this.designBasePath+"/"+s,this.fileContent="",this.hasChanges=!1,this.rightTab="preview",this.$refs.sidebar&&this.$refs.sidebar.setCurrentPage(s),this.$route.query.page!==s&&this.$router.replace({query:{page:s}}).catch(()=>{}))},async openFile(s){if(console.log("[DesignView] openFile called, node:",s.name,"path:",s.path,"is_dir:",s.is_directory),s.is_directory)return;this.activeFilePath=s.path;const e=this.extractRelativePath(s.path);console.log("[DesignView] extractRelativePath result:",e),this.openDesignPage(e),console.log("[DesignView] openFile done, relativePath:",this.relativePath)},async loadFileContent(){var s;if(this.activeFilePath){console.log("[DesignView] loadFileContent:",this.activeFilePath);try{const e=performance.now(),t=await l.getFileContent(this.activeFilePath);console.log("[DesignView] getFileContent took:",(performance.now()-e).toFixed(1),"ms"),this.fileContent=((s=t.data)==null?void 0:s.content)||""}catch(e){console.error("[DesignView] loadFileContent failed:",e),this.fileContent=""}}},onContentChanged(s){this.hasChanges=s},onContentSaved(s){this.fileContent=s,this.hasChanges=!1},async refreshCurrentFile(){this.activeFilePath&&(console.log("[DesignView] refreshCurrentFile:",this.activeFilePath),await this.loadFileContent(),this.$refs.editor&&this.rightTab==="editor"&&this.$refs.editor.updateContent(this.fileContent))},onFileChanged(s){if(console.log("[DesignView] file:changed received",s),!s.filePath||!this.activeFilePath){console.log("[DesignView] file:changed skipped (no filePath or activeFilePath)");return}const e=s.filePath.replace(/\\/g,"/"),t=this.activeFilePath.replace(/\\/g,"/"),i=(this.designBasePath||".txcode/design").replace(/\\/g,"/");if(e.indexOf(i)===-1&&t.indexOf(e)===-1){console.log("[DesignView] file:changed skipped (not in designBasePath)");return}console.log("[DesignView] file:changed → refreshCurrentFile()"),this.$refs.preview&&this.$refs.preview.refreshPreview()},saveAsTemplate(){if(!this.activeFilePath){this.$message.warning("请先打开一个设计页面");return}this.templateDialogVisible=!0},onTemplateSaved(){},extractRelativePath(s){const e=["/.txcode/design/",".txcode/design/","\\.txcode\\design\\",".txcode\\design\\"];for(const t of e){const i=s.indexOf(t);if(i!==-1)return s.slice(i+t.length).replace(/\\/g,"/")}return""},startResize(s){this.isResizing=!0,document.body.style.cursor="col-resize",document.body.style.userSelect="none"},handleResize(s){if(!this.isResizing)return;const e=this.$refs.sidebar;if(!e)return;const t=s.clientX;t>=150&&t<=800&&(e.$el.style.width=t+"px")},stopResize(){this.isResizing=!1,document.body.style.cursor="",document.body.style.userSelect=""}}};var fe=function(){var e=this,t=e._self._c;return t("div",{staticClass:"flex-1 flex overflow-hidden"},[t("DesignSidebar",{ref:"sidebar",attrs:{"base-path":e.designBasePath},on:{"open-file":e.openFile,"file-changed":e.refreshCurrentFile,"ai-status-change":e.onAiStatusChange}}),t("div",{staticClass:"w-1 bg-border hover:bg-accent cursor-col-resize transition-colors",on:{mousedown:e.startResize}}),t("main",{staticClass:"flex-1 flex flex-col min-w-0 bg-contentBg"},[t("div",{staticClass:"flex border-b border-border bg-sidebar"},[t("div",{staticClass:"flex items-center"},[t("div",{staticClass:"px-4 py-2 cursor-pointer border-r border-border text-sm",class:e.rightTab==="preview"?"bg-contentBg text-white border-t-2 border-t-accent":"text-textMuted hover:bg-hoverBg",on:{click:function(i){e.rightTab="preview"}}},[t("i",{staticClass:"fa-solid fa-eye mr-1"}),e._v(" 预览 ")]),t("div",{staticClass:"px-4 py-2 cursor-pointer border-r border-border text-sm",class:e.rightTab==="editor"?"bg-contentBg text-white border-t-2 border-t-accent":"text-textMuted hover:bg-hoverBg",on:{click:function(i){e.rightTab="editor"}}},[t("i",{staticClass:"fa-solid fa-code mr-1"}),e._v(" 编辑 ")])])]),t("div",{staticClass:"flex-1 overflow-hidden"},[t("DesignPreview",{directives:[{name:"show",rawName:"v-show",value:e.rightTab==="preview",expression:"rightTab === 'preview'"}],ref:"preview",attrs:{"file-content":e.fileContent,"file-name":e.activeFileName,"relative-path":e.relativePath},on:{navigate:e.onPreviewNavigate,"save-template":e.saveAsTemplate}}),t("DesignEditor",{directives:[{name:"show",rawName:"v-show",value:e.rightTab==="editor",expression:"rightTab === 'editor'"}],ref:"editor",attrs:{"file-content":e.fileContent,"file-name":e.activeFileName,"file-path":e.activeFilePath},on:{"content-changed":e.onContentChanged,"content-saved":e.onContentSaved,refresh:e.refreshCurrentFile}})],1),t("div",{staticClass:"h-8 bg-sidebar border-t border-border flex items-center px-3"},[t("div",{staticClass:"flex items-center gap-4 text-xs text-textMuted"},[e.activeFilePath?t("span",[e._v(e._s(e.activeFilePath))]):t("span",{staticClass:"text-textMuted"},[e._v("双击左侧文件打开")]),e.hasChanges?t("span",{staticClass:"text-yellow-500"},[e._v("已修改")]):e._e()])])]),t("SaveTemplateDialog",{attrs:{visible:e.templateDialogVisible,"current-file-path":e.activeFilePath,"current-file-name":e.activeFileName},on:{"update:visible":function(i){e.templateDialogVisible=i},success:e.onTemplateSaved}})],1)},me=[],ge=o(pe,fe,me,!1,null,null);const xe=ge.exports;export{xe as default};