From bc65b830c175e164437de2ef80f6dd270d4ee543 Mon Sep 17 00:00:00 2001 From: colin Date: Wed, 12 Mar 2025 20:18:47 +0800 Subject: [PATCH] fix(vben5): fixed useVbenForm Component not registed --- apps/vben5/apps/app-antd/src/adapter/form.ts | 49 +++++ apps/vben5/apps/app-antd/src/bootstrap.ts | 2 + .../components/audit-logs/AuditLogTable.vue | 8 +- .../@abp/core/src/constants/events.ts | 2 + .../features/FeatureDefinitionModal.vue | 4 +- .../features/FeatureDefinitionTable.vue | 6 +- .../groups/FeatureGroupDefinitionModal.vue | 4 +- .../groups/FeatureGroupDefinitionTable.vue | 6 +- .../@abp/gdpr/src/components/GdprTable.vue | 2 +- .../src/api/useOrganizationUnitsApi.ts | 2 +- .../components/claim-types/ClaimTypeModal.vue | 4 +- .../components/claim-types/ClaimTypeTable.vue | 6 +- .../src/components/claims/ClaimModal.vue | 4 +- .../src/components/claims/ClaimTable.vue | 2 +- .../OrganizationUnitModal.vue | 15 +- .../OrganizationUnitRoleTable.vue | 14 +- .../OrganizationUnitTree.vue | 2 +- .../OrganizationUnitUserTable.vue | 6 +- .../organization-units/SelectMemberModal.vue | 4 +- .../organization-units/SelectRoleModal.vue | 12 +- .../src/components/roles/RoleModal.vue | 4 +- .../src/components/roles/RoleTable.vue | 18 +- .../security-logs/SecurityLogTable.vue | 8 +- .../src/components/sessions/SessionTable.vue | 4 +- .../src/components/users/UserLockModal.vue | 8 +- .../src/components/users/UserModal.vue | 8 +- .../components/users/UserPasswordModal.vue | 4 +- .../src/components/users/UserTable.vue | 6 +- .../@abp/identity/src/constants/index.ts | 1 - .../vben5/packages/@abp/identity/src/index.ts | 2 +- .../languages/LocalizationLanguageTable.vue | 4 +- .../resources/LocalizationResourceTable.vue | 4 +- .../texts/LocalizationTextTable.vue | 10 +- .../localization/src/constants/permissions.ts | 10 + .../NotificationGroupDefinitionModal.vue | 4 +- .../NotificationGroupDefinitionTable.vue | 12 +- .../NotificationDefinitionTable.vue | 6 +- .../my-notifilers/MyNotificationTable.vue | 6 +- .../applications/ApplicationModal.vue | 4 +- .../applications/ApplicationSecretModal.vue | 19 +- .../applications/ApplicationTable.vue | 6 +- .../authorizations/AuthorizationTable.vue | 6 +- .../src/components/scopes/ScopeModal.vue | 4 +- .../src/components/scopes/ScopeTable.vue | 6 +- .../src/components/tokens/TokenTable.vue | 6 +- .../@abp/openiddict/src/constants/index.ts | 1 - .../packages/@abp/openiddict/src/index.ts | 1 - .../groups/PermissionGroupDefinitionModal.vue | 4 +- .../groups/PermissionGroupDefinitionTable.vue | 6 +- .../permissions/PermissionDefinitionModal.vue | 4 +- .../permissions/PermissionDefinitionTable.vue | 6 +- .../permissions/PermissionModal.vue | 17 +- .../@abp/permissions/src/constants/index.ts | 1 - .../messages/email/EmailMessageTable.vue | 6 +- .../messages/sms/SmsMessageTable.vue | 6 +- .../@abp/platform/src/constants/index.ts | 1 - .../vben5/packages/@abp/platform/src/index.ts | 1 - .../src/components/editions/EditionModal.vue | 3 +- .../src/components/editions/EditionTable.vue | 6 +- .../src/components/tenants/TenantTable.vue | 6 +- .../packages/@abp/saas/src/constants/index.ts | 1 - apps/vben5/packages/@abp/saas/src/index.ts | 1 - .../@abp/settings/src/api/definitions.ts | 77 -------- .../packages/@abp/settings/src/api/index.ts | 4 +- .../@abp/settings/src/api/settings.ts | 84 --------- .../settings/src/api/useDefinitionsApi.ts | 99 ++++++++++ .../@abp/settings/src/api/useSettingsApi.ts | 103 +++++++++++ .../definitions/SettingDefinitionModal.vue | 8 +- .../definitions/SettingDefinitionTable.vue | 9 +- .../src/components/settings/SystemSetting.vue | 15 +- .../src/components/settings/UserSetting.vue | 4 +- .../@abp/settings/src/constants/index.ts | 1 - .../vben5/packages/@abp/settings/src/index.ts | 1 - .../@abp/ui/src/adapter/component/index.ts | 172 ------------------ .../packages/@abp/ui/src/adapter/form.ts | 47 ----- .../packages/@abp/ui/src/adapter/vxe-table.ts | 3 +- apps/vben5/packages/@abp/ui/src/index.ts | 2 - 77 files changed, 481 insertions(+), 543 deletions(-) create mode 100644 apps/vben5/apps/app-antd/src/adapter/form.ts delete mode 100644 apps/vben5/packages/@abp/identity/src/constants/index.ts delete mode 100644 apps/vben5/packages/@abp/openiddict/src/constants/index.ts delete mode 100644 apps/vben5/packages/@abp/permissions/src/constants/index.ts delete mode 100644 apps/vben5/packages/@abp/platform/src/constants/index.ts delete mode 100644 apps/vben5/packages/@abp/saas/src/constants/index.ts delete mode 100644 apps/vben5/packages/@abp/settings/src/api/definitions.ts delete mode 100644 apps/vben5/packages/@abp/settings/src/api/settings.ts create mode 100644 apps/vben5/packages/@abp/settings/src/api/useDefinitionsApi.ts create mode 100644 apps/vben5/packages/@abp/settings/src/api/useSettingsApi.ts delete mode 100644 apps/vben5/packages/@abp/settings/src/constants/index.ts delete mode 100644 apps/vben5/packages/@abp/ui/src/adapter/component/index.ts delete mode 100644 apps/vben5/packages/@abp/ui/src/adapter/form.ts diff --git a/apps/vben5/apps/app-antd/src/adapter/form.ts b/apps/vben5/apps/app-antd/src/adapter/form.ts new file mode 100644 index 000000000..4a55850ec --- /dev/null +++ b/apps/vben5/apps/app-antd/src/adapter/form.ts @@ -0,0 +1,49 @@ +import type { + VbenFormSchema as FormSchema, + VbenFormProps, +} from '@vben/common-ui'; + +import type { ComponentType } from './component'; + +import { setupVbenForm, useVbenForm as useForm, z } from '@vben/common-ui'; +import { $t } from '@vben/locales'; + +async function initVbenForm() { + setupVbenForm({ + config: { + // ant design vue组件库默认都是 v-model:value + baseModelPropName: 'value', + + // 一些组件是 v-model:checked 或者 v-model:fileList + modelPropNameMap: { + Checkbox: 'checked', + Radio: 'checked', + Switch: 'checked', + Upload: 'fileList', + }, + }, + defineRules: { + // 输入项目必填国际化适配 + required: (value, _params, ctx) => { + if (value === undefined || value === null || value.length === 0) { + return $t('ui.formRules.required', [ctx.label]); + } + return true; + }, + // 选择项目必填国际化适配 + selectRequired: (value, _params, ctx) => { + if (value === undefined || value === null) { + return $t('ui.formRules.selectRequired', [ctx.label]); + } + return true; + }, + }, + }); +} + +const useVbenForm = useForm; + +export { initVbenForm, useVbenForm, z }; + +export type VbenFormSchema = FormSchema; +export type { VbenFormProps }; diff --git a/apps/vben5/apps/app-antd/src/bootstrap.ts b/apps/vben5/apps/app-antd/src/bootstrap.ts index 1967cea94..520ec1e1f 100644 --- a/apps/vben5/apps/app-antd/src/bootstrap.ts +++ b/apps/vben5/apps/app-antd/src/bootstrap.ts @@ -12,6 +12,7 @@ import { useTitle } from '@vueuse/core'; import { $t, setupI18n } from '#/locales'; import { initComponentAdapter } from './adapter/component'; +import { initVbenForm } from './adapter/form'; import { initRequestClient } from './adapter/request'; import App from './app.vue'; import { router } from './router'; @@ -19,6 +20,7 @@ import { router } from './router'; async function bootstrap(namespace: string) { // 初始化组件适配器 await initComponentAdapter(); + await initVbenForm(); initRequestClient(); const app = createApp(App); diff --git a/apps/vben5/packages/@abp/auditing/src/components/audit-logs/AuditLogTable.vue b/apps/vben5/packages/@abp/auditing/src/components/audit-logs/AuditLogTable.vue index 5c2e29ad6..0b4b4a27e 100644 --- a/apps/vben5/packages/@abp/auditing/src/components/audit-logs/AuditLogTable.vue +++ b/apps/vben5/packages/@abp/auditing/src/components/audit-logs/AuditLogTable.vue @@ -1,6 +1,8 @@ diff --git a/apps/vben5/packages/@abp/identity/src/components/claims/ClaimTable.vue b/apps/vben5/packages/@abp/identity/src/components/claims/ClaimTable.vue index 305720e43..e52ef683d 100644 --- a/apps/vben5/packages/@abp/identity/src/components/claims/ClaimTable.vue +++ b/apps/vben5/packages/@abp/identity/src/components/claims/ClaimTable.vue @@ -91,7 +91,7 @@ async function onDelete(row: IdentityClaimDto) { claimType: row.claimType, claimValue: row.claimValue, }); - message.success($t('AbpUi.SuccessfullyDeleted')); + message.success($t('AbpUi.DeletedSuccessfully')); query(); emits('onDelete'); } diff --git a/apps/vben5/packages/@abp/identity/src/components/organization-units/OrganizationUnitModal.vue b/apps/vben5/packages/@abp/identity/src/components/organization-units/OrganizationUnitModal.vue index 7b9fcbf2f..aa8c5b4b5 100644 --- a/apps/vben5/packages/@abp/identity/src/components/organization-units/OrganizationUnitModal.vue +++ b/apps/vben5/packages/@abp/identity/src/components/organization-units/OrganizationUnitModal.vue @@ -5,11 +5,9 @@ import type { OrganizationUnitUpdateDto, } from '../../types/organization-units'; -import { useVbenModal } from '@vben/common-ui'; +import { useVbenForm, useVbenModal } from '@vben/common-ui'; import { $t } from '@vben/locales'; -import { useVbenForm } from '@abp/ui'; - import { useOrganizationUnitsApi } from '../../api/useOrganizationUnitsApi'; defineOptions({ @@ -103,17 +101,16 @@ const [Modal, modalApi] = useVbenModal({ async function onSubmit(input: Record) { try { modalApi.setState({ - confirmLoading: true, + submitting: true, }); - const api = input.id - ? updateApi(input.id, input as OrganizationUnitUpdateDto) - : createApi(input as OrganizationUnitCreateDto); - const dto = await api; + const dto = input.id + ? await updateApi(input.id, input as OrganizationUnitUpdateDto) + : await createApi(input as OrganizationUnitCreateDto); emits('change', dto); modalApi.close(); } finally { modalApi.setState({ - confirmLoading: false, + submitting: false, }); } } diff --git a/apps/vben5/packages/@abp/identity/src/components/organization-units/OrganizationUnitRoleTable.vue b/apps/vben5/packages/@abp/identity/src/components/organization-units/OrganizationUnitRoleTable.vue index 6d55021d2..bc501fd02 100644 --- a/apps/vben5/packages/@abp/identity/src/components/organization-units/OrganizationUnitRoleTable.vue +++ b/apps/vben5/packages/@abp/identity/src/components/organization-units/OrganizationUnitRoleTable.vue @@ -1,4 +1,6 @@ diff --git a/apps/vben5/packages/@abp/identity/src/components/security-logs/SecurityLogTable.vue b/apps/vben5/packages/@abp/identity/src/components/security-logs/SecurityLogTable.vue index 19d65cf6d..fc3d3ae42 100644 --- a/apps/vben5/packages/@abp/identity/src/components/security-logs/SecurityLogTable.vue +++ b/apps/vben5/packages/@abp/identity/src/components/security-logs/SecurityLogTable.vue @@ -1,6 +1,8 @@ diff --git a/apps/vben5/packages/@abp/openiddict/src/components/applications/ApplicationTable.vue b/apps/vben5/packages/@abp/openiddict/src/components/applications/ApplicationTable.vue index b4fc12d84..9c32c2566 100644 --- a/apps/vben5/packages/@abp/openiddict/src/components/applications/ApplicationTable.vue +++ b/apps/vben5/packages/@abp/openiddict/src/components/applications/ApplicationTable.vue @@ -1,7 +1,9 @@