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) => { export const defineMock = createDefineMock((mock) => {
// 拼接url // 拼接url
mock.url = path.join( mock.url = path.join(import.meta.env.VITE_APP_BASE_API + "/api/v1/", mock.url);
import.meta.env.VITE_APP_BASE_API + "/api/v1/",
mock.url
);
}); });

View File

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

View File

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

View File

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

View File

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

View File

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