fix: 修复windows下的问题

This commit is contained in:
jmal 2023-05-03 11:58:25 +08:00
parent 571b7a8a32
commit 092a0084d0
4 changed files with 17 additions and 9 deletions

View File

@ -973,7 +973,7 @@ export default {
this.selectPin = true this.selectPin = true
} }
// ctrl + A / cmd + A // ctrl + A / cmd + A
if (this.isCmd && keyCode == 65) { if (this.isCmd && keyCode === 65) {
if (this.inputting || this.editingIndex !== -1) { if (this.inputting || this.editingIndex !== -1) {
event.target.select() event.target.select()
} else { } else {
@ -999,7 +999,6 @@ export default {
onmessageFault(msg) { onmessageFault(msg) {
if ('fault' === msg) { if ('fault' === msg) {
this.getFileList() this.getFileList()
return
} }
}, },
onmessage(msg) { onmessage(msg) {
@ -1024,10 +1023,14 @@ export default {
} }
if (fileDoc) { if (fileDoc) {
if (fileDoc.$set) { if (fileDoc.$set) {
if (this.path + '/' === fileDoc.$set.path) { let path = fileDoc.$set.path
path = path.replace(/\\/g, '/')
if (this.path + '/' === path) {
this.getFileList() this.getFileList()
} }
} else { } else {
let path = fileDoc.path
path = path.replace(/\\/g, '/')
if (this.path + '/' === fileDoc.path) { if (this.path + '/' === fileDoc.path) {
this.getFileList() this.getFileList()
} }
@ -1740,6 +1743,7 @@ export default {
} else { } else {
this.path += '/' + this.pathList[number].folder this.path += '/' + this.pathList[number].folder
} }
this.path = this.path.replace(/\\/g, '/')
}) })
if (!unPushLink) { if (!unPushLink) {
if (!this.$route.query.path) { if (!this.$route.query.path) {
@ -2069,6 +2073,7 @@ export default {
this.listModeSearchOpenDir = row this.listModeSearchOpenDir = row
}) })
this.path = row.path + row.name this.path = row.path + row.name
this.path = this.path.replace(/\\/g, '/')
}, },
openDir(row, onLoad) { openDir(row, onLoad) {
this.beforeLoadData(onLoad) this.beforeLoadData(onLoad)
@ -2083,6 +2088,7 @@ export default {
this.loadData(res, onLoad) this.loadData(res, onLoad)
}) })
this.path = row.path + row.name this.path = row.path + row.name
this.path = this.path.replace(/\\/g, '/')
}, },
getFileList(onLoad) { getFileList(onLoad) {
this.beforeLoadData(onLoad) this.beforeLoadData(onLoad)

View File

@ -175,7 +175,7 @@ export default {
this.fileList = fileList this.fileList = fileList
}, },
format(filepath){ format(filepath){
this.currentValue = fileConfig.mardownPreviewUrl(filepath) this.currentValue = fileConfig.markdownPreviewUrl(filepath)
this.change(this.currentValue) this.change(this.currentValue)
}, },
// url转blob // url转blob

View File

@ -21,6 +21,7 @@ export default {
// 预览文件的url // 预览文件的url
previewUrl: function(username, file, token, shareToken) { previewUrl: function(username, file, token, shareToken) {
let fileUrl = `${this.baseUrl}/file/${username}${encodeURI(file.path)}${encodeURI(file.name)}` let fileUrl = `${this.baseUrl}/file/${username}${encodeURI(file.path)}${encodeURI(file.name)}`
fileUrl = fileUrl.replace(/%5C/g, '/')
if (token) { if (token) {
return `${fileUrl}?jmal-token=${token}&name=${username}` return `${fileUrl}?jmal-token=${token}&name=${username}`
} }
@ -29,13 +30,14 @@ export default {
} }
return fileUrl return fileUrl
}, },
// mardown里上传图片后的图片预览地址 // markdown里上传图片后的图片预览地址
mardownPreviewUrl: function (path){ markdownPreviewUrl: function (path){
return window.location.origin + `${this.baseUrl}${path}` return window.location.origin + `${this.baseUrl}${path}`
}, },
// 预览文件 // 预览文件
preview: function(username, file, token) { preview: function(username, file, token) {
const url = this.previewUrl(username, file, token) let url = this.previewUrl(username, file, token)
url = url.replace(/%5C/g, '/')
window.open(url, '_blank') window.open(url, '_blank')
}, },
// 下载文件 // 下载文件

View File

@ -393,7 +393,7 @@ export default {
let response = JSON.parse(responseText) let response = JSON.parse(responseText)
let succMap = {} let succMap = {}
response.data.forEach(map => { response.data.forEach(map => {
succMap[map.filename] = fileConfig.mardownPreviewUrl(map.filepath) succMap[map.filename] = fileConfig.markdownPreviewUrl(map.filepath)
}) })
response.data = {} response.data = {}
response.data['succMap'] = succMap response.data['succMap'] = succMap
@ -405,7 +405,7 @@ export default {
linkToImgUrl: '/api/upload-markdown-link-image', linkToImgUrl: '/api/upload-markdown-link-image',
linkToImgFormat(responseText) { linkToImgFormat(responseText) {
let response = JSON.parse(responseText) let response = JSON.parse(responseText)
response.data['url'] = fileConfig.mardownPreviewUrl(response.data.url) response.data['url'] = fileConfig.markdownPreviewUrl(response.data.url)
return JSON.stringify(response) return JSON.stringify(response)
}, },
} }