Explorar el Código

Refactor callDeepLink function to improve deep linking behavior

- Enhanced the callDeepLink function by removing the iframe implementation and directly using window.location.href for deep linking, ensuring better compatibility and reliability across platforms.
0es hace 2 meses
padre
commit
62659a1547
Se han modificado 1 ficheros con 20 adiciones y 0 borrados
  1. 20 0
      app/plugins/blurScrollTop.client.ts

+ 20 - 0
app/plugins/blurScrollTop.client.ts

@@ -0,0 +1,20 @@
+export default defineNuxtPlugin(() => {
+  if (!import.meta.client) return
+
+  const onBlur = (e: FocusEvent) => {
+    const target = e.target as HTMLElement | null
+    if (!target) return
+
+    const tag = target.tagName
+    if (tag !== 'INPUT' && tag !== 'TEXTAREA') return
+
+    window.setTimeout(() => {
+      window.scrollTo(0, 0)
+      document.body.scrollTop = 0
+      document.documentElement.scrollTop = 0
+    }, 100)
+  }
+
+  // `blur` does not bubble; use capture to listen globally.
+  document.addEventListener('blur', onBlur, true)
+})