|
@@ -6,17 +6,48 @@
|
|
|
height="840"
|
|
|
frameborder="0"
|
|
|
scrolling="auto"
|
|
|
+ id="myIframe"
|
|
|
+ ref="iframe"
|
|
|
></iframe>
|
|
|
</el-container>
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
+import { getCatalogToken } from "@/api/login";
|
|
|
+import { setCatalogToken } from '@/utils/auth'
|
|
|
export default {
|
|
|
data() {
|
|
|
return {
|
|
|
- iframeUrl: "http://localhost:8090/catalog/InfoSystemManageHome",
|
|
|
+ // iframeUrl: "http://localhost:8090/catalog/Upper-chain/DutyCatalogue", //要跳转的菜单页
|
|
|
+ iframeUrl: "http://localhost:8090/catalog/SixDutyCatalogue", //要跳转的菜单页
|
|
|
};
|
|
|
},
|
|
|
+ mounted() {
|
|
|
+ // 获取 iframe 元素
|
|
|
+ const iframe = this.$refs.iframe;
|
|
|
+
|
|
|
+ // 监听来自 iframe 的消息
|
|
|
+ window.addEventListener("message", this.handleIframeMessage, false);
|
|
|
+
|
|
|
+ // 获取 token 并发送给 iframe
|
|
|
+ getCatalogToken().then((result) => {
|
|
|
+ const token = result; // 假设 result 是整个 token 对象
|
|
|
+ setCatalogToken(token)
|
|
|
+ // 更新 iframe 的 URL 后再发送 token
|
|
|
+ this.iframeUrl = this.iframeUrl; // 强制刷新 iframe(可能需要更改为其他 URL)
|
|
|
+
|
|
|
+ // 确保 iframe 已加载,再发送 token
|
|
|
+ iframe.onload = () => {
|
|
|
+ const params = {
|
|
|
+ type: "setToken",
|
|
|
+ token: token, // 传递 token
|
|
|
+ };
|
|
|
+
|
|
|
+ // 使用 postMessage 向 iframe 发送 token
|
|
|
+ iframe.contentWindow.postMessage(params, "http://localhost:8090"); // 这里是子系统的域名,需要与子系统的 URL 匹配
|
|
|
+ };
|
|
|
+ });
|
|
|
+ },
|
|
|
methods: {
|
|
|
changeIframeUrl(url) {
|
|
|
this.iframeUrl = url;
|