From 752ea4c647a8a8d35d0872acb405272be560237e Mon Sep 17 00:00:00 2001
From: ludc
Date: 星期四, 13 七月 2023 10:21:38 +0800
Subject: [PATCH] 代码整合
---
Source/UBCS-WEB/dist/src/components/iframe/main.vue | 129 +++++++++++++++++++++++++++++++++++++++++++
1 files changed, 129 insertions(+), 0 deletions(-)
diff --git a/Source/UBCS-WEB/dist/src/components/iframe/main.vue b/Source/UBCS-WEB/dist/src/components/iframe/main.vue
new file mode 100644
index 0000000..4d421bc
--- /dev/null
+++ b/Source/UBCS-WEB/dist/src/components/iframe/main.vue
@@ -0,0 +1,129 @@
+<template>
+ <basic-container>
+ <iframe :src="src"
+ class="iframe"
+ ref="iframe"></iframe>
+ </basic-container>
+</template>
+
+<script>
+ import {mapGetters} from "vuex";
+ import NProgress from "nprogress"; // progress bar
+ import "nprogress/nprogress.css"; // progress bar style
+ export default {
+ name: "AvueIframe",
+ data() {
+ return {
+ urlPath: this.getUrlPath() //iframe src 璺緞
+ };
+ },
+ created() {
+ NProgress.configure({showSpinner: false});
+ },
+ mounted() {
+ this.load();
+ this.resize();
+ },
+ props: ["routerPath"],
+ watch: {
+ $route: function () {
+ this.load();
+ },
+ routerPath: function () {
+ // 鐩戝惉routerPath鍙樺寲锛屾敼鍙榮rc璺緞
+ this.urlPath = this.getUrlPath();
+ }
+ },
+ computed: {
+ ...mapGetters(["screen"]),
+ src() {
+ return this.$route.query.src
+ ? this.$route.query.src.replace("$", "#")
+ : this.urlPath;
+ }
+ },
+ methods: {
+ // 鏄剧ず绛夊緟妗�
+ show() {
+ NProgress.start();
+ },
+ // 闅愯棌绛夊緟鐙�
+ hide() {
+ NProgress.done();
+ },
+ // 鍔犺浇娴忚鍣ㄧ獥鍙e彉鍖栬嚜閫傚簲
+ resize() {
+ window.onresize = () => {
+ this.iframeInit();
+ };
+ },
+ // 鍔犺浇缁勪欢
+ load() {
+ this.show();
+ var flag = true; //URL鏄惁鍖呭惈闂彿
+ if (this.$route.query.src !== undefined && this.$route.query.src.indexOf("?") === -1) {
+ flag = false;
+ }
+ var list = [];
+ for (var key in this.$route.query) {
+ if (key !== "src" && key !== "name" && key !== "i18n") {
+ list.push(`${key}= this.$route.query[key]`);
+ }
+ }
+ list = list.join("&").toString();
+ if (flag) {
+ this.$route.query.src = `${this.$route.query.src}${
+ list.length > 0 ? `&list` : ""
+ }`;
+ } else {
+ this.$route.query.src = `${this.$route.query.src}${
+ list.length > 0 ? `?list` : ""
+ }`;
+ }
+ //瓒呮椂3s鑷姩闅愯棌绛夊緟鐙傦紝鍔犲己鐢ㄦ埛浣撻獙
+ let time = 3;
+ const timeFunc = setInterval(() => {
+ time--;
+ if (time === 0) {
+ this.hide();
+ clearInterval(timeFunc);
+ }
+ }, 1000);
+ this.iframeInit();
+ },
+ //iframe绐楀彛鍒濆鍖�
+ iframeInit() {
+ const iframe = this.$refs.iframe;
+ const clientHeight =
+ document.documentElement.clientHeight - (screen > 1 ? 200 : 130);
+ if (!iframe) return;
+ iframe.style.height = `${clientHeight}px`;
+ if (iframe.attachEvent) {
+ iframe.attachEvent("onload", () => {
+ this.hide();
+ });
+ } else {
+ iframe.onload = () => {
+ this.hide();
+ };
+ }
+ },
+ getUrlPath: function () {
+ //鑾峰彇 iframe src 璺緞
+ let url = window.location.href;
+ url = url.replace("/myiframe", "");
+ return url;
+ }
+ }
+ };
+</script>
+
+<style lang="scss">
+ .iframe {
+ width: 100%;
+ height: 100%;
+ border: 0;
+ overflow: hidden;
+ box-sizing: border-box;
+ }
+</style>
--
Gitblit v1.9.3