perf: 打开office文件的加载动画
This commit is contained in:
parent
c9b8f6c138
commit
465f7e942e
@ -441,7 +441,6 @@
|
|||||||
<message-dialog
|
<message-dialog
|
||||||
title="提示"
|
title="提示"
|
||||||
content="此文件不支持预览, 是否下载该文件?"
|
content="此文件不支持预览, 是否下载该文件?"
|
||||||
:loading="notPreviewDialogLoading"
|
|
||||||
:show.sync="notPreviewDialogVisible"
|
:show.sync="notPreviewDialogVisible"
|
||||||
operatButtonText="强行使用文本编辑器打开"
|
operatButtonText="强行使用文本编辑器打开"
|
||||||
confirmButtonText="下载"
|
confirmButtonText="下载"
|
||||||
@ -547,7 +546,6 @@ import fileConfig from '@/utils/file-config'
|
|||||||
import EditElement from "@/views/markdown/EditElement";
|
import EditElement from "@/views/markdown/EditElement";
|
||||||
import OfficePreview from "@/components/preview/OfficePreview";
|
import OfficePreview from "@/components/preview/OfficePreview";
|
||||||
|
|
||||||
var rowStyleExecuting = false
|
|
||||||
export default {
|
export default {
|
||||||
name: 'ShowFile',
|
name: 'ShowFile',
|
||||||
components: {
|
components: {
|
||||||
@ -794,7 +792,6 @@ export default {
|
|||||||
drawFlag: false,
|
drawFlag: false,
|
||||||
fileListScrollTop: 0,
|
fileListScrollTop: 0,
|
||||||
notPreviewDialogVisible: false,
|
notPreviewDialogVisible: false,
|
||||||
notPreviewDialogLoading: false,
|
|
||||||
openingFile: '',
|
openingFile: '',
|
||||||
openCompressionVisible: false,
|
openCompressionVisible: false,
|
||||||
stompClient: undefined,//websocket订阅集合
|
stompClient: undefined,//websocket订阅集合
|
||||||
@ -828,18 +825,10 @@ export default {
|
|||||||
created() {
|
created() {
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
Bus.$on('fileSuccess', () => {
|
Bus.$on('fileSuccess', () => {})
|
||||||
|
|
||||||
})
|
|
||||||
Bus.$on('loadFileReady', () => {
|
|
||||||
this.closeNotPreviewDialogVisible()
|
|
||||||
})
|
|
||||||
Bus.$on('loadFileFaild', () => {
|
Bus.$on('loadFileFaild', () => {
|
||||||
console.log('loadFileFaild')
|
console.log('loadFileFaild')
|
||||||
this.notPreviewDialogVisible = true
|
this.notPreviewDialogVisible = true
|
||||||
this.$nextTick(() => {
|
|
||||||
this.notPreviewDialogLoading = false
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
Bus.$on('clickMore', (rows) => {
|
Bus.$on('clickMore', (rows) => {
|
||||||
this.$refs.fileListTable.tableSelectData = rows
|
this.$refs.fileListTable.tableSelectData = rows
|
||||||
@ -3139,39 +3128,32 @@ export default {
|
|||||||
this.$emit("selectedFile", selectFile)
|
this.$emit("selectedFile", selectFile)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
this.notPreviewDialogVisible = true
|
|
||||||
this.notPreviewDialogLoading = true
|
|
||||||
if (row.contentType.startsWith('image')) {
|
if (row.contentType.startsWith('image')) {
|
||||||
// 图片
|
// 图片
|
||||||
this.imagePreviewVisible = true
|
this.imagePreviewVisible = true
|
||||||
this.imagePreviewRow = row
|
this.imagePreviewRow = row
|
||||||
this.closeNotPreviewDialogVisible()
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (suffix.simText.includes(row.suffix)) {
|
if (suffix.simText.includes(row.suffix)) {
|
||||||
// 文本文件
|
// 文本文件
|
||||||
this.textPreviewRow = row
|
this.textPreviewRow = row
|
||||||
this.textPreviewVisible = true
|
this.textPreviewVisible = true
|
||||||
this.closeNotPreviewDialogVisible()
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (row.contentType.indexOf('video') > -1) {
|
if (row.contentType.indexOf('video') > -1) {
|
||||||
// 视频文件
|
// 视频文件
|
||||||
this.videoPreviewVisible = true
|
this.videoPreviewVisible = true
|
||||||
this.videoPreviewRow = row
|
this.videoPreviewRow = row
|
||||||
this.closeNotPreviewDialogVisible()
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (row.contentType.indexOf('audio') > -1) {
|
if (row.contentType.indexOf('audio') > -1) {
|
||||||
// 音频文件
|
// 音频文件
|
||||||
Bus.$emit('onAddAudio', row, this.audioCoverUrl)
|
Bus.$emit('onAddAudio', row, this.audioCoverUrl)
|
||||||
this.closeNotPreviewDialogVisible()
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (suffix.compressedFile.includes(row.suffix)) {
|
if (suffix.compressedFile.includes(row.suffix)) {
|
||||||
// 压缩文件
|
// 压缩文件
|
||||||
this.openCompressionVisible = true
|
this.openCompressionVisible = true
|
||||||
this.closeNotPreviewDialogVisible()
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (row.contentType.indexOf('office') > -1 || row.suffix === 'csv') {
|
if (row.contentType.indexOf('office') > -1 || row.suffix === 'csv') {
|
||||||
@ -3186,15 +3168,9 @@ export default {
|
|||||||
this.closeNotPreviewDialogVisible()
|
this.closeNotPreviewDialogVisible()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
this.notPreviewDialogLoading = false
|
|
||||||
this.notPreviewDialogVisible = true
|
this.notPreviewDialogVisible = true
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
closeNotPreviewDialogVisible() {
|
|
||||||
// 其他文件
|
|
||||||
this.notPreviewDialogVisible = false
|
|
||||||
this.notPreviewDialogLoading = false
|
|
||||||
},
|
|
||||||
// 强行使用文本编辑器打开
|
// 强行使用文本编辑器打开
|
||||||
forciblyOpen(file) {
|
forciblyOpen(file) {
|
||||||
this.textPreviewRow = file
|
this.textPreviewRow = file
|
||||||
|
|||||||
@ -165,6 +165,7 @@ export default {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
config.events = {
|
config.events = {
|
||||||
|
"onAppReady": this.onAppReady,
|
||||||
"onDocumentReady": this.onDocumentReady,
|
"onDocumentReady": this.onDocumentReady,
|
||||||
"onDocumentStateChange": this.onDocumentStateChange,
|
"onDocumentStateChange": this.onDocumentStateChange,
|
||||||
}
|
}
|
||||||
@ -172,9 +173,11 @@ export default {
|
|||||||
this.docEditor = new DocsAPI.DocEditor(this.id, config)
|
this.docEditor = new DocsAPI.DocEditor(this.id, config)
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
onAppReady() {
|
||||||
|
this.$emit('onReady')
|
||||||
|
},
|
||||||
onDocumentReady() {
|
onDocumentReady() {
|
||||||
console.log('onDocumentReady')
|
console.log('onDocumentReady')
|
||||||
this.$emit('onReday')
|
|
||||||
let parentDoc = document.querySelector('.component-only-office')
|
let parentDoc = document.querySelector('.component-only-office')
|
||||||
let doc = parentDoc.getElementsByTagName('iframe')[0].contentWindow.document
|
let doc = parentDoc.getElementsByTagName('iframe')[0].contentWindow.document
|
||||||
let logo = doc.querySelector('.extra .logo')
|
let logo = doc.querySelector('.extra .logo')
|
||||||
|
|||||||
@ -10,13 +10,13 @@
|
|||||||
@confirm="saveAndClose"
|
@confirm="saveAndClose"
|
||||||
>
|
>
|
||||||
</message-dialog>
|
</message-dialog>
|
||||||
<div class="office-preview" v-if="show">
|
<div class="office-preview" v-if="show" v-loading="!readyShow">
|
||||||
<div class="preview-block" v-show="readyShow">
|
<div class="preview-block" v-show="readyShow">
|
||||||
<div class="close-bar" @click="beforeClose">
|
<div class="close-bar" @click="beforeClose">
|
||||||
<svg-icon class="preview-close" icon-class="close"/>
|
<svg-icon class="preview-close" icon-class="close"/>
|
||||||
</div>
|
</div>
|
||||||
<div class="wrapper">
|
<div class="wrapper">
|
||||||
<only-office-editor ref="officeEditor" :file="file" :read-only="readOnly" @onEdit="onEdit" @manualSave="manualSave" @onClose="close" @onReday="onReday"></only-office-editor>
|
<only-office-editor ref="officeEditor" :file="file" :read-only="readOnly" @onEdit="onEdit" @manualSave="manualSave" @onClose="close" @onReady="onReady"></only-office-editor>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -73,6 +73,14 @@ export default {
|
|||||||
this.previewDocument = document.querySelector('.preview-block')
|
this.previewDocument = document.querySelector('.preview-block')
|
||||||
})
|
})
|
||||||
this.checkReadOnly(this.file.userId)
|
this.checkReadOnly(this.file.userId)
|
||||||
|
// 3秒后还没加载出来视为加载失败
|
||||||
|
let that = this
|
||||||
|
setTimeout(function () {
|
||||||
|
if (!that.readyShow) {
|
||||||
|
that.readyShow = true
|
||||||
|
Bus.$emit('loadFileFaild')
|
||||||
|
}
|
||||||
|
},3000)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -98,12 +106,11 @@ export default {
|
|||||||
/**
|
/**
|
||||||
* 文件内容已经加载好了
|
* 文件内容已经加载好了
|
||||||
*/
|
*/
|
||||||
onReday() {
|
onReady() {
|
||||||
this.saved = true
|
this.saved = true
|
||||||
this.previewDocument.style.zIndex = 9999
|
this.previewDocument.style.zIndex = 9999
|
||||||
this.readyShow = true
|
this.readyShow = true
|
||||||
this.$nextTick(() => {
|
this.$nextTick(() => {
|
||||||
Bus.$emit('loadFileReady')
|
|
||||||
let that = this
|
let that = this
|
||||||
setTimeout(function () {
|
setTimeout(function () {
|
||||||
that.previewDocument.style.zIndex = 2001
|
that.previewDocument.style.zIndex = 2001
|
||||||
@ -171,13 +178,14 @@ export default {
|
|||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
|
|
||||||
.preview {
|
.office-preview {
|
||||||
position: fixed;
|
position: fixed;
|
||||||
top: 0;
|
top: 0;
|
||||||
left: 0;
|
left: 0;
|
||||||
z-index: 1002;
|
z-index: 1002;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.van-overlay {
|
.van-overlay {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user