优化账号绑定功能及社交解绑

This commit is contained in:
wangqiao
2025-09-14 10:41:15 +08:00
parent cef6c8c341
commit a0a44b4551
3 changed files with 56 additions and 20 deletions

View File

@ -13,19 +13,17 @@ export const generateRandomString = (length: number) => {
// QQ登录
export const handleLoginQQ = () => {
const appId = QQ_APP_ID // APP ID
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=${appId}&redirect_uri=${redirectUri}&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 appId = WECHAT_APP_ID // APP ID
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=${appId}&redirect_uri=${redirectUri}&response_type=code&scope=snsapi_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}`
}