Merge pull request #253 from jamebal/search

perf: dwg文件预览友好性提示
This commit is contained in:
jmal 2024-08-02 22:50:29 +08:00 committed by GitHub
commit 4039bf17b1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 35 additions and 15 deletions

View File

@ -633,7 +633,7 @@
<message-dialog
title="提示"
content="此文件不支持预览, 是否下载该文件?"
:content="notPreviewDialogMsg"
:show.sync="notPreviewDialogVisible"
button-size="mini"
operatButtonText="取消"
@ -1098,6 +1098,7 @@ export default {
drawFlag: false,
fileListScrollTop: 0,
initFileListScrollTop: 0,
notPreviewDialogMsg: '', // 非预览文件提示信息
notPreviewDialogVisible: false,
openingFile: '',
openCompressionVisible: false,
@ -1227,6 +1228,7 @@ export default {
break
case 'loadFileFailed':
this.notPreviewDialogVisible = true
this.notPreviewDialogMsg = msg.msg || '此文件不支持预览, 是否下载该文件?'
break
case 'clickMore':
this.$refs.fileListTable.tableSelectData = msg.data
@ -1477,7 +1479,6 @@ export default {
}
},
onmessage(msg) {
console.log(msg.url, this.$route.path, msg, this.path)
let fileDoc = msg.body
const url = msg.url
let index = this.fileList.findIndex(file => file.id === fileDoc.id)

View File

@ -2,11 +2,13 @@
<div>
<div class="top-bar">
<div class="top-left"></div>
<div class="top-center">{{file.name}}</div>
<div class="top-center">{{ file.name }}</div>
<div class="top-right">
<div class="top-right-option">
<el-button title="切换背景色" size="medium" type="primary" @click="changeBackground" :icon="lightTheme?'el-icon-moon':'el-icon-sunny'"></el-button>
<el-button title="显示全部" size="medium" type="primary" @click="reset" icon="el-icon-c-scale-to-original"></el-button>
<el-button title="切换背景色" size="medium" type="primary" @click="changeBackground"
:icon="lightTheme?'el-icon-moon':'el-icon-sunny'"></el-button>
<el-button title="显示全部" size="medium" type="primary" @click="reset"
icon="el-icon-c-scale-to-original"></el-button>
</div>
</div>
</div>
@ -17,7 +19,7 @@
</template>
<script>
import { createMxCad, MxCpp } from 'mxcad'
import { createMxCad, loadMxCADassembly, MxCpp } from 'mxcad'
import { MxFun } from 'mxdraw'
export default {
@ -57,10 +59,15 @@ export default {
canvas: '#mxCadCanvas',
locateFile: (fileName) => window.location.origin + '/resource/mxcad/wasm/2d-st/' + fileName,
fontspath: window.location.origin + '/resource/mxcad/fonts/',
fileUrl: this.mxwebUrl,
}).then(() => {
fileUrl: '',
onOpenFileComplete: () => {
this.$emit('onReady')
},
}).then((mxcad) => {
this.fetchFile()
MxFun.sendStringToExecute('Mx_Pan')
this.$emit('onReady')
}).catch((error) => {
console.error('加载 MxCAD assembly 时出错:', error)
})
},
methods: {
@ -71,6 +78,16 @@ export default {
mxcad.updateDisplay()
mxcad.setViewBackgroundColor(value, value, value)
},
fetchFile() {
const mxcad = this.mxcad()
mxcad.openWebFile(this.mxwebUrl, (iRet) => {
if (iRet === 0) {
this.$emit('onReady')
} else {
this.$emit('loadFileFailed', '文件加载失败, 请稍后再试, 或者对该文件重建索引')
}
})
},
reset() {
const mxcad = this.mxcad()
mxcad.regen()
@ -79,7 +96,7 @@ export default {
},
mxcad() {
return MxCpp.getCurrentMxCAD()
}
},
},
}
</script>

View File

@ -16,7 +16,7 @@
<svg-icon class="preview-close" icon-class="close"/>
</div>
<div class="wrapper">
<CADPreview v-if="fileType === 'cad'" :file="file" :shareId="shareId" :file-url="fileUrl" @onReady="onReady"></CADPreview>
<CADPreview v-if="fileType === 'cad'" :file="file" :shareId="shareId" :file-url="fileUrl" @onReady="onReady" @loadFileFailed="loadFileFailed"></CADPreview>
<pdf-preview v-else-if="fileType === 'pdf'" :file="file" :shareId="shareId" :file-url="fileUrl" @onReady="onReady"></pdf-preview>
<drawio v-else-if="fileType === 'drawio'" v-show="fileReday" :file="file" :shareId="shareId" :read-only="readOnly" @onEdit="onEdit" @onReady="onReady" @onClose="close"></drawio>
<my-mind-editor v-else-if="fileType === 'mind'" :file="file" :shareId="shareId" :read-only="readOnly" @onEdit="onEdit" @onReady="onReady" @onClose="close"></my-mind-editor>
@ -157,9 +157,9 @@ export default {
/**
* 加载失败
*/
loadFileFailed() {
loadFileFailed(msg) {
this.close()
this.$store.dispatch('updateMessage', { event: 'loadFileFailed'})
this.$store.dispatch('updateMessage', { event: 'loadFileFailed', msg: msg})
this.readyShow = true
},
/**

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 5.7 KiB

View File

@ -0,0 +1 @@
<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1722606319523" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="6475" xmlns:xlink="http://www.w3.org/1999/xlink" width="200" height="200"><path d="M874.834646 185.448819v774.047244a24.17285 24.17285 0 0 1-24.188977 24.188976H173.354331a24.180913 24.180913 0 0 1-24.188977-24.188976V64.503937a24.188976 24.188976 0 0 1 24.188977-24.188976h556.346456l145.133859 145.133858z" fill="#5892B6" p-id="6476"></path><path d="M874.834646 185.448819H753.889764a24.188976 24.188976 0 0 1-24.188977-24.188976V40.314961l145.133859 145.133858z" opacity=".2" p-id="6477"></path><path d="M433.966362 919.181102h-39.782803v-69.06759h39.782803v11.997732h-25.132346v15.166488h23.382677v11.997733h-23.382677v17.811149h25.132346v12.094488z m29.107402-36.565669h4.813606c4.49915 0 7.86948-0.886929 10.110992-2.644661 2.233449-1.798047 3.354205-4.394331 3.354205-7.796914 0-3.434835-0.94337-5.966614-2.838173-7.603401-1.854488-1.64485-4.789417-2.459213-8.788662-2.459213h-6.660031v20.504189z m33.058267-10.965669c0 7.434079-2.322142 13.118488-6.982551 17.061291-4.63622 3.93474-11.231748 5.90211-19.802708 5.90211h-6.281071V919.181102h-14.642394v-69.06759h22.060347c8.385512 0 14.73915 1.80611 19.085102 5.426394 4.378205 3.596094 6.571339 8.966047 6.571338 16.109858z m69.261103-21.536252v44.693165c0 5.095811-1.144945 9.570772-3.442898 13.416819-2.265701 3.837984-5.563465 6.780976-9.877165 8.828976-4.313701 2.048-9.417575 3.072-15.303559 3.072-8.885417 0-15.779276-2.265701-20.697701-6.805165-4.910362-4.563654-7.369575-10.796346-7.369575-18.706142v-44.499653h14.594016v42.282331c0 5.321575 1.080441 9.224063 3.225197 11.715527 2.136693 2.483402 5.676346 3.733165 10.627023 3.733165 4.781354 0 8.248441-1.249764 10.393197-3.733165 2.177008-2.523717 3.257449-6.458457 3.257449-11.812283v-42.185575h14.594016z m16.916157 0h21.495937c9.796535 0 16.900031 1.394898 21.310489 4.200819 4.434646 2.773669 6.660031 7.200252 6.660031 13.279748 0 4.120189-0.975622 7.506646-2.926866 10.151307a11.513953 11.513953 0 0 1-7.700158 4.773291v0.475717c4.378205 0.975622 7.522772 2.797858 9.449827 5.474771 1.951244 2.676913 2.926866 6.240756 2.926866 10.683465 0 6.297197-2.281827 11.207559-6.853543 14.73915-4.531402 3.523528-10.707654 5.289323-18.520693 5.289322H582.309291v-69.06759z m14.650457 27.349669h8.498394c3.966992 0 6.837417-0.612787 8.603212-1.838362 1.789984-1.233638 2.693039-3.265512 2.69304-6.095622 0-2.644661-0.975622-4.539465-2.934929-5.668284-1.918992-1.169134-4.974866-1.749669-9.159559-1.749669h-7.700158v15.351937z m0 11.626835v17.996598h9.53852c4.031496 0 7.014803-0.774047 8.933795-2.314079 1.918992-1.548094 2.878488-3.902488 2.878488-7.08737 0-5.732787-4.096-8.59515-12.279937-8.595149h-9.070866zM503.937008 677.291339V395.086614s-72.566929-48.377953-193.511811-56.440945v266.07874s137.070866 8.062992 193.511811 72.56693zM713.574803 604.724409V338.645669c-120.944882 8.062992-193.511811 56.440945-193.511811 56.440945v282.204725c56.440945-64.503937 193.511811-72.566929 193.511811-72.56693z" fill="#FFFFFF" p-id="6478"></path><path d="M729.700787 378.96063v258.015748s-120.944882 0-217.700787 66.922835C415.244094 636.976378 294.299213 636.976378 294.299213 636.976378V378.96063h-24.188977v282.204724s104.818898-16.125984 241.889764 48.377953c137.070866-64.503937 241.889764-48.377953 241.889764-48.377953V378.96063h-24.188977z" fill="#FFFFFF" p-id="6479"></path></svg>

After

Width:  |  Height:  |  Size: 3.5 KiB

View File

@ -92,8 +92,8 @@ iconClass.set('plist','file-plist')
iconClass.set('iso','file-iso')
iconClass.set('glb','file-glb')
iconClass.set('gltf','file-glb')
iconClass.set('epub','epub')
iconClass.set('dwg','dwg')
iconClass.set('epub','file-epub')
iconClass.set('dwg','file-dwg')
export function findIconClass(file){
if(!file){