From 525d1b03de79c76f8930d8fb7e80536b68a4b826 Mon Sep 17 00:00:00 2001 From: Edan's Win11 <961150665@qq.com> Date: Tue, 3 Jun 2025 21:27:10 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=96=B0=E5=A2=9E=20api=20=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sau_frontend/src/api/account.js | 24 ++++++++++++++++ sau_frontend/src/api/index.js | 9 ++++++ sau_frontend/src/api/material.js | 30 +++++++++++++++++++ sau_frontend/src/api/user.js | 49 ++++++++++++++++++++++++++++++++ 4 files changed, 112 insertions(+) create mode 100644 sau_frontend/src/api/account.js create mode 100644 sau_frontend/src/api/index.js create mode 100644 sau_frontend/src/api/material.js create mode 100644 sau_frontend/src/api/user.js diff --git a/sau_frontend/src/api/account.js b/sau_frontend/src/api/account.js new file mode 100644 index 0000000..de9d344 --- /dev/null +++ b/sau_frontend/src/api/account.js @@ -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}`) + } +} \ No newline at end of file diff --git a/sau_frontend/src/api/index.js b/sau_frontend/src/api/index.js new file mode 100644 index 0000000..320c254 --- /dev/null +++ b/sau_frontend/src/api/index.js @@ -0,0 +1,9 @@ +// API 统一导出 +export * from './user' +export * from './account' +export * from './material' + +// 可以在这里添加其他API模块的导出 +// export * from './product' +// export * from './order' +// export * from './common' \ No newline at end of file diff --git a/sau_frontend/src/api/material.js b/sau_frontend/src/api/material.js new file mode 100644 index 0000000..04b9c23 --- /dev/null +++ b/sau_frontend/src/api/material.js @@ -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}` + } +} \ No newline at end of file diff --git a/sau_frontend/src/api/user.js b/sau_frontend/src/api/user.js new file mode 100644 index 0000000..a2b2e10 --- /dev/null +++ b/sau_frontend/src/api/user.js @@ -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') + } +} \ No newline at end of file