refactor: ♻️ 移除 log 和完善 mock 接口

This commit is contained in:
hxr
2024-01-10 23:43:59 +08:00
parent a7233960e3
commit 06c448ebbc
10 changed files with 970 additions and 140 deletions

View File

@@ -30,4 +30,46 @@ export default defineMock([
msg: "一切ok",
},
},
{
url: "/api/v1/dept",
method: ["GET"],
body: {
code: "00000",
data: [
{
id: 1,
parentId: 0,
name: "有来技术",
sort: 1,
status: 1,
children: [
{
id: 2,
parentId: 1,
name: "研发部门",
sort: 1,
status: 1,
children: [],
createTime: null,
updateTime: "2022-04-19 12:46",
},
{
id: 3,
parentId: 1,
name: "测试部门",
sort: 1,
status: 1,
children: [],
createTime: null,
updateTime: "2022-04-19 12:46",
},
],
createTime: null,
updateTime: null,
},
],
msg: "一切ok",
},
},
]);

View File

@@ -38,4 +38,62 @@ export default defineMock([
};
},
},
{
url: "/api/v1/dict/types/page",
method: ["GET"],
body: {
code: "00000",
data: {
list: [
{
id: 1,
name: "性别",
code: "gender",
status: 1,
},
{
id: 2,
name: "状态",
code: "status",
status: 1,
},
],
total: 2,
},
msg: "一切ok",
},
},
{
url: "/api/v1/dict/page",
method: ["GET"],
body: {
code: "00000",
data: {
list: [
{
id: 1,
name: "男",
value: "1",
status: 1,
},
{
id: 2,
name: "女",
value: "2",
status: 1,
},
{
id: 3,
name: "未知",
value: "0",
status: 1,
},
],
total: 3,
},
msg: "一切ok",
},
},
]);

File diff suppressed because it is too large Load Diff

View File

@@ -60,4 +60,108 @@ export default defineMock([
msg: "一切ok",
},
},
{
url: "/api/v1/roles/page",
method: ["GET"],
body: {
code: "00000",
data: {
list: [
{
id: 2,
name: "系统管理员",
code: "ADMIN",
status: 1,
sort: 2,
createTime: "2021-03-25 12:39:54",
updateTime: null,
},
{
id: 3,
name: "访问游客",
code: "GUEST",
status: 1,
sort: 3,
createTime: "2021-05-26 15:49:05",
updateTime: "2019-05-05 16:00:00",
},
{
id: 4,
name: "系统管理员1",
code: "ADMIN1",
status: 1,
sort: 2,
createTime: "2021-03-25 12:39:54",
updateTime: null,
},
{
id: 5,
name: "系统管理员2",
code: "ADMIN2",
status: 1,
sort: 2,
createTime: "2021-03-25 12:39:54",
updateTime: null,
},
{
id: 6,
name: "系统管理员3",
code: "ADMIN3",
status: 1,
sort: 2,
createTime: "2021-03-25 12:39:54",
updateTime: null,
},
{
id: 7,
name: "系统管理员4",
code: "ADMIN4",
status: 1,
sort: 2,
createTime: "2021-03-25 12:39:54",
updateTime: null,
},
{
id: 8,
name: "系统管理员5",
code: "ADMIN5",
status: 1,
sort: 2,
createTime: "2021-03-25 12:39:54",
updateTime: null,
},
{
id: 9,
name: "系统管理员6",
code: "ADMIN6",
status: 1,
sort: 2,
createTime: "2021-03-25 12:39:54",
updateTime: "2023-12-04 11:43:15",
},
{
id: 10,
name: "系统管理员7",
code: "ADMIN7",
status: 1,
sort: 2,
createTime: "2021-03-25 12:39:54",
updateTime: null,
},
{
id: 11,
name: "系统管理员8",
code: "ADMIN8",
status: 1,
sort: 2,
createTime: "2021-03-25 12:39:54",
updateTime: null,
},
],
total: 10,
},
msg: "一切ok",
},
},
]);

View File

@@ -129,25 +129,3 @@ export default defineMock([
},
},
]);
import { defineMock } from "vite-plugin-mock-dev-server";
export default defineMock([
{
url: "/api/hello_world",
method: ["GET"],
},
{
url: "/api/v1/auth/captcha",
method: ["GET"],
body: {
code: "00000",
data: {
captchaKey: "534b8ef2b0a24121bec76391ddd159f9",
captchaBase64:
"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAHgAAAAkCAIAAADNSmkJAAAFKUlEQVR4Xu2ZXUwcVRiGV70wMWo08V5NvPXCrDbFaGpMaZW2hqQxaoiJTRsaMBCNSYtpa2JTKiFSelFa+Q/QZcMWqEhBlh+htbEpZhMrBQrlJ0hBywLLyrJ0WZbje3bqOvPNLHPWrDvdOE9ONmfe78zkzMs335wzWJhJQrBQweS/wTQ6QWgYHdoIOcecOe05O+t2WkutO+p2ZF3Ksg/YV9ZW6FATYajR3nveg60H9327r3O8c35lHgp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OZI3Qt8GFzMwxyjo3RgBiN4fr+elXVpZGRLWXl6PdOTtJBSlBDUK/lnIrjOlrtqWYTQDJaF6FrTXu9sOa1ysrVoM5HVE1GFxZQcyJ/p+xzv6K/rbr6N6+XDpUBl0tKFIrbz78qWB6YnWFMCBld4XLBms+7df75ook/GNzb0GCV7U1Qfz9p64TyQWNjYD3qe9rj4SMJtQP3MyjSDPzWIRHPjH7X4YAvfXoPuyZf9Pbi3PcuXIh4mp3NllYC6XY79C+jl2o8PBipxjnBttn4MgMNnWgfcRJGPI2OL8hTj3LloIlmRicvBhiNykvecpqoa3RSY4DRcLAwyicuOepVR1JjgNFYHWONHL04czTX0UmNAUYD7Pr+xc4wqTHGaBb2OtZvHUmNYUazcA2J6etdUmOk0f8rTKMTxF91RG0D1SwYGwAAAABJRU5ErkJggg==",
},
msg: "一切ok",
},
},
]);

View File

@@ -79,7 +79,6 @@ const tagsViewStore = useTagsViewStore();
const appStore = useAppStore();
const { visitedViews } = storeToRefs(tagsViewStore);
console.log("visitedViews", visitedViews);
const settingsStore = useSettingsStore();
const layout = computed(() => settingsStore.layout);
@@ -142,14 +141,11 @@ function filterAffixTags(routes: RouteRecordRaw[], basePath = "/") {
let tags: TagView[] = [];
routes.forEach(processRoute);
console.log("filterAffixTags", tags);
return tags;
}
function initTags() {
const tags: TagView[] = filterAffixTags(permissionStore.routes);
console.log("initTags", tags);
affixTags.value = tags;
for (const tag of tags) {
// Must have tag name
@@ -160,7 +156,6 @@ function initTags() {
}
function addTags() {
console.log("addTags", visitedViews);
if (route.meta.title) {
tagsViewStore.addView({
name: route.name as string,
@@ -174,7 +169,6 @@ function addTags() {
}
function moveToCurrentTag() {
console.log("moveToCurrentTag", visitedViews);
// 使用 nextTick() 的目的是确保在更新 tagsView 组件之前scrollPaneRef 对象已经滚动到了正确的位置。
nextTick(() => {
for (const tag of visitedViews.value) {

View File

@@ -4,13 +4,10 @@ export const useTagsViewStore = defineStore("tagsView", () => {
const visitedViews = ref<TagView[]>([]);
const cachedViews = ref<string[]>([]);
console.log("first visitedViews", visitedViews, "cachedViews", cachedViews);
/**
* 添加已访问视图到已访问视图列表中
*/
function addVisitedView(view: TagView) {
console.log("addVisitedView", visitedViews, view);
// 如果已经存在于已访问的视图列表中,则不再添加
if (visitedViews.value.some((v) => v.fullPath === view.fullPath)) {
return;
@@ -28,7 +25,6 @@ export const useTagsViewStore = defineStore("tagsView", () => {
* 添加缓存视图到缓存视图列表中
*/
function addCachedView(view: TagView) {
console.log("addCachedView", visitedViews, view);
const viewName = view.name;
// 如果缓存视图名称已经存在于缓存视图列表中,则不再添加
if (cachedViews.value.includes(viewName)) {
@@ -90,7 +86,6 @@ export const useTagsViewStore = defineStore("tagsView", () => {
}
function updateVisitedView(view: TagView) {
console.log("updateVisitedView", visitedViews, view);
for (let v of visitedViews.value) {
if (v.path === view.path) {
v = Object.assign(v, view);
@@ -100,7 +95,6 @@ export const useTagsViewStore = defineStore("tagsView", () => {
}
function addView(view: TagView) {
console.log("addView", visitedViews, view);
addVisitedView(view);
addCachedView(view);
}

View File

@@ -182,7 +182,6 @@ function openMenuDialog(row: RolePageVO) {
getRoleMenuIds(roleId)
.then(({ data }) => {
const checkedMenuIds = data;
console.log("勾选权限", checkedMenuIds);
checkedMenuIds.forEach((menuId) =>
menuRef.value.setChecked(menuId, true, false)
);

View File

@@ -291,7 +291,6 @@ function downloadTemplate() {
/** Excel文件 Change */
function handleFileChange(file: any) {
importData.file = file.raw;
console.log(importData.file);
}
/** Excel文件 Exceed */

View File

@@ -66,6 +66,8 @@ export default defineConfig(({ mode }: ConfigEnv): UserConfig => {
UnoCSS({
hmrTopLevelAwait: false,
}),
// MOCK 服务
mockDevServerPlugin(),
// 自动导入参考: https://github.com/sxzz/element-plus-best-practices/blob/main/vite.config.ts
AutoImport({
// 自动导入 Vue 相关函数ref, reactive, toRef 等
@@ -106,8 +108,6 @@ export default defineConfig(({ mode }: ConfigEnv): UserConfig => {
// 指定symbolId格式
symbolId: "icon-[dir]-[name]",
}),
// 开启 mock
mockDevServerPlugin(),
],
// 预加载项目必需的组件
optimizeDeps: {