From b6eca7095e793e221e9365ab6be74d0e733c058d Mon Sep 17 00:00:00 2001 From: zhengzhou Date: Fri, 26 Mar 2021 15:09:47 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B7=A5=E4=BD=9C=E7=A9=BA=E9=97=B4=20?= =?UTF-8?q?=E4=B8=9A=E5=8A=A1=E9=80=BB=E8=BE=91=E4=BF=AE=E6=94=B9=EF=BC=9A?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E7=8A=B6=E6=80=81=E5=9B=BE=E6=A0=87=E5=90=AB?= =?UTF-8?q?=E4=B9=89=E6=94=B9=E4=B8=BA=E5=8D=8F=E5=90=8C=E7=8A=B6=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/file-explorer/index.vue | 12 ++++++ .../workspace/components/file-item.vue | 39 ++++++++++++------- 2 files changed, 37 insertions(+), 14 deletions(-) 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 6d22d0bd..f162aaaf 100644 --- a/src/views/main_web/workspace/components/file-explorer/index.vue +++ b/src/views/main_web/workspace/components/file-explorer/index.vue @@ -17,6 +17,7 @@ :nodeFolder="currentNodeFolder" :currentFolder="currentFolder" @commitFile="showCommitWindow" + @change-file-status="toggleFileShareStatus" @dblclickFile="fileClick(file)" @filePreview="filePreview" @openFileWith="openFileWith(file)" @@ -125,6 +126,7 @@ :nodeFolder="currentNodeFolder" :currentFolder="currentFolder" @commitFile="showCommitWindow" + @change-file-status="toggleFileShareStatus" @dblclickFile="fileClick(file)" @filePreview="filePreview" @openFileWith="openFileWith(file)" @@ -446,6 +448,7 @@ import AddFileButton from '../add-file-button'; import * as services from '../../service'; import { FileWorkStatus, getFileStoreKey, injectionFileLocalStatus, LoadingEnum, VirtualFolder, analyzeRelativePath, imgExtensionList, RecExtensionList, VideoExtensionList, office, filePreviewList } from '../../helper'; import { propertyOf, uniqBy, throttle, flatten, debounce, cloneDeep } from 'lodash'; +import { wrapErrorHint } from '@/utils/request'; const $ = window.jQuery; const Velocity = window.Velocity; @@ -1822,6 +1825,15 @@ export default { this.commitJudgeFile = file; this.fileImgClass = fileImgClass; }, + async toggleFileShareStatus(file) { + const nextStatus = file.status == 2 ? 1 : 2; + const hintKeyword = nextStatus === 2 ? '开启': '关闭'; + const res = await this.$fetchApi('file/changeFileStatus', { fileId: file.id, status: nextStatus }); + wrapErrorHint(res); + if(res.Code) { return } + notify.success(`文件已${hintKeyword}协同`); + file.status = nextStatus; + }, /** * 提交本地文件 fileImgClass: 获得文件图标的类型 string * remarkNote: 要提交的备注信息 string diff --git a/src/views/main_web/workspace/components/file-item.vue b/src/views/main_web/workspace/components/file-item.vue index 0bda0e08..c1e1370e 100644 --- a/src/views/main_web/workspace/components/file-item.vue +++ b/src/views/main_web/workspace/components/file-item.vue @@ -83,12 +83,12 @@
@@ -104,13 +104,14 @@
+ title="点击关闭文件协同" + @click.stop="toggleFileShareStatus" + />
@@ -352,12 +353,19 @@ export default { return localIpfsCid && status == "1"; }, //文件是否没有被修改也不需要更新 -》 显示绿色图标 - localFileIsLatest() { - const { ipfsCid } = this.file; - const localIpfsCid = this.localIpfsCid; - // 这里的localIpfsCid是包含标记0 1 的 0:本地未修改 1本地修改 - const [myLocalIpfsCid, status] = localIpfsCid.split(";"); - return localIpfsCid && myLocalIpfsCid === ipfsCid && status == "0"; + // localFileIsLatest() { + // const { ipfsCid } = this.file; + // const localIpfsCid = this.localIpfsCid; + // // 这里的localIpfsCid是包含标记0 1 的 0:本地未修改 1本地修改 + // const [myLocalIpfsCid, status] = localIpfsCid.split(";"); + // return localIpfsCid && myLocalIpfsCid === ipfsCid && status == "0"; + // }, + /** + * 文件已启用协同 + * status --- 1: 未协同 2: 已协同 + */ + fileEnableShare() { + return this.file.status == '2'; }, fileIsDifferent() { const { ipfsCid } = this.file; @@ -381,8 +389,11 @@ export default { // } }, methods: { - commitFile() { - this.$emit('commitFile', this.file, this.fileImgClass); + // commitFile() { + // this.$emit('commitFile', this.file, this.fileImgClass); + // }, + toggleFileShareStatus() { + this.$emit('change-file-status', this.file); }, oneOf, // 打开方式