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/locales/langs/en-US/abp.json b/apps/vben5/apps/app-antd/src/locales/langs/en-US/abp.json index 7e50c1168..c1bf002b0 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,10 @@ "myNotifilers": "My Notifilers", "groups": "Groups", "definitions": "Definitions" + }, + "localization": { + "title": "Localization", + "resources": "Resources" } }, "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..9572acc11 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,10 @@ "myNotifilers": "我的通知", "groups": "通知分组", "definitions": "通知定义" + }, + "localization": { + "title": "本地化管理", + "resources": "资源管理" } }, "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..8a8f6477a 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,26 @@ 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.identity.auditLogs'), 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/packages/@abp/localization/package.json b/apps/vben5/packages/@abp/localization/package.json new file mode 100644 index 000000000..121edef76 --- /dev/null +++ b/apps/vben5/packages/@abp/localization/package.json @@ -0,0 +1,40 @@ +{ + "name": "@abp/localization", + "version": "9.0.4", + "homepage": "https://github.com/colinin/abp-next-admin", + "bugs": "https://github.com/colinin/abp-next-admin/issues", + "repository": { + "type": "git", + "url": "git+https://github.com/colinin/abp-next-admin.git", + "directory": "packages/@abp/localization" + }, + "license": "MIT", + "type": "module", + "sideEffects": [ + "**/*.css" + ], + "exports": { + ".": { + "types": "./src/index.ts", + "default": "./src/index.ts" + } + }, + "dependencies": { + "@abp/components": "workspace:*", + "@abp/core": "workspace:*", + "@abp/request": "workspace:*", + "@abp/signalr": "workspace:*", + "@abp/ui": "workspace:*", + "@ant-design/icons-vue": "catalog:", + "@vben/access": "workspace:*", + "@vben/common-ui": "workspace:*", + "@vben/hooks": "workspace:*", + "@vben/icons": "workspace:*", + "@vben/layouts": "workspace:*", + "@vben/locales": "workspace:*", + "ant-design-vue": "catalog:", + "dayjs": "catalog:", + "vue": "catalog:*", + "vxe-table": "catalog:" + } +} diff --git a/apps/vben5/packages/@abp/localization/src/api/index.ts b/apps/vben5/packages/@abp/localization/src/api/index.ts new file mode 100644 index 000000000..d0bdf1313 --- /dev/null +++ b/apps/vben5/packages/@abp/localization/src/api/index.ts @@ -0,0 +1,2 @@ +export { useLocalizationsApi } from './useLocalizationsApi'; +export { useResourcesApi } from './useResourcesApi'; diff --git a/apps/vben5/packages/@abp/localization/src/api/useLocalizationsApi.ts b/apps/vben5/packages/@abp/localization/src/api/useLocalizationsApi.ts new file mode 100644 index 000000000..bfb6975ac --- /dev/null +++ b/apps/vben5/packages/@abp/localization/src/api/useLocalizationsApi.ts @@ -0,0 +1,28 @@ +import type { ApplicationLocalizationDto } from '@abp/core'; + +import { useRequest } from '@abp/request'; + +export function useLocalizationsApi() { + const { cancel, request } = useRequest(); + /** + * 获取应用程序语言 + * @returns 本地化配置 + */ + function getLocalizationApi(options: { + cultureName: string; + onlyDynamics?: boolean; + }): Promise { + return request( + '/api/abp/application-localization', + { + method: 'GET', + params: options, + }, + ); + } + + return { + cancel, + getLocalizationApi, + }; +} diff --git a/apps/vben5/packages/@abp/localization/src/api/useResourcesApi.ts b/apps/vben5/packages/@abp/localization/src/api/useResourcesApi.ts new file mode 100644 index 000000000..a8bcd38e5 --- /dev/null +++ b/apps/vben5/packages/@abp/localization/src/api/useResourcesApi.ts @@ -0,0 +1,89 @@ +import type { ListResultDto } from '@abp/core'; + +import type { + ResourceCreateDto, + ResourceDto, + ResourceGetListInput, + ResourceUpdateDto, +} from '../types/resources'; + +import { useRequest } from '@abp/request'; + +export function useResourcesApi() { + const { cancel, request } = useRequest(); + + /** + * 查询资源列表 + * @param input 参数 + * @returns 资源列表 + */ + function getListApi( + input?: ResourceGetListInput, + ): Promise> { + return request>( + '/api/abp/localization/resources', + { + method: 'GET', + params: input, + }, + ); + } + + /** + * 查询资源 + * @param name 资源名称 + * @returns 查询的资源 + */ + function getApi(name: string): Promise { + return request(`/api/localization/resources/${name}`, { + method: 'GET', + }); + } + + /** + * 删除资源 + * @param name 资源名称 + */ + function deleteApi(name: string): Promise { + return request(`/api/localization/resources/${name}`, { + method: 'DELETE', + }); + } + + /** + * 创建资源 + * @param input 参数 + * @returns 创建的资源 + */ + function createApi(input: ResourceCreateDto): Promise { + return request(`/api/localization/resources`, { + data: input, + method: 'POST', + }); + } + + /** + * 编辑资源 + * @param name 资源名称 + * @param input 参数 + * @returns 编辑的资源 + */ + function updateApi( + name: string, + input: ResourceUpdateDto, + ): Promise { + return request(`/api/localization/resources/${name}`, { + data: input, + method: 'PUT', + }); + } + + return { + cancel, + createApi, + deleteApi, + getApi, + getListApi, + updateApi, + }; +} diff --git a/apps/vben5/packages/@abp/localization/src/components/index.ts b/apps/vben5/packages/@abp/localization/src/components/index.ts new file mode 100644 index 000000000..78dfadb28 --- /dev/null +++ b/apps/vben5/packages/@abp/localization/src/components/index.ts @@ -0,0 +1 @@ +export { default as LocalizationResourceTable } from './resources/LocalizationResourceTable.vue'; 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 @@ + + + + + + + + {{ $t('LocalizationManagement.DisplayName:Enable') }} + + + + + + + + + + + + + + + + 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..9aad82e66 --- /dev/null +++ b/apps/vben5/packages/@abp/localization/src/components/resources/LocalizationResourceTable.vue @@ -0,0 +1,234 @@ + + + + + + + {{ $t('LocalizationManagement.Resource:AddNew') }} + + + + + + {{ $t('AbpUi.Edit') }} + + + {{ $t('AbpUi.Delete') }} + + + + + + + + diff --git a/apps/vben5/packages/@abp/localization/src/constants/index.ts b/apps/vben5/packages/@abp/localization/src/constants/index.ts new file mode 100644 index 000000000..c85954d3e --- /dev/null +++ b/apps/vben5/packages/@abp/localization/src/constants/index.ts @@ -0,0 +1 @@ +export * from './permissions'; diff --git a/apps/vben5/packages/@abp/localization/src/constants/permissions.ts b/apps/vben5/packages/@abp/localization/src/constants/permissions.ts new file mode 100644 index 000000000..f8efa3338 --- /dev/null +++ b/apps/vben5/packages/@abp/localization/src/constants/permissions.ts @@ -0,0 +1,10 @@ +/** 资源管理权限 */ +export const ResourcesPermissions = { + /** 新增 */ + Create: 'LocalizationManagement.Resource.Create', + Default: 'LocalizationManagement.Resource', + /** 删除 */ + Delete: 'LocalizationManagement.Resource.Delete', + /** 更新 */ + Update: 'LocalizationManagement.Resource.Update', +}; diff --git a/apps/vben5/packages/@abp/localization/src/index.ts b/apps/vben5/packages/@abp/localization/src/index.ts new file mode 100644 index 000000000..314dad0cd --- /dev/null +++ b/apps/vben5/packages/@abp/localization/src/index.ts @@ -0,0 +1,3 @@ +export * from './api'; +export * from './components'; +export * from './types'; diff --git a/apps/vben5/packages/@abp/localization/src/types/index.ts b/apps/vben5/packages/@abp/localization/src/types/index.ts new file mode 100644 index 000000000..00e67e02e --- /dev/null +++ b/apps/vben5/packages/@abp/localization/src/types/index.ts @@ -0,0 +1 @@ +export * from './resources'; diff --git a/apps/vben5/packages/@abp/localization/src/types/resources.ts b/apps/vben5/packages/@abp/localization/src/types/resources.ts new file mode 100644 index 000000000..8523c0094 --- /dev/null +++ b/apps/vben5/packages/@abp/localization/src/types/resources.ts @@ -0,0 +1,33 @@ +import type { AuditedEntityDto } from '@abp/core'; + +interface ResourceDto extends AuditedEntityDto { + defaultCultureName?: string; + description?: string; + displayName: string; + enable: boolean; + name: string; +} + +interface ResourceCreateOrUpdateDto { + defaultCultureName?: string; + description?: string; + displayName: string; + enable: boolean; +} + +interface ResourceCreateDto extends ResourceCreateOrUpdateDto { + name: string; +} + +type ResourceUpdateDto = ResourceCreateOrUpdateDto; + +interface ResourceGetListInput { + filter?: string; +} + +export type { + ResourceCreateDto, + ResourceDto, + ResourceGetListInput, + ResourceUpdateDto, +}; diff --git a/apps/vben5/packages/@abp/localization/tsconfig.json b/apps/vben5/packages/@abp/localization/tsconfig.json new file mode 100644 index 000000000..ce1a891fb --- /dev/null +++ b/apps/vben5/packages/@abp/localization/tsconfig.json @@ -0,0 +1,6 @@ +{ + "$schema": "https://json.schemastore.org/tsconfig", + "extends": "@vben/tsconfig/web.json", + "include": ["src"], + "exclude": ["node_modules"] +}