AXCWG 3 сар өмнө
parent
commit
f372a878ed
5 өөрчлөгдсөн 76 нэмэгдсэн , 1 устгасан
  1. 12 0
      main.js
  2. 0 0
      op.json
  3. 56 0
      package-lock.json
  4. 2 0
      package.json
  5. 6 1
      test.js

+ 12 - 0
main.js

@@ -7,6 +7,8 @@ const SendSeekable = require('send-seekable');
 const pool = mysql.createPool({
     keepAliveInitialDelay: 0, enableKeepAlive: true,
 })
+const cnchar = require('cnchar');
+const sort = require('sort-array')
 
 const Kind = {
     0: "去和声伴奏",
@@ -39,6 +41,7 @@ const nrc = require('node-run-cmd')
 const https = require("node:https");
 const {OpenCC} = require("opencc");
 const {HttpsProxyAgent} = require("https-proxy-agent");
+const sortArray = require("sort-array");
 const converters2t = new OpenCC('s2t.json')
 const convertert2s = new OpenCC('t2s.json')
 app.use(bodyParser.json({"limit": "200mb"}));
@@ -325,6 +328,15 @@ app.post('/search_api', async function (req, res) {
                         prepare = prepare.concat(row);
                     }
                 })
+                for (let obj of prepare) {
+                    obj.stroke = obj.song_name[0].stroke() // Problematic as shit. Do not use.
+                    obj.spell = obj.song_name.spell()
+                }
+                sortArray(prepare, {
+                    by: 'spell'
+                })
+                fs.writeFileSync("op.json", JSON.stringify(prepare))
+
                 res.header("Access-Control-Allow-Origin", "*");
 
                 res.end(JSON.stringify(prepare));

Файлын зөрүү хэтэрхий том тул дарагдсан байна
+ 0 - 0
op.json


+ 56 - 0
package-lock.json

@@ -10,6 +10,7 @@
       "license": "MIT",
       "dependencies": {
         "body-parser": "^1.20.3",
+        "cnchar": "^3.2.6",
         "express": "^4.21.1",
         "html-entities": "^2.5.2",
         "https": "^1.0.0",
@@ -22,6 +23,7 @@
         "nodemailer": "^6.9.16",
         "opencc": "github:BYVoid/OpenCC",
         "send-seekable": "^1.0.4",
+        "sort-array": "^5.0.0",
         "sqlite3": "^5.1.7",
         "webp-converter": "^2.3.3",
         "webp-converter-browser": "^1.0.4",
@@ -261,6 +263,15 @@
         "node": "^12.13.0 || ^14.15.0 || >=16.0.0"
       }
     },
+    "node_modules/array-back": {
+      "version": "6.2.2",
+      "resolved": "https://registry.npmjs.org/array-back/-/array-back-6.2.2.tgz",
+      "integrity": "sha512-gUAZ7HPyb4SJczXAMUXMGAvI976JoK3qEx9v1FTmeYuJj0IBiaKttG1ydtGKdkfqWkIkouke7nG8ufGy77+Cvw==",
+      "license": "MIT",
+      "engines": {
+        "node": ">=12.17"
+      }
+    },
     "node_modules/array-flatten": {
       "version": "1.1.1",
       "resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz",
@@ -484,6 +495,21 @@
         "node": ">=6"
       }
     },
+    "node_modules/cnchar": {
+      "version": "3.2.6",
+      "resolved": "https://registry.npmjs.org/cnchar/-/cnchar-3.2.6.tgz",
+      "integrity": "sha512-7Up5ALAkoOTAHlRMN0B7VgrrRsp6+trgFV0M7xSsZ0TwnnBfW68gXClcE9Oz8sTOEu+zqGOZjBhlHNzPIBckDA==",
+      "license": "MIT",
+      "dependencies": {
+        "cnchar-types": "^3.2.6"
+      }
+    },
+    "node_modules/cnchar-types": {
+      "version": "3.2.6",
+      "resolved": "https://registry.npmjs.org/cnchar-types/-/cnchar-types-3.2.6.tgz",
+      "integrity": "sha512-LGU2ss7KcsI1Psme73+jffUX0ZDuChr6P9Rj2j8lynJHStklNpoC/+kheKSSUcXQ1u2KNvZt1Shs/5efcihHkg==",
+      "license": "MIT"
+    },
     "node_modules/color-support": {
       "version": "1.1.3",
       "resolved": "https://registry.npmjs.org/color-support/-/color-support-1.1.3.tgz",
@@ -2353,6 +2379,27 @@
         "node": ">= 10"
       }
     },
+    "node_modules/sort-array": {
+      "version": "5.0.0",
+      "resolved": "https://registry.npmjs.org/sort-array/-/sort-array-5.0.0.tgz",
+      "integrity": "sha512-Sg9MzajSGprcSrMIxsXyNT0e0JB47RJRfJspC+7co4Z5BdNsNl8FmWI+lXEpyKq+vkMG6pHgAhqyCO+bkDTfFQ==",
+      "license": "MIT",
+      "dependencies": {
+        "array-back": "^6.2.2",
+        "typical": "^7.1.1"
+      },
+      "engines": {
+        "node": ">=12.17"
+      },
+      "peerDependencies": {
+        "@75lb/nature": "^0.1.1"
+      },
+      "peerDependenciesMeta": {
+        "@75lb/nature": {
+          "optional": true
+        }
+      }
+    },
     "node_modules/sprintf-js": {
       "version": "1.1.3",
       "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.1.3.tgz",
@@ -2575,6 +2622,15 @@
         "node": ">= 0.6"
       }
     },
+    "node_modules/typical": {
+      "version": "7.3.0",
+      "resolved": "https://registry.npmjs.org/typical/-/typical-7.3.0.tgz",
+      "integrity": "sha512-ya4mg/30vm+DOWfBg4YK3j2WD6TWtRkCbasOJr40CseYENzCUby/7rIvXA99JGsQHeNxLbnXdyLLxKSv3tauFw==",
+      "license": "MIT",
+      "engines": {
+        "node": ">=12.17"
+      }
+    },
     "node_modules/unique-filename": {
       "version": "1.1.1",
       "resolved": "https://registry.npmjs.org/unique-filename/-/unique-filename-1.1.1.tgz",

+ 2 - 0
package.json

@@ -13,6 +13,7 @@
   "description": "",
   "dependencies": {
     "body-parser": "^1.20.3",
+    "cnchar": "^3.2.6",
     "express": "^4.21.1",
     "html-entities": "^2.5.2",
     "https": "^1.0.0",
@@ -25,6 +26,7 @@
     "nodemailer": "^6.9.16",
     "opencc": "github:BYVoid/OpenCC",
     "send-seekable": "^1.0.4",
+    "sort-array": "^5.0.0",
     "sqlite3": "^5.1.7",
     "webp-converter": "^2.3.3",
     "webp-converter-browser": "^1.0.4",

+ 6 - 1
test.js

@@ -2,5 +2,10 @@ let queue = require('js-queue')
 const req = require("express/lib/request");
 let queue1 = new queue();
 queue1.autoRun = false;
+const cnchar = require('cnchar');
+const sortArray = require("sort-array");
 
-console.log("dwasdwa" === ("dwsdwa" || "dwasdwa" || "dwa2112sdwa"))
+
+
+cnchar.setStrokeCount("愛", 13)
+console.log("愛".stroke())

Энэ ялгаанд хэт олон файл өөрчлөгдсөн тул зарим файлыг харуулаагүй болно