|
@@ -1,6 +1,11 @@
|
|
|
<template>
|
|
<template>
|
|
|
- <el-dialog :title="titleText" :visible.sync="visible" width="600px" :close-on-click-modal="false"
|
|
|
|
|
- @close="dialogClose()">
|
|
|
|
|
|
|
+ <el-dialog
|
|
|
|
|
+ :title="titleText"
|
|
|
|
|
+ :visible.sync="visible"
|
|
|
|
|
+ width="600px"
|
|
|
|
|
+ :close-on-click-modal="false"
|
|
|
|
|
+ @close="dialogClose()"
|
|
|
|
|
+ >
|
|
|
<div class="translate-container">
|
|
<div class="translate-container">
|
|
|
<div class="translate-section">
|
|
<div class="translate-section">
|
|
|
<div class="section-label">原文:</div>
|
|
<div class="section-label">原文:</div>
|
|
@@ -16,8 +21,9 @@
|
|
|
|
|
|
|
|
<div class="translate-section">
|
|
<div class="translate-section">
|
|
|
<div class="section-label">译文:</div>
|
|
<div class="section-label">译文:</div>
|
|
|
- <div class="text-content translated-text" :style="{ lineHeight: lang === 'ZH' ? '1' : '1.5' }">{{
|
|
|
|
|
- translateResultText }}</div>
|
|
|
|
|
|
|
+ <div class="text-content translated-text" :style="{ lineHeight: lang === 'ZH' ? '1' : '1.5' }">
|
|
|
|
|
+ {{ translateResultText }}
|
|
|
|
|
+ </div>
|
|
|
</div>
|
|
</div>
|
|
|
</div>
|
|
</div>
|
|
|
|
|
|
|
@@ -32,8 +38,7 @@ import { GetLanguageTypeList, Texttrans } from '@/api/book';
|
|
|
|
|
|
|
|
export default {
|
|
export default {
|
|
|
name: 'TranslateDialog',
|
|
name: 'TranslateDialog',
|
|
|
- components: {
|
|
|
|
|
- },
|
|
|
|
|
|
|
+ components: {},
|
|
|
props: {
|
|
props: {
|
|
|
open: {
|
|
open: {
|
|
|
type: Boolean,
|
|
type: Boolean,
|
|
@@ -67,7 +72,7 @@ export default {
|
|
|
if (!this.translateResultList || this.translateResultList.length === 0) {
|
|
if (!this.translateResultList || this.translateResultList.length === 0) {
|
|
|
return '';
|
|
return '';
|
|
|
}
|
|
}
|
|
|
- let resultText = this.translateResultList.map(item => item.dst);
|
|
|
|
|
|
|
+ let resultText = this.translateResultList.map((item) => item.dst);
|
|
|
return resultText.join('\n');
|
|
return resultText.join('\n');
|
|
|
},
|
|
},
|
|
|
},
|
|
},
|
|
@@ -86,6 +91,13 @@ export default {
|
|
|
this.lang = 'ZH';
|
|
this.lang = 'ZH';
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
|
|
|
+ langList(newVal) {
|
|
|
|
|
+ if (newVal && newVal.length > 0 && this.initText) {
|
|
|
|
|
+ this.$nextTick(() => {
|
|
|
|
|
+ this.fetchTranslation();
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
},
|
|
},
|
|
|
methods: {
|
|
methods: {
|
|
|
dialogClose() {
|
|
dialogClose() {
|
|
@@ -97,11 +109,9 @@ export default {
|
|
|
*/
|
|
*/
|
|
|
getLangList() {
|
|
getLangList() {
|
|
|
if (!this.bookId) return;
|
|
if (!this.bookId) return;
|
|
|
- GetLanguageTypeList({ book_id: this.bookId, is_contain_zh: 'true' }).then(
|
|
|
|
|
- ({ language_type_list }) => {
|
|
|
|
|
- this.langList = language_type_list;
|
|
|
|
|
- },
|
|
|
|
|
- );
|
|
|
|
|
|
|
+ GetLanguageTypeList({ book_id: this.bookId, is_contain_zh: 'true' }).then(({ language_type_list }) => {
|
|
|
|
|
+ this.langList = language_type_list;
|
|
|
|
|
+ });
|
|
|
},
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -123,15 +133,17 @@ export default {
|
|
|
const params = {
|
|
const params = {
|
|
|
text: this.initText,
|
|
text: this.initText,
|
|
|
from: 'zh',
|
|
from: 'zh',
|
|
|
- to: this.lang
|
|
|
|
|
- }
|
|
|
|
|
- Texttrans(params).then(res => {
|
|
|
|
|
- if (res.status == 1) {
|
|
|
|
|
- this.translateResultList = res.trans_list || [];
|
|
|
|
|
- }
|
|
|
|
|
- }).catch(err => {
|
|
|
|
|
- this.$message.error('翻译失败');
|
|
|
|
|
- });
|
|
|
|
|
|
|
+ to: this.lang,
|
|
|
|
|
+ };
|
|
|
|
|
+ Texttrans(params)
|
|
|
|
|
+ .then((res) => {
|
|
|
|
|
+ if (res.status == 1) {
|
|
|
|
|
+ this.translateResultList = res.trans_list || [];
|
|
|
|
|
+ }
|
|
|
|
|
+ })
|
|
|
|
|
+ .catch((err) => {
|
|
|
|
|
+ this.$message.error('翻译失败');
|
|
|
|
|
+ });
|
|
|
},
|
|
},
|
|
|
},
|
|
},
|
|
|
};
|
|
};
|
|
@@ -191,13 +203,11 @@ export default {
|
|
|
display: flex;
|
|
display: flex;
|
|
|
flex-direction: column;
|
|
flex-direction: column;
|
|
|
row-gap: 8px;
|
|
row-gap: 8px;
|
|
|
- padding: 10pX;
|
|
|
|
|
|
|
+ padding: 10px;
|
|
|
|
|
|
|
|
.el-textarea__inner {
|
|
.el-textarea__inner {
|
|
|
height: 108px;
|
|
height: 108px;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
}
|
|
}
|
|
|
</style>
|
|
</style>
|