From 23e792a491d14511d9075f6fd8e1745466d6525a Mon Sep 17 00:00:00 2001 From: yiludege <xzd123@qq.com> Date: Sat, 24 Sep 2022 17:44:27 +0800 Subject: [PATCH 1/2] =?UTF-8?q?chore:=20=E4=BF=AE=E6=94=B9=E6=97=A0?= =?UTF-8?q?=E6=9E=81=E8=B7=B3=E8=BD=AC=E5=9C=B0=E5=9D=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- examples/react16/src/Location.js | 4 ++-- examples/react17/src/Location.js | 4 ++-- examples/react17/src/State.js | 2 +- examples/vite/src/views/Location.vue | 2 +- examples/vue2/src/views/Location.vue | 4 ++-- examples/vue3/src/views/Location.vue | 4 ++-- packages/wujie-core/__test__/integration/href.test.ts | 4 ++-- 7 files changed, 12 insertions(+), 12 deletions(-) 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"); }) From 01f10994ed710a41133c8f5124fe94ace18a9be1 Mon Sep 17 00:00:00 2001 From: yiludege <xzd123@qq.com> Date: Tue, 27 Sep 2022 11:52:04 +0800 Subject: [PATCH 2/2] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E5=BC=82=E6=AD=A5?= =?UTF-8?q?JavaScript=E6=96=87=E4=BB=B6=E5=8A=A0=E8=BD=BD=E5=BC=82?= =?UTF-8?q?=E5=B8=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/wujie-core/src/effect.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) 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 = {