mirror of
				https://git.unlock-music.dev/um/web.git
				synced 2025-11-04 23:23:29 +08:00 
			
		
		
		
	Performance improvement in multiple files
This commit is contained in:
		
							parent
							
								
									211b4e0206
								
							
						
					
					
						commit
						92bd0f6be3
					
				
							
								
								
									
										49
									
								
								src/App.vue
									
									
									
									
									
								
							
							
						
						
									
										49
									
								
								src/App.vue
									
									
									
									
									
								
							@ -96,6 +96,19 @@
 | 
				
			|||||||
                tableData: [],
 | 
					                tableData: [],
 | 
				
			||||||
                playing_url: "",
 | 
					                playing_url: "",
 | 
				
			||||||
                playing_auto: false,
 | 
					                playing_auto: false,
 | 
				
			||||||
 | 
					                workCount: 0,
 | 
				
			||||||
 | 
					                cacheQueue: [],
 | 
				
			||||||
 | 
					                cacheQueueOption: {
 | 
				
			||||||
 | 
					                    push: (element) => {
 | 
				
			||||||
 | 
					                        this.cacheQueue.push(element);
 | 
				
			||||||
 | 
					                    },
 | 
				
			||||||
 | 
					                    pop: () => {
 | 
				
			||||||
 | 
					                        return this.cacheQueue.shift();
 | 
				
			||||||
 | 
					                    },
 | 
				
			||||||
 | 
					                    size: () => {
 | 
				
			||||||
 | 
					                        return this.cacheQueue.length;
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                },
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        },
 | 
					        },
 | 
				
			||||||
        mounted() {
 | 
					        mounted() {
 | 
				
			||||||
@ -117,9 +130,43 @@
 | 
				
			|||||||
                });
 | 
					                });
 | 
				
			||||||
            },
 | 
					            },
 | 
				
			||||||
            handleFile(file) {
 | 
					            handleFile(file) {
 | 
				
			||||||
 | 
					                // 新的文件加入
 | 
				
			||||||
 | 
					                if (file) {
 | 
				
			||||||
 | 
					                    console.log("workCount", this.workCount);
 | 
				
			||||||
 | 
					                    // 将工作数量大小限制为100
 | 
				
			||||||
 | 
					                    if (this.workCount < 100) {
 | 
				
			||||||
 | 
					                        // 工作数量增加
 | 
				
			||||||
 | 
					                        this.workCount++;
 | 
				
			||||||
 | 
					                        // 工作数量小于100  立刻处理文件
 | 
				
			||||||
 | 
					                        this.handleDoFile(file);
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                    // 工作数量大于100 则放入缓存队列
 | 
				
			||||||
 | 
					                    else {
 | 
				
			||||||
 | 
					                        this.cacheQueueOption.push(file);
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                //消费缓存队列的数据
 | 
				
			||||||
 | 
					                else {
 | 
				
			||||||
 | 
					                    this.workCount++;
 | 
				
			||||||
 | 
					                    this.handleDoFile(this.cacheQueueOption.pop());
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            },
 | 
				
			||||||
 | 
					            handleCacheQueue() {
 | 
				
			||||||
 | 
					                // 缓存队列中有数据且工作数量少于50的话 调用方法消费缓存队列中的数据
 | 
				
			||||||
 | 
					                if (this.cacheQueueOption.size() > 0 && this.workCount < 50) {
 | 
				
			||||||
 | 
					                    this.handleFile(null);
 | 
				
			||||||
 | 
					                    console.log("size", this.cacheQueueOption.size(), this.workCount);
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            },
 | 
				
			||||||
 | 
					            handleDoFile(file) {
 | 
				
			||||||
                (async () => {
 | 
					                (async () => {
 | 
				
			||||||
                    let data = await dec.CommonDecrypt(file);
 | 
					                    let data = await dec.CommonDecrypt(file);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    // 完成之后 数量减少 同时调用判断函数
 | 
				
			||||||
 | 
					                    this.workCount--;
 | 
				
			||||||
 | 
					                    this.handleCacheQueue();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                    if (data.status) {
 | 
					                    if (data.status) {
 | 
				
			||||||
                        this.tableData.push(data);
 | 
					                        this.tableData.push(data);
 | 
				
			||||||
                        this.$notify.success({
 | 
					                        this.$notify.success({
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user