@@ -98,26 +98,48 @@ onMounted(async () => {
9898 }),
9999 });
100100 macos_selected_link .value = macos_links .value [0 ];
101+ });
102+ // 判断是否为微信浏览器
103+ const isWeChatBrowser = () => {
104+ return / MicroMessenger/ i .test (navigator .userAgent );
105+ };
106+ const handleAppStoreClick = (event : MouseEvent ) => {
107+ if (isWeChatBrowser ()) {
108+ event .preventDefault ();
109+ // 创建引导遮罩层
110+ const mask = document .createElement (" div" );
111+ mask .style .cssText = `
112+ position: fixed;
113+ top: 0;
114+ left: 0;
115+ width: 100%;
116+ height: 100%;
117+ background: rgba(0, 0, 0, 0.7);
118+ z-index: 999999;
119+ display: flex;
120+ justify-content: center;
121+ align-items: center;
122+ ` ;
101123
102- // 判断是否为微信浏览器
103- function isWeChatBrowser() {
104- const userAgent = navigator .userAgent .toLowerCase ();
105- return userAgent .toLowerCase ().includes (" micromessenger" );
106- }
124+ const text = document .createElement (" div" );
125+ text .style .cssText = `
126+ color: white;
127+ font-size: 16px;
128+ text-align: center;
129+ padding: 20px;
130+ ` ;
131+ text .innerHTML =
132+ ' 请点击右上角<br/>选择"在浏览器中打开"<br/>以访问 App Store' ;
107133
108- // 获取 <a> 标签并动态修改行为
109- document .addEventListener (" DOMContentLoaded" , () => {
110- const link = document .getElementById (" app-store-link" );
134+ mask .appendChild (text );
135+ document .body .appendChild (mask );
111136
112- if (isWeChatBrowser ()) {
113- // 如果是微信浏览器,阻止默认跳转行为
114- link ?.addEventListener (" click" , (event ) => {
115- event .preventDefault (); // 阻止默认跳转
116- window .location .href = " https://apps.apple.com/cn/app/6443558874" ; // 可选:尝试强制跳转
117- });
118- }
119- });
120- });
137+ // 点击遮罩层移除
138+ mask .addEventListener (" click" , () => {
139+ document .body .removeChild (mask );
140+ });
141+ }
142+ };
121143 </script >
122144
123145<template >
@@ -180,6 +202,7 @@ onMounted(async () => {
180202 id =" app-store-link"
181203 href =" https://apps.apple.com/cn/app/6443558874"
182204 target =" _blank"
205+ @click =" handleAppStoreClick"
183206 >
184207 App Store @Dweb Browser
185208 </a >
0 commit comments