diff --git a/src/api/file-api.js b/src/api/file-api.js
index e50dc78..abaa2ee 100644
--- a/src/api/file-api.js
+++ b/src/api/file-api.js
@@ -107,6 +107,14 @@ export default {
params
})
},
+ // 查找下级目录
+ listfiles: function(params) {
+ return request({
+ url: 'listfiles',
+ method: 'get',
+ params
+ })
+ },
// 移动文件/文件夹
move: function(params) {
return request({
@@ -180,6 +188,14 @@ export default {
params
})
},
+ // 通过filepath预览文本文件
+ previewTextByPath: function(params) {
+ return request({
+ url: '/preview/path/text',
+ method: 'get',
+ params
+ })
+ },
// 预览文本文件
previewText: function(params) {
return request({
@@ -196,4 +212,12 @@ export default {
params
})
},
+ // 解压文件
+ unzip: function(params) {
+ return request({
+ url: '/unzip',
+ method: 'get',
+ params
+ })
+ },
}
diff --git a/src/components/FileTree/index.vue b/src/components/FileTree/index.vue
new file mode 100644
index 0000000..87cfdf1
--- /dev/null
+++ b/src/components/FileTree/index.vue
@@ -0,0 +1,201 @@
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/components/ShowFile/ShowFile.vue b/src/components/ShowFile/ShowFile.vue
index 544607e..74f2d2c 100644
--- a/src/components/ShowFile/ShowFile.vue
+++ b/src/components/ShowFile/ShowFile.vue
@@ -102,6 +102,37 @@
+
+ 查看压缩文件
+
+
+
+
+ 此文件不支持预览, 是否下载该文件?
+
+
+
+
+
+
+
+
正在'+status+''
+ });
+ api.unzip({
+ fileId: file.id,
+ destFileId: destFileId
+ }).then((res) => {
+ decompressing.iconClass = null
+ decompressing.type = 'success'
+ decompressing.message = status+'成功'
+
+ this.compressedFileData = res.data
+ this.compressedFileVisible = true
+ this.compressedFileName = file.name
+ this.compressedFileTempDir = tempDir
+
+ setTimeout(function () {
+ decompressing.close()
+ },1000)
+ }).catch(() => {
+ decompressing.close()
+ })
+ },
// 点击文件或文件夹
fileClick(row) {
+ this.openingFile = row
if (row.isFolder) {
this.editingIndex = -1
// 打开文件夹
@@ -2415,19 +2492,46 @@
this.$router.push(`/public/articles/article?mark=${row.id}`)
return
}
+ if(suffix.compressedFile.includes(row.suffix)){
+ // this.unzip(row)
+ this.openCompressionVisible = true
+ return
+ }
// 打开文件
let fileIds = [row.id]
- this.$confirm('此文件不支持预览, 是否下载该文件?', '提示', {
- confirmButtonText: '确定',
- cancelButtonText: '取消',
- type: 'warning'
- }).then(() => {
- let url = process.env.VUE_APP_BASE_FILE_API + 'preview/' + row.name + '?jmal-token=' + this.$store.state.user.token + '&fileIds=' + fileIds
- window.open(url, '_self')
- })
+ this.notPreviewDialogVisible = true
+
+ // this.$confirm('此文件不支持预览, 是否下载该文件?', '提示', {
+ // confirmButtonText: '确定',
+ // cancelButtonText: '强行使用文本编辑器打开',
+ // type: 'warning',
+ // distinguishCancelAndClose: true
+ // }).then(() => {
+ // let url = process.env.VUE_APP_BASE_FILE_API + 'preview/' + row.name + '?jmal-token=' + this.$store.state.user.token + '&fileIds=' + fileIds
+ // window.open(url, '_self')
+ // }).catch(() => {
+ // this.textPreviewRow = row
+ // this.textPreviewVisible = true
+ // })
}
- }
+ },
+ // 强行使用文本编辑器打开
+ forciblyOpen(file) {
+ this.textPreviewRow = file
+ this.textPreviewVisible = true
+ const that = this
+ setTimeout(function () {
+ that.notPreviewDialogVisible = false
+ },100)
+ },
+ determineDownload(file) {
+ this.downLaod(file)
+ this.notPreviewDialogVisible = false
+ },
+ downLaod(file){
+ window.open(`${process.env.VUE_APP_BASE_FILE_API}preview/${file.name}?jmal-token=${this.$store.state.user.token}&fileIds=${file.id}`, '_self')
+ },
}
}
@@ -2518,5 +2622,16 @@
/deep/.el-input-tree-button {
margin-left: 5px!important;
}
+ /deep/.open-file-dialog {
+ .el-dialog {
+ width: 400px;
+ }
+ .svg-icon {
+ font-size: 20px;
+ }
+ .dialog-msg {
+ margin-left: 10px;
+ }
+ }
diff --git a/src/components/preview/SimTextPreview.vue b/src/components/preview/SimTextPreview.vue
index e808c67..1a47f41 100644
--- a/src/components/preview/SimTextPreview.vue
+++ b/src/components/preview/SimTextPreview.vue
@@ -66,6 +66,10 @@
type: String,
default: undefined
},
+ filepath: {
+ type: String,
+ default: undefined
+ },
status: {
type: Boolean,
default: function () {
@@ -160,15 +164,20 @@
if(this.shareId){
request = 'sharePreviewText'
}
+ if(this.filepath){
+ request = 'previewTextByPath'
+ this.options.readOnly = true
+ }
api[request]({
shareId: this.shareId,
fileId: file.id,
id: file.id,
+ path: this.filepath,
username: this.$store.state.user.name
}).then((res)=>{
- this.loading.close()
- this.textPreviewVisible = true
- this.content = res.data.contentText
+ this.loading.close()
+ this.textPreviewVisible = true
+ this.content = res.data.contentText
}).catch(() => {
this.loading.close()
})
@@ -256,7 +265,7 @@
this.setTheme()
},
setTheme(){
- let header = document.querySelector('.simtext-dialog .el-dialog__header')
+ let header = document.querySelector('.simtext-dialog .el-dialog .el-dialog__header')
if(this.lightTheme){
header.style.background = '#FFF'
header.style.color = '#181818'
@@ -290,7 +299,6 @@
-
-
-
-
-
-
-
-
-
-