Merge branch 'feature/feature-20250430-h5' into uat

This commit is contained in:
Huangzhe
2025-05-27 21:35:38 +08:00
2 changed files with 50 additions and 42 deletions

View File

@@ -1,53 +1,60 @@
<script setup lang="ts"> <script setup lang="ts">
import { onMounted, ref } from 'vue'; import { onMounted, ref } from 'vue';
import { useRouter } from 'vue-router';
const host = window.location.origin; const host = window.location.origin;
const path = '/aiagent/assistant/78907182-cc42-4072-abae-86ef67c1ecd3/share?'; const path = '/aiagent/assistant/78907182-cc42-4072-abae-86ef67c1ecd3/share?';
const param = `token=${encodeURIComponent(localStorage.getItem('plantToken') as string)}&source=app`; const param = `token=${encodeURIComponent(localStorage.getItem('plantToken') as string)}&source=app`;
// const url = host + path + param;
const url = host + path + param; const url = host + path + param;
console.log(url); const iframe = ref<HTMLIFrameElement | null>(null);
// const iframe = ref<HTMLIFrameElement | null>(null); const router = useRouter();
onMounted(() => {
// 保存原始的window.open方法
const originalOpen = window.open;
// onMounted(() => { // 监听iframe的load事件确保iframe已完全加载
// // 保存原始的window.open方法 iframe.value?.addEventListener('load', () => {
// const originalOpen = window.open; try {
const iframeWindow = iframe.value?.contentWindow;
// // 监听iframe的load事件确保iframe已完全加载 // 尝试覆盖iframe的open方法
// iframe.value?.addEventListener('load', () => { if (iframeWindow) {
// try { // 方法一:直接覆盖
// const iframeWindow = iframe.value?.contentWindow; try {
iframeWindow.open = function (...args: any[]) {
// // 尝试覆盖iframe的open方法 const url = new URL(args[0]); // 使用 URL API 解析
// if (iframeWindow) { const path = url.pathname; // 获取路径部分
// // 方法一:直接覆盖 const query = Object.fromEntries(url.searchParams); // 将 search 转换为对象
// try { // 如果需要去除特定 host 前缀(如本地调试)
// iframeWindow.open = function (...args: any[]) { if (url.host === window.location.host) {
// // console.log('iframe中的open方法被调用参数', args); args[0] = args[0].replace(`https://${url.host}`, '');
// // 使用父窗口的open方法打开 }
// return originalOpen.apply(window, args as any); router.push({
// }; path,
// } catch (e) { query
// // 方法二如果直接覆盖失败尝试使用defineProperty });
// try { };
// Object.defineProperty(iframeWindow, 'open', { } catch (e) {
// value: function (...args: any[]) { // 方法二如果直接覆盖失败尝试使用defineProperty
// // console.log('iframe中的open方法被调用参数', args); try {
// return originalOpen.apply(window, args as any); Object.defineProperty(iframeWindow, 'open', {
// }, value: function (...args: any[]) {
// writable: true, // console.log('iframe中的open方法被调用参数', args);
// configurable: true return originalOpen.apply(window, args as any);
// }); },
// } catch (e2) { writable: true,
// // console.error('无法覆盖iframe的open方法(defineProperty)', e2); configurable: true
// } });
// } } catch (e2) {
// } console.error('无法覆盖iframe的open方法(defineProperty)', e2);
// } catch (error) { }
// console.error('无法覆盖iframe的open方法', error); }
// } }
// }); } catch (error) {
// }); console.error('无法覆盖iframe的open方法', error);
}
});
});
</script> </script>
<template> <template>

View File

@@ -11,7 +11,7 @@ import legacy from '@vitejs/plugin-legacy';
// shift + alt 快速定位到对应组件 // shift + alt 快速定位到对应组件
import { codeInspectorPlugin } from 'code-inspector-plugin'; import { codeInspectorPlugin } from 'code-inspector-plugin';
// 导入 dev tools // 导入 dev tools
import vueDevTools from 'vite-plugin-vue-devtools' import vueDevTools from 'vite-plugin-vue-devtools';
export default defineConfig(({ mode }) => { export default defineConfig(({ mode }) => {
// 接收 mode 参数 // 接收 mode 参数
@@ -24,6 +24,7 @@ export default defineConfig(({ mode }) => {
return { return {
// 必须 return 配置对象 // 必须 return 配置对象
server: { server: {
allowedHosts: ['yiligpt.x.digitalyili.com'],
host: '0.0.0.0', host: '0.0.0.0',
port: 3000, port: 3000,
proxy: { proxy: {