Explorar el Código

fix: kaifain mobile redirect: handle /s/:id & /d/:id

Acathur hace 5 años
padre
commit
490427a4d6
Se han modificado 1 ficheros con 10 adiciones y 1 borrados
  1. 10 1
      layouts/kaifain_v2.vue

+ 10 - 1
layouts/kaifain_v2.vue

@@ -19,7 +19,16 @@ export default {
   created() {
     if (process.client) {
       if (Cookies.get('x_app') || /(android|iphone|ipod)/i.test(window.navigator.userAgent)) {
-        window.location.href = window.location.href.replace(location.host, MOB_HOST)
+        const source = window.location.href
+        let target
+
+        if (/\/(s|d)\/[0-9a-f]+/.test(source)) {
+          target = source.replace(location.host, MOB_HOST)
+        } else {
+          target = `https://${MOB_HOST}/`
+        }
+
+        window.location.href = target
       }
     }
   }