Browse Source

拼音排序

11wqe1 5 days ago
parent
commit
a6e0f388b0
3 changed files with 136 additions and 1 deletions
  1. 120 0
      package-lock.json
  2. 1 0
      package.json
  3. 15 1
      src/views/login/loginPage.vue

+ 120 - 0
package-lock.json

@@ -15,6 +15,7 @@
         "js-cookie": "^3.0.5",
         "nprogress": "^0.2.0",
         "pblAdminTable": "file:",
+        "pinyin": "^4.0.0",
         "qrcode": "^1.5.4",
         "userManage": "file:",
         "vue": "^2.6.14",
@@ -6998,6 +6999,12 @@
         "graceful-fs": "^4.1.6"
       }
     },
+    "node_modules/keypress": {
+      "version": "0.1.0",
+      "resolved": "https://registry.npmmirror.com/keypress/-/keypress-0.1.0.tgz",
+      "integrity": "sha512-x0yf9PL/nx9Nw9oLL8ZVErFAk85/lslwEP7Vz7s5SI1ODXZIgit3C5qyWjw4DxOuO/3Hb4866SQh28a1V1d+WA==",
+      "license": "MIT"
+    },
     "node_modules/keyv": {
       "version": "4.5.4",
       "resolved": "https://registry.npmmirror.com/keyv/-/keyv-4.5.4.tgz",
@@ -8226,6 +8233,48 @@
         "url": "https://github.com/sponsors/jonschlinkert"
       }
     },
+    "node_modules/pinyin": {
+      "version": "4.0.0",
+      "resolved": "https://registry.npmmirror.com/pinyin/-/pinyin-4.0.0.tgz",
+      "integrity": "sha512-vHpV5K+vpp6XUUpZNGRDuHoN+1xcmieM3EWlH4QjSX2kkpG/gVOwpqwV9EOJ9x9c9UERFKeLml5XVSukE/PLgQ==",
+      "license": "MIT",
+      "dependencies": {
+        "commander": "~1.1.1"
+      },
+      "bin": {
+        "pinyin": "bin/pinyin"
+      },
+      "engines": {
+        "install-node": "^18.0.0"
+      },
+      "peerDependencies": {
+        "@node-rs/jieba": "^1.6.0",
+        "nodejieba": "^3.4.4",
+        "segmentit": "^2.0.3"
+      },
+      "peerDependenciesMeta": {
+        "@node-rs/jieba": {
+          "optional": true
+        },
+        "nodejieba": {
+          "optional": true
+        },
+        "segmentit": {
+          "optional": true
+        }
+      }
+    },
+    "node_modules/pinyin/node_modules/commander": {
+      "version": "1.1.1",
+      "resolved": "https://registry.npmmirror.com/commander/-/commander-1.1.1.tgz",
+      "integrity": "sha512-71Rod2AhcH3JhkBikVpNd0pA+fWsmAaVoti6OR38T76chA7vE3pSerS0Jor4wDw+tOueD2zLVvFOw5H0Rcj7rA==",
+      "dependencies": {
+        "keypress": "0.1.x"
+      },
+      "engines": {
+        "node": ">= 0.6.x"
+      }
+    },
     "node_modules/pkg-dir": {
       "version": "4.2.0",
       "resolved": "https://registry.npmmirror.com/pkg-dir/-/pkg-dir-4.2.0.tgz",
@@ -16638,6 +16687,11 @@
         "universalify": "^2.0.0"
       }
     },
+    "keypress": {
+      "version": "0.1.0",
+      "resolved": "https://registry.npmmirror.com/keypress/-/keypress-0.1.0.tgz",
+      "integrity": "sha512-x0yf9PL/nx9Nw9oLL8ZVErFAk85/lslwEP7Vz7s5SI1ODXZIgit3C5qyWjw4DxOuO/3Hb4866SQh28a1V1d+WA=="
+    },
     "keyv": {
       "version": "4.5.4",
       "resolved": "https://registry.npmmirror.com/keyv/-/keyv-4.5.4.tgz",
@@ -17584,6 +17638,7 @@
         "js-cookie": "^3.0.5",
         "nprogress": "^0.2.0",
         "pblAdminTable": "file:",
+        "pinyin": "^4.0.0",
         "qrcode": "^1.5.4",
         "userManage": "file:",
         "vue": "^2.6.14",
@@ -22734,6 +22789,11 @@
             "universalify": "^2.0.0"
           }
         },
+        "keypress": {
+          "version": "0.1.0",
+          "resolved": "https://registry.npmmirror.com/keypress/-/keypress-0.1.0.tgz",
+          "integrity": "sha512-x0yf9PL/nx9Nw9oLL8ZVErFAk85/lslwEP7Vz7s5SI1ODXZIgit3C5qyWjw4DxOuO/3Hb4866SQh28a1V1d+WA=="
+        },
         "keyv": {
           "version": "4.5.4",
           "resolved": "https://registry.npmmirror.com/keyv/-/keyv-4.5.4.tgz",
@@ -23672,6 +23732,24 @@
           "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==",
           "dev": true
         },
+        "pinyin": {
+          "version": "4.0.0",
+          "resolved": "https://registry.npmmirror.com/pinyin/-/pinyin-4.0.0.tgz",
+          "integrity": "sha512-vHpV5K+vpp6XUUpZNGRDuHoN+1xcmieM3EWlH4QjSX2kkpG/gVOwpqwV9EOJ9x9c9UERFKeLml5XVSukE/PLgQ==",
+          "requires": {
+            "commander": "~1.1.1"
+          },
+          "dependencies": {
+            "commander": {
+              "version": "1.1.1",
+              "resolved": "https://registry.npmmirror.com/commander/-/commander-1.1.1.tgz",
+              "integrity": "sha512-71Rod2AhcH3JhkBikVpNd0pA+fWsmAaVoti6OR38T76chA7vE3pSerS0Jor4wDw+tOueD2zLVvFOw5H0Rcj7rA==",
+              "requires": {
+                "keypress": "0.1.x"
+              }
+            }
+          }
+        },
         "pkg-dir": {
           "version": "4.2.0",
           "resolved": "https://registry.npmmirror.com/pkg-dir/-/pkg-dir-4.2.0.tgz",
@@ -26065,6 +26143,24 @@
       "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==",
       "dev": true
     },
+    "pinyin": {
+      "version": "4.0.0",
+      "resolved": "https://registry.npmmirror.com/pinyin/-/pinyin-4.0.0.tgz",
+      "integrity": "sha512-vHpV5K+vpp6XUUpZNGRDuHoN+1xcmieM3EWlH4QjSX2kkpG/gVOwpqwV9EOJ9x9c9UERFKeLml5XVSukE/PLgQ==",
+      "requires": {
+        "commander": "~1.1.1"
+      },
+      "dependencies": {
+        "commander": {
+          "version": "1.1.1",
+          "resolved": "https://registry.npmmirror.com/commander/-/commander-1.1.1.tgz",
+          "integrity": "sha512-71Rod2AhcH3JhkBikVpNd0pA+fWsmAaVoti6OR38T76chA7vE3pSerS0Jor4wDw+tOueD2zLVvFOw5H0Rcj7rA==",
+          "requires": {
+            "keypress": "0.1.x"
+          }
+        }
+      }
+    },
     "pkg-dir": {
       "version": "4.2.0",
       "resolved": "https://registry.npmmirror.com/pkg-dir/-/pkg-dir-4.2.0.tgz",
@@ -27776,6 +27872,7 @@
         "js-cookie": "^3.0.5",
         "nprogress": "^0.2.0",
         "pblAdminTable": "file:",
+        "pinyin": "^4.0.0",
         "qrcode": "^1.5.4",
         "userManage": "file:",
         "vue": "^2.6.14",
@@ -32926,6 +33023,11 @@
             "universalify": "^2.0.0"
           }
         },
+        "keypress": {
+          "version": "0.1.0",
+          "resolved": "https://registry.npmmirror.com/keypress/-/keypress-0.1.0.tgz",
+          "integrity": "sha512-x0yf9PL/nx9Nw9oLL8ZVErFAk85/lslwEP7Vz7s5SI1ODXZIgit3C5qyWjw4DxOuO/3Hb4866SQh28a1V1d+WA=="
+        },
         "keyv": {
           "version": "4.5.4",
           "resolved": "https://registry.npmmirror.com/keyv/-/keyv-4.5.4.tgz",
@@ -33864,6 +33966,24 @@
           "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==",
           "dev": true
         },
+        "pinyin": {
+          "version": "4.0.0",
+          "resolved": "https://registry.npmmirror.com/pinyin/-/pinyin-4.0.0.tgz",
+          "integrity": "sha512-vHpV5K+vpp6XUUpZNGRDuHoN+1xcmieM3EWlH4QjSX2kkpG/gVOwpqwV9EOJ9x9c9UERFKeLml5XVSukE/PLgQ==",
+          "requires": {
+            "commander": "~1.1.1"
+          },
+          "dependencies": {
+            "commander": {
+              "version": "1.1.1",
+              "resolved": "https://registry.npmmirror.com/commander/-/commander-1.1.1.tgz",
+              "integrity": "sha512-71Rod2AhcH3JhkBikVpNd0pA+fWsmAaVoti6OR38T76chA7vE3pSerS0Jor4wDw+tOueD2zLVvFOw5H0Rcj7rA==",
+              "requires": {
+                "keypress": "0.1.x"
+              }
+            }
+          }
+        },
         "pkg-dir": {
           "version": "4.2.0",
           "resolved": "https://registry.npmmirror.com/pkg-dir/-/pkg-dir-4.2.0.tgz",

+ 1 - 0
package.json

@@ -16,6 +16,7 @@
     "js-cookie": "^3.0.5",
     "nprogress": "^0.2.0",
     "pblAdminTable": "file:",
+    "pinyin": "^4.0.0",
     "qrcode": "^1.5.4",
     "userManage": "file:",
     "vue": "^2.6.14",

+ 15 - 1
src/views/login/loginPage.vue

@@ -338,6 +338,8 @@ import { API_CONFIG } from "@/common/apiConfig";
 import "@/common/wxLogin";
 import { getUser, loginOut, GetSuffix } from "@/api/user";
 import { myMixin } from "@/mixins/mixin.js";
+import pinyin from 'pinyin';
+
 
 export default {
 	mixins: [myMixin],
@@ -1098,13 +1100,25 @@ export default {
 			this.$ajax
 				.post(API_CONFIG.baseUrl, params)
 				.then((res) => {
-					this.classJuri = res.data[0];
+					// this.classJuri = res.data[0];
+
+					this.classJuri = this.groupByName(res.data[0])
+					console.log('this.classJuri',this.classJuri);
+						
 					this.steps = 2;
 				})
 				.catch((err) => {
 					console.error(err);
 				});
 		},
+		
+		groupByName(list) {
+			return list.sort((a, b) => {
+				const pinyinA = pinyin(a.username, { style: pinyin.STYLE_NORMAL }).join('');
+				const pinyinB = pinyin(b.username, { style: pinyin.STYLE_NORMAL }).join('');
+				return pinyinA.localeCompare(pinyinB);
+			});
+		},
 		// 选择学生账户
 		selAcc(val) {
 			console.log("val", val);