From a8be8df117364f5145e037ad510c0b0edb74c7b9 Mon Sep 17 00:00:00 2001 From: AN <1983933789@qq.com> Date: Thu, 24 Apr 2025 22:23:08 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=AF=B9=E6=8E=A5oss?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/router/elegant/imports.ts | 1 + src/router/elegant/routes.ts | 9 + src/router/elegant/transform.ts | 1 + src/service/api/system/config.ts | 8 + src/service/api/system/oss.ts | 18 ++ src/typings/api/system.api.d.ts | 27 +++ src/typings/elegant-router.d.ts | 2 + src/utils/common.ts | 6 + src/views/system/oss/index.vue | 227 ++++++++++++++++++++ src/views/system/oss/modules/oss-search.vue | 72 +++++++ 10 files changed, 371 insertions(+) create mode 100644 src/service/api/system/oss.ts create mode 100644 src/views/system/oss/index.vue create mode 100644 src/views/system/oss/modules/oss-search.vue diff --git a/src/router/elegant/imports.ts b/src/router/elegant/imports.ts index 90a75bbc..29b71b19 100644 --- a/src/router/elegant/imports.ts +++ b/src/router/elegant/imports.ts @@ -32,6 +32,7 @@ export const views: Record Promise import("@/views/system/dict/type/index.vue"), system_menu: () => import("@/views/system/menu/index.vue"), system_notice: () => import("@/views/system/notice/index.vue"), + system_oss: () => import("@/views/system/oss/index.vue"), system_post: () => import("@/views/system/post/index.vue"), system_tenant: () => import("@/views/system/tenant/index.vue"), system_user: () => import("@/views/system/user/index.vue"), diff --git a/src/router/elegant/routes.ts b/src/router/elegant/routes.ts index cca82f82..2f9938ff 100644 --- a/src/router/elegant/routes.ts +++ b/src/router/elegant/routes.ts @@ -202,6 +202,15 @@ export const generatedRoutes: GeneratedRoute[] = [ i18nKey: 'route.system_notice' } }, + { + name: 'system_oss', + path: '/system/oss', + component: 'view.system_oss', + meta: { + title: 'system_oss', + i18nKey: 'route.system_oss' + } + }, { name: 'system_post', path: '/system/post', diff --git a/src/router/elegant/transform.ts b/src/router/elegant/transform.ts index dcc5979e..a80a503a 100644 --- a/src/router/elegant/transform.ts +++ b/src/router/elegant/transform.ts @@ -182,6 +182,7 @@ const routeMap: RouteMap = { "system_dict_type": "/system/dict/type", "system_menu": "/system/menu", "system_notice": "/system/notice", + "system_oss": "/system/oss", "system_post": "/system/post", "system_tenant": "/system/tenant", "system_user": "/system/user", diff --git a/src/service/api/system/config.ts b/src/service/api/system/config.ts index 836b1791..c8548f1a 100644 --- a/src/service/api/system/config.ts +++ b/src/service/api/system/config.ts @@ -43,6 +43,14 @@ export function fetchBatchDeleteConfig(configIds: CommonType.IdType[]) { }); } +/** 根据Key获取值 */ +export function fetchGetConfigByKey(configKey: string) { + return request({ + url: `/system/config/configKey/${configKey}`, + method: 'get' + }); +} + /** 刷新缓存 */ export function fetchRefreshCache() { return request({ diff --git a/src/service/api/system/oss.ts b/src/service/api/system/oss.ts new file mode 100644 index 00000000..f8e0f39d --- /dev/null +++ b/src/service/api/system/oss.ts @@ -0,0 +1,18 @@ +import { request } from '@/service/request'; + +/** 获取文件管理列表 */ +export function fetchGetOssList(params?: Api.System.OssSearchParams) { + return request({ + url: '/resource/oss/list', + method: 'get', + params + }); +} + +/** 批量删除文件管理 */ +export function fetchBatchDeleteOss(ossIds: CommonType.IdType[]) { + return request({ + url: `/resource/oss/${ossIds.join(',')}`, + method: 'delete' + }); +} diff --git a/src/typings/api/system.api.d.ts b/src/typings/api/system.api.d.ts index 2a39c2cd..148c4ff1 100644 --- a/src/typings/api/system.api.d.ts +++ b/src/typings/api/system.api.d.ts @@ -612,5 +612,32 @@ declare namespace Api { | 'wechat_mp' | 'wechat_enterprise' | 'gitlab'; + + /** oss */ + type Oss = Common.CommonRecord<{ + /** 对象存储主键 */ + ossId: CommonType.IdType; + /** 租户编号 */ + tenantId: CommonType.IdType; + /** 文件名 */ + fileName: string; + /** 原名 */ + originalName: string; + /** 后缀名 */ + fileSuffix: string; + /** 文件预览 */ + url: string; + /** 服务商 */ + service: string; + /** 创建者 */ + createByName: string; + }>; + + /** oss search params */ + type OssSearchParams = CommonType.RecordNullable< + Pick & Api.Common.CommonSearchParams + >; + /** oss list */ + type OssList = Api.Common.PaginatingQueryRecord; } } diff --git a/src/typings/elegant-router.d.ts b/src/typings/elegant-router.d.ts index af5788cd..3ebcb8cc 100644 --- a/src/typings/elegant-router.d.ts +++ b/src/typings/elegant-router.d.ts @@ -36,6 +36,7 @@ declare module "@elegant-router/types" { "system_dict_type": "/system/dict/type"; "system_menu": "/system/menu"; "system_notice": "/system/notice"; + "system_oss": "/system/oss"; "system_post": "/system/post"; "system_tenant": "/system/tenant"; "system_user": "/system/user"; @@ -115,6 +116,7 @@ declare module "@elegant-router/types" { | "system_dict_type" | "system_menu" | "system_notice" + | "system_oss" | "system_post" | "system_tenant" | "system_user" diff --git a/src/utils/common.ts b/src/utils/common.ts index d7e9133c..231eb366 100644 --- a/src/utils/common.ts +++ b/src/utils/common.ts @@ -85,6 +85,12 @@ export function isNull(value: any) { return value === undefined || value === null || value === '' || value === 'undefined' || value === 'null'; } +/** 判断是否为图片类型 */ +export function isImage(suffix: string) { + const imgSuffixList = ['.jpg', '.jpeg', '.png', '.gif', '.webp']; + return imgSuffixList.includes(suffix.toLowerCase()); +} + /** * 构造树型结构数据 * diff --git a/src/views/system/oss/index.vue b/src/views/system/oss/index.vue new file mode 100644 index 00000000..e95830ec --- /dev/null +++ b/src/views/system/oss/index.vue @@ -0,0 +1,227 @@ + + + + + diff --git a/src/views/system/oss/modules/oss-search.vue b/src/views/system/oss/modules/oss-search.vue new file mode 100644 index 00000000..56be83e6 --- /dev/null +++ b/src/views/system/oss/modules/oss-search.vue @@ -0,0 +1,72 @@ + + + + +