(vue)将dify和ragflow页面嵌入到vue3项目

(vue)将dify和ragflow页面嵌入到vue3项目


dify:

ragflow:


代码:

bash 复制代码
<template>
  <div class="dify-container">
    <iframe
      :src="`https://dify.dev.tudb.work/apps`" //ragflow地址:https://ragflow19.prod.tudb.work/
      frameborder="0"
      width="100%"
      :height="data.height"
    ></iframe>
  </div>
</template>

<script setup>
import { onMounted, onUnmounted, reactive } from 'vue';
const data = reactive({
  height: 0,
  email: '...@admin.com',
  password: '...@2025'
})

onMounted(() => {
  const dom = document.querySelector('.app-main');
  const height = dom ? dom.offsetHeight : 0;
  data.height = height;

  window.addEventListener('message', handleMessage);
});

onUnmounted(() => {
  window.removeEventListener('message', handleMessage);
});

const handleMessage = (event) => {
  const { isLoad, isLogin, isFailed } = event.data;
  if(isLoad){
    postToIframe();
    return
  }

  if(isLogin){//登录成功
    console.log('登录成功')
    return 
  }

  if(isFailed){//登录失败
    return
    console.log('登录失败')
  }
}

const postToIframe = () => {
  const iFrame = document.querySelector('iframe')
  if (iFrame) {
    iFrame.contentWindow?.postMessage({
      email: data.email,
      password: data.password,
    }, '*')
  }
}
</script>

<style lang="scss" scoped>
.dify-container {
  height: 100%;
}
</style>
相关推荐
你脸上有BUG14 小时前
【工程化】前端打包时间优化
前端
TeleostNaCl14 小时前
Google Chrome 浏览器历史记录的存储位置
前端·chrome·经验分享
大模型教程14 小时前
前端可以转型AI工程师吗?那可太能了...
前端·llm·agent
转转技术团队14 小时前
前端开发应该了解的浏览器背后的黑科技
前端
2503_9284115614 小时前
12.15 element-plus的一些组件(上)
前端·vue.js
JS_GGbond14 小时前
JavaScript原型链:一份会“遗传”的家族传家宝
前端·javascript
前端达人14 小时前
CSS终于不再是痛点:2026年这7个特性让你删掉一半JavaScript
开发语言·前端·javascript·css·ecmascript
阿蒙Amon14 小时前
JavaScript学习笔记:15.迭代器与生成器
javascript·笔记·学习
JS_GGbond14 小时前
当JS拷贝玩起了“俄罗斯套娃”:深拷贝与浅拷贝的趣味对决
前端·javascript
code_YuJun14 小时前
脚手架开发工具——npmlog
前端