diff --git a/src/App.vue b/src/App.vue index 6459a95..16afd50 100644 --- a/src/App.vue +++ b/src/App.vue @@ -2,6 +2,7 @@ // 路由转发页面无需额外组件引入 import api from './utils/api.js'; import { onMounted } from 'vue' +import { WechatAuth } from '@/utils/wechat' // 获取当前URL参数 const urlParams = new URLSearchParams(window.location.search); @@ -9,21 +10,24 @@ const urlParams = new URLSearchParams(window.location.search); const friend_account_id = urlParams.get('friend_account_id'); const accountId = urlParams.get('accountId'); -// 执行微信授权检查 -try { - api.wechatAPI.checkAndLogin(window.location.href, accountId ? accountId : undefined,friend_account_id ? friend_account_id : undefined) - .then(result => { - if (result.redirecting) { - console.log('跳转微信授权中...'); - } else if (result.success) { - console.log('微信授权成功,token:', result.token); - } - }) - .catch(error => { - console.error('微信授权失败:', error); - }); -} catch (error) { - console.error('授权初始化异常:', error); +//微信环境 +if(WechatAuth.isWechatBrowser()){ + // 执行微信授权检查 + try { + api.wechatAPI.checkAndLogin(window.location.href, accountId ? accountId : undefined,friend_account_id ? friend_account_id : undefined) + .then(result => { + if (result.redirecting) { + console.log('跳转微信授权中...'); + } else if (result.success) { + console.log('微信授权成功,token:', result.token); + } + }) + .catch(error => { + console.error('微信授权失败:', error); + }); + } catch (error) { + console.error('授权初始化异常:', error); + } } onMounted(() => { diff --git a/src/pages/Home.vue b/src/pages/Home.vue index b8a1c00..99e8d89 100644 --- a/src/pages/Home.vue +++ b/src/pages/Home.vue @@ -1,26 +1,35 @@