22301023 | 71ee1c9 | 2025-06-05 16:18:32 +0800 | [diff] [blame^] | 1 | import axios from 'axios'; |
22301014 | bc4616f | 2025-06-03 16:59:44 +0800 | [diff] [blame] | 2 | |
| 3 | |
22301023 | 71ee1c9 | 2025-06-05 16:18:32 +0800 | [diff] [blame^] | 4 | class authAPI { |
| 5 | |
| 6 | // static getUserById(userId) { |
| 7 | // // 例如 GET http://localhost:8080/123 |
| 8 | // return axios.get(`/${userId}`); |
| 9 | // } |
| 10 | |
| 11 | |
| 12 | // static updateUser(userId, data) { |
| 13 | // // 例如 PUT http://localhost:8080/123 Body: { username: 'xxx', ... } |
| 14 | // return axios.put(`/${userId}`, data); |
| 15 | // } |
| 16 | // |
| 17 | // |
| 18 | // static deleteUser(userId:string) { |
| 19 | // // 例如 DELETE http://localhost:8080/123 |
| 20 | // return axios.delete(`/${userId}`); |
| 21 | // } |
| 22 | |
| 23 | |
| 24 | static sendVerificationCode(email: string) { |
| 25 | // Body: { email: 'xxx@yyy.com'} |
| 26 | return axios.post('/api/sendVerification', { email }); |
| 27 | } |
| 28 | |
| 29 | |
| 30 | static sendResetCode(email: string) { |
| 31 | // Body: { email: 'xxx@yyy.com' } |
| 32 | return axios.post('/api/sendResetCode', { email }); |
| 33 | } |
| 34 | |
| 35 | // |
| 36 | // static resetPassword({ email, code, newPassword }) { |
| 37 | // // Body: { email, code, newPassword } |
| 38 | // return axios.post('/resetPassword', { email, code, newPassword }); |
| 39 | // } |
| 40 | // |
| 41 | // |
| 42 | // static register({ username, email, verificationCode, password }) { |
| 43 | // // Body: { username, email, verificationCode, password, identificationNumber? } |
| 44 | // const body = { |
| 45 | // username, |
| 46 | // email, |
| 47 | // verificationCode, |
| 48 | // password, |
| 49 | // }; |
| 50 | // return axios.post('/register', body); |
| 51 | // } |
| 52 | // |
| 53 | // /** |
| 54 | // * 刷新 JWT Token(POST /refreshToken) |
| 55 | // * @param {string} oldToken 旧的 JWT(放在 header: token) |
| 56 | // * @returns {Promise<AxiosResponse>} |
| 57 | // */ |
| 58 | // static refreshToken(oldToken : string) { |
| 59 | // // 因为后端是从 header 中读取旧 token,这里直接把 token 放进 headers |
| 60 | // return axios.post( |
| 61 | // '/refreshToken', |
| 62 | // {}, // 请求体空 |
| 63 | // { |
| 64 | // headers: { |
| 65 | // token: oldToken, |
| 66 | // }, |
| 67 | // } |
| 68 | // ); |
| 69 | // } |
| 70 | // |
| 71 | // |
| 72 | // static login({ email, password } : {email: string, password:string}) { |
| 73 | // // Body: { email, password } |
| 74 | // return axios.post('/login', { email, password }); |
| 75 | // } |
| 76 | |
| 77 | } |
| 78 | |
| 79 | export default authAPI; |
22301014 | bc4616f | 2025-06-03 16:59:44 +0800 | [diff] [blame] | 80 | |