浏览代码

字词卡片部首

natasha 1 年之前
父节点
当前提交
ebd7af9ffb
共有 5 个文件被更改,包括 66 次插入17 次删除
  1. 2 0
      package.json
  2. 17 0
      src/api/api.js
  3. 34 8
      src/components/corpus/Strockred.vue
  4. 6 2
      src/views/wordcard/cread.vue
  5. 7 7
      src/views/wordcard/writeTable.vue

+ 2 - 0
package.json

@@ -12,6 +12,8 @@
     "@tinymce/tinymce-vue": "^3.2.8",
     "axios": "^0.21.4",
     "canvg": "3.0.10",
+    "cnchar": "^3.2.5",
+    "cnchar-radical": "^3.2.5",
     "core-js": "^3.32.2",
     "echarts": "^5.4.3",
     "element-ui": "^2.15.14",

+ 17 - 0
src/api/api.js

@@ -467,4 +467,21 @@ export function GetFileURLMap (data) {
         method: 'post',
         data: data,
     });
+}
+export function getHZChineseInfo(data) {
+    let userInfor = getToken();
+    let UserCode = '',
+        UserType = '',
+        SessionID = ''
+    if (userInfor) {
+        let user = JSON.parse(getToken());
+        UserCode = user.user_code;
+        UserType = user.user_type;
+        SessionID = user.session_id;
+    }
+    return request({
+        url: `/GCLSHMToolsServer/api/baidu/chineseInfo?UserCode=${UserCode}&UserType=${UserType}&SessionID=${SessionID}`,
+        method: 'post',
+        data
+    })
 }

+ 34 - 8
src/components/corpus/Strockred.vue

@@ -19,7 +19,17 @@ const HanziWriter = require('hanzi-writer');
 export default {
   name: 'Strockred',
   components: {},
-  props: ['targetDiv', 'hanzicolor', 'Book_text', 'wordNum', 'tianColor', 'drawingColor', 'BoxbgType', 'fontSize'],
+  props: [
+    'targetDiv',
+    'hanzicolor',
+    'Book_text',
+    'wordNum',
+    'tianColor',
+    'drawingColor',
+    'BoxbgType',
+    'fontSize',
+    'curItem',
+  ],
   data() {
     return {
       writer: null,
@@ -66,13 +76,17 @@ export default {
       }
       let options = {
         charDataLoader: function (char, onComplete) {
-          let MethodName = 'hz_resource_manager-GetHZStrokesContent';
-          let data = {
-            hz: char,
-          };
-          getContentFile(MethodName, data).then((res) => {
-            onComplete(res);
-          });
+          if (_this.curItem) {
+            onComplete(JSON.parse(JSON.stringify(_this.curItem)));
+          } else {
+            let MethodName = 'hz_resource_manager-GetHZStrokesContent';
+            let data = {
+              hz: char,
+            };
+            getContentFile(MethodName, data).then((res) => {
+              onComplete(res);
+            });
+          }
         },
         padding: 5,
         showCharacter: false,
@@ -87,6 +101,18 @@ export default {
       let _this = this;
       _this.writer.quiz();
     },
+    handleData(stroke_num) {
+      if (this.curItem) {
+        let charData = JSON.parse(JSON.stringify(this.curItem));
+        if (stroke_num) {
+          charData.strokes = charData.strokes.slice(0, stroke_num);
+          charData.medians = charData.medians.slice(0, stroke_num);
+        } else if (charData) {
+          charData.radStrokes = [];
+        }
+        return charData;
+      }
+    },
     updateColor(color) {
       let _this = this;
       _this.writer.updateColor('strokeColor', color);

+ 6 - 2
src/views/wordcard/cread.vue

@@ -186,7 +186,8 @@ import writeTable from './writeTable.vue';
 import html2canvas from 'html2canvas';
 import { jsPDF } from 'jspdf';
 import canvg from 'canvg';
-import { pinyin } from 'pinyin-pro';
+import cnchar from 'cnchar';
+import 'cnchar-radical';
 
 import FileSaver from 'file-saver';
 import htmlDocx from 'html-docx-js/dist/html-docx';
@@ -606,7 +607,7 @@ export default {
             hz_list.push(obj);
           });
           item.hz_list = hz_list;
-          item.pinyin = pinyin(item.con);
+          item.pinyin = cnchar.spell(item.con, 'low', 'tone');
           let MethodName = 'tool-TextToVoiceFile';
           let datas = {
             text: item.con,
@@ -701,6 +702,7 @@ export default {
                         con: items.con,
                         miaoRed: true,
                         write: true,
+                        hzDetail: JSON.parse(JSON.stringify(items.hzDetail.hz_json)),
                       });
                     }
                   });
@@ -756,6 +758,7 @@ export default {
               hz_info: item.hz_list,
               pinyin: item.pinyin,
               con: item.con,
+              radical: cnchar.radical(item.con) ? cnchar.radical(item.con)[0].radical : '',
             };
             final_result.push(obj);
           } else {
@@ -770,6 +773,7 @@ export default {
               hz_info: item.hz_list,
               pinyin: item.pinyin,
               con: item.con,
+              radical: cnchar.radical(item.con) ? cnchar.radical(item.con)[0].radical : '',
             };
             final_result.push(obj);
             for (let i = data.firstPageLine; i < arr.length; i += data.pageNumber) {

+ 7 - 7
src/views/wordcard/writeTable.vue

@@ -49,7 +49,7 @@
               <div class="item-info-row">
                 <div class="item-info-half">
                   <label>偏旁:</label>
-                  <div :id="'character-target-info-div' + pageNumber"></div>
+                  <div>{{ data.radical }}</div>
                 </div>
                 <div class="item-info-half">
                   <label>笔画:</label>
@@ -375,12 +375,12 @@ export default {
   },
   //生命周期 - 挂载完成(可以访问DOM元素)
   mounted() {
-    let _this = this;
-    _this.$nextTick(() => {
-      if (_this.data.hz_info && _this.data.hz_info.length === 1) {
-        _this.initHanziwrite();
-      }
-    });
+    // let _this = this;
+    // _this.$nextTick(() => {
+    //   if (_this.data.hz_info && _this.data.hz_info.length === 1) {
+    //     _this.initHanziwrite();
+    //   }
+    // });
   },
   //生命周期-创建之前
   beforeCreated() {},