fix: 修复了文件名中的'+'转换为空格的问题

This commit is contained in:
jmal 2025-08-05 21:07:06 +08:00
parent 3cf9adfd49
commit 00c0d99225
13 changed files with 50 additions and 51 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: encodeURI(data.path) path: encodeURIComponent(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: encodeURI(path), path: encodeURIComponent(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: encodeURI(this.currentPath), path: encodeURIComponent(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: encodeURI(node.path), path: encodeURIComponent(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: encodeURI(treeData.path), path: encodeURIComponent(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: encodeURI(fileName), fileName: encodeURIComponent(fileName),
isFolder: node.folder, isFolder: node.folder,
username: this.$store.state.user.name, username: this.$store.state.user.name,
parentPath: encodeURI(parentPath) parentPath: encodeURIComponent(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: encodeURI(node.data.path) path: encodeURIComponent(node.data.path)
}).then(res => { }).then(res => {
row.oldName = node.data.name row.oldName = node.data.name
row.name = newFileName row.name = newFileName
@ -466,7 +466,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: encodeURI(data.path), path: encodeURIComponent(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: encodeURI(data.name), filename: encodeURIComponent(data.name),
currentDirectory: encodeURI(path), currentDirectory: encodeURIComponent(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

@ -136,7 +136,7 @@ export default {
api api
.listfiles({ .listfiles({
username: this.$store.state.user.name, username: this.$store.state.user.name,
path: encodeURI(node.data.path), path: encodeURIComponent(node.data.path),
tempDir: this.tempDir tempDir: this.tempDir
}) })
.then(res => { .then(res => {
@ -205,8 +205,8 @@ export default {
let newFolderName = document.getElementById("treeInput").value let newFolderName = document.getElementById("treeInput").value
api.newFolder({ api.newFolder({
isFolder: true, isFolder: true,
filename: encodeURI(newFolderName), filename: encodeURIComponent(newFolderName),
currentDirectory: encodeURI(path), currentDirectory: encodeURIComponent(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

@ -155,7 +155,7 @@ export default {
if (!this.$store.getters.token) return if (!this.$store.getters.token) return
this.resetState() this.resetState()
this.loadApiFunction = historyApi.fileHistoryPathList this.loadApiFunction = historyApi.fileHistoryPathList
this.loadApiParams = { path: encodeURI(pathname), username: this.$store.state.user.name } this.loadApiParams = { path: encodeURIComponent(pathname), username: this.$store.state.user.name }
this._internalLoadHistory() this._internalLoadHistory()
}, },

View File

@ -187,7 +187,7 @@ export default {
fileId: this.file.id, fileId: this.file.id,
id: this.file.id, id: this.file.id,
fileName: this.file.name, fileName: this.file.name,
path: encodeURI(this.file.path), path: encodeURIComponent(this.file.path),
username: this.$store.state.user.name, username: this.$store.state.user.name,
content: true, content: true,
}).then((res) => { }).then((res) => {
@ -391,7 +391,7 @@ export default {
update(value) { update(value) {
this.saveBtnUpdating = true this.saveBtnUpdating = true
txtApi.editMarkdownByPath({ txtApi.editMarkdownByPath({
relativePath: encodeURI(this.file.path + this.file.name), relativePath: encodeURIComponent(this.file.path + this.file.name),
userId: this.$store.state.user.userId, userId: this.$store.state.user.userId,
username: this.$store.state.user.name, username: this.$store.state.user.name,
mountFileId: this.$store.state.user.userId !== this.file.userId ? this.file.id : '', mountFileId: this.$store.state.user.userId !== this.file.userId ? this.file.id : '',

View File

@ -2366,7 +2366,7 @@ export default {
: '' : ''
const basePath = this.getBasePath() const basePath = this.getBasePath()
this.$router.push( this.$router.push(
`/?vmode=${this.vmode}&path=${encodeURI( `/?vmode=${this.vmode}&path=${encodeURIComponent(
this.path this.path
)}${queryTagId}${basePath}${keyword}` )}${queryTagId}${basePath}${keyword}`
) )
@ -2431,7 +2431,7 @@ export default {
keywordQuery = '' keywordQuery = ''
searchOpenFolder = '' searchOpenFolder = ''
} }
this.$router.push(`?vmode=${this.vmode}&path=${encodeURI(this.path).replaceAll('#', '%23')}${queryFolder ? '&folder=' + queryFolder : ''}${queryTagId}${basePath}${keywordQuery}${searchOpenFolder}`) this.$router.push(`?vmode=${this.vmode}&path=${encodeURIComponent(this.path).replaceAll('#', '%23')}${queryFolder ? '&folder=' + queryFolder : ''}${queryTagId}${basePath}${keywordQuery}${searchOpenFolder}`)
} }
if (!unRefresh) { if (!unRefresh) {
this.pagination.pageIndex = 1 this.pagination.pageIndex = 1
@ -2565,7 +2565,7 @@ export default {
api api
.uploadFolder({ .uploadFolder({
isFolder: true, isFolder: true,
filename: encodeURI(this.newFolderName), filename: encodeURIComponent(this.newFolderName),
currentDirectory: this.getQueryPath(), currentDirectory: this.getQueryPath(),
folder: this.$route.query.searchOpenFolder || this.$route.query.folder, folder: this.$route.query.searchOpenFolder || this.$route.query.folder,
username: this.$store.state.user.name, username: this.$store.state.user.name,
@ -2629,11 +2629,11 @@ export default {
let suffix = newFileName.substring(newFileName.lastIndexOf('.') + 1) let suffix = newFileName.substring(newFileName.lastIndexOf('.') + 1)
api api
.addFile({ .addFile({
fileName: encodeURI(newFileName), fileName: encodeURIComponent(newFileName),
isFolder: false, isFolder: false,
folder: this.$route.query.searchOpenFolder || this.$route.query.folder, folder: this.$route.query.searchOpenFolder || this.$route.query.folder,
username: this.$store.state.user.name, username: this.$store.state.user.name,
parentPath: encodeURI(parentPath), parentPath: encodeURIComponent(parentPath),
}) })
.then(res => { .then(res => {
this.createFileLoading = false this.createFileLoading = false
@ -2881,7 +2881,7 @@ export default {
const basePath = this.getBasePath() const basePath = this.getBasePath()
const keyword = key ? `&keyword=${key}` : '' const keyword = key ? `&keyword=${key}` : ''
const path = this.path const path = this.path
? encodeURI(this.path.replace(this.basePath, '/')) ? encodeURIComponent(this.path.replace(this.basePath, '/'))
: '/' : '/'
this.$router.push( this.$router.push(
`?vmode=${ `?vmode=${
@ -3032,7 +3032,7 @@ export default {
basePath = basePath.substring(0, basePath.length - 1) basePath = basePath.substring(0, basePath.length - 1)
} }
} }
return encodeURI(basePath + this.$route.query.path) return encodeURIComponent(basePath + this.$route.query.path)
}, },
tableBodyScroll(table, e) { tableBodyScroll(table, e) {
this.fileListScrollTop = e.target.scrollTop this.fileListScrollTop = e.target.scrollTop
@ -3359,7 +3359,7 @@ export default {
} }
api api
.rename({ .rename({
newFileName: encodeURI(newFileName), newFileName: encodeURIComponent(newFileName),
username: this.$store.state.user.name, username: this.$store.state.user.name,
folder: this.$route.query.searchOpenFolder || this.$route.query.folder, folder: this.$route.query.searchOpenFolder || this.$route.query.folder,
id: row.id, id: row.id,
@ -4033,7 +4033,7 @@ export default {
api api
.newFolder({ .newFolder({
isFolder: true, isFolder: true,
filename: encodeURI(newFolderName), filename: encodeURIComponent(newFolderName),
currentDirectory: this.getQueryPath(), currentDirectory: this.getQueryPath(),
folder: this.$route.query.searchOpenFolder || this.$route.query.folder, folder: this.$route.query.searchOpenFolder || this.$route.query.folder,
username: this.$store.state.user.name, username: this.$store.state.user.name,
@ -4423,8 +4423,7 @@ export default {
this.path = this.path.replace(/\/\//g, '/') this.path = this.path.replace(/\/\//g, '/')
// 去掉this.path开头的this.basePath // 去掉this.path开头的this.basePath
this.path = this.path.replace(this.basePath, '/') this.path = this.path.replace(this.basePath, '/')
const path = encodeURI(this.path).replaceAll('#', '%23') const path = encodeURIComponent(this.path).replaceAll('#', '%23')
const item = { folder: row.name, shareBase: row.shareBase } const item = { folder: row.name, shareBase: row.shareBase }
this.pathList.push(item) this.pathList.push(item)
this.pagination.pageIndex = 1 this.pagination.pageIndex = 1

View File

@ -111,7 +111,7 @@ export default {
fileId: this.file.id, fileId: this.file.id,
id: this.file.id, id: this.file.id,
fileName: this.file.name, fileName: this.file.name,
path: encodeURI(this.file.path), path: encodeURIComponent(this.file.path),
username: this.$store.state.user.name, username: this.$store.state.user.name,
content: true, content: true,
}).then(async (res) => { }).then(async (res) => {
@ -225,7 +225,7 @@ export default {
update(value) { update(value) {
this.saveBtnUpdating = true this.saveBtnUpdating = true
txtApi.editMarkdownByPath({ txtApi.editMarkdownByPath({
relativePath: encodeURI(this.file.path + this.file.name), relativePath: encodeURIComponent(this.file.path + this.file.name),
userId: this.$store.state.user.userId, userId: this.$store.state.user.userId,
username: this.$store.state.user.name, username: this.$store.state.user.name,
mountFileId: this.$store.state.user.userId !== this.file.userId ? this.file.id : '', mountFileId: this.$store.state.user.userId !== this.file.userId ? this.file.id : '',

View File

@ -123,7 +123,7 @@ export default {
fileId: this.file.id, fileId: this.file.id,
id: this.file.id, id: this.file.id,
fileName: this.file.name, fileName: this.file.name,
path: encodeURI(this.file.path), path: encodeURIComponent(this.file.path),
username: this.$store.state.user.name, username: this.$store.state.user.name,
content: true, content: true,
}).then(async (res) => { }).then(async (res) => {
@ -234,7 +234,7 @@ export default {
this.saveBtnUpdating = true this.saveBtnUpdating = true
this.currentContext = JSON.stringify(this.excalidrawData) this.currentContext = JSON.stringify(this.excalidrawData)
txtApi.editMarkdownByPath({ txtApi.editMarkdownByPath({
relativePath: encodeURI(this.file.path + this.file.name), relativePath: encodeURIComponent(this.file.path + this.file.name),
userId: this.$store.state.user.userId, userId: this.$store.state.user.userId,
username: this.$store.state.user.name, username: this.$store.state.user.name,
mountFileId: this.$store.state.user.userId !== this.file.userId ? this.file.id : '', mountFileId: this.$store.state.user.userId !== this.file.userId ? this.file.id : '',

View File

@ -344,7 +344,7 @@
fileId: file.id, fileId: file.id,
id: file.id, id: file.id,
fileName: file.name, fileName: file.name,
path: encodeURI(file.path), path: encodeURIComponent(file.path),
username: this.$store.state.user.name username: this.$store.state.user.name
} }
api[request](params).then((res) => { api[request](params).then((res) => {
@ -733,7 +733,7 @@
message: '<span>&nbsp;&nbsp;正在加载数据...</span>' message: '<span>&nbsp;&nbsp;正在加载数据...</span>'
}) })
const params = { const params = {
path: encodeURI(row.path), path: encodeURIComponent(row.path),
fileName: row.name, fileName: row.name,
username: this.$store.state.user.name username: this.$store.state.user.name
} }
@ -976,7 +976,7 @@
update(value,path,index) { update(value,path,index) {
this.updating = true this.updating = true
markdownApi.editMarkdownByPath({ markdownApi.editMarkdownByPath({
relativePath: encodeURI(path), relativePath: encodeURIComponent(path),
userId: this.$store.state.user.userId, userId: this.$store.state.user.userId,
username: this.$store.state.user.name, username: this.$store.state.user.name,
mountFileId: this.mountFileId, mountFileId: this.mountFileId,

View File

@ -36,12 +36,12 @@ export default {
// 预览文件的url // 预览文件的url
previewUrl: function(username, file, token, shareToken, serverUrl) { previewUrl: function(username, file, token, shareToken, serverUrl) {
let baseUrl = serverUrl || this.baseUrl let baseUrl = serverUrl || this.baseUrl
let fileUrl = `${baseUrl}/file/${store.getters.name}${encodeURI(file.path)}${encodeURI(file.name)}` let fileUrl = `${baseUrl}/file/${store.getters.name}${encodeURIComponent(file.path)}${encodeURIComponent(file.name)}`
fileUrl = fileUrl.replaceAll('#', '%23') fileUrl = fileUrl.replaceAll('#', '%23')
fileUrl = fileUrl.replaceAll(/%5C/g, '/') fileUrl = fileUrl.replaceAll(/%5C/g, '/')
if (file.userId !== store.getters.userId && token && !shareToken) { if (file.userId !== store.getters.userId && token && !shareToken) {
return `${baseUrl}/pre-file/${file.id}/${encodeURI(file.name)}?jmal-token=${token}&name=${username}` return `${baseUrl}/pre-file/${file.id}/${encodeURIComponent(file.name)}?jmal-token=${token}&name=${username}`
} }
if (token) { if (token) {
@ -51,12 +51,12 @@ export default {
if (isFilePath(file.id)) { if (isFilePath(file.id)) {
return `${fileUrl}?share-token=${shareToken}` return `${fileUrl}?share-token=${shareToken}`
} }
return `${baseUrl}/share-file/${file.id}/${shareToken}/${encodeURI(file.name)}` return `${baseUrl}/share-file/${file.id}/${shareToken}/${encodeURIComponent(file.name)}`
} }
if (isFilePath(file.id)) { if (isFilePath(file.id)) {
return fileUrl return fileUrl
} }
return `${baseUrl}/share-file/${file.id}/${encodeURI(file.name)}` return `${baseUrl}/share-file/${file.id}/${encodeURIComponent(file.name)}`
}, },
// 预览历史文件 // 预览历史文件
previewHistoryUrl: function(historyId, name, token) { previewHistoryUrl: function(historyId, name, token) {

View File

@ -6,6 +6,6 @@ export function encodeIfNeeded(str) {
if (isEncoded(str)) { if (isEncoded(str)) {
return str; return str;
} else { } else {
return encodeURI(str); return encodeURIComponent(str);
} }
} }

View File

@ -603,7 +603,7 @@ export default {
} }
api.rename({ api.rename({
newFileName: encodeURI(newFileName), newFileName: encodeURIComponent(newFileName),
username: this.$store.state.user.name, username: this.$store.state.user.name,
folder: this.$route.query.folder, folder: this.$route.query.folder,
id: row.id id: row.id
@ -771,7 +771,7 @@ export default {
// 浏览器的返回事件 // 浏览器的返回事件
goBack() { goBack() {
if (this.pathList.length <= 1) { if (this.pathList.length <= 1) {
this.$router.push(`/_m?vmode=${this.vmode}&path=${encodeURI(this.path)}`) this.$router.push(`/_m?vmode=${this.vmode}&path=${encodeURIComponent(this.path)}`)
return return
} }
this.clickBack() this.clickBack()
@ -881,9 +881,9 @@ export default {
let queryFolder = localStorage.getItem(this.path) let queryFolder = localStorage.getItem(this.path)
if (!unPushLink) { if (!unPushLink) {
if (!this.$route.query.path) { if (!this.$route.query.path) {
this.$router.push(`/_m?vmode=${this.vmode}&path=${encodeURI(this.path)}${queryFolder ? '&folder='+queryFolder : ''}`) this.$router.push(`/_m?vmode=${this.vmode}&path=${encodeURIComponent(this.path)}${queryFolder ? '&folder='+queryFolder : ''}`)
} else { } else {
this.$router.push(`/_m?vmode=${this.vmode}&path=${encodeURI(this.path)}${queryFolder ? '&folder='+queryFolder : ''}`) this.$router.push(`/_m?vmode=${this.vmode}&path=${encodeURIComponent(this.path)}${queryFolder ? '&folder='+queryFolder : ''}`)
} }
} }
if (!unRefresh) { if (!unRefresh) {
@ -939,7 +939,7 @@ export default {
api.fileList({ api.fileList({
username: this.$store.state.user.name, username: this.$store.state.user.name,
userId: this.$store.state.user.userId, userId: this.$store.state.user.userId,
currentDirectory: encodeURI(this.$route.query.path), currentDirectory: encodeURIComponent(this.$route.query.path),
folder: this.$route.query.folder, folder: this.$route.query.folder,
queryFileType: this.queryFileType, queryFileType: this.queryFileType,
sortableProp: this.sortableProp, sortableProp: this.sortableProp,
@ -963,7 +963,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: encodeURI(this.$route.query.path), currentDirectory: encodeURIComponent(this.$route.query.path),
pageIndex: this.pagination.pageIndex, pageIndex: this.pagination.pageIndex,
pageSize: this.pagination.pageSize pageSize: this.pagination.pageSize
}).then(res => { }).then(res => {
@ -1136,7 +1136,7 @@ export default {
this.$router.push(`?vmode=${this.vmode}${path}${keyword}${folder}`); this.$router.push(`?vmode=${this.vmode}${path}${keyword}${folder}`);
this.getFileList() this.getFileList()
} else { } else {
const path = encodeURI(this.path); const path = encodeURIComponent(this.path);
if (this.$store.getters.userId !== row.userId) { if (this.$store.getters.userId !== row.userId) {
row.mountFileId = row.id row.mountFileId = row.id
} }
@ -1280,7 +1280,7 @@ export default {
return { return {
// 传入的参数 // 传入的参数
folder: this.$route.query.folder, folder: this.$route.query.folder,
currentDirectory: encodeURI(this.path), currentDirectory: encodeURIComponent(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
} }
@ -1291,9 +1291,9 @@ export default {
if (this.newFolderName) { if (this.newFolderName) {
api.uploadFolder({ api.uploadFolder({
isFolder: true, isFolder: true,
filename: encodeURI(this.newFolderName), filename: encodeURIComponent(this.newFolderName),
folder: this.$route.query.folder, folder: this.$route.query.folder,
currentDirectory: encodeURI(this.path), currentDirectory: encodeURIComponent(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

@ -377,7 +377,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: encodeURI(this.filename + ".md"), filename: encodeURIComponent(this.filename + ".md"),
cover: this.file.cover, cover: this.file.cover,
isDraft: this.draft, isDraft: this.draft,
isRelease: this.file.release, isRelease: this.file.release,