fix: 调整项目结构,添加 src 目录

This commit is contained in:
Agent
2026-03-23 15:03:37 +00:00
parent 0b03f81b55
commit a39c9ee8f7
13 changed files with 0 additions and 0 deletions

41
src/api/index.js Normal file
View File

@@ -0,0 +1,41 @@
// API基础配置
const BASE_URL = 'http://localhost:8080/api/v1'
// 请求拦截器
const request = (url, method, data = {}) => {
const token = uni.getStorageSync('token')
return new Promise((resolve, reject) => {
uni.request({
url: BASE_URL + url,
method: method,
data: data,
header: {
'Content-Type': 'application/json',
'Authorization': token ? `Bearer ${token}` : ''
},
success: (res) => {
if (res.data.code === 0) {
resolve(res.data.data)
} else {
uni.showToast({
title: res.data.message || '请求失败',
icon: 'none'
})
reject(res.data)
}
},
fail: (err) => {
uni.showToast({
title: '网络请求失败',
icon: 'none'
})
reject(err)
}
})
})
}
export default {
request
}