File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -147,17 +147,24 @@ function goBack() {
147147 step .value = ' input' ;
148148}
149149
150+ let copyTimer: ReturnType <typeof setTimeout > | undefined ;
151+
150152async function copyRssLink() {
151153 const rssLink = rule .value .rss_link ?.[0 ] || rss .value .url || ' ' ;
152154 if (rssLink ) {
153155 await navigator .clipboard .writeText (rssLink );
154156 copied .value = true ;
155- setTimeout (() => {
157+ clearTimeout (copyTimer );
158+ copyTimer = setTimeout (() => {
156159 copied .value = false ;
157160 }, 2000 );
158161 }
159162}
160163
164+ onBeforeUnmount (() => {
165+ clearTimeout (copyTimer );
166+ });
167+
161168async function autoDetectOffset() {
162169 if (! rule .value .id ) return ;
163170 offsetLoading .value = true ;
Original file line number Diff line number Diff line change @@ -82,17 +82,24 @@ const infoTags = computed(() => {
8282});
8383
8484// Copy RSS link
85+ let copyTimer: ReturnType <typeof setTimeout > | undefined ;
86+
8587async function copyRssLink() {
8688 const rssLink = localRule .value .rss_link ?.[0 ] || ' ' ;
8789 if (rssLink ) {
8890 await navigator .clipboard .writeText (rssLink );
8991 copied .value = true ;
90- setTimeout (() => {
92+ clearTimeout (copyTimer );
93+ copyTimer = setTimeout (() => {
9194 copied .value = false ;
9295 }, 2000 );
9396 }
9497}
9598
99+ onBeforeUnmount (() => {
100+ clearTimeout (copyTimer );
101+ });
102+
96103// Auto detect offset using the new detectOffset API
97104async function autoDetectOffset() {
98105 if (! localRule .value .official_title || ! localRule .value .season ) return ;
Original file line number Diff line number Diff line change @@ -103,17 +103,24 @@ const infoTags = computed(() => {
103103});
104104
105105// Copy RSS link
106+ let copyTimer: ReturnType <typeof setTimeout > | undefined ;
107+
106108async function copyRssLink() {
107109 const rssLink = localBangumi .value .rss_link ?.[0 ] || ' ' ;
108110 if (rssLink ) {
109111 await navigator .clipboard .writeText (rssLink );
110112 copied .value = true ;
111- setTimeout (() => {
113+ clearTimeout (copyTimer );
114+ copyTimer = setTimeout (() => {
112115 copied .value = false ;
113116 }, 2000 );
114117 }
115118}
116119
120+ onBeforeUnmount (() => {
121+ clearTimeout (copyTimer );
122+ });
123+
117124// Auto detect offset
118125async function autoDetectOffset() {
119126 if (! localBangumi .value .id ) return ;
Original file line number Diff line number Diff line change @@ -27,6 +27,7 @@ const {
2727 getProviders,
2828 onSearch,
2929 clearSearch,
30+ closeSearch,
3031 selectResult,
3132 clearSelectedResult,
3233} = useSearchStore ();
@@ -61,6 +62,11 @@ const expandedCategories = ref<Set<'group' | 'resolution' | 'subtitle' | 'season
6162// Track which bangumi groups have expanded variants
6263const expandedVariants = ref <Set <string >>(new Set ());
6364
65+ // Close EventSource on unmount (prevents leak if navigating away mid-search)
66+ onBeforeUnmount (() => {
67+ closeSearch ();
68+ });
69+
6470// Close on Escape
6571onKeyStroke (' Escape' , () => {
6672 if (selectedResult .value ) {
You can’t perform that action at this time.
0 commit comments