Skip to content

Commit 995c604

Browse files
committed
lint(web): [大量改动] 格式化前端代码
1 parent 370b0e4 commit 995c604

File tree

117 files changed

+9088
-8267
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

117 files changed

+9088
-8267
lines changed

AGENTS.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ Don't create helpers, utilities, or abstractions for one-time operations. Don't
2525
- Icon 应该从 @ant-design/icons-vue 或者 lucide-vue-next (推荐,但是需要注意尺寸)
2626
- Vue 中的样式使用 less,非必要情况必须使用[base.css](web/src/assets/css/base.css) 中的颜色变量。
2727
- UI风格要简洁,同时要保持一致性,不要悬停位移,不要过度使用阴影以及渐变色。
28-
- 绝对不要尝试使用 npm/pnpm 等等运行前端开发服务器。
28+
- 开发完成后,可以在 docker 的 web 文件夹下,运行 npm run format 格式化代码
2929

3030

3131
### 后端开发规范

CLAUDE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ Don't create helpers, utilities, or abstractions for one-time operations. Don't
2525
- Icon 应该从 @ant-design/icons-vue 或者 lucide-vue-next (推荐,但是需要注意尺寸)
2626
- Vue 中的样式使用 less,非必要情况必须使用[base.css](web/src/assets/css/base.css) 中的颜色变量。
2727
- UI风格要简洁,同时要保持一致性,不要悬停位移,不要过度使用阴影以及渐变色。
28-
- 绝对不要尝试使用 npm/pnpm 等等运行前端开发服务器。
28+
- 开发完成后,可以在 docker 的 web 文件夹下,运行 npm run format 格式化代码
2929

3030

3131
### 后端开发规范

web/src/App.vue

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,22 @@
11
<script setup>
2-
import zhCN from 'ant-design-vue/es/locale/zh_CN';
2+
import zhCN from 'ant-design-vue/es/locale/zh_CN'
33
import { useAgentStore } from '@/stores/agent'
44
import { useUserStore } from '@/stores/user'
55
import { useThemeStore } from '@/stores/theme'
66
import { onMounted } from 'vue'
77
8-
const agentStore = useAgentStore();
9-
const userStore = useUserStore();
10-
const themeStore = useThemeStore();
8+
const agentStore = useAgentStore()
9+
const userStore = useUserStore()
10+
const themeStore = useThemeStore()
1111
1212
onMounted(async () => {
1313
if (userStore.isLoggedIn) {
14-
await agentStore.initialize();
14+
await agentStore.initialize()
1515
}
1616
})
1717
</script>
1818
<template>
19-
<a-config-provider
20-
:theme="themeStore.currentTheme"
21-
:locale="zhCN"
22-
>
19+
<a-config-provider :theme="themeStore.currentTheme" :locale="zhCN">
2320
<router-view />
2421
</a-config-provider>
2522
</template>

web/src/apis/agent_api.js

Lines changed: 40 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@ import { useUserStore } from '@/stores/user'
77
* 权限要求: 任何已登录用户(普通用户、管理员、超级管理员)
88
*/
99

10-
11-
1210
// =============================================================================
1311
// === 智能体聊天分组 ===
1412
// =============================================================================
@@ -21,11 +19,11 @@ export const agentApi = {
2119
* @returns {Promise} - 聊天响应流
2220
*/
2321
sendAgentMessage: (agentId, data, options = {}) => {
24-
const { signal, headers: extraHeaders, ...restOptions } = options || {};
22+
const { signal, headers: extraHeaders, ...restOptions } = options || {}
2523
const baseHeaders = {
2624
'Content-Type': 'application/json',
2725
...useUserStore().getAuthHeaders()
28-
};
26+
}
2927

3028
return fetch(`/api/chat/agent/${agentId}`, {
3129
method: 'POST',
@@ -71,15 +69,17 @@ export const agentApi = {
7169
* @param {string} threadId - 会话ID
7270
* @returns {Promise} - 历史消息
7371
*/
74-
getAgentHistory: (agentId, threadId) => apiGet(`/api/chat/agent/${agentId}/history?thread_id=${threadId}`),
72+
getAgentHistory: (agentId, threadId) =>
73+
apiGet(`/api/chat/agent/${agentId}/history?thread_id=${threadId}`),
7574

7675
/**
7776
* 获取指定会话的 AgentState
7877
* @param {string} agentId - 智能体ID
7978
* @param {string} threadId - 会话ID
8079
* @returns {Promise} - AgentState
8180
*/
82-
getAgentState: (agentId, threadId) => apiGet(`/api/chat/agent/${agentId}/state?thread_id=${threadId}`),
81+
getAgentState: (agentId, threadId) =>
82+
apiGet(`/api/chat/agent/${agentId}/state?thread_id=${threadId}`),
8383

8484
/**
8585
* Submit feedback for a message
@@ -111,7 +111,8 @@ export const agentApi = {
111111
* @param {Array} models - 选中的模型列表
112112
* @returns {Promise} - 更新结果
113113
*/
114-
updateProviderModels: (provider, models) => apiPost(`/api/chat/models/update?model_provider=${provider}`, models),
114+
updateProviderModels: (provider, models) =>
115+
apiPost(`/api/chat/models/update?model_provider=${provider}`, models),
115116

116117
/**
117118
* 获取智能体配置
@@ -130,8 +131,8 @@ export const agentApi = {
130131
* @returns {Promise} - 保存结果
131132
*/
132133
saveAgentConfig: async (agentName, config, options = {}) => {
133-
const queryParams = new URLSearchParams(options).toString();
134-
const url = `/api/chat/agent/${agentName}/config` + (queryParams ? `?${queryParams}` : '');
134+
const queryParams = new URLSearchParams(options).toString()
135+
const url = `/api/chat/agent/${agentName}/config` + (queryParams ? `?${queryParams}` : '')
135136
return apiAdminPost(url, config)
136137
},
137138

@@ -152,11 +153,11 @@ export const agentApi = {
152153
* @returns {Promise} - 恢复响应流
153154
*/
154155
resumeAgentChat: (agentId, data, options = {}) => {
155-
const { signal, headers: extraHeaders, ...restOptions } = options || {};
156+
const { signal, headers: extraHeaders, ...restOptions } = options || {}
156157
const baseHeaders = {
157158
'Content-Type': 'application/json',
158159
...useUserStore().getAuthHeaders()
159-
};
160+
}
160161

161162
return fetch(`/api/chat/agent/${agentId}/resume`, {
162163
method: 'POST',
@@ -171,7 +172,6 @@ export const agentApi = {
171172
}
172173
}
173174

174-
175175
// =============================================================================
176176
// === 多模态图片支持分组 ===
177177
// =============================================================================
@@ -183,16 +183,19 @@ export const multimodalApi = {
183183
* @returns {Promise} - 上传结果
184184
*/
185185
uploadImage: (file) => {
186-
const formData = new FormData();
187-
formData.append('file', file);
188-
189-
return apiRequest('/api/chat/image/upload', {
190-
method: 'POST',
191-
body: formData,
192-
}, true);
193-
},
186+
const formData = new FormData()
187+
formData.append('file', file)
194188

195-
};
189+
return apiRequest(
190+
'/api/chat/image/upload',
191+
{
192+
method: 'POST',
193+
body: formData
194+
},
195+
true
196+
)
197+
}
198+
}
196199

197200
// =============================================================================
198201
// === 对话线程分组 ===
@@ -205,8 +208,8 @@ export const threadApi = {
205208
* @returns {Promise} - 对话线程列表
206209
*/
207210
getThreads: (agentId) => {
208-
const url = `/api/chat/threads?agent_id=${agentId}`;
209-
return apiGet(url);
211+
const url = `/api/chat/threads?agent_id=${agentId}`
212+
return apiGet(url)
210213
},
211214

212215
/**
@@ -216,11 +219,12 @@ export const threadApi = {
216219
* @param {Object} metadata - 元数据
217220
* @returns {Promise} - 创建结果
218221
*/
219-
createThread: (agentId, title, metadata) => apiPost('/api/chat/thread', {
220-
agent_id: agentId,
221-
title: title || '新的对话',
222-
metadata: metadata || {}
223-
}),
222+
createThread: (agentId, title, metadata) =>
223+
apiPost('/api/chat/thread', {
224+
agent_id: agentId,
225+
title: title || '新的对话',
226+
metadata: metadata || {}
227+
}),
224228

225229
/**
226230
* 更新对话线程
@@ -229,10 +233,11 @@ export const threadApi = {
229233
* @param {string} description - 对话描述
230234
* @returns {Promise} - 更新结果
231235
*/
232-
updateThread: (threadId, title, description) => apiPut(`/api/chat/thread/${threadId}`, {
233-
title,
234-
description
235-
}),
236+
updateThread: (threadId, title, description) =>
237+
apiPut(`/api/chat/thread/${threadId}`, {
238+
title,
239+
description
240+
}),
236241

237242
/**
238243
* 删除对话线程
@@ -269,5 +274,6 @@ export const threadApi = {
269274
* @param {string} fileId
270275
* @returns {Promise}
271276
*/
272-
deleteThreadAttachment: (threadId, fileId) => apiDelete(`/api/chat/thread/${threadId}/attachments/${fileId}`)
273-
};
277+
deleteThreadAttachment: (threadId, fileId) =>
278+
apiDelete(`/api/chat/thread/${threadId}/attachments/${fileId}`)
279+
}

web/src/apis/base.js

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ export async function apiRequest(url, options = {}, requiresAuth = true, respons
2222
...options,
2323
headers: {
2424
...(!isFormData ? { 'Content-Type': 'application/json' } : {}),
25-
...options.headers,
26-
},
25+
...options.headers
26+
}
2727
}
2828

2929
// 如果需要认证,添加认证头
@@ -50,12 +50,12 @@ export async function apiRequest(url, options = {}, requiresAuth = true, respons
5050
status: response.status,
5151
statusText: response.statusText,
5252
headers: Object.fromEntries(response.headers.entries())
53-
});
53+
})
5454

5555
try {
5656
errorData = await response.json()
5757
errorMessage = errorData.detail || errorData.message || errorMessage
58-
console.log('API错误详情:', errorData);
58+
console.log('API错误详情:', errorData)
5959

6060
// 如果是422错误,打印更详细的信息
6161
if (response.status === 422) {
@@ -65,11 +65,11 @@ export async function apiRequest(url, options = {}, requiresAuth = true, respons
6565
requestHeaders: requestOptions.headers,
6666
requestBody: requestOptions.body,
6767
responseData: errorData
68-
});
68+
})
6969
}
7070
} catch (e) {
7171
// 如果无法解析JSON,使用默认错误信息
72-
console.log('无法解析错误响应JSON:', e);
72+
console.log('无法解析错误响应JSON:', e)
7373
}
7474

7575
// 特殊处理401和403错误
@@ -78,11 +78,12 @@ export async function apiRequest(url, options = {}, requiresAuth = true, respons
7878
const userStore = useUserStore()
7979

8080
// 检查是否是token过期
81-
const isTokenExpired = errorData &&
81+
const isTokenExpired =
82+
errorData &&
8283
(errorData.detail?.includes('令牌已过期') ||
83-
errorData.detail?.includes('token expired') ||
84-
errorMessage?.includes('令牌已过期') ||
85-
errorMessage?.includes('token expired'))
84+
errorData.detail?.includes('token expired') ||
85+
errorMessage?.includes('令牌已过期') ||
86+
errorMessage?.includes('token expired'))
8687

8788
message.error(isTokenExpired ? '登录已过期,请重新登录' : '认证失败,请重新登录')
8889

@@ -225,13 +226,11 @@ export function apiDelete(url, options = {}, requiresAuth = true, responseType =
225226
return apiRequest(url, { method: 'DELETE', ...options }, requiresAuth, responseType)
226227
}
227228

228-
229229
export function apiAdminDelete(url, options = {}) {
230230
checkAdminPermission()
231231
return apiDelete(url, options, true)
232232
}
233233

234-
235234
export function apiSuperAdminDelete(url, options = {}) {
236235
checkSuperAdminPermission()
237236
return apiDelete(url, options, true)

web/src/apis/dashboard_api.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,5 +130,3 @@ export const dashboardApi = {
130130
return apiAdminGet(`/api/dashboard/stats/calls/timeseries?type=${type}&time_range=${timeRange}`)
131131
}
132132
}
133-
134-

0 commit comments

Comments
 (0)