diff --git a/apps/vben5/apps/app-antd/package.json b/apps/vben5/apps/app-antd/package.json index adfaf25a1..b4b1336ef 100644 --- a/apps/vben5/apps/app-antd/package.json +++ b/apps/vben5/apps/app-antd/package.json @@ -31,6 +31,7 @@ "@abp/core": "workspace:*", "@abp/features": "workspace:*", "@abp/identity": "workspace:*", + "@abp/localization": "workspace:*", "@abp/notifications": "workspace:*", "@abp/openiddict": "workspace:*", "@abp/permissions": "workspace:*", 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/api/core/useAbpConfigApi.ts b/apps/vben5/apps/app-antd/src/api/core/useAbpConfigApi.ts index 39715ab18..4eb9c3a94 100644 --- a/apps/vben5/apps/app-antd/src/api/core/useAbpConfigApi.ts +++ b/apps/vben5/apps/app-antd/src/api/core/useAbpConfigApi.ts @@ -1,7 +1,4 @@ -import type { - ApplicationConfigurationDto, - ApplicationLocalizationDto, -} from '@abp/core'; +import type { ApplicationConfigurationDto } from '@abp/core'; import { useRequest } from '@abp/request'; @@ -23,26 +20,8 @@ export function useAbpConfigApi() { ); } - /** - * 获取应用程序语言 - * @returns 本地化配置 - */ - function getLocalizationApi(options: { - cultureName: string; - onlyDynamics?: boolean; - }): Promise { - return request( - '/api/abp/application-localization', - { - params: options, - method: 'GET', - }, - ); - } - return { cancel, getConfigApi, - getLocalizationApi, }; } 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/apps/app-antd/src/locales/index.ts b/apps/vben5/apps/app-antd/src/locales/index.ts index 7e50af3b5..f221600e7 100644 --- a/apps/vben5/apps/app-antd/src/locales/index.ts +++ b/apps/vben5/apps/app-antd/src/locales/index.ts @@ -14,13 +14,12 @@ import { import { preferences } from '@vben/preferences'; import { useAbpStore } from '@abp/core'; +import { useLocalizationsApi } from '@abp/localization'; import antdEnLocale from 'ant-design-vue/es/locale/en_US'; import antdDefaultLocale from 'ant-design-vue/es/locale/zh_CN'; import dayjs from 'dayjs'; import localizedFormat from 'dayjs/plugin/localizedFormat'; -import { useAbpConfigApi } from '#/api/core/useAbpConfigApi'; - const antdLocale = ref(antdDefaultLocale); const modules = import.meta.glob('./langs/**/*.json'); @@ -106,7 +105,7 @@ async function loadAntdLocale(lang: SupportedLanguagesType) { */ async function loadAbpLocale(lang: SupportedLanguagesType) { const abpStore = useAbpStore(); - const { getLocalizationApi } = useAbpConfigApi(); + const { getLocalizationApi } = useLocalizationsApi(); let localization = abpStore.localization; if (lang !== localization?.currentCulture.cultureName) { diff --git a/apps/vben5/apps/app-antd/src/locales/langs/en-US/abp.json b/apps/vben5/apps/app-antd/src/locales/langs/en-US/abp.json index 7e50c1168..920c5e943 100644 --- a/apps/vben5/apps/app-antd/src/locales/langs/en-US/abp.json +++ b/apps/vben5/apps/app-antd/src/locales/langs/en-US/abp.json @@ -45,6 +45,12 @@ "myNotifilers": "My Notifilers", "groups": "Groups", "definitions": "Definitions" + }, + "localization": { + "title": "Localization", + "resources": "Resources", + "languages": "Languages", + "texts": "Texts" } }, "openiddict": { diff --git a/apps/vben5/apps/app-antd/src/locales/langs/zh-CN/abp.json b/apps/vben5/apps/app-antd/src/locales/langs/zh-CN/abp.json index 7976ea8f7..23c6b717a 100644 --- a/apps/vben5/apps/app-antd/src/locales/langs/zh-CN/abp.json +++ b/apps/vben5/apps/app-antd/src/locales/langs/zh-CN/abp.json @@ -45,6 +45,12 @@ "myNotifilers": "我的通知", "groups": "通知分组", "definitions": "通知定义" + }, + "localization": { + "title": "本地化管理", + "resources": "资源管理", + "languages": "语言管理", + "texts": "文档管理" } }, "openiddict": { diff --git a/apps/vben5/apps/app-antd/src/router/routes/modules/abp.ts b/apps/vben5/apps/app-antd/src/router/routes/modules/abp.ts index 3504f198a..cd842c657 100644 --- a/apps/vben5/apps/app-antd/src/router/routes/modules/abp.ts +++ b/apps/vben5/apps/app-antd/src/router/routes/modules/abp.ts @@ -175,6 +175,45 @@ const routes: RouteRecordRaw[] = [ }, ], }, + { + meta: { + title: $t('abp.manage.localization.title'), + icon: 'ion:globe-outline', + }, + name: 'LocalizationManagement', + path: '/manage/localization', + children: [ + { + meta: { + title: $t('abp.manage.localization.resources'), + icon: 'grommet-icons:resources', + }, + name: 'LocalizationResources', + path: '/manage/localization/resources', + component: () => + import('#/views/localization/resources/index.vue'), + }, + { + meta: { + title: $t('abp.manage.localization.languages'), + icon: 'cil:language', + }, + name: 'LocalizationLanguages', + path: '/manage/localization/languages', + component: () => + import('#/views/localization/languages/index.vue'), + }, + { + meta: { + title: $t('abp.manage.localization.texts'), + icon: 'mi:text', + }, + name: 'LocalizationTexts', + path: '/manage/localization/texts', + component: () => import('#/views/localization/texts/index.vue'), + }, + ], + }, { meta: { title: $t('abp.manage.identity.auditLogs'), diff --git a/apps/vben5/apps/app-antd/src/views/localization/languages/index.vue b/apps/vben5/apps/app-antd/src/views/localization/languages/index.vue new file mode 100644 index 000000000..b2c23dd24 --- /dev/null +++ b/apps/vben5/apps/app-antd/src/views/localization/languages/index.vue @@ -0,0 +1,15 @@ + + + diff --git a/apps/vben5/apps/app-antd/src/views/localization/resources/index.vue b/apps/vben5/apps/app-antd/src/views/localization/resources/index.vue new file mode 100644 index 000000000..114495512 --- /dev/null +++ b/apps/vben5/apps/app-antd/src/views/localization/resources/index.vue @@ -0,0 +1,15 @@ + + + diff --git a/apps/vben5/apps/app-antd/src/views/localization/texts/index.vue b/apps/vben5/apps/app-antd/src/views/localization/texts/index.vue new file mode 100644 index 000000000..ac0169dc2 --- /dev/null +++ b/apps/vben5/apps/app-antd/src/views/localization/texts/index.vue @@ -0,0 +1,15 @@ + + + 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/localization/src/components/languages/LocalizationLanguageTable.vue b/apps/vben5/packages/@abp/localization/src/components/languages/LocalizationLanguageTable.vue new file mode 100644 index 000000000..e70fc11fe --- /dev/null +++ b/apps/vben5/packages/@abp/localization/src/components/languages/LocalizationLanguageTable.vue @@ -0,0 +1,234 @@ + + + + + diff --git a/apps/vben5/packages/@abp/localization/src/components/resources/LocalizationResourceModal.vue b/apps/vben5/packages/@abp/localization/src/components/resources/LocalizationResourceModal.vue new file mode 100644 index 000000000..5ea5f6bb9 --- /dev/null +++ b/apps/vben5/packages/@abp/localization/src/components/resources/LocalizationResourceModal.vue @@ -0,0 +1,125 @@ + + + + + diff --git a/apps/vben5/packages/@abp/localization/src/components/resources/LocalizationResourceTable.vue b/apps/vben5/packages/@abp/localization/src/components/resources/LocalizationResourceTable.vue new file mode 100644 index 000000000..3a1c6f7d0 --- /dev/null +++ b/apps/vben5/packages/@abp/localization/src/components/resources/LocalizationResourceTable.vue @@ -0,0 +1,225 @@ + + + + + diff --git a/apps/vben5/packages/@abp/localization/src/components/texts/LocalizationTextModal.vue b/apps/vben5/packages/@abp/localization/src/components/texts/LocalizationTextModal.vue new file mode 100644 index 000000000..6d7f72c8d --- /dev/null +++ b/apps/vben5/packages/@abp/localization/src/components/texts/LocalizationTextModal.vue @@ -0,0 +1,196 @@ + + +