@@ -9,7 +9,6 @@ import html2canvas from 'html2canvas'
99import { Message } from ' ./components'
1010import { useScroll } from ' ./hooks/useScroll'
1111import { useChat } from ' ./hooks/useChat'
12- import { useUsingContext } from ' ./hooks/useUsingContext'
1312import HeaderComponent from ' ./components/Header/index.vue'
1413import { HoverButton , SvgIcon } from ' @/components/common'
1514import { useBasicLayout } from ' @/hooks/useBasicLayout'
@@ -34,10 +33,11 @@ const chatStore = useChatStore()
3433const { isMobile } = useBasicLayout ()
3534const { addChat, updateChat, updateChatSome, getChatByUuidAndIndex } = useChat ()
3635const { scrollRef, scrollToBottom, scrollToBottomIfAtBottom, scrollTo } = useScroll ()
37- const { usingContext, toggleUsingContext } = useUsingContext ()
3836
3937const { uuid } = route .params as { uuid: string }
4038
39+ const currentChatHistory = computed (() => chatStore .getChatHistoryByCurrentActive )
40+ const usingContext = computed (() => currentChatHistory ?.value ?.usingContext ?? true )
4141const dataSources = computed (() => chatStore .getChatByUuid (+ uuid ))
4242const conversationList = computed (() => dataSources .value .filter (item => (! item .inversion && !! item .conversationOptions )))
4343
@@ -513,6 +513,18 @@ async function handleScroll(event: any) {
513513 prevScrollTop = scrollTop
514514}
515515
516+ async function handleToggleUsingContext() {
517+ if (! currentChatHistory .value )
518+ return
519+
520+ currentChatHistory .value .usingContext = ! currentChatHistory .value .usingContext
521+ chatStore .setUsingContext (currentChatHistory .value .usingContext , + uuid )
522+ if (currentChatHistory .value .usingContext )
523+ ms .success (t (' chat.turnOnContext' ))
524+ else
525+ ms .warning (t (' chat.turnOffContext' ))
526+ }
527+
516528// 可优化部分
517529// 搜索选项计算,这里使用value作为索引项,所以当出现重复value时渲染异常(多项同时出现选中效果)
518530// 理想状态下其实应该是key作为索引项,但官方的renderOption会出现问题,所以就需要value反renderLabel实现
@@ -577,7 +589,7 @@ onUnmounted(() => {
577589 v-if =" isMobile"
578590 :using-context =" usingContext"
579591 :show-prompt =" showPrompt"
580- @export =" handleExport" @toggle-using-context =" toggleUsingContext "
592+ @export =" handleExport" @toggle-using-context =" handleToggleUsingContext "
581593 @toggle-show-prompt =" showPrompt = true"
582594 />
583595 <main class =" flex-1 overflow-hidden" >
@@ -642,7 +654,7 @@ onUnmounted(() => {
642654 <IconPrompt class =" w-[20px] m-auto" />
643655 </span >
644656 </HoverButton >
645- <HoverButton v-if =" !isMobile" @click =" toggleUsingContext " >
657+ <HoverButton v-if =" !isMobile" @click =" handleToggleUsingContext " >
646658 <span class =" text-xl" :class =" { 'text-[#4b9e5f]': usingContext, 'text-[#a8071a]': !usingContext }" >
647659 <SvgIcon icon =" ri:chat-history-line" />
648660 </span >
0 commit comments