|  | @@ -5,33 +5,25 @@
 | 
	
		
			
				|  |  |  <script lang="ts" setup>
 | 
	
		
			
				|  |  |    import { onMounted, onUnmounted } from 'vue';
 | 
	
		
			
				|  |  |    import { CADViewer, useCADViewer } from '/@/components/CADViewer';
 | 
	
		
			
				|  |  | -  import { downloadById } from '../fileDetail.api';
 | 
	
		
			
				|  |  |    import { useRoute } from 'vue-router';
 | 
	
		
			
				|  |  | -  import { message } from 'ant-design-vue';
 | 
	
		
			
				|  |  | +  import { useGlobSetting } from '/@/hooks/setting';
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |    const props = defineProps<{
 | 
	
		
			
				|  |  |      // 文件共享中心中该文件的ID
 | 
	
		
			
				|  |  |      id: string;
 | 
	
		
			
				|  |  |      // 文件名
 | 
	
		
			
				|  |  | -    filename: string;
 | 
	
		
			
				|  |  | +    filename?: string;
 | 
	
		
			
				|  |  |      height: number;
 | 
	
		
			
				|  |  |    }>();
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |    const { processFile, postMessage, registHook, unregistHook } = useCADViewer();
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -  function openFile(id: string, filename: string) {
 | 
	
		
			
				|  |  | +  function openFile(id: string) {
 | 
	
		
			
				|  |  |      // 只触发一次,因为MKY_Open_Mxweb之后会自动触发MKY_Open_File_Complete钩子,导致循环
 | 
	
		
			
				|  |  |      registHook('MKY_Open_File_Complete', () => {
 | 
	
		
			
				|  |  |        unregistHook('MKY_Open_File_Complete');
 | 
	
		
			
				|  |  | -      const loading = message.loading('正在下载文件', 0);
 | 
	
		
			
				|  |  | -      downloadById({ id, ifMine: initByRoute }).then((res: Blob) => {
 | 
	
		
			
				|  |  | -        processFile(new File([res], filename))
 | 
	
		
			
				|  |  | -          .then((path) => {
 | 
	
		
			
				|  |  | -            postMessage('MKY_Open_Mxweb', path);
 | 
	
		
			
				|  |  | -          })
 | 
	
		
			
				|  |  | -          .finally(() => {
 | 
	
		
			
				|  |  | -            loading();
 | 
	
		
			
				|  |  | -          });
 | 
	
		
			
				|  |  | +      processFile(id).then((path) => {
 | 
	
		
			
				|  |  | +        postMessage('MKY_Open_Mxweb', path);
 | 
	
		
			
				|  |  |        });
 | 
	
		
			
				|  |  |      });
 | 
	
		
			
				|  |  |    }
 | 
	
	
		
			
				|  | @@ -44,17 +36,18 @@
 | 
	
		
			
				|  |  |    //   }
 | 
	
		
			
				|  |  |    // );
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -  let initByRoute = false;
 | 
	
		
			
				|  |  | +  // let initByRoute = false;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |    onMounted(() => {
 | 
	
		
			
				|  |  | +    console.log(useGlobSetting());
 | 
	
		
			
				|  |  |      const route = useRoute();
 | 
	
		
			
				|  |  |      if (route.query.id && route.query.filename) {
 | 
	
		
			
				|  |  | -      initByRoute = true;
 | 
	
		
			
				|  |  | +      // initByRoute = true;
 | 
	
		
			
				|  |  |        // 通过 url query 指定文件 ID 的形式使用该组件
 | 
	
		
			
				|  |  | -      openFile(route.query.id as string, route.query.filename as string);
 | 
	
		
			
				|  |  | +      openFile(route.query.id as string);
 | 
	
		
			
				|  |  |      } else {
 | 
	
		
			
				|  |  |        // 通过 props 指定文件 ID 的形式使用该组件
 | 
	
		
			
				|  |  | -      openFile(props.id, props.filename);
 | 
	
		
			
				|  |  | +      openFile(props.id);
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |    });
 | 
	
		
			
				|  |  |  
 |