|
@@ -7,6 +7,7 @@
|
|
|
import { CADViewer, useCADViewer } from '/@/components/CADViewer';
|
|
|
import { downLoad } from '../fileDetail.api';
|
|
|
import { useRoute } from 'vue-router';
|
|
|
+ import { message } from 'ant-design-vue';
|
|
|
|
|
|
const props = defineProps<{
|
|
|
// 文件共享中心中该文件的ID
|
|
@@ -19,14 +20,18 @@
|
|
|
const { processFile, postMessage } = useCADViewer();
|
|
|
|
|
|
function openFile(id: string, filename: string) {
|
|
|
+ const loading = message.loading('正在下载文件', 0);
|
|
|
downLoad({ id }).then((res: Blob) => {
|
|
|
- processFile(new File([res], filename)).then((path) => {
|
|
|
- postMessage('MKY_Open_Mxweb', path);
|
|
|
- });
|
|
|
+ processFile(new File([res], filename))
|
|
|
+ .then((path) => {
|
|
|
+ postMessage('MKY_Open_Mxweb', path);
|
|
|
+ })
|
|
|
+ .finally(() => {
|
|
|
+ loading();
|
|
|
+ });
|
|
|
});
|
|
|
}
|
|
|
|
|
|
- // 通过 props 指定文件 ID 的形式使用该组件
|
|
|
watch(
|
|
|
() => props.id,
|
|
|
(v) => {
|
|
@@ -35,11 +40,16 @@
|
|
|
}
|
|
|
);
|
|
|
|
|
|
- // 通过 url query 指定文件 ID 的形式使用该组件
|
|
|
onMounted(() => {
|
|
|
+ console.log('debug try open');
|
|
|
+ postMessage('MKY_Open_Mxweb', window.location.origin + '/mxcad/test31.mxweb');
|
|
|
const route = useRoute();
|
|
|
if (route.query.id && route.query.filename) {
|
|
|
+ // 通过 url query 指定文件 ID 的形式使用该组件
|
|
|
openFile(route.query.id as string, route.query.filename as string);
|
|
|
+ } else {
|
|
|
+ // 通过 props 指定文件 ID 的形式使用该组件
|
|
|
+ openFile(props.id, props.filename);
|
|
|
}
|
|
|
});
|
|
|
</script>
|