Compare commits

..

No commits in common. "b62b4272f1877c42a1d8439bd6954d7e680d2526" and "6721db00024fcffa54cbc3d90b6ccbb3a868674e" have entirely different histories.

4 changed files with 6 additions and 98 deletions

View File

@ -1,8 +0,0 @@
import request from "@/utils/request";
// 统一管理接口
const API = {
LOGIN_URL: "/api/user",
udaiu: "/user",
};
export const reqUser = () => request.get(API.LOGIN_URL);
export const reqUser = (data) => request.post(API.LOGIN_URL, data);

View File

@ -46,7 +46,6 @@
<script setup>
import { MessagePlugin } from "tdesign-vue-next";
import { reactive, ref } from "vue";
import { reqUser } from "@/api/login";
// import { DesktopIcon, LockOnIcon } from "tdesign-icons-vue";
const INITIAL_DATA = {
@ -90,15 +89,14 @@ const rules = reactive({
});
const onReset = () => {
MessagePlugin.success("重置成功");
};
const onSubmit = async ({ validateResult, firstError }) => {
await reqUser();
MessagePlugin.success('重置成功')
}
const onSubmit = ({ validateResult, firstError }) => {
if (validateResult === true) {
MessagePlugin.success("提交成功");
MessagePlugin.success('提交成功')
} else {
console.log("Errors: ", validateResult);
MessagePlugin.warning(firstError);
console.log('Errors: ', validateResult)
MessagePlugin.warning(firstError)
}
};

View File

@ -1,73 +0,0 @@
// 进行axios二次封装使用请求与响应拦截器
import axios from "axios";
import { MessagePlugin } from "tdesign-vue-next";
import { useRouter } from "vue-router";
// import { refreshToken } from '@/apis/token'
// import { useTokenStore } from '@/stores/index'
// 第一步:利用axios对象的create方法去创建axios实例(其他的配置:基础的路径、超时的时间)
const request = axios.create({
baseURL: "/", // 基础路径上会携带/api
timeout: 5000, // 超时的时间的设置
});
// 第二步axios实例添加请求与响应拦截器
request.interceptors.request.use((config) => {
// config配置对象headers属性请求头经常给服务器端携带公共参数
// 返回配置对象
// const { token } = useTokenStore()
// if (token) {
// config.headers.Authorization = `Bearer ${token}`
// }
return config;
});
// 第三步axios响应拦截器
request.interceptors.response.use(
(response) => {
// 成功回调
// 简化数据
return response.data;
},
async (error) => {
// 失败回调处理http网络错误的
// 定义一个变量:存储网络错误信息
let message = "";
const { status } = error.response;
// http状态码
switch (status) {
case 401:
// try {
// const tokenStore = useTokenStore()
// const refreshedTokenData = await refreshToken(tokenStore.refreshToken)
// if (refreshedTokenData && refreshedTokenData.data.token) {
// tokenStore.setToken(refreshedTokenData.data.token)
// const originalRequest = error.config
// originalRequest.headers.Authorization = `Bearer ${refreshedTokenData.data.token}`
// return request(originalRequest)
// }
// } catch (error) {
// const tokenStore = useTokenStore()
// tokenStore.clearToken()
// useRouter().push('/login')
// }
break;
case 403:
message = "无权访问";
break;
case 404:
message = "请求地址错误";
break;
case 500:
message = "服务器出现问题";
break;
default:
message = "网络出现问题";
break;
}
MessagePlugin.error(message);
return Promise.reject(error);
}
);
// 对外暴露
export default request;

View File

@ -8,15 +8,6 @@ import { viteMockServe } from "vite-plugin-mock";
// https://vitejs.dev/config/
export default defineConfig({
server: {
proxy: {
"/api": {
target: "http://192.168.1.10:8000",
changeOrigin: true,
},
},
},
plugins: [
vue(),
vueJsx(),