update 格式化代码

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