From 367e24d2eaeddd04748b2e250ce9c7d943cda589 Mon Sep 17 00:00:00 2001 From: Kunagisa <1549184870@qq.com> Date: Sat, 14 Jun 2025 20:08:00 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/axiosConfig.js | 11 +++++++++-- src/api/centre_maps.js | 5 ++++- src/api/login.js | 23 ++++++++++++++++++++--- src/api/maps.js | 30 ++++++++++++++++++++++++++---- src/views/index/DemandList.vue | 2 +- 5 files changed, 60 insertions(+), 11 deletions(-) diff --git a/src/api/axiosConfig.js b/src/api/axiosConfig.js index 472849e..9cea5f0 100644 --- a/src/api/axiosConfig.js +++ b/src/api/axiosConfig.js @@ -13,7 +13,11 @@ const axiosInstance = axios.create({ timeout: 10000 }); -// 请求拦截器 +/** + * 请求拦截器 + * - 对需要认证的请求,在请求头中添加Authorization + * - 对登录、注册和获取列表的请求,不添加Authorization + */ axiosInstance.interceptors.request.use( config => { const token = localStorage.getItem('access_token'); @@ -35,7 +39,10 @@ axiosInstance.interceptors.request.use( } ); -// 响应拦截器 +/** + * 响应拦截器 + * - 如果收到401错误(未授权),并且不是来自登录请求,则调用logoutUser函数清除用户凭证 + */ axiosInstance.interceptors.response.use( response => response, error => { diff --git a/src/api/centre_maps.js b/src/api/centre_maps.js index 0bbb758..1dbc884 100644 --- a/src/api/centre_maps.js +++ b/src/api/centre_maps.js @@ -1,6 +1,9 @@ import axiosInstance from './axiosConfig'; - +/** + * 获取地图编辑者列表 + * @returns {Promise} 返回一个包含地图编辑者信息的Promise对象 + */ export const getMapEditors = async () => { try { const response = await axiosInstance.get('/map/editors'); diff --git a/src/api/login.js b/src/api/login.js index b7fe887..a1fef94 100644 --- a/src/api/login.js +++ b/src/api/login.js @@ -50,7 +50,10 @@ import { loginSuccess } from '../utils/jwt'; // } // ) -// 获取验证码 +/** + * 获取验证码 + * @returns {Promise} 返回一个包含验证码信息的Promise对象 + */ export const getCaptcha = async () => { try { const response = await axiosInstance.get('/captcha'); @@ -60,7 +63,14 @@ export const getCaptcha = async () => { } }; -// 用户登录 +/** + * 用户登录 + * @param {string} username - 用户名 + * @param {string} password - 密码 + * @param {string} token - 验证码token + * @param {string} captcha - 用户输入的验证码 + * @returns {Promise} 返回一个包含登录结果信息的Promise对象 + */ export const userLogin = async (username, password, token, captcha) => { try { const response = await axiosInstance.post('/user/login', { @@ -80,7 +90,14 @@ export const userLogin = async (username, password, token, captcha) => { } }; -// 用户注册 +/** + * 用户注册 + * @param {string} qq_code - QQ号 + * @param {string} password - 密码 + * @param {string} token - 验证码token + * @param {string} captcha - 用户输入的验证码 + * @returns {Promise} 返回一个包含注册结果信息的Promise对象 + */ export const userRegister = async (qq_code, password, token, captcha) => { try { const response = await axiosInstance.post('/user/register', { diff --git a/src/api/maps.js b/src/api/maps.js index 09c6a09..57b71a1 100644 --- a/src/api/maps.js +++ b/src/api/maps.js @@ -2,7 +2,16 @@ import axios from 'axios' const API_BASE_URL = 'https://ra3.z31.xyz/v1' -// 获取地图列表 +/** + * 获取地图列表 + * @param {object} params - 查询参数 + * @param {number} params.page - 页码 + * @param {string} params.search - 搜索关键字 + * @param {string} params.player_count - 玩家数量 + * @param {string} params.tags - 标签 + * @param {string} params.ordering - 排序方式 + * @returns {Promise} + */ export const getMaps = async (params = {}) => { try { const response = await axios.get(`${API_BASE_URL}/maps/`, { @@ -21,7 +30,13 @@ export const getMaps = async (params = {}) => { } } -// 获取每周推荐地图 +/** + * 获取每周推荐地图 + * @param {object} params - 查询参数 + * @param {number} params.page - 页码 + * @param {string} params.ordering - 排序方式 + * @returns {Promise} + */ export const getWeeklyTopMaps = async (params = {}) => { try { const response = await axios.get(`${API_BASE_URL}/maps/`, { @@ -38,7 +53,11 @@ export const getWeeklyTopMaps = async (params = {}) => { } } -// 获取地图详情 +/** + * 获取地图详情 + * @param {number} id - 地图ID + * @returns {Promise} + */ export const getMapDetail = async (id) => { try { const response = await axios.get(`${API_BASE_URL}/maps/${id}/`) @@ -49,7 +68,10 @@ export const getMapDetail = async (id) => { } } -// 获取所有标签 +/** + * 获取所有标签 + * @returns {Promise} + */ export const getAllTags = async () => { try { const response = await axios.get(`${API_BASE_URL}/maps/`) diff --git a/src/views/index/DemandList.vue b/src/views/index/DemandList.vue index 72836da..d245997 100644 --- a/src/views/index/DemandList.vue +++ b/src/views/index/DemandList.vue @@ -304,7 +304,7 @@ const closeModal = () => { // 打开弹窗 const openAddModal = (demand) => { reply.value = demand; - replyModal.value = true; + showAddModal.value = true; resetReplyForm(); }