From 313e7c12fb7ee6e628242964689d513f5432c3ca Mon Sep 17 00:00:00 2001 From: jiangzhe <244140623@qq.com> Date: Fri, 31 May 2024 17:09:32 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=87=E4=BB=B6=E9=A2=84=E8=A7=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/system/oss/index.ts | 31 +++++++++ src/api/system/oss/types.ts | 1 + .../resourceMgt/catalogTextbookMgt/index.vue | 68 +++++++++++++++++-- 3 files changed, 94 insertions(+), 6 deletions(-) diff --git a/src/api/system/oss/index.ts b/src/api/system/oss/index.ts index 3b985f7..1abddae 100644 --- a/src/api/system/oss/index.ts +++ b/src/api/system/oss/index.ts @@ -11,6 +11,37 @@ export function listOss(query: OssQuery): AxiosPromise { }); } +export function preview(ossId: string | number): any { + return request({ + url: '/file/preview/' + ossId, + method: 'post', + responseType: 'blob' + }); +} + +export function previewTxt(ossId: string | number): any { + return request({ + url: '/file/preview/' + ossId, + method: 'post', + responseType: 'blob', + transformResponse: [ + async function (data) { + return await transformData(data) + } + ] + }); +} + +const transformData = (data: any) => { + return new Promise((resolve) => { + let reader = new FileReader() + reader.readAsText(data) + reader.onload = function () { + resolve(reader.result) + } + }) +} + // 查询OSS对象基于id串 export function listByIds(ossId: string | number): AxiosPromise { return request({ diff --git a/src/api/system/oss/types.ts b/src/api/system/oss/types.ts index bc0bc1f..c73dd60 100644 --- a/src/api/system/oss/types.ts +++ b/src/api/system/oss/types.ts @@ -9,6 +9,7 @@ export interface OssVO extends BaseEntity { } export interface OssQuery extends PageQuery { + ossId: string | number; fileName: string; originalName: string; fileSuffix: string; diff --git a/src/views/resourceMgt/catalogTextbookMgt/index.vue b/src/views/resourceMgt/catalogTextbookMgt/index.vue index edad25f..cd9c243 100644 --- a/src/views/resourceMgt/catalogTextbookMgt/index.vue +++ b/src/views/resourceMgt/catalogTextbookMgt/index.vue @@ -108,7 +108,22 @@ - + + + + + + +
{{ txt }} +
+ +
@@ -116,16 +131,27 @@