Skip to content

Commit

Permalink
文件预览优化
Browse files Browse the repository at this point in the history
  • Loading branch information
kuaifan committed Dec 10, 2021
1 parent 0fe89c3 commit 5fe79c4
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 11 deletions.
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ services:

fileview:
container_name: "dootask-fileview-${APP_ID}"
image: "kuaifan/fileview:4.1.0"
image: "kuaifan/fileview:4.1.0-SNAPSHOT"
environment:
TZ: "Asia/Shanghai"
KK_CONTEXT_PATH: "/fileview"
Expand Down
38 changes: 28 additions & 10 deletions resources/assets/js/pages/manage/components/FileContent.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
</div>
<span slot="reference">[{{$L('未保存')}}*]</span>
</EPopover>
{{formatName(file.name, file.type)}}
{{formatName(file)}}
</div>
<div class="header-user">
<ul>
Expand Down Expand Up @@ -62,7 +62,7 @@
<OnlyOffice v-else-if="['word', 'excel', 'ppt'].includes(file.type)" v-model="contentDetail"/>
</div>
</template>
<div v-if="loadContent > 0" class="content-load"><Loading/></div>
<div v-if="loadContent > 0 || previewLoad" class="content-load"><Loading/></div>
</div>
</template>

Expand Down Expand Up @@ -106,10 +106,19 @@ export default {
contentDetail: null,
contentBak: {},
editUser: []
editUser: [],
loadPreview: true,
}
},
mounted() {
window.addEventListener('message', this.handleMessage)
},
beforeDestroy() {
window.removeEventListener('message', this.handleMessage)
},
watch: {
file: {
handler(info) {
Expand Down Expand Up @@ -174,6 +183,10 @@ export default {
return this.contentDetail && this.contentDetail.preview === true;
},
previewLoad() {
return this.isPreview && this.loadPreview === true;
},
previewUrl() {
if (this.isPreview) {
return this.$store.state.method.apiUrl("../fileview/onlinePreview?url=" + encodeURIComponent(this.contentDetail.url))
Expand All @@ -184,6 +197,15 @@ export default {
},
methods: {
handleMessage (event) {
const data = event.data;
switch (data.act) {
case 'ready':
this.loadPreview = false;
break
}
},
getContent() {
if (!this.fileId) {
this.contentDetail = {};
Expand Down Expand Up @@ -287,13 +309,9 @@ export default {
this.unsaveTip = false;
},
formatName(name, type) {
if (type == 'word') {
name += ".docx";
} else if (type == 'excel') {
name += ".xlsx";
} else if (type == 'ppt') {
name += ".pptx";
formatName({name, ext}) {
if (ext != '') {
name += "." + ext;
}
return name;
},
Expand Down

0 comments on commit 5fe79c4

Please sign in to comment.