<template>
|
<div class="flex items-center mb-8">
|
<img src="/static/images/logo/logoWithNoName.png" alt="logo" class="layout-logo-medium-img" />
|
<p class="set-waterTitle"><strong>WI水务智能平台</strong>智慧水务数据挖掘者</p>
|
</div>
|
<!-- <div class="flex items-center pc-roleList"></div> -->
|
<PlayBar style="width: 760px" v-model="inputValue" @send-click="sendClick" :is-home="true" />
|
</template>
|
|
<script setup lang="ts">
|
import { ElMessage } from 'element-plus';
|
import { ref } from 'vue';
|
import { GetLLMList, setHistoryGroupTitle } from '/@/api/ai/chat';
|
import PlayBar from '/@/components/chat/components/playBar/PlayBar.vue';
|
import router from '/@/router';
|
import { activeChatRoom, activeLLMId } from '/@/stores/chatRoom';
|
import { handleNormalAuth } from '/@/utils/request';
|
|
const emits = defineEmits(['sendClick']);
|
const inputValue = ref('');
|
|
const sendClick = async (cb) => {
|
if (!inputValue.value.trim()) return;
|
|
if (!handleNormalAuth()) {
|
return;
|
}
|
|
const res = await setHistoryGroupTitle({
|
history_group_id: activeChatRoom.value.id,
|
title: inputValue.value,
|
});
|
if (!res.json_ok) {
|
return ElMessage.error('修改聊天室名称失败');
|
}
|
|
activeChatRoom.value.title = inputValue.value;
|
activeChatRoom.value.isInitial = false;
|
router.push({
|
name: 'AskAnswer',
|
query: {
|
id: activeChatRoom.value.id,
|
},
|
});
|
};
|
|
const llmList = ref([]);
|
const iconList = ['/static/images/wave/Glm.jpg', '/static/images/wave/Glm.jpg', '/static/images/wave/Glm.jpg'];
|
const getLLMList = async () => {
|
const res = await GetLLMList();
|
|
const resData = (res?.llm_list || []) as any[];
|
llmList.value = resData.map((item, index) => ({
|
get logicId() {
|
return this.logicModel.id;
|
},
|
get logicTitle() {
|
return this.logicModel.title;
|
},
|
icon: iconList[index],
|
logicModel: {
|
...item,
|
},
|
}));
|
const first = llmList.value?.[0];
|
first && setLLm(first.logicId);
|
};
|
|
const setLLm = async (llmId: string) => {
|
// const res = await SetLLM({
|
// llm: llmId,
|
// });
|
activeLLMId.value = llmId;
|
|
return true;
|
};
|
const handleClick = (item) => {
|
setLLm(item.logicId);
|
};
|
|
const updateChatInput = (val) => {
|
inputValue.value = val;
|
};
|
|
defineExpose({
|
updateChatInput,
|
});
|
</script>
|
<style scoped lang="scss">
|
.set-waterTitle {
|
line-height: 24px;
|
font-weight: 500;
|
font-size: 18px;
|
color: #3b4066;
|
vertical-align: middle;
|
}
|
strong {
|
font-size: 26px;
|
font-weight: 700;
|
margin-right: 12px;
|
}
|
.layout-logo-medium-img {
|
width: 28px;
|
margin-right: 7px;
|
}
|
.pc-roleList {
|
margin: 40px 0 26px;
|
position: relative;
|
}
|
.modelItem {
|
height: 34px;
|
padding: 0 16px;
|
border-radius: 17px;
|
border: 1px solid #00000020;
|
background-color: #f2f4f8;
|
transition: background-color 0.1s, border-color 0.1s, color 0.1s;
|
color: #333;
|
.set-icon {
|
width: 20px;
|
height: 20px;
|
position: relative;
|
}
|
.set-icon-more {
|
width: 16px;
|
height: 16px;
|
position: relative;
|
}
|
span {
|
margin-left: 8px;
|
font-weight: 500;
|
font-size: 15px;
|
}
|
}
|
.modelItemActive {
|
background-color: #1c86ff;
|
border-color: #1c86ff;
|
color: #fff;
|
}
|
</style>
|
<style lang="scss">
|
.my-pop {
|
max-width: 300px;
|
}
|
</style>
|