chore:支持换一换按钮应用
This commit is contained in:
@@ -1779,6 +1779,8 @@ export default {
|
|||||||
|
|
||||||
// 3. 插入欢迎语(再次检查是否仍是全新会话)
|
// 3. 插入欢迎语(再次检查是否仍是全新会话)
|
||||||
if (!this.currentConversationId && this.messages.length === 0) {
|
if (!this.currentConversationId && this.messages.length === 0) {
|
||||||
|
// PR-WELCOME-QUICK-BATCH: 所有快捷问题先存起来, 前端每 4 个一批轮播
|
||||||
|
const allQuickQuestions = this.normalizeQuickQuestions(welcomeInfo && welcomeInfo.quick_questions)
|
||||||
const welcomeMsg = {
|
const welcomeMsg = {
|
||||||
id: ++this.messageId,
|
id: ++this.messageId,
|
||||||
role: 'ai',
|
role: 'ai',
|
||||||
@@ -1789,7 +1791,10 @@ export default {
|
|||||||
// PR-WELCOME-QUICK-CHIPS (2026-09-19): 欢迎语配套快捷问题 (chips)
|
// PR-WELCOME-QUICK-CHIPS (2026-09-19): 欢迎语配套快捷问题 (chips)
|
||||||
// 后端可存 string[] 或 {id,text}[] ,前端统一归一化为 string[]
|
// 后端可存 string[] 或 {id,text}[] ,前端统一归一化为 string[]
|
||||||
// message.quickQuestions 数组非空 → 模板渲染 chips;点击调 onQuickQuestionClick
|
// message.quickQuestions 数组非空 → 模板渲染 chips;点击调 onQuickQuestionClick
|
||||||
quickQuestions: this.normalizeQuickQuestions(welcomeInfo && welcomeInfo.quick_questions),
|
// PR-WELCOME-QUICK-BATCH: 每 4 个一批展示, 点击换一换循环切换
|
||||||
|
quickQuestions: (allQuickQuestions || []).slice(0, 4),
|
||||||
|
allQuickQuestions: allQuickQuestions || [],
|
||||||
|
_qqBatchIndex: 0,
|
||||||
// PR-WELCOME-HIDE-AFTER-SEND: 标记这是欢迎语消息, 发送第一条用户消息后永久隐藏
|
// PR-WELCOME-HIDE-AFTER-SEND: 标记这是欢迎语消息, 发送第一条用户消息后永久隐藏
|
||||||
isWelcome: true
|
isWelcome: true
|
||||||
}
|
}
|
||||||
@@ -3764,13 +3769,23 @@ _handleStreamError(msg) {
|
|||||||
} catch (e) { /* noop */ }
|
} catch (e) { /* noop */ }
|
||||||
},
|
},
|
||||||
|
|
||||||
// 欢迎语"换一换": 移除当前欢迎语并重新加载(刷新快捷问题)
|
// 欢迎语"换一换": 快捷问题每 4 个一批, 点击后切换到下一批, 末尾循环回第一批
|
||||||
onAiActionRefreshWelcome(message) {
|
onAiActionRefreshWelcome(message) {
|
||||||
try {
|
try {
|
||||||
const idx = this.messages.findIndex(m => m && m.id === message.id)
|
const all = message.allQuickQuestions || []
|
||||||
if (idx !== -1) this.messages.splice(idx, 1)
|
if (!all.length) {
|
||||||
this._welcomeLoading = false
|
uni.showToast({ title: '暂无更多问题', icon: 'none' })
|
||||||
this._loadWelcomeMessage()
|
return
|
||||||
|
}
|
||||||
|
const batchSize = 4
|
||||||
|
const total = all.length
|
||||||
|
const batchCount = Math.ceil(total / batchSize) || 1
|
||||||
|
const current = message._qqBatchIndex || 0
|
||||||
|
const next = (current + 1) % batchCount
|
||||||
|
const start = next * batchSize
|
||||||
|
const end = Math.min(start + batchSize, total)
|
||||||
|
this.$set(message, '_qqBatchIndex', next)
|
||||||
|
this.$set(message, 'quickQuestions', all.slice(start, end))
|
||||||
} catch (e) { /* noop */ }
|
} catch (e) { /* noop */ }
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user