(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>
相关推荐
OpenTiny社区11 小时前
我的新同事是个AI:支持skill后,它用TinyVue搭项目还挺溜!
前端·vue.js·ai编程
心在飞扬11 小时前
MultiVector 多向量检索
前端·后端
用户390513321928811 小时前
async 函数返回的 Promise 状态何时变为 resolved
前端
李剑一11 小时前
大屏天气展示太普通?视觉升级!用 Canvas 做动态天气遮罩,雷阵雨效果直接封神
前端·vue.js·canvas
Lee川11 小时前
现代Web开发中的CSS继承、Flexbox布局与LocalStorage交互:从文档解析到实践应用
前端·css
csdn飘逸飘逸11 小时前
Autojs基础-用户界面(ui)
javascript
炫饭第一名11 小时前
速通Canvas指北🦮——图形、文本与样式篇
前端·javascript·程序员
本末倒置18311 小时前
面向 Vue 开发者的 Next.js 快速入门指南
前端·vue.js
暴走的小呆11 小时前
vue3暗影代理:非原始值的响应式迷局
前端
进击的尘埃11 小时前
React useEffect 的闭包陷阱与竞态条件:你以为的 cleanup 真的在正确时机执行了吗
javascript