Add project status report and frontend documentation

- Introduced `PROJECT_STATUS.md` to provide a comprehensive overview of the MiroFish project, detailing the current status, completed features, and future development plans.
- Added multiple documentation files in the frontend directory, including detailed descriptions of the homepage functionality, startup guide, and project completion summary.
- Implemented a structured approach to document the project's architecture, API integration, and user interaction processes, enhancing clarity for developers and users alike.
- Included a `.gitignore` file to manage ignored files and directories in the frontend project, improving project organization and cleanliness.
This commit is contained in:
666ghj
2025-12-10 14:49:11 +08:00
parent d59bda908c
commit b67e14cced
19 changed files with 4539 additions and 0 deletions

67
frontend/src/api/index.js Normal file
View File

@@ -0,0 +1,67 @@
import axios from 'axios'
// 创建axios实例
const service = axios.create({
baseURL: import.meta.env.VITE_API_BASE_URL || 'http://localhost:5001',
timeout: 300000, // 5分钟超时本体生成可能需要较长时间
headers: {
'Content-Type': 'application/json'
}
})
// 请求拦截器
service.interceptors.request.use(
config => {
return config
},
error => {
console.error('Request error:', error)
return Promise.reject(error)
}
)
// 响应拦截器(容错重试机制)
service.interceptors.response.use(
response => {
const res = response.data
// 如果返回的状态码不是success则抛出错误
if (!res.success && res.success !== undefined) {
console.error('API Error:', res.error || res.message || 'Unknown error')
return Promise.reject(new Error(res.error || res.message || 'Error'))
}
return res
},
error => {
console.error('Response error:', error)
// 处理超时
if (error.code === 'ECONNABORTED' && error.message.includes('timeout')) {
console.error('Request timeout')
}
// 处理网络错误
if (error.message === 'Network Error') {
console.error('Network error - please check your connection')
}
return Promise.reject(error)
}
)
// 带重试的请求函数
export const requestWithRetry = async (requestFn, maxRetries = 3, delay = 1000) => {
for (let i = 0; i < maxRetries; i++) {
try {
return await requestFn()
} catch (error) {
if (i === maxRetries - 1) throw error
console.warn(`Request failed, retrying (${i + 1}/${maxRetries})...`)
await new Promise(resolve => setTimeout(resolve, delay * Math.pow(2, i)))
}
}
}
export default service