diff --git a/f/web-kboss/src/api/roleManagement.js b/f/web-kboss/src/api/roleManagement.js new file mode 100644 index 0000000..cca6343 --- /dev/null +++ b/f/web-kboss/src/api/roleManagement.js @@ -0,0 +1,33 @@ +import request from '@/utils/request' +// 获取角色 +export function getRoleAPI(data) { + return request({ + url: `/role/getRole.dspy`, + method: 'get', + params: data + }) +} +// 添加角色 +export function addRoleAPI(data) { + return request({ + url: `/reseller/reseller_add_user.dspy`, + method: 'post', + data: data + }) +} +// 列表 +export function getListAPI(data) { + return request({ + url: `/user/get_user_and_role.dspy`, + method: 'get', + params: data + }) +} +// 分配角色 参数为userid roleid +export function assignRoleAPI(data) { + return request({ + url: `/user/add_user_role.dspy`, + method: 'post', + data: data + }) +} \ No newline at end of file diff --git a/f/web-kboss/src/router/index.js b/f/web-kboss/src/router/index.js index 81298f0..1dca6fa 100644 --- a/f/web-kboss/src/router/index.js +++ b/f/web-kboss/src/router/index.js @@ -2305,6 +2305,13 @@ export const asyncRoutes = [ path: "/superAdministrator", component: Layout, redirect: "/superAdministrator/index", meta: { title: "超级管理员", icon: "el-icon-user-solid", noCache: true, fullPath: "/superAdministrator", }, children: [{ + path: "roleManagement", + component: () => import("@/views/superAdministrator/roleManagement"), + name: "RoleManagement", + meta: { + title: "角色管理", fullPath: "/superAdministrator/roleManagement", + }, + }, { path: "addAdmin", component: () => import("@/views/superAdministrator/addAdmin"), name: "addAdmin", meta: { title: "添加业主机构管理员", fullPath: "/superAdministrator/addAdmin", }, diff --git a/f/web-kboss/src/store/modules/permission.js b/f/web-kboss/src/store/modules/permission.js index d773d45..08d5880 100644 --- a/f/web-kboss/src/store/modules/permission.js +++ b/f/web-kboss/src/store/modules/permission.js @@ -7,6 +7,7 @@ const MOBILE_UA_REGEXP = /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Ope const CUSTOMER_ROLE = '客户'; const OPERATION_ROLE = '运营'; const FINANCE_ROLE = '财务'; +const ADMINISTRATOR_ROLE = '管理员'; // 这个用户能看到订单管理里的特殊子菜单,比如历史订单和订单详情。 const SPECIAL_ORDER_USER = 'ZhipuHZ'; @@ -23,6 +24,8 @@ const OPERATION_EXTRA_ROUTE_PATHS = ['/modelManagement', '/modelInfoConfig', '/o // 财务角色需要额外补出来的菜单。 const FINANCE_EXTRA_ROUTE_PATHS = ['/financialOverview']; +const ADMINISTRATOR_ROUTE_FULL_PATH = '/superAdministrator/roleManagement'; + // 普通客户账号默认要补出来的基础菜单。 const BASE_USER_ROUTE_PATHS = ['/orderManagement', '/resourceManagement']; @@ -350,6 +353,30 @@ function addFinanceRoutes(accessedRoutes, routes, userRoles = [], deviceType = ' return appendMissingRoutes(accessedRoutes, getRoutesByPath(routes, FINANCE_EXTRA_ROUTE_PATHS)); } +function getAdministratorRoutes(routes, deviceType = 'pc') { + if (deviceType !== 'pc') { + return []; + } + + const superAdminRoute = findRouteByPath(routes, SUPER_ADMIN_ROUTE_PATH); + if (!superAdminRoute) { + return []; + } + + const clonedRoute = cloneRoute(superAdminRoute); + clonedRoute.redirect = ADMINISTRATOR_ROUTE_FULL_PATH; + clonedRoute.children = (clonedRoute.children || []).filter(child => child.meta?.fullPath === ADMINISTRATOR_ROUTE_FULL_PATH); + return clonedRoute.children.length ? [clonedRoute] : []; +} + +function addAdministratorRoutes(accessedRoutes, routes, userRoles = [], deviceType = 'pc') { + if (!userRoles.includes(ADMINISTRATOR_ROLE)) { + return accessedRoutes; + } + + return appendMissingRoutes(accessedRoutes, getAdministratorRoutes(routes, deviceType)); +} + // token市集是公共菜单,所有登录用户都要能看到。 function addCommonRoutes(accessedRoutes, routes, deviceType = 'pc') { const commonRoutes = getRoutesByPath(routes, COMMON_ROUTE_PATHS) @@ -495,6 +522,13 @@ const actions = { console.log("用户类型:", userType, "orgType:", orgType, "设备类型:", deviceType); console.log("ACTION generateRoutes - auths:", auths); + if (!isSuperAdmin && userRoles.includes(ADMINISTRATOR_ROLE)) { + const administratorRoutes = getAdministratorRoutes(asyncRoutes, deviceType); + commit("SET_ROUTES", administratorRoutes); + resolve(administratorRoutes); + return; + } + // 3. 先生成第一版菜单:超级管理员只拿超管菜单,普通用户按后端 auths 过滤。 let accessedRoutes = isSuperAdmin ? getSuperAdminRoutes(deviceType) @@ -502,6 +536,7 @@ const actions = { // 4. token市集是公共入口,所有登录用户都补上。 accessedRoutes = addCommonRoutes(accessedRoutes, asyncRoutes, deviceType); + accessedRoutes = addAdministratorRoutes(accessedRoutes, asyncRoutes, userRoles, deviceType); if (!isSuperAdmin) { // 5. 普通用户再补一些固定入口,比如订单、资源、客户专属菜单。 diff --git a/f/web-kboss/src/views/LoginDialog/LoginDialog.vue b/f/web-kboss/src/views/LoginDialog/LoginDialog.vue index 263a61f..298bfc8 100644 --- a/f/web-kboss/src/views/LoginDialog/LoginDialog.vue +++ b/f/web-kboss/src/views/LoginDialog/LoginDialog.vue @@ -382,6 +382,11 @@ export default { }) }, redirectAfterLogin(res) { + if (res.roles && res.roles.includes('管理员')) { + sessionStorage.removeItem('loginRedirectPath') + this.$router.push('/superAdministrator/roleManagement').catch(() => {}) + return + } const redirectPath = sessionStorage.getItem('loginRedirectPath') if (redirectPath && redirectPath.startsWith('/') && !redirectPath.includes('/login')) { sessionStorage.removeItem('loginRedirectPath') diff --git a/f/web-kboss/src/views/homePage/components/topBox/index.vue b/f/web-kboss/src/views/homePage/components/topBox/index.vue index 91f25ee..24c8b71 100644 --- a/f/web-kboss/src/views/homePage/components/topBox/index.vue +++ b/f/web-kboss/src/views/homePage/components/topBox/index.vue @@ -544,6 +544,7 @@ export default Vue.extend({ else if (role.includes('运维')) this.$router.push('/operationAndMaintenance/workOrderProcessing') else if (role.includes('销售')) this.$router.push('/sales/distributorManagement') else if (role.includes('财务')) this.$router.push('/finance/supplierSettlementStatistics') + else if (role.includes('管理员')) this.$router.push('/superAdministrator/roleManagement') else if (role.includes('admin')) this.$router.push('/superAdministrator/addAdmin') }, async logout() { diff --git a/f/web-kboss/src/views/homePage/news/ArticleEditorDialog.vue b/f/web-kboss/src/views/homePage/news/ArticleEditorDialog.vue index 4f04029..792d8a1 100644 --- a/f/web-kboss/src/views/homePage/news/ArticleEditorDialog.vue +++ b/f/web-kboss/src/views/homePage/news/ArticleEditorDialog.vue @@ -243,7 +243,7 @@ export default { this.stopObserveEditorFullscreen() this.editorFullscreen = false }, - methods: { + methods: { createEmptyForm() { // 创建新增文章时使用的默认表单结构。 return { diff --git a/f/web-kboss/src/views/modelManagement/ApiDocument.vue b/f/web-kboss/src/views/modelManagement/ApiDocument.vue index 61c629c..8ed6cc9 100644 --- a/f/web-kboss/src/views/modelManagement/ApiDocument.vue +++ b/f/web-kboss/src/views/modelManagement/ApiDocument.vue @@ -5,7 +5,7 @@ 返回 - API文档 + 元境 API 文档
@@ -19,40 +19,12 @@ >
-

{{ apiDoc.model_name }} API 文档

-

{{ heroDescription }}

- +

元境 API 文档

+

统一展示大模型、视频、图像、音频、任务查询等接口说明。

-
-

1. 接口地址

-

统一使用 HTTPS 请求,所有接口都需要携带平台签发的 API Key。

-
{{ apiUrlText }}
-
- - - - - -
-

2. 请求示例

-
{{ apiDoc.curl_code || requestExample }}
-
- -
-

3. Python 示例

-
{{ apiDoc.python_code || pythonExample }}
-
- -
-

4. 错误码

- - - - - +
+
@@ -61,124 +33,137 @@ + +