From 14bf34fbc6e665a59348dc8741315a56bbd0d84d Mon Sep 17 00:00:00 2001 From: Simba Date: Wed, 1 Jul 2020 17:38:44 +0800 Subject: [PATCH] use template string instead of common string --- src/common/model/matter/Matter.ts | 124 +++++++----------------------- src/common/model/share/Share.ts | 14 +--- src/pages/matter/List.tsx | 2 +- 3 files changed, 33 insertions(+), 107 deletions(-) diff --git a/src/common/model/matter/Matter.ts b/src/common/model/matter/Matter.ts index e080f8d..443420c 100644 --- a/src/common/model/matter/Matter.ts +++ b/src/common/model/matter/Matter.ts @@ -1,4 +1,4 @@ -import {message} from "antd"; +import { message } from "antd"; import BaseEntity from "../base/BaseEntity"; import Filter from "../base/filter/Filter"; import HttpUtil from "../../util/HttpUtil"; @@ -60,6 +60,13 @@ export default class Matter extends BaseEntity { static MATTER_ROOT = "root"; + //下载zip包 + static downloadZip(uuidsString: string) { + window.open( + EnvUtil.currentHost() + Matter.URL_MATTER_ZIP + "?uuids=" + uuidsString + ); + } + constructor(reactComponent?: React.Component) { super(reactComponent); } @@ -161,13 +168,6 @@ export default class Matter extends BaseEntity { window.open(downloadUrl); } - //下载zip包 - downloadZip(uuidsString: string) { - window.open( - EnvUtil.currentHost() + Matter.URL_MATTER_ZIP + "?uuids=" + uuidsString - ); - } - //预览文件 在分享的预览中才主动传入previewUrl. preview(previewUrl?: string | null) { let that = this; @@ -181,46 +181,10 @@ export default class Matter extends BaseEntity { } if (that.isImage()) { - - ImagePreviewer.showSinglePhoto(previewUrl) - + ImagePreviewer.showSinglePhoto(previewUrl); } else { - PreviewerHelper.preview(this) + PreviewerHelper.preview(this); } - - // if (that.isImage()) { - // - // ImagePreviewer.showSinglePhoto(previewUrl) - // - // } else if (that.isPdf() || that.isText() || that.isAudio() || that.isVideo()) { - // - // BrowserPreviewer.show(that.name, previewUrl, that.size) - // - // } else if (that.isDoc() || that.isPpt() || that.isXls()) { - // - // - // MessageBoxUtil.warning("Office的预览还没做好") - // //如果是分享中的预览,直接就可以公有访问。 - // if (shareMode) { - // Vue.$previewer.previewOffice(that.name, previewUrl, that.size) - // } else { - // - // //如果是共有文件 office文件的预览请求一次性链接。 - // if (this.privacy) { - // - // let downloadToken = new DownloadToken() - // downloadToken.httpFetchDownloadToken(that.uuid, function () { - // Vue.$previewer.previewOffice(that.name, that.getPreviewUrl(downloadToken.uuid), that.size) - // }) - // } else { - // Vue.$previewer.previewOffice(that.name, previewUrl, that.size) - // } - // } - - - // } else { - // window.open(this.getPreviewUrl()) - // } } httpCreateDirectory( @@ -229,7 +193,7 @@ export default class Matter extends BaseEntity { finallyCallback?: any ) { let that = this; - let form = {userUuid: that.userUuid, name: that.name, puuid: that.puuid}; + let form = { userUuid: that.userUuid, name: that.name, puuid: that.puuid }; return this.httpPost( Matter.URL_MATTER_CREATE_DIRECTORY, @@ -246,7 +210,7 @@ export default class Matter extends BaseEntity { httpDelete(successCallback?: any, errorCallback?: any) { this.httpPost( Matter.URL_MATTER_DELETE, - {uuid: this.uuid}, + { uuid: this.uuid }, function (response: any) { typeof successCallback === "function" && successCallback(response); }, @@ -257,7 +221,7 @@ export default class Matter extends BaseEntity { httpDeleteBatch(uuids: string, successCallback?: any, errorCallback?: any) { this.httpPost( Matter.URL_MATTER_DELETE_BATCH, - {uuids: uuids}, + { uuids: uuids }, function (response: any) { typeof successCallback === "function" && successCallback(response); }, @@ -274,7 +238,7 @@ export default class Matter extends BaseEntity { let that = this; this.httpPost( Matter.URL_MATTER_RENAME, - {uuid: this.uuid, name: name}, + { uuid: this.uuid, name: name }, function (response: any) { that.assign(response.data.data); typeof successCallback === "function" && successCallback(response); @@ -292,7 +256,7 @@ export default class Matter extends BaseEntity { let that = this; this.httpPost( Matter.URL_CHANGE_PRIVACY, - {uuid: this.uuid, privacy: privacy}, + { uuid: this.uuid, privacy: privacy }, function (response: any) { that.privacy = privacy; if (typeof successCallback === "function") { @@ -312,7 +276,7 @@ export default class Matter extends BaseEntity { successCallback?: any, errorCallback?: any ) { - let form: any = {srcUuids: srcUuids}; + let form: any = { srcUuids: srcUuids }; if (destUuid) { form.destUuid = destUuid; } else { @@ -445,7 +409,7 @@ export default class Matter extends BaseEntity { //验证是否满足过滤器 if (!this.validateFileType()) { - MessageBoxUtil.error('文件类型不满足,请重试'); + MessageBoxUtil.error("文件类型不满足,请重试"); return; } @@ -517,25 +481,15 @@ export default class Matter extends BaseEntity { } getPreviewUrl(downloadTokenUuid?: string): string { - return ( - EnvUtil.currentHost() + - "/api/alien/preview/" + - this.uuid + - "/" + - this.name + - (downloadTokenUuid ? "?downloadTokenUuid=" + downloadTokenUuid : "") - ); + return `${EnvUtil.currentHost()}/api/alien/preview/${this.uuid}/${ + this.name + }${downloadTokenUuid ? "?downloadTokenUuid=" + downloadTokenUuid : ""}`; } getDownloadUrl(downloadTokenUuid?: string): string { - return ( - EnvUtil.currentHost() + - "/api/alien/download/" + - this.uuid + - "/" + - this.name + - (downloadTokenUuid ? "?downloadTokenUuid=" + downloadTokenUuid : "") - ); + return `${EnvUtil.currentHost()}/api/alien/download/${this.uuid}/${ + this.name + }${downloadTokenUuid ? "?downloadTokenUuid=" + downloadTokenUuid : ""}`; } getShareDownloadUrl( @@ -543,19 +497,9 @@ export default class Matter extends BaseEntity { shareCode: string, shareRootUuid: string ): string { - return ( - EnvUtil.currentHost() + - "/api/alien/download/" + - this.uuid + - "/" + - this.name + - "?shareUuid=" + - shareUuid + - "&shareCode=" + - shareCode + - "&shareRootUuid=" + - shareRootUuid - ); + return `${EnvUtil.currentHost()}/api/alien/download/${this.uuid}/${ + this.name + }?shareUuid=${shareUuid}&shareCode=${shareCode}&shareRootUuid=${shareRootUuid}`; } getSharePreviewUrl( @@ -563,18 +507,8 @@ export default class Matter extends BaseEntity { shareCode: string, shareRootUuid: String ): string { - return ( - EnvUtil.currentHost() + - "/api/alien/preview/" + - this.uuid + - "/" + - this.name + - "?shareUuid=" + - shareUuid + - "&shareCode=" + - shareCode + - "&shareRootUuid=" + - shareRootUuid - ); + return `${EnvUtil.currentHost()}/api/alien/preview/${this.uuid}/${ + this.name + }?shareUuid=${shareUuid}&shareCode=${shareCode}&shareRootUuid=${shareRootUuid}`; } } diff --git a/src/common/model/share/Share.ts b/src/common/model/share/Share.ts index f4c33ec..ce88e70 100644 --- a/src/common/model/share/Share.ts +++ b/src/common/model/share/Share.ts @@ -6,7 +6,6 @@ import { ShareType } from "./ShareType"; import { ShareExpireOption, ShareExpireOptionMap } from "./ShareExpireOption"; import DateUtil from "../../util/DateUtil"; import SafeUtil from "../../util/SafeUtil"; -import {WebResultCode} from "../base/WebResultCode"; import MessageBoxUtil from "../../util/MessageBoxUtil"; export default class Share extends BaseEntity { @@ -98,16 +97,9 @@ export default class Share extends BaseEntity { //下载zip包 downloadZip(puuid?: string) { window.open( - EnvUtil.currentHost() + - Share.URL_ZIP + - "?shareUuid=" + - this.uuid + - "&code=" + - this.code + - "&puuid=" + - puuid + - "&rootUuid=" + - this.rootUuid + `${EnvUtil.currentHost()}${Share.URL_ZIP}?shareUuid=${this.uuid}&code=${ + this.code + }&puuid=${puuid}&rootUuid=${this.rootUuid}` ); } diff --git a/src/pages/matter/List.tsx b/src/pages/matter/List.tsx index 75e829a..e957107 100644 --- a/src/pages/matter/List.tsx +++ b/src/pages/matter/List.tsx @@ -232,7 +232,7 @@ export default class List extends TankComponent { downloadZip = () => { const uuids = this.selectedMatters.map((i) => i.uuid).toString(); - this.matter.downloadZip(uuids); + Matter.downloadZip(uuids); }; toggleMoveBatch = () => {