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 5156e2b28..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 @@ -49,7 +49,8 @@ "localization": { "title": "Localization", "resources": "Resources", - "languages": "Languages" + "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 5ea364714..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 @@ -49,7 +49,8 @@ "localization": { "title": "本地化管理", "resources": "资源管理", - "languages": "语言管理" + "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 43b422883..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 @@ -203,6 +203,15 @@ const routes: RouteRecordRaw[] = [ 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'), + }, ], }, { 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/localization/src/api/useTextsApi.ts b/apps/vben5/packages/@abp/localization/src/api/useTextsApi.ts new file mode 100644 index 000000000..d3fa49576 --- /dev/null +++ b/apps/vben5/packages/@abp/localization/src/api/useTextsApi.ts @@ -0,0 +1,62 @@ +import type { ListResultDto } from '@abp/core'; + +import type { + GetTextByKeyInput, + GetTextsInput, + SetTextInput, + TextDifferenceDto, + TextDto, +} from '../types/texts'; + +import { useRequest } from '@abp/request'; + +export function useTextsApi() { + const { cancel, request } = useRequest(); + + /** + * 查询文本列表 + * @param input 参数 + * @returns 文本列表 + */ + function getListApi( + input: GetTextsInput, + ): Promise> { + return request>( + '/api/abp/localization/texts', + { + method: 'GET', + params: input, + }, + ); + } + + /** + * 查询文本 + * @param input 参数 + * @returns 查询的文本 + */ + function getApi(input: GetTextByKeyInput): Promise { + return request('/api/abp/localization/texts/by-culture-key', { + method: 'GET', + params: input, + }); + } + + /** + * 设置文本 + * @param input 参数 + */ + function setApi(input: SetTextInput): Promise { + return request('/api/localization/texts', { + data: input, + method: 'PUT', + }); + } + + return { + cancel, + getApi, + getListApi, + setApi, + }; +} diff --git a/apps/vben5/packages/@abp/localization/src/components/index.ts b/apps/vben5/packages/@abp/localization/src/components/index.ts index a338e40b0..378940d70 100644 --- a/apps/vben5/packages/@abp/localization/src/components/index.ts +++ b/apps/vben5/packages/@abp/localization/src/components/index.ts @@ -1,2 +1,3 @@ export { default as LocalizationLanguageTable } from './languages/LocalizationLanguageTable.vue'; export { default as LocalizationResourceTable } from './resources/LocalizationResourceTable.vue'; +export { default as LocalizationTextTable } from './texts/LocalizationTextTable.vue'; diff --git a/apps/vben5/packages/@abp/localization/src/components/languages/LocalizationLanguageTable.vue b/apps/vben5/packages/@abp/localization/src/components/languages/LocalizationLanguageTable.vue index 20862327a..9df0786f0 100644 --- a/apps/vben5/packages/@abp/localization/src/components/languages/LocalizationLanguageTable.vue +++ b/apps/vben5/packages/@abp/localization/src/components/languages/LocalizationLanguageTable.vue @@ -8,11 +8,7 @@ import { defineAsyncComponent, h, onMounted, reactive, ref } from 'vue'; import { useVbenModal } from '@vben/common-ui'; import { $t } from '@vben/locales'; -import { - useAbpStore, - useLocalization, - useLocalizationSerializer, -} from '@abp/core'; +import { useAbpStore } from '@abp/core'; import { useVbenVxeGrid } from '@abp/ui'; import { DeleteOutlined, @@ -29,7 +25,7 @@ defineOptions({ name: 'LocalizationLanguageTable', }); -const permissionGroups = ref([]); +const dataSource = ref([]); const pageState = reactive({ current: 1, size: 10, @@ -37,8 +33,6 @@ const pageState = reactive({ }); const abpStore = useAbpStore(); -const { Lr } = useLocalization(); -const { deserialize } = useLocalizationSerializer(); const { deleteApi, getListApi } = useLanguagesApi(); const { getLocalizationApi } = useLocalizationsApi(); @@ -127,13 +121,7 @@ async function onGet(input?: Record) { gridApi.setLoading(true); const { items } = await getListApi(input); pageState.total = items.length; - permissionGroups.value = items.map((item) => { - const localizableString = deserialize(item.displayName); - return { - ...item, - displayName: Lr(localizableString.resourceName, localizableString.name), - }; - }); + dataSource.value = items; onPageChange(); } finally { gridApi.setLoading(false); @@ -147,7 +135,7 @@ async function onReset() { } function onPageChange() { - const items = permissionGroups.value.slice( + const items = dataSource.value.slice( (pageState.current - 1) * pageState.size, pageState.current * pageState.size, ); @@ -178,20 +166,24 @@ function onDelete(row: LanguageDto) { onOk: async () => { await deleteApi(row.cultureName); message.success($t('AbpUi.DeletedSuccessfully')); - onChange(); + onChange(row); }, title: $t('AbpUi.AreYouSure'), }); } -async function onChange() { - gridApi.query(); +async function onChange(data: LanguageDto) { + const input = await gridApi.formApi.getValues(); + onGet(input); // 资源变化刷新本地多语言缓存 - const cultureName = abpStore.localization!.currentCulture.cultureName; - const localization = await getLocalizationApi({ - cultureName, - }); - abpStore.setLocalization(localization); + const cultureName = + abpStore.application!.localization.currentCulture.cultureName; + if (data.cultureName === cultureName) { + const localization = await getLocalizationApi({ + cultureName, + }); + abpStore.setLocalization(localization); + } } onMounted(onGet); diff --git a/apps/vben5/packages/@abp/localization/src/components/resources/LocalizationResourceTable.vue b/apps/vben5/packages/@abp/localization/src/components/resources/LocalizationResourceTable.vue index 9aad82e66..ba6ead397 100644 --- a/apps/vben5/packages/@abp/localization/src/components/resources/LocalizationResourceTable.vue +++ b/apps/vben5/packages/@abp/localization/src/components/resources/LocalizationResourceTable.vue @@ -8,11 +8,7 @@ import { defineAsyncComponent, h, onMounted, reactive, ref } from 'vue'; import { useVbenModal } from '@vben/common-ui'; import { $t } from '@vben/locales'; -import { - useAbpStore, - useLocalization, - useLocalizationSerializer, -} from '@abp/core'; +import { useAbpStore } from '@abp/core'; import { useVbenVxeGrid } from '@abp/ui'; import { DeleteOutlined, @@ -29,7 +25,7 @@ defineOptions({ name: 'LocalizationResourceTable', }); -const permissionGroups = ref([]); +const dataSource = ref([]); const pageState = reactive({ current: 1, size: 10, @@ -37,8 +33,6 @@ const pageState = reactive({ }); const abpStore = useAbpStore(); -const { Lr } = useLocalization(); -const { deserialize } = useLocalizationSerializer(); const { deleteApi, getListApi } = useResourcesApi(); const { getLocalizationApi } = useLocalizationsApi(); @@ -121,13 +115,7 @@ async function onGet(input?: Record) { gridApi.setLoading(true); const { items } = await getListApi(input); pageState.total = items.length; - permissionGroups.value = items.map((item) => { - const localizableString = deserialize(item.displayName); - return { - ...item, - displayName: Lr(localizableString.resourceName, localizableString.name), - }; - }); + dataSource.value = items; onPageChange(); } finally { gridApi.setLoading(false); @@ -141,7 +129,7 @@ async function onReset() { } function onPageChange() { - const items = permissionGroups.value.slice( + const items = dataSource.value.slice( (pageState.current - 1) * pageState.size, pageState.current * pageState.size, ); @@ -179,7 +167,8 @@ function onDelete(row: ResourceDto) { } async function onChange() { - gridApi.query(); + const input = await gridApi.formApi.getValues(); + onGet(input); // 资源变化刷新本地多语言缓存 const cultureName = abpStore.localization!.currentCulture.cultureName; const localization = await getLocalizationApi({ 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 @@ + + + + + + + onLanguageChange(value!.toString())" + /> + + + + + + + + + + + + + + + diff --git a/apps/vben5/packages/@abp/localization/src/components/texts/LocalizationTextTable.vue b/apps/vben5/packages/@abp/localization/src/components/texts/LocalizationTextTable.vue new file mode 100644 index 000000000..4a97a67fa --- /dev/null +++ b/apps/vben5/packages/@abp/localization/src/components/texts/LocalizationTextTable.vue @@ -0,0 +1,317 @@ + + + + + + onFieldChange('cultureName', value?.toString())" + /> + + + onFieldChange('targetCultureName', value?.toString()) + " + /> + + + onFieldChange('resourceName', value?.toString())" + /> + + + onFieldChange('onlyNull', value?.toString())" + /> + + + + {{ $t('LocalizationManagement.Text:AddNew') }} + + + + + + {{ $t('AbpUi.Edit') }} + + + + + + + + diff --git a/apps/vben5/packages/@abp/localization/src/types/texts.ts b/apps/vben5/packages/@abp/localization/src/types/texts.ts new file mode 100644 index 000000000..a5369bf79 --- /dev/null +++ b/apps/vben5/packages/@abp/localization/src/types/texts.ts @@ -0,0 +1,51 @@ +interface GetTextByKeyInput { + cultureName: string; + key: string; + resourceName: string; +} + +interface GetTextsInput { + cultureName: string; + filter?: string; + onlyNull?: boolean; + resourceName?: string; + targetCultureName: string; +} + +interface SetTextInput { + cultureName: string; + key: string; + resourceName: string; + value: string; +} + +interface RestoreDefaultTextInput { + cultureName: string; + key: string; + resourceName: string; +} + +interface TextDifferenceDto { + cultureName: string; + key: string; + resourceName: string; + targetCultureName: string; + targetValue: string; + value: string; +} + +interface TextDto { + cultureName: string; + key: string; + resourceName: string; + value: string; +} + +export type { + GetTextByKeyInput, + GetTextsInput, + RestoreDefaultTextInput, + SetTextInput, + TextDifferenceDto, + TextDto, +};