update 格式化代码
This commit is contained in:
+32
-26
@@ -7,18 +7,18 @@
|
|||||||
<script>
|
<script>
|
||||||
|
|
||||||
let docEditor
|
let docEditor
|
||||||
const {location} = window
|
const { location } = window
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'editor',
|
name: 'editor',
|
||||||
data() {
|
data () {
|
||||||
return {
|
return {
|
||||||
docEditor: {},
|
docEditor: {},
|
||||||
documentUrl: window._CONFIG.documentUrl,
|
documentUrl: window._CONFIG.documentUrl,
|
||||||
callbackUrl: window._CONFIG.callbackUrl
|
callbackUrl: window._CONFIG.callbackUrl
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted () {
|
||||||
if (window.addEventListener) {
|
if (window.addEventListener) {
|
||||||
window.addEventListener('load', this.connectEditor)
|
window.addEventListener('load', this.connectEditor)
|
||||||
window.addEventListener('resize', this.fixSize)
|
window.addEventListener('resize', this.fixSize)
|
||||||
@@ -28,20 +28,20 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
innerAlert(message) {
|
innerAlert (message) {
|
||||||
if (console && console.log) console.log(message)
|
if (console && console.log) console.log(message)
|
||||||
},
|
},
|
||||||
onAppReady() {
|
onAppReady () {
|
||||||
this.innerAlert('Document editor ready')
|
this.innerAlert('Document editor ready')
|
||||||
},
|
},
|
||||||
onDocumentStateChange(event) {
|
onDocumentStateChange (event) {
|
||||||
const title = document.title.replace(/\*$/g, '')
|
const title = document.title.replace(/\*$/g, '')
|
||||||
document.title = title + (event.data ? '*' : '')
|
document.title = title + (event.data ? '*' : '')
|
||||||
},
|
},
|
||||||
onRequestEditRights() {
|
onRequestEditRights () {
|
||||||
location.href = location.href.replace(RegExp('mode=view', 'i'), '')
|
location.href = location.href.replace(RegExp('mode=view', 'i'), '')
|
||||||
},
|
},
|
||||||
onRequestHistory(event) {
|
onRequestHistory (event) {
|
||||||
const historyObj =
|
const historyObj =
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
@@ -49,7 +49,7 @@ export default {
|
|||||||
key: this.$route.query.attId,
|
key: this.$route.query.attId,
|
||||||
version: 1,
|
version: 1,
|
||||||
created: '2022-10-17 14:17:09',
|
created: '2022-10-17 14:17:09',
|
||||||
user: {id: this.$route.query.userId, name: this.$route.query.userName}
|
user: { id: this.$route.query.userId, name: this.$route.query.userName }
|
||||||
}
|
}
|
||||||
] || null
|
] || null
|
||||||
|
|
||||||
@@ -58,7 +58,7 @@ export default {
|
|||||||
history: historyObj
|
history: historyObj
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
onRequestHistoryData(data) {
|
onRequestHistoryData (data) {
|
||||||
const version = data.data
|
const version = data.data
|
||||||
const historyData =
|
const historyData =
|
||||||
[
|
[
|
||||||
@@ -70,17 +70,17 @@ export default {
|
|||||||
] || null
|
] || null
|
||||||
this.docEditor.setHistoryData(historyData[version - 1])
|
this.docEditor.setHistoryData(historyData[version - 1])
|
||||||
},
|
},
|
||||||
onRequestHistoryClose(event) {
|
onRequestHistoryClose (event) {
|
||||||
document.location.reload()
|
document.location.reload()
|
||||||
},
|
},
|
||||||
onError(event) {
|
onError (event) {
|
||||||
if (event) this.innerAlert(event.data)
|
if (event) this.innerAlert(event.data)
|
||||||
},
|
},
|
||||||
onOutdatedVersion(event) {
|
onOutdatedVersion (event) {
|
||||||
// console.log(event);
|
// console.log(event);
|
||||||
location.reload(true)
|
location.reload(true)
|
||||||
},
|
},
|
||||||
replaceActionLink(href, linkParam) {
|
replaceActionLink (href, linkParam) {
|
||||||
let link
|
let link
|
||||||
const actionIndex = href.indexOf('&action=')
|
const actionIndex = href.indexOf('&action=')
|
||||||
// eslint-disable-next-line eqeqeq
|
// eslint-disable-next-line eqeqeq
|
||||||
@@ -101,12 +101,12 @@ export default {
|
|||||||
}
|
}
|
||||||
return link
|
return link
|
||||||
},
|
},
|
||||||
onMakeActionLink(event) {
|
onMakeActionLink (event) {
|
||||||
const actionData = event.data
|
const actionData = event.data
|
||||||
const linkParam = JSON.stringify(actionData)
|
const linkParam = JSON.stringify(actionData)
|
||||||
this.docEditor.setActionLink(this.replaceActionLink(location.href, linkParam))
|
this.docEditor.setActionLink(this.replaceActionLink(location.href, linkParam))
|
||||||
},
|
},
|
||||||
fixSize() {
|
fixSize () {
|
||||||
const wrapEl = document.getElementsByClassName('form')
|
const wrapEl = document.getElementsByClassName('form')
|
||||||
if (wrapEl.length) {
|
if (wrapEl.length) {
|
||||||
// eslint-disable-next-line no-restricted-globals
|
// eslint-disable-next-line no-restricted-globals
|
||||||
@@ -115,10 +115,11 @@ export default {
|
|||||||
wrapEl[0].style.height = `${window.innerHeight}px`
|
wrapEl[0].style.height = `${window.innerHeight}px`
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onDocumentSaved() {
|
onDocumentSaved () {
|
||||||
console.log(12)
|
console.log(12)
|
||||||
},
|
},
|
||||||
connectEditor() {
|
connectEditor () {
|
||||||
|
console.log(this.documentUrl)
|
||||||
const nowTime = new Date().getTime()
|
const nowTime = new Date().getTime()
|
||||||
this.docEditor = new DocsAPI.DocEditor('iframeEditor', {
|
this.docEditor = new DocsAPI.DocEditor('iframeEditor', {
|
||||||
width: '100%',
|
width: '100%',
|
||||||
@@ -131,8 +132,10 @@ export default {
|
|||||||
documentType: 'text',
|
documentType: 'text',
|
||||||
token: '',
|
token: '',
|
||||||
document: {
|
document: {
|
||||||
title: this.$route.query.oldFileName + '.' + this.$route.query.fileType,
|
// title: this.$route.query.oldFileName + '.' + this.$route.query.fileType,
|
||||||
url: this.documentUrl + this.$route.query.filePath + this.$route.query.fileName,
|
title: '文档.docx',
|
||||||
|
// url: this.documentUrl + this.$route.query.filePath + this.$route.query.fileName,
|
||||||
|
url: this.documentUrl,
|
||||||
fileType: this.$route.query.fileType,
|
fileType: this.$route.query.fileType,
|
||||||
key: this.$route.query.key,
|
key: this.$route.query.key,
|
||||||
info: {
|
info: {
|
||||||
@@ -163,9 +166,12 @@ export default {
|
|||||||
},
|
},
|
||||||
// embedded部分仅适用于嵌入式文档类型(请参阅config部分以了解如何定义嵌入式文档类型)。它允许更改设置,这些设置定义嵌入式模式下按钮的行为。
|
// embedded部分仅适用于嵌入式文档类型(请参阅config部分以了解如何定义嵌入式文档类型)。它允许更改设置,这些设置定义嵌入式模式下按钮的行为。
|
||||||
embedded: {
|
embedded: {
|
||||||
saveUrl: this.documentUrl + this.$route.query.filePath + this.$route.query.fileName, // 定义允许将文档保存到用户个人计算机上的绝对URL。
|
// saveUrl: this.documentUrl + this.$route.query.filePath + this.$route.query.fileName, // 定义允许将文档保存到用户个人计算机上的绝对URL。
|
||||||
embedUrl: this.documentUrl + this.$route.query.filePath + this.$route.query.fileName, // 定义文档的绝对URL,以作为嵌入到网页中的文档的源文件
|
// embedUrl: this.documentUrl + this.$route.query.filePath + this.$route.query.fileName, // 定义文档的绝对URL,以作为嵌入到网页中的文档的源文件
|
||||||
shareUrl: this.documentUrl + this.$route.query.filePath + this.$route.query.fileName, // 定义允许其他用户共享此文档的绝对URL。
|
// shareUrl: this.documentUrl + this.$route.query.filePath + this.$route.query.fileName, // 定义允许其他用户共享此文档的绝对URL。
|
||||||
|
saveUrl: this.documentUrl, // 定义允许将文档保存到用户个人计算机上的绝对URL。
|
||||||
|
embedUrl: this.documentUrl, // 定义文档的绝对URL,以作为嵌入到网页中的文档的源文件
|
||||||
|
shareUrl: this.documentUrl, // 定义允许其他用户共享此文档的绝对URL。
|
||||||
toolbarDocked: 'top' // 定义嵌入式查看器工具栏的位置,可以为top或bottom。
|
toolbarDocked: 'top' // 定义嵌入式查看器工具栏的位置,可以为top或bottom。
|
||||||
},
|
},
|
||||||
// 定制部分允许自定义编辑器界面,使其看起来像您的其他产品,并更改是否存在其他按钮,链接,更改徽标和编辑者所有者详细信息。
|
// 定制部分允许自定义编辑器界面,使其看起来像您的其他产品,并更改是否存在其他按钮,链接,更改徽标和编辑者所有者详细信息。
|
||||||
@@ -191,12 +197,12 @@ export default {
|
|||||||
},
|
},
|
||||||
fileChoiceUrl: '',
|
fileChoiceUrl: '',
|
||||||
// 定义是否将启动插件并可用。默认值为true。
|
// 定义是否将启动插件并可用。默认值为true。
|
||||||
plugins: this.$route.query.isEdit && this.$route.query.isEdit == 123 ? {
|
plugins: {
|
||||||
autostart: ['asc.{0616AE85-5DBE-4B6B-A0A9-455C4F1503AD}'],
|
autostart: ['asc.{0616AE85-5DBE-4B6B-A0A9-455C4F1503AD}'],
|
||||||
pluginsData: [
|
pluginsData: [
|
||||||
window._CONFIG.configUrl + 'page1/config.json'
|
window._CONFIG.configUrl + 'page1/config.json'
|
||||||
]
|
]
|
||||||
} : {}
|
}
|
||||||
},
|
},
|
||||||
events: {
|
events: {
|
||||||
'onAppReady': this.onAppReady,
|
'onAppReady': this.onAppReady,
|
||||||
@@ -214,7 +220,7 @@ export default {
|
|||||||
this.fixSize()
|
this.fixSize()
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
beforeDestroy() {
|
beforeDestroy () {
|
||||||
if (window.removeEventListener) {
|
if (window.removeEventListener) {
|
||||||
window.removeEventListener('load', this.connectEditor)
|
window.removeEventListener('load', this.connectEditor)
|
||||||
window.removeEventListener('resize', this.fixSize)
|
window.removeEventListener('resize', this.fixSize)
|
||||||
|
|||||||
Reference in New Issue
Block a user