瀏覽代碼

手机端打不开问题

liuq 2 月之前
父節點
當前提交
68794082d7
共有 1 個文件被更改,包括 12 次插入1 次删除
  1. 12 1
      frontend/src/views/PlatformLaunchpad.vue

+ 12 - 1
frontend/src/views/PlatformLaunchpad.vue

@@ -49,6 +49,11 @@ import { useRouter } from 'vue-router'
 
 const router = useRouter()
 
+// 检测是否为移动端设备
+const isMobile = () => {
+  return /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)
+}
+
 // Types
 interface Mapping {
   app_name: string
@@ -134,7 +139,13 @@ const handleAppClick = async (app: Mapping) => {
     )
     
     if (res.data && res.data.redirect_url) {
-      window.open(res.data.redirect_url, '_blank')
+      if (isMobile()) {
+        // 手机端直接在当前标签页打开
+        window.location.href = res.data.redirect_url
+      } else {
+        // PC端在新标签页打开
+        window.open(res.data.redirect_url, '_blank')
+      }
       loadingMsg.close()
       ElMessage.success('已打开应用')
     } else {