缩小小程序体积

This commit is contained in:
34701892@qq.com 2025-08-13 12:04:58 +08:00
parent 5934ff0b93
commit 784e1c2be1
94 changed files with 403 additions and 192 deletions

View File

@ -1,15 +0,0 @@
@font-face {
font-family: "SourceHanSansCN-Regular";
font-style: normal;
src: url("./PingFang_Medium.ttf") format("opentype");
}
@font-face {
font-family: "SourceHanSansCN-Medium";
font-style: normal;
src: url("./SourceHanSansCN-Medium.otf") format("opentype");
}
html,
body {
font-family: "SourceHanSansCN-Regular";
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 480 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 989 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 233 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 994 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 258 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 646 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 851 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 39 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 106 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 701 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 234 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 470 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 707 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 536 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 860 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 800 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 237 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 639 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 92 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 416 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 839 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 238 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 388 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 580 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 735 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 142 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 36 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 44 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 892 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 37 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 70 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 28 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 62 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 47 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 466 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 502 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 158 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 231 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 269 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 78 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 122 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 120 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 42 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 34 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.7 KiB

View File

@ -1,4 +1,4 @@
// const baseURL = "http://192.168.31.25:8060/api"; // const baseURL = "http://192.168.31.25:8060/api";
const baseURL = "http://localhost:8060/api"; export const baseUrl = "https://cankao.cs.com.cn/apih5";
export const baseUrlDataV = "https://cankao.cs.com.cn/zzck_datav";
export default baseURL;

View File

@ -2,9 +2,7 @@ import { createSSRApp } from "vue";
import pinia from "@/stores/index"; import pinia from "@/stores/index";
import App from "./App.vue"; import App from "./App.vue";
import uviewPlus from "@/uni_modules/uview-plus"; import uviewPlus from "@/uni_modules/uview-plus";
import "@/assets/fonts/font.css"; // import "@/assets/fonts/font.css";
export function createApp() { export function createApp() {
const app = createSSRApp(App); const app = createSSRApp(App);

View File

@ -123,12 +123,6 @@
<script setup> <script setup>
import { ref, onMounted, onUnmounted, reactive } from "vue"; import { ref, onMounted, onUnmounted, reactive } from "vue";
import Line from "@/components/charts/Line.vue"; import Line from "@/components/charts/Line.vue";
// import bannerImg from "https://cankao.obs.cn-east-3.myhuaweicloud.com/mini/zixun/banner_pic.png";
// import bannerTitle from "https://cankao.obs.cn-east-3.myhuaweicloud.com/mini/zixun/banner_title.png";
// import tagicon_1_bg from "https://cankao.obs.cn-east-3.myhuaweicloud.com/mini/zixun/tagicon_1_bg.png";
// import tagicon_2_bg from "https://cankao.obs.cn-east-3.myhuaweicloud.com/mini/zixun/tagicon_2_bg.png";
// import tagicon_1 from "https://cankao.obs.cn-east-3.myhuaweicloud.com/mini/zixun/tagicon_1.png";
// import tagicon_2 from "https://cankao.obs.cn-east-3.myhuaweicloud.com/mini/zixun/tagicon_2.png";
import LoginPopup from "@/components/loginPopup/index.vue"; import LoginPopup from "@/components/loginPopup/index.vue";
import { Session } from "@/utils/storage"; import { Session } from "@/utils/storage";
@ -148,6 +142,7 @@ import InfoSummary from "@/components/InfoSummary.vue"; // 路径根据实际调
import indexMenuTitle from "@/components/indexMenuTitle.vue"; // import indexMenuTitle from "@/components/indexMenuTitle.vue"; //
import dayjs from "dayjs/esm/index"; import dayjs from "dayjs/esm/index";
import HotIndustryList from "@/components/HotIndustryList.vue"; // import HotIndustryList from "@/components/HotIndustryList.vue"; //
import { onLoad } from "@dcloudio/uni-app";
const newsList = ref([]); const newsList = ref([]);
@ -265,12 +260,19 @@ onUnmounted(() => {
clearInterval(timer); clearInterval(timer);
}); });
onMounted(async () => { // onMounted(async () => {
// initData();
// if (!Session.get("token")) {
// LoginShow.value = true;
// }
// });
onLoad(() => {
initData(); initData();
if (!Session.get("token")) { if (!Session.get("token")) {
LoginShow.value = true; LoginShow.value = true;
} }
}); })
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">

90
src/utils/index copy.ts Normal file
View File

@ -0,0 +1,90 @@
import axios from "axios";
import type { AxiosResponse } from "axios";
// import { ElMessage, ElMessageBox, ElNotification } from 'element-plus';
import { Session } from "@/utils/storage";
import qs from "qs";
// 配置新建一个 axios 实例
const service = axios.create({
baseURL: import.meta.env.VITE_API_URL,
timeout: 50000,
headers: { "Content-Type": "application/json" },
paramsSerializer: {
serialize(params) {
return qs.stringify(params, { allowDots: true });
},
},
});
// 添加请求拦截器
service.interceptors.request.use(
(config) => {
// 在发送请求之前做些什么 token
if (Session.get("token")) {
config.headers!["auth-token"] = `${Session.get("token")}`;
config.headers!["phone"] = `${Session.get("userPhone")}`;
}
return config;
},
(error) => {
// 对请求错误做些什么
return Promise.reject(error);
}
);
// 添加响应拦截器
service.interceptors.response.use(
(response) => {
// 对响应数据做点什么
const res: AxiosResponse = response.data;
if (res.code && res.code !== 200) {
console.log("提示");
uni.showToast({
title: res.msg,
icon: "error",
duration: 2000,
});
// ElNotification({
// title: '提示',
// message: 'res.msg',
// type: 'error',
// });
// `token` 过期或者账号已在别处登录
if (res.code === 401 || res.code === 4001) {
Session.clear(); // 清除浏览器全部临时缓存
window.location.href = "/"; // 去登录页
console.log("你已被登出,请重新登录");
// ElMessageBox.alert('你已被登出,请重新登录', '提示', {})
// .then(() => {})
// .catch(() => {});
}
// return Promise.reject(service.interceptors.response);
return res;
} else {
return res;
}
},
(error) => {
// 对响应错误做点什么
if (error.message.indexOf("timeout") != -1) {
// ElMessage.error('网络超时');
console.log("网络超时");
} else if (error.message == "Network Error") {
// ElMessage.error('网络连接错误');
console.log("网络连接错误");
} else {
if (error.response.data) {
// ElMessage.error(error.response.statusText)
console.log("error.response.statusText ===>", error.response.statusText);
} else {
// ElMessage.error('接口路径找不到')
console.log("接口路径找不到");
}
}
return Promise.reject(error);
}
);
// 导出 axios 实例
export default service;

View File

@ -1,90 +1,57 @@
import axios from "axios"; import requestClass from "./requestClass";
import type { AxiosResponse } from "axios"; import { baseUrl } from "@/config/index";
// import { ElMessage, ElMessageBox, ElNotification } from 'element-plus';
import { Session } from "@/utils/storage";
import qs from "qs"; import qs from "qs";
// 配置新建一个 axios 实例 const Request = new requestClass();
const service = axios.create({
baseURL: import.meta.env.VITE_API_URL, // 请求拦截器
timeout: 50000, Request.interceptors.request((request: any) => {
headers: { "Content-Type": "application/json" }, if (request.header.contentType) {
paramsSerializer: { request.header["content-type"] = request.header.contentType;
serialize(params) { delete request.header.contentType;
return qs.stringify(params, { allowDots: true }); }
}, if (request.method === "GET") {
}, request.data = qs.stringify(request.data);
request.url = request.url + "?" + request.data;
}
return request;
}); });
// 添加请求拦截器 // 响应拦截器
service.interceptors.request.use( Request.interceptors.response((response: any) => {
(config) => { // 对响应数据做点什么
// 在发送请求之前做些什么 token const res = response.data;
if (Session.get("token")) { if (res.code && res.code !== 200) {
config.headers!["auth-token"] = `${Session.get("token")}`; console.log("提示");
config.headers!["phone"] = `${Session.get("userPhone")}`; uni.showToast({
} title: res.msg,
return config; icon: "error",
}, duration: 2000,
(error) => { });
// 对请求错误做些什么
return Promise.reject(error); // `token` 过期或者账号已在别处登录
// if (res.code === 401 || res.code === 4001) {
// Session.clear(); // 清除浏览器全部临时缓存
// window.location.href = "/"; // 去登录页
// console.log("你已被登出,请重新登录");
// }
return res;
} else {
return res;
} }
); });
// 添加响应拦截器 // 设置默认配置
service.interceptors.response.use( Request.setConfig((config: any) => {
(response) => { config.baseURL = baseUrl;
// 对响应数据做点什么 // config.baseURL = "http://127.0.0.1:8082";
const res: AxiosResponse = response.data; if (uni.getStorageSync("token")) {
if (res.code && res.code !== 200) { // config.header["Authorization"] = "Bearer " + uni.getStorageSync("token");
console.log("提示"); config.headers!["auth-token"] = uni.getStorageSync("token");
uni.showToast({ config.headers!["phone"] = uni.getStorageSync("token");
title: res.msg,
icon: "error",
duration: 2000,
});
// ElNotification({
// title: '提示',
// message: 'res.msg',
// type: 'error',
// });
// `token` 过期或者账号已在别处登录
if (res.code === 401 || res.code === 4001) {
Session.clear(); // 清除浏览器全部临时缓存
window.location.href = "/"; // 去登录页
console.log("你已被登出,请重新登录");
// ElMessageBox.alert('你已被登出,请重新登录', '提示', {})
// .then(() => {})
// .catch(() => {});
}
// return Promise.reject(service.interceptors.response);
return res;
} else {
return res;
}
},
(error) => {
// 对响应错误做点什么
if (error.message.indexOf("timeout") != -1) {
// ElMessage.error('网络超时');
console.log("网络超时");
} else if (error.message == "Network Error") {
// ElMessage.error('网络连接错误');
console.log("网络连接错误");
} else {
if (error.response.data) {
// ElMessage.error(error.response.statusText)
console.log("error.response.statusText ===>", error.response.statusText);
} else {
// ElMessage.error('接口路径找不到')
console.log("接口路径找不到");
}
}
return Promise.reject(error);
} }
);
// 导出 axios 实例 return config;
export default service; });
export default Request;

View File

@ -0,0 +1,90 @@
import axios from "axios";
import type { AxiosResponse } from "axios";
// import { ElMessage, ElMessageBox, ElNotification } from 'element-plus';
import { Session } from "@/utils/storage";
import qs from "qs";
// 配置新建一个 axios 实例
const service = axios.create({
baseURL: import.meta.env.VITE_API_DATAV_URL,
timeout: 50000,
headers: { "Content-Type": "application/json" },
paramsSerializer: {
serialize(params) {
return qs.stringify(params, { allowDots: true });
},
},
});
// 添加请求拦截器
service.interceptors.request.use(
(config) => {
// 在发送请求之前做些什么 token
if (Session.get("token")) {
config.headers!["auth-token"] = `${Session.get("token")}`;
config.headers!["phone"] = `${Session.get("userPhone")}`;
}
return config;
},
(error) => {
// 对请求错误做些什么
return Promise.reject(error);
}
);
// 添加响应拦截器
service.interceptors.response.use(
(response) => {
// 对响应数据做点什么
const res: AxiosResponse = response.data;
if (res.status && res.status !== 200) {
console.log("提示");
uni.showToast({
title: res.msg,
icon: "error",
duration: 2000,
});
// ElNotification({
// title: '提示',
// message: 'res.msg',
// type: 'error',
// });
// `token` 过期或者账号已在别处登录
if (res.status === 401 || res.status === 4001) {
Session.clear(); // 清除浏览器全部临时缓存
window.location.href = "/"; // 去登录页
console.log("你已被登出,请重新登录");
// ElMessageBox.alert('你已被登出,请重新登录', '提示', {})
// .then(() => {})
// .catch(() => {});
}
// return Promise.reject(service.interceptors.response);
return res;
} else {
return res;
}
},
(error) => {
// 对响应错误做点什么
if (error.message.indexOf("timeout") != -1) {
// ElMessage.error('网络超时');
console.log("网络超时");
} else if (error.message == "Network Error") {
// ElMessage.error('网络连接错误');
console.log("网络连接错误");
} else {
if (error.response.data) {
// ElMessage.error(error.response.statusText)
console.log("error.response.statusText ===>", error.response.statusText);
} else {
// ElMessage.error('接口路径找不到')
console.log("接口路径找不到");
}
}
return Promise.reject(error);
}
);
// 导出 axios 实例
export default service;

View File

@ -1,90 +1,57 @@
import axios from "axios"; import requestClass from "./requestClass";
import type { AxiosResponse } from "axios"; import { baseUrlDataV } from "@/config/index";
// import { ElMessage, ElMessageBox, ElNotification } from 'element-plus';
import { Session } from "@/utils/storage";
import qs from "qs"; import qs from "qs";
// 配置新建一个 axios 实例 const Request = new requestClass();
const service = axios.create({
baseURL: import.meta.env.VITE_API_DATAV_URL, // 请求拦截器
timeout: 50000, Request.interceptors.request((request: any) => {
headers: { "Content-Type": "application/json" }, if (request.header.contentType) {
paramsSerializer: { request.header["content-type"] = request.header.contentType;
serialize(params) { delete request.header.contentType;
return qs.stringify(params, { allowDots: true }); }
}, if (request.method === "GET") {
}, request.data = qs.stringify(request.data);
request.url = request.url + "?" + request.data;
}
return request;
}); });
// 添加请求拦截器 // 响应拦截器
service.interceptors.request.use( Request.interceptors.response((response: any) => {
(config) => { // 对响应数据做点什么
// 在发送请求之前做些什么 token const res = response.data;
if (Session.get("token")) { if (res.code && res.code !== 200) {
config.headers!["auth-token"] = `${Session.get("token")}`; console.log("提示");
config.headers!["phone"] = `${Session.get("userPhone")}`; uni.showToast({
} title: res.msg,
return config; icon: "error",
}, duration: 2000,
(error) => { });
// 对请求错误做些什么
return Promise.reject(error); // `token` 过期或者账号已在别处登录
// if (res.code === 401 || res.code === 4001) {
// Session.clear(); // 清除浏览器全部临时缓存
// window.location.href = "/"; // 去登录页
// console.log("你已被登出,请重新登录");
// }
return res;
} else {
return res;
} }
); });
// 添加响应拦截器 // 设置默认配置
service.interceptors.response.use( Request.setConfig((config: any) => {
(response) => { config.baseURL = baseUrlDataV;
// 对响应数据做点什么 // config.baseURL = "http://127.0.0.1:8082";
const res: AxiosResponse = response.data; if (uni.getStorageSync("token")) {
if (res.status && res.status !== 200) { // config.header["Authorization"] = "Bearer " + uni.getStorageSync("token");
console.log("提示"); config.headers!["auth-token"] = uni.getStorageSync("token");
uni.showToast({ config.headers!["phone"] = uni.getStorageSync("token");
title: res.msg,
icon: "error",
duration: 2000,
});
// ElNotification({
// title: '提示',
// message: 'res.msg',
// type: 'error',
// });
// `token` 过期或者账号已在别处登录
if (res.status === 401 || res.status === 4001) {
Session.clear(); // 清除浏览器全部临时缓存
window.location.href = "/"; // 去登录页
console.log("你已被登出,请重新登录");
// ElMessageBox.alert('你已被登出,请重新登录', '提示', {})
// .then(() => {})
// .catch(() => {});
}
// return Promise.reject(service.interceptors.response);
return res;
} else {
return res;
}
},
(error) => {
// 对响应错误做点什么
if (error.message.indexOf("timeout") != -1) {
// ElMessage.error('网络超时');
console.log("网络超时");
} else if (error.message == "Network Error") {
// ElMessage.error('网络连接错误');
console.log("网络连接错误");
} else {
if (error.response.data) {
// ElMessage.error(error.response.statusText)
console.log("error.response.statusText ===>", error.response.statusText);
} else {
// ElMessage.error('接口路径找不到')
console.log("接口路径找不到");
}
}
return Promise.reject(error);
} }
);
// 导出 axios 实例 return config;
export default service; });
export default Request;

112
src/utils/requestClass.ts Normal file
View File

@ -0,0 +1,112 @@
const config = Symbol("config");
const isCompleteURL = Symbol("isCompleteURL");
const requestBefore = Symbol("requestBefore");
const requestAfter = Symbol("requestAfter");
class requestClass {
// 默认配置
[config]: { baseURL?: string } & UniApp.RequestOptions = {
baseURL: "",
url: "",
header: {
// "content-type": "application/x-www-form-urlencoded",
"content-type": "application/json",
},
method: "GET",
timeout: 3000,
dataType: "json",
responseType: "text",
};
// 拦截器
interceptors = {
request: (func: Fn) => {
if (func) {
requestClass[requestBefore] = func;
} else {
requestClass[requestBefore] = (request) => request;
}
},
response: (func: Fn) => {
if (func) {
requestClass[requestAfter] = func;
} else {
requestClass[requestAfter] = (response) => response;
}
},
};
// 请求之前,是默认配置
static [requestBefore](config: UniApp.RequestOptions) {
return config;
}
// 请求之后,默认配置发生改变的话
static [requestAfter](response: any) {
return response;
}
// 判断url是否完整
static [isCompleteURL](url: string) {
return /(http|https):\/\/([\w.]+\/?)\S*/.test(url);
}
request(options: UniApp.RequestOptions & { baseURL?: string }) {
options.baseURL = options.baseURL || this[config].baseURL;
options.dataType = options.dataType || this[config].dataType;
options.url = requestClass[isCompleteURL](options.url)
? options.url
: options.baseURL + options.url;
options.data = options.data;
options.header = { ...options.header, ...this[config].header };
options.method = options.method || this[config].method;
options = { ...options, ...requestClass[requestBefore](options) };
return new Promise((resolve, reject) => {
options.success = function (res) {
resolve(requestClass[requestAfter](res));
};
options.fail = function (err) {
reject(requestClass[requestAfter](err));
};
uni.request(options);
// 中断请求实现方法
// let obj: any = {}
// obj[request.url] = uni.request(options)
// abortRequest() {
// for (const key in obj) {
// if (Object.prototype.hasOwnProperty.call(obj, key)) {
// const element = obj[key];
// element.abort()
// }
// }
// }
});
}
get(url: string, data: any = {}, options: Recordable = {}) {
return this.request({ ...options, url, data, method: "GET" });
}
post(url: string, data: any = {}, options: Recordable = {}) {
return this.request({ ...options, url, data, method: "POST" });
}
put(url: string, data: any = {}, options: Recordable = {}) {
return this.request({ ...options, url, data, method: "PUT" });
}
delete(url: string, data: any = {}, options: Recordable = {}) {
return this.request({ ...options, url, data, method: "DELETE" });
}
getConfig() {
return this[config];
}
// 修改默认配置的一个方法,可以修改请求地址,请求方式等等..
setConfig(func: Fn) {
this[config] = func(this[config]);
}
}
export default requestClass;