Repository navigation
fix: Whether to display a share button on the conversation page #7818
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,13 +6,6 @@ import MessageInput from '../../components/message-input/index.vue' | |
| import { useConversationListStore } from '../../left-sidebar/conversation-list/index' | ||
| import { useMessageInputStore } from '../../components/message-input/index' | ||
|
|
||
| defineProps<{ | ||
| /** 标题栏显示分享入口;仅对话端传入 */ | ||
| shareable?: boolean | ||
| }>() | ||
|
|
||
| const emit = defineEmits<{ share: [] }>() | ||
|
|
||
| const list = useConversationListStore() | ||
| const input = useMessageInputStore() | ||
| // 拖拽到面板任意处 → 交给 message-input 接收文件 | ||
|
|
@@ -25,7 +18,7 @@ const disclaimerText = computed(() => (list.appInfo.value?.disclaimer ? list.app | |
| <main class="mk-conversation-main" @drop.prevent="handleDrop" @dragover.prevent> | ||
| <!-- 头部可被替换(如 debug 用 debug header);默认普通 chat header --> | ||
| <slot name="header"> | ||
| <ChatHeader :shareable="shareable" @share="emit('share')" /> | ||
| <ChatHeader /> | ||
| </slot> | ||
| <!-- 聊天背景铺满标题栏以下的消息区与输入区,与显示设置预览一致 --> | ||
| <div | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here is an analysis of the provided code diff: 1. Irregularities & Potential Issues
2. Optimization Suggestions
SummaryThe code cleanup simplifies the component signature but is a breaking change. It is safe only if no external consumer relies on the removed |
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -13,7 +13,7 @@ import { MESSAGE_INPUT_KEY } from '../../components/message-input/index' | |
| import { EXECUTION_DETAIL_KEY } from '../../right-sidebar/execution-detail/index' | ||
| import { SHARE_LINK_KEY } from '../../components/message-list/share/index' | ||
| import { createChatConversation, createChatUserProfileGetter } from './index' | ||
| import { VIEW_KEY, VIEW_TYPE, DEVICE_KEY, CHAT_USER_PROFILE_KEY, createDeviceType } from '../index.ts' | ||
| import { VIEW_KEY, VIEW_TYPE, DEVICE_KEY, CHAT_USER_PROFILE_KEY, SHOW_SHARE_KEY, createDeviceType } from '../index.ts' | ||
|
|
||
| const bundle = createChatConversation() | ||
|
|
||
|
|
@@ -38,6 +38,11 @@ provide(MESSAGE_INPUT_KEY, bundle.input) | |
| provide(EXECUTION_DETAIL_KEY, bundle.detail) | ||
| provide(SHARE_LINK_KEY, bundle.share) | ||
| provide(VIEW_KEY, VIEW_TYPE.CHAT) | ||
| // 智能体开启「允许分享对话记录」时显示标题栏、会话菜单、提问与回答上的分享入口 | ||
| provide( | ||
| SHOW_SHARE_KEY, | ||
| computed(() => Boolean(bundle.list.appInfo.value?.show_share)), | ||
| ) | ||
| // HTML 内容 iframe 内 chatUserProfile() 取当前对话用户 | ||
| provide(CHAT_USER_PROFILE_KEY, createChatUserProfileGetter()) | ||
|
|
||
|
|
@@ -83,7 +88,7 @@ watch([() => bundle.list.currentChatId.value, () => bundle.list.composerResetSig | |
| @mask-click="closeDrawers" | ||
| > | ||
| <template #left><ConversationList /></template> | ||
| <template #main><ChatPanel shareable /></template> | ||
| <template #main><ChatPanel /></template> | ||
| <template #right><ExecutionDetail /></template> | ||
| </ConversationLayout> | ||
| </template> | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here is the review of the code changes: 1. Potential Issues
2. Optimization Suggestions
3. Style & Best Practices
4. SummaryThe change effectively shifts the "shareability" logic from a static, per-component prop to a dynamic, app-level contextual state via Vue's Action Required: Verify that all components previously relying on the |
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code modifications introduce several logical issues and anti-patterns:
1. Violation of Vue Composition API Rules (Critical)
const showShare = useShowShare()executesuseShowShare()immediately during the script setup phase. IfuseShowShareis a standard composable returning a reactive reference (e.g.,Ref<boolean>), assigning it directly to a plainconstmeans:v-if="showShare") to always be truthy.Fix: Ensure
useShowSharereturns a reactive ref and use it correctly in the template, or destructure/compute if necessary. If it's a computed property inside,useShowShareshould likely return aComputedRef.2. Reactivity Loss
Previously,
SHAREABLE_VIEWS.includes(useViewType())suggestsuseViewType()is a reactive getter or function call that was potentially evaluated once but relied on imported constants. Now, replacing it with a custom hookuseShowShare()isolates logic appropriately, but you must ensureuseShowShareproperly tracks dependencies (like route params or view types) so thatshowShareupdates dynamically when the user switches views.3. Comment Alignment
The comment text updated from "views sharing service" to "agent allows sharing". Ensure the business logic inside
useShowSharematches this new description.4. Redundant Imports Check
Verify that
useViewTypeis truly not used elsewhere in this file since it was removed. Similarly, ensureSHAREABLE_VIEWSis no longer needed.Optimization Suggestion:
If
useShowShareis simply a boolean check based on current route/view, consider if it could be derived directly viacomputedwithin this component for better locality, unless it is reused across multiple components (which justifies a separate hook).