Browse Source

magic api iframe 替换

xiaochan 1 year ago
parent
commit
c4051621fe

+ 1 - 1
.env.production

@@ -3,7 +3,7 @@ ENV = 'production'
 VITE_BASE_URL = 'http://172.16.32.167:8077'
 VITE_SOCKET_URL = 'ws://172.16.32.160:8707/websocket/'
 VITE_EMR_CONTROL_URL = '172.16.32.160:9227'
-VITE_DATA_BASE = 'http://172.16.32.160:9205'
+VITE_DATA_BASE = 'http://172.16.32.167:9205'
 VITE_EMR_SOCKET = 'http://172.16.32.160:8707/socketApi'
 
 VITE_HOSPITAL_NAME = '长沙泰和'

+ 18 - 0
src/components/cy/iframe/Iframes.vue

@@ -0,0 +1,18 @@
+<script setup lang="ts">
+import {iframeList, showIframe} from "@/components/cy/iframe/useIframe";
+
+
+</script>
+
+<template>
+  <div class="cy_h-w_max" v-show="showIframe">
+    <iframe
+        :ref="(el) => item?.onRef(el)"
+        :src="item.src"
+        v-for="item in iframeList"/>
+  </div>
+</template>
+
+<style scoped lang="scss">
+
+</style>

+ 38 - 0
src/components/cy/iframe/useIframe.ts

@@ -0,0 +1,38 @@
+import {Ref, onActivated, onDeactivated, ref} from "vue";
+
+export const showIframe = ref(false)
+export const iframeList: Ref<Option[]> = ref([])
+
+declare type Option = {
+    src: string;
+    key: string;
+    onRef?: (el: any) => void;
+    show?: boolean
+}
+
+export function useIframe(div: Ref<HTMLDivElement | null>, opt: Option) {
+    const index = iframeList.value.push(opt)
+
+
+    div?.value?.addEventListener('visibilitychange', () => {
+        console.log(123213)
+    })
+
+    onActivated(() => {
+        showIframe.value = true
+        iframeList.value[index].show = true
+    })
+
+    onDeactivated(() => {
+        showIframe.value = false
+        iframeList.value[index].show = false
+    })
+
+    function stop() {
+        iframeList.value.splice(index, 1)
+    }
+
+    return {
+        stop
+    }
+}

+ 2 - 1
src/router/index.js

@@ -24,7 +24,8 @@ const router = createRouter({
 
 let routesAsynced = false
 
-const vueFile = import.meta.glob('/src/views/**/*.vue')
+const vueFile = import.meta.glob('../views/**/*.{vue,tsx}');
+console.log(vueFile)
 
 //   这个方法可以动态添加 路由
 function text() {

+ 62 - 0
src/store/noLocalStorage.ts

@@ -0,0 +1,62 @@
+// @ts-ignore
+import {fetchMenusApi} from "@/api/login";
+import {Ref, ref} from "vue";
+import {isDev} from "@/utils/public";
+
+declare type RoutesType = {
+    id: number;
+    path: string;
+    completeRoute: string;
+    metaTitle: string;
+    metaIcon: string | null;
+    parent: number;
+    hideTabs: null;
+    hideMenu: null;
+    redirect: null;
+    meta: {
+        icon: string | null;
+        title: string;
+    };
+    children: RoutesType[] | null;
+}
+
+declare type MenusData = {
+    flatRoutes: {
+        id: null | string;
+        path: null | string;
+        completeRoute: string;
+        metaTitle: string;
+        metaIcon: null | string;
+        parent: null | string;
+        hideTabs: null | string;
+        hideMenu: null | string;
+        redirect: null | string;
+        meta: null | string;
+        children: null | string;
+    }[],
+    paths: string[],
+    routes: RoutesType[]
+}
+
+export const menusData: Ref<MenusData> = ref({
+    routes: [],
+    flatRoutes: [],
+    paths: [],
+})
+
+let once = false
+
+export const initStoreData = async () => {
+    if (once) {
+        return
+    }
+    await fetchMenusApi().then((res: MenusData) => {
+        isDev && console.log(res)
+        menusData.value = res
+    }).catch(() => {
+
+    }).finally(() => {
+        once = true
+    })
+    return once
+}

+ 2 - 1
src/utils/database/magic-api-request.ts

@@ -5,7 +5,8 @@ import {CyMessageBox} from "@/components/cy/message-box";
 
 // @ts-ignore
 // export const MAGIC_API = import.meta.env.VITE_DATA_BASE
-export const MAGIC_API = 'http://172.16.32.160:9205'
+export const MAGIC_API = 'http://172.16.32.167:9205'
+export const MAGIC_API_IFRAME = MAGIC_API.replaceAll("9205", "9206")
 
 const service = axios.create({
     baseURL: MAGIC_API,

+ 2 - 2
src/views/data-base/data-base-api/DataBase.vue

@@ -8,7 +8,7 @@ import {
 } from "vue";
 import {userInfoStore} from "@/utils/store-public";
 import DataBaseDialog from "@/views/data-base/data-base-api/components/DataBaseDialog.vue";
-import {MAGIC_API} from "@/utils/database/magic-api-request";
+import {MAGIC_API_IFRAME} from "@/utils/database/magic-api-request";
 
 const iframe = ref<HTMLIFrameElement | null>(null)
 const func = {
@@ -52,7 +52,7 @@ onMounted(async () => {
 
 <template>
   <DataBaseDialog ref="dialogRef"/>
-  <iframe :src="MAGIC_API + '/magic/web/index.html'"
+  <iframe :src="MAGIC_API_IFRAME + '/magic/web/index.html'"
           width="100%"
           height="100%"
           style="border: 0"

+ 2 - 2
src/views/data-base/page-editor-help-v2/components/page-help-editor/MagicIframeEditor.vue

@@ -5,13 +5,13 @@ import {ReportForms} from "@/api/reports/report-query-center";
 import {pageHelpV2Mitt} from "@/views/data-base/page-editor-help-v2/page-help-v2";
 import {useEventListener} from "@vueuse/core";
 import {xcMessage} from "@/utils/xiaochan-element-plus";
-import {MAGIC_API} from "@/utils/database/magic-api-request";
+import {MAGIC_API_IFRAME} from "@/utils/database/magic-api-request";
 
 const iframe = ref<HTMLIFrameElement>()
 // const src = 'http://192.168.56.1:8991'
 // const src = import.meta.env.VITE_DATA_BASE + '/magic/web/index.html'
 
-const src = `${MAGIC_API}/magic/web/index.html`
+const src = `${MAGIC_API_IFRAME}/magic/web/index.html`
 
 function sendMessage(name: string, value: any) {
   const data = {