MessageBody.vue 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <template>
  2. <div class="body-container">
  3. <!-- <WujieVue
  4. width="100%"
  5. height="100%"
  6. name="sub-app"
  7. :url="defaultUrl"
  8. :sandbox="['allow-scripts', 'allow-same-origin', 'allow-forms', 'allow-popups']"
  9. :debug="true"
  10. :mode="'iframe'"
  11. :onError="handleError"
  12. :onBeforeLoad="beforeLoad"
  13. :onAfterLoad="afterLoad"
  14. sync
  15. ></WujieVue> -->
  16. <iframe id="dify" :src="defaultURL" width="100%" height="100%" frameborder="0"></iframe>
  17. </div>
  18. </template>
  19. <script setup>
  20. import { ref, onMounted } from 'vue';
  21. import { tokenExchange } from '../../apis/login';
  22. import { kuky_Authorization } from '../../base/storage';
  23. const props = defineProps({
  24. id: {
  25. type: String,
  26. required: true
  27. }
  28. });
  29. const DIFY_TOKEN = ref('');
  30. const BASE_URL = 'http://192.168.20.119:28003/app';
  31. const getToken = async () => {
  32. const res = await tokenExchange();
  33. if (res.code == 200) {
  34. DIFY_TOKEN.value = res.data.dify_token;
  35. }
  36. };
  37. const defaultURL = ref('');
  38. onMounted(async () => {
  39. await getToken();
  40. defaultURL.value = BASE_URL + '/' + props.id + `/workflow?token=${DIFY_TOKEN.value}`;
  41. const element = document.getElementById('dify');
  42. element.onload = function () {
  43. if (element && element.contentWindow) {
  44. console.log('iframe loaded', element.contentWindow);
  45. element.contentWindow.postMessage(
  46. JSON.stringify({
  47. type: 'insertStyle',
  48. value: `
  49. .sticky{display:none;}`
  50. }),
  51. defaultURL.value
  52. );
  53. }
  54. };
  55. });
  56. </script>
  57. <style scoped lang="css">
  58. .body-container {
  59. margin-top: 15px;
  60. height: calc(100% - 55px);
  61. }
  62. </style>