Browse Source

[Feat 0000] CADViewer配置修改

houzekong 4 months ago
parent
commit
6968ffa0dd

+ 4 - 4
public/mxcad/mxUiConfig.json

@@ -7,13 +7,13 @@
   "?logoImg:logo图标": "布尔值false表示不显示, 也可以自行设置网络图片地址",
   "logoImg": false,
   "?isShowHeaderTopBar": "头部标题栏显示隐藏 为false 则logoImg失效",
-  "isShowHeaderTopBar": true,
+  "isShowHeaderTopBar": false,
   "?isShowHeaderTopBarRightBtns": "头部标题栏右侧按钮显示隐藏",
   "isShowHeaderTopBarRightBtns": false,
   "?headerTopBarRightBtns": "头部右侧按钮标识, 未填写则不显示",
   "headerTopBarRightBtns": ["ai", "language", "theme"],
   "?mTitleButtonBarData:标题按钮栏数据": "标题按钮栏数据",
-  "isShowTitleButtonBar": true,
+  "isShowTitleButtonBar": false,
   "mTitleButtonBarData": [
   ],
   "?mTopButtonBarData:顶部按钮栏": "",
@@ -62,7 +62,7 @@
   ],
   "?mLeftButtonBarData:左侧按钮栏": "左侧按钮栏",
   "mLeftButtonBarData": {
-    "isShow": true,
+    "isShow": false,
     "buttonBarData": [
       {
         "icon": "zhixian",
@@ -163,7 +163,7 @@
   },
   "?mRightButtonBarData:右侧按钮栏": "右侧按钮栏",
   "mRightButtonBarData": {
-    "isShow": true,
+    "isShow": false,
     "buttonBarData": [
       {
         "icon": "shanchu",

+ 4 - 8
src/components/CADViewer/src/hooks/useCADViewer.ts

@@ -2,9 +2,6 @@ import { CAD_VIEWER_IFRAME_ID } from '../viewer.data';
 import { message } from 'ant-design-vue';
 import { transformCadFile } from '../viewer.api';
 import { SupportedOperationName } from '../types';
-import { useGlobSetting } from '/@/hooks/setting';
-const globSetting = useGlobSetting();
-const baseApiUrl = globSetting.domainUrl;
 
 // 先设计成这样避免hooks无法取消注册
 const hooks = new Map<SupportedOperationName, () => void>();
@@ -25,15 +22,14 @@ export default function useCADViewer() {
   }
 
   /** 调用 api 转换文件格式,并返回转换后文件的网络地址 */
-  function processFile(file: Blob) {
-    const data = new FormData();
-    data.append('file', file);
+  function processFile(id: string) {
     const close = message.loading('正在转换文件格式,请稍等', 0);
-    return transformCadFile(data)
+    return transformCadFile({ id })
       .then((result) => {
         const filepath = result.replace('/data/file/', '');
         if (import.meta.env.PROD) {
-          return `${baseApiUrl}/sys/common/static/${filepath}`.replace(/\/+/g, '/');
+          // cad为打头是要走 nginx 代理,代理到存下面的文件的服务器
+          return `/cad/sys/common/static/${filepath}`.replace(/\/+/g, '/');
         } else {
           return import.meta.env.VITE_GLOB_DOMAIN_URL + `/sys/common/static/${filepath}`.replace(/\/+/g, '/');
         }

+ 10 - 17
src/views/vent/performance/fileDetail/commen/CADViewer.vue

@@ -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);
     }
   });