wujingjing
2025-04-02 6ca24301fd3edf76359240ae5272e75b7a4db77f
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
<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>