From d2c8ceb94a1d9a303909e41bf79acd698d911145 Mon Sep 17 00:00:00 2001 From: ClarkXia Date: Fri, 17 Feb 2023 11:20:40 +0800 Subject: [PATCH 1/4] chore: version --- packages/icestark/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/icestark/package.json b/packages/icestark/package.json index e87d4e28..2b9dd822 100644 --- a/packages/icestark/package.json +++ b/packages/icestark/package.json @@ -1,6 +1,6 @@ { "name": "@ice/stark", - "version": "2.7.5", + "version": "2.7.6", "description": "Icestark is a JavaScript library for multiple projects, Ice workbench solution.", "scripts": { "build": "rm -rf lib && tsc", From d6faf5ffe416bdaa7b52b9da548a53fdbb4a8a82 Mon Sep 17 00:00:00 2001 From: chinluin <44611361+chinluin@users.noreply.github.com> Date: Fri, 17 Feb 2023 11:26:50 +0800 Subject: [PATCH 2/4] fix: avoid prefetch block when render child app (#658) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix: 修复预加载场景下,子应用切换时js脚本执行导致的页面交互阻塞问题 * fix: 修复预加载场景下,子应用切换时js脚本执行导致的页面交互阻塞问题 --------- Co-authored-by: qinling --- packages/icestark/src/AppRoute.tsx | 3 ++- packages/icestark/src/AppRouter.tsx | 20 +++++++++++++++----- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/packages/icestark/src/AppRoute.tsx b/packages/icestark/src/AppRoute.tsx index 84558289..e10a639f 100644 --- a/packages/icestark/src/AppRoute.tsx +++ b/packages/icestark/src/AppRoute.tsx @@ -146,7 +146,8 @@ export default class AppRoute extends React.Component this.renderChild()); } }; diff --git a/packages/icestark/src/AppRouter.tsx b/packages/icestark/src/AppRouter.tsx index 6c7426b1..999b50d0 100644 --- a/packages/icestark/src/AppRouter.tsx +++ b/packages/icestark/src/AppRouter.tsx @@ -47,7 +47,9 @@ export default class AppRouter extends React.Component {}, // eslint-disable-next-line react/jsx-filename-extension - ErrorComponent: ({ err }: { err: string | Error}) =>
{ typeof err === 'string' ? err : err?.message }
, + ErrorComponent: ({ err }: { err: string | Error }) => ( +
{typeof err === 'string' ? err : err?.message}
+ ), LoadingComponent:
Loading...
, NotFoundComponent:
NotFound
, onAppEnter: () => {}, @@ -90,10 +92,10 @@ export default class AppRouter extends React.Component { + this.props.onAppEnter(app); + if (!!this.props.prefetch) { + // 预加载场景需要将loading提升,否则会由于脚本阻塞进程,导致loading失效 + this.setState({ appLoading: app.name }); + } + }; + loadingApp = (app: AppConfig) => { if (this.unmounted) return; this.props.onLoadingApp(app); @@ -256,7 +266,7 @@ export default class AppRouter extends React.Component From d401a58aa390fc71a2766d38e8abd1a90d99d4d2 Mon Sep 17 00:00:00 2001 From: ClarkXia Date: Fri, 17 Feb 2023 12:00:26 +0800 Subject: [PATCH 3/4] fix: lint --- packages/icestark/src/AppRouter.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/icestark/src/AppRouter.tsx b/packages/icestark/src/AppRouter.tsx index 999b50d0..2ad749a4 100644 --- a/packages/icestark/src/AppRouter.tsx +++ b/packages/icestark/src/AppRouter.tsx @@ -177,7 +177,7 @@ export default class AppRouter extends React.Component { this.props.onAppEnter(app); - if (!!this.props.prefetch) { + if (this.props.prefetch) { // 预加载场景需要将loading提升,否则会由于脚本阻塞进程,导致loading失效 this.setState({ appLoading: app.name }); } From af18c9bbfd72d975cbe23cdef2825c43f96c95cb Mon Sep 17 00:00:00 2001 From: Alex Date: Tue, 14 Mar 2023 17:28:32 +0800 Subject: [PATCH 4/4] feat: add renderError method to icestark/app (#661) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat: add renderError method to icestark/app * fix: unregister listener * fix: error event * doc: 修改注释问题 * feat: 合并renderError和renderNotFound (因为都算是错误页,所以文件名命名为了renderError) --- packages/icestark-app/src/index.ts | 2 +- .../src/{renderNotFound.ts => renderError.ts} | 75 +++++++++++-------- packages/icestark/src/AppRouter.tsx | 9 +++ 3 files changed, 54 insertions(+), 32 deletions(-) rename packages/icestark-app/src/{renderNotFound.ts => renderError.ts} (63%) diff --git a/packages/icestark-app/src/index.ts b/packages/icestark-app/src/index.ts index 0cf77553..72d5b973 100644 --- a/packages/icestark-app/src/index.ts +++ b/packages/icestark-app/src/index.ts @@ -1,5 +1,5 @@ export { default as getMountNode } from './getMountNode'; -export { default as renderNotFound } from './renderNotFound'; +export { default as renderError, renderNotFound } from './renderError'; export { default as getBasename } from './getBasename'; export { default as setBasename } from './setBasename'; export { default as registerAppEnter } from './registerAppEnter'; diff --git a/packages/icestark-app/src/renderNotFound.ts b/packages/icestark-app/src/renderError.ts similarity index 63% rename from packages/icestark-app/src/renderNotFound.ts rename to packages/icestark-app/src/renderError.ts index 20a13194..dedd6412 100644 --- a/packages/icestark-app/src/renderNotFound.ts +++ b/packages/icestark-app/src/renderError.ts @@ -1,31 +1,44 @@ -import { getCache } from './cache'; - -/** - * CustomEvent Polyfill for IE - */ -(function () { - if (typeof (window as any).CustomEvent === 'function') return false; - - function CustomEvent(event, params) { - params = params || { bubbles: false, cancelable: false, detail: null }; - const evt = document.createEvent('CustomEvent'); - evt.initCustomEvent(event, params.bubbles, params.cancelable, params.detail); - return evt; - } - - (window as any).CustomEvent = CustomEvent; -})(); - -/** - * Trigger customEvent icestark:not-found - */ -export default () => { - if (getCache('root')) { - window.dispatchEvent(new CustomEvent('icestark:not-found')); - - // Compatible processing return renderNotFound(); - return null; - } - - return 'Current sub-application is running independently'; -}; +import { getCache } from './cache'; + +/** + * CustomEvent Polyfill for IE + */ +(function () { + if (typeof (window as any).CustomEvent === 'function') return false; + + function CustomEvent(event, params) { + params = params || { bubbles: false, cancelable: false, detail: null }; + const evt = document.createEvent('CustomEvent'); + evt.initCustomEvent(event, params.bubbles, params.cancelable, params.detail); + return evt; + } + + (window as any).CustomEvent = CustomEvent; +})(); + +/** + * Trigger customEvent icestark:error + */ +export default (error) => { + if (getCache('root')) { + window.dispatchEvent(new CustomEvent('icestark:error', { bubbles: false, cancelable: false, detail: error })); + // Compatible processing return renderError(); + return null; + } + + return 'Current sub-application is running independently'; +}; + +/** + * Trigger customEvent icestark:not-found + */ +export const renderNotFound = () => { + if (getCache('root')) { + window.dispatchEvent(new CustomEvent('icestark:not-found')); + + // Compatible processing return renderNotFound(); + return null; + } + + return 'Current sub-application is running independently'; +}; diff --git a/packages/icestark/src/AppRouter.tsx b/packages/icestark/src/AppRouter.tsx index 2ad749a4..e43e0007 100644 --- a/packages/icestark/src/AppRouter.tsx +++ b/packages/icestark/src/AppRouter.tsx @@ -86,6 +86,7 @@ export default class AppRouter extends React.Component { + this.triggerError(e.detail); + }; + triggerNotFound = (): void => { // if AppRouter is unmounted, cancel all operations if (this.unmounted) return;