reactor:【system 系统管理】oauth2/client 进一步统一代码风格
This commit is contained in:
@@ -1,15 +1,11 @@
|
||||
import type { VbenFormSchema } from '#/adapter/form';
|
||||
import type { OnActionClickFn, VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||
import type { SystemOAuth2ClientApi } from '#/api/system/oauth2/client';
|
||||
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||
|
||||
import { useAccess } from '@vben/access';
|
||||
import { CommonStatusEnum, DICT_TYPE } from '@vben/constants';
|
||||
import { getDictOptions } from '@vben/hooks';
|
||||
|
||||
import { z } from '#/adapter/form';
|
||||
|
||||
const { hasAccessByCodes } = useAccess();
|
||||
|
||||
/** 新增/修改的表单 */
|
||||
export function useFormSchema(): VbenFormSchema[] {
|
||||
return [
|
||||
@@ -52,9 +48,6 @@ export function useFormSchema(): VbenFormSchema[] {
|
||||
fieldName: 'logo',
|
||||
label: '应用图标',
|
||||
component: 'ImageUpload',
|
||||
componentProps: {
|
||||
limit: 1,
|
||||
},
|
||||
rules: 'required',
|
||||
},
|
||||
{
|
||||
@@ -104,7 +97,7 @@ export function useFormSchema(): VbenFormSchema[] {
|
||||
component: 'Select',
|
||||
componentProps: {
|
||||
options: getDictOptions(DICT_TYPE.SYSTEM_OAUTH2_GRANT_TYPE),
|
||||
mode: 'multiple',
|
||||
multiple: true,
|
||||
placeholder: '请输入授权类型',
|
||||
},
|
||||
rules: 'required',
|
||||
@@ -112,10 +105,9 @@ export function useFormSchema(): VbenFormSchema[] {
|
||||
{
|
||||
fieldName: 'scopes',
|
||||
label: '授权范围',
|
||||
component: 'Select',
|
||||
component: 'InputTag',
|
||||
componentProps: {
|
||||
placeholder: '请输入授权范围',
|
||||
mode: 'tags',
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -124,37 +116,47 @@ export function useFormSchema(): VbenFormSchema[] {
|
||||
component: 'Select',
|
||||
componentProps: {
|
||||
placeholder: '请输入自动授权范围',
|
||||
mode: 'multiple',
|
||||
// TODO @芋艿:根据权限,自动授权范围
|
||||
multiple: true,
|
||||
options: [],
|
||||
},
|
||||
dependencies: {
|
||||
triggerFields: ['scopes'],
|
||||
componentProps: (values) => ({
|
||||
options: values.scopes
|
||||
? values.scopes.map((scope: string) => ({
|
||||
label: scope,
|
||||
value: scope,
|
||||
}))
|
||||
: [],
|
||||
}),
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'redirectUris',
|
||||
label: '可重定向的 URI 地址',
|
||||
component: 'Select',
|
||||
component: 'InputTag',
|
||||
componentProps: {
|
||||
placeholder: '请输入可重定向的 URI 地址',
|
||||
mode: 'tags',
|
||||
},
|
||||
rules: 'required',
|
||||
},
|
||||
{
|
||||
fieldName: 'authorities',
|
||||
label: '权限',
|
||||
component: 'Select',
|
||||
component: 'InputTag',
|
||||
componentProps: {
|
||||
placeholder: '请输入权限',
|
||||
mode: 'tags',
|
||||
},
|
||||
rules: 'required',
|
||||
},
|
||||
{
|
||||
fieldName: 'resourceIds',
|
||||
label: '资源',
|
||||
component: 'Select',
|
||||
component: 'InputTag',
|
||||
componentProps: {
|
||||
mode: 'tags',
|
||||
placeholder: '请输入资源',
|
||||
},
|
||||
rules: 'required',
|
||||
},
|
||||
{
|
||||
fieldName: 'additionalInformation',
|
||||
@@ -176,6 +178,7 @@ export function useGridFormSchema(): VbenFormSchema[] {
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
placeholder: '请输入应用名',
|
||||
clearable: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -192,18 +195,13 @@ export function useGridFormSchema(): VbenFormSchema[] {
|
||||
}
|
||||
|
||||
/** 列表的字段 */
|
||||
export function useGridColumns<T = SystemOAuth2ClientApi.OAuth2Client>(
|
||||
onActionClick: OnActionClickFn<T>,
|
||||
): VxeTableGridOptions['columns'] {
|
||||
export function useGridColumns(): VxeTableGridOptions['columns'] {
|
||||
return [
|
||||
{
|
||||
type: 'checkbox',
|
||||
width: 40,
|
||||
},
|
||||
{ type: 'checkbox', width: 40 },
|
||||
{
|
||||
field: 'clientId',
|
||||
title: '客户端编号',
|
||||
minWidth: 200,
|
||||
minWidth: 120,
|
||||
},
|
||||
{
|
||||
field: 'secret',
|
||||
@@ -213,12 +211,12 @@ export function useGridColumns<T = SystemOAuth2ClientApi.OAuth2Client>(
|
||||
{
|
||||
field: 'name',
|
||||
title: '应用名',
|
||||
minWidth: 300,
|
||||
minWidth: 120,
|
||||
},
|
||||
{
|
||||
field: 'logo',
|
||||
title: '应用图标',
|
||||
minWidth: 80,
|
||||
minWidth: 100,
|
||||
cellRender: {
|
||||
name: 'CellImage',
|
||||
},
|
||||
@@ -235,19 +233,19 @@ export function useGridColumns<T = SystemOAuth2ClientApi.OAuth2Client>(
|
||||
{
|
||||
field: 'accessTokenValiditySeconds',
|
||||
title: '访问令牌的有效期',
|
||||
minWidth: 130,
|
||||
minWidth: 150,
|
||||
formatter: ({ cellValue }) => `${cellValue} 秒`,
|
||||
},
|
||||
{
|
||||
field: 'refreshTokenValiditySeconds',
|
||||
title: '刷新令牌的有效期',
|
||||
minWidth: 130,
|
||||
minWidth: 150,
|
||||
formatter: ({ cellValue }) => `${cellValue} 秒`,
|
||||
},
|
||||
{
|
||||
field: 'authorizedGrantTypes',
|
||||
title: '授权类型',
|
||||
minWidth: 180,
|
||||
minWidth: 100,
|
||||
},
|
||||
{
|
||||
field: 'createTime',
|
||||
@@ -256,29 +254,10 @@ export function useGridColumns<T = SystemOAuth2ClientApi.OAuth2Client>(
|
||||
formatter: 'formatDateTime',
|
||||
},
|
||||
{
|
||||
field: 'operation',
|
||||
title: '操作',
|
||||
minWidth: 130,
|
||||
align: 'center',
|
||||
width: 130,
|
||||
fixed: 'right',
|
||||
cellRender: {
|
||||
attrs: {
|
||||
nameField: 'name',
|
||||
nameTitle: 'OAuth2 客户端',
|
||||
onClick: onActionClick,
|
||||
},
|
||||
name: 'CellOperation',
|
||||
options: [
|
||||
{
|
||||
code: 'edit',
|
||||
show: hasAccessByCodes(['system:oauth2-client:update']),
|
||||
},
|
||||
{
|
||||
code: 'delete',
|
||||
show: hasAccessByCodes(['system:oauth2-client:delete']),
|
||||
},
|
||||
],
|
||||
},
|
||||
slots: { default: 'actions' },
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user