mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-10 11:21:29 +00:00
optimization code
This commit is contained in:
@@ -24,7 +24,7 @@ class MyLibraries extends Component {
|
|||||||
isLoading: true,
|
isLoading: true,
|
||||||
repoList: [],
|
repoList: [],
|
||||||
isShowDetails: false,
|
isShowDetails: false,
|
||||||
sortBy: cookie.load('seafile-repo-dir-sort-by') || 'name', // 'name' or 'time' or size
|
sortBy: cookie.load('seafile-repo-dir-sort-by') || 'name', // 'name' or 'time' or 'size'
|
||||||
sortOrder: cookie.load('seafile-repo-dir-sort-order') || 'asc', // 'asc' or 'desc'
|
sortOrder: cookie.load('seafile-repo-dir-sort-order') || 'asc', // 'asc' or 'desc'
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -699,7 +699,7 @@ export const Utils = {
|
|||||||
|
|
||||||
compareTwoSize: function(a, b) {
|
compareTwoSize: function(a, b) {
|
||||||
let suffix = /[A-Za-z]+/g;
|
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 sizes = ['bytes', 'KB', 'MB', 'GB', 'TB', 'PB'];
|
||||||
|
|
||||||
let aSuffixName = a.match(suffix)[0];
|
let aSuffixName = a.match(suffix)[0];
|
||||||
@@ -707,16 +707,12 @@ export const Utils = {
|
|||||||
let aIndex = sizes.indexOf(aSuffixName);
|
let aIndex = sizes.indexOf(aSuffixName);
|
||||||
let bIndex = sizes.indexOf(bSuffixName);
|
let bIndex = sizes.indexOf(bSuffixName);
|
||||||
|
|
||||||
if (aIndex === bIndex) {
|
|
||||||
let aFileName = a.match(fileSizeName)[0];
|
let aFileName = a.match(fileSizeName)[0];
|
||||||
let bFileName = b.match(fileSizeName)[0];
|
let bFileName = b.match(fileSizeName)[0];
|
||||||
let aBytes = aFileName * (1000 ** aIndex);
|
let aBytes = aFileName * (1000 ** aIndex);
|
||||||
let bBytes = bFileName * (1000 ** bIndex);
|
let bBytes = bFileName * (1000 ** bIndex);
|
||||||
return aBytes < bBytes ? -1 : 1;
|
|
||||||
} else {
|
|
||||||
return aIndex < bIndex ? -1 : 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
return aBytes < bBytes ? -1 : 1;
|
||||||
},
|
},
|
||||||
|
|
||||||
changeMarkdownNodes: function(nodes, fn) {
|
changeMarkdownNodes: function(nodes, fn) {
|
||||||
|
Reference in New Issue
Block a user