|
|
@@ -136,6 +136,7 @@ import ModuleMixin from '../../common/ModuleMixin';
|
|
|
|
|
|
import { getCharacterData, modelList, getOption } from '@/views/book/courseware/data/character';
|
|
|
import { GetStaticResources, TextToAudioFile } from '@/api/app';
|
|
|
+import { PinyinBuild_OldFormat } from '@/api/book';
|
|
|
import cnchar from 'cnchar';
|
|
|
import UploadFile from '../../base/common/UploadFile.vue';
|
|
|
import SoundRecord from '@/views/book/courseware/create/components/question/fill/components/SoundRecord.vue';
|
|
|
@@ -259,7 +260,10 @@ export default {
|
|
|
let data = {
|
|
|
hz_str: str,
|
|
|
};
|
|
|
- items.pinyin = cnchar.spell(str, 'array', 'low', 'tone').join(' ');
|
|
|
+ // items.pinyin = cnchar.spell(str, 'array', 'low', 'tone').join(' ');
|
|
|
+ if (str) {
|
|
|
+ items.pinyin = await this.handlePinyin(str);
|
|
|
+ }
|
|
|
await GetStaticResources(MethodName, data)
|
|
|
.then((res) => {
|
|
|
for (let key in res) {
|
|
|
@@ -268,6 +272,7 @@ export default {
|
|
|
}
|
|
|
}
|
|
|
let hzDetailList = res;
|
|
|
+
|
|
|
arr.forEach((item, index) => {
|
|
|
let objs = {};
|
|
|
if (item === '@') {
|
|
|
@@ -324,13 +329,41 @@ export default {
|
|
|
});
|
|
|
})
|
|
|
.catch(() => {});
|
|
|
- // if (str) {
|
|
|
- // this.handleMatic(str, index);
|
|
|
- // }
|
|
|
+ for (let index = 0; index < arr.length; index++) {
|
|
|
+ if (regex.test(arr[index])) {
|
|
|
+ // 汉字
|
|
|
+ items.content_list[index].pinyin = await this.handlePinyin(arr[index]);
|
|
|
+ }
|
|
|
+ }
|
|
|
} else {
|
|
|
this.$message.warning('请先输入内容');
|
|
|
}
|
|
|
},
|
|
|
+ // 自动生成拼音
|
|
|
+ handlePinyin(text) {
|
|
|
+ let data = {
|
|
|
+ text: text,
|
|
|
+ is_rich_text: 'false',
|
|
|
+ is_first_sentence_first_hz_pinyin_first_char_upper_case: 'false',
|
|
|
+ is_fill_space: 'false',
|
|
|
+ is_custom_fc: 'false',
|
|
|
+ };
|
|
|
+ return new Promise((resolve, reject) => {
|
|
|
+ PinyinBuild_OldFormat(data).then((res) => {
|
|
|
+ if (res.parsed_text) {
|
|
|
+ let mergedData = '';
|
|
|
+ res.parsed_text.paragraph_list.map((outerArr, i) =>
|
|
|
+ outerArr.map((innerArr, j) =>
|
|
|
+ innerArr.map((newItem, k) => {
|
|
|
+ mergedData += newItem.pinyin + ' ';
|
|
|
+ }),
|
|
|
+ ),
|
|
|
+ );
|
|
|
+ resolve(mergedData);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ });
|
|
|
+ },
|
|
|
uploads(file_id, index, file_url) {
|
|
|
this.data.option_list[index].audio_file_id = {
|
|
|
file_url,
|