mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-08 10:22:46 +00:00
Compare initial size
This commit is contained in:
@@ -13,6 +13,7 @@ class Dirent {
|
||||
this.isSelected = false; // is check or not
|
||||
this.starred = json.starred || false;
|
||||
if (json.type === 'file') {
|
||||
this.Initialsize = json.size;
|
||||
this.size = Utils.bytesToSize(json.size);
|
||||
this.is_locked = json.is_locked || false;
|
||||
this.lock_time = json.lock_time || '';
|
||||
|
@@ -6,6 +6,7 @@ class Repo {
|
||||
this.repo_name = object.repo_name;
|
||||
this.permission = object.permission;
|
||||
this.size = Utils.bytesToSize(object.size);
|
||||
this.Initialsize = object.size
|
||||
this.owner_name = object.owner_name;
|
||||
this.owner_email = object.owner_email;
|
||||
this.owner_contact_email = object.owner_contact_email;
|
||||
|
@@ -622,9 +622,7 @@ export const Utils = {
|
||||
let result = _this.compareTwoWord(a.repo_name, b.repo_name);
|
||||
return result;
|
||||
}
|
||||
|
||||
let result = _this.compareTwoSize(a.size, b.size);
|
||||
return result;
|
||||
return a.Initialsize < b.Initialsize ? -1 : 1;
|
||||
};
|
||||
break;
|
||||
case 'size-desc':
|
||||
@@ -634,8 +632,7 @@ export const Utils = {
|
||||
return -result;
|
||||
}
|
||||
|
||||
let result = _this.compareTwoSize(a.size, b.size);
|
||||
return -result;
|
||||
return a.Initialsize < b.Initialsize ? 1 : -1;
|
||||
};
|
||||
break;
|
||||
}
|
||||
@@ -676,10 +673,8 @@ export const Utils = {
|
||||
if (a.type == 'dir' && b.type == 'dir') {
|
||||
let result = _this.compareTwoWord(a.name, b.name);
|
||||
return result;
|
||||
} else {
|
||||
let result = _this.compareTwoSize(a.size, b.size);
|
||||
return result;
|
||||
}
|
||||
return a.Initialsize < b.Initialsize ? -1 : 1;
|
||||
};
|
||||
break;
|
||||
case 'size-desc':
|
||||
@@ -687,10 +682,8 @@ export const Utils = {
|
||||
if (a.type == 'dir' && b.type == 'dir') {
|
||||
let result = _this.compareTwoWord(a.name, b.name);
|
||||
return -result;
|
||||
} else {
|
||||
let result = _this.compareTwoSize(a.size, b.size);
|
||||
return -result;
|
||||
}
|
||||
return a.Initialsize < b.Initialsize ? 1 : -1;
|
||||
};
|
||||
break;
|
||||
}
|
||||
@@ -707,24 +700,6 @@ export const Utils = {
|
||||
return items;
|
||||
},
|
||||
|
||||
compareTwoSize: function(a, b) {
|
||||
let suffix = /[A-Za-z]+/g;
|
||||
let fileSizeName = /\d+(\.\d+)?/g;
|
||||
let sizes = ['bytes', 'KB', 'MB', 'GB', 'TB', 'PB'];
|
||||
|
||||
let aSuffixName = a.match(suffix)[0];
|
||||
let bSuffixName = b.match(suffix)[0];
|
||||
let aIndex = sizes.indexOf(aSuffixName);
|
||||
let bIndex = sizes.indexOf(bSuffixName);
|
||||
|
||||
let aSizeName = a.match(fileSizeName)[0];
|
||||
let bSizeName = b.match(fileSizeName)[0];
|
||||
let aBytes = aSizeName * (1000 ** aIndex);
|
||||
let bBytes = bSizeName * (1000 ** bIndex);
|
||||
|
||||
return aBytes < bBytes ? -1 : 1;
|
||||
},
|
||||
|
||||
changeMarkdownNodes: function(nodes, fn) {
|
||||
nodes.map((item) => {
|
||||
fn(item);
|
||||
|
Reference in New Issue
Block a user