style: 💄 mock接口根据 prettier 格式化

This commit is contained in:
ray
2025-01-13 18:28:03 +08:00
parent 01b8a6840c
commit 2cae42e8d9
6 changed files with 33 additions and 46 deletions

View File

@@ -3,8 +3,5 @@ import { createDefineMock } from "vite-plugin-mock-dev-server";
export const defineMock = createDefineMock((mock) => {
// 拼接url
mock.url = path.join(
import.meta.env.VITE_APP_BASE_API + "/api/v1/",
mock.url
);
mock.url = path.join(import.meta.env.VITE_APP_BASE_API + "/api/v1/", mock.url);
});

View File

@@ -127,8 +127,7 @@ export default defineMock([
},
{
id: 10,
title:
"v2.16.1 版本修复了 WebSocket 重复连接导致的后台线程阻塞问题,优化了通知公告。",
title: "v2.16.1 版本修复了 WebSocket 重复连接导致的后台线程阻塞问题,优化了通知公告。",
publishStatus: 1,
type: 1,
publisherName: "系统管理员",
@@ -150,7 +149,7 @@ export default defineMock([
{
url: "notices",
method: ["POST"],
body({ body }) {
body() {
return {
code: "00000",
data: null,
@@ -220,8 +219,7 @@ export default defineMock([
list: [
{
id: 10,
title:
"v2.16.1 版本修复了 WebSocket 重复连接导致的后台线程阻塞问题,优化了通知公告。",
title: "v2.16.1 版本修复了 WebSocket 重复连接导致的后台线程阻塞问题,优化了通知公告。",
type: 1,
level: "L",
publisherName: "系统管理员",
@@ -403,8 +401,7 @@ const noticeMap: Record<string, any> = {
},
10: {
id: 10,
title:
"v2.16.1 版本修复了 WebSocket 重复连接导致的后台线程阻塞问题,优化了通知公告。",
title: "v2.16.1 版本修复了 WebSocket 重复连接导致的后台线程阻塞问题,优化了通知公告。",
publishStatus: 1,
type: 1,
publisherName: "系统管理员",

View File

@@ -214,14 +214,13 @@ export default defineMock([
{
url: "roles/:id/menuIds",
method: ["GET"],
body: ({ params }) => {
body: ({}) => {
return {
code: "00000",
data: [
1, 2, 31, 32, 33, 88, 3, 70, 71, 72, 4, 73, 75, 74, 5, 76, 77, 78, 6,
79, 81, 84, 85, 86, 87, 40, 41, 26, 30, 20, 21, 22, 23, 24, 89, 90,
91, 36, 37, 38, 39, 93, 94, 95, 97, 102, 89, 90, 91, 93, 94, 95, 97,
102, 103, 104,
1, 2, 31, 32, 33, 88, 3, 70, 71, 72, 4, 73, 75, 74, 5, 76, 77, 78, 6, 79, 81, 84, 85, 86,
87, 40, 41, 26, 30, 20, 21, 22, 23, 24, 89, 90, 91, 36, 37, 38, 39, 93, 94, 95, 97, 102,
89, 90, 91, 93, 94, 95, 97, 102, 103, 104,
],
msg: "一切ok",
};

View File

@@ -10,8 +10,7 @@ export default defineMock([
userId: 2,
username: "admin",
nickname: "系统管理员",
avatar:
"https://foruda.gitee.com/images/1723603502796844527/03cdca2a_716974.gif",
avatar: "https://foruda.gitee.com/images/1723603502796844527/03cdca2a_716974.gif",
roles: ["ADMIN"],
perms: [
"sys:notice:edit",
@@ -65,8 +64,7 @@ export default defineMock([
nickname: "系统管理员",
mobile: "17621210366",
gender: 1,
avatar:
"https://foruda.gitee.com/images/1723603502796844527/03cdca2a_716974.gif",
avatar: "https://foruda.gitee.com/images/1723603502796844527/03cdca2a_716974.gif",
email: "",
status: 1,
deptId: 1,
@@ -78,8 +76,7 @@ export default defineMock([
nickname: "测试小用户",
mobile: "17621210366",
gender: 1,
avatar:
"https://foruda.gitee.com/images/1723603502796844527/03cdca2a_716974.gif",
avatar: "https://foruda.gitee.com/images/1723603502796844527/03cdca2a_716974.gif",
email: "youlaitech@163.com",
status: 1,
deptId: 3,
@@ -161,10 +158,8 @@ export default defineMock([
url: "users/_export",
method: ["GET"],
headers: {
"Content-Disposition":
"attachment; filename=%E7%94%A8%E6%88%B7%E5%88%97%E8%A1%A8.xlsx",
"Content-Type":
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
"Content-Disposition": "attachment; filename=%E7%94%A8%E6%88%B7%E5%88%97%E8%A1%A8.xlsx",
"Content-Type": "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
},
},
@@ -177,8 +172,7 @@ export default defineMock([
id: 2,
username: "admin",
nickname: "系统管理员",
avatar:
"https://foruda.gitee.com/images/1723603502796844527/03cdca2a_716974.gif",
avatar: "https://foruda.gitee.com/images/1723603502796844527/03cdca2a_716974.gif",
gender: 1,
mobile: "17621210366",
email: null,
@@ -192,7 +186,7 @@ export default defineMock([
{
url: "users/profile",
method: ["PUT"],
body({ query }) {
body() {
return {
code: "00000",
data: null,
@@ -204,7 +198,7 @@ export default defineMock([
{
url: "users/password",
method: ["PUT"],
body({ query }) {
body() {
return {
code: "00000",
data: null,
@@ -222,8 +216,7 @@ const userMap: Record<string, any> = {
nickname: "系统管理员",
mobile: "17621210366",
gender: 1,
avatar:
"https://foruda.gitee.com/images/1723603502796844527/03cdca2a_716974.gif",
avatar: "https://foruda.gitee.com/images/1723603502796844527/03cdca2a_716974.gif",
email: "",
status: 1,
deptId: 1,
@@ -235,8 +228,7 @@ const userMap: Record<string, any> = {
nickname: "测试小用户",
mobile: "17621210366",
gender: 1,
avatar:
"https://foruda.gitee.com/images/1723603502796844527/03cdca2a_716974.gif",
avatar: "https://foruda.gitee.com/images/1723603502796844527/03cdca2a_716974.gif",
email: "youlaitech@163.com",
status: 1,
deptId: 3,

View File

@@ -4,7 +4,7 @@ const AUTH_BASE_URL = "/api/v1/auth";
const AuthAPI = {
/** 登录接口*/
login(data: LoginData) {
login(data: LoginFormData) {
const formData = new FormData();
formData.append("username", data.username);
formData.append("password", data.password);
@@ -22,17 +22,19 @@ const AuthAPI = {
/** 刷新 token 接口*/
refreshToken(refreshToken: string) {
const formData = new FormData();
formData.append("refreshToken", refreshToken);
return request<any, LoginResult>({
url: `${AUTH_BASE_URL}/refresh-token`,
method: "post",
data: { refreshToken: refreshToken },
data: formData,
headers: {
Authorization: "no-auth",
},
});
},
/** 注销接口*/
/** 注销接口 */
logout() {
return request({
url: `${AUTH_BASE_URL}/logout`,
@@ -42,7 +44,7 @@ const AuthAPI = {
/** 获取验证码接口*/
getCaptcha() {
return request<any, CaptchaResult>({
return request<any, CaptchaInfo>({
url: `${AUTH_BASE_URL}/captcha`,
method: "get",
});
@@ -51,8 +53,8 @@ const AuthAPI = {
export default AuthAPI;
/** 登录请求参数 */
export interface LoginData {
/** 登录表单数据 */
export interface LoginFormData {
/** 用户名 */
username: string;
/** 密码 */
@@ -75,8 +77,8 @@ export interface LoginResult {
expiresIn: number;
}
/** 验证码响应 */
export interface CaptchaResult {
/** 验证码信息 */
export interface CaptchaInfo {
/** 验证码缓存key */
captchaKey: string;
/** 验证码图片Base64字符串 */

View File

@@ -2,7 +2,7 @@ import { store } from "@/store";
import { usePermissionStoreHook } from "@/store/modules/permission";
import { useDictStoreHook } from "@/store/modules/dict";
import AuthAPI, { type LoginData } from "@/api/auth";
import AuthAPI, { type LoginFormData } from "@/api/auth";
import UserAPI, { type UserInfo } from "@/api/system/user";
import { setToken, setRefreshToken, getRefreshToken, clearToken } from "@/utils/auth";
@@ -13,12 +13,12 @@ export const useUserStore = defineStore("user", () => {
/**
* 登录
*
* @param {LoginData}
* @param {LoginFormData}
* @returns
*/
function login(loginData: LoginData) {
function login(LoginFormData: LoginFormData) {
return new Promise<void>((resolve, reject) => {
AuthAPI.login(loginData)
AuthAPI.login(LoginFormData)
.then((data) => {
const { tokenType, accessToken, refreshToken } = data;
setToken(tokenType + " " + accessToken); // Bearer eyJhbGciOiJIUzI1NiJ9.xxx.xxx