@@ -30,10 +30,13 @@ import { clipboardStore } from "@/stores/clipboard";
3030import { globalStore } from "@/stores/global" ;
3131import type { DatabaseSchemaHistory } from "@/types/database" ;
3232import { dayjs } from "@/utils/dayjs" ;
33+ import { runDockAction } from "@/utils/dockAction" ;
3334import { isImage , isLinux } from "@/utils/is" ;
3435
3536export interface PasteCardProps {
3637 active ?: boolean ;
38+ afterHide ?: ( ) => void ;
39+ beforeActivate ?: ( ) => void ;
3740 data : DatabaseSchemaHistory ;
3841 deleteModal : HookAPI ;
3942 handleNote : ( ) => void ;
@@ -72,10 +75,20 @@ const getTypeColorClass = (type: DatabaseSchemaHistory["type"]) => {
7275} ;
7376
7477const PasteCard : FC < PasteCardProps > = ( props ) => {
75- const { active, data, deleteModal, handleNote, handleSend, index, onSelect } =
76- props ;
78+ const {
79+ active,
80+ afterHide,
81+ beforeActivate,
82+ data,
83+ deleteModal,
84+ handleNote,
85+ handleSend,
86+ index,
87+ onSelect,
88+ } = props ;
7789 const { id, count, createTime, favorite, note, subtype, type, value } = data ;
78- const { rootState, handlePasteResult } = useContext ( MainContext ) ;
90+ const { rootState, handlePasteResult, touchHistoryItem } =
91+ useContext ( MainContext ) ;
7992 const { t, i18n } = useTranslation ( ) ;
8093 const { wegent } = useSnapshot ( clipboardStore ) ;
8194 const { env, shortcut } = useSnapshot ( globalStore ) ;
@@ -333,6 +346,8 @@ const PasteCard: FC<PasteCardProps> = (props) => {
333346 } ;
334347
335348 const { handleContextMenu, handleDelete, handleFavorite } = useContextMenu ( {
349+ afterHide,
350+ beforeActivate,
336351 data,
337352 deleteModal,
338353 handleNext,
@@ -348,9 +363,18 @@ const PasteCard: FC<PasteCardProps> = (props) => {
348363 case LISTEN_KEY . CLIPBOARD_ITEM_PREVIEW :
349364 return handlePreview ( ) ;
350365 case LISTEN_KEY . CLIPBOARD_ITEM_PASTE : {
351- const result = await runActivateAction ( data ) ;
352- handlePasteResult ?.( result ) ;
353- await hideWindow ( ) ;
366+ await runDockAction ( {
367+ action : ( ) => runActivateAction ( data ) ,
368+ afterHide,
369+ beforeAction : beforeActivate ,
370+ hideWindow,
371+ onResult : ( result ) => {
372+ handlePasteResult ?.( result ) ;
373+ if ( result . success ) {
374+ touchHistoryItem ?.( data ) ;
375+ }
376+ } ,
377+ } ) ;
354378 return ;
355379 }
356380 case LISTEN_KEY . CLIPBOARD_ITEM_DELETE :
@@ -526,9 +550,18 @@ const PasteCard: FC<PasteCardProps> = (props) => {
526550
527551 const handleCardDoubleClick = async ( ) => {
528552 rootState . activeId = id ;
529- const result = await runActivateAction ( data ) ;
530- handlePasteResult ?.( result ) ;
531- await hideWindow ( ) ;
553+ await runDockAction ( {
554+ action : ( ) => runActivateAction ( data ) ,
555+ afterHide,
556+ beforeAction : beforeActivate ,
557+ hideWindow,
558+ onResult : ( result ) => {
559+ handlePasteResult ?.( result ) ;
560+ if ( result . success ) {
561+ touchHistoryItem ?.( data ) ;
562+ }
563+ } ,
564+ } ) ;
532565 } ;
533566
534567 const cardContent = (
0 commit comments