Ver Fonte

完善简繁转换

qinpeng há 2 anos atrás
pai
commit
aeef46eeaa
3 ficheiros alterados com 15 adições e 4 exclusões
  1. 5 0
      package-lock.json
  2. 1 0
      package.json
  3. 9 4
      src/views/corpus/Result.vue

+ 5 - 0
package-lock.json

@@ -8753,6 +8753,11 @@
         "is-wsl": "^1.1.0"
       }
     },
+    "opencc-js": {
+      "version": "1.0.4",
+      "resolved": "https://registry.npmmirror.com/opencc-js/-/opencc-js-1.0.4.tgz",
+      "integrity": "sha512-0vPnzCrUhmEKDakju7prFD851PW4LPyOMBUCx4g9ndu6s0X4s9bULJRe/Ns+kZVh9i7qPhC53xm4HeON1hHpVg=="
+    },
     "opener": {
       "version": "1.5.2",
       "resolved": "https://registry.npm.taobao.org/opener/download/opener-1.5.2.tgz",

+ 1 - 0
package.json

@@ -23,6 +23,7 @@
     "mockjs": "^1.1.0",
     "node-sass": "^4.14.1",
     "nprogress": "^0.2.0",
+    "opencc-js": "^1.0.4",
     "sass-loader": "^9.0.0",
     "script-ext-html-webpack-plugin": "^2.1.5",
     "script-loader": "^0.7.2",

+ 9 - 4
src/views/corpus/Result.vue

@@ -77,7 +77,8 @@ import Strockplayredline from "@/components/corpus/Strockplayredline";
 import "@/utils/pinyin_dict_withtone";
 import "@/utils/pinyinUtil";
 import seekWord from "@/utils/lang.js";
-
+const OpenCC = require("opencc-js");
+const converter = OpenCC.Converter({ from: "cn", to: "tw" });
 export default {
   //import引入的组件需要注入到对象中才能使用
   components: {
@@ -117,7 +118,9 @@ export default {
       } else {
         //繁体
         this.hzData.forEach((item) => {
-          let a = seekWord(item.con);
+          // let a = seekWord(item.con);
+          // item.fanti = a;
+          let a = converter(item.con);
           item.fanti = a;
         });
         this.gethzJSON();
@@ -127,7 +130,7 @@ export default {
     gethzJSON() {
       this.loading = true;
       let MethodName = "hz_resource_manager-GetHZStrokesContent";
-      this.hzData.forEach((item) => {
+      this.hzData.forEach((item, i) => {
         let data = {
           hz: this.JFIndex == 0 ? item.con : item.fanti,
         };
@@ -138,7 +141,9 @@ export default {
           .then((res) => {
             this.$set(item.hzDetail, "hz_json", res);
             this.ShowHzData = JSON.parse(JSON.stringify(this.hzData));
-            this.loading = false;
+            if (i == this.hzData.length - 1) {
+              this.loading = false;
+            }
           })
           .catch(() => {
             this.loading = false;