feat: 模型提示词、剩余额度、对话状态优化
This commit is contained in:
@@ -45,9 +45,9 @@ const debouncedSend = useDebounceFn(async () => {
|
||||
});
|
||||
senderValue.value = ''; // 清空输入框
|
||||
}
|
||||
catch (error) {
|
||||
catch (error: any) {
|
||||
console.error('发送消息失败:', error);
|
||||
ElMessage.error('发送消息失败,请重试');
|
||||
ElMessage.error(error);
|
||||
}
|
||||
finally {
|
||||
isSending.value = false;
|
||||
|
||||
@@ -46,10 +46,13 @@ const inputValue = ref('');
|
||||
const senderRef = ref<InstanceType<typeof Sender> | null>(null);
|
||||
const bubbleItems = ref<MessageItem[]>([]);
|
||||
const bubbleListRef = ref<BubbleListInstance | null>(null);
|
||||
const isSending = ref(false);
|
||||
|
||||
const { stream, loading: isLoading, cancel } = useHookFetch({
|
||||
request: send,
|
||||
onError: async (error) => {
|
||||
isLoading.value = false;
|
||||
|
||||
if (error.status === 403) {
|
||||
const data = await (error.response.json());
|
||||
// 弹窗提示
|
||||
@@ -168,12 +171,13 @@ function handleDataChunk(chunk: AnyObject) {
|
||||
function handleError(err: any) {
|
||||
console.error('Fetch error:', err);
|
||||
}
|
||||
const isSending = ref(false);
|
||||
|
||||
async function startSSE(chatContent: string) {
|
||||
if (isSending.value)
|
||||
return;
|
||||
|
||||
isSending.value = true;
|
||||
|
||||
try {
|
||||
// 清空输入框
|
||||
inputValue.value = '';
|
||||
@@ -205,14 +209,20 @@ async function startSSE(chatContent: string) {
|
||||
}
|
||||
else {
|
||||
handleError(err); // 其他错误
|
||||
// ElMessage.error('消息发送失败,请重试');
|
||||
}
|
||||
}
|
||||
finally {
|
||||
isSending.value = false;
|
||||
|
||||
// 停止打字器状态
|
||||
// 停止打字器状态和加载状态
|
||||
if (bubbleItems.value.length) {
|
||||
bubbleItems.value[bubbleItems.value.length - 1].typing = false;
|
||||
const latest = bubbleItems.value[bubbleItems.value.length - 1];
|
||||
latest.typing = false;
|
||||
latest.loading = false;
|
||||
if (latest.thinkingStatus === 'thinking') {
|
||||
latest.thinkingStatus = 'end';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -221,8 +231,14 @@ async function startSSE(chatContent: string) {
|
||||
async function cancelSSE() {
|
||||
try {
|
||||
cancel(); // 直接调用,无需参数
|
||||
isSending.value = false;
|
||||
if (bubbleItems.value.length) {
|
||||
bubbleItems.value[bubbleItems.value.length - 1].typing = false;
|
||||
const latest = bubbleItems.value[bubbleItems.value.length - 1];
|
||||
latest.typing = false;
|
||||
latest.loading = false;
|
||||
if (latest.thinkingStatus === 'thinking') {
|
||||
latest.thinkingStatus = 'end';
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (err) {
|
||||
@@ -254,7 +270,6 @@ function addMessage(message: string, isUser: boolean) {
|
||||
|
||||
// 展开收起 事件展示
|
||||
function handleChange(payload: { value: boolean; status: ThinkingStatus }) {
|
||||
console.log('value', payload.value, 'status', payload.status);
|
||||
}
|
||||
|
||||
function handleDeleteCard(_item: FilesCardProps, index: number) {
|
||||
@@ -279,7 +294,6 @@ watch(
|
||||
|
||||
// 复制
|
||||
function copy(item: any) {
|
||||
console.log('复制', item);
|
||||
navigator.clipboard.writeText(item.content || '')
|
||||
.then(() => ElMessage.success('已复制到剪贴板'))
|
||||
.catch(() => ElMessage.error('复制失败'));
|
||||
@@ -312,7 +326,7 @@ function copy(item: any) {
|
||||
<div class="footer-container">
|
||||
<div class="footer-time">
|
||||
<span v-if="item.creationTime "> {{ item.creationTime }}</span>
|
||||
<span style="margin-left: 10px;" v-if="((item.role === 'ai' || item.role === 'assistant') && item?.tokenUsage?.total) " class="footer-token">
|
||||
<span v-if="((item.role === 'ai' || item.role === 'assistant') && item?.tokenUsage?.total) " style="margin-left: 10px;" class="footer-token">
|
||||
{{ ((item.role === 'ai' || item.role === 'assistant') && item?.tokenUsage?.total) ? `token:${item?.tokenUsage?.total}` : '' }}</span>
|
||||
<el-button icon="DocumentCopy" size="small" circle @click="copy(item)" />
|
||||
</div>
|
||||
|
||||
@@ -63,7 +63,6 @@ async function onReLogin() {
|
||||
}
|
||||
function handleThirdPartyLogin(type: any) {
|
||||
const redirectUri = encodeURIComponent(`${window.location.origin}/chat`);
|
||||
console.log('cccc', type);
|
||||
const popup = window.open(
|
||||
`${SSO_SEVER_URL}/login?client_id=${type}&redirect_uri=${redirectUri}`,
|
||||
'SSOLogin',
|
||||
|
||||
Reference in New Issue
Block a user