diff --git a/src/components/FancyTree/index.vue b/src/components/FancyTree/index.vue index 1c21946..233469b 100644 --- a/src/components/FancyTree/index.vue +++ b/src/components/FancyTree/index.vue @@ -26,7 +26,6 @@ - 搜索 @@ -135,7 +134,7 @@ let input = data.node.span.querySelector('.fancytree-title .fancytree-edit-input') let width = input.style.width.substring(0,input.style.width.length-2) input.style.width = parseInt(width)+50+'px' - if(input.value.length -1 > data.node.data.suffix.length){ + if(input.value && input.value.length -1 > data.node.data.suffix.length){ input.selectionStart = 0 input.selectionEnd = input.value.length - 1 - data.node.data.suffix.length } @@ -246,6 +245,7 @@ username: this.$store.state.user.name, path: data.path }).then(()=>{ + this.$emit('removeFile', data.path) let node = this.tree.getActiveNode() node.remove() this.$message.success("删除成功!") diff --git a/src/components/preview/SimTextPreview.vue b/src/components/preview/SimTextPreview.vue index 997ce7a..7c00472 100644 --- a/src/components/preview/SimTextPreview.vue +++ b/src/components/preview/SimTextPreview.vue @@ -76,6 +76,7 @@ @treeNodeClick="treeNodeClick" @onLoadTreePath="onLoadTreePath" @onRename="onRename" + @removeFile="removeFile" > @@ -85,7 +86,7 @@
- + {{item.title}}
{ @@ -479,6 +482,12 @@ onLoadTreePath(path){ this.filePathNav = path }, + removeFile(filepath) { + let findIndex = this.editableTabs.findIndex(editable => editable.name === filepath) + if(findIndex > -1){ + this.editableTabs.splice(findIndex, 1) + } + }, treeNodeClick(row) { if(row.isFolder){ return @@ -519,17 +528,19 @@ copyTitle:row.name, status: undefined, language: this.getEditorLanguage(row.suffix), - name:row.path, - content:res.data.contentText + name:row.path } if(row.isAddTab){ this.editableTabs.push(tab) + this.setEditMap(this.editableTabs.length -1, res.data.contentText) }else{ let thisTabIndex = this.editableTabs.findIndex(tab=> tab.status===undefined) if(thisTabIndex > -1){ this.editableTabs[thisTabIndex] = tab + this.setEditMap(thisTabIndex, res.data.contentText) }else{ this.editableTabs.push(tab) + this.setEditMap(this.editableTabs.length - 1, res.data.contentText) } } this.editableTabsValue = row.path @@ -538,8 +549,19 @@ }) }else{ this.editableTabsValue = row.path + this.clickTab() } }, + setEditMap(index, text) { + this.editableValueMap.set(index, text) + this.$nextTick(()=> { + let ref = 'monacoEditor' + index + this.$refs[ref][0]._setValue(text) + if (!this.$pc && this.dialogWidthPercent < 1) { + this.fullScreen() + } + }) + }, containerResize() { this.loadEditorSize() }, @@ -554,6 +576,9 @@ if(this.$store.state.user.token && this.$store.state.user.userId === fileUserId){ this.options.readOnly = false } + if (!this.$pc) { + this.options.readOnly = true + } if(this.options.readOnly || this.moblie){ this.$nextTick(()=> { this.editorWidth += this.contentsWidth @@ -597,9 +622,15 @@ this.isSaveDialogVisible = false this.isShowUpdateBtn = false }, + // 放弃修改 closeTabDialog(){ this.isTabSaveDialogVisible = false + this.editableTabsValue = this.nextActiveName this.editableTabs.splice(this.removeIndex,1) + let modifyingIndex = this.editableTabs.findIndex(editable => editable.status === 'Modifying') + if (modifyingIndex < 0){ + this.isShowUpdateBtn = false + } }, closeDialog() { this.textPreviewVisible = false @@ -609,7 +640,7 @@ this.closeAllTabs() }, change(value,index) { - if(value === this.editableTabs[index].content){ + if(value === this.editableValueMap.get(index)){ if(this.editableTabs[index].copyTitle !== this.editableTabs[index].title){ this.editableTabs[index].title = this.editableTabs[index].copyTitle this.editableTabs[index].status = 'Modified' @@ -758,7 +789,17 @@ } }, changePreviewMode() { + let currentIndex = this.editableTabs.findIndex(editable => editable.name === this.editableTabsValue) + if (currentIndex > -1){ + let ref = 'vditor' + currentIndex + this.$refs[ref][0].setContent(this.editableValueMap.get(currentIndex)) + } this.previewMode = !this.previewMode + this.clickTab() + }, + clickTab() { + this.editorWidth += 0.001 + this.editorHieght += 0.001 }, removeTab(targetName) { let tabs = this.editableTabs; @@ -775,6 +816,7 @@ } }); } + this.nextActiveName = activeName if(this.editableTabs[removeIndex].status !== 'Modifying'){ this.editableTabsValue = activeName; this.editableTabs = tabs.filter(tab => tab.name !== targetName); diff --git a/src/components/preview/VditorPreview.vue b/src/components/preview/VditorPreview.vue index 299bf6f..ffb7d6d 100644 --- a/src/components/preview/VditorPreview.vue +++ b/src/components/preview/VditorPreview.vue @@ -30,10 +30,7 @@ import "vditor/src/assets/scss/index.scss" }, watch: { content(val){ - if(!this.vditorPreviewShow){ - this.vditorPreviewInit(val) - this.vditorPreviewShow = true - } + this.setContent(val) } }, mounted() { @@ -43,6 +40,12 @@ import "vditor/src/assets/scss/index.scss" } }, methods:{ + setContent(val) { + if(!this.vditorPreviewShow){ + this.vditorPreviewInit(val) + this.vditorPreviewShow = true + } + }, vditorPreviewInit(content){ const that = this vditor.preview(document.getElementById('vditor'), diff --git a/src/views/home/mobile/index.vue b/src/views/home/mobile/index.vue index 23675f8..342b64d 100644 --- a/src/views/home/mobile/index.vue +++ b/src/views/home/mobile/index.vue @@ -22,6 +22,7 @@ +
@@ -46,7 +47,7 @@ title="浏览" right-arrow @click-right="checkboxAll" - :right-text="this.selectRowData.length !== this.fileList.length ? '选择' : '取消'" + :right-text="this.selectRowData.length !== this.fileList.length ? '选择44' : '取消'" @click-left="leftMenu" left-arrow>
@@ -63,7 +64,7 @@ -
@@ -207,7 +208,7 @@ - +
@@ -344,23 +345,38 @@ }; }, mounted(){ - // 加载路径 - const pathList = getPathList() - if (pathList && pathList !== 'undefined') { - const res = JSON.parse(pathList) - const list = [] - res.forEach(function(element) { - const item0 = {} - item0['folder'] = element.folder + '' - item0['index'] = element.index - list.push(item0) + // // 加载路径 + // const pathList = getPathList() + // if (pathList && pathList !== 'undefined') { + // const res = JSON.parse(pathList) + // const list = [] + // res.forEach(function(element) { + // const item0 = {} + // item0['folder'] = element.folder + '' + // item0['index'] = element.index + // list.push(item0) + // }) + // this.pathList = list + // } + + // 加载url上的path + if (this.$route.query.path !== '/') { + const path = decodeURI(this.$route.query.path) + this.pathList.splice(1, 1) + path.split('/').forEach((pathName, index) => { + if (index > 0) { + const item = {} + item['folder'] = pathName + item['index'] = index + this.pathList.push(item) + } }) - this.pathList = list } + console.log(this.pathList) if (window.history && window.history.pushState) { - history.pushState(null, null, document.URL); - window.addEventListener('popstate', this.goBack, false); + history.pushState(null, null, document.URL) + window.addEventListener('popstate', this.goBack, false) } }, destroyed(){ @@ -406,7 +422,6 @@ }, // 长按事件 rowContextmenu(row, target, touchClientX) { - // 改变菜单 if(this.selectStatus && this.selectIndexList.includes(row.index)){ if(this.selectIndexList.includes(row.index)){ @@ -446,7 +461,7 @@ this.favoriteOperating(true) break case 'open': - this.fileClick(this.rowContextData) + this.fileClick(this.rowContextData, this.rowContextData.index) break case 'unselect': const index = this.rowContextData.index @@ -458,8 +473,8 @@ case 'select': this.selectStatus = true this.selectIndexList.push(this.rowContextData.index) - setTimeout(function () { - that.$refs.checkboxes[that.rowContextData.index].toggle(); + setTimeout(() => { + this.$refs.checkboxes[that.rowContextData.index].toggle() },0) break case 'rename': @@ -470,7 +485,7 @@ },0) break case 'copy': - Toast('暂不支持移动'); + vant.Toast('暂不支持移动'); break case 'download': this.downloadFile() @@ -552,7 +567,7 @@ fileConfig.packageDownload(fileIds, this.$store.state.user.token) return } - fileConfig.publicDownload(this.rowContextData) + fileConfig.download(this.$store.state.user.name, this.rowContextData, this.$store.state.user.token) } else { this.$message({ message: '所选文件夹为空', @@ -563,11 +578,10 @@ // 收藏/取消收藏 favoriteOperating(isFavorite) { this.rowContextData.isFavorite = isFavorite - this.highlightFavorite(isFavorite, true) api.favoriteUrl({ token: this.$store.state.user.token, - id: this.rowContextData.id, + fileIds: this.rowContextData.id, isFavorite: isFavorite }).then(res => { }) @@ -587,7 +601,7 @@ } const str = this.getShowSumFileAndFolder(fileList) - Dialog.confirm({ + vant.Dialog.confirm({ title: '提示', message: '此操作将永久删除' + str + ', 是否继续?' }).then(() => { @@ -601,9 +615,8 @@ } else { this.getFileList() } - Toast.setDefaultOptions({ duration: 500 }); - Toast.success('删除成功'); - this.$refs.fileListTable.clearSelection()// 删除后清空之前选择的数据 + vant.Toast.setDefaultOptions({ duration: 800 }); + vant.Toast.success('删除成功'); this.selectRowData = [] }) }) @@ -674,12 +687,12 @@ }, // 浏览器的返回事件 goBack(){ - const linkIndex = this.pathList.length-3 + const linkIndex = this.pathList.length - 2 this.handleLink(this.pathList[linkIndex],linkIndex) }, // 点击返回按钮(标题) clickBack() { - const linkIndex = this.pathList.length-3 + const linkIndex = this.pathList.length - 2 this.handleLink(this.pathList[linkIndex], linkIndex, true) }, //菜单键 @@ -784,7 +797,6 @@ if(isPushLink){ this.$router.push(`/_m?path=${encodeURIComponent(this.path)}`) } - setPath(this.path, this.pathList) this.getFileList() } }, @@ -853,12 +865,15 @@ // 填充数据 loadData(res,onLoad){ if(onLoad){ - res.data.forEach((file,number) => { - file['index'] = (this.pagination.pageIndex - 1) * this.pagination.pageSize + number + res.data.forEach((file,index) => { + file['index'] = (this.pagination.pageIndex - 1) * this.pagination.pageSize + index this.fileList.push(file) - }); + }) }else{ this.fileList = res.data + this.fileList.map((file,index) => { + file['index'] = index + }) } // 加载状态结束 this.loading = false @@ -877,6 +892,9 @@ this.getFileList() this.leftMenuShow = false }, + uploadList() { + this.$router.push(`/upload/index_m`) + }, // 统计 statistics() { let totalSize = 0 @@ -962,16 +980,11 @@ } else { this.path = '/' + row.name } - const itemFirst = {} - itemFirst['folder'] = row.name - itemFirst['index'] = this.pathList.length - 1 - const itemSecond = {} - itemSecond['folder'] = '+' - itemSecond['index'] = this.pathList.length - this.pathList[this.pathList.length - 1] = itemFirst - this.pathList.push(itemSecond) + const item = {} + item['folder'] = row.name + item['index'] = this.pathList.length - 1 + this.pathList.push(item) this.$router.push(`/_m?path=${encodeURIComponent(this.path)}`) - setPath(this.path, this.pathList) this.getFileList() } else { if (row.contentType.startsWith('image')) { diff --git a/src/views/upload/mobile/index.vue b/src/views/upload/mobile/index.vue index e47ede9..885e19d 100644 --- a/src/views/upload/mobile/index.vue +++ b/src/views/upload/mobile/index.vue @@ -16,7 +16,10 @@
  • -
    暂无待上传文件
    +
    + + +
    @@ -34,10 +37,12 @@ }; }, mounted(){ - this.fileList = window.uploader.fileList + if (window.uploader) { + this.fileList = window.uploader.fileList + } }, destroyed(){ - window.removeEventListener('popstate', this.goBack, false); + window.removeEventListener('popstate', this.goBack, false) }, methods: { onClickLeft() { @@ -78,4 +83,11 @@ margin-right: 16px; } } + .no-file { + .plus { + position: absolute; + bottom: 1rem; + right: 2rem; + } + }