This commit is contained in:
六如
2024-12-19 18:05:59 +08:00
parent 3e06fcd799
commit f7f04c28eb
24 changed files with 517 additions and 188 deletions

View File

@@ -1,156 +1,12 @@
// 模拟后端动态生成路由
import { defineFakeRoute } from "vite-plugin-fake-server/client";
import { system } from "@/router/enums";
const apiRouters = [
{
path: "/serve",
meta: {
title: "服务管理",
icon: "ri:server-line",
rank: 10
},
children: [
{
path: "/serve/api",
name: "ServeApi",
meta: {
title: "接口管理",
roles: ["admin"]
}
}
]
},
{
path: "/doc",
meta: {
title: "文档管理",
icon: "ep:document",
rank: 10
},
children: [
{
path: "/doc/setting",
name: "DocSetting",
meta: {
title: "基础配置",
roles: ["admin"]
}
},
{
path: "/doc/list",
name: "DocList",
meta: {
title: "文档列表",
roles: ["admin"]
}
}
]
},
{
path: "/isv",
meta: {
title: "ISV管理",
icon: "ri:shield-user-line",
rank: 10
},
children: [
{
path: "/isv/list",
name: "IsvList",
meta: {
title: "ISV列表",
roles: ["admin"]
}
},
{
path: "/isv/perm/permGroup",
name: "IsvPermPermGroup",
meta: {
title: "分组管理",
roles: ["admin"]
}
}
]
}
// ,
// {
// path: "/sys",
// meta: {
// title: "系统管理",
// icon: "ri:settings-2-line",
// rank: 10
// },
// children: [
// {
// path: "/admin/user/index",
// name: "AdminUser",
// meta: {
// title: "用户管理",
// roles: ["admin"]
// }
// }
// ]
// }
];
const systemManagementRouter = {
path: "/system",
meta: {
icon: "ri:settings-3-line",
title: "menus.pureSysManagement",
rank: system
},
children: [
{
path: "/system/user/index",
name: "SystemUser",
meta: {
icon: "ri:admin-line",
title: "menus.pureUser",
roles: ["admin"]
}
},
{
path: "/system/role/index",
name: "SystemRole",
meta: {
icon: "ri:admin-fill",
title: "menus.pureRole",
roles: ["admin"]
}
},
{
path: "/system/menu/index",
name: "SystemMenu",
meta: {
icon: "ep:menu",
title: "menus.pureSystemMenu",
roles: ["admin"]
}
},
{
path: "/system/dept/index",
name: "SystemDept",
meta: {
icon: "ri:git-branch-line",
title: "menus.pureDept",
roles: ["admin"]
}
}
]
};
export default defineFakeRoute([
{
url: "/get-async-routes",
method: "get",
response: () => {
return {
success: true,
data: apiRouters.concat(systemManagementRouter)
};
return [];
}
}
]);

View File

@@ -1,4 +1,9 @@
import { http } from "@/utils/http";
import { createUrl, http } from "@/utils/http";
// 后端请求接口
const apiUrl: any = createUrl({
listMenu: "sys/userperm/listCurrentUserMenu"
});
type Result = {
success: boolean;
@@ -6,5 +11,6 @@ type Result = {
};
export const getAsyncRoutes = () => {
return http.request<Result>("get", "/get-async-routes");
return http.request<Result>("get", apiUrl.listMenu);
// return http.request<Result>("get", "/get-async-routes");
};

View File

@@ -0,0 +1,23 @@
/**
* 按钮权限定义
*/
export const PermCode = {
// 接口管理按钮权限
api: {
// 更新
update: "api:table-btn:update",
// 启用/禁用
updateStatus: "api:table-btn:updateStatus"
},
// 文档列表按钮定义
doc: {
// 发布
publish: "doc:table-btn:publish",
// 下线
offline: "doc:table-btn:offline",
// 同步
sync: "doc:table-btn:sync",
// 同步所有接口
syncAll: "doc:page-btn:sync"
}
};

View File

@@ -1,12 +1,14 @@
import { computed, onMounted, ref } from "vue";
import { ElMessage, ElMessageBox } from "element-plus";
import { api } from "@/api/doc";
import { PermCode } from "@/utils/perm";
import {
type ButtonsCallBackParams,
type PlusColumn,
useTable
} from "plus-pro-components";
import { YesOrNoEnum } from "@/model/enums";
import { hasPerms } from "@/utils/auth";
export function useDocList() {
const tabsData = ref<Array<any>>([
@@ -45,6 +47,8 @@ export function useDocList() {
);
};
// 按钮权限code
const btnCode = PermCode.doc;
// 表格字段定义
const tableColumns: PlusColumn[] = [
{
@@ -129,7 +133,7 @@ export function useDocList() {
search();
});
},
show: (row: any) => row.isFolder === 1
show: (row: any) => hasPerms(btnCode.publish) && row.isFolder === 1
},
{
text: "下线",
@@ -155,7 +159,7 @@ export function useDocList() {
search();
});
},
show: (row: any) => row.isFolder === 1
show: (row: any) => hasPerms(btnCode.offline) && row.isFolder === 1
},
{
text: row => (row.isPublish ? "下线" : "发布"),
@@ -181,7 +185,10 @@ export function useDocList() {
search();
});
},
show: (row: any) => row.isFolder === 0
show: (row: any) => {
const perm = row.isPublish ? btnCode.offline : btnCode.publish;
return hasPerms(perm) && row.isFolder === 0;
}
},
{
text: "同步",
@@ -210,7 +217,8 @@ export function useDocList() {
.catch(() => {
loading.value = false;
});
}
},
show: () => hasPerms(btnCode.sync)
}
];

View File

@@ -1,6 +1,7 @@
<script setup lang="ts">
import { useDocList } from "./index";
import { Search } from "@element-plus/icons-vue";
import { hasPerms } from "@/utils/auth";
defineOptions({
name: "DocList"
});
@@ -65,7 +66,11 @@ const {
</el-input>
</template>
<template #toolbar>
<el-button type="primary" @click="handleSyncApi">
<el-button
v-if="hasPerms('doc:page-btn:sync')"
type="primary"
@click="handleSyncApi"
>
同步全部接口
</el-button>
</template>

View File

@@ -8,6 +8,8 @@ import {
import { ElMessage } from "element-plus";
import { RegSource, StatusEnum, YesOrNoEnum } from "@/model/enums";
import { api } from "@/api/serveApi";
import { hasPerms } from "@/utils/auth";
import { PermCode } from "@/utils/perm";
const isAdd = ref(false);
@@ -195,6 +197,8 @@ export const tableColumns: PlusColumn[] = [
width: 160
}
];
// 表格按钮权限
const btnCode = PermCode.api;
// 表格按钮定义
actionButtons.value = [
{
@@ -204,13 +208,13 @@ actionButtons.value = [
props: {
type: "primary"
},
show: computed(() => true),
onClick(params: ButtonsCallBackParams) {
isAdd.value = false;
editFormData.value = Object.assign({}, params.row);
dlgTitle.value = "修改接口";
dlgShow.value = true;
}
},
show: () => hasPerms(btnCode.update)
},
{
// 启用/禁用
@@ -235,7 +239,8 @@ actionButtons.value = [
ElMessage.success("修改成功");
search();
});
}
},
show: () => hasPerms(btnCode.updateStatus)
}
];