@@ -6,6 +6,7 @@ import type {
66 PluginLocation ,
77 PluginRuntimeContext ,
88 RuntimeMisc ,
9+ NavTip ,
910} from "@next-core/brick-types" ;
1011import {
1112 restoreDynamicTemplates ,
@@ -234,6 +235,7 @@ export class Router {
234235 const history = getHistory ( ) ;
235236 history . unblock ( ) ;
236237
238+ const renderStartTime = Date . now ( ) ;
237239 // Create the page tracker before page load.
238240 // And the API Analyzer maybe disabled.
239241 const pageTracker = apiAnalyzer . getInstance ( ) ?. pageTracker ( ) ;
@@ -559,6 +561,36 @@ export class Router {
559561 pageTitle : document . title ,
560562 } ) ;
561563
564+ const renderTime = Date . now ( ) - renderStartTime ;
565+ const { loadTime = 2500 , loadInfoPage } =
566+ this . kernel . bootstrapData . settings . misc ?? { } ;
567+ if ( currentApp . isBuildPush && renderTime > loadTime ) {
568+ const getSecond = ( time : number ) : number =>
569+ Math . floor ( time * 100 ) / 100 ;
570+ window . dispatchEvent (
571+ new CustomEvent < NavTip [ ] > ( "app.bar.tips" , {
572+ detail : [
573+ {
574+ text : `您的页面存在性能问题, 当前页面渲染时间为: ${ getSecond (
575+ renderTime / 1000
576+ ) } 秒, 规定阈值为: ${ getSecond (
577+ ( loadTime as number ) / 1000
578+ ) } 秒; 您已超过, 请您针对该页面进行性能优化!`,
579+ closeable : false ,
580+ ...( loadInfoPage
581+ ? {
582+ info : {
583+ label : "查看详情" ,
584+ url : loadInfoPage as string ,
585+ } ,
586+ }
587+ : { } ) ,
588+ } ,
589+ ] ,
590+ } )
591+ ) ;
592+ }
593+
562594 // analytics page_view event
563595 userAnalytics . event ( "page_view" , {
564596 micro_app_id : this . kernel . currentApp . id ,
0 commit comments