forked from wangziqi/gongxue-base
fix: guard admin h5 entry pages
This commit is contained in:
@@ -211,6 +211,65 @@
|
||||
background: var(--tiku-primary-soft);
|
||||
}
|
||||
|
||||
.admin-module-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
gap: 16px;
|
||||
}
|
||||
|
||||
.admin-module-card {
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
min-height: 170px;
|
||||
padding: 22px;
|
||||
border: 0;
|
||||
border-radius: 28px;
|
||||
background: linear-gradient(135deg, #1152d4, #38bdf8);
|
||||
box-shadow: 0 12px 24px rgba(17, 82, 212, 0.14);
|
||||
}
|
||||
|
||||
.admin-module-card::after {
|
||||
content: "";
|
||||
position: absolute;
|
||||
right: -28px;
|
||||
bottom: -44px;
|
||||
width: 130px;
|
||||
height: 130px;
|
||||
border-radius: 999px;
|
||||
background: rgba(255, 255, 255, 0.16);
|
||||
}
|
||||
|
||||
.admin-module-card.module-students { background: linear-gradient(135deg, #10b981, #2dd4bf); }
|
||||
.admin-module-card.module-content { background: linear-gradient(135deg, #7c3aed, #a78bfa); }
|
||||
.admin-module-card.module-marketing { background: linear-gradient(135deg, #f97316, #fbbf24); }
|
||||
.admin-module-card.module-commerce { background: linear-gradient(135deg, #ec4899, #f472b6); }
|
||||
.admin-module-card.module-settings { background: linear-gradient(135deg, #334155, #64748b); }
|
||||
|
||||
.admin-module-card .admin-row-main,
|
||||
.admin-module-card .admin-row-meta,
|
||||
.admin-module-label {
|
||||
position: relative;
|
||||
z-index: 1;
|
||||
}
|
||||
|
||||
.admin-module-card .admin-row-main {
|
||||
margin-top: 30px;
|
||||
color: #fff;
|
||||
font-size: 30px;
|
||||
font-weight: 950;
|
||||
}
|
||||
|
||||
.admin-module-card .admin-row-meta {
|
||||
color: rgba(255, 255, 255, 0.82);
|
||||
}
|
||||
|
||||
.admin-module-label {
|
||||
display: block;
|
||||
color: rgba(255, 255, 255, 0.82);
|
||||
font-size: 20px;
|
||||
font-weight: 850;
|
||||
}
|
||||
|
||||
.admin-row-main {
|
||||
display: block;
|
||||
color: var(--tiku-text);
|
||||
|
||||
@@ -10,7 +10,7 @@ import {
|
||||
type TenantOverview,
|
||||
type TenantPermissionsPayload,
|
||||
} from '@/services/tenantAdmin';
|
||||
import { requireSignedIn } from '@/services/routeGuard';
|
||||
import { requireTenantAdmin } from '@/services/routeGuard';
|
||||
import '../admin.css';
|
||||
|
||||
interface AdminModule {
|
||||
@@ -72,11 +72,13 @@ export default function TenantWorkbenchPage() {
|
||||
const [dashboard, setDashboard] = useState<TenantDashboard | null>(null);
|
||||
const [overview, setOverview] = useState<TenantOverview | null>(null);
|
||||
const [permissions, setPermissions] = useState<TenantPermissionsPayload>({});
|
||||
const [authorized, setAuthorized] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
requireSignedIn('/pages/tenant-admin/workbench/index')
|
||||
requireTenantAdmin('/pages/tenant-admin/workbench/index')
|
||||
.then(payload => {
|
||||
if (!payload) return;
|
||||
setAuthorized(true);
|
||||
loadTenantDashboard('30d').then(next => setDashboard(next.item || null)).catch(() => setDashboard(null));
|
||||
loadTenantOverview().then(next => setOverview(next.item || null)).catch(() => setOverview(null));
|
||||
loadTenantPermissions().then(next => setPermissions(next)).catch(() => setPermissions({}));
|
||||
@@ -88,6 +90,20 @@ export default function TenantWorkbenchPage() {
|
||||
const payment = dashboard?.paymentStats || {};
|
||||
const modules = MODULES.filter(item => canOpenModule(permissions, item));
|
||||
|
||||
if (!authorized) {
|
||||
return (
|
||||
<View className='admin-page'>
|
||||
<View className='admin-shell'>
|
||||
<View className='admin-header'>
|
||||
<Text className='admin-kicker'>Tenant Admin</Text>
|
||||
<Text className='admin-title'>正在校验后台权限</Text>
|
||||
<Text className='admin-subtitle'>请先完成登录,系统会确认当前账号是否拥有租户后台权限。</Text>
|
||||
</View>
|
||||
</View>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<View className='admin-page'>
|
||||
<View className='admin-shell'>
|
||||
@@ -118,9 +134,10 @@ export default function TenantWorkbenchPage() {
|
||||
|
||||
<View className='admin-section'>
|
||||
<Text className='admin-section-title'>后台模块</Text>
|
||||
<View className='admin-list'>
|
||||
<View className='admin-module-grid'>
|
||||
{modules.map(item => (
|
||||
<View className='admin-row' key={item.path} onClick={() => Taro.navigateTo({ url: item.path })}>
|
||||
<View className={`admin-module-card module-${item.key}`} key={item.path} onClick={() => Taro.navigateTo({ url: item.path })}>
|
||||
<Text className='admin-module-label'>Module</Text>
|
||||
<Text className='admin-row-main'>{item.name}</Text>
|
||||
<Text className='admin-row-meta'>{item.meta}</Text>
|
||||
</View>
|
||||
|
||||
Reference in New Issue
Block a user