perf: 1.优化文件夹的并发上传; 2.优化文件同步到数据库的操作

This commit is contained in:
jmal 2022-08-21 16:23:55 +08:00
parent 076236a33a
commit b3d21d50ca
15 changed files with 29 additions and 21 deletions

View File

@ -8,6 +8,13 @@ export default {
params
})
},
isSync(params) {
return request({
url: '/user/setting/isSync',
method: 'get',
params
})
},
getWebp(params) {
return request({
url: '/user/setting/get/webp',

View File

@ -1847,7 +1847,6 @@ export default {
this.officePreviewVisible = true
break
}
this.$message.success(`新建文件成功`)
const that = this
setTimeout(function () {
that.newCreateFileDialog = false
@ -2345,7 +2344,6 @@ export default {
rowRename(newFileName, row) {
//去掉回车换行
newFileName = newFileName.replace(/[\r\n]/g, "");
console.log('newFileName', newFileName)
if (newFileName) {
if (/[\[\]\/\\"<>\?\*]/gi.test(newFileName)) {
this.$message({

View File

@ -98,11 +98,11 @@
username: this.$store.state.user.name,
options: {
target: api.simpleUploadURL,
chunkSize: 3 * 1024 * 1024,
chunkSize: 1 * 1024 * 1024,
// speedSmoothingFactor: 0.1,
// progressCallbacksInterval: 500,
maxChunkRetries: 1, // 最大重试次数
simultaneousUploads: 5, // 并发上传数
maxChunkRetries: 5, // 最大重试次数
simultaneousUploads: 10, // 并发上传数
testChunks: true, // 是否开启服务器分片校验
// 服务器分片校验函数,秒传及断点续传基础
checkChunkUploadedByResponse: function(chunk, message) {

View File

@ -192,7 +192,6 @@ export default {
};
xhr.onerror = function (){
that.uploadState = 3
console.log(this.status, this.response)
}
xhr.send();
},

View File

@ -184,7 +184,6 @@ export default {
this.$emit('onReady')
},
onDocumentReady() {
console.log('onDocumentReady')
let parentDoc = document.querySelector('.component-only-office')
let doc = parentDoc.getElementsByTagName('iframe')[0].contentWindow.document
let logo = doc.querySelector('.extra .logo')

View File

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

View File

@ -183,7 +183,6 @@ export default {
}
},
onbeforeunload(event) {
console.log('event', event)
event.returnValue=("文件未保存, 确定退出吗?");
},
/**

View File

@ -167,11 +167,9 @@ export default {
this.closeBarShow = true
},
ontouchstart() {
console.log('ontouchstart', this.closeBarShow)
this.closeBarShow = true
},
ontouchsend() {
console.log('ontouchsend', this.closeBarShow)
this.closeBarShow = false
this.clearTimeout()
}

View File

@ -103,7 +103,6 @@ function findPath(menuList, to, parentPath){
}
}
if(parentPath){
console.log("parentPath", parentPath)
menu.path = parentPath + '/' + menu.path
}
if(menu.path === to) return true

View File

@ -420,7 +420,6 @@
if (height !== tmpHeight || width !== tmpWidth) {
height = tmpHeight;
width = tmpWidth;
console.log(width, height);
if (typeof callback === 'function') callback();
}
}, 250);

View File

@ -842,7 +842,6 @@
this.$refs.contextShow.hideMenu()
},
downloadFile(copy) {
console.log('downloadFile', copy)
let totalSize = 0
if(this.indexList.length > 0){
this.selectRowData.forEach(item => {

View File

@ -274,7 +274,6 @@ export default {
fileIdList.push(article.id)
})
// 修改排序
console.log(fileIdList)
markdownApi.sortMarkdown(fileIdList).then(()=>{
}).catch(() => {

View File

@ -38,6 +38,7 @@
<script>
import settingApi from "@/api/setting-api";
import Bus from "@/assets/js/bus";
export default {
data() {
@ -50,6 +51,13 @@ export default {
},
mounted() {
this.getInfo()
this.getIsSync()
Bus.$on('msg/synced', () => {
this.syncLoading = false
})
},
destroyed() {
Bus.$off()
},
methods: {
getInfo(){
@ -57,6 +65,11 @@ export default {
this.webpEnabled = !res.data
})
},
getIsSync() {
settingApi.isSync().then((res) => {
this.syncLoading = res.data
})
},
sync() {
this.$confirm('是否开始同步? ', '提示', {
confirmButtonText: '确定',
@ -65,12 +78,9 @@ export default {
}).then(() => {
this.syncLoading = true
settingApi.sync({username: this.$store.state.user.name}).then(() => {
this.syncLoading = false
}).catch(() => {
this.syncLoading = false
})
}).catch(() => {
this.syncLoading = false
})
},
// 重置角色菜单

View File

@ -203,7 +203,6 @@
},
// 确认密码
onSavePassword() {
console.log('this.validOldPass', this.validOldPass)
if(this.validOldPass){
this.$refs.passwordForm.validate((valid) => {
this.valid = valid
@ -274,7 +273,6 @@
let data = new FormData();
data.append('id', this.$store.state.user.userId)
// data.append('avatar', dataURL)
console.log(this.blobToFile(blob))
data.append('blobAvatar',blob)
this.userUpdate(data,dataURL)
},

View File

@ -33,7 +33,12 @@ function connect(username,token){
ws.isConnected = true;
// 订阅消息
ws.stompClient.subscribe('/user/queue/update', (msg) => {
Bus.$emit('msg/file/change', msg)
const url = msg.headers.url
if (url === 'synced') {
Bus.$emit('msg/synced', msg)
} else {
Bus.$emit('msg/file/change', msg)
}
}, ws.headers);
}, (err) => {
ws.isConnected = false;