🐛fix(*): 修复文件夹中有特殊字符时,出现的一系列问题

This commit is contained in:
jmal 2022-08-09 14:42:54 +08:00
parent ab6f82e0fe
commit 114cf4f724
10 changed files with 53 additions and 53 deletions

View File

@ -243,7 +243,7 @@
}).then(() => { }).then(() => {
api.delFile({ api.delFile({
username: this.$store.state.user.name, username: this.$store.state.user.name,
path: data.path path: encodeURI(data.path)
}).then(()=>{ }).then(()=>{
this.$emit('removeFile', data.path) this.$emit('removeFile', data.path)
let node = this.tree.getActiveNode() let node = this.tree.getActiveNode()
@ -261,7 +261,7 @@
let path = this.currentPath.substring(0,this.currentPath.length-title.length) let path = this.currentPath.substring(0,this.currentPath.length-title.length)
api.upperLevelList({ api.upperLevelList({
username: this.$store.state.user.name, username: this.$store.state.user.name,
path: path, path: encodeURI(path),
}).then(res => { }).then(res => {
this.tree.reload(this.convert(res.data)) this.tree.reload(this.convert(res.data))
}) })
@ -271,7 +271,7 @@
api.listfiles({ api.listfiles({
userId: this.$store.state.user.userId, userId: this.$store.state.user.userId,
username: this.$store.state.user.name, username: this.$store.state.user.name,
path: this.currentPath, path: encodeURI(this.currentPath),
}).then(res => { }).then(res => {
this.tree.reload(this.convert(res.data)) this.tree.reload(this.convert(res.data))
}) })
@ -292,7 +292,7 @@
api.listfiles({ api.listfiles({
userId: this.$store.state.user.userId, userId: this.$store.state.user.userId,
username: this.$store.state.user.name, username: this.$store.state.user.name,
path: node.path, path: encodeURI(node.path),
}).then(res => { }).then(res => {
loading.close() loading.close()
if(res.data.length === 0){ if(res.data.length === 0){
@ -311,7 +311,7 @@
api.listfiles({ api.listfiles({
userId: this.$store.state.user.userId, userId: this.$store.state.user.userId,
username: this.$store.state.user.name, username: this.$store.state.user.name,
path: treeData.path, path: encodeURI(treeData.path),
}).then(res => { }).then(res => {
let oldname = treeData.name let oldname = treeData.name
let data = res.data.map(doc => { let data = res.data.map(doc => {
@ -350,10 +350,10 @@
} }
} }
api.addFile({ api.addFile({
fileName: fileName, fileName: encodeURI(fileName),
isFolder: node.folder, isFolder: node.folder,
username: this.$store.state.user.name, username: this.$store.state.user.name,
parentPath: parentPath parentPath: encodeURI(parentPath)
}).then((res)=>{ }).then((res)=>{
let str = node.folder?'文件夹':'文件' let str = node.folder?'文件夹':'文件'
this.$message.success(`新建${str}成功`) this.$message.success(`新建${str}成功`)
@ -429,7 +429,7 @@
api.renameByPath({ api.renameByPath({
newFileName: newFileName, newFileName: newFileName,
username: this.$store.state.user.name, username: this.$store.state.user.name,
path: node.data.path path: encodeURI(node.data.path)
}).then(res => { }).then(res => {
if (res.data) { if (res.data) {
row.oldName = node.data.name row.oldName = node.data.name
@ -491,7 +491,7 @@
return new Promise(function(resolve) { return new Promise(function(resolve) {
api.listfiles({ api.listfiles({
username: that.$store.state.user.name, username: that.$store.state.user.name,
path: data.path, path: encodeURI(data.path),
}).then(res => { }).then(res => {
resolve(that.convert(res.data)) resolve(that.convert(res.data))
}) })

View File

@ -174,8 +174,8 @@ export default {
} }
api.newFolder({ api.newFolder({
isFolder: true, isFolder: true,
filename: data.name, filename: encodeURI(data.name),
currentDirectory: path, currentDirectory: encodeURI(path),
username: this.$store.state.user.name, username: this.$store.state.user.name,
userId: this.$store.state.user.userId userId: this.$store.state.user.userId
}).then((res) => { }).then((res) => {

View File

@ -76,7 +76,7 @@
if (node.level > 0){ if (node.level > 0){
api.listfiles({ api.listfiles({
username: this.$store.state.user.name, username: this.$store.state.user.name,
path: node.data.path, path: encodeURI(node.data.path),
tempDir: this.tempDir tempDir: this.tempDir
}).then(res => { }).then(res => {
const nextNodes = res.data.map(data => { const nextNodes = res.data.map(data => {
@ -135,8 +135,8 @@
} }
api.newFolder({ api.newFolder({
isFolder: true, isFolder: true,
filename: data.name, filename: encodeURI(data.name),
currentDirectory: path, currentDirectory: encodeURI(path),
username: this.$store.state.user.name, username: this.$store.state.user.name,
userId: this.$store.state.user.userId userId: this.$store.state.user.userId
}).then((res) => { }).then((res) => {

View File

@ -1662,7 +1662,7 @@ export default {
// 浏览器的返回事件 // 浏览器的返回事件
goBack() { goBack() {
if (this.pathList.length <= 1) { if (this.pathList.length <= 1) {
this.$router.push(`/?vmode=${this.vmode}&path=${encodeURIComponent(this.path)}`) this.$router.push(`/?vmode=${this.vmode}&path=${encodeURI(this.path)}`)
return return
} }
this.lastLink() this.lastLink()
@ -1690,9 +1690,9 @@ export default {
}) })
if (!unPushLink) { if (!unPushLink) {
if (!this.$route.query.path) { if (!this.$route.query.path) {
this.$router.push(`?vmode=${this.vmode}&path=${encodeURIComponent(this.path)}`) this.$router.push(`?vmode=${this.vmode}&path=${encodeURI(this.path)}`)
} else { } else {
this.$router.push(`?vmode=${this.vmode}&path=${encodeURIComponent(this.path)}`) this.$router.push(`?vmode=${this.vmode}&path=${encodeURI(this.path)}`)
} }
} }
if (!unRefresh) { if (!unRefresh) {
@ -1755,8 +1755,8 @@ export default {
this.newFolderLoading = true this.newFolderLoading = true
api.uploadFolder({ api.uploadFolder({
isFolder: true, isFolder: true,
filename: this.newFolderName, filename: encodeURI(this.newFolderName),
currentDirectory: encodeURIComponent(this.path), currentDirectory: encodeURI(this.path),
username: this.$store.state.user.name, username: this.$store.state.user.name,
userId: this.$store.state.user.userId userId: this.$store.state.user.userId
}).then((res) => { }).then((res) => {
@ -1810,10 +1810,10 @@ export default {
} }
} }
api.addFile({ api.addFile({
fileName: newFileName, fileName: encodeURI(newFileName),
isFolder: false, isFolder: false,
username: this.$store.state.user.name, username: this.$store.state.user.name,
parentPath: parentPath parentPath: encodeURI(parentPath)
}).then((res) => { }).then((res) => {
this.createTextFileLoading = false this.createTextFileLoading = false
@ -1967,7 +1967,7 @@ export default {
keyword: key, keyword: key,
sortableProp: this.sortable.prop, sortableProp: this.sortable.prop,
order: this.sortable.order, order: this.sortable.order,
currentDirectory: encodeURIComponent(this.$route.query.path), currentDirectory: encodeURI(this.$route.query.path),
pageIndex: this.pagination.pageIndex, pageIndex: this.pagination.pageIndex,
pageSize: this.pagination.pageSize pageSize: this.pagination.pageSize
}).then(res => { }).then(res => {
@ -1983,7 +1983,7 @@ export default {
api.searchFileAndOpenDir({ api.searchFileAndOpenDir({
userId: this.$store.state.user.userId, userId: this.$store.state.user.userId,
id: row.id, id: row.id,
currentDirectory: encodeURIComponent(this.$route.query.path), currentDirectory: encodeURI(this.$route.query.path),
pageIndex: this.pagination.pageIndex, pageIndex: this.pagination.pageIndex,
pageSize: this.pagination.pageSize pageSize: this.pagination.pageSize
}).then(res => { }).then(res => {
@ -1998,7 +1998,7 @@ export default {
api.searchFileAndOpenDir({ api.searchFileAndOpenDir({
userId: this.$store.state.user.userId, userId: this.$store.state.user.userId,
id: row.id, id: row.id,
currentDirectory: encodeURIComponent(this.$route.query.path), currentDirectory: encodeURI(this.$route.query.path),
pageIndex: this.pagination.pageIndex, pageIndex: this.pagination.pageIndex,
pageSize: this.pagination.pageSize pageSize: this.pagination.pageSize
}).then(res => { }).then(res => {
@ -2011,7 +2011,7 @@ export default {
api.fileList({ api.fileList({
userId: this.$store.state.user.userId, userId: this.$store.state.user.userId,
username: this.$store.state.user.name, username: this.$store.state.user.name,
currentDirectory: encodeURIComponent(this.$route.query.path), currentDirectory: encodeURI(this.$route.query.path),
queryFileType: this.queryFileType, queryFileType: this.queryFileType,
sortableProp: this.sortable.prop, sortableProp: this.sortable.prop,
order: this.sortable.order, order: this.sortable.order,
@ -2028,7 +2028,7 @@ export default {
this.beforeLoadData(onLoad) this.beforeLoadData(onLoad)
api.fileList({ api.fileList({
userId: this.$store.state.user.userId, userId: this.$store.state.user.userId,
currentDirectory: encodeURIComponent(this.$route.query.path), currentDirectory: encodeURI(this.$route.query.path),
pageIndex: this.pagination.pageIndex, pageIndex: this.pagination.pageIndex,
pageSize: this.pagination.pageSize pageSize: this.pagination.pageSize
}).then(res => { }).then(res => {
@ -2776,8 +2776,8 @@ export default {
} }
api.newFolder({ api.newFolder({
isFolder: true, isFolder: true,
filename: data.name, filename: encodeURI(data.name),
currentDirectory: encodeURIComponent(this.$route.query.path), currentDirectory: encodeURI(this.$route.query.path),
username: this.$store.state.user.name, username: this.$store.state.user.name,
userId: this.$store.state.user.userId userId: this.$store.state.user.userId
}).then((res) => { }).then((res) => {
@ -3067,7 +3067,7 @@ export default {
const item = {'folder': row.name} const item = {'folder': row.name}
this.pathList.push(item) this.pathList.push(item)
this.pagination.pageIndex = 1 this.pagination.pageIndex = 1
const path = encodeURIComponent(this.path); const path = encodeURI(this.path);
this.$router.push(`?vmode=${this.vmode}&path=${path}`) this.$router.push(`?vmode=${this.vmode}&path=${path}`)
this.openDir(row) this.openDir(row)
} }

View File

@ -275,9 +275,9 @@
// 上传文件夹 // 上传文件夹
api.uploadFolder({ api.uploadFolder({
isFolder: true, isFolder: true,
folderPath: folder.parent.path, folderPath: encodeURI(folder.parent.path),
filename: folder.name, filename: encodeURI(folder.name),
currentDirectory: this.params.currentDirectory, currentDirectory: encodeURI(this.params.currentDirectory),
username: this.params.username, username: this.params.username,
userId: this.params.userId userId: this.params.userId
}).then(() => { }).then(() => {
@ -347,10 +347,10 @@
// 文件状态设为“合并中” // 文件状态设为“合并中”
this.statusSet(file.id, 'merging') this.statusSet(file.id, 'merging')
api.mergeSimpleUpload({ api.mergeSimpleUpload({
filename: encodeURIComponent(file.name), filename: encodeURI(file.name),
relativePath: encodeURIComponent(file.relativePath), relativePath: encodeURI(file.relativePath),
identifier: file.uniqueIdentifier, identifier: file.uniqueIdentifier,
currentDirectory: this.params.currentDirectory, currentDirectory: encodeURI(this.params.currentDirectory),
username: this.params.username, username: this.params.username,
userId: this.params.userId, userId: this.params.userId,
totalSize: file.size, totalSize: file.size,

View File

@ -90,6 +90,7 @@ export default {
let viewIndex = 0 let viewIndex = 0
this.imageFiles = this.fileList.filter(element => !element.isFolder && element.contentType.startsWith('image')) this.imageFiles = this.fileList.filter(element => !element.isFolder && element.contentType.startsWith('image'))
this.imageFiles.forEach((element) => { this.imageFiles.forEach((element) => {
console.log(element)
this.images.push({ this.images.push({
thumbnail: this.getImageUrlbyThumbnail(element.id), thumbnail: this.getImageUrlbyThumbnail(element.id),
source: this.getImageUrl(element) source: this.getImageUrl(element)

View File

@ -290,7 +290,7 @@
shareId: this.shareId, shareId: this.shareId,
fileId: file.id, fileId: file.id,
id: file.id, id: file.id,
path: file.path, path: encodeURI(file.path),
username: this.$store.state.user.name username: this.$store.state.user.name
}).then((res)=>{ }).then((res)=>{
this.loading.close() this.loading.close()
@ -518,7 +518,7 @@
message: '<span>&nbsp;&nbsp;正在加载数据...</span>' message: '<span>&nbsp;&nbsp;正在加载数据...</span>'
}) })
api.previewTextByPath({ api.previewTextByPath({
path: row.path, path: encodeURI(row.path),
username: this.$store.state.user.name username: this.$store.state.user.name
}).then((res)=>{ }).then((res)=>{
this.loading.close() this.loading.close()

View File

@ -12,9 +12,9 @@ export default {
if (token) { if (token) {
let path = "/" let path = "/"
if (file.path.length > 1) { if (file.path.length > 1) {
path = encodeURIComponent(file.path.substr(1, file.path.length - 2)) path = encodeURI(file.path.substr(1, file.path.length - 2))
} }
const filename = encodeURIComponent(file.name); const filename = encodeURI(file.name);
return `${this.baseUrl}/file/${username}/${path}/${filename}?jmal-token=${token}` return `${this.baseUrl}/file/${username}/${path}/${filename}?jmal-token=${token}`
} else { } else {
return `${this.baseUrl}/file/${username}/${path}/${filename}` return `${this.baseUrl}/file/${username}/${path}/${filename}`
@ -32,8 +32,7 @@ export default {
// 下载文件 // 下载文件
download: function(username, file, token) { download: function(username, file, token) {
fileApi.isAllowDownload().then(() => { fileApi.isAllowDownload().then(() => {
encodeURI() let url = `${this.baseUrl}/file/${username}${encodeURI(file.path)}${encodeURI(file.name)}?jmal-token=${token}&o=download`
let url = `${this.baseUrl}/file/${username}${file.path}${encodeURIComponent(file.name)}?jmal-token=${token}&o=download`
window.open(url, '_self') window.open(url, '_self')
}) })
}, },

View File

@ -743,7 +743,7 @@ export default {
// 浏览器的返回事件 // 浏览器的返回事件
goBack() { goBack() {
if (this.pathList.length <= 1) { if (this.pathList.length <= 1) {
this.$router.push(`/_m?vmode=${this.vmode}&path=${encodeURIComponent(this.path)}`) this.$router.push(`/_m?vmode=${this.vmode}&path=${encodeURI(this.path)}`)
return return
} }
this.clickBack() this.clickBack()
@ -849,9 +849,9 @@ export default {
}) })
if (!unPushLink) { if (!unPushLink) {
if (!this.$route.query.path) { if (!this.$route.query.path) {
this.$router.push(`/_m?vmode=${this.vmode}&path=${encodeURIComponent(this.path)}`) this.$router.push(`/_m?vmode=${this.vmode}&path=${encodeURI(this.path)}`)
} else { } else {
this.$router.push(`/_m?vmode=${this.vmode}&path=${encodeURIComponent(this.path)}`) this.$router.push(`/_m?vmode=${this.vmode}&path=${encodeURI(this.path)}`)
} }
} }
if (!unRefresh) { if (!unRefresh) {
@ -881,7 +881,7 @@ export default {
this.beforeLoadData(onLoad) this.beforeLoadData(onLoad)
api.fileList({ api.fileList({
userId: this.$store.state.user.userId, userId: this.$store.state.user.userId,
currentDirectory: this.$route.query.path, currentDirectory: encodeURI(this.$route.query.path),
queryFileType: this.queryFileType, queryFileType: this.queryFileType,
sortableProp: this.sortableProp, sortableProp: this.sortableProp,
order: this.order, order: this.order,
@ -903,7 +903,7 @@ export default {
userId: this.$store.state.user.userId, userId: this.$store.state.user.userId,
username: this.$store.state.user.name, username: this.$store.state.user.name,
keyword: key, keyword: key,
currentDirectory: this.$route.query.path, currentDirectory: encodeURI(this.$route.query.path),
pageIndex: this.pagination.pageIndex, pageIndex: this.pagination.pageIndex,
pageSize: this.pagination.pageSize pageSize: this.pagination.pageSize
}).then(res => { }).then(res => {
@ -1064,7 +1064,7 @@ export default {
item['folder'] = row.name item['folder'] = row.name
item['index'] = this.pathList.length - 1 item['index'] = this.pathList.length - 1
this.pathList.push(item) this.pathList.push(item)
this.$router.push(`/_m?vmode=${this.vmode}&path=${encodeURIComponent(this.path)}`) this.$router.push(`/_m?vmode=${this.vmode}&path=${encodeURI(this.path)}`)
this.getFileList() this.getFileList()
} else { } else {
if (row.contentType.startsWith('image')) { if (row.contentType.startsWith('image')) {
@ -1184,7 +1184,7 @@ export default {
// 打开文件选择框 // 打开文件选择框
Bus.$emit('openUploader', { Bus.$emit('openUploader', {
// 传入的参数 // 传入的参数
currentDirectory: this.path, currentDirectory: encodeURI(this.path),
username: this.$store.state.user.name, username: this.$store.state.user.name,
userId: this.$store.state.user.userId userId: this.$store.state.user.userId
}) })
@ -1194,7 +1194,7 @@ export default {
// 打开文件夹选择框 // 打开文件夹选择框
Bus.$emit('uploadFolder', { Bus.$emit('uploadFolder', {
// 传入的参数 // 传入的参数
currentDirectory: this.path, currentDirectory: encodeURI(this.path),
username: this.$store.state.user.name, username: this.$store.state.user.name,
userId: this.$store.state.user.userId userId: this.$store.state.user.userId
}) })
@ -1206,8 +1206,8 @@ export default {
if (this.newFolderName) { if (this.newFolderName) {
api.uploadFolder({ api.uploadFolder({
isFolder: true, isFolder: true,
filename: this.newFolderName, filename: encodeURI(this.newFolderName),
currentDirectory: this.path, currentDirectory: encodeURI(this.path),
username: this.$store.state.user.name, username: this.$store.state.user.name,
userId: this.$store.state.user.userId userId: this.$store.state.user.userId
}).then((res) => { }).then((res) => {

View File

@ -468,7 +468,7 @@ export default {
fileId: this.$route.query.id, fileId: this.$route.query.id,
userId: this.$store.state.user.userId, userId: this.$store.state.user.userId,
username: this.$store.state.user.name, username: this.$store.state.user.name,
filename: filename, filename: encodeURI(filename),
cover: this.file.cover, cover: this.file.cover,
isDraft: this.draft, isDraft: this.draft,
isRelease: this.file.release, isRelease: this.file.release,
@ -476,7 +476,7 @@ export default {
slug: this.file.slug ? this.file.slug : this.filename, slug: this.file.slug ? this.file.slug : this.filename,
categoryIds: this.file.categoryIds, categoryIds: this.file.categoryIds,
tagNames: this.dynamicTags, tagNames: this.dynamicTags,
currentDirectory: this.storageLocation, currentDirectory: encodeURI(this.path),
contentText: this.contentEditor.getValue(), contentText: this.contentEditor.getValue(),
html: this.contentEditor.getHTML(), html: this.contentEditor.getHTML(),
uploadDate: this.file.uploadDate, uploadDate: this.file.uploadDate,