ソースを参照

简化Safari浏览器兼容性处理,直接使用location.href跳转支付页面,提升代码可读性和维护性。

wuyi 3 ヶ月 前
コミット
c367f17ca2
1 ファイル変更2 行追加33 行削除
  1. 2 33
      src/views/Account.vue

+ 2 - 33
src/views/Account.vue

@@ -87,39 +87,8 @@ const showSuccess = (message: string) => {
 
 // Safari兼容性处理:打开支付页面
 const openPaymentPage = (url: string) => {
-  // 检测是否为Safari浏览器
-  const isSafari = /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
-
-  if (isSafari) {
-    // Safari浏览器:尝试多种方式打开支付页面
-    try {
-      // 方法1:直接使用window.open
-      const newWindow = window.open(url, "_blank");
-
-      // 检查是否被阻止
-      if (
-        !newWindow ||
-        newWindow.closed ||
-        typeof newWindow.closed === "undefined"
-      ) {
-        // 方法2:创建临时链接并点击
-        const link = document.createElement("a");
-        link.href = url;
-        link.target = "_blank";
-        link.rel = "noopener noreferrer";
-        document.body.appendChild(link);
-        link.click();
-        document.body.removeChild(link);
-      }
-    } catch (error) {
-      console.error("Safari支付页面打开失败:", error);
-      // 方法3:使用location.href作为备用方案
-      showError("无法打开支付页面,请手动复制链接:" + url);
-    }
-  } else {
-    // 其他浏览器:正常使用window.open
-    window.open(url, "_blank");
-  }
+  // 直接使用location.href跳转,确保Safari兼容性
+  window.location.href = url;
 };
 
 const handleMembershipPurchase = async () => {