perf: 优化office组件
This commit is contained in:
parent
0276709027
commit
6f9d0c85ab
@ -441,6 +441,7 @@
|
|||||||
<message-dialog
|
<message-dialog
|
||||||
title="提示"
|
title="提示"
|
||||||
content="此文件不支持预览, 是否下载该文件?"
|
content="此文件不支持预览, 是否下载该文件?"
|
||||||
|
:loading="notPreviewDialogLoading"
|
||||||
:show.sync="notPreviewDialogVisible"
|
:show.sync="notPreviewDialogVisible"
|
||||||
operatButtonText="强行使用文本编辑器打开"
|
operatButtonText="强行使用文本编辑器打开"
|
||||||
confirmButtonText="下载"
|
confirmButtonText="下载"
|
||||||
@ -793,6 +794,7 @@ 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,6 +830,16 @@ export default {
|
|||||||
mounted() {
|
mounted() {
|
||||||
Bus.$on('fileSuccess', () => {
|
Bus.$on('fileSuccess', () => {
|
||||||
|
|
||||||
|
})
|
||||||
|
Bus.$on('loadFileReady', () => {
|
||||||
|
this.closeNotPreviewDialogVisible()
|
||||||
|
})
|
||||||
|
Bus.$on('loadFileFaild', () => {
|
||||||
|
console.log('loadFileFaild')
|
||||||
|
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
|
||||||
@ -3127,27 +3139,39 @@ 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
|
||||||
|
}
|
||||||
|
if (suffix.compressedFile.includes(row.suffix)) {
|
||||||
|
// 压缩文件
|
||||||
|
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') {
|
||||||
@ -3159,17 +3183,18 @@ export default {
|
|||||||
if (row.suffix === 'pdf') {
|
if (row.suffix === 'pdf') {
|
||||||
// pdf文件
|
// pdf文件
|
||||||
fileConfig.preview(this.$store.state.user.name, row, this.$store.getters.token)
|
fileConfig.preview(this.$store.state.user.name, row, this.$store.getters.token)
|
||||||
|
this.closeNotPreviewDialogVisible()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (suffix.compressedFile.includes(row.suffix)) {
|
this.notPreviewDialogLoading = false
|
||||||
// 压缩文件
|
|
||||||
this.openCompressionVisible = true
|
|
||||||
return
|
|
||||||
}
|
|
||||||
// 其他文件
|
|
||||||
this.notPreviewDialogVisible = true
|
this.notPreviewDialogVisible = true
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
closeNotPreviewDialogVisible() {
|
||||||
|
// 其他文件
|
||||||
|
this.notPreviewDialogVisible = false
|
||||||
|
this.notPreviewDialogLoading = false
|
||||||
|
},
|
||||||
// 强行使用文本编辑器打开
|
// 强行使用文本编辑器打开
|
||||||
forciblyOpen(file) {
|
forciblyOpen(file) {
|
||||||
this.textPreviewRow = file
|
this.textPreviewRow = file
|
||||||
|
|||||||
@ -1,19 +1,23 @@
|
|||||||
<template>
|
<template>
|
||||||
<div>
|
<div>
|
||||||
<el-dialog
|
<!-- <el-container v-loading="loading">-->
|
||||||
class="jmal-message-dialog"
|
<!-- </el-container>-->
|
||||||
:title="title"
|
<el-dialog
|
||||||
:visible.sync="visible"
|
class="jmal-message-dialog"
|
||||||
top="0vh"
|
:title="title"
|
||||||
:close-on-click-modal="false"
|
:visible.sync="visible"
|
||||||
@close="closeDialog">
|
:modal="modal"
|
||||||
<svg-icon icon-class="warring"></svg-icon> <span class="dialog-msg">{{content}}</span>
|
v-loading="loading"
|
||||||
<span slot="footer" class="dialog-footer">
|
top="0vh"
|
||||||
<el-button :size="buttonSize" @click="operating">{{operatButtonText}}</el-button>
|
:close-on-click-modal="false"
|
||||||
<!-- <el-button :size="buttonSize" @click="cancel">{{cancelButtonText}}</el-button>-->
|
@close="closeDialog">
|
||||||
<el-button :size="buttonSize" type="primary" @click=confirm>{{confirmButtonText}}</el-button>
|
<svg-icon v-if="!loading" icon-class="warring"></svg-icon> <span class="dialog-msg">{{content}}</span>
|
||||||
</span>
|
<span v-if="!loading" slot="footer" class="dialog-footer">
|
||||||
</el-dialog>
|
<el-button :size="buttonSize" @click="operating">{{operatButtonText}}</el-button>
|
||||||
|
<!-- <el-button :size="buttonSize" @click="cancel">{{cancelButtonText}}</el-button>-->
|
||||||
|
<el-button :size="buttonSize" type="primary" @click=confirm>{{confirmButtonText}}</el-button>
|
||||||
|
</span>
|
||||||
|
</el-dialog>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@ -25,12 +29,24 @@
|
|||||||
type: String,
|
type: String,
|
||||||
default: ''
|
default: ''
|
||||||
},
|
},
|
||||||
|
modal: {
|
||||||
|
type: Boolean,
|
||||||
|
default: function () {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
},
|
||||||
show: {
|
show: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
default: function () {
|
default: function () {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
loading: {
|
||||||
|
type: Boolean,
|
||||||
|
default: function () {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
},
|
||||||
content: {
|
content: {
|
||||||
type: String,
|
type: String,
|
||||||
default: ''
|
default: ''
|
||||||
@ -81,8 +97,20 @@
|
|||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
|
>>>.el-container {
|
||||||
|
.el-loading-mask {
|
||||||
|
position: fixed;
|
||||||
|
height: 300px;
|
||||||
|
width: 420px;
|
||||||
|
margin: 0 auto;
|
||||||
|
top: calc(50% - 175px);
|
||||||
|
background: #FFFFFF;
|
||||||
|
}
|
||||||
|
}
|
||||||
>>>.jmal-message-dialog {
|
>>>.jmal-message-dialog {
|
||||||
height: 200px;
|
height: 200px;
|
||||||
|
width: 420px;
|
||||||
|
margin: 0 auto;
|
||||||
top: calc(50% - 100px);
|
top: calc(50% - 100px);
|
||||||
.el-dialog {
|
.el-dialog {
|
||||||
width: 420px;
|
width: 420px;
|
||||||
@ -93,5 +121,8 @@
|
|||||||
.dialog-msg {
|
.dialog-msg {
|
||||||
margin-left: 10px;
|
margin-left: 10px;
|
||||||
}
|
}
|
||||||
|
.el-loading-mask {
|
||||||
|
background: #FFFFFF;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@ -60,9 +60,11 @@ export default {
|
|||||||
if (!id) {
|
if (!id) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
$J.loadScript($J.apiUrl("http://imac/office/web-apps/apps/api/documents/api.js"), (e) => {
|
let officeApiUrl = fileConfig.officeApiUrl()
|
||||||
|
$J.loadScript($J.apiUrl(officeApiUrl), (e) => {
|
||||||
if (e !== null) {
|
if (e !== null) {
|
||||||
$J.modalAlert("组件加载失败!")
|
this.$emit('onClose')
|
||||||
|
Bus.$emit('loadFileFaild')
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if(this.$store.state.user.token && this.$store.state.user.userId === this.file.userId){
|
if(this.$store.state.user.token && this.$store.state.user.userId === this.file.userId){
|
||||||
@ -172,6 +174,7 @@ export default {
|
|||||||
},
|
},
|
||||||
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')
|
||||||
|
|||||||
@ -11,16 +11,14 @@
|
|||||||
>
|
>
|
||||||
</message-dialog>
|
</message-dialog>
|
||||||
<div class="office-preview" v-if="show">
|
<div class="office-preview" v-if="show">
|
||||||
<van-overlay :show="show">
|
<div class="preview-block" v-show="readyShow">
|
||||||
<div class="block">
|
|
||||||
<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"></only-office-editor>
|
<only-office-editor ref="officeEditor" :file="file" :read-only="readOnly" @onEdit="onEdit" @manualSave="manualSave" @onClose="close" @onReday="onReday"></only-office-editor>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</van-overlay>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
@ -60,15 +58,20 @@ export default {
|
|||||||
return {
|
return {
|
||||||
pc: this.$pc,
|
pc: this.$pc,
|
||||||
show: this.status,
|
show: this.status,
|
||||||
|
readyShow: false,
|
||||||
readOnly: true,
|
readOnly: true,
|
||||||
isSaveDialogVisible: false,
|
isSaveDialogVisible: false,
|
||||||
saved: true,
|
saved: true,
|
||||||
|
previewDocument: {},
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
status: function(visible){
|
status: function(visible){
|
||||||
if(visible){
|
if(visible){
|
||||||
this.show = true
|
this.show = true
|
||||||
|
this.$nextTick(() => {
|
||||||
|
this.previewDocument = document.querySelector('.preview-block')
|
||||||
|
})
|
||||||
this.checkReadOnly(this.file.userId)
|
this.checkReadOnly(this.file.userId)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -89,8 +92,24 @@ export default {
|
|||||||
*/
|
*/
|
||||||
close() {
|
close() {
|
||||||
this.show = false
|
this.show = false
|
||||||
|
this.readyShow = false
|
||||||
this.$emit('update:status', false)
|
this.$emit('update:status', false)
|
||||||
},
|
},
|
||||||
|
/**
|
||||||
|
* 文件内容已经加载好了
|
||||||
|
*/
|
||||||
|
onReday() {
|
||||||
|
this.saved = true
|
||||||
|
this.previewDocument.style.zIndex = 9999
|
||||||
|
this.readyShow = true
|
||||||
|
this.$nextTick(() => {
|
||||||
|
Bus.$emit('loadFileReady')
|
||||||
|
let that = this
|
||||||
|
setTimeout(function () {
|
||||||
|
that.previewDocument.style.zIndex = 2001
|
||||||
|
},200)
|
||||||
|
})
|
||||||
|
},
|
||||||
/**
|
/**
|
||||||
* 编辑回调
|
* 编辑回调
|
||||||
* @param saved 是否已经保存
|
* @param saved 是否已经保存
|
||||||
@ -171,9 +190,16 @@ export default {
|
|||||||
background-color: rgba(0,0,0,.7);
|
background-color: rgba(0,0,0,.7);
|
||||||
}
|
}
|
||||||
|
|
||||||
.block {
|
.preview-block {
|
||||||
|
position: fixed;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
background-color: rgba(0,0,0,.7);
|
||||||
|
z-index: 2001;
|
||||||
|
|
||||||
.close-bar {
|
.close-bar {
|
||||||
z-index: 2006;
|
|
||||||
background-color: rgba(0,0,0,.5);
|
background-color: rgba(0,0,0,.5);
|
||||||
position: relative;
|
position: relative;
|
||||||
top: -2.5rem;
|
top: -2.5rem;
|
||||||
@ -197,7 +223,6 @@ export default {
|
|||||||
|
|
||||||
.preview-close {
|
.preview-close {
|
||||||
transform: rotate(-45deg);
|
transform: rotate(-45deg);
|
||||||
z-index: 2009;
|
|
||||||
position: absolute;
|
position: absolute;
|
||||||
font-size: 1.25rem;
|
font-size: 1.25rem;
|
||||||
top: -8px;
|
top: -8px;
|
||||||
|
|||||||
@ -7,7 +7,11 @@ export default {
|
|||||||
webDAVUrl: function(username) {
|
webDAVUrl: function(username) {
|
||||||
return window.location.origin + `${this.baseUrl}/webDAV/${username}`
|
return window.location.origin + `${this.baseUrl}/webDAV/${username}`
|
||||||
},
|
},
|
||||||
// webDAV的url
|
// office api url
|
||||||
|
officeApiUrl: function() {
|
||||||
|
return `${window.location.origin}/office/web-apps/apps/api/documents/api.js`
|
||||||
|
},
|
||||||
|
// office回调url
|
||||||
officeCallBackUrl: function(token, fileId) {
|
officeCallBackUrl: function(token, fileId) {
|
||||||
return `${window.location.origin}${this.baseUrl}/office/track?jmal-token=${token}&fileId=${fileId}`
|
return `${window.location.origin}${this.baseUrl}/office/track?jmal-token=${token}&fileId=${fileId}`
|
||||||
},
|
},
|
||||||
|
|||||||
@ -531,20 +531,20 @@
|
|||||||
if (msg === false) {
|
if (msg === false) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
alert($J.L(msg));
|
alert(msg);
|
||||||
},
|
},
|
||||||
|
|
||||||
//提示
|
//提示
|
||||||
messageSuccess(msg) {
|
messageSuccess(msg) {
|
||||||
$J.Message.success($J.L(msg));
|
$J.Message.success(msg);
|
||||||
},
|
},
|
||||||
|
|
||||||
messageWarning(msg) {
|
messageWarning(msg) {
|
||||||
$J.Message.warning($J.L(msg));
|
$J.Message.warning(msg);
|
||||||
},
|
},
|
||||||
|
|
||||||
messageError(msg) {
|
messageError(msg) {
|
||||||
$J.Message.error($J.L(msg));
|
$J.Message.error(msg);
|
||||||
},
|
},
|
||||||
|
|
||||||
//通知
|
//通知
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user