no message

This commit is contained in:
Pang 2023-07-27 23:43:57 +08:00
parent 201c0e086b
commit be94c816ca
3 changed files with 26 additions and 10 deletions

View File

@ -653,7 +653,7 @@ export default {
}, },
mounted() { mounted() {
this.msgSubscribe = Store.subscribe('dialogMsgUpdate', this.updateMsg); this.msgSubscribe = Store.subscribe('dialogMsgChange', this.onMsgChange);
}, },
beforeDestroy() { beforeDestroy() {
@ -1343,11 +1343,15 @@ export default {
this.sendMsg(`<p><span data-quick-key="${item.key}">${item.label}</span></p>`) this.sendMsg(`<p><span data-quick-key="${item.key}">${item.label}</span></p>`)
}, },
updateMsg(data) { onMsgChange(data) {
const item = this.allMsgs.find(({type, id}) => type == "text" && id == data.id) const item = this.allMsgs.find(({type, id}) => type == "text" && id == data.id)
if (item) { if (item) {
const {tail} = this.scrollInfo() const {tail} = this.scrollInfo()
item.msg.text = data.text if (data.type === 'append') {
item.msg.text += data.text
} else if (data.type === 'replace') {
item.msg.text = data.text
}
if (tail <= 45) { if (tail <= 45) {
this.onToBottom() this.onToBottom()
} }

View File

@ -2,24 +2,28 @@
<div class="setting-component-item"> <div class="setting-component-item">
<Form ref="formData" :model="formData" :rules="ruleData" label-width="auto" @submit.native.prevent> <Form ref="formData" :model="formData" :rules="ruleData" label-width="auto" @submit.native.prevent>
<div class="block-setting-box"> <div class="block-setting-box">
<h3>{{ $L('ChatGTP') }}</h3> <h3>ChatGTP</h3>
<div class="form-box"> <div class="form-box">
<FormItem label="Key" prop="openai_key"> <FormItem label="API Key" prop="openai_key">
<Input :maxlength="255" v-model="formData.openai_key"/> <Input :maxlength="255" v-model="formData.openai_key" placeholder="OpenAI API Key"/>
<div class="form-tip">{{$L('访问OpenAI网站查看')}}<a href="https://platform.openai.com/account/api-keys" target="_blank">https://platform.openai.com/account/api-keys</a></div>
</FormItem> </FormItem>
<FormItem :label="$L('使用代理')" prop="openai_agency"> <FormItem :label="$L('使用代理')" prop="openai_agency">
<Input :maxlength="500" v-model="formData.openai_agency" :placeholder="$L('支持 http 或 socks 代理')"/> <Input :maxlength="500" v-model="formData.openai_agency" :placeholder="$L('支持 http 或 socks 代理')"/>
<div class="form-tip">{{$L('例如http://proxy.com 或 socks5://proxy.com')}}</div>
</FormItem> </FormItem>
</div> </div>
</div> </div>
<div class="block-setting-box"> <div class="block-setting-box">
<h3>{{ $L('Claude') }}</h3> <h3>Claude</h3>
<div class="form-box"> <div class="form-box">
<FormItem label="Token" prop="claude_token"> <FormItem label="Token" prop="claude_token">
<Input :maxlength="255" v-model="formData.claude_token"/> <Input :maxlength="255" v-model="formData.claude_token" placeholder="Claude Token"/>
<div class="form-tip">{{$L('登录')}} <a href="https://claude.ai" target="_blank">https://claude.ai</a> {{$L(' Cookie sessionKey 便')}}</div>
</FormItem> </FormItem>
<FormItem :label="$L('使用代理')" prop="claude_agency"> <FormItem :label="$L('使用代理')" prop="claude_agency">
<Input :maxlength="500" v-model="formData.claude_agency" :placeholder="$L('支持 http 或 socks 代理')"/> <Input :maxlength="500" v-model="formData.claude_agency" :placeholder="$L('支持 http 或 socks 代理')"/>
<div class="form-tip">{{$L('例如http://proxy.com 或 socks5://proxy.com')}}</div>
</FormItem> </FormItem>
</div> </div>
</div> </div>

View File

@ -2851,9 +2851,17 @@ export default {
*/ */
streamDialogMsg({state, dispatch}, streamUrl) { streamDialogMsg({state, dispatch}, streamUrl) {
const sse = new EventSource(streamUrl) const sse = new EventSource(streamUrl)
sse.addEventListener("update", e => { sse.addEventListener("append", e => {
Store.set('dialogMsgUpdate', { Store.set('dialogMsgChange', {
id: e.lastEventId, id: e.lastEventId,
type: 'append',
text: e.data
});
})
sse.addEventListener("replace", e => {
Store.set('dialogMsgChange', {
id: e.lastEventId,
type: 'replace',
text: e.data text: e.data
}); });
}) })