前端美化

This commit is contained in:
2025-09-16 18:39:10 +08:00
parent 17691af8d1
commit 174d8a3bc5
26 changed files with 337 additions and 474 deletions

View File

@@ -0,0 +1,26 @@
// 环境配置文件
// 此文件定义了AI应用的基本配置
// API配置
window.API_CONFIG = {
baseUrl: 'http://127.0.0.1:5002',
endpoints: {
nameAnalysis: '/api/aimodelapp/name-analysis'
}
};
// 认证配置
window.AUTH_CONFIG = {
tokenKey: 'token',
getToken: () => localStorage.getItem('token'),
isAuthenticated: () => !!localStorage.getItem('token')
};
// 应用配置
window.APP_CONFIG = {
name: 'InfoGenie AI工具',
version: '1.0.0',
debug: false
};
console.log('环境配置已加载');

View File

@@ -193,11 +193,18 @@ async function analyzeName() {
try {
// 调用后端API
const response = await fetch('http://127.0.0.1:5002/api/aimodelapp/name-analysis', {
const token = AUTH_CONFIG.getToken();
const headers = {
'Content-Type': 'application/json'
};
if (token) {
headers['Authorization'] = `Bearer ${token}`;
}
const response = await fetch(`${API_CONFIG.baseUrl}${API_CONFIG.endpoints.nameAnalysis}`, {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
headers: headers,
body: JSON.stringify(requestBody)
});
@@ -207,6 +214,9 @@ async function analyzeName() {
}
if (!response.ok) {
if (response.status === 402) {
throw new Error('您的萌芽币余额不足,无法使用此功能');
}
const errorData = await response.json();
throw new Error(errorData.error || `请求失败: ${response.status} ${response.statusText}`);
}