|
|
3 年之前 | |
|---|---|---|
| .husky | 3 年之前 | |
| build | 3 年之前 | |
| plop | 3 年之前 | |
| public | 3 年之前 | |
| readme | 3 年之前 | |
| src | 3 年之前 | |
| types | 3 年之前 | |
| .commitlintrc.js | 3 年之前 | |
| .env | 3 年之前 | |
| .eslintignore | 3 年之前 | |
| .eslintrc.js | 3 年之前 | |
| .gitignore | 3 年之前 | |
| LICENSE | 3 年之前 | |
| Makefile | 3 年之前 | |
| README.md | 3 年之前 | |
| index.css | 3 年之前 | |
| index.html | 3 年之前 | |
| package.json | 3 年之前 | |
| pnpm-lock.yaml | 3 年之前 | |
| prettier.config.js | 3 年之前 | |
| tsconfig.json | 3 年之前 | |
| vite.config.ts | 3 年之前 |
master-fetch 分支是带有后端接口请求的分支
后端项目地址:https://gitee.com/MTrun/go-view-serve
所有的接口地址位置:src\api\path\*
接口地址修改:.env
# port
VITE_DEV_PORT = '8080'
# development path
VITE_DEV_PATH = 'http://127.0.0.1:8080'
# production path
VITE_PRO_PATH = 'http://127.0.0.1:8080'
公共前缀修改:src\settings\httpSetting.ts
// 请求前缀
export const axiosPre = '/goview'
接口封装:src\api\http.ts
import axiosInstance from './axios'
import { RequestHttpEnum, ContentTypeEnum } from '@/enums/httpEnum'
export const get = (url: string, params?: object) => {
return axiosInstance({
url: url,
method: RequestHttpEnum.GET,
params: params,
})
}
export const post = (url: string, data?: object, headersType?: string) => {
return axiosInstance({
url: url,
method: RequestHttpEnum.POST,
data: data,
headers: {
'Content-Type': headersType || ContentTypeEnum.JSON
}
})
}
export const put = (url: string, data?: object, headersType?: string) => {
return axiosInstance({
url: url,
method: RequestHttpEnum.PUT,
data: data,
headers: {
'Content-Type': headersType || ContentTypeEnum.JSON
}
})
}
export const del = (url: string, params?: object) => {
return axiosInstance({
url: url,
method: RequestHttpEnum.DELETE,
params
})
}
// 获取请求函数,默认get
export const http = (type?: RequestHttpEnum) => {
switch (type) {
case RequestHttpEnum.GET:
return get
case RequestHttpEnum.POST:
return post
case RequestHttpEnum.PUT:
return put
case RequestHttpEnum.DELETE:
return del
default:
return get
}
}
QQ 群:1030129384