From 9c6c61e3b655fbec23f5611390555d6f676efe9e Mon Sep 17 00:00:00 2001 From: zhengzhou Date: Tue, 30 Mar 2021 16:46:11 +0800 Subject: [PATCH] =?UTF-8?q?workspace=20=E4=BF=AE=E6=AD=A3=E4=B9=8B?= =?UTF-8?q?=E5=89=8D=E7=82=B9=E5=87=BB=E6=96=87=E4=BB=B6=E7=89=88=E6=9C=AC?= =?UTF-8?q?=E5=8F=B7=E7=9A=84=E6=93=8D=E4=BD=9C;=20=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E5=8F=B3=E9=94=AE=E6=B7=BB=E5=8A=A0=E5=88=9B=E5=BB=BA=E5=8E=86?= =?UTF-8?q?=E5=8F=B2=E7=89=88=E6=9C=AC;setShareFile=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=8F=82=E6=95=B0;init=20websocket=20?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0accountId=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/services/system.js | 4 +- .../components/file-explorer/index.vue | 72 ++++++------------- .../workspace/components/file-item.vue | 13 ++-- src/views/main_web/workspace/service.js | 4 +- .../main_web/workspace/workspace.new.vue | 2 +- 5 files changed, 35 insertions(+), 60 deletions(-) diff --git a/src/services/system.js b/src/services/system.js index bfb4540e..1105d20e 100644 --- a/src/services/system.js +++ b/src/services/system.js @@ -174,8 +174,8 @@ const system = { /** * 通知系统进入当前的工作空间 */ - entryProject: safeCall(async (projName, accountName, fileChangeHandler, initHandler, socketInsHandler, errorHandler = identity) => { - const response = await requestBySocket(io('init'), [accountName, projName].join('|')); + entryProject: safeCall(async (projName, accountId, accountName, fileChangeHandler, initHandler, socketInsHandler, errorHandler = identity) => { + const response = await requestBySocket(io('init'), [accountName, accountId, projName].join('|')); initHandler(response.data); const watchSocket = io('subscriptionFileChange'); watchSocket.on('open', () => { diff --git a/src/views/main_web/workspace/components/file-explorer/index.vue b/src/views/main_web/workspace/components/file-explorer/index.vue index f162aaaf..d6e20889 100644 --- a/src/views/main_web/workspace/components/file-explorer/index.vue +++ b/src/views/main_web/workspace/components/file-explorer/index.vue @@ -13,7 +13,6 @@ :key="file.id" :file="file" :clientDownLoad="clientDownLoad" - :showFileMilestone="showFileMilestone" :nodeFolder="currentNodeFolder" :currentFolder="currentFolder" @commitFile="showCommitWindow" @@ -42,7 +41,6 @@ :file="file" :tempRightFileId="tempRightFileId" :clientDownLoad="clientDownLoad" - :showFileMilestone="showFileMilestone" :nodeFolder="currentNodeFolder" :currentFolder="currentFolder" @dblclickFile="fileClick(file)" @@ -108,7 +106,6 @@ :key="file.id" :file="file" :clientDownLoad="clientDownLoad" - :showFileMilestone="showFileMilestone" :nodeFolder="currentNodeFolder" :currentFolder="currentFolder" :localFileHashMap="localFileHashMap" @@ -122,7 +119,6 @@ :key="file.id" :file="file" :clientDownLoad="clientDownLoad" - :showFileMilestone="showFileMilestone" :nodeFolder="currentNodeFolder" :currentFolder="currentFolder" @commitFile="showCommitWindow" @@ -230,7 +226,6 @@ :file="file" :tempRightFileId="tempRightFileId" :clientDownLoad="clientDownLoad" - :showFileMilestone="showFileMilestone" :nodeFolder="currentNodeFolder" :currentFolder="currentFolder" @dblclickFile="fileClick(file)" @@ -633,7 +628,7 @@ export default { this.fetchFolderFiles(); system.entryProject( - sessionStorage.projName, sessionStorage.accountName, + sessionStorage.projName, sessionStorage.accountId, sessionStorage.accountName, this.onSocketFileChangeDetected.bind(this), (localWorkspacePrefix) => { this.localWorkspacePrefix = localWorkspacePrefix;}, socketIns => { this.socketIns = socketIns; }, @@ -1792,27 +1787,28 @@ export default { const isConflict = (fileLocalIpfsCid && status == "1" && myLocalIpfsCid !== ipfsCid); console.log(isConflict); - if(isConflict) { - // const text = `${file.modifyName}编辑过您的文件,是继续我上次编辑还是打开${file.modifyName}的编辑?`; - const text = `${file.modifyName}更新了文件,请选择协同版本。`; - this.$confirm(text, "", { - confirmButtonText: "继续提交我的版本", - cancelButtonText: '保留对方版本', - showClose: true, - type: "warning", - customClass: 'conflit-message-box', - }).then(() => { - //点击继续我的编辑 -> 继续完成本次版本的提交 相当于忽略别人编辑过的版本 - this.commitFile(false); - }) - .catch((err)=> { - //点击了打开XXX的编辑 -> 完成本次版本提交 - //但是本次版本提交updateFile(服务端)传递的 historyCurrentIpfsCid 不是websocket接口返回的 而是文件的ipfscid(别人编辑的版本) - this.commitFile(true); - }); - } else { - this.commitFile(false); - } + // if(isConflict) { + // // const text = `${file.modifyName}编辑过您的文件,是继续我上次编辑还是打开${file.modifyName}的编辑?`; + // const text = `${file.modifyName}更新了文件,请选择协同版本。`; + // this.$confirm(text, "", { + // confirmButtonText: "继续提交我的版本", + // cancelButtonText: '保留对方版本', + // showClose: true, + // type: "warning", + // customClass: 'conflit-message-box', + // }).then(() => { + // //点击继续我的编辑 -> 继续完成本次版本的提交 相当于忽略别人编辑过的版本 + // this.commitFile(false); + // }) + // .catch((err)=> { + // //点击了打开XXX的编辑 -> 完成本次版本提交 + // //但是本次版本提交updateFile(服务端)传递的 historyCurrentIpfsCid 不是websocket接口返回的 而是文件的ipfscid(别人编辑的版本) + // this.commitFile(true); + // }); + // } else { + // this.commitFile(false); + // } + this.commitFile(isConflict); this.isShowCommitJudgeWindow = false; this.commitFileControlIpfsCid = ''; this.comitJudgeCom = null; @@ -1971,28 +1967,6 @@ export default { system.openFile(filePath); // this.fetchFolderFiles(); }, - /** - * 设置历史文件界面 - */ - showFileMilestone: function (file) { - // todo 待修正,思考是否可以放到file组件中去 - debugger; - if (file.status == 1 && file.modifyUserID != sessionStorage.userId) { - this.$notify({ - message: "其他人编辑中,不能设置历史文件", - type: "warning", - offset: 100, - duration: 5000, - }); - return; - } - this.currentMilestone=file; - this.dialogFileHistory = true; - //返回与该文件同名的所有文件并把自己过滤掉 - this.listMilestones=this.getMilstoneFile(file); - console.log(this.listMilestones) - this.currentArchID = file.archID; - }, /** * 右键菜单 */ diff --git a/src/views/main_web/workspace/components/file-item.vue b/src/views/main_web/workspace/components/file-item.vue index c1e1370e..25d8ee9a 100644 --- a/src/views/main_web/workspace/components/file-item.vue +++ b/src/views/main_web/workspace/components/file-item.vue @@ -144,6 +144,7 @@
  • 在线预览
  • 查看历史版本
  • +
  • 创建历史版本
  • @@ -184,7 +185,7 @@ 版本 {{ file.version }} @@ -243,7 +244,6 @@ export default { type: Object, default: () => ({}), }, - showFileMilestone: Function, localFileHashMap: { type: Object, default: () => ({}), @@ -389,9 +389,10 @@ export default { // } }, methods: { - // commitFile() { - // this.$emit('commitFile', this.file, this.fileImgClass); - // }, + commitFile() { + this.isFileRightMenuVisible = false; + this.$emit('commitFile', this.file, this.fileImgClass); + }, toggleFileShareStatus() { this.$emit('change-file-status', this.file); }, @@ -461,7 +462,7 @@ export default { this.isFileRightMenuVisible = false; }, openfileBtnClick() { - this.isFileRightMenuVisible = false; + this.isFileRightMenuVisible = false; this.$emit('openfileBtnClick', this.file); }, copyFileBtnClick() { diff --git a/src/views/main_web/workspace/service.js b/src/views/main_web/workspace/service.js index 8378187f..6d0a69f7 100644 --- a/src/views/main_web/workspace/service.js +++ b/src/views/main_web/workspace/service.js @@ -195,8 +195,8 @@ export async function queryProjArchiveHistory(archId) { /** * 设为协同版本 */ -export async function setShareFile(Id,IpfsCid,ModifyUserId) { - const res = await fetchApi('file/setShareFile', {Id,IpfsCid,ModifyUserId}); +export async function setShareFile(Id,IpfsCid,ModifyUserId, Version) { + const res = await fetchApi('file/setShareFile', {Id,IpfsCid,ModifyUserId, Version}); return res; } diff --git a/src/views/main_web/workspace/workspace.new.vue b/src/views/main_web/workspace/workspace.new.vue index 9023d6ea..68aeeb38 100644 --- a/src/views/main_web/workspace/workspace.new.vue +++ b/src/views/main_web/workspace/workspace.new.vue @@ -721,7 +721,7 @@ export default { this.getNestNode(); system.entryProject( - sessionStorage.projName, sessionStorage.accountName, + sessionStorage.projName, sessionStorage.accountId, sessionStorage.accountName, this.onSocketFileChangeDetected.bind(this), (localWorkspacePrefix) => { this.localWorkspacePrefix = localWorkspacePrefix;}, socketIns => { this.socketIns = socketIns; },