This commit is contained in:
王创世 2025-02-28 20:34:13 +08:00
parent 86e835f67c
commit 81422e7710
3 changed files with 83 additions and 65 deletions

Binary file not shown.

View File

@ -1,44 +1,44 @@
{ {
"hash": "2c5e6f78", "hash": "5b5aeddc",
"configHash": "b7fa4f41", "configHash": "b7fa4f41",
"lockfileHash": "64049b29", "lockfileHash": "691ad5f6",
"browserHash": "a3a373ee", "browserHash": "d31dc7ba",
"optimized": { "optimized": {
"naive-ui": {
"src": "../../naive-ui/es/index.mjs",
"file": "naive-ui.js",
"fileHash": "45d8e824",
"needsInterop": false
},
"vue": {
"src": "../../vue/dist/vue.runtime.esm-bundler.js",
"file": "vue.js",
"fileHash": "32fae398",
"needsInterop": false
},
"vue-router": {
"src": "../../vue-router/dist/vue-router.mjs",
"file": "vue-router.js",
"fileHash": "b35d4254",
"needsInterop": false
},
"vue-wechat-title": {
"src": "../../vue-wechat-title/vue-wechat-title.js",
"file": "vue-wechat-title.js",
"fileHash": "1d78b2b2",
"needsInterop": true
},
"axios": { "axios": {
"src": "../../axios/index.js", "src": "../../axios/index.js",
"file": "axios.js", "file": "axios.js",
"fileHash": "5add746f", "fileHash": "596cc5f7",
"needsInterop": false "needsInterop": false
}, },
"marked": { "marked": {
"src": "../../marked/lib/marked.esm.js", "src": "../../marked/lib/marked.esm.js",
"file": "marked.js", "file": "marked.js",
"fileHash": "8ca88ca7", "fileHash": "9d266fed",
"needsInterop": false "needsInterop": false
},
"naive-ui": {
"src": "../../naive-ui/es/index.mjs",
"file": "naive-ui.js",
"fileHash": "48531eea",
"needsInterop": false
},
"vue": {
"src": "../../vue/dist/vue.runtime.esm-bundler.js",
"file": "vue.js",
"fileHash": "5fca8b08",
"needsInterop": false
},
"vue-router": {
"src": "../../vue-router/dist/vue-router.mjs",
"file": "vue-router.js",
"fileHash": "50af2467",
"needsInterop": false
},
"vue-wechat-title": {
"src": "../../vue-wechat-title/vue-wechat-title.js",
"file": "vue-wechat-title.js",
"fileHash": "b0f5b871",
"needsInterop": true
} }
}, },
"chunks": { "chunks": {

View File

@ -6,7 +6,7 @@
<div class="a5cd95be"> <div class="a5cd95be">
<div class="b83ee326"> <div class="b83ee326">
<div class="f6004764" ref="chatContainerRef" @scroll="handleScroll"> <div class="f6004764" ref="chatContainerRef" @scroll="handleScroll">
<div class="f72b0bab" :style="{ height: !showList ? '60%' : '100%' }" > <div class="f72b0bab" :style="{ height: !showList ? '60%' : '100%' }">
<div class="dad65929" style="flex-grow: 0;margin: 0px auto;" ref="chatContainer" v-if="showList" <div class="dad65929" style="flex-grow: 0;margin: 0px auto;" ref="chatContainer" v-if="showList"
v-for="item in paramMsg"> v-for="item in paramMsg">
<div v-if="item.role == 'user'" class="fa81"> <div v-if="item.role == 'user'" class="fa81">
@ -14,9 +14,9 @@
style="position: absolute; right: calc(100% + 18px); top: 12px; gap: 12px;"> style="position: absolute; right: calc(100% + 18px); top: 12px; gap: 12px;">
<div class="ds-icon-button" tabindex="0" <div class="ds-icon-button" tabindex="0"
style="--ds-icon-button-text-color: #909090; --ds-icon-button-size: 20px;"> style="--ds-icon-button-text-color: #909090; --ds-icon-button-size: 20px;">
<div @click="copy(item.content)" class="ds-icon" style="font-size: 20px; width: 20px; height: 20px;"><svg <div @click="copy(item.content)" class="ds-icon"
viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg" style="font-size: 20px; width: 20px; height: 20px;"><svg viewBox="0 0 20 20" fill="none"
xmlns:xlink="http://www.w3.org/1999/xlink"> xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<defs> <defs>
<clippath id="clip1257_20794"> <clippath id="clip1257_20794">
<rect id="复制" width="20.000000" height="20.000000" fill="white" fill-opacity="0"> <rect id="复制" width="20.000000" height="20.000000" fill="white" fill-opacity="0">
@ -89,9 +89,9 @@
<div class="ds-flex abe97156" style="align-items: center; gap: 12px;"> <div class="ds-flex abe97156" style="align-items: center; gap: 12px;">
<div class="ds-icon-button" tabindex="0" <div class="ds-icon-button" tabindex="0"
style="--ds-icon-button-text-color: #909090; --ds-icon-button-size: 20px;"> style="--ds-icon-button-text-color: #909090; --ds-icon-button-size: 20px;">
<div @click="copy(item.content)" class="ds-icon" style="font-size: 20px; width: 20px; height: 20px;"><svg <div @click="copy(item.content)" class="ds-icon"
viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg" style="font-size: 20px; width: 20px; height: 20px;"><svg viewBox="0 0 20 20" fill="none"
xmlns:xlink="http://www.w3.org/1999/xlink"> xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<defs> <defs>
<clippath id="clip1257_20794"> <clippath id="clip1257_20794">
<rect id="复制" width="20.000000" height="20.000000" fill="white" fill-opacity="0"> <rect id="复制" width="20.000000" height="20.000000" fill="white" fill-opacity="0">
@ -150,9 +150,14 @@
<div class="b13855df"> <div class="b13855df">
</div> </div>
</div> </div>
<div @click="MesdsetQuestion" class="ec4f5d61"> <div class="ec4f5d61">
<div class="bf38813a"> <div class="bf38813a">
<div role="button" aria-disabled="false" class="f6d670"> <div @click="MesdsetQuestionStorp" v-if="!chatHdEnd" role="button" aria-disabled="false" class="f6d670">
<div class="f286936b">
<div class="be24146b"></div>
</div>
</div>
<div @click="MesdsetQuestion" v-if="chatHdEnd" role="button" aria-disabled="false" class="f6d670">
<div class="f286936b"> <div class="f286936b">
<div class="ds-icon" style="font-size: 16px; width: 16px; height: 16px;"><svg <div class="ds-icon" style="font-size: 16px; width: 16px; height: 16px;"><svg
width="14" height="16" viewBox="0 0 14 16" fill="none" width="14" height="16" viewBox="0 0 14 16" fill="none"
@ -187,7 +192,7 @@
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { reactive, ref, onUnmounted, nextTick, watch } from 'vue' import { reactive, ref, onUnmounted, nextTick, onMounted } from 'vue'
import { setQuestion, getQuestion } from "@/api/index"; import { setQuestion, getQuestion } from "@/api/index";
import { marked } from 'marked'; import { marked } from 'marked';
import { useMessage } from 'naive-ui' import { useMessage } from 'naive-ui'
@ -196,20 +201,15 @@ const Nevkey = ref('');
const showList = ref(false); const showList = ref(false);
const message = ref(''); const message = ref('');
const paramMsg = ref([]); const paramMsg = ref([]);
const AllMessage = useMessage()
//
const showSk = ref('');
// //
const page = reactive({ page: 1, limit: 1 }); const page = reactive({ page: 1, limit: 1 });
//
const showHd = ref('');
//ID //ID
const processedIds = ref(new Set()); const processedIds = ref(new Set());
const chatContainerRef = ref(null); const chatContainerRef = ref(null);
// //
const userScrolled = ref(false); const userScrolled = ref(false);
const chatHdEnd=ref(true); const chatHdEnd = ref(true);
// //
const scrollToBottom = async () => { const scrollToBottom = async () => {
// //
@ -218,12 +218,13 @@ const scrollToBottom = async () => {
setTimeout(() => { setTimeout(() => {
if (chatContainerRef.value) { if (chatContainerRef.value) {
const container = chatContainerRef.value; const container = chatContainerRef.value;
console.log(container);
container.scrollTop = container.scrollHeight; container.scrollTop = container.scrollHeight;
} }
}, 100); }, 100);
}; };
onMounted(()=>{
Nevkey.value = Date.now().toString();
})
// //
const handleScroll = (event) => { const handleScroll = (event) => {
const container = event.target; const container = event.target;
@ -242,9 +243,14 @@ const handleScroll = (event) => {
// //
const getQuestionList = () => { const getQuestionList = () => {
if (storp.value == true) {
storp.value = false;
chatHdEnd.value = true;
return;
}
const index = paramMsg.value.length - 1; const index = paramMsg.value.length - 1;
if (paramMsg.value[index].role != 'assistant') { if (paramMsg.value[index].role != 'assistant') {
paramMsg.value.push({ role: 'assistant', sk: '', content: '',skLong:true }); paramMsg.value.push({ role: 'assistant', sk: '', content: '', skLong: true });
} }
getQuestion({ 'key': Nevkey.value, 'page': page.page, 'limit': page.limit }).then(res => { getQuestion({ 'key': Nevkey.value, 'page': page.page, 'limit': page.limit }).then(res => {
if (res.code == 1) { if (res.code == 1) {
@ -256,14 +262,14 @@ const getQuestionList = () => {
if (item.reasoning == 1) { if (item.reasoning == 1) {
paramMsg.value[lastIndex].sk += item.content; paramMsg.value[lastIndex].sk += item.content;
} else { } else {
paramMsg.value[lastIndex].skLong =false; paramMsg.value[lastIndex].skLong = false;
paramMsg.value[lastIndex].content += item.content; paramMsg.value[lastIndex].content += item.content;
} }
} }
if (item.usage_json.length > 0 || item.usage_json.prompt_tokens) { if (item.usage_json.length > 0 || item.usage_json.prompt_tokens) {
const lIndex = paramMsg.value.length - 1; const lIndex = paramMsg.value.length - 1;
paramMsg.value[lIndex].content = marked(paramMsg.value[lIndex].content); paramMsg.value[lIndex].content = marked(paramMsg.value[lIndex].content);
paramMsg.value[lIndex].skLong =false; paramMsg.value[lIndex].skLong = false;
chatHdEnd.value = true; chatHdEnd.value = true;
return; return;
} }
@ -279,11 +285,13 @@ const getQuestionList = () => {
}) })
} }
const storp = ref(false);
// //
const MesdsetQuestion = () => { const MesdsetQuestion = () => {
if (!message.value || message.value.trim() === '') return if (!message.value || message.value.trim() === '') return
console.log(chatHdEnd.value);
if (chatHdEnd.value == true) { if (chatHdEnd.value == true) {
showList.value = true; showList.value = true;
paramMsg.value.push({ role: 'user', content: message.value }) paramMsg.value.push({ role: 'user', content: message.value })
@ -302,13 +310,20 @@ const MesdsetQuestion = () => {
} }
} }
const MesdsetQuestionStorp=()=>{
storp.value=true;
paramMsg.value=[];
chatHdEnd.value = true;
showList.value=false;
// const lIndex = paramMsg.value.length - 1;
// paramMsg.value[lIndex].skLong = false;
}
// //
onUnmounted(() => { onUnmounted(() => {
processedIds.value.clear(); processedIds.value.clear();
page.page = 1; page.page = 1;
}); });
const copy = (d) =>{ const copy = (d) => {
navigator.clipboard.writeText(d); navigator.clipboard.writeText(d);
//AllMessage.success(''); //AllMessage.success('');
} }
@ -317,13 +332,16 @@ const copy = (d) =>{
import "highlight.js/styles/monokai-sublime.css"; import "highlight.js/styles/monokai-sublime.css";
<style> <style>
.language-markdown{ .language-markdown {
color: #000!important; color: #000 !important;
} }
.ds-markdown .ds-markdown--block{
color: #000!important; .ds-markdown .ds-markdown--block {
color: #000 !important;
} }
code[class*=language-], pre[class*=language-]{
color: #000!important; code[class*=language-],
pre[class*=language-] {
color: #000 !important;
} }
</style> </style>