1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-05 08:53:14 +00:00

optimization code

This commit is contained in:
zxj96
2019-05-29 14:43:22 +08:00
parent 8eba860bcb
commit 835fcb8ddb
2 changed files with 7 additions and 11 deletions

View File

@@ -699,7 +699,7 @@ export const Utils = {
compareTwoSize: function(a, b) {
let suffix = /[A-Za-z]+/g;
let fileSizeName = /(\-|\+)?\d+(\.\d+)?/g;
let fileSizeName = /\d+(\.\d+)?/g;
let sizes = ['bytes', 'KB', 'MB', 'GB', 'TB', 'PB'];
let aSuffixName = a.match(suffix)[0];
@@ -707,16 +707,12 @@ export const Utils = {
let aIndex = sizes.indexOf(aSuffixName);
let bIndex = sizes.indexOf(bSuffixName);
if (aIndex === bIndex) {
let aFileName = a.match(fileSizeName)[0];
let bFileName = b.match(fileSizeName)[0];
let aBytes = aFileName * (1000 ** aIndex);
let bBytes = bFileName * (1000 ** bIndex);
return aBytes < bBytes ? -1 : 1;
} else {
return aIndex < bIndex ? -1 : 1;
}
let aFileName = a.match(fileSizeName)[0];
let bFileName = b.match(fileSizeName)[0];
let aBytes = aFileName * (1000 ** aIndex);
let bBytes = bFileName * (1000 ** bIndex);
return aBytes < bBytes ? -1 : 1;
},
changeMarkdownNodes: function(nodes, fn) {