export const QQ_APP_ID = '102796005' // QQ appid export const WECHAT_APP_ID = 'wxc2fa7aafa1649f7a' // 微信 appid // 生成随机字符串 export const generateRandomString = (length: number) => { const characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789' let result = '' for (let i = 0; i < length; i++) { result += characters.charAt(Math.floor(Math.random() * characters.length)) } return result } // QQ登录 export const handleLoginQQ = () => { const redirectUri = encodeURIComponent('https://tuxixi.net?type=35') // 回调地址 const state = generateRandomString(16) // 生成随机state // 存储state用于后续验证 localStorage.setItem('qq_login_state', state) window.location.href = `https://graph.qq.com/oauth2.0/authorize?response_type=code&client_id=${QQ_APP_ID}&redirect_uri=${redirectUri}&state=${state}` } export const handleLoginWechat = () => { const redirectUri = encodeURIComponent('https://tuxixi.net?type=32') // 回调地址 const state = generateRandomString(16) // 生成随机state // 存储state用于后续验证 localStorage.setItem('wechat_login_state', state) window.location.href = `https://open.weixin.qq.com/connect/qrconnect?appid=${WECHAT_APP_ID}&redirect_uri=${redirectUri}&response_type=code&scope=snsapi_login&state=${state}` }