feat(chat-ui): 增加聊天 UI 配置的本地持久化和预加载功能,优化首帧渲染体验
This commit is contained in:
@@ -615,6 +615,13 @@ export default {
|
||||
type: Array,
|
||||
default: () => []
|
||||
},
|
||||
// PR-CHAT-UI-CONFIG-PRELOAD (2026-09-24): 父页面渲染前预取的聊天 UI 配置
|
||||
// 传入后 created() 立即用作首帧值, 消除"默认值渲染 → 异步配置到达跳变"的闪烁;
|
||||
// 之后 _loadChatUiConfig() 仍会拉最新值覆盖 (与父页面共享 60s TTL 缓存)
|
||||
preloadedUiConfig: {
|
||||
type: Object,
|
||||
default: null
|
||||
},
|
||||
// 初始用户头像(外部传入,可选)
|
||||
initUserAvatar: {
|
||||
type: String,
|
||||
@@ -880,6 +887,21 @@ export default {
|
||||
this.currentConversationId = aiService.getConversationId();
|
||||
console.log('[AI Chat] created, currentConversationId:', this.currentConversationId, 'messages.length:', this.messages.length);
|
||||
|
||||
// PR-CHAT-UI-CONFIG-PRELOAD (2026-09-24): 父页面预取配置优先作为首帧值
|
||||
// 父页面已保证渲染本组件时配置就绪 (缓存或预取), 此处同步落位;
|
||||
// _loadChatUiConfig() 随后仍拉最新值 (TTL 缓存命中则同值, 无视觉跳变)
|
||||
if (this.preloadedUiConfig && typeof this.preloadedUiConfig === 'object') {
|
||||
this.chatUiConfig = Object.assign({}, this.chatUiConfig, this.preloadedUiConfig)
|
||||
if (Array.isArray(this.preloadedUiConfig.ui_available_models) && this.preloadedUiConfig.ui_available_models.length) {
|
||||
this.availableModels = this.preloadedUiConfig.ui_available_models.slice()
|
||||
if (!this.availableModels.includes(this.selectedModel)) {
|
||||
this.selectedModel = this.availableModels[0] || 'Auto'
|
||||
}
|
||||
}
|
||||
this.chatUiConfigLoaded = true
|
||||
console.log('[AI Chat] chatUiConfig 使用父页面预取值 (首帧即真实配置)')
|
||||
}
|
||||
|
||||
// 异步获取服务配置(含欢迎语)
|
||||
this._loadWelcomeMessage()
|
||||
// PR-CHAT-UI-CONFIG (2026-09-20): 异步加载 UI 开关 (与欢迎语并行, 不阻塞 created)
|
||||
|
||||
Reference in New Issue
Block a user