对接文档翻译
This commit is contained in:
@@ -28,6 +28,7 @@
|
|||||||
"jsencrypt": "^3.0.0-rc.1",
|
"jsencrypt": "^3.0.0-rc.1",
|
||||||
"lodash.get": "^4.4.2",
|
"lodash.get": "^4.4.2",
|
||||||
"lodash.pick": "^4.4.0",
|
"lodash.pick": "^4.4.0",
|
||||||
|
"mammoth": "^1.4.21",
|
||||||
"md5": "^2.2.1",
|
"md5": "^2.2.1",
|
||||||
"nprogress": "^0.2.0",
|
"nprogress": "^0.2.0",
|
||||||
"tinymce": "^5.3.2",
|
"tinymce": "^5.3.2",
|
||||||
|
|||||||
+57
-8
@@ -18,18 +18,22 @@
|
|||||||
<div class="detail-text">
|
<div class="detail-text">
|
||||||
<iframe :src="detailUrlLeft"
|
<iframe :src="detailUrlLeft"
|
||||||
ref="iframeLeft"
|
ref="iframeLeft"
|
||||||
|
@load="detailUrlLeftLoad"
|
||||||
sandbox="allow-same-origin allow-scripts"
|
sandbox="allow-same-origin allow-scripts"
|
||||||
id="iframe-left"
|
id="iframe-left"
|
||||||
class="detail-text-iframe" frameborder="0"></iframe>
|
class="detail-text-iframe" frameborder="0"></iframe>
|
||||||
</div>
|
</div>
|
||||||
|
<JLoading :loading="loadingLeft">{{$t('dataLoading')}}</JLoading>
|
||||||
</div>
|
</div>
|
||||||
<div class="detail-content-right">
|
<div class="detail-content-right">
|
||||||
<div class="detail-text-top">
|
<div class="detail-text-top">
|
||||||
{{$t('translatedText')}}
|
{{$t('translatedText')}}
|
||||||
</div>
|
</div>
|
||||||
<div class="detail-text">
|
<div class="detail-text">
|
||||||
<iframe :src="detailUrlRight" class="detail-text-iframe" frameborder="0"></iframe>
|
<iframe :src="detailUrlRight" @load="detailUrlrightLoad" class="detail-text-iframe"
|
||||||
|
frameborder="0"></iframe>
|
||||||
</div>
|
</div>
|
||||||
|
<JLoading :loading="loadingRight">{{$t('dataLoading')}}</JLoading>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -39,6 +43,10 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { Base64 } from 'js-base64'
|
import { Base64 } from 'js-base64'
|
||||||
|
import mammoth from 'mammoth'
|
||||||
|
import axios from 'axios'
|
||||||
|
import { ACCESS_TOKEN } from '@/store/mutation-types'
|
||||||
|
import Vue from 'vue'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'documentTranslationResults',
|
name: 'documentTranslationResults',
|
||||||
@@ -46,6 +54,8 @@
|
|||||||
return {
|
return {
|
||||||
detailUrlLeft: '',
|
detailUrlLeft: '',
|
||||||
detailUrlRight: '',
|
detailUrlRight: '',
|
||||||
|
loadingLeft: false,
|
||||||
|
loadingRight: false,
|
||||||
downLoadFileUrl: window._CONFIG['domianPreviewURL'] + '/sys/common/download',
|
downLoadFileUrl: window._CONFIG['domianPreviewURL'] + '/sys/common/download',
|
||||||
fileQuery: {}
|
fileQuery: {}
|
||||||
}
|
}
|
||||||
@@ -53,13 +63,6 @@
|
|||||||
mounted() {
|
mounted() {
|
||||||
this.fileQuery = this.$route.query
|
this.fileQuery = this.$route.query
|
||||||
this.onlinePreview()
|
this.onlinePreview()
|
||||||
setTimeout(() => {
|
|
||||||
this.$nextTick(() => {
|
|
||||||
this.$refs.iframeLeft.contentWindow.document.body.style = 'background-color:#fff'
|
|
||||||
console.log(this.$refs.iframeLeft.contentWindow.document.body.style.backgroundColor)
|
|
||||||
})
|
|
||||||
}, 2000)
|
|
||||||
|
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
Fallback() {
|
Fallback() {
|
||||||
@@ -67,13 +70,57 @@
|
|||||||
path: '/documentTranslation'
|
path: '/documentTranslation'
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
detailUrlLeftLoad() {
|
||||||
|
this.loadingLeft = false
|
||||||
|
},
|
||||||
|
detailUrlrightLoad() {
|
||||||
|
this.loadingRight = false
|
||||||
|
},
|
||||||
onlinePreview() {
|
onlinePreview() {
|
||||||
let fileName = this.fileQuery.fileName
|
let fileName = this.fileQuery.fileName
|
||||||
let index1 = fileName.lastIndexOf('.')
|
let index1 = fileName.lastIndexOf('.')
|
||||||
let index2 = fileName.length
|
let index2 = fileName.length
|
||||||
let fileSuffix = fileName.substring(index1, index2)
|
let fileSuffix = fileName.substring(index1, index2)
|
||||||
|
this.loadingLeft = true
|
||||||
|
this.loadingRight = true
|
||||||
|
// this.readExcelFromRemoteFileLeft(this.downLoadFileUrl + '/' + this.fileQuery.sourceFileId + fileSuffix)
|
||||||
|
// this.readExcelFromRemoteFileRight(this.downLoadFileUrl + '/' + this.fileQuery.targetFileId + fileSuffix)
|
||||||
this.detailUrlLeft = window._CONFIG['onlinePreviewDomainURL'] + '?url=' + Base64.encode(this.downLoadFileUrl + '/' + this.fileQuery.sourceFileId + fileSuffix)
|
this.detailUrlLeft = window._CONFIG['onlinePreviewDomainURL'] + '?url=' + Base64.encode(this.downLoadFileUrl + '/' + this.fileQuery.sourceFileId + fileSuffix)
|
||||||
this.detailUrlRight = window._CONFIG['onlinePreviewDomainURL'] + '?url=' + Base64.encode(this.downLoadFileUrl + '/' + this.fileQuery.targetFileId + fileSuffix)
|
this.detailUrlRight = window._CONFIG['onlinePreviewDomainURL'] + '?url=' + Base64.encode(this.downLoadFileUrl + '/' + this.fileQuery.targetFileId + fileSuffix)
|
||||||
|
},
|
||||||
|
readExcelFromRemoteFileLeft: function(url) {
|
||||||
|
var vm = this
|
||||||
|
var xhr = new XMLHttpRequest()
|
||||||
|
xhr.open('get', url, true)
|
||||||
|
xhr.responseType = 'arraybuffer'
|
||||||
|
xhr.onload = function() {
|
||||||
|
if (xhr.status == 200) {
|
||||||
|
mammoth.convertToHtml({ arrayBuffer: new Uint8Array(xhr.response) })
|
||||||
|
.then(function(resultObject) {
|
||||||
|
vm.$nextTick(() => {
|
||||||
|
vm.detailUrlLeft = resultObject.value
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
xhr.send()
|
||||||
|
},
|
||||||
|
readExcelFromRemoteFileRight: function(url) {
|
||||||
|
var vm = this
|
||||||
|
var xhr = new XMLHttpRequest()
|
||||||
|
xhr.open('get', url, true)
|
||||||
|
xhr.responseType = 'arraybuffer'
|
||||||
|
xhr.onload = function() {
|
||||||
|
if (xhr.status == 200) {
|
||||||
|
mammoth.convertToHtml({ arrayBuffer: new Uint8Array(xhr.response) })
|
||||||
|
.then(function(resultObject) {
|
||||||
|
vm.$nextTick(() => {
|
||||||
|
vm.detailUrlRight = resultObject.value
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
xhr.send()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -126,9 +173,11 @@
|
|||||||
padding: 24px 32px;
|
padding: 24px 32px;
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
overflow: auto;
|
overflow: auto;
|
||||||
|
position: relative;
|
||||||
}
|
}
|
||||||
|
|
||||||
.detail-content-right {
|
.detail-content-right {
|
||||||
|
position: relative;
|
||||||
float: left;
|
float: left;
|
||||||
width: calc(50% - 12px);
|
width: calc(50% - 12px);
|
||||||
padding: 24px 32px;
|
padding: 24px 32px;
|
||||||
|
|||||||
Reference in New Issue
Block a user