refactor(splash-screen): 移除废弃的启动屏配置系统
简化启动屏组件代码,删除不再使用的splashConfig全局配置、相关工具方法和冗余的布局逻辑,统一进度条展示样式。
This commit is contained in:
@@ -158,21 +158,6 @@ export const privacyConfig = {
|
||||
// },
|
||||
};
|
||||
|
||||
// ============================================================
|
||||
// 启动屏配置 (与 privacyConfig 同构, 由 splash-state.js 消费)
|
||||
// showProgress 是否显示进度条本身 + 数字 (label 单独可独立关闭)
|
||||
// showLabel 是否显示阶段文案 (Loading language... 等)
|
||||
// showPercent 是否显示百分比数字
|
||||
// showProgress=true + showLabel=false + showPercent=true → 只显示进度条+百分比
|
||||
// showProgress=false → 整个进度条区域隐藏
|
||||
// 业务侧可改 splashConfig.* 或在 splash 组件 <splash-screen :show-label="false" /> 覆盖
|
||||
// ============================================================
|
||||
export const splashConfig = {
|
||||
showProgress: true,
|
||||
showLabel: false, // 默认 false: 用户想要"只显示百分比"
|
||||
showPercent: true,
|
||||
}
|
||||
|
||||
// 配置外置管理类
|
||||
class ConfigExternal {
|
||||
constructor() {
|
||||
|
||||
@@ -10,12 +10,8 @@
|
||||
// 4. 兜底超时: 默认 8s 未关闭则强制 hide,防止卡死
|
||||
// 5. 平台隔离: APP-PLUS 有原生 splash,这里直接返回 false
|
||||
// 6. 跨平台兼容: 同步状态可被 Vue 组件直接 watch
|
||||
// 7. 可配置: splashConfig 支持 showProgress/showLabel/showPercent 单独控制
|
||||
// 业务侧可在 config-external.js 改 splashConfig, 或 <splash-screen :show-label="false" /> 覆盖
|
||||
// ============================================================
|
||||
|
||||
import { splashConfig as _defaultSplashConfig } from './config-external.js'
|
||||
|
||||
// APP-PLUS 直接返回 false (有原生启动屏)
|
||||
function needSplash() {
|
||||
// #ifdef APP-PLUS
|
||||
@@ -71,8 +67,6 @@ class SplashState {
|
||||
// 避免多通道并发时, splash 组件 re-render 风暴
|
||||
this._pendingProgress = null; // 待 emit 的最新进度
|
||||
this._flushTimer = null; // 节流定时器
|
||||
// 启动屏显示配置: 初始读 config-external.js 的 splashConfig, 可运行时改
|
||||
this._splashConfig = Object.assign({}, _defaultSplashConfig)
|
||||
}
|
||||
|
||||
show(opts = {}) {
|
||||
@@ -349,33 +343,6 @@ getStageDef(stageId) {
|
||||
return STAGES[stageId]
|
||||
}
|
||||
|
||||
/**
|
||||
* 读取启动屏显示配置
|
||||
* splash 组件读这个决定 label/percent 是否显示
|
||||
* 缺字段时回退到默认 (splashConfig=true)
|
||||
* @returns {{showProgress: boolean, showLabel: boolean, showPercent: boolean}}
|
||||
*/
|
||||
getSplashConfig() {
|
||||
const c = this._splashConfig || {}
|
||||
return {
|
||||
showProgress: c.showProgress !== false,
|
||||
showLabel: !!c.showLabel,
|
||||
showPercent: c.showPercent !== false,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 运行时合并更新 splash 配置
|
||||
* 全局 splashConfig 在 boot 前注入; 业务运行时改某些字段可用本方法
|
||||
* 不会触发组件 re-render (splash 组件用 props 优先)
|
||||
* @param {Object} partial
|
||||
*/
|
||||
setSplashConfig(partial) {
|
||||
if (!partial || typeof partial !== 'object') return
|
||||
this._splashConfig = Object.assign({}, this._splashConfig, partial)
|
||||
}
|
||||
|
||||
/**
|
||||
* 立即刷新挂起的进度更新
|
||||
* - reportProgress 默认 16ms throttle (1 帧), 避免连续触发 splash 组件多次 re-render
|
||||
|
||||
Reference in New Issue
Block a user