feat: ai问答

This commit is contained in:
Blizzard
2026-04-28 10:36:51 +08:00
parent 0715a16d91
commit 058a575e10
13 changed files with 329 additions and 52 deletions
+14 -2
View File
@@ -10,6 +10,7 @@ Page({
_counter: 0,
quotaRemaining: -1,
quotaLimit: 0,
_pendingPrefill: '',
},
onLoad(options) {
@@ -23,8 +24,9 @@ Page({
this.setData({ messages: msgs, _counter: 2 }, () => this.scrollToBottom());
});
} else if (options && options.prefillQuestion) {
const q = decodeURIComponent(options.prefillQuestion);
this.setData({ inputValue: q }, () => this.onSend());
// Only save the question; actual send waits for quota check in onShow
this._pendingPrefill = decodeURIComponent(options.prefillQuestion);
this.setData({ inputValue: this._pendingPrefill });
}
},
@@ -38,6 +40,16 @@ Page({
quotaRemaining: res.remaining,
quotaLimit: res.limit,
});
// Auto-send prefill question only after quota is confirmed
if (this._pendingPrefill) {
const q = this._pendingPrefill;
this._pendingPrefill = '';
if (res.remaining > 0) {
this.onSend();
} else {
wx.showToast({ title: '今日问答次数已用完,明天再来吧', icon: 'none', duration: 2500 });
}
}
}).catch(() => {});
},