unknown 4 роки тому
джерело
коміт
1a35a0eaea
4 змінених файлів з 50 додано та 59 видалено
  1. +10
    -6
      src/views/main_web/workspace/components/file-item.vue
  2. +3
    -8
      src/views/main_web/workspace/helper.js
  3. +9
    -14
      src/views/main_web/workspace/service.js
  4. +28
    -31
      src/views/main_web/workspace/workspace.new.vue

+ 10
- 6
src/views/main_web/workspace/components/file-item.vue Переглянути файл

@@ -13,7 +13,7 @@
v-if="!oneOf(file.extension, imgExtensionList)"
class="defultImage-mid"
:class="`${file.extension}-mid ${
isClient && !localFileIsLatest ? 'toumin' : ''
isClient && ((isInWorkFolder && !localFileIsLatest) || (!isInWorkFolder && !fileInLocal)) ? 'toumin' : ''
}`"
@contextmenu.prevent.stop="rightShowMenu($event, file, 1)"
/>
@@ -22,7 +22,7 @@
v-else
class="defultImage-mid img_bg-mid"
:class="
isClient && !localFileIsLatest ? 'toumin' : ''
isClient && ((isInWorkFolder && !localFileIsLatest) || (!isInWorkFolder && !fileInLocal)) ? 'toumin' : ''
"
@contextmenu.prevent.stop="rightShowMenu($event, file, 1)"
>
@@ -46,7 +46,7 @@
@contextmenu.prevent.stop="rightShowMenu($event, file, 1)"
class="downloadIcon"
@click="clientDownLoad(file, 1)"
v-if="(!isInWorkFolder || !otherUserIsWorking) && !localFileIsLatest"
v-if="((isInWorkFolder && !localFileIsLatest) || (!isInWorkFolder && !fileInLocal)) && !fileIsLoading"
>
<div class="readytodownload-icon"><img src="/static/img/download.svg" alt class="imgjuzhong" /></div>
</div>
@@ -67,7 +67,7 @@
<div
@contextmenu.prevent.stop="rightShowMenu($event, file, 1)"
class="downloadIcon"
v-if="isClient && file.downloadStatus === DownloadStatus.UPLOADING"
v-if="file.downloadStatus === DownloadStatus.UPLOADING"
>
<div class="progress-circle">
<img class="bg-pic" src="/static/img/upload.png" alt="" :style="{ width: '24px' }" >
@@ -83,7 +83,7 @@
</div>

<!-- 左上角图标 -->
<template v-if="fileInLocal">
<template v-if="fileInLocal && !fileIsLoading">
<!-- 灰色感叹号 -->
<div
class="yijianxietong modified-icon-parent"
@@ -98,7 +98,7 @@
<!-- 蓝色更新图标 协同文件列表中当本地文件和云端文件不同时 出现 -->
<div
v-if="
!isInWorkFolder && file.downloadStatus === DownloadStatus.DIFF
!isInWorkFolder && !localFileIsLatest
"
class="yijianxietong isonselect_update"
>
@@ -228,6 +228,10 @@ export default {
const { localIpfsCid, ipfsCid } = this.file;
return localIpfsCid && localIpfsCid === ipfsCid;
},
fileIsLoading() {
const file = this.file;
return file.downloadStatus === DownloadStatus.UPLOADING || file.downloadStatus === DownloadStatus.DOWNLOADING;
},
// 本地是否有文件
fileInLocal() {
return !!this.file.localIpfsCid;


+ 3
- 8
src/views/main_web/workspace/helper.js Переглянути файл

@@ -52,8 +52,8 @@ export const FileStatus = {
*/
export function injectionFileLocalStatus(fileList, localFileHash, fileLoadingHash, folderMap) {
return fileList.map(file => {
const { archName, extension, folderId } = file;
const folderName = (folderMap[folderId] || {}).folderName;
const { archName, extension, folderId, nodeName } = file;
const folderName = nodeName || (folderMap[folderId] || {}).folderName;
const fileKey = `${folderName}\\${archName}${extension ? `.${extension}`:''}`;

// 注入loadProgress 和 loadStatus属性
@@ -63,12 +63,7 @@ export function injectionFileLocalStatus(fileList, localFileHash, fileLoadingHas
file.localIpfsCid = localFileHash[fileKey];
if(file.localIpfsCid === file.ipfsCid) {
file.downloadStatus = FileLoadStatus.DOWNLOADED;
} else if(!fileLoadingHash[file.id]) { // 不存在加载进度时
if(!file.localIpfsCid) {
file.downloadStatus = FileLoadStatus.UNDOWNLOAD;
} else {
file.downloadStatus = FileLoadStatus.DIFF;
}
delete fileLoadingHash[file.id];
}
return file;
});

+ 9
- 14
src/views/main_web/workspace/service.js Переглянути файл

@@ -24,22 +24,17 @@ export async function fetchFolderFileList(folderId, userId, commonFolderId) {
wrapErrorHint(res);
if (res.Code !== 0) return null;
const data = res.Data || {};
const injectFileBasicValue = upperCaseFile => {
const file = firstCharToLowerCase(upperCaseFile);
file.downloadStatus = DownloadStatus.UNDOWNLOAD;
return file;
}
const outputObj = {
folder: (data.folder || []).map(firstCharToLowerCase),
myFile: (data.myFile || []).map(f => {
const obj = firstCharToLowerCase(f);
obj.isShowFile = true;
obj.downloadStatus = DownloadStatus.UNDOWNLOAD;
return obj;
}),
workFile: (data.workFile || []).map(f => {
const obj = firstCharToLowerCase(f);
obj.isShowFile = true;
obj.downloadStatus = DownloadStatus.UNDOWNLOAD;
return obj;
}),
coordinationFiles: (data.coordinationFiles || []).map(firstCharToLowerCase),
public: (data.public || []).map(firstCharToLowerCase),
myFile: (data.myFile || []).map(injectFileBasicValue),
workFile: (data.workFile || []).map(injectFileBasicValue),
coordinationFiles: (data.coordinationFiles || []).map(injectFileBasicValue),
// public: (data.public || []).map(firstCharToLowerCase),
}
return outputObj;
}


+ 28
- 31
src/views/main_web/workspace/workspace.new.vue Переглянути файл

@@ -451,16 +451,20 @@ export default {
this.workFileList = injectionFileLocalStatus(this.workFileList, fileStatusHash, stateMap, folderMap);
this.cooperationFileList = injectionFileLocalStatus(this.cooperationFileList, fileStatusHash, stateMap, folderMap);
},
updateFileLoadState(file, progress){
updateFileLoadState(file, progress, type){
const stateMap = this.fileLocalStateMap;
const updateState = {
loadProgress: progress,
downloadStatus: DownloadStatus.DOWNLOADING,
downloadStatus: type === 'download' ? DownloadStatus.DOWNLOADING : DownloadStatus.UPLOADING,
};
stateMap[file.id] = updateState;
this.fileLocalStateMap = { ...stateMap, [file.id]: updateState };
this.refreshFileStatus();
},
removeFileLoadingState(fileId) {
delete this.fileLocalStateMap[fileId];
this.fileLocalStateMap = {...this.fileLocalStateMap};
this.refreshFileStatus();
},

/* 工作链API */
/**
* 工作链页面点击
@@ -586,6 +590,7 @@ export default {
this.fileLocalStateMap,
this.folderMap,
);
this.resolveUploadFileList(this.cooperationFileList);
},
/**
* 点击确定 保存文件夹组
@@ -706,9 +711,10 @@ export default {
clientDownLoad: function (file, type) {
if(!this.isClient) return;
console.log('下载的文件对象', file);
const { ipfsCid, archName: fileName, extension, folderId } = file;
const { ipfsCid, archName: fileName, extension, folderId, nodeName } = file;
const folderMap = this.folderMap;
const { folderName, levelId } = folderMap[folderId] || {};
// const { levelId } = folderMap[folderId] || {};
const nodeFolderName = nodeName || this.currentNodeFolder.folderName;
const extensionedFileName = `${fileName}${extension ? `.${extension}`:''}`;
const copyFile = { ...file };
const errorHandler = () => {
@@ -717,19 +723,19 @@ export default {
delete this.fileLocalStateMap[file.id];
this.refreshFileStatus();
}
this.updateFileLoadState(file, 0);
system.downloadFile(ipfsCid, sessionStorage.projName, extensionedFileName, folderName, (resMessage, socketIns) => {
this.updateFileLoadState(file, 0, 'download');
system.downloadFile(ipfsCid, sessionStorage.projName, extensionedFileName, nodeFolderName, (resMessage, socketIns) => {
console.log('receive download file message:', resMessage, socketIns);
// {"size":"11","currentSize":"11","unit":"B","process":100,"hash":""}
try {
const { process } = JSON.parse(resMessage.data);
this.updateFileLoadState(file, process);
if(resMessage.data === '-1') { throw 'download failed'; }
this.updateFileLoadState(file, process, 'download');
if(process !== 100) return;
socketIns.close();
// file.downloadStatus = 2;
// file.isDownload = true;
// 注入到文件下载检测表中
const key = `${folderName}\\${extensionedFileName}`;
const key = `${nodeFolderName}\\${extensionedFileName}`;
this.fileDownloadStatusHash[key] = ipfsCid;
this.refreshFileStatus();
notify.success(`文件:${fileName} 下载完成`);
@@ -737,6 +743,8 @@ export default {
} catch (e) {
console.error('socket-download-file parse data have error:', e);
errorHandler();
} finally {
socketIns.close();
}
}, errorHandler);
},
@@ -777,7 +785,7 @@ export default {
* 更新文件
*/
async updateFileWorkStatus(file, nextWorkStatus, message) {
if(!this.isClient || nextWorkStatus === FileWorkStatus.WORKING && file.workStatus === FileWorkStatus.NOT_WORKING) {
if(!this.isClient || (nextWorkStatus === FileWorkStatus.WORKING && file.workStatus === FileWorkStatus.NOT_WORKING)) {
const resFlag = await services.changeFileWorkStatus(file.id, nextWorkStatus);
if(resFlag.Code !== 0) return;
notify.success(message);
@@ -788,16 +796,11 @@ export default {
// todo 获取文件最新的hash并更新文件
const { folderName, levelId, id: folderId } = this.currentNodeFolder;
const { archName, extension, id: fileId } = file;
const stateMap = this.fileLocalStateMap;
const updateState = {
loadProgress: 0,
downloadStatus: DownloadStatus.UPLOADING,
isDownload: true,
};
stateMap[fileId] = updateState;
this.refreshFileStatus();
this.updateFileLoadState(file, 0, 'upload');
// const fileList = this.currentPageType === 0 ? this.folderFileList.listMyFiles : this.folderFileList.listOtherFiles;
const fileKey = `${folderName}\\${archName}${extension ? `.${extension}`:''}`;
this.fileDownloadStatusHash[fileId] = `${file.localIpfsCid}--upload`;
this.refreshFileStatus();
system.updateFile(
file, this.localWorkspacePrefix,
this.projectName, folderName,
@@ -808,17 +811,11 @@ export default {
const {IpfsCid} = fileNewState;
// 注入到文件下载检测表中
this.fileDownloadStatusHash[fileKey] = IpfsCid;
this.refreshFileStatus();
this.removeFileLoadingState(fileId);
},
(progressData) => {
const { process, hash } = progressData;
const updateState = {
loadProgress: process,
downloadStatus: process === 100 ? DownloadStatus.DOWNLOADED : DownloadStatus.UPLOADING,
isDownload: true,
};
stateMap[fileId] = updateState;
this.refreshFileStatus();
this.updateFileLoadState(file, process, 'upload');
},
);
},
@@ -832,14 +829,14 @@ export default {
const folderName = nodeName || this.currentFolder.folderName;
const localWorkspacePrefix = this.localWorkspacePrefix;
const filePath = `${localWorkspacePrefix}\\${folderName}\\${archName}${extension ? `.${extension}` : ''}`;
if(file.workStatus === 2 && sessionStorage.userId !== file.modifyUserId) {
const isCooperationFile = !!nodeName;
if(!isCooperationFile && (file.workStatus === 2 && sessionStorage.userId !== file.modifyUserId)) {
notify.warning('文件正在工作编辑中,请耐心等待');
return;
}
system.openFile(filePath);
// 若文件在协作文件中,则不更改状态
if(nodeName) { return; }
if(isCooperationFile) { return; }
// 将文件状态设置为编辑中
const flagRes = await services.changeFileWorkStatus(fileId, 2);
if(flagRes.Code !== 0) return;


Завантаження…
Відмінити
Зберегти