task-10(壳层/路由): 实现页面级异步组件加载边界
lazy-config 暴露 loading 延迟/超时/文案与懒加载判定;lazy-page 用 defineAsyncComponent 提供 loading/error 组件,router 对所有注册路由统一包裹; main.css 增加 .page-loading/.page-error 兜底样式。
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
/** 异步页面加载边界可调参数(任务 10):loading 延迟/超时/文案。 */
|
||||
export const PAGE_LOADING_DELAY = 200
|
||||
export const PAGE_LOADING_TIMEOUT = 15000
|
||||
export const PAGE_LOADING_TEXT = '页面加载中'
|
||||
export const PAGE_LOAD_ERROR_TEXT = '页面加载失败,请刷新重试'
|
||||
|
||||
/** 是否为异步加载器(函数式)。 */
|
||||
export function isLazyLoader(value: unknown): value is () => Promise<unknown> {
|
||||
return typeof value === 'function'
|
||||
}
|
||||
|
||||
/** 动态 import 产物是否为含 default 的页面模块。 */
|
||||
export function isPageModule(module: unknown): boolean {
|
||||
return typeof module === 'object' && module !== null && 'default' in module
|
||||
}
|
||||
Reference in New Issue
Block a user