Procházet zdrojové kódy

封装iframe组件

RuoYi před 4 roky
rodič
revize
5c130cfda6

+ 36 - 0
ruoyi-ui/src/components/iFrame/index.vue

@@ -0,0 +1,36 @@
1
+<template>
2
+  <div v-loading="loading" :style="'height:' + height">
3
+    <iframe
4
+      :src="src"
5
+      frameborder="no"
6
+      style="width: 100%; height: 100%"
7
+      scrolling="auto"
8
+    />
9
+  </div>
10
+</template>
11
+<script>
12
+export default {
13
+  props: {
14
+    src: {
15
+      type: String,
16
+      required: true
17
+    },
18
+  },
19
+  data() {
20
+    return {
21
+      height: document.documentElement.clientHeight - 94.5 + "px;",
22
+      loading: true,
23
+      url: this.src
24
+    };
25
+  },
26
+  mounted: function () {
27
+    setTimeout(() => {
28
+      this.loading = false;
29
+    }, 300);
30
+    const that = this;
31
+    window.onresize = function temp() {
32
+      that.height = document.documentElement.clientHeight - 94.5 + "px;";
33
+    };
34
+  }
35
+};
36
+</script>

+ 2 - 2
ruoyi-ui/src/layout/components/Sidebar/Logo.vue

@@ -2,11 +2,11 @@
2 2
   <div class="sidebar-logo-container" :class="{'collapse':collapse}" :style="{ backgroundColor: sideTheme === 'theme-dark' ? variables.menuBg : variables.menuLightBg }">
3 3
     <transition name="sidebarLogoFade">
4 4
       <router-link v-if="collapse" key="collapse" class="sidebar-logo-link" to="/">
5
-        <img v-if="logo" :src="logo" class="sidebar-logo">
5
+        <img v-if="logo" :src="logo" class="sidebar-logo" />
6 6
         <h1 v-else class="sidebar-title" :style="{ color: sideTheme === 'theme-dark' ? variables.sidebarTitle : variables.sidebarLightTitle }">{{ title }} </h1>
7 7
       </router-link>
8 8
       <router-link v-else key="expand" class="sidebar-logo-link" to="/">
9
-        <img v-if="logo" :src="logo" class="sidebar-logo">
9
+        <img v-if="logo" :src="logo" class="sidebar-logo" />
10 10
         <h1 class="sidebar-title" :style="{ color: sideTheme === 'theme-dark' ? variables.sidebarTitle : variables.sidebarLightTitle }">{{ title }} </h1>
11 11
       </router-link>
12 12
     </transition>

+ 4 - 15
ruoyi-ui/src/views/monitor/druid/index.vue

@@ -1,26 +1,15 @@
1 1
 <template>
2
-  <div v-loading="loading" :style="'height:'+ height">
3
-    <iframe :src="src" frameborder="no" style="width: 100%;height: 100%" scrolling="auto" />
4
-  </div>
2
+  <i-frame :src="url" />
5 3
 </template>
6 4
 <script>
5
+import iFrame from "@/components/iFrame/index";
7 6
 export default {
8 7
   name: "Druid",
8
+  components: { iFrame },
9 9
   data() {
10 10
     return {
11
-      src: process.env.VUE_APP_BASE_API + "/druid/login.html",
12
-      height: document.documentElement.clientHeight - 94.5 + "px;",
13
-      loading: true
11
+      url: process.env.VUE_APP_BASE_API + "/druid/login.html"
14 12
     };
15 13
   },
16
-  mounted: function() {
17
-    setTimeout(() => {
18
-      this.loading = false;
19
-    }, 230);
20
-    const that = this;
21
-    window.onresize = function temp() {
22
-      that.height = document.documentElement.clientHeight - 94.5 + "px;";
23
-    };
24
-  }
25 14
 };
26 15
 </script>