[Base] 修改 API 接口使得支持 GET 请求参数
All checks were successful
Build / build-and-test (push) Successful in 28s

This commit is contained in:
2025-05-24 10:33:57 +08:00
parent 8d248a44ff
commit eb5b28249f
2 changed files with 9 additions and 4 deletions

View File

@ -1,6 +1,8 @@
import { useAxios } from '@vueuse/integrations/useAxios'
import axios from 'axios'
import { objectToQueryString } from '../utils.js'
function getEndpoint() {
const apiMapping = {
'': ['http://localhost:28001/', '/api/'],
@ -20,7 +22,10 @@ function replaceUrl(url) {
export function useApiRequest(method, url, data, config = {}) {
const start = Date.now()
const baseURL = getEndpoint()
const fullURL = `${baseURL}${url}`
// 若为 GET 请求,将 data 转为查询参数拼接到 URL 上
const fullURL = method === 'GET' && data
? `${baseURL}${url}?${objectToQueryString(data)}`
: `${baseURL}${url}`
const {
response,
error,