update pay ui
This commit is contained in:
4
app.py
4
app.py
@@ -4180,7 +4180,9 @@ def wechat_callback():
|
|||||||
'debug_user_id': user.id,
|
'debug_user_id': user.id,
|
||||||
'debug_nickname': user_info.get('nickname', '')[:10],
|
'debug_nickname': user_info.get('nickname', '')[:10],
|
||||||
})
|
})
|
||||||
return redirect(f"{frontend_redirect}?{debug_params}")
|
# ⚡ 修复:正确处理已有查询参数的 URL
|
||||||
|
separator = '&' if '?' in frontend_redirect else '?'
|
||||||
|
return redirect(f"{frontend_redirect}{separator}{debug_params}")
|
||||||
|
|
||||||
# PC 扫码模式:更新状态供前端轮询
|
# PC 扫码模式:更新状态供前端轮询
|
||||||
if not mode:
|
if not mode:
|
||||||
|
|||||||
@@ -407,8 +407,10 @@ export default function AuthFormContent() {
|
|||||||
authEvents.trackWechatLoginInitiated('icon_button');
|
authEvents.trackWechatLoginInitiated('icon_button');
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// 1. 构建回调URL
|
// 1. 构建回调URL,携带当前页面路径以便登录后返回
|
||||||
const redirectUrl = `${window.location.origin}/home/wechat-callback`;
|
const currentPath = window.location.pathname + window.location.search;
|
||||||
|
const returnUrl = encodeURIComponent(currentPath);
|
||||||
|
const redirectUrl = `${window.location.origin}/home/wechat-callback?returnUrl=${returnUrl}`;
|
||||||
|
|
||||||
// 2. 显示提示
|
// 2. 显示提示
|
||||||
toast({
|
toast({
|
||||||
|
|||||||
@@ -38,11 +38,21 @@ export default function WechatCallback() {
|
|||||||
const code = searchParams.get("code");
|
const code = searchParams.get("code");
|
||||||
const state = searchParams.get("state");
|
const state = searchParams.get("state");
|
||||||
const wechatLogin = searchParams.get("wechat_login");
|
const wechatLogin = searchParams.get("wechat_login");
|
||||||
|
// ⚡ 获取登录前的页面路径(用于登录后跳转回原页面)
|
||||||
|
const returnUrl = searchParams.get("returnUrl");
|
||||||
|
const targetUrl = returnUrl ? decodeURIComponent(returnUrl) : "/home";
|
||||||
|
|
||||||
|
logger.info('WechatCallback', '解析回调参数', {
|
||||||
|
wechatLogin,
|
||||||
|
returnUrl,
|
||||||
|
targetUrl,
|
||||||
|
state
|
||||||
|
});
|
||||||
|
|
||||||
// 2. 检查是否是 H5 模式登录成功回调
|
// 2. 检查是否是 H5 模式登录成功回调
|
||||||
// 后端已经完成登录,只需要刷新前端 session 状态
|
// 后端已经完成登录,只需要刷新前端 session 状态
|
||||||
if (wechatLogin === "success") {
|
if (wechatLogin === "success") {
|
||||||
logger.info('WechatCallback', 'H5 模式登录成功', { state });
|
logger.info('WechatCallback', 'H5 模式登录成功', { state, targetUrl });
|
||||||
|
|
||||||
// 刷新 session 状态
|
// 刷新 session 状态
|
||||||
await checkSession();
|
await checkSession();
|
||||||
@@ -51,9 +61,9 @@ export default function WechatCallback() {
|
|||||||
setStatus("success");
|
setStatus("success");
|
||||||
setMessage("登录成功!正在跳转...");
|
setMessage("登录成功!正在跳转...");
|
||||||
|
|
||||||
// 延迟跳转到首页
|
// ⚡ 延迟跳转到原页面(而不是固定 /home)
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
navigate("/home", { replace: true });
|
navigate(targetUrl, { replace: true });
|
||||||
}, 1000);
|
}, 1000);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -85,15 +95,16 @@ export default function WechatCallback() {
|
|||||||
setStatus("success");
|
setStatus("success");
|
||||||
setMessage("登录成功!正在跳转...");
|
setMessage("登录成功!正在跳转...");
|
||||||
|
|
||||||
// 8. 延迟跳转到首页
|
// 8. ⚡ 延迟跳转到原页面(而不是固定 /home)
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
navigate("/home", { replace: true });
|
navigate(targetUrl, { replace: true });
|
||||||
}, 1500);
|
}, 1500);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
logger.error('WechatCallback', 'handleCallback', error, {
|
logger.error('WechatCallback', 'handleCallback', error, {
|
||||||
code: searchParams.get("code"),
|
code: searchParams.get("code"),
|
||||||
state: searchParams.get("state"),
|
state: searchParams.get("state"),
|
||||||
wechat_login: searchParams.get("wechat_login"),
|
wechat_login: searchParams.get("wechat_login"),
|
||||||
|
returnUrl: searchParams.get("returnUrl"),
|
||||||
errorMessage: error.message
|
errorMessage: error.message
|
||||||
});
|
});
|
||||||
setStatus("error");
|
setStatus("error");
|
||||||
|
|||||||
Reference in New Issue
Block a user