/* ui-splash.js —— 启动加载屏(v3.26.109 从 app.js 的 JSX 里搬出来) * * 设计:图标轻浮动 + 标题 + 细进度条(真实百分比,带流光)+ 阶段文字 + 右侧百分比。 * 数据来自 src/boot-progress.js(读取阶段上报真实进度),未知总量时退回不定长流光。 */ ;(function (global) { 'use strict' const React = global.React const el = React.createElement const NOOP = function () {} function Splash (props) { const p = props || {} const bp = global.IWBBootProgress const [s, setS] = React.useState(() => (bp ? bp.snapshot() : { pct: 0, label: '正在启动…', detail: '', indeterminate: true })) React.useEffect(() => { // React 启动屏一挂载就顶掉 index.html 里的静态启动屏(同款外观,切换无感) try { const n = document.getElementById('iwb-boot-static'); if (n && n.parentNode) n.parentNode.removeChild(n) } catch (e) { /* ignore */ } const un = bp ? bp.subscribe(setS) : NOOP return function () { try { un() } catch (e) { /* ignore */ } } }, []) // 进入淡出即视为加载完成:进度收口到 100%,避免最后停在 96% React.useEffect(() => { if (p.fade && bp) bp.finish() }, [p.fade]) const pct = Math.max(0, Math.min(100, Number(s.pct) || 0)) const indet = !!s.indeterminate const label = s.detail ? s.label + ' · ' + s.detail : s.label return el('div', { className: 'iwb-splash' + (p.fade ? ' iwb-splash-fade' : '') }, el('div', { className: 'iwb-splash-logo' }, p.icon || null), el('div', { className: 'iwb-splash-title' }, '生图工作台'), el('div', { className: 'iwb-splash-bar' + (indet ? ' is-indeterminate' : ''), role: 'progressbar', 'aria-valuemin': 0, 'aria-valuemax': 100, 'aria-valuenow': indet ? undefined : pct, }, el('div', { className: 'iwb-splash-bar-fill', style: indet ? null : { width: pct + '%' } }, null)), el('div', { className: 'iwb-splash-meta' }, el('span', { className: 'iwb-splash-sub' }, p.fade ? '加载完成' : label), el('span', { className: 'iwb-splash-pct' }, p.fade || indet ? '' : pct + '%'), ), ) } global.IWBUISplash = { Splash } })(typeof window !== 'undefined' ? window : globalThis)