diff --git a/examples/react16/src/Location.js b/examples/react16/src/Location.js index f3985da0a..186cb968b 100644 --- a/examples/react16/src/Location.js +++ b/examples/react16/src/Location.js @@ -4,8 +4,8 @@ import Button from "antd/es/button"; export default class Location extends React.Component { handleClick() { if (window.__WUJIE?.degrade || !window.Proxy || !window.CustomElementRegistry) { - window.$wujie.location.href = "https://wujicode.cn/xy/app/prod/official/home"; - } else window.location.href = "https://wujicode.cn/xy/app/prod/official/home"; + window.$wujie.location.href = "https://wujicode.cn/xy/app/prod/official/index"; + } else window.location.href = "https://wujicode.cn/xy/app/prod/official/index"; } componentDidMount() { console.log("react16 location mounted") diff --git a/examples/react17/src/Location.js b/examples/react17/src/Location.js index 46c783627..82f5455cb 100644 --- a/examples/react17/src/Location.js +++ b/examples/react17/src/Location.js @@ -4,8 +4,8 @@ import Button from "antd/es/button"; export default class Location extends React.Component { handleClick() { if (window.__WUJIE?.degrade || !window.Proxy || !window.CustomElementRegistry) { - window.$wujie.location.href = "https://wujicode.cn/xy/app/prod/official/home"; - } else window.location.href = "https://wujicode.cn/xy/app/prod/official/home"; + window.$wujie.location.href = "https://wujicode.cn/xy/app/prod/official/index"; + } else window.location.href = "https://wujicode.cn/xy/app/prod/official/index"; } componentDidMount() { diff --git a/examples/react17/src/State.js b/examples/react17/src/State.js index 9ee309531..957694489 100644 --- a/examples/react17/src/State.js +++ b/examples/react17/src/State.js @@ -5,7 +5,7 @@ import "antd/es/button/style/css"; export default class Location extends React.Component { state = { count: 10 }; handleClick() { - window.location.href = "https://wujicode.cn/xy/app/prod/official/home"; + window.location.href = "https://wujicode.cn/xy/app/prod/official/index"; } componentDidMount() { diff --git a/examples/vite/src/views/Location.vue b/examples/vite/src/views/Location.vue index 6b871588b..676f43fa5 100644 --- a/examples/vite/src/views/Location.vue +++ b/examples/vite/src/views/Location.vue @@ -40,7 +40,7 @@ export default { }, methods: { handleClick() { - window.$wujie.location.href = "https://wujicode.cn/xy/app/prod/official/home"; + window.$wujie.location.href = "https://wujicode.cn/xy/app/prod/official/index"; }, }, }; diff --git a/examples/vue2/src/views/Location.vue b/examples/vue2/src/views/Location.vue index 82f0e182a..42190f391 100644 --- a/examples/vue2/src/views/Location.vue +++ b/examples/vue2/src/views/Location.vue @@ -43,8 +43,8 @@ export default { methods: { handleClick() { if (window.__WUJIE?.degrade || !window.Proxy || !window.CustomElementRegistry) { - window.$wujie.location.href = "https://wujicode.cn/xy/app/prod/official/home"; - } else window.location.href = "https://wujicode.cn/xy/app/prod/official/home"; + window.$wujie.location.href = "https://wujicode.cn/xy/app/prod/official/index"; + } else window.location.href = "https://wujicode.cn/xy/app/prod/official/index"; }, }, }; diff --git a/examples/vue3/src/views/Location.vue b/examples/vue3/src/views/Location.vue index ec4692f53..a5d810dd7 100644 --- a/examples/vue3/src/views/Location.vue +++ b/examples/vue3/src/views/Location.vue @@ -41,8 +41,8 @@ export default { methods: { handleClick() { if (window.__WUJIE?.degrade || !window.Proxy || !window.CustomElementRegistry) { - window.$wujie.location.href = "https://wujicode.cn/xy/app/prod/official/home"; - } else window.location.href = "https://wujicode.cn/xy/app/prod/official/home"; + window.$wujie.location.href = "https://wujicode.cn/xy/app/prod/official/index"; + } else window.location.href = "https://wujicode.cn/xy/app/prod/official/index"; }, }, }; diff --git a/packages/wujie-core/__test__/integration/href.test.ts b/packages/wujie-core/__test__/integration/href.test.ts index 1663de998..a4582c16a 100644 --- a/packages/wujie-core/__test__/integration/href.test.ts +++ b/packages/wujie-core/__test__/integration/href.test.ts @@ -23,7 +23,7 @@ describe("main react location href test", () => { await triggerClickByJsSelector(page, (appInfo as LooseObject).routeNavSelector); await appInfoRouteMountedPromise; await triggerClickByJsSelector(page, (appInfo as LooseObject).routeJumpButtonSelector); - await page.waitForSelector("iframe[src='https://wujicode.cn/xy/app/prod/official/home']"); + await page.waitForSelector("iframe[src='https://wujicode.cn/xy/app/prod/official/index']"); await page.goBack(); await page.waitForSelector("wujie-app"); }) @@ -50,7 +50,7 @@ describe("main vue location href test", () => { await triggerClickByJsSelector(page, (appInfo as LooseObject).routeNavSelector); await appInfoRouteMountedPromise; await triggerClickByJsSelector(page, (appInfo as LooseObject).routeJumpButtonSelector); - await page.waitForSelector("iframe[src='https://wujicode.cn/xy/app/prod/official/home']"); + await page.waitForSelector("iframe[src='https://wujicode.cn/xy/app/prod/official/index']"); await page.goBack(); await page.waitForSelector("wujie-app"); }) diff --git a/packages/wujie-core/src/effect.ts b/packages/wujie-core/src/effect.ts index a6ece40dc..5798976f0 100644 --- a/packages/wujie-core/src/effect.ts +++ b/packages/wujie-core/src/effect.ts @@ -224,11 +224,12 @@ function rewriteAppendOrInsertChild(opts: { const { src, text, type, crossOrigin } = element as HTMLScriptElement; // 排除js if (!isMatchUrl(src, getEffectLoaders("jsExcludes", plugins))) { - const execScript = (scriptResult) => { + const execScript = (scriptResult: ScriptObject) => { // 假如子应用被连续渲染两次,两次渲染会导致处理流程的交叉污染 if (sandbox.iframe === null) return warn(WUJIE_TIPS_REPEAT_RENDER); insertScriptToIframe(scriptResult, sandbox.iframe.contentWindow); - manualInvokeElementEvent(element, "load"); + // 只有外联转内联才需要手动触发load + if (scriptResult.content) manualInvokeElementEvent(element, "load"); element = null; }; const scriptOptions = {