chengjie 2 months ago
parent
commit
c70976b68a
1 changed files with 22 additions and 2 deletions
  1. 22 2
      src/api/miaoguo/literacyController.js

+ 22 - 2
src/api/miaoguo/literacyController.js

@@ -38,6 +38,7 @@ export async function GetMiaoguoAISearch(ctx) {
38 38
         if (literacyItem && literacyItem.length>0){
39 39
             //console.log("Old Word");
40 40
             //console.log("2:"+moment().format("mm:ss"));
41
+            
41 42
             for(let i=0;i<literacyItem.length;i++){
42 43
                 if (literacyItem[i].SearchType=="list"){
43 44
                     literacyItem[0]=literacyItem[i];
@@ -49,6 +50,10 @@ export async function GetMiaoguoAISearch(ctx) {
49 50
             if (param.SearchType!="list" && literacyItem.length>1){
50 51
                 result=[];
51 52
                 param.SearchType="list";
53
+                result={};
54
+                result.HanZi=param.Word;
55
+                result.List=[];
56
+                
52 57
                 for(let i=0;i<literacyItem.length;i++){
53 58
                     let obj={};
54 59
                     if (literacyItem[i].SearchType=="zici"){
@@ -61,10 +66,25 @@ export async function GetMiaoguoAISearch(ctx) {
61 66
                         obj.Key=param.Word;
62 67
                         obj.TypeName="翻译";
63 68
                     }
64
-                    result.push(obj);
69
+                    result.List.push(obj);
65 70
                 }
66 71
             }
67 72
 
73
+            let bExistZici=false;
74
+            for(let i=0;i<literacyItem.length;i++){
75
+                if (literacyItem[i].SearchType=="zici"){
76
+                    bExistZici=true;
77
+                    break;
78
+                }
79
+            }
80
+            if (param.SearchType=="list" && stringUtils.IsChinese(param.Word) && param.Word.length>=2 && !bExistZici) {
81
+                let obj={};
82
+                obj.Type="zici";
83
+                obj.Key=param.Word;
84
+                obj.TypeName="字词";
85
+                result.List.push(obj);
86
+            }
87
+
68 88
             if (param.SearchType!="list"){
69 89
                 //console.log(literacyItem[0].JSONString);
70 90
                 literacyItem[0].JSONString=stringUtils.ReplaceAllString(literacyItem[0].JSONString,"&#x27;","ˈ");
@@ -460,7 +480,7 @@ async function getAiDataEng(word){
460 480
     
461 481
     result=JSON.parse(result);
462 482
 
463
-    if (result.ENG.Soundmark){
483
+    if (result.ENG && result.ENG.Soundmark){
464 484
         result.ENG.Soundmark.EngSound="https://sp0.baidu.com/-rM1hT4a2gU2pMbgoY3K/gettts?lan=uk&text="+result.ENG.Word+"&spd=3&source=alading";
465 485
         result.ENG.Soundmark.AmESound="https://sp0.baidu.com/-rM1hT4a2gU2pMbgoY3K/gettts?lan=en&text="+result.ENG.Word+"&spd=3&source=alading";
466 486
     }