diff --git a/ui/src/api/API_README.md b/ui/src/api/API_README.md index 0b14a6cd3f7..e450e83fd67 100644 --- a/ui/src/api/API_README.md +++ b/ui/src/api/API_README.md @@ -68,6 +68,11 @@ API 类型统一在 `src/api` 范围内管理,相关规则由本文档统一 `import type { ... } from '@/api/types'` 导入,不写 `/index.ts`。 - `src/api/types/index.ts` 只负责导出各业务域类型,不直接声明类型。 - 新增类型前先搜索是否已有等价声明,优先复用或扩展已有类型。 +- 后端字段的固定协议值与其类型放在同一个 `src/api/types/.ts` 中:使用 + `as const` 对象声明运行时常量,并从该对象派生联合类型。协议常量是唯一数据源;新增、删除或 + 修改协议值只维护对应的 API 类型文件,业务判断不得重复使用裸字符串或另建同值常量。 +- 同时导出协议常量的类型模块在 `src/api/types/index.ts` 中使用 `export *`;只有纯类型模块使用 + `export type *`。 - 同一业务边界内的重复类型提取到最近共同目录的 `common.ts`;`common.ts` 不得成为无关类型 的集合。 - API 与 View 或 Component 使用同一业务类型时只保留一份声明,不得在两层分别定义。 diff --git a/ui/src/api/admin/system/chat-user-auth.ts b/ui/src/api/admin/system/chat-user-auth.ts index 993e23c666d..d55895700f8 100644 --- a/ui/src/api/admin/system/chat-user-auth.ts +++ b/ui/src/api/admin/system/chat-user-auth.ts @@ -17,21 +17,8 @@ const postAuthSettingConnection = (setting: AuthProviderSetting) => { const putAuthSetting = (authType: AuthProviderType, setting: AuthProviderSetting) => { return put(`${prefix}/${authType}/info`, setting) } - -/** 获取对话用户登录设置。 */ -const getLoginSetting = () => { - return get(`${prefix}/setting`) -} - -/** 保存对话用户登录设置。 */ -const putLoginSetting = (setting: LoginAuthSetting) => { - return put(`${prefix}/setting`, setting) -} - export default { getAuthSetting, - getLoginSetting, postAuthSettingConnection, putAuthSetting, - putLoginSetting, } diff --git a/ui/src/api/admin/system/role.ts b/ui/src/api/admin/system/role.ts new file mode 100644 index 00000000000..4ca172d7326 --- /dev/null +++ b/ui/src/api/admin/system/role.ts @@ -0,0 +1,70 @@ +import { del, get, post } from '../core/request' +import type { ParamsPage, ResponsePage } from '../core/types' +import type { + CreateRoleMembersRequest, + RequestParams, + RoleItem, + RoleMember, + RolePermissionModule, + SaveRoleRequest, + SaveRolePermissionRequest, + RoleType, +} from '@/api/types' + +const prefix = '/system/role' + +/** 获取内置角色与自定义角色列表。 */ +const getRoleList = () => { + return get<{ internal_role: RoleItem[]; custom_role: RoleItem[] }>(prefix) +} + +/** 创建或重命名自定义角色。 */ +const postRole = (role: SaveRoleRequest) => { + return post(prefix, role) +} + +/** 删除自定义角色。 */ +const deleteRole = (roleId: string) => { + return del(`${prefix}/${roleId}`) +} + + +/** 获取指定角色的权限配置。 */ +const getRolePermissionList = (roleId: string) => { + return get(`${prefix}/${roleId}/permission`) +} + + +/** 保存指定角色的权限配置。 */ +const postRolePermissions = (roleId: string, permissions: SaveRolePermissionRequest[]) => { + return post(`${prefix}/${roleId}/permission`, permissions) +} + +/** 获取指定角色的成员分页列表。 */ +const getRoleMemberList = (roleId: string, page: ParamsPage, query?: RequestParams) => { + return get>( + `${prefix}/${roleId}/user_list/${page.currentPage}/${page.pageSize}`, + query, + ) +} + +/** 为指定角色添加成员。 */ +const postRoleMembers = (roleId: string, request: CreateRoleMembersRequest) => { + return post(`${prefix}/${roleId}/add_member`, request) +} + +/** 从指定角色移除成员。 */ +const deleteRoleMember = (roleId: string, userRelationId: string) => { + return del(`${prefix}/${roleId}/remove_member/${userRelationId}`) +} + +export default { + deleteRole, + deleteRoleMember, + getRoleList, + getRoleMemberList, + getRolePermissionList, + postRole, + postRoleMembers, + postRolePermissions, +} diff --git a/ui/src/api/types/index.ts b/ui/src/api/types/index.ts index 9da931b22cf..ea30261778a 100644 --- a/ui/src/api/types/index.ts +++ b/ui/src/api/types/index.ts @@ -2,10 +2,11 @@ export type * from './common' export type * from './chat-user' export type * from './chat-user-groups' -export type * from './login' +export * from './login' export type * from './system-user' export type * from './system-user-groups' export type * from './system-workspace' export type * from './system-authentication' export type * from './system-operate-log' +export * from './system-role' export type * from './system-email' diff --git a/ui/src/api/types/login.ts b/ui/src/api/types/login.ts index 92560202a0e..037095d87c2 100644 --- a/ui/src/api/types/login.ts +++ b/ui/src/api/types/login.ts @@ -1,15 +1,19 @@ /** 登录 API 与登录页面共同使用的业务类型。 */ -export type LoginMethod = - | 'CAS' - | 'LDAP' - | 'LOCAL' - | 'OAuth2' - | 'OIDC' - | 'SAML2' - | 'dingtalk' - | 'lark' - | 'wecom' +/** 后端登录方式协议值;新增或修改登录方式时以此处为唯一数据源。 */ +export const LOGIN_METHOD = { + CAS: 'CAS', + DINGTALK: 'dingtalk', + LDAP: 'LDAP', + LARK: 'lark', + LOCAL: 'LOCAL', + OAUTH2: 'OAuth2', + OIDC: 'OIDC', + SAML2: 'SAML2', + WECOM: 'wecom', +} as const + +export type LoginMethod = (typeof LOGIN_METHOD)[keyof typeof LOGIN_METHOD] export interface LoginConfig { default_value: LoginMethod @@ -17,7 +21,10 @@ export interface LoginConfig { max_attempts: number } -export type QrCodeProvider = Extract +export type QrCodeProvider = Extract< + LoginMethod, + typeof LOGIN_METHOD.DINGTALK | typeof LOGIN_METHOD.LARK | typeof LOGIN_METHOD.WECOM +> export interface QrCodeConfig { agent_id?: string diff --git a/ui/src/api/types/system-role.ts b/ui/src/api/types/system-role.ts new file mode 100644 index 00000000000..27616b976d4 --- /dev/null +++ b/ui/src/api/types/system-role.ts @@ -0,0 +1,65 @@ +/** 后端角色类型协议值;新增或修改角色类型时以此处为唯一数据源。 */ +export const ROLE_TYPE = { + ADMIN: 'ADMIN', + USER: 'USER', + WORKSPACE_MANAGE: 'WORKSPACE_MANAGE', +} as const + +export type RoleType = (typeof ROLE_TYPE)[keyof typeof ROLE_TYPE] + +export interface RoleItem { + id: string + role_name: string + type: RoleType + create_user: string + internal: boolean + user_count?: number +} + +export interface RolePermission { + id: string + name: string + enable: boolean +} + +export interface RolePermissionFeature { + id: string + name: string + enable: boolean + permission: RolePermission[] +} + +export interface RolePermissionModule { + id: string + name: string + children: RolePermissionFeature[] +} + +export interface SaveRoleRequest { + role_id?: string + role_name: string + role_type?: RoleType +} + +export interface SaveRolePermissionRequest { + id: string + enable: boolean +} + +export interface RoleMember { + user_relation_id: string + user_id: string + username: string + nick_name: string + workspace_id: string + workspace_name: string +} + +export interface CreateRoleMemberItem { + user_ids: string[] + workspace_ids?: string[] +} + +export interface CreateRoleMembersRequest { + members: CreateRoleMemberItem[] +} diff --git a/ui/src/components.d.ts b/ui/src/components.d.ts index 82916575ca6..7f84e02e11b 100644 --- a/ui/src/components.d.ts +++ b/ui/src/components.d.ts @@ -13,6 +13,7 @@ export {} declare module 'vue' { export interface GlobalComponents { LayoutAside: typeof import('./components/global/mk-view-layout/layout-aside.vue')['default'] + MkCollapse: typeof import('./components/global/mk-collapse/index.vue')['default'] MkComplexSearch: typeof import('./components/global/mk-complex-search/index.vue')['default'] MkDialog: typeof import('./components/global/mk-dialog/index.vue')['default'] MkDrawer: typeof import('./components/global/mk-drawer/index.vue')['default'] @@ -35,6 +36,7 @@ declare module 'vue' { // For TSX support declare global { const LayoutAside: typeof import('./components/global/mk-view-layout/layout-aside.vue')['default'] + const MkCollapse: typeof import('./components/global/mk-collapse/index.vue')['default'] const MkComplexSearch: typeof import('./components/global/mk-complex-search/index.vue')['default'] const MkDialog: typeof import('./components/global/mk-dialog/index.vue')['default'] const MkDrawer: typeof import('./components/global/mk-drawer/index.vue')['default'] diff --git a/ui/src/components/COMPONENT_README.md b/ui/src/components/COMPONENT_README.md index d3def83a89a..99388f1ae91 100644 --- a/ui/src/components/COMPONENT_README.md +++ b/ui/src/components/COMPONENT_README.md @@ -35,6 +35,8 @@ src/components/ ├── global/ # 高频、稳定的基础组件,自动注册 │ ├── mk-complex-search/ │ │ └── index.vue # 字段选择与输入或枚举条件组合搜索框 +│ ├── mk-collapse/ +│ │ └── index.vue # 带标题和过渡动画的折叠内容区 │ ├── mk-dialog/ │ │ └── index.vue # 统一对话框关闭行为和内容滚动布局 │ ├── mk-dropdown/ @@ -61,7 +63,8 @@ src/components/ │ └── mk-tag-group/ │ └── index.vue # 标签折叠和剩余标签浮层 ├── mk-search-list/ -│ └── index.vue # 搜索框与剩余空间滚动列表,手动导入 +│ ├── index.vue # 搜索框与剩余空间滚动列表,手动导入 +│ └── mk-list-item.vue # 列表与业务分组列表复用的私有行结构 ├── mk-workspace-dropdown/ │ └── index.vue # 工作空间选择下拉框,手动导入 └── mk-workspace-relation-tags/ @@ -117,6 +120,17 @@ Element Plus 使用 `ElOnlyChild` 处理浮层触发器。`el-tooltip`、`el-pop ## 自动注册组件 +### MkCollapse + +带标题触发器和展开过渡动画的内容折叠组件。通过 `v-model` 控制展开状态,默认展开;点击标题行 +会切换状态,默认插槽放置折叠内容。 + +```vue + +
折叠内容
+
+``` + ### MkEmpty 全局空状态组件,基于 `el-empty` 统一图片和默认文案。`type` 默认为 `default`,展示“暂无数据”; diff --git a/ui/src/components/global/mk-collapse/index.vue b/ui/src/components/global/mk-collapse/index.vue new file mode 100644 index 00000000000..28528985a7a --- /dev/null +++ b/ui/src/components/global/mk-collapse/index.vue @@ -0,0 +1,35 @@ + + + diff --git a/ui/src/components/global/mk-table/index.vue b/ui/src/components/global/mk-table/index.vue index 43121c7a8c4..866df282bab 100644 --- a/ui/src/components/global/mk-table/index.vue +++ b/ui/src/components/global/mk-table/index.vue @@ -19,7 +19,7 @@ const props = withDefaults( maxTableHeight?: number paginationConfig?: PaginationConfig resizable?: boolean - search?: boolean + isSearching?: boolean }>(), { data: () => [], @@ -42,7 +42,9 @@ const paginationPageSizes = computed(() => props.paginationConfig?.pageSizes ?? /** 表格高度 */ const tableHeight = ref(window.innerHeight - props.maxTableHeight) function updateTableHeight() { - tableHeight.value = window.innerHeight - props.maxTableHeight + tableHeight.value = props.paginationConfig + ? window.innerHeight - props.maxTableHeight + : window.innerHeight - props.maxTableHeight + 50 } /** 选择操作栏 */ @@ -151,8 +153,8 @@ defineExpose({ clearSelection, tableRef }) diff --git a/ui/src/views/login/modes/QrCodeLogin.vue b/ui/src/views/login/modes/QrCodeLogin.vue index e306a8705b8..db1e1313591 100644 --- a/ui/src/views/login/modes/QrCodeLogin.vue +++ b/ui/src/views/login/modes/QrCodeLogin.vue @@ -2,7 +2,12 @@ import { computed, onMounted, ref } from 'vue' import ExternalLoginApi from '@/api/admin/auth/external-login' import { LOGIN_METHOD_LABELS } from '@/constants/auth.ts' -import type { LoginConfig, QrCodeConfig, QrCodeProvider } from '@/api/types/index.ts' +import { + LOGIN_METHOD, + type LoginConfig, + type QrCodeConfig, + type QrCodeProvider, +} from '@/api/types/index.ts' import DingTalkQrCode from '../scanComponents/dingtalkQrCode.vue' import LarkQrCode from '../scanComponents/larkQrCode.vue' import WecomQrCode from '../scanComponents/wecomQrCode.vue' @@ -14,13 +19,13 @@ const qrCodeLoginMethods = computed(() => props.loginConfig.login_methods ?? []) const qrCodeConfigs = ref>>({}) const qrCodeProvider = ref( - (props.loginConfig.default_value as QrCodeProvider) ?? 'wecom', + (props.loginConfig.default_value as QrCodeProvider) ?? LOGIN_METHOD.WECOM, ) const providerComponents = { - dingtalk: DingTalkQrCode, - lark: LarkQrCode, - wecom: WecomQrCode, + [LOGIN_METHOD.DINGTALK]: DingTalkQrCode, + [LOGIN_METHOD.LARK]: LarkQrCode, + [LOGIN_METHOD.WECOM]: WecomQrCode, } const currentConfig = computed(() => qrCodeConfigs.value[qrCodeProvider.value]) diff --git a/ui/src/views/system/chat/authentication/AuthenticationView.vue b/ui/src/views/system/chat/authentication/AuthenticationView.vue index de7f6789136..f8e83df67e8 100644 --- a/ui/src/views/system/chat/authentication/AuthenticationView.vue +++ b/ui/src/views/system/chat/authentication/AuthenticationView.vue @@ -1,12 +1,11 @@ @@ -47,15 +44,4 @@ const authenticationTabs: AuthenticationTab[] = [ - + diff --git a/ui/src/views/system/chat/authentication/EditSCANDrawer.vue b/ui/src/views/system/chat/authentication/EditSCANDrawer.vue index 66ee18725b6..3880fe24fef 100644 --- a/ui/src/views/system/chat/authentication/EditSCANDrawer.vue +++ b/ui/src/views/system/chat/authentication/EditSCANDrawer.vue @@ -2,7 +2,7 @@ import { computed, reactive, ref, useTemplateRef } from 'vue' import type { FormInstance, FormRules } from 'element-plus' import ChatUserAuthScanApi from '@/api/admin/system/chat-user-auth-scan' -import type { QrLoginPlatformRequest } from '@/api/types' +import { LOGIN_METHOD, type QrLoginPlatformRequest } from '@/api/types' import { LOGIN_METHOD_LABELS, SCAN_FIELD_LABELS } from '@/constants/auth' import { MsgSuccess, MsgError } from '@/utils/message' @@ -11,7 +11,7 @@ const visible = ref(false) const loading = ref(false) const formRef = useTemplateRef('formRef') const form = reactive({ - key: 'wecom', + key: LOGIN_METHOD.WECOM, isActive: false, config: {}, }) @@ -65,7 +65,7 @@ function close() { } function resetData() { - Object.assign(form, { key: 'wecom', isActive: false, config: {} }) + Object.assign(form, { key: LOGIN_METHOD.WECOM, isActive: false, config: {} }) formRef.value?.resetFields() } defineExpose({ open }) diff --git a/ui/src/views/system/chat/authentication/components/CAS.vue b/ui/src/views/system/chat/authentication/components/CAS.vue index 0d3214a5109..d656f0e4bc8 100644 --- a/ui/src/views/system/chat/authentication/components/CAS.vue +++ b/ui/src/views/system/chat/authentication/components/CAS.vue @@ -2,7 +2,7 @@ import { onMounted, reactive, ref, useTemplateRef } from 'vue' import type { FormInstance, FormRules } from 'element-plus' import ChatUserAuthApi from '@/api/admin/system/chat-user-auth' -import type { AuthProviderSetting } from '@/api/types' +import { LOGIN_METHOD, type AuthProviderSetting } from '@/api/types' import { MsgSuccess } from '@/utils/message' defineOptions({ name: 'CasAuthenticationSetting' }) @@ -11,7 +11,7 @@ const defaultRedirectUrl = `${window.location.origin}${window.MaxKB?.prefix ?? ' const authFormRef = useTemplateRef('authFormRef') const loading = ref(false) const form = reactive({ - auth_type: 'CAS', + auth_type: LOGIN_METHOD.CAS, config: { ldpUri: '', validateUrl: '', redirectUrl: defaultRedirectUrl }, is_active: false, }) diff --git a/ui/src/views/system/chat/authentication/components/LDAP.vue b/ui/src/views/system/chat/authentication/components/LDAP.vue index 15fac93b1fe..b815f7b7646 100644 --- a/ui/src/views/system/chat/authentication/components/LDAP.vue +++ b/ui/src/views/system/chat/authentication/components/LDAP.vue @@ -2,14 +2,14 @@ import { onMounted, reactive, ref, useTemplateRef } from 'vue' import type { FormInstance, FormRules } from 'element-plus' import ChatUserAuthApi from '@/api/admin/system/chat-user-auth' -import type { AuthProviderSetting } from '@/api/types' +import { LOGIN_METHOD, type AuthProviderSetting } from '@/api/types' import { MsgSuccess } from '@/utils/message' defineOptions({ name: 'LdapAuthenticationSetting' }) const authFormRef = useTemplateRef('authFormRef') const loading = ref(false) const form = reactive({ - auth_type: 'LDAP', + auth_type: LOGIN_METHOD.LDAP, config: { ldap_server: '', base_dn: '', password: '', ou: '', ldap_filter: '', ldap_mapping: '' }, is_active: false, }) diff --git a/ui/src/views/system/chat/authentication/components/LoginSetting.vue b/ui/src/views/system/chat/authentication/components/LoginSetting.vue deleted file mode 100644 index f62de530dda..00000000000 --- a/ui/src/views/system/chat/authentication/components/LoginSetting.vue +++ /dev/null @@ -1,274 +0,0 @@ - - - diff --git a/ui/src/views/system/chat/authentication/components/OAuth2.vue b/ui/src/views/system/chat/authentication/components/OAuth2.vue index 79fb094ec63..4d77ab2b12e 100644 --- a/ui/src/views/system/chat/authentication/components/OAuth2.vue +++ b/ui/src/views/system/chat/authentication/components/OAuth2.vue @@ -2,7 +2,7 @@ import { onMounted, reactive, ref, useTemplateRef } from 'vue' import type { FormInstance, FormRules } from 'element-plus' import ChatUserAuthApi from '@/api/admin/system/chat-user-auth' -import type { AuthProviderSetting } from '@/api/types' +import { LOGIN_METHOD, type AuthProviderSetting } from '@/api/types' import { MsgSuccess } from '@/utils/message' defineOptions({ name: 'OidcAuthenticationSetting' }) @@ -11,7 +11,7 @@ const defaultRedirectUrl = `${window.location.origin}${window.MaxKB?.prefix ?? ' const authFormRef = useTemplateRef('authFormRef') const loading = ref(false) const form = reactive({ - auth_type: 'OAuth2', + auth_type: LOGIN_METHOD.OAUTH2, config: { authEndpoint: '', tokenEndpoint: '', diff --git a/ui/src/views/system/chat/authentication/components/OIDC.vue b/ui/src/views/system/chat/authentication/components/OIDC.vue index 7ad89b3c23b..e9eb0baebcf 100644 --- a/ui/src/views/system/chat/authentication/components/OIDC.vue +++ b/ui/src/views/system/chat/authentication/components/OIDC.vue @@ -2,7 +2,7 @@ import { onMounted, reactive, ref, useTemplateRef } from 'vue' import type { FormInstance, FormRules } from 'element-plus' import ChatUserAuthApi from '@/api/admin/system/chat-user-auth' -import type { AuthProviderSetting } from '@/api/types' +import { LOGIN_METHOD, type AuthProviderSetting } from '@/api/types' import { MsgSuccess } from '@/utils/message' defineOptions({ name: 'OidcAuthenticationSetting' }) @@ -12,7 +12,7 @@ const defaultRedirectUrl = `${window.location.origin}${window.MaxKB?.prefix ?? ' const authFormRef = useTemplateRef('authFormRef') const loading = ref(false) const form = reactive({ - auth_type: 'OIDC', + auth_type: LOGIN_METHOD.OIDC, config: { authEndpoint: '', tokenEndpoint: '', diff --git a/ui/src/views/system/chat/authentication/components/SCANLogin.vue b/ui/src/views/system/chat/authentication/components/SCANLogin.vue index a0c39f47187..408970f4fd4 100644 --- a/ui/src/views/system/chat/authentication/components/SCANLogin.vue +++ b/ui/src/views/system/chat/authentication/components/SCANLogin.vue @@ -1,7 +1,12 @@ - - diff --git a/ui/src/views/system/chat/user-groups/GroupsListView.vue b/ui/src/views/system/chat/user-groups/GroupsListView.vue index 7dc3ce8d614..167fd03e683 100644 --- a/ui/src/views/system/chat/user-groups/GroupsListView.vue +++ b/ui/src/views/system/chat/user-groups/GroupsListView.vue @@ -1,12 +1,13 @@ + + diff --git a/ui/src/views/system/identity/roles/RoleListView.vue b/ui/src/views/system/identity/roles/RoleListView.vue index 3e53b66b357..f079b396e7c 100644 --- a/ui/src/views/system/identity/roles/RoleListView.vue +++ b/ui/src/views/system/identity/roles/RoleListView.vue @@ -1,437 +1,181 @@ - - diff --git a/ui/src/views/system/identity/roles/components/RoleMemberList.vue b/ui/src/views/system/identity/roles/components/RoleMemberList.vue new file mode 100644 index 00000000000..745cc85cfdb --- /dev/null +++ b/ui/src/views/system/identity/roles/components/RoleMemberList.vue @@ -0,0 +1,120 @@ + + + diff --git a/ui/src/views/system/identity/roles/components/RolePermissionConfiguration.vue b/ui/src/views/system/identity/roles/components/RolePermissionConfiguration.vue new file mode 100644 index 00000000000..79c6b0c5505 --- /dev/null +++ b/ui/src/views/system/identity/roles/components/RolePermissionConfiguration.vue @@ -0,0 +1,190 @@ + + + + + diff --git a/ui/src/views/system/identity/roles/dialog/CreateOrUpdateRoleDialog.vue b/ui/src/views/system/identity/roles/dialog/CreateOrUpdateRoleDialog.vue new file mode 100644 index 00000000000..809499526aa --- /dev/null +++ b/ui/src/views/system/identity/roles/dialog/CreateOrUpdateRoleDialog.vue @@ -0,0 +1,95 @@ + + + diff --git a/ui/src/views/system/identity/users/UserListView.vue b/ui/src/views/system/identity/users/UserListView.vue index c4dbd692bc2..5272f731c33 100644 --- a/ui/src/views/system/identity/users/UserListView.vue +++ b/ui/src/views/system/identity/users/UserListView.vue @@ -2,7 +2,14 @@ import { onMounted, ref, useTemplateRef } from 'vue' import { useStore } from '@/stores' import UserManageApi from '@/api/admin/system/user-manage' -import type { LoginMethod, OptionItem, SystemUser, RequestParams } from '@/api/types/index.ts' +import { + LOGIN_METHOD, + ROLE_TYPE, + type LoginMethod, + type OptionItem, + type SystemUser, + type RequestParams, +} from '@/api/types/index.ts' import { MsgConfirm, MsgSuccess } from '@/utils/message' import { datetimeFormat } from '@/utils/time' import { LOGIN_METHOD_LABELS } from '@/constants/auth.ts' @@ -165,7 +172,7 @@ onMounted(() => loadSystemUsers()) @current-change="loadSystemUsers()" @size-change="loadSystemUsers()" @selection-change="handleBatchSelectionChange" - :search="Boolean(systemUserQuery)" + :isSearching="Boolean(systemUserQuery)" > @@ -210,7 +217,9 @@ onMounted(() => loadSystemUsers()) @@ -226,7 +235,7 @@ onMounted(() => loadSystemUsers()) diff --git a/ui/src/views/system/identity/users/components/UserRoleSetting.vue b/ui/src/views/system/identity/users/components/UserRoleSetting.vue index 3b463d7ba8d..6273c790b53 100644 --- a/ui/src/views/system/identity/users/components/UserRoleSetting.vue +++ b/ui/src/views/system/identity/users/components/UserRoleSetting.vue @@ -1,6 +1,6 @@ @@ -47,15 +48,4 @@ const authenticationTabs: AuthenticationTab[] = [ - + diff --git a/ui/src/views/system/settings/authentication/EditSCANDrawer.vue b/ui/src/views/system/settings/authentication/EditSCANDrawer.vue index fb517447768..adc94cf38b0 100644 --- a/ui/src/views/system/settings/authentication/EditSCANDrawer.vue +++ b/ui/src/views/system/settings/authentication/EditSCANDrawer.vue @@ -2,7 +2,7 @@ import { computed, reactive, ref, useTemplateRef } from 'vue' import type { FormInstance, FormRules } from 'element-plus' import AuthScanApi from '@/api/admin/system/auth-scan-setting' -import type { QrLoginPlatformRequest } from '@/api/types' +import { LOGIN_METHOD, type QrLoginPlatformRequest } from '@/api/types' import { LOGIN_METHOD_LABELS, SCAN_FIELD_LABELS } from '@/constants/auth' import { MsgSuccess, MsgError } from '@/utils/message' @@ -11,7 +11,7 @@ const visible = ref(false) const loading = ref(false) const formRef = useTemplateRef('formRef') const form = reactive({ - key: 'wecom', + key: LOGIN_METHOD.WECOM, isActive: false, config: {}, }) @@ -65,7 +65,7 @@ function close() { } function resetData() { - Object.assign(form, { key: 'wecom', isActive: false, config: {} }) + Object.assign(form, { key: LOGIN_METHOD.WECOM, isActive: false, config: {} }) formRef.value?.resetFields() } defineExpose({ open }) diff --git a/ui/src/views/system/settings/authentication/components/CAS.vue b/ui/src/views/system/settings/authentication/components/CAS.vue index 581c5c422af..1704c972532 100644 --- a/ui/src/views/system/settings/authentication/components/CAS.vue +++ b/ui/src/views/system/settings/authentication/components/CAS.vue @@ -2,7 +2,7 @@ import { onMounted, reactive, ref, useTemplateRef } from 'vue' import type { FormInstance, FormRules } from 'element-plus' import AuthSettingApi from '@/api/admin/system/auth-setting' -import type { AuthProviderSetting } from '@/api/types' +import { LOGIN_METHOD, type AuthProviderSetting } from '@/api/types' import { MsgSuccess } from '@/utils/message' defineOptions({ name: 'CasAuthenticationSetting' }) @@ -11,7 +11,7 @@ const defaultRedirectUrl = `${window.location.origin}${window.MaxKB?.prefix ?? ' const authFormRef = useTemplateRef('authFormRef') const loading = ref(false) const form = reactive({ - auth_type: 'CAS', + auth_type: LOGIN_METHOD.CAS, config: { ldpUri: '', validateUrl: '', redirectUrl: defaultRedirectUrl }, is_active: false, }) diff --git a/ui/src/views/system/settings/authentication/components/LDAP.vue b/ui/src/views/system/settings/authentication/components/LDAP.vue index ec9f47deb1f..7694b94622c 100644 --- a/ui/src/views/system/settings/authentication/components/LDAP.vue +++ b/ui/src/views/system/settings/authentication/components/LDAP.vue @@ -2,14 +2,14 @@ import { onMounted, reactive, ref, useTemplateRef } from 'vue' import type { FormInstance, FormRules } from 'element-plus' import AuthSettingApi from '@/api/admin/system/auth-setting' -import type { AuthProviderSetting } from '@/api/types' +import { LOGIN_METHOD, type AuthProviderSetting } from '@/api/types' import { MsgSuccess } from '@/utils/message' defineOptions({ name: 'LdapAuthenticationSetting' }) const authFormRef = useTemplateRef('authFormRef') const loading = ref(false) const form = reactive({ - auth_type: 'LDAP', + auth_type: LOGIN_METHOD.LDAP, config: { ldap_server: '', base_dn: '', password: '', ou: '', ldap_filter: '', ldap_mapping: '' }, is_active: false, }) diff --git a/ui/src/views/system/settings/authentication/components/LoginSetting.vue b/ui/src/views/system/settings/authentication/components/LoginSetting.vue index 632ae90d998..8d74592a48d 100644 --- a/ui/src/views/system/settings/authentication/components/LoginSetting.vue +++ b/ui/src/views/system/settings/authentication/components/LoginSetting.vue @@ -4,7 +4,14 @@ import type { FormInstance, FormRules } from 'element-plus' import CurrentUserApi from '@/api/admin/auth/current-user' import AuthSettingApi from '@/api/admin/system/auth-setting' import UserGroupsApi from '@/api/admin/system/user-groups' -import type { ListItem, LoginAuthSetting, SystemUserGroup, LoginMethod } from '@/api/types' +import { + LOGIN_METHOD, + ROLE_TYPE, + type ListItem, + type LoginAuthSetting, + type SystemUserGroup, + type LoginMethod, +} from '@/api/types' import { LOGIN_METHOD_LABELS } from '@/constants/auth' import { MsgSuccess } from '@/utils/message' import { useStore } from '@/stores' @@ -14,12 +21,12 @@ const { auth } = useStore() const authFormRef = useTemplateRef('authFormRef') const loading = ref(false) const form = reactive({ - login_methods: ['LOCAL'], - default_value: 'LOCAL', + login_methods: [LOGIN_METHOD.LOCAL], + default_value: LOGIN_METHOD.LOCAL, max_attempts: 1, failed_attempts: 5, lock_time: 10, - role_id: 'USER', + role_id: ROLE_TYPE.USER, workspace_id: 'default', permission: 'NOT_AUTH', }) @@ -62,7 +69,7 @@ const workspaceOptions = ref([]) const selectedRoleType = computed( () => roleOptions.value.find(({ id }) => id === form.role_id)?.type, ) -const showWorkspaceSelector = computed(() => selectedRoleType.value !== 'ADMIN') +const showWorkspaceSelector = computed(() => selectedRoleType.value !== ROLE_TYPE.ADMIN) function loadRoleSettingOptions() { roleSettingOptionsLoading.value = true diff --git a/ui/src/views/system/settings/authentication/components/OAuth2.vue b/ui/src/views/system/settings/authentication/components/OAuth2.vue index ee781828c29..fbf2bc9fb77 100644 --- a/ui/src/views/system/settings/authentication/components/OAuth2.vue +++ b/ui/src/views/system/settings/authentication/components/OAuth2.vue @@ -2,7 +2,7 @@ import { onMounted, reactive, ref, useTemplateRef } from 'vue' import type { FormInstance, FormRules } from 'element-plus' import AuthSettingApi from '@/api/admin/system/auth-setting' -import type { AuthProviderSetting } from '@/api/types' +import { LOGIN_METHOD, type AuthProviderSetting } from '@/api/types' import { MsgSuccess } from '@/utils/message' defineOptions({ name: 'OidcAuthenticationSetting' }) @@ -11,7 +11,7 @@ const defaultRedirectUrl = `${window.location.origin}${window.MaxKB?.prefix ?? ' const authFormRef = useTemplateRef('authFormRef') const loading = ref(false) const form = reactive({ - auth_type: 'OAuth2', + auth_type: LOGIN_METHOD.OAUTH2, config: { authEndpoint: '', tokenEndpoint: '', diff --git a/ui/src/views/system/settings/authentication/components/OIDC.vue b/ui/src/views/system/settings/authentication/components/OIDC.vue index 924baa67a21..6d4fc85ea28 100644 --- a/ui/src/views/system/settings/authentication/components/OIDC.vue +++ b/ui/src/views/system/settings/authentication/components/OIDC.vue @@ -2,7 +2,7 @@ import { onMounted, reactive, ref, useTemplateRef } from 'vue' import type { FormInstance, FormRules } from 'element-plus' import AuthSettingApi from '@/api/admin/system/auth-setting' -import type { AuthProviderSetting } from '@/api/types' +import { LOGIN_METHOD, type AuthProviderSetting } from '@/api/types' import { MsgSuccess } from '@/utils/message' defineOptions({ name: 'OidcAuthenticationSetting' }) @@ -12,7 +12,7 @@ const defaultRedirectUrl = `${window.location.origin}${window.MaxKB?.prefix ?? ' const authFormRef = useTemplateRef('authFormRef') const loading = ref(false) const form = reactive({ - auth_type: 'OIDC', + auth_type: LOGIN_METHOD.OIDC, config: { authEndpoint: '', tokenEndpoint: '', diff --git a/ui/src/views/system/settings/authentication/components/SCANLogin.vue b/ui/src/views/system/settings/authentication/components/SCANLogin.vue index 43af77dc69d..e0e992688d5 100644 --- a/ui/src/views/system/settings/authentication/components/SCANLogin.vue +++ b/ui/src/views/system/settings/authentication/components/SCANLogin.vue @@ -1,7 +1,12 @@