tianxincode 1.0.49 → 1.0.50

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (152) 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 +1 -0
  5. package/dist/core/db/db.service.d.ts.map +1 -1
  6. package/dist/core/db/db.service.js +7 -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/skill/categories_skill.d.ts +3 -0
  15. package/dist/gateway/api/skill/categories_skill.d.ts.map +1 -0
  16. package/dist/gateway/api/skill/categories_skill.js +11 -0
  17. package/dist/gateway/api/skill/categories_skill.js.map +1 -0
  18. package/dist/gateway/api/skill/detail_skill.js +2 -2
  19. package/dist/gateway/api/skill/detail_skill.js.map +1 -1
  20. package/dist/gateway/api/skill/install_skill.d.ts +3 -0
  21. package/dist/gateway/api/skill/install_skill.d.ts.map +1 -0
  22. package/dist/gateway/api/skill/install_skill.js +26 -0
  23. package/dist/gateway/api/skill/install_skill.js.map +1 -0
  24. package/dist/gateway/api/skill/published_skill.d.ts +3 -0
  25. package/dist/gateway/api/skill/published_skill.d.ts.map +1 -0
  26. package/dist/gateway/api/skill/published_skill.js +15 -0
  27. package/dist/gateway/api/skill/published_skill.js.map +1 -0
  28. package/dist/gateway/api/skill/skill_routes.d.ts.map +1 -1
  29. package/dist/gateway/api/skill/skill_routes.js +8 -12
  30. package/dist/gateway/api/skill/skill_routes.js.map +1 -1
  31. package/dist/gateway/api/skill/uninstall_skill.d.ts +3 -0
  32. package/dist/gateway/api/skill/uninstall_skill.d.ts.map +1 -0
  33. package/dist/gateway/api/skill/uninstall_skill.js +20 -0
  34. package/dist/gateway/api/skill/uninstall_skill.js.map +1 -0
  35. package/dist/gateway/api/songbing/auth_cancel_songbing.d.ts +3 -0
  36. package/dist/gateway/api/songbing/auth_cancel_songbing.d.ts.map +1 -0
  37. package/dist/gateway/api/songbing/auth_cancel_songbing.js +11 -0
  38. package/dist/gateway/api/songbing/auth_cancel_songbing.js.map +1 -0
  39. package/dist/gateway/api/songbing/auth_start_songbing.d.ts +3 -0
  40. package/dist/gateway/api/songbing/auth_start_songbing.d.ts.map +1 -0
  41. package/dist/gateway/api/songbing/auth_start_songbing.js +15 -0
  42. package/dist/gateway/api/songbing/auth_start_songbing.js.map +1 -0
  43. package/dist/gateway/api/songbing/auth_verify_songbing.d.ts +3 -0
  44. package/dist/gateway/api/songbing/auth_verify_songbing.d.ts.map +1 -0
  45. package/dist/gateway/api/songbing/auth_verify_songbing.js +15 -0
  46. package/dist/gateway/api/songbing/auth_verify_songbing.js.map +1 -0
  47. package/dist/gateway/api/songbing/config_songbing.d.ts +3 -0
  48. package/dist/gateway/api/songbing/config_songbing.d.ts.map +1 -0
  49. package/dist/gateway/api/songbing/config_songbing.js +6 -0
  50. package/dist/gateway/api/songbing/config_songbing.js.map +1 -0
  51. package/dist/gateway/api/songbing/save_config_songbing.d.ts +3 -0
  52. package/dist/gateway/api/songbing/save_config_songbing.d.ts.map +1 -0
  53. package/dist/gateway/api/songbing/save_config_songbing.js +12 -0
  54. package/dist/gateway/api/songbing/save_config_songbing.js.map +1 -0
  55. package/dist/gateway/api/songbing/songbing_routes.d.ts +3 -0
  56. package/dist/gateway/api/songbing/songbing_routes.d.ts.map +1 -0
  57. package/dist/gateway/api/songbing/songbing_routes.js +15 -0
  58. package/dist/gateway/api/songbing/songbing_routes.js.map +1 -0
  59. package/dist/gateway/api/songbing/sync_models_songbing.d.ts +3 -0
  60. package/dist/gateway/api/songbing/sync_models_songbing.d.ts.map +1 -0
  61. package/dist/gateway/api/songbing/sync_models_songbing.js +11 -0
  62. package/dist/gateway/api/songbing/sync_models_songbing.js.map +1 -0
  63. package/dist/gateway/api/spec/categories_spec.d.ts +3 -0
  64. package/dist/gateway/api/spec/categories_spec.d.ts.map +1 -0
  65. package/dist/gateway/api/spec/categories_spec.js +11 -0
  66. package/dist/gateway/api/spec/categories_spec.js.map +1 -0
  67. package/dist/gateway/api/spec/install_spec.d.ts +3 -0
  68. package/dist/gateway/api/spec/install_spec.d.ts.map +1 -0
  69. package/dist/gateway/api/spec/install_spec.js +26 -0
  70. package/dist/gateway/api/spec/install_spec.js.map +1 -0
  71. package/dist/gateway/api/spec/published_spec.d.ts +3 -0
  72. package/dist/gateway/api/spec/published_spec.d.ts.map +1 -0
  73. package/dist/gateway/api/spec/published_spec.js +18 -0
  74. package/dist/gateway/api/spec/published_spec.js.map +1 -0
  75. package/dist/gateway/api/spec/spec_routes.d.ts.map +1 -1
  76. package/dist/gateway/api/spec/spec_routes.js +9 -19
  77. package/dist/gateway/api/spec/spec_routes.js.map +1 -1
  78. package/dist/gateway/api/spec/uninstall_spec.d.ts +3 -0
  79. package/dist/gateway/api/spec/uninstall_spec.d.ts.map +1 -0
  80. package/dist/gateway/api/spec/uninstall_spec.js +20 -0
  81. package/dist/gateway/api/spec/uninstall_spec.js.map +1 -0
  82. package/dist/gateway/api/system/system_routes.d.ts.map +1 -1
  83. package/dist/gateway/api/system/system_routes.js +2 -0
  84. package/dist/gateway/api/system/system_routes.js.map +1 -1
  85. package/dist/gateway/api/system/version_check.d.ts +3 -0
  86. package/dist/gateway/api/system/version_check.d.ts.map +1 -0
  87. package/dist/gateway/api/system/version_check.js +47 -0
  88. package/dist/gateway/api/system/version_check.js.map +1 -0
  89. package/dist/index.js +2 -0
  90. package/dist/index.js.map +1 -1
  91. package/dist/modules/spec/index.d.ts +0 -1
  92. package/dist/modules/spec/index.d.ts.map +1 -1
  93. package/dist/modules/spec/index.js +0 -1
  94. package/dist/modules/spec/index.js.map +1 -1
  95. package/dist/modules/spec/spec.injector.d.ts.map +1 -1
  96. package/dist/modules/spec/spec.injector.js +2 -24
  97. package/dist/modules/spec/spec.injector.js.map +1 -1
  98. package/dist/repository/index.d.ts +2 -0
  99. package/dist/repository/index.d.ts.map +1 -1
  100. package/dist/repository/index.js +1 -0
  101. package/dist/repository/index.js.map +1 -1
  102. package/dist/repository/system.repository.d.ts +18 -0
  103. package/dist/repository/system.repository.d.ts.map +1 -0
  104. package/dist/repository/system.repository.js +14 -0
  105. package/dist/repository/system.repository.js.map +1 -0
  106. package/dist/services/hub/txcode_hub.service.d.ts +98 -0
  107. package/dist/services/hub/txcode_hub.service.d.ts.map +1 -0
  108. package/dist/services/hub/txcode_hub.service.js +173 -0
  109. package/dist/services/hub/txcode_hub.service.js.map +1 -0
  110. package/dist/services/songbing/songbing.service.d.ts +30 -0
  111. package/dist/services/songbing/songbing.service.d.ts.map +1 -0
  112. package/dist/services/songbing/songbing.service.js +155 -0
  113. package/dist/services/songbing/songbing.service.js.map +1 -0
  114. package/dist/services/system/device-sync.service.d.ts +2 -0
  115. package/dist/services/system/device-sync.service.d.ts.map +1 -0
  116. package/dist/services/system/device-sync.service.js +51 -0
  117. package/dist/services/system/device-sync.service.js.map +1 -0
  118. package/package.json +2 -1
  119. package/web/dist/assets/{ConfirmDialog-B03GcCHQ.js → ConfirmDialog-CINqhvEA.js} +1 -1
  120. package/web/dist/assets/PcLayout-DEl_7OzB.js +1 -0
  121. package/web/dist/assets/{aiLogsView-Bt8Xg1Qx.js → aiLogsView-m_EDQ3Z2.js} +1 -1
  122. package/web/dist/assets/{cssMode-CBb6D87U.js → cssMode-4Nt4dQN8.js} +1 -1
  123. package/web/dist/assets/{customActionsView-DdjnHzwm.js → customActionsView-CqA23zc4.js} +1 -1
  124. package/web/dist/assets/{deployView-Cj51_Job.js → deployView-CZIOYWpA.js} +1 -1
  125. package/web/dist/assets/{designView-RT8tKEN9.js → designView-vScFop-k.js} +1 -1
  126. package/web/dist/assets/{devWorkflowView-BTozmaiN.js → devWorkflowView-BBDYiAz5.js} +1 -1
  127. package/web/dist/assets/{devWorkflowViewApp-DLslXEq9.js → devWorkflowViewApp-DA-U7e-D.js} +1 -1
  128. package/web/dist/assets/{fileZihao-CtZ4bUIH.js → fileZihao-D2TT5yyQ.js} +1 -1
  129. package/web/dist/assets/{freemarker2-CX3jc3l2.js → freemarker2-BIItB8xo.js} +1 -1
  130. package/web/dist/assets/{gitChanges-DFRvzL5I.js → gitChanges-Bl5ksKLW.js} +1 -1
  131. package/web/dist/assets/{gitChangesApp-ZI7-V8oB.js → gitChangesApp-dzIfGmtz.js} +1 -1
  132. package/web/dist/assets/{handlebars-CTaQD6FN.js → handlebars-BsyQEHQy.js} +1 -1
  133. package/web/dist/assets/{html-BruJsfYv.js → html-BhwQtsug.js} +1 -1
  134. package/web/dist/assets/{htmlMode-wewroXLr.js → htmlMode-DWCjFBRw.js} +1 -1
  135. package/web/dist/assets/{index-Cn73hS12.js → index-BWmvR_0d.js} +150 -150
  136. package/web/dist/assets/{index-C0xmVTIn.css → index-DzNPtEQX.css} +1 -1
  137. package/web/dist/assets/{javascript-B4ku8P1-.js → javascript-DXwUJSTZ.js} +1 -1
  138. package/web/dist/assets/{jsonMode-BIvVuBMG.js → jsonMode-BnmFmR-Q.js} +1 -1
  139. package/web/dist/assets/{liquid-Bo3G0Ep7.js → liquid-DDyzdvJI.js} +1 -1
  140. package/web/dist/assets/{mdx-Duv0ylZz.js → mdx-BmcHTEVO.js} +1 -1
  141. package/web/dist/assets/{mediaChat-RT7iqqYb.js → mediaChat-BAOZIeJr.js} +1 -1
  142. package/web/dist/assets/{python-CEhCctGm.js → python-CS2xzwXn.js} +1 -1
  143. package/web/dist/assets/{razor-DPK8nTD7.js → razor-DmA5x3s1.js} +1 -1
  144. package/web/dist/assets/{taskView-sOyebRqn.js → taskView-BaKz6N0T.js} +1 -1
  145. package/web/dist/assets/{terminalView-GTYtDlus.js → terminalView-ByU-IRop.js} +1 -1
  146. package/web/dist/assets/{tsMode-BZvUU1nf.js → tsMode-BzdGwv1C.js} +1 -1
  147. package/web/dist/assets/{typescript-CmEn-k1B.js → typescript-DqgHOT1h.js} +1 -1
  148. package/web/dist/assets/{wikiView-CRjg-cZ8.js → wikiView-CH95iVWL.js} +1 -1
  149. package/web/dist/assets/{xml-bjvdKeyy.js → xml-DBiYZn44.js} +1 -1
  150. package/web/dist/assets/{yaml-N5RXWxJk.js → yaml-CTPYHtxL.js} +1 -1
  151. package/web/dist/index.html +2 -2
  152. package/web/dist/assets/PcLayout-ZTdJNg7G.js +0 -1
@@ -0,0 +1,173 @@
1
+ import * as https from 'node:https';
2
+ import * as http from 'node:http';
3
+ import config from '../../config/tx.config.js';
4
+ let _hubUrl;
5
+ function getHubUrl() {
6
+ if (!_hubUrl) {
7
+ _hubUrl = config.txcodeHub;
8
+ }
9
+ return _hubUrl;
10
+ }
11
+ function httpRequest(method, path, body) {
12
+ return new Promise((resolve, reject) => {
13
+ const hubUrl = getHubUrl();
14
+ const urlStr = hubUrl + path;
15
+ const parsedUrl = new URL(urlStr);
16
+ const isHttps = parsedUrl.protocol === 'https:';
17
+ const requestModule = isHttps ? https : http;
18
+ const bodyStr = body ? JSON.stringify(body) : '';
19
+ const headers = {};
20
+ if (body) {
21
+ headers['Content-Type'] = 'application/json';
22
+ headers['Content-Length'] = String(Buffer.byteLength(bodyStr));
23
+ }
24
+ const req = requestModule.request({
25
+ hostname: parsedUrl.hostname,
26
+ port: parsedUrl.port || (isHttps ? 443 : 80),
27
+ path: parsedUrl.pathname + parsedUrl.search,
28
+ method,
29
+ headers,
30
+ rejectUnauthorized: false,
31
+ timeout: 15000,
32
+ }, (res) => {
33
+ let data = '';
34
+ res.on('data', (chunk) => { data += chunk.toString(); });
35
+ res.on('end', () => {
36
+ try {
37
+ resolve(JSON.parse(data));
38
+ }
39
+ catch {
40
+ reject(new Error(`Invalid JSON response: ${data.substring(0, 200)}`));
41
+ }
42
+ });
43
+ });
44
+ req.on('error', (err) => reject(err));
45
+ req.on('timeout', () => { req.destroy(); reject(new Error('Request timeout')); });
46
+ if (bodyStr) {
47
+ req.write(bodyStr);
48
+ }
49
+ req.end();
50
+ });
51
+ }
52
+ function httpDownload(path) {
53
+ return new Promise((resolve, reject) => {
54
+ const hubUrl = getHubUrl();
55
+ const urlStr = hubUrl + path;
56
+ const parsedUrl = new URL(urlStr);
57
+ const isHttps = parsedUrl.protocol === 'https:';
58
+ const requestModule = isHttps ? https : http;
59
+ const req = requestModule.request({
60
+ hostname: parsedUrl.hostname,
61
+ port: parsedUrl.port || (isHttps ? 443 : 80),
62
+ path: parsedUrl.pathname + parsedUrl.search,
63
+ method: 'GET',
64
+ rejectUnauthorized: false,
65
+ timeout: 60000,
66
+ }, (res) => {
67
+ if (res.statusCode && res.statusCode >= 400) {
68
+ let body = '';
69
+ res.on('data', (chunk) => { body += chunk.toString(); });
70
+ res.on('end', () => reject(new Error(`Download failed: ${res.statusCode} ${body}`)));
71
+ return;
72
+ }
73
+ const chunks = [];
74
+ res.on('data', (chunk) => chunks.push(chunk));
75
+ res.on('end', () => resolve(Buffer.concat(chunks)));
76
+ });
77
+ req.on('error', (err) => reject(err));
78
+ req.on('timeout', () => { req.destroy(); reject(new Error('Download timeout')); });
79
+ req.end();
80
+ });
81
+ }
82
+ class TxcodeHubService {
83
+ async fetchCategories() {
84
+ const res = await httpRequest('GET', '/api/skill_category/list_skill_category');
85
+ if (res.code !== 200) {
86
+ throw new Error(res.message || 'Failed to fetch categories');
87
+ }
88
+ return res.data || [];
89
+ }
90
+ async fetchPublishedSkills(params) {
91
+ const queryParts = [];
92
+ if (params.page)
93
+ queryParts.push(`page=${params.page}`);
94
+ if (params.page_size)
95
+ queryParts.push(`page_size=${params.page_size}`);
96
+ if (params.keyword)
97
+ queryParts.push(`keyword=${encodeURIComponent(params.keyword)}`);
98
+ if (params.category_id)
99
+ queryParts.push(`category_id=${params.category_id}`);
100
+ const query = queryParts.length > 0 ? '?' + queryParts.join('&') : '';
101
+ const res = await httpRequest('GET', '/api/skill/list_published_skill' + query);
102
+ if (res.code !== 200) {
103
+ throw new Error(res.message || 'Failed to fetch published skills');
104
+ }
105
+ return res.data || { total: 0, page: 1, page_size: 20, list: [] };
106
+ }
107
+ async downloadSkillZip(skillId) {
108
+ return httpDownload(`/api/skill/download_skill?id=${skillId}`);
109
+ }
110
+ async fetchSpecCategories() {
111
+ const res = await httpRequest('GET', '/api/spec_category/list_spec_category');
112
+ if (res.code !== 200) {
113
+ throw new Error(res.message || 'Failed to fetch spec categories');
114
+ }
115
+ return res.data || [];
116
+ }
117
+ async fetchPublishedSpecs(params) {
118
+ const queryParts = [];
119
+ if (params.page)
120
+ queryParts.push(`page=${params.page}`);
121
+ if (params.page_size)
122
+ queryParts.push(`page_size=${params.page_size}`);
123
+ if (params.keyword)
124
+ queryParts.push(`keyword=${encodeURIComponent(params.keyword)}`);
125
+ if (params.category_id)
126
+ queryParts.push(`category_id=${params.category_id}`);
127
+ if (params.platform_category)
128
+ queryParts.push(`platform_category=${encodeURIComponent(params.platform_category)}`);
129
+ const query = queryParts.length > 0 ? '?' + queryParts.join('&') : '';
130
+ const res = await httpRequest('GET', '/api/spec/list_published_spec' + query);
131
+ if (res.code !== 200) {
132
+ throw new Error(res.message || 'Failed to fetch published specs');
133
+ }
134
+ return res.data || { total: 0, page: 1, page_size: 20, list: [] };
135
+ }
136
+ async fetchSpecDetail(specId) {
137
+ try {
138
+ const res = await httpRequest('GET', `/api/spec/public_spec_detail?id=${specId}`);
139
+ if (res.code !== 200) {
140
+ return null;
141
+ }
142
+ return res.data || null;
143
+ }
144
+ catch {
145
+ return null;
146
+ }
147
+ }
148
+ async downloadSpecZip(specId) {
149
+ return httpDownload(`/api/spec/download_spec?id=${specId}`);
150
+ }
151
+ async reportUsage(deviceId, deviceType) {
152
+ try {
153
+ await httpRequest('POST', '/api/usage/report_usage', { device_id: deviceId, device_type: deviceType });
154
+ }
155
+ catch {
156
+ // 静默失败
157
+ }
158
+ }
159
+ async fetchLatestVersion() {
160
+ try {
161
+ const res = await httpRequest('GET', '/api/version/list_published_version?page=1&page_size=1');
162
+ if (res.code !== 200 || !res.data?.list?.length) {
163
+ return null;
164
+ }
165
+ return res.data.list[0];
166
+ }
167
+ catch {
168
+ return null;
169
+ }
170
+ }
171
+ }
172
+ export const txcodeHubService = new TxcodeHubService();
173
+ //# sourceMappingURL=txcode_hub.service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"txcode_hub.service.js","sourceRoot":"","sources":["../../../src/services/hub/txcode_hub.service.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,YAAY,CAAC;AACpC,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,MAAM,MAAM,2BAA2B,CAAC;AA6F/C,IAAI,OAA2B,CAAC;AAEhC,SAAS,SAAS;IAChB,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,OAAO,GAAG,MAAM,CAAC,SAAS,CAAC;IAC7B,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC;AAED,SAAS,WAAW,CAAI,MAAc,EAAE,IAAY,EAAE,IAAc;IAClE,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACrC,MAAM,MAAM,GAAG,SAAS,EAAE,CAAC;QAC3B,MAAM,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC;QAC7B,MAAM,SAAS,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,CAAC;QAClC,MAAM,OAAO,GAAG,SAAS,CAAC,QAAQ,KAAK,QAAQ,CAAC;QAChD,MAAM,aAAa,GAAG,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC;QAE7C,MAAM,OAAO,GAAG,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC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AC;QAC1B,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,IAAI,CAAC;QACd,CAAC;IACH,CAAC;CACF;AAED,MAAM,CAAC,MAAM,gBAAgB,GAAG,IAAI,gBAAgB,EAAE,CAAC"}
@@ -0,0 +1,30 @@
1
+ interface StartAuthResult {
2
+ key: string;
3
+ auth_url: string;
4
+ }
5
+ interface VerifyAuthResult {
6
+ active: boolean;
7
+ syncedModels: number;
8
+ }
9
+ interface SyncModelsResult {
10
+ count: number;
11
+ }
12
+ export declare class SongbingService {
13
+ getConfig(): {
14
+ platformUrl: string;
15
+ };
16
+ private getPlatformUrl;
17
+ saveConfig(config: {
18
+ platformUrl: string;
19
+ }): {
20
+ platformUrl: string;
21
+ };
22
+ startAuth(platformUrl: string): Promise<StartAuthResult>;
23
+ verifyAuth(key: string): Promise<VerifyAuthResult>;
24
+ cancelAuth(): Promise<void>;
25
+ syncModels(): Promise<SyncModelsResult>;
26
+ private syncModelsInternal;
27
+ }
28
+ export declare const songbingService: SongbingService;
29
+ export {};
30
+ //# sourceMappingURL=songbing.service.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"songbing.service.d.ts","sourceRoot":"","sources":["../../../src/services/songbing/songbing.service.ts"],"names":[],"mappings":"AAQA,UAAU,eAAe;IACvB,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,UAAU,gBAAgB;IACxB,MAAM,EAAE,OAAO,CAAC;IAChB,YAAY,EAAE,MAAM,CAAC;CACtB;AAED,UAAU,gBAAgB;IACxB,KAAK,EAAE,MAAM,CAAC;CACf;AA6CD,qBAAa,eAAe;IAC1B,SAAS;;;IAKT,OAAO,CAAC,cAAc;IAQtB,UAAU,CAAC,MAAM,EAAE;QAAE,WAAW,EAAE,MAAM,CAAA;KAAE;;;IAKpC,SAAS,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC;IA+BxD,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAsDlD,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAa3B,UAAU,IAAI,OAAO,CAAC,gBAAgB,CAAC;YAU/B,kBAAkB;CA8CjC;AAED,eAAO,MAAM,eAAe,iBAAwB,CAAC"}
@@ -0,0 +1,155 @@
1
+ import { configService } from '../config/index.js';
2
+ import { providerAuthRepository } from '../../repository/provider_auth.repository.js';
3
+ import { configRepository } from '../../repository/config.repository.js';
4
+ import txConfig from '../../config/tx.config.js';
5
+ const PROVIDER_NAME = '自建AI平台';
6
+ const CONFIG_KEY_PLATFORM_URL = 'songbing.platformUrl';
7
+ export class SongbingService {
8
+ getConfig() {
9
+ const platformUrl = configService.get(CONFIG_KEY_PLATFORM_URL) || txConfig.songbing.platformUrl || '';
10
+ return { platformUrl };
11
+ }
12
+ getPlatformUrl() {
13
+ const { platformUrl } = this.getConfig();
14
+ if (!platformUrl) {
15
+ throw new Error('未配置松饼AI平台地址');
16
+ }
17
+ return platformUrl;
18
+ }
19
+ saveConfig(config) {
20
+ configService.set(CONFIG_KEY_PLATFORM_URL, config.platformUrl);
21
+ return this.getConfig();
22
+ }
23
+ async startAuth(platformUrl) {
24
+ this.saveConfig({ platformUrl });
25
+ const res = await fetch(`${platformUrl}/api/appkey/generate_appkey`, {
26
+ method: 'POST',
27
+ headers: { 'Content-Type': 'application/json' },
28
+ body: JSON.stringify({}),
29
+ });
30
+ if (!res.ok) {
31
+ throw new Error(`生成认证Key失败: HTTP ${res.status}`);
32
+ }
33
+ const json = (await res.json());
34
+ if (json.code !== 200) {
35
+ throw new Error(`生成认证Key失败: ${json.message}`);
36
+ }
37
+ const { key, auth_url } = json.data;
38
+ providerAuthRepository.upsert({
39
+ id: PROVIDER_NAME,
40
+ providerName: PROVIDER_NAME,
41
+ key,
42
+ authUrl: auth_url,
43
+ active: false,
44
+ });
45
+ return { key, auth_url };
46
+ }
47
+ async verifyAuth(key) {
48
+ const platformUrl = this.getPlatformUrl();
49
+ const res = await fetch(`${platformUrl}/api/appkey/verify_appkey`, {
50
+ method: 'POST',
51
+ headers: { 'Content-Type': 'application/json' },
52
+ body: JSON.stringify({ key }),
53
+ });
54
+ if (!res.ok) {
55
+ throw new Error(`验证Key失败: HTTP ${res.status}`);
56
+ }
57
+ const json = (await res.json());
58
+ if (json.code !== 200) {
59
+ return { active: false, syncedModels: 0 };
60
+ }
61
+ if (!json.data?.active) {
62
+ return { active: false, syncedModels: 0 };
63
+ }
64
+ providerAuthRepository.upsert({
65
+ id: PROVIDER_NAME,
66
+ providerName: PROVIDER_NAME,
67
+ key,
68
+ authUrl: '',
69
+ active: true,
70
+ });
71
+ const existingProvider = configRepository.listProviders().find(p => p.name === PROVIDER_NAME);
72
+ let providerId;
73
+ if (existingProvider) {
74
+ configRepository.updateProvider(existingProvider.id, { apiKey: key });
75
+ providerId = existingProvider.id;
76
+ }
77
+ else {
78
+ providerId = configRepository.insertProvider({
79
+ name: PROVIDER_NAME,
80
+ apiKey: key,
81
+ baseUrl: platformUrl + '/api/v1',
82
+ enabled: true,
83
+ });
84
+ }
85
+ let syncedModels = 0;
86
+ try {
87
+ syncedModels = await this.syncModelsInternal(providerId, platformUrl);
88
+ }
89
+ catch {
90
+ // 模型同步失败不影响认证成功
91
+ }
92
+ return { active: true, syncedModels };
93
+ }
94
+ async cancelAuth() {
95
+ providerAuthRepository.delete(PROVIDER_NAME);
96
+ const provider = configRepository.listProviders().find(p => p.name === PROVIDER_NAME);
97
+ if (provider) {
98
+ const models = configRepository.listModels(provider.id);
99
+ for (const m of models) {
100
+ configRepository.deleteModel(m.id);
101
+ }
102
+ configRepository.deleteProvider(provider.id);
103
+ }
104
+ }
105
+ async syncModels() {
106
+ const provider = configRepository.listProviders().find(p => p.name === PROVIDER_NAME);
107
+ if (!provider) {
108
+ throw new Error('未找到自建AI平台提供商,请先完成认证');
109
+ }
110
+ const platformUrl = this.getPlatformUrl();
111
+ const count = await this.syncModelsInternal(provider.id, platformUrl);
112
+ return { count };
113
+ }
114
+ async syncModelsInternal(providerId, platformUrl) {
115
+ const res = await fetch(`${platformUrl}/api/common/scene_models`, {
116
+ method: 'GET',
117
+ });
118
+ if (!res.ok) {
119
+ throw new Error(`获取模型列表失败: HTTP ${res.status}`);
120
+ }
121
+ const json = (await res.json());
122
+ if (json.code !== 200) {
123
+ throw new Error(`获取模型列表失败: ${json.message}`);
124
+ }
125
+ const scenes = json.data || [];
126
+ const allModels = [];
127
+ for (const scene of scenes) {
128
+ if (scene.models && Array.isArray(scene.models)) {
129
+ allModels.push(...scene.models);
130
+ }
131
+ }
132
+ if (allModels.length === 0) {
133
+ return 0;
134
+ }
135
+ const existingModels = configRepository.listModels(providerId);
136
+ const existingNames = new Set(existingModels.map(m => m.name));
137
+ let count = 0;
138
+ for (const m of allModels) {
139
+ const modelName = m.model_name;
140
+ if (!existingNames.has(modelName)) {
141
+ configRepository.insertModel({
142
+ providerId,
143
+ name: modelName,
144
+ contextWindow: 4096,
145
+ maxOutputTokens: 4096,
146
+ enabled: true,
147
+ });
148
+ count++;
149
+ }
150
+ }
151
+ return count;
152
+ }
153
+ }
154
+ export const songbingService = new SongbingService();
155
+ //# sourceMappingURL=songbing.service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"songbing.service.js","sourceRoot":"","sources":["../../../src/services/songbing/songbing.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,sBAAsB,EAAE,MAAM,8CAA8C,CAAC;AACtF,OAAO,EAAE,gBAAgB,EAAE,MAAM,uCAAuC,CAAC;AACzE,OAAO,QAAQ,MAAM,2BAA2B,CAAC;AAEjD,MAAM,aAAa,GAAG,QAAQ,CAAC;AAC/B,MAAM,uBAAuB,GAAG,sBAAsB,CAAC;AA2DvD,MAAM,OAAO,eAAe;IAC1B,SAAS;QACP,MAAM,WAAW,GAAG,aAAa,CAAC,GAAG,CAAS,uBAAuB,CAAC,IA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,EAAE,CAAC;gBAChD,SAAS,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC;YAClC,CAAC;QACH,CAAC;QAED,IAAI,SAAS,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAC3B,OAAO,CAAC,CAAC;QACX,CAAC;QAED,MAAM,cAAc,GAAG,gBAAgB,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC;QAC/D,MAAM,aAAa,GAAG,IAAI,GAAG,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;QAE/D,IAAI,KAAK,GAAG,CAAC,CAAC;QACd,KAAK,MAAM,CAAC,IAAI,SAAS,EAAE,CAAC;YAC1B,MAAM,SAAS,GAAG,CAAC,CAAC,UAAU,CAAC;YAC/B,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,SAAS,CAAC,EAAE,CAAC;gBAClC,gBAAgB,CAAC,WAAW,CAAC;oBAC3B,UAAU;oBACV,IAAI,EAAE,SAAS;oBACf,aAAa,EAAE,IAAI;oBACnB,eAAe,EAAE,IAAI;oBACrB,OAAO,EAAE,IAAI;iBACd,CAAC,CAAC;gBACH,KAAK,EAAE,CAAC;YACV,CAAC;QACH,CAAC;QAED,OAAO,KAAK,CAAC;IACf,CAAC;CACF;AAED,MAAM,CAAC,MAAM,eAAe,GAAG,IAAI,eAAe,EAAE,CAAC"}
@@ -0,0 +1,2 @@
1
+ export declare function syncOnStartup(): void;
2
+ //# sourceMappingURL=device-sync.service.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"device-sync.service.d.ts","sourceRoot":"","sources":["../../../src/services/system/device-sync.service.ts"],"names":[],"mappings":"AA+BA,wBAAgB,aAAa,IAAI,IAAI,CAoBpC"}
@@ -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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,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.50",
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-BWmvR_0d.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 as o,a as i}from"./index-BWmvR_0d.js";const l={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 c=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)])},d=[],h=o(l,c,d,!1,null,"e90f8022");const f=h.exports,u={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 p=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()},v=[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 ")])])}],b=o(u,p,v,!1,null,null);const m=b.exports,x={name:"Layout",components:{SelectProjectDialog:f,VersionUpgradeDialog:m},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 w=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 n;return t("el-dropdown-item",{key:r.id,attrs:{command:r.id}},[t("span",{class:r.id===((n=e.currentProject)==null?void 0:n.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(),e._m(1),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(2),t("VersionUpgradeDialog",{attrs:{visible:e.showUpgradeDialog,localVersion:e.systemVersion,latestInfo:e.latestVersionInfo},on:{close:function(r){e.showUpgradeDialog=!1}}})],1)},_=[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("span",{staticClass:"text-xs text-textMuted mr-2"},[e("i",{staticClass:"fa-solid fa-circle text-green-500 text-[8px]"}),s._v(" Server Connected")])},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")])])])}],g=o(x,w,_,!1,null,null);const y=g.exports;export{y 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-BWmvR_0d.js";const c=[{key:"ai_call_logs",name:"AI 日志",icon:"fa-solid fa-robot text-xs"}],p={name:"AiLogsView",data(){return{logTypes:c,selectedLogType:c[0],logs:[],page:1,pageSize:20,total:0,totalPages:1,sessions:[],loading:!1,filters:{callType:"",sessionId:"",startTime:"",endTime:""}}},async created(){await this.loadSessions(),await this.loadLogs()},methods:{async loadSessions(){try{const s=await n.getSessions(100,0);this.sessions=s.data||[]}catch(s){console.error("Load sessions failed:",s)}},selectLogType(s){this.selectedLogType=s,this.resetFilters()},async loadLogs(){this.loading=!0;try{const s=await n.getAiCallLogs(this.page,this.pageSize);let t=s.data.rows||[];if(this.filters.callType&&(t=t.filter(e=>e.call_type===this.filters.callType)),this.filters.sessionId&&(t=t.filter(e=>e.session_id&&e.session_id.includes(this.filters.sessionId))),this.filters.startTime){const e=new Date(this.filters.startTime).getTime();t=t.filter(l=>new Date(l.request_time).getTime()>=e)}if(this.filters.endTime){const e=new Date(this.filters.endTime).getTime();t=t.filter(l=>new Date(l.request_time).getTime()<=e)}this.logs=t,this.total=s.data.total,this.totalPages=s.data.totalPages}catch(s){console.error("Load logs failed:",s),this.logs=[]}finally{this.loading=!1}},resetFilters(){this.filters.callType="",this.filters.sessionId="",this.filters.startTime="",this.filters.endTime="",this.page=1,this.loadLogs()},async prevPage(){this.page>1&&(this.page--,await this.loadLogs())},async nextPage(){this.page<this.totalPages&&(this.page++,await this.loadLogs())},formatTime(s){return s?new Date(s).toLocaleString("zh-CN"):"-"},getSessionTitle(s){if(!s)return"-";const t=this.sessions.find(e=>e.id===s);return t?t.title:s.substring(0,8)},formatDuration(s){return s?s<1e3?`${s}ms`:`${(s/1e3).toFixed(2)}s`:"0ms"}}};var b=function(){var l,d;var t=this,e=t._self._c;return e("div",{staticClass:"flex-1 flex overflow-hidden"},[e("aside",{staticClass:"w-[260px] bg-sidebar border-r border-border flex flex-col shrink-0"},[t._m(0),e("div",{staticClass:"flex-1 overflow-y-auto py-1"},t._l(t.logTypes,function(a){var i;return e("div",{key:a.key,staticClass:"flex items-center gap-2 px-3 py-1.5 cursor-pointer text-sm",class:((i=t.selectedLogType)==null?void 0:i.key)===a.key?"bg-active text-white border-l-2 border-accent":"text-textMuted hover:text-white hover:bg-white/5 border-l-2 border-transparent",on:{click:function(r){return t.selectLogType(a)}}},[e("i",{class:a.icon}),e("span",{staticClass:"truncate"},[t._v(t._s(a.name))])])}),0)]),e("main",{staticClass:"flex-1 flex flex-col min-w-0 bg-[#1e1e1e]"},[e("div",{staticClass:"px-4 py-3 border-b border-border bg-sidebar"},[e("div",{staticClass:"flex items-center gap-4 mb-3"},[e("div",{staticClass:"flex items-center gap-2"},[e("i",{class:(l=t.selectedLogType)==null?void 0:l.icon}),e("span",{staticClass:"text-white font-medium"},[t._v(t._s((d=t.selectedLogType)==null?void 0:d.name))])]),e("span",{staticClass:"text-xs text-textMuted"},[t._v(t._s(t.total)+" 条记录")])]),e("div",{staticClass:"flex items-center gap-4 flex-wrap"},[e("div",{staticClass:"flex items-center gap-2"},[e("label",{staticClass:"text-xs text-textMuted"},[t._v("调用类型:")]),e("select",{directives:[{name:"model",rawName:"v-model",value:t.filters.callType,expression:"filters.callType"}],staticClass:"bg-black/20 border border-white/10 text-white text-xs px-2 py-1 rounded",on:{change:[function(a){var i=Array.prototype.filter.call(a.target.options,function(r){return r.selected}).map(function(r){var o="_value"in r?r._value:r.value;return o});t.$set(t.filters,"callType",a.target.multiple?i:i[0])},t.loadLogs]}},[e("option",{attrs:{value:""}},[t._v("全部")]),e("option",{attrs:{value:"tool_call"}},[t._v("工具调用")]),e("option",{attrs:{value:"normal"}},[t._v("普通对话")])])]),e("div",{staticClass:"flex items-center gap-2"},[e("label",{staticClass:"text-xs text-textMuted"},[t._v("会话:")]),e("select",{directives:[{name:"model",rawName:"v-model",value:t.filters.sessionId,expression:"filters.sessionId"}],staticClass:"bg-black/20 border border-white/10 text-white text-xs px-2 py-1 rounded",on:{change:[function(a){var i=Array.prototype.filter.call(a.target.options,function(r){return r.selected}).map(function(r){var o="_value"in r?r._value:r.value;return o});t.$set(t.filters,"sessionId",a.target.multiple?i:i[0])},t.loadLogs]}},[e("option",{attrs:{value:""}},[t._v("全部会话")]),t._l(t.sessions,function(a){return e("option",{key:a.id,domProps:{value:a.id}},[t._v(t._s(a.title))])})],2)]),e("div",{staticClass:"flex items-center gap-2"},[e("label",{staticClass:"text-xs text-textMuted"},[t._v("开始时间:")]),e("input",{directives:[{name:"model",rawName:"v-model",value:t.filters.startTime,expression:"filters.startTime"}],staticClass:"bg-black/20 border border-white/10 text-white text-xs px-2 py-1 rounded",attrs:{type:"datetime-local"},domProps:{value:t.filters.startTime},on:{change:t.loadLogs,input:function(a){a.target.composing||t.$set(t.filters,"startTime",a.target.value)}}})]),e("div",{staticClass:"flex items-center gap-2"},[e("label",{staticClass:"text-xs text-textMuted"},[t._v("结束时间:")]),e("input",{directives:[{name:"model",rawName:"v-model",value:t.filters.endTime,expression:"filters.endTime"}],staticClass:"bg-black/20 border border-white/10 text-white text-xs px-2 py-1 rounded",attrs:{type:"datetime-local"},domProps:{value:t.filters.endTime},on:{change:t.loadLogs,input:function(a){a.target.composing||t.$set(t.filters,"endTime",a.target.value)}}})]),e("button",{staticClass:"px-3 py-1 bg-accent text-white text-xs rounded hover:bg-accent/80",on:{click:t.loadLogs}},[t._v(" 查询 ")]),e("button",{staticClass:"px-3 py-1 text-textMuted text-xs rounded hover:bg-white/10",on:{click:t.resetFilters}},[t._v(" 重置 ")])])]),e("div",{staticClass:"flex-1 overflow-auto p-4"},[e("table",{staticClass:"w-full text-sm"},[t._m(1),e("tbody",[t._l(t.logs,function(a){return e("tr",{key:a.id,staticClass:"hover:bg-white/5"},[e("td",{staticClass:"px-3 py-2 text-gray-300 border-b border-border/30"},[t._v(t._s(a.id))]),e("td",{staticClass:"px-3 py-2 text-gray-300 border-b border-border/30"},[t._v(t._s(t.formatTime(a.request_time)))]),e("td",{staticClass:"px-3 py-2 border-b border-border/30"},[e("span",{staticClass:"text-xs px-2 py-0.5 rounded",class:a.call_type==="tool_call"?"bg-blue-500/20 text-blue-400":"bg-green-500/20 text-green-400"},[t._v(" "+t._s(a.call_type==="tool_call"?"工具调用":"普通对话")+" ")])]),e("td",{staticClass:"px-3 py-2 text-gray-300 border-b border-border/30"},[t._v(t._s(a.model_name))]),e("td",{staticClass:"px-3 py-2 text-gray-300 border-b border-border/30"},[t._v(t._s(t.formatDuration(a.duration_ms)))]),e("td",{staticClass:"px-3 py-2 text-gray-300 border-b border-border/30"},[t._v(t._s(a.input_tokens||0))]),e("td",{staticClass:"px-3 py-2 text-gray-300 border-b border-border/30"},[t._v(t._s(a.output_tokens||0))]),e("td",{staticClass:"px-3 py-2 text-gray-300 border-b border-border/30"},[t._v("$"+t._s((a.cost||0).toFixed(4)))]),e("td",{staticClass:"px-3 py-2 text-gray-300 border-b border-border/30 truncate max-w-[150px]",attrs:{title:a.session_id}},[t._v(t._s(t.getSessionTitle(a.session_id)))])])}),t.logs.length===0?e("tr",[e("td",{staticClass:"px-3 py-8 text-center text-textMuted",attrs:{colspan:"9"}},[t._v("暂无数据")])]):t._e()],2)])]),e("div",{staticClass:"flex items-center justify-between px-4 py-2 border-t border-border bg-sidebar"},[e("span",{staticClass:"text-xs text-textMuted"},[t._v("共 "+t._s(t.total)+" 条")]),e("div",{staticClass:"flex items-center gap-2"},[e("button",{staticClass:"px-2 py-1 text-xs text-textMuted hover:text-white disabled:opacity-30 disabled:cursor-not-allowed",attrs:{disabled:t.page<=1},on:{click:t.prevPage}},[e("i",{staticClass:"fa-solid fa-chevron-left"}),t._v(" 上一页 ")]),e("span",{staticClass:"text-xs text-textMuted"},[t._v(t._s(t.page)+" / "+t._s(t.totalPages||1))]),e("button",{staticClass:"px-2 py-1 text-xs text-textMuted hover:text-white disabled:opacity-30 disabled:cursor-not-allowed",attrs:{disabled:t.page>=t.totalPages},on:{click:t.nextPage}},[t._v(" 下一页 "),e("i",{staticClass:"fa-solid fa-chevron-right"})])])])])])},f=[function(){var s=this,t=s._self._c;return t("div",{staticClass:"flex border-b border-border text-xs uppercase font-bold text-textMuted"},[t("div",{staticClass:"px-4 py-2 border-b-2 border-accent text-white flex items-center gap-2"},[t("i",{staticClass:"fa-solid fa-list"}),s._v(" 日志 ")])])},function(){var s=this,t=s._self._c;return t("thead",{staticClass:"bg-sidebar sticky top-0"},[t("tr",[t("th",{staticClass:"px-3 py-2 text-left text-xs font-bold text-textMuted uppercase border-b border-border"},[s._v("ID")]),t("th",{staticClass:"px-3 py-2 text-left text-xs font-bold text-textMuted uppercase border-b border-border"},[s._v("时间")]),t("th",{staticClass:"px-3 py-2 text-left text-xs font-bold text-textMuted uppercase border-b border-border"},[s._v("类型")]),t("th",{staticClass:"px-3 py-2 text-left text-xs font-bold text-textMuted uppercase border-b border-border"},[s._v("模型")]),t("th",{staticClass:"px-3 py-2 text-left text-xs font-bold text-textMuted uppercase border-b border-border"},[s._v("耗时")]),t("th",{staticClass:"px-3 py-2 text-left text-xs font-bold text-textMuted uppercase border-b border-border"},[s._v("输入Token")]),t("th",{staticClass:"px-3 py-2 text-left text-xs font-bold text-textMuted uppercase border-b border-border"},[s._v("输出Token")]),t("th",{staticClass:"px-3 py-2 text-left text-xs font-bold text-textMuted uppercase border-b border-border"},[s._v("费用")]),t("th",{staticClass:"px-3 py-2 text-left text-xs font-bold text-textMuted uppercase border-b border-border"},[s._v("会话ID")])])])}],u=x(p,b,f,!1,null,null);const _=u.exports;export{_ as default};
@@ -1,4 +1,4 @@
1
- import{m as et}from"./index-Cn73hS12.js";/*!-----------------------------------------------------------------------------
1
+ import{m as et}from"./index-BWmvR_0d.js";/*!-----------------------------------------------------------------------------
2
2
  * Copyright (c) Microsoft Corporation. All rights reserved.
3
3
  * Version: 0.52.2(404545bded1df6ffa41ea0af4e8ddb219018c6c1)
4
4
  * Released under the MIT license