Add WeChat in-app JSAPI recharge for g2.tkmind.cn.
Use JSAPI with bound openid inside WeChat instead of QR long-press, and include related auth redirect and admin UX fixes. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import { Navigate } from 'react-router-dom';
|
||||
import { useEffect } from 'react';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
import type { PortalUser } from '../types';
|
||||
|
||||
export function RequireAdmin({
|
||||
@@ -8,8 +9,15 @@ export function RequireAdmin({
|
||||
user: PortalUser | null;
|
||||
children: React.ReactNode;
|
||||
}) {
|
||||
if (user?.role !== 'admin') {
|
||||
return <Navigate to="/" replace />;
|
||||
}
|
||||
const navigate = useNavigate();
|
||||
const allowed = user?.role === 'admin';
|
||||
|
||||
useEffect(() => {
|
||||
if (!allowed) {
|
||||
navigate('/', { replace: true });
|
||||
}
|
||||
}, [allowed, navigate]);
|
||||
|
||||
if (!allowed) return null;
|
||||
return children;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user