diff --git a/src/common/model/global/Moon.ts b/src/common/model/global/Moon.ts index f19081f..42000a3 100644 --- a/src/common/model/global/Moon.ts +++ b/src/common/model/global/Moon.ts @@ -5,6 +5,7 @@ */ import User from '../user/User'; import Preference from '../preference/Preference'; +import Matter from '../matter/Matter'; export default class Moon { //全局具有唯一的用户,即当前登录的用户. @@ -13,6 +14,9 @@ export default class Moon { //全局唯一的偏好设置 preference: Preference = new Preference(); + //全局的上传文件对象,key是space的uuid + uploadMattersMap: Record = {}; + //全局的一个store对象 private static singleton: Moon | null = null; diff --git a/src/pages/matter/List.tsx b/src/pages/matter/List.tsx index 82a073e..f2afc4e 100644 --- a/src/pages/matter/List.tsx +++ b/src/pages/matter/List.tsx @@ -93,8 +93,9 @@ export default class List extends TankComponent { //上传错误日志 uploadErrorLogs: [string, string, string][] = []; - //准备上传的一系列文件 - static uploadMatters: Matter[] = []; + // 全局的上传对象 + uploadMattersMap: Record = + Moon.getSingleton().uploadMattersMap; //持有全局唯一的实例。 static instance: List | null = null; @@ -231,14 +232,14 @@ export default class List extends TankComponent { MatterDeleteModal.open( !!this.props.spaceUuid, () => { - Matter.httpSoftDeleteBatch(uuids, this.getSpaceUuid()!, () => { + Matter.httpSoftDeleteBatch(uuids, this.getSpaceUuid(), () => { MessageBoxUtil.success(Lang.t('operationSuccess')); Capacity.instance?.refresh(); this.refresh(); }); }, () => { - Matter.httpDeleteBatch(uuids, this.getSpaceUuid()!, () => { + Matter.httpDeleteBatch(uuids, this.getSpaceUuid(), () => { MessageBoxUtil.success(Lang.t('operationSuccess')); Capacity.instance?.refresh(); this.refresh(); @@ -249,13 +250,13 @@ export default class List extends TankComponent { downloadZip() { const uuids = this.selectedMatters.map((i) => i.uuid).toString(); - Matter.downloadZip(uuids, this.getSpaceUuid()!); + Matter.downloadZip(uuids, this.getSpaceUuid()); } toggleMoveBatch() { - MoveBatchModal.open(this.getSpaceUuid()!, (targetUuid) => { + MoveBatchModal.open(this.getSpaceUuid(), (targetUuid) => { const uuids = this.selectedMatters.map((i) => i.uuid).join(','); - Matter.httpMove(this.getSpaceUuid()!, uuids, targetUuid, () => { + Matter.httpMove(this.getSpaceUuid(), uuids, targetUuid, () => { MessageBoxUtil.success(Lang.t('operationSuccess')); this.refresh(); }); @@ -388,10 +389,10 @@ export default class List extends TankComponent { m.file = file; m.httpUpload( () => { - const index = List.uploadMatters.findIndex( + const index = this.uploadMattersMap[this.getSpaceUuid()].findIndex( (matter) => matter === m ); - List.uploadMatters.splice(index, 1); + this.uploadMattersMap[this.getSpaceUuid()].splice(index, 1); List.instance?.refresh(); Capacity.instance?.refresh(); }, @@ -401,7 +402,11 @@ export default class List extends TankComponent { } ); - List.uploadMatters.push(m); + if (this.uploadMattersMap[this.getSpaceUuid()]) { + this.uploadMattersMap[this.getSpaceUuid()].push(m); + } else { + this.uploadMattersMap[this.getSpaceUuid()] = [m]; + } }; } } @@ -433,7 +438,7 @@ export default class List extends TankComponent { getSpaceUuid() { if (this.props.spaceUuid) return this.props.spaceUuid; - return this.user.spaceUuid; + return this.user.spaceUuid!; } createDirectory() { @@ -671,7 +676,9 @@ export default class List extends TankComponent { {Children.toArray( - List.uploadMatters.map((m) => ) + this.uploadMattersMap[this.getSpaceUuid()]?.map((m) => ( + + )) )} {pager.data.length ? (