From 8937e88ea13aabf783686c20c1e525c97633ca4c Mon Sep 17 00:00:00 2001 From: chanLee <2535849195@qq.com> Date: Sun, 14 Dec 2025 23:31:17 +0800 Subject: [PATCH 1/2] refactor: refactor part of context --- .../src/chain-of-thought/ChainOfThought.vue | 10 ++++--- .../chain-of-thought/ChainOfThoughtImage.vue | 2 +- .../elements/src/chain-of-thought/context.ts | 27 +++++-------------- .../elements/src/code-block/CodeBlock.vue | 12 ++++----- .../src/code-block/CodeBlockCopyButton.vue | 11 +++----- packages/elements/src/code-block/context.ts | 7 ++--- .../src/confirmation/Confirmation.vue | 6 ++--- .../src/confirmation/ConfirmationAccepted.vue | 4 +-- .../src/confirmation/ConfirmationActions.vue | 4 +-- .../src/confirmation/ConfirmationRejected.vue | 4 +-- .../src/confirmation/ConfirmationRequest.vue | 4 +-- packages/elements/src/confirmation/context.ts | 14 +++------- packages/elements/src/context/Context.vue | 6 ++--- packages/elements/src/context/context.ts | 15 +++-------- .../elements/src/message/MessageBranch.vue | 11 +++----- .../src/message/MessageBranchContent.vue | 4 +-- .../src/message/MessageBranchNext.vue | 4 +-- .../src/message/MessageBranchPage.vue | 4 +-- .../src/message/MessageBranchPrevious.vue | 4 +-- .../src/message/MessageBranchSelector.vue | 4 +-- packages/elements/src/message/context.ts | 15 +++-------- packages/elements/src/open-in-chat/context.ts | 19 +++---------- packages/elements/src/plan/context.ts | 18 +++---------- 23 files changed, 71 insertions(+), 138 deletions(-) diff --git a/packages/elements/src/chain-of-thought/ChainOfThought.vue b/packages/elements/src/chain-of-thought/ChainOfThought.vue index 2386370..ac12b63 100644 --- a/packages/elements/src/chain-of-thought/ChainOfThought.vue +++ b/packages/elements/src/chain-of-thought/ChainOfThought.vue @@ -2,8 +2,7 @@ import type { HTMLAttributes, Ref } from 'vue' import { cn } from '@repo/shadcn-vue/lib/utils' import { useVModel } from '@vueuse/core' -import { provide } from 'vue' -import { ChainOfThoughtContextKey } from './context' +import { provideChainOfThought } from './context' interface ChainOfThoughtProps { modelValue?: boolean @@ -28,7 +27,12 @@ const isOpen = useVModel(props, 'modelValue', emit, { passive: true, }) -provide(ChainOfThoughtContextKey, isOpen as Ref) +provideChainOfThought({ + isOpen: isOpen as Ref, + setIsOpen: (open: boolean) => { + isOpen.value = open + }, +})