feat: 新增 api 接口
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
import { http } from '@/utils/request'
|
||||
|
||||
// 账号管理相关API
|
||||
export const accountApi = {
|
||||
// 获取有效账号列表
|
||||
getValidAccounts() {
|
||||
return http.get('/getValidAccounts')
|
||||
},
|
||||
|
||||
// 添加账号
|
||||
addAccount(data) {
|
||||
return http.post('/account', data)
|
||||
},
|
||||
|
||||
// 更新账号
|
||||
updateAccount(id, data) {
|
||||
return http.put(`/account/${id}`, data)
|
||||
},
|
||||
|
||||
// 删除账号
|
||||
deleteAccount(id) {
|
||||
return http.get(`/deleteAccount?id=${id}`)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
// API 统一导出
|
||||
export * from './user'
|
||||
export * from './account'
|
||||
export * from './material'
|
||||
|
||||
// 可以在这里添加其他API模块的导出
|
||||
// export * from './product'
|
||||
// export * from './order'
|
||||
// export * from './common'
|
||||
@@ -0,0 +1,30 @@
|
||||
import { http } from '@/utils/request'
|
||||
|
||||
// 素材管理API
|
||||
export const materialApi = {
|
||||
// 获取所有素材
|
||||
getAllMaterials: () => {
|
||||
return http.get('/getFiles')
|
||||
},
|
||||
|
||||
// 上传素材
|
||||
uploadMaterial: (formData) => {
|
||||
// 使用http.upload方法,它已经配置了正确的Content-Type
|
||||
return http.upload('/uploadSave', formData)
|
||||
},
|
||||
|
||||
// 删除素材
|
||||
deleteMaterial: (id) => {
|
||||
return http.get(`/deleteFile?id=${id}`)
|
||||
},
|
||||
|
||||
// 下载素材
|
||||
downloadMaterial: (filePath) => {
|
||||
return `${import.meta.env.VITE_API_BASE_URL || 'http://localhost:5409'}/download/${filePath}`
|
||||
},
|
||||
|
||||
// 获取素材预览URL
|
||||
getMaterialPreviewUrl: (filename) => {
|
||||
return `${import.meta.env.VITE_API_BASE_URL || 'http://localhost:5409'}/getFile?filename=${filename}`
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
import { http } from '@/utils/request'
|
||||
|
||||
// 用户相关API
|
||||
export const userApi = {
|
||||
// 获取用户信息
|
||||
getUserInfo(id) {
|
||||
return http.get(`/user/${id}`)
|
||||
},
|
||||
|
||||
// 获取用户列表
|
||||
getUserList(params) {
|
||||
return http.get('/user/list', params)
|
||||
},
|
||||
|
||||
// 创建用户
|
||||
createUser(data) {
|
||||
return http.post('/user', data)
|
||||
},
|
||||
|
||||
// 更新用户信息
|
||||
updateUser(id, data) {
|
||||
return http.put(`/user/${id}`, data)
|
||||
},
|
||||
|
||||
// 删除用户
|
||||
deleteUser(id) {
|
||||
return http.delete(`/user/${id}`)
|
||||
},
|
||||
|
||||
// 用户登录
|
||||
login(data) {
|
||||
return http.post('/auth/login', data)
|
||||
},
|
||||
|
||||
// 用户注册
|
||||
register(data) {
|
||||
return http.post('/auth/register', data)
|
||||
},
|
||||
|
||||
// 用户登出
|
||||
logout() {
|
||||
return http.post('/auth/logout')
|
||||
},
|
||||
|
||||
// 刷新token
|
||||
refreshToken() {
|
||||
return http.post('/auth/refresh')
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user