(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>
相关推荐
初遇你时动了情10 小时前
css中backdrop-filter 详细使用 ios毛玻璃效果、filter和backdrop-filter使用说明
前端·css
景彡先生12 小时前
Python Selenium详解:从入门到实战,Web自动化的“瑞士军刀”
前端·python·selenium
Liudef0613 小时前
DeepseekV3.2 实现构建简易版Wiki系统:从零开始的HTML实现
前端·javascript·人工智能·html
景早15 小时前
vue 记事本案例详解
前端·javascript·vue.js
wangjialelele16 小时前
Qt中的常用组件:QWidget篇
开发语言·前端·c++·qt
乔冠宇16 小时前
vue需要学习的点
前端·vue.js·学习
用户479492835691516 小时前
同样是 #,锚点和路由有什么区别
前端·javascript
Hero_112716 小时前
在pycharm中install不上需要的包
服务器·前端·pycharm
爱上妖精的尾巴17 小时前
5-26 WPS JS宏数组元素添加删除应用
开发语言·前端·javascript·wps·js宏
是谁眉眼17 小时前
wpsapi
前端·javascript·html