22 <div
33 class =" view"
44 :data-focus-id =" effectiveWindowId"
5- :class =" { 'is-active': windowStore.activeFocus === props.chunkId }"
6- @pointerdown =" windowStore.setFocus(props.chunkId )"
5+ :class =" { 'is-active': windowStore.activeFocus === effectiveWindowId }"
6+ @pointerdown =" windowStore.setFocus(effectiveWindowId )"
77 >
88 <header class =" view-header" >
99 <div class =" view-title" >
5454 ></div >
5555 <MessageItem
5656 :message =" msg "
57- :chunk-id =" props . chunkId "
57+ :chunk-id =" currentChunkId "
5858 :index =" index "
5959 :is-selected ="
6060 filterTool .selectedMessageIds .value .has (
9090
9191<script setup lang="ts">
9292import { FileText , X , SquareSplitHorizontal } from ' @lucide/vue' ;
93- import { computed , ref , onMounted } from ' vue' ;
93+ import { computed , ref } from ' vue' ;
9494import { useLogStore } from ' @/stores/logStore' ;
9595import { useFilter } from ' @/composables/useFilter' ;
9696import { useMessageDragDrop } from ' @/composables/useDragDrop' ;
@@ -102,10 +102,11 @@ import { useWindowStore } from '@/stores/windowStore';
102102import type { Message } from ' @/types/log' ;
103103
104104const props = defineProps <{
105- chunkId : string ;
106- windowId ? : string ;
105+ windowId : string ;
106+ originalId : string ;
107107}>();
108- const effectiveWindowId = computed (() => props .windowId ?? props .chunkId );
108+ const effectiveWindowId = computed (() => props .windowId );
109+ const currentChunkId = computed (() => props .originalId );
109110const filterTool = useFilter (effectiveWindowId .value );
110111const dragDropTool = useMessageDragDrop ();
111112const dropIndicatorIndex = ref <number | null >(null );
@@ -123,24 +124,26 @@ const canClose = computed(() => {
123124 );
124125});
125126
126- onMounted (() => {
127- // 注册窗口时,显式传入 originalId
128- // 将 split 窗口映射回原始 chunkId,从而共享选区
129- windowStore .registerWindow ({
130- windowId: effectiveWindowId .value ,
131- windowName: ' chunkView' ,
132- windowType: ' view' ,
133- originalId: props .chunkId ,
134- });
135- });
127+ // view的生命周期统一交给windowStore处理,不在组件层调用
128+ // onMounted(() => {
129+ // windowStore.registerWindow({
130+ // windowId: effectiveWindowId.value,
131+ // windowName: 'chunkView',
132+ // windowType: 'view',
133+ // originalId: currentChunkId.value,
134+ // });
135+ // });
136+ // onUnmounted(() => {
137+ // windowStore.unregisterWindow(effectiveWindowId.value);
138+ // });
136139
137140function handleSplit() {
138- windowStore .enterSplitMode (' chunkView' , props . chunkId );
141+ windowStore .enterSplitMode (' chunkView' , currentChunkId . value );
139142}
140143
141144function handleClose() {
142145 if (windowStore .splitMode === ' double' ) {
143- windowStore .closePane ();
146+ windowStore .closePane (effectiveWindowId . value );
144147 } else {
145148 windowStore .unregisterWindow (effectiveWindowId .value );
146149 // 如果还有其他打开的视图,聚焦到第一个可用的
@@ -157,10 +160,12 @@ function handleClose() {
157160 }
158161}
159162
160- const isViewFocused = computed (() => windowStore .activeFocus === props .chunkId );
163+ const isViewFocused = computed (
164+ () => windowStore .activeFocus === effectiveWindowId .value ,
165+ );
161166
162167const currentChunk = computed (function () {
163- return logStore .findChunkById (props . chunkId ) || undefined ;
168+ return logStore .findChunkById (currentChunkId . value ) || undefined ;
164169});
165170
166171const messages = computed (function () {
@@ -177,7 +182,7 @@ function handleMessageSelect(event: MouseEvent, msgId: string, index: number) {
177182}
178183
179184function handleUpdateContent(messageId : string , newContent : string ) {
180- messageEditorStore .updateMessage (props . chunkId , messageId , {
185+ messageEditorStore .updateMessage (currentChunkId . value , messageId , {
181186 content: newContent ,
182187 });
183188}
@@ -226,25 +231,28 @@ function handleContainerDrop(event: DragEvent) {
226231}
227232
228233function handleActionInsert(msg : Message , index : number ) {
229- messageEditorStore .insertNewMessageAfter (props . chunkId , msg , index );
234+ messageEditorStore .insertNewMessageAfter (currentChunkId . value , msg , index );
230235}
231236
232237function handleActionMerge(msg : Message ) {
233238 const selectedIds = filterTool .selectedMessageIds .value ;
234239 if (selectedIds .has (msg .messageId ) && selectedIds .size > 1 ) {
235240 messageEditorStore .mergeMessages (
236- props . chunkId ,
241+ currentChunkId . value ,
237242 Array .from (selectedIds ),
238243 msg .messageId ,
239244 );
240245 filterTool .clearMessageSelection ();
241246 } else {
242- messageEditorStore .mergeWithNextMessage (props .chunkId , msg .messageId );
247+ messageEditorStore .mergeWithNextMessage (
248+ currentChunkId .value ,
249+ msg .messageId ,
250+ );
243251 }
244252}
245253
246254function handleActionSplit(msgId : string ) {
247- chunkEditorStore .splitChunk (props . chunkId , msgId );
255+ chunkEditorStore .splitChunk (currentChunkId . value , msgId );
248256}
249257
250258function handleActionDelete(msgId : string ) {
@@ -253,7 +261,7 @@ function handleActionDelete(msgId: string) {
253261 messageEditorStore .batchDeleteMessages (selectedIds );
254262 filterTool .clearMessageSelection ();
255263 } else {
256- messageEditorStore .deleteMessage (props . chunkId , msgId );
264+ messageEditorStore .deleteMessage (currentChunkId . value , msgId );
257265 }
258266}
259267 </script >
0 commit comments