|
@@ -912,12 +912,43 @@ export default {
|
|
sort(){
|
|
sort(){
|
|
console.log(this.fileList);
|
|
console.log(this.fileList);
|
|
},
|
|
},
|
|
|
|
+ containsChinese(str) {
|
|
|
|
+ for (let i = 0; i < str.length; i++) {
|
|
|
|
+ const charCode = str.charCodeAt(i);
|
|
|
|
+ // 基本的中文范围
|
|
|
|
+ if (charCode >= 0x4e00 && charCode <= 0x9fff) {
|
|
|
|
+ return true;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return false;
|
|
|
|
+ },
|
|
|
|
+ contrastStr(str, str2) {
|
|
|
|
+ let length = str.length;
|
|
|
|
+ let length2 = str.length;
|
|
|
|
+ let rLength = length < length2 ? length : length2;
|
|
|
|
+
|
|
|
|
+ let charCodeA = str.charCodeAt(0);
|
|
|
|
+ let charCodeB = str2.charCodeAt(0);
|
|
|
|
+
|
|
|
|
+ for(let i = 0; i < rLength; i++){
|
|
|
|
+ if(str[i] == str2[i]){
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ },
|
|
sortAsc(){
|
|
sortAsc(){
|
|
const collator = new Intl.Collator('zh-Hans-CN', { sensitivity: 'case', numeric: false });
|
|
const collator = new Intl.Collator('zh-Hans-CN', { sensitivity: 'case', numeric: false });
|
|
// this.fileList.sort(collator.compare);
|
|
// this.fileList.sort(collator.compare);
|
|
this.fileList.sort((a, b) => {
|
|
this.fileList.sort((a, b) => {
|
|
- console.log(a.name, '--->', b.name, a.name.localeCompare(b.name));
|
|
|
|
- return a.name.localeCompare(b.name)
|
|
|
|
|
|
+ let charCodeA = a.name.charCodeAt(0);
|
|
|
|
+ let charCodeB = b.name.charCodeAt(0);
|
|
|
|
+ if(charCodeA >= 0x4e00 && charCodeA <= 0x9fff && charCodeB >= 0x4e00 && charCodeB <= 0x9fff){
|
|
|
|
+ console.log(a.name, '--->', b.name, '==cn==', a.name.localeCompare(b.name, 'zh-CN'));
|
|
|
|
+ return a.name.localeCompare(b.name, 'zh-CN', {sensitivity: 'base'});
|
|
|
|
+ }
|
|
|
|
+ console.log(a.name, '--->', b.name, '==en==', a.name.localeCompare(b.name, 'en-US'));
|
|
|
|
+ return a.name.localeCompare(b.name, 'en-US', {sensitivity: 'base'});
|
|
})
|
|
})
|
|
|
|
|
|
// this.fileList.sort((a, b) => {
|
|
// this.fileList.sort((a, b) => {
|