forked from wangziqi/gongxue-base
fix: align Taro H5 with legacy question bank UI
This commit is contained in:
@@ -1,36 +1,56 @@
|
||||
declare const process: {
|
||||
env: Record<string, string | undefined>;
|
||||
};
|
||||
|
||||
const allPageRoutes = [
|
||||
'pages/bootstrap/index',
|
||||
'pages/student/login/index',
|
||||
'pages/student/home/index',
|
||||
'pages/student/region/index',
|
||||
'pages/student/catalog/index',
|
||||
'pages/student/practice/index',
|
||||
'pages/student/review/index',
|
||||
'pages/student/reports/index',
|
||||
'pages/student/video/index',
|
||||
'pages/student/checkout/index',
|
||||
'pages/student/order-detail/index',
|
||||
'pages/student/vocabulary/index',
|
||||
'pages/student/handbook/index',
|
||||
'pages/student/scoreline/index',
|
||||
'pages/student/ai-school/index',
|
||||
'pages/student/assets/index',
|
||||
'pages/student/notifications/index',
|
||||
'pages/student/profile/index',
|
||||
'pages/tenant-admin/workbench/index',
|
||||
'pages/tenant-admin/dashboard/index',
|
||||
'pages/tenant-admin/students/index',
|
||||
'pages/tenant-admin/content/index',
|
||||
'pages/tenant-admin/marketing/index',
|
||||
'pages/tenant-admin/finance/index',
|
||||
'pages/tenant-admin/settings/index',
|
||||
'pages/platform-admin/workbench/index',
|
||||
'pages/platform-admin/tenants/index',
|
||||
'pages/platform-admin/billing/index',
|
||||
'pages/platform-admin/question-banks/index',
|
||||
'pages/platform-admin/staff/index',
|
||||
];
|
||||
|
||||
const portalLandingRoutes: Record<string, string> = {
|
||||
student: 'pages/student/home/index',
|
||||
'tenant-admin': 'pages/tenant-admin/workbench/index',
|
||||
'platform-admin': 'pages/platform-admin/workbench/index',
|
||||
};
|
||||
|
||||
function pagesForPortal(portal: string | undefined) {
|
||||
const landingRoute = portalLandingRoutes[portal || 'student'] || portalLandingRoutes.student;
|
||||
return [
|
||||
landingRoute,
|
||||
...allPageRoutes.filter(route => route !== landingRoute),
|
||||
];
|
||||
}
|
||||
|
||||
export default defineAppConfig({
|
||||
pages: [
|
||||
'pages/bootstrap/index',
|
||||
'pages/student/login/index',
|
||||
'pages/student/home/index',
|
||||
'pages/student/region/index',
|
||||
'pages/student/catalog/index',
|
||||
'pages/student/practice/index',
|
||||
'pages/student/review/index',
|
||||
'pages/student/reports/index',
|
||||
'pages/student/video/index',
|
||||
'pages/student/checkout/index',
|
||||
'pages/student/order-detail/index',
|
||||
'pages/student/vocabulary/index',
|
||||
'pages/student/handbook/index',
|
||||
'pages/student/scoreline/index',
|
||||
'pages/student/ai-school/index',
|
||||
'pages/student/assets/index',
|
||||
'pages/student/notifications/index',
|
||||
'pages/student/profile/index',
|
||||
'pages/tenant-admin/workbench/index',
|
||||
'pages/tenant-admin/dashboard/index',
|
||||
'pages/tenant-admin/students/index',
|
||||
'pages/tenant-admin/content/index',
|
||||
'pages/tenant-admin/marketing/index',
|
||||
'pages/tenant-admin/finance/index',
|
||||
'pages/tenant-admin/settings/index',
|
||||
'pages/platform-admin/workbench/index',
|
||||
'pages/platform-admin/tenants/index',
|
||||
'pages/platform-admin/billing/index',
|
||||
'pages/platform-admin/question-banks/index',
|
||||
'pages/platform-admin/staff/index',
|
||||
],
|
||||
pages: pagesForPortal(process.env.TARO_APP_PORTAL),
|
||||
window: {
|
||||
backgroundTextStyle: 'light',
|
||||
navigationBarBackgroundColor: '#0f172a',
|
||||
|
||||
@@ -89,11 +89,20 @@ textarea {
|
||||
}
|
||||
|
||||
.route-guard-page {
|
||||
position: fixed;
|
||||
inset: 0;
|
||||
z-index: 9999;
|
||||
min-height: 100vh;
|
||||
padding: 28px;
|
||||
background: var(--tiku-page);
|
||||
}
|
||||
|
||||
.route-guard-hidden {
|
||||
height: 100vh;
|
||||
overflow: hidden;
|
||||
visibility: hidden;
|
||||
}
|
||||
|
||||
.route-guard-shell {
|
||||
width: 100%;
|
||||
max-width: 760px;
|
||||
|
||||
@@ -60,6 +60,38 @@ function shouldUseAdminShell(path: string) {
|
||||
return false;
|
||||
}
|
||||
|
||||
function RouteGuardOverlay() {
|
||||
const copy = appEnv.portal === 'tenant-admin'
|
||||
? {
|
||||
kicker: 'Tenant Admin',
|
||||
title: '正在校验后台权限',
|
||||
subtitle: '请先完成登录,系统会确认当前账号是否拥有租户后台权限。',
|
||||
}
|
||||
: appEnv.portal === 'platform-admin'
|
||||
? {
|
||||
kicker: 'Platform Admin',
|
||||
title: '正在校验平台权限',
|
||||
subtitle: '请先完成登录,系统会确认当前账号是否拥有平台管理员权限。',
|
||||
}
|
||||
: {
|
||||
kicker: 'Student',
|
||||
title: '正在校验登录状态',
|
||||
subtitle: '请先完成登录,系统会带你回到刚才打开的页面。',
|
||||
};
|
||||
|
||||
return (
|
||||
<View className='route-guard-page'>
|
||||
<View className='route-guard-shell'>
|
||||
<View className='route-guard-panel'>
|
||||
<Text className='route-guard-kicker'>{copy.kicker}</Text>
|
||||
<Text className='route-guard-title'>{copy.title}</Text>
|
||||
<Text className='route-guard-subtitle'>{copy.subtitle}</Text>
|
||||
</View>
|
||||
</View>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
export default function App({ children }: PropsWithChildren) {
|
||||
const [routeReady, setRouteReady] = useState(false);
|
||||
const [path, setPath] = useState(() => currentPagePath());
|
||||
@@ -80,55 +112,18 @@ export default function App({ children }: PropsWithChildren) {
|
||||
return installH5RouteListener(verifyCurrentRoute);
|
||||
}, []);
|
||||
|
||||
if (!routeReady && appEnv.portal === 'tenant-admin') {
|
||||
return (
|
||||
<View className='route-guard-page'>
|
||||
<View className='route-guard-shell'>
|
||||
<View className='route-guard-panel'>
|
||||
<Text className='route-guard-kicker'>Tenant Admin</Text>
|
||||
<Text className='route-guard-title'>正在校验后台权限</Text>
|
||||
<Text className='route-guard-subtitle'>请先完成登录,系统会确认当前账号是否拥有租户后台权限。</Text>
|
||||
</View>
|
||||
</View>
|
||||
const content = shouldUseStudentShell(path)
|
||||
? <StudentLegacyShell>{children}</StudentLegacyShell>
|
||||
: shouldUseAdminShell(path)
|
||||
? <AdminLegacyShell>{children}</AdminLegacyShell>
|
||||
: children;
|
||||
|
||||
return (
|
||||
<>
|
||||
<View className={routeReady ? '' : 'route-guard-hidden'}>
|
||||
{content}
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
if (!routeReady && appEnv.portal === 'platform-admin') {
|
||||
return (
|
||||
<View className='route-guard-page'>
|
||||
<View className='route-guard-shell'>
|
||||
<View className='route-guard-panel'>
|
||||
<Text className='route-guard-kicker'>Platform Admin</Text>
|
||||
<Text className='route-guard-title'>正在校验平台权限</Text>
|
||||
<Text className='route-guard-subtitle'>请先完成登录,系统会确认当前账号是否拥有平台管理员权限。</Text>
|
||||
</View>
|
||||
</View>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
if (!routeReady) {
|
||||
return (
|
||||
<View className='route-guard-page'>
|
||||
<View className='route-guard-shell'>
|
||||
<View className='route-guard-panel'>
|
||||
<Text className='route-guard-kicker'>Student</Text>
|
||||
<Text className='route-guard-title'>正在校验登录状态</Text>
|
||||
<Text className='route-guard-subtitle'>请先完成登录,系统会带你回到刚才打开的页面。</Text>
|
||||
</View>
|
||||
</View>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
if (shouldUseStudentShell(path)) {
|
||||
return <StudentLegacyShell>{children}</StudentLegacyShell>;
|
||||
}
|
||||
|
||||
if (shouldUseAdminShell(path)) {
|
||||
return <AdminLegacyShell>{children}</AdminLegacyShell>;
|
||||
}
|
||||
|
||||
return children;
|
||||
{!routeReady ? <RouteGuardOverlay /> : null}
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -476,3 +476,216 @@
|
||||
padding: 14px;
|
||||
}
|
||||
}
|
||||
|
||||
/* Legacy backoffice refinement: table-first workspace, tight nav, quiet chrome. */
|
||||
.backoffice-legacy-layout {
|
||||
--backoffice-line: #eef2f7;
|
||||
--backoffice-muted: #6b7280;
|
||||
}
|
||||
|
||||
.backoffice-mobile-nav,
|
||||
.backoffice-legacy-sidebar,
|
||||
.backoffice-legacy-main {
|
||||
scrollbar-color: #cbd5e1 transparent;
|
||||
scrollbar-width: thin;
|
||||
}
|
||||
|
||||
.backoffice-mobile-nav::-webkit-scrollbar,
|
||||
.backoffice-nav::-webkit-scrollbar,
|
||||
.backoffice-legacy-main::-webkit-scrollbar {
|
||||
width: 6px;
|
||||
height: 6px;
|
||||
}
|
||||
|
||||
.backoffice-mobile-nav::-webkit-scrollbar-thumb,
|
||||
.backoffice-nav::-webkit-scrollbar-thumb,
|
||||
.backoffice-legacy-main::-webkit-scrollbar-thumb {
|
||||
border-radius: 999px;
|
||||
background: #cbd5e1;
|
||||
}
|
||||
|
||||
.backoffice-legacy-main .admin-header,
|
||||
.backoffice-legacy-main .platform-header {
|
||||
display: grid;
|
||||
gap: 5px;
|
||||
padding: 18px 20px;
|
||||
}
|
||||
|
||||
.backoffice-legacy-main .admin-kicker,
|
||||
.backoffice-legacy-main .platform-kicker {
|
||||
font-size: 12px;
|
||||
font-weight: 950;
|
||||
text-transform: uppercase;
|
||||
}
|
||||
|
||||
.backoffice-legacy-main .admin-title,
|
||||
.backoffice-legacy-main .platform-title {
|
||||
font-size: 26px;
|
||||
line-height: 1.15;
|
||||
}
|
||||
|
||||
.backoffice-legacy-main .admin-subtitle,
|
||||
.backoffice-legacy-main .platform-subtitle {
|
||||
max-width: 760px;
|
||||
font-size: 14px;
|
||||
line-height: 1.45;
|
||||
}
|
||||
|
||||
.backoffice-legacy-main .admin-section-title,
|
||||
.backoffice-legacy-main .platform-section-title {
|
||||
font-size: 18px;
|
||||
}
|
||||
|
||||
.backoffice-legacy-main .admin-section-title::before,
|
||||
.backoffice-legacy-main .platform-section-title::before {
|
||||
width: 4px;
|
||||
height: 16px;
|
||||
}
|
||||
|
||||
.backoffice-legacy-main .admin-grid,
|
||||
.backoffice-legacy-main .platform-grid {
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.backoffice-legacy-main .admin-row,
|
||||
.backoffice-legacy-main .platform-row {
|
||||
padding: 12px 14px 12px 18px;
|
||||
border-radius: 12px;
|
||||
}
|
||||
|
||||
.backoffice-legacy-main .admin-row-main,
|
||||
.backoffice-legacy-main .platform-row-main {
|
||||
font-size: 15px;
|
||||
line-height: 1.3;
|
||||
}
|
||||
|
||||
.backoffice-legacy-main .admin-row-meta,
|
||||
.backoffice-legacy-main .platform-row-meta {
|
||||
font-size: 12px;
|
||||
line-height: 1.45;
|
||||
}
|
||||
|
||||
.backoffice-legacy-main .admin-metric,
|
||||
.backoffice-legacy-main .platform-metric {
|
||||
min-height: 78px;
|
||||
padding: 12px 14px;
|
||||
border-radius: 12px;
|
||||
}
|
||||
|
||||
.backoffice-legacy-main .admin-metric-label,
|
||||
.backoffice-legacy-main .platform-metric-label {
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.backoffice-legacy-main .admin-metric-value,
|
||||
.backoffice-legacy-main .platform-metric-value {
|
||||
margin-top: 5px;
|
||||
font-size: 21px;
|
||||
}
|
||||
|
||||
.backoffice-legacy-main .admin-input,
|
||||
.backoffice-legacy-main .platform-input {
|
||||
height: 38px;
|
||||
border-radius: 9px;
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.backoffice-legacy-main .admin-textarea {
|
||||
min-height: 118px;
|
||||
border-radius: 10px;
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.backoffice-legacy-main .admin-button,
|
||||
.backoffice-legacy-main .platform-button {
|
||||
height: 38px;
|
||||
min-width: 86px;
|
||||
border-radius: 9px;
|
||||
font-size: 13px;
|
||||
line-height: 38px;
|
||||
}
|
||||
|
||||
.backoffice-legacy-main .admin-mini-button,
|
||||
.backoffice-legacy-main .platform-mini-button {
|
||||
height: 32px;
|
||||
min-width: 74px;
|
||||
border-radius: 8px;
|
||||
font-size: 12px;
|
||||
line-height: 32px;
|
||||
}
|
||||
|
||||
@media (min-width: 980px) {
|
||||
.backoffice-legacy-layout {
|
||||
grid-template-columns: 236px minmax(0, 1fr);
|
||||
gap: 12px;
|
||||
padding: 12px;
|
||||
}
|
||||
|
||||
.backoffice-legacy-sidebar {
|
||||
top: 12px;
|
||||
height: calc(100vh - 24px);
|
||||
padding: 12px;
|
||||
border-radius: 18px;
|
||||
}
|
||||
|
||||
.backoffice-brand {
|
||||
padding: 10px 8px 14px;
|
||||
}
|
||||
|
||||
.backoffice-brand-icon {
|
||||
flex-basis: 38px;
|
||||
width: 38px;
|
||||
height: 38px;
|
||||
border-radius: 10px;
|
||||
}
|
||||
|
||||
.backoffice-brand-title {
|
||||
font-size: 17px;
|
||||
}
|
||||
|
||||
.backoffice-brand-sub {
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.backoffice-select-box {
|
||||
min-height: 36px;
|
||||
border-radius: 10px;
|
||||
}
|
||||
|
||||
.backoffice-select-text {
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.backoffice-nav-btn {
|
||||
min-height: 40px;
|
||||
padding: 0 11px;
|
||||
border-radius: 10px;
|
||||
}
|
||||
|
||||
.backoffice-nav-mark {
|
||||
width: 22px;
|
||||
height: 22px;
|
||||
border-radius: 7px;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.backoffice-nav-text {
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.backoffice-nav-group {
|
||||
margin-top: 8px;
|
||||
font-size: 10px;
|
||||
}
|
||||
|
||||
.backoffice-legacy-main {
|
||||
max-height: calc(100vh - 24px);
|
||||
overflow: auto;
|
||||
border-radius: 18px;
|
||||
}
|
||||
|
||||
.backoffice-legacy-main .admin-page,
|
||||
.backoffice-legacy-main .platform-page {
|
||||
padding: 18px;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,39 +15,28 @@
|
||||
(function () {
|
||||
var path = window.location.pathname || '';
|
||||
var portal = '<%= process.env.TARO_APP_PORTAL || "student" %>';
|
||||
var redirect = path + (window.location.search || '');
|
||||
var isRootEntry = !path || path === '/' || /\/index\.html$/.test(path);
|
||||
var publicStudentPaths = {
|
||||
'/pages/student/login/index': true,
|
||||
'/pages/student/region/index': true
|
||||
};
|
||||
var landing = portal === 'tenant-admin'
|
||||
? '/pages/tenant-admin/workbench/index'
|
||||
: portal === 'platform-admin'
|
||||
? '/pages/platform-admin/workbench/index'
|
||||
: '/pages/student/home/index';
|
||||
if (isRootEntry) {
|
||||
window.location.replace('/pages/bootstrap/index?redirect=' + encodeURIComponent('/'));
|
||||
window.location.replace(landing);
|
||||
return;
|
||||
}
|
||||
if (portal === 'student' && path.indexOf('/pages/') === 0 && path.indexOf('/pages/student/') !== 0 && path.indexOf('/pages/bootstrap/') !== 0) {
|
||||
window.location.replace('/pages/bootstrap/index?redirect=' + encodeURIComponent('/pages/student/home/index'));
|
||||
window.location.replace(landing);
|
||||
return;
|
||||
}
|
||||
if (portal === 'tenant-admin' && path.indexOf('/pages/') === 0 && path.indexOf('/pages/tenant-admin/') !== 0 && path.indexOf('/pages/bootstrap/') !== 0 && path.indexOf('/pages/student/login/') !== 0) {
|
||||
window.location.replace('/pages/bootstrap/index?redirect=' + encodeURIComponent('/pages/tenant-admin/workbench/index'));
|
||||
window.location.replace(landing);
|
||||
return;
|
||||
}
|
||||
if (portal === 'platform-admin' && path.indexOf('/pages/') === 0 && path.indexOf('/pages/platform-admin/') !== 0 && path.indexOf('/pages/bootstrap/') !== 0 && path.indexOf('/pages/student/login/') !== 0) {
|
||||
window.location.replace('/pages/bootstrap/index?redirect=' + encodeURIComponent('/pages/platform-admin/workbench/index'));
|
||||
window.location.replace(landing);
|
||||
return;
|
||||
}
|
||||
if (path.indexOf('/pages/student/') === 0 && !publicStudentPaths[path]) {
|
||||
window.location.replace('/pages/bootstrap/index?redirect=' + encodeURIComponent(redirect));
|
||||
return;
|
||||
}
|
||||
if (portal === 'tenant-admin' && path.indexOf('/pages/tenant-admin/') === 0) {
|
||||
window.location.replace('/pages/bootstrap/index?redirect=' + encodeURIComponent(redirect));
|
||||
return;
|
||||
}
|
||||
if (portal === 'platform-admin' && path.indexOf('/pages/platform-admin/') === 0) {
|
||||
window.location.replace('/pages/bootstrap/index?redirect=' + encodeURIComponent(redirect));
|
||||
}
|
||||
}());
|
||||
</script>
|
||||
<script><%= htmlWebpackPlugin.options.script %></script>
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import { useEffect, useState } from 'react';
|
||||
import Taro, { useRouter } from '@tarojs/taro';
|
||||
import Taro from '@tarojs/taro';
|
||||
import { Button, Text, View } from '@tarojs/components';
|
||||
import { appEnv, assertFrontendSecretsAreAbsent, ensureRuntimeConfigLoaded, isH5Runtime } from '@/env';
|
||||
import { resolveTenant } from '@/services/api';
|
||||
import { landingPath, requirePlatformAdmin, requireSignedIn, requireTenantAdmin, safeRedirectPath } from '@/services/routeGuard';
|
||||
import { currentRouteParams, landingPath, requirePlatformAdmin, requireSignedIn, requireTenantAdmin, safeRedirectPath } from '@/services/routeGuard';
|
||||
import './index.css';
|
||||
|
||||
function hostFromRuntime() {
|
||||
@@ -12,12 +12,12 @@ function hostFromRuntime() {
|
||||
}
|
||||
|
||||
export default function BootstrapPage() {
|
||||
const router = useRouter();
|
||||
const [status, setStatus] = useState('正在解析租户');
|
||||
const [error, setError] = useState('');
|
||||
|
||||
useEffect(() => {
|
||||
const redirectPath = safeRedirectPath(router.params?.redirect ? decodeURIComponent(router.params.redirect) : landingPath());
|
||||
const params = currentRouteParams();
|
||||
const redirectPath = safeRedirectPath(params.redirect ? decodeURIComponent(String(params.redirect)) : landingPath());
|
||||
assertFrontendSecretsAreAbsent();
|
||||
ensureRuntimeConfigLoaded()
|
||||
.then(() => resolveTenant({ host: hostFromRuntime() }))
|
||||
@@ -30,6 +30,10 @@ export default function BootstrapPage() {
|
||||
.then(authPayload => {
|
||||
if (!authPayload) return;
|
||||
setStatus('租户解析完成');
|
||||
if (isH5Runtime() && typeof window !== 'undefined') {
|
||||
window.location.replace(redirectPath);
|
||||
return;
|
||||
}
|
||||
Taro.redirectTo({ url: redirectPath });
|
||||
})
|
||||
.catch((nextError: Error) => {
|
||||
|
||||
@@ -924,3 +924,166 @@
|
||||
padding: 16px;
|
||||
}
|
||||
}
|
||||
|
||||
/* Legacy platform admin deep pages: billing, tenant detail, grants, staff. */
|
||||
.platform-page {
|
||||
--platform-table-line: #eef2f7;
|
||||
}
|
||||
|
||||
.platform-section {
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.platform-section + .platform-section {
|
||||
margin-top: 0;
|
||||
}
|
||||
|
||||
.platform-form {
|
||||
align-items: end;
|
||||
border-color: #eef2f7;
|
||||
background:
|
||||
linear-gradient(to right, rgba(15, 23, 42, 0.018) 1px, transparent 1px),
|
||||
#fbfdff;
|
||||
background-size: 32px 32px;
|
||||
}
|
||||
|
||||
.platform-form.compact + .platform-actions,
|
||||
.platform-actions + .platform-form.compact,
|
||||
.platform-actions + .platform-list,
|
||||
.platform-grid + .platform-section {
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
.platform-actions {
|
||||
flex-wrap: wrap;
|
||||
overflow-x: visible;
|
||||
padding-bottom: 0;
|
||||
}
|
||||
|
||||
.platform-actions .platform-input {
|
||||
height: 38px;
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.platform-section > .platform-actions:first-child .platform-section-title {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
.platform-list {
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.platform-row {
|
||||
border-left: 0;
|
||||
}
|
||||
|
||||
.platform-row:hover {
|
||||
border-color: #dbeafe;
|
||||
background: #fbfdff;
|
||||
}
|
||||
|
||||
.platform-row-actions {
|
||||
margin-top: 10px;
|
||||
padding-top: 9px;
|
||||
}
|
||||
|
||||
.platform-row-actions .platform-input {
|
||||
max-width: 280px;
|
||||
}
|
||||
|
||||
.platform-empty {
|
||||
margin-top: 8px;
|
||||
padding: 16px;
|
||||
border-style: dashed;
|
||||
background: #fbfdff;
|
||||
}
|
||||
|
||||
.platform-error {
|
||||
padding: 10px 12px;
|
||||
border-radius: 10px;
|
||||
background: #fff1f2;
|
||||
}
|
||||
|
||||
.platform-chip,
|
||||
.platform-chip.readonly {
|
||||
min-height: 28px;
|
||||
border-radius: 7px;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.platform-chip.active,
|
||||
.platform-button.active,
|
||||
.platform-mini-button.active {
|
||||
border-color: #1e293b;
|
||||
background: #1e293b;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.platform-permission-panel {
|
||||
border-color: #eef2f7;
|
||||
border-radius: 12px;
|
||||
}
|
||||
|
||||
.platform-permission-header {
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.platform-permission-group {
|
||||
padding: 8px;
|
||||
border: 1px solid #eef2f7;
|
||||
border-radius: 10px;
|
||||
background: #fff;
|
||||
}
|
||||
|
||||
.platform-chip-list.compact,
|
||||
.platform-row .platform-chip-list.compact {
|
||||
gap: 6px;
|
||||
}
|
||||
|
||||
.platform-section .platform-section {
|
||||
border-color: #e5e7eb;
|
||||
border-radius: 12px;
|
||||
}
|
||||
|
||||
.platform-section .platform-section + .platform-section {
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
.platform-section .platform-section .platform-list {
|
||||
gap: 6px;
|
||||
}
|
||||
|
||||
.platform-section .platform-section .platform-row {
|
||||
padding: 10px 12px 10px 16px;
|
||||
box-shadow: none;
|
||||
}
|
||||
|
||||
.platform-metric {
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
@media (min-width: 980px) {
|
||||
.platform-section {
|
||||
padding: 16px;
|
||||
}
|
||||
|
||||
.platform-form {
|
||||
gap: 8px;
|
||||
padding: 10px;
|
||||
}
|
||||
|
||||
.platform-module-grid {
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.platform-module-card {
|
||||
min-height: 112px;
|
||||
padding: 16px;
|
||||
border-radius: 14px;
|
||||
}
|
||||
|
||||
.platform-module-card .platform-row-main {
|
||||
margin-top: 16px;
|
||||
font-size: 20px;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -172,7 +172,7 @@ export default function PlatformWorkbenchPage() {
|
||||
<Text className='platform-section-title'>后台模块</Text>
|
||||
<View className='platform-module-grid'>
|
||||
{modules.map(item => (
|
||||
<View className='platform-module-card' key={item.path} onClick={() => Taro.navigateTo({ url: item.path })}>
|
||||
<View className='platform-module-card' key={item.path} role='button' onClick={() => Taro.navigateTo({ url: item.path })}>
|
||||
<Text className='platform-module-label'>Console</Text>
|
||||
<Text className='platform-row-main'>{item.name}</Text>
|
||||
<Text className='platform-row-meta'>{item.meta}</Text>
|
||||
|
||||
@@ -61,7 +61,7 @@ export default function StudentHomePage() {
|
||||
|
||||
<View className='hero-band'>
|
||||
<View className='hero-content'>
|
||||
<Text className='hero-kicker'>今天也是元气满满的一天</Text>
|
||||
<Text className='hero-kicker'>今日学习</Text>
|
||||
<Text className='hero-title'>继续你的备考之旅</Text>
|
||||
<Text className='hero-copy'>已经连续学习的每一天,都会让你离目标院校更近一步。</Text>
|
||||
<View className='hero-actions'>
|
||||
@@ -113,16 +113,16 @@ export default function StudentHomePage() {
|
||||
</View>
|
||||
|
||||
<View className='section'>
|
||||
<Text className='section-title'>学习入口</Text>
|
||||
<Text className='section-title'>功能导航</Text>
|
||||
<View className='entry-grid'>
|
||||
{entryNames.length ? entryNames.map(item => (
|
||||
<View className='entry-tile tone-blue' key={item.id} onClick={() => Taro.navigateTo({ url: `/pages/student/catalog/index?entryId=${item.id}` })}>
|
||||
<View className='entry-tile tone-blue' role='button' key={item.id} onClick={() => Taro.navigateTo({ url: `/pages/student/catalog/index?entryId=${item.id}` })}>
|
||||
<Text className='entry-label'>已配置入口</Text>
|
||||
<Text className='entry-name'>{item.name}</Text>
|
||||
<Text className='entry-type'>{item.entryType || 'content'}</Text>
|
||||
</View>
|
||||
)) : quickActions.map(item => (
|
||||
<View className={`entry-tile tone-${item.tone}`} key={item.name} onClick={() => Taro.navigateTo({ url: item.path })}>
|
||||
<View className={`entry-tile tone-${item.tone}`} role='button' key={item.name} onClick={() => Taro.navigateTo({ url: item.path })}>
|
||||
<Text className='entry-label'>{item.meta}</Text>
|
||||
<Text className='entry-name'>{item.name}</Text>
|
||||
<Text className='entry-type'>点击进入</Text>
|
||||
@@ -135,7 +135,7 @@ export default function StudentHomePage() {
|
||||
<Text className='section-title'>全部功能</Text>
|
||||
<View className='quick-list'>
|
||||
{quickActions.map(item => (
|
||||
<View className='quick-row' key={item.path} onClick={() => Taro.navigateTo({ url: item.path })}>
|
||||
<View className='quick-row' role='button' key={item.path} onClick={() => Taro.navigateTo({ url: item.path })}>
|
||||
<View>
|
||||
<Text className='quick-name'>{item.name}</Text>
|
||||
<Text className='quick-meta'>{item.meta}</Text>
|
||||
|
||||
@@ -1,15 +1,14 @@
|
||||
import { useEffect, useState } from 'react';
|
||||
import { useRouter } from '@tarojs/taro';
|
||||
import { Button, Input, Text, View } from '@tarojs/components';
|
||||
import { appEnv, ensureRuntimeConfigLoaded, type Portal } from '@/env';
|
||||
import { getTenantContext } from '@/services/api';
|
||||
import { loadCurrentUser, sendSmsCode, verifySmsCode } from '@/services/auth';
|
||||
import { landingPath, redirectAfterLogin } from '@/services/routeGuard';
|
||||
import { currentRouteParams, landingPath, redirectAfterLogin } from '@/services/routeGuard';
|
||||
import '../student.css';
|
||||
|
||||
export default function StudentLoginPage() {
|
||||
const router = useRouter();
|
||||
const tenant = getTenantContext();
|
||||
const params = currentRouteParams();
|
||||
const [portal, setPortal] = useState<Portal>(appEnv.portal);
|
||||
const [runtimeReady, setRuntimeReady] = useState(false);
|
||||
const [phone, setPhone] = useState('');
|
||||
@@ -26,12 +25,12 @@ export default function StudentLoginPage() {
|
||||
.then(() => {
|
||||
setPortal(appEnv.portal);
|
||||
setRuntimeReady(true);
|
||||
if (router.params?.reason) {
|
||||
setReason(decodeURIComponent(router.params.reason));
|
||||
if (params.reason) {
|
||||
setReason(decodeURIComponent(String(params.reason)));
|
||||
return;
|
||||
}
|
||||
loadCurrentUser()
|
||||
.then(() => redirectAfterLogin(router.params?.redirect || landingPath()))
|
||||
.then(() => redirectAfterLogin(params.redirect || landingPath()))
|
||||
.catch(() => undefined);
|
||||
})
|
||||
.catch(() => {
|
||||
@@ -91,7 +90,7 @@ export default function StudentLoginPage() {
|
||||
setError('');
|
||||
try {
|
||||
await verifySmsCode(phone, code || debugCode);
|
||||
redirectAfterLogin(router.params?.redirect || landingPath());
|
||||
redirectAfterLogin(params.redirect || landingPath());
|
||||
} catch (nextError) {
|
||||
setError(nextError instanceof Error ? nextError.message : '登录失败');
|
||||
} finally {
|
||||
|
||||
@@ -1033,3 +1033,202 @@
|
||||
grid-column: span 2;
|
||||
}
|
||||
}
|
||||
|
||||
/* Legacy tenant admin deep pages: compact forms, badges, and operational rows. */
|
||||
.admin-page {
|
||||
--admin-table-line: #eef2f7;
|
||||
}
|
||||
|
||||
.admin-section {
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.admin-section + .admin-section {
|
||||
margin-top: 0;
|
||||
}
|
||||
|
||||
.admin-section > .admin-form-grid:first-child,
|
||||
.admin-section > .admin-actions:first-child,
|
||||
.admin-section > .admin-list:first-child {
|
||||
margin-top: 0;
|
||||
}
|
||||
|
||||
.admin-form-grid {
|
||||
align-items: end;
|
||||
border-color: #eef2f7;
|
||||
background:
|
||||
linear-gradient(to right, rgba(15, 23, 42, 0.018) 1px, transparent 1px),
|
||||
#fbfdff;
|
||||
background-size: 32px 32px;
|
||||
}
|
||||
|
||||
.admin-form-grid .admin-input,
|
||||
.admin-form-grid .admin-textarea {
|
||||
box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7);
|
||||
}
|
||||
|
||||
.admin-form-grid .admin-textarea {
|
||||
grid-column: 1 / -1;
|
||||
}
|
||||
|
||||
.admin-section > .admin-textarea {
|
||||
margin-top: 8px;
|
||||
}
|
||||
|
||||
.admin-actions.compact + .admin-form-grid,
|
||||
.admin-actions.compact + .admin-list,
|
||||
.admin-actions.compact + .admin-grid,
|
||||
.admin-actions.compact + .admin-row {
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
.admin-actions.compact .admin-section-title {
|
||||
flex: 1 1 220px;
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
.admin-actions.compact .admin-input {
|
||||
height: 38px;
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.admin-list {
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.admin-list:not(.compact) > .admin-row + .admin-row {
|
||||
margin-top: 0;
|
||||
}
|
||||
|
||||
.admin-row {
|
||||
border-left: 0;
|
||||
}
|
||||
|
||||
.admin-row:hover {
|
||||
border-color: #dbeafe;
|
||||
background: #fbfdff;
|
||||
}
|
||||
|
||||
.admin-row-actions {
|
||||
margin-top: 10px;
|
||||
padding-top: 9px;
|
||||
}
|
||||
|
||||
.admin-row-actions .admin-input {
|
||||
max-width: 280px;
|
||||
}
|
||||
|
||||
.admin-empty {
|
||||
margin-top: 8px;
|
||||
padding: 16px;
|
||||
border-style: dashed;
|
||||
background: #fbfdff;
|
||||
}
|
||||
|
||||
.admin-error,
|
||||
.success-text {
|
||||
padding: 10px 12px;
|
||||
border-radius: 10px;
|
||||
background: #fff1f2;
|
||||
}
|
||||
|
||||
.admin-sub-list {
|
||||
border: 1px solid #eef2f7;
|
||||
border-radius: 12px;
|
||||
}
|
||||
|
||||
.admin-sub-row {
|
||||
box-shadow: none;
|
||||
}
|
||||
|
||||
.admin-chip,
|
||||
.admin-row .admin-chip {
|
||||
min-height: 28px;
|
||||
border-radius: 7px;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.admin-button.active,
|
||||
.admin-mini-button.active,
|
||||
.admin-chip.active {
|
||||
border-color: #1e293b;
|
||||
background: #1e293b;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.admin-grid.three .admin-metric,
|
||||
.admin-grid .admin-metric {
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.admin-metric.theme-template {
|
||||
min-height: 120px;
|
||||
border-left: 0;
|
||||
border-top-width: 4px;
|
||||
}
|
||||
|
||||
.theme-swatch-row {
|
||||
gap: 7px;
|
||||
}
|
||||
|
||||
.theme-swatch {
|
||||
width: 28px;
|
||||
height: 28px;
|
||||
}
|
||||
|
||||
.theme-preview-panel {
|
||||
border-radius: 14px;
|
||||
}
|
||||
|
||||
.theme-preview-banner {
|
||||
min-height: 84px;
|
||||
}
|
||||
|
||||
.theme-preview-title {
|
||||
font-size: 18px;
|
||||
}
|
||||
|
||||
.theme-preview-subtitle {
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.break-line {
|
||||
display: block;
|
||||
max-height: 180px;
|
||||
overflow: auto;
|
||||
}
|
||||
|
||||
.admin-textarea + .admin-row-meta,
|
||||
.admin-form-grid + .admin-row-meta {
|
||||
margin-top: 8px;
|
||||
}
|
||||
|
||||
@media (min-width: 980px) {
|
||||
.admin-section {
|
||||
padding: 16px;
|
||||
}
|
||||
|
||||
.admin-form-grid {
|
||||
gap: 8px;
|
||||
padding: 10px;
|
||||
}
|
||||
|
||||
.admin-grid.three {
|
||||
grid-template-columns: repeat(3, minmax(0, 1fr));
|
||||
}
|
||||
|
||||
.admin-module-grid {
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.admin-module-card {
|
||||
min-height: 112px;
|
||||
padding: 16px;
|
||||
border-radius: 14px;
|
||||
}
|
||||
|
||||
.admin-module-card .admin-row-main {
|
||||
margin-top: 16px;
|
||||
font-size: 20px;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -136,7 +136,7 @@ export default function TenantWorkbenchPage() {
|
||||
<Text className='admin-section-title'>后台模块</Text>
|
||||
<View className='admin-module-grid'>
|
||||
{modules.map(item => (
|
||||
<View className={`admin-module-card module-${item.key}`} key={item.path} onClick={() => Taro.navigateTo({ url: item.path })}>
|
||||
<View className={`admin-module-card module-${item.key}`} key={item.path} role='button' 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>
|
||||
|
||||
@@ -50,6 +50,15 @@ export function currentPagePath() {
|
||||
return normalizedPath;
|
||||
}
|
||||
|
||||
export function currentRouteParams() {
|
||||
if (isH5Runtime() && typeof window !== 'undefined') {
|
||||
const search = window.location.search || (window.location.hash.includes('?') ? `?${window.location.hash.split('?').slice(1).join('?')}` : '');
|
||||
const params = new URLSearchParams(search);
|
||||
return Object.fromEntries(params.entries());
|
||||
}
|
||||
return Taro.getCurrentInstance().router?.params || {};
|
||||
}
|
||||
|
||||
function isPublicPath(path: string) {
|
||||
return path === '/pages/bootstrap/index' || path === '/pages/student/login/index';
|
||||
}
|
||||
@@ -121,7 +130,7 @@ export async function guardCurrentRoute() {
|
||||
const path = currentPagePath();
|
||||
if (!path || !shouldGuardPath(path)) return true;
|
||||
if (!isPathAllowedForPortal(path)) {
|
||||
redirectToAuthUrl(`/pages/bootstrap/index?redirect=${encodeURIComponent(landingPath())}`);
|
||||
redirectToAuthUrl(landingPath());
|
||||
return false;
|
||||
}
|
||||
if (pendingGuardPath === path) return false;
|
||||
@@ -144,5 +153,10 @@ export async function guardCurrentRoute() {
|
||||
|
||||
export function redirectAfterLogin(rawRedirect?: string) {
|
||||
const redirectPath = rawRedirect ? decodeURIComponent(rawRedirect) : landingPath();
|
||||
Taro.redirectTo({ url: safeRedirectPath(redirectPath) });
|
||||
const url = safeRedirectPath(redirectPath);
|
||||
if (isH5Runtime() && typeof window !== 'undefined') {
|
||||
window.location.replace(url);
|
||||
return;
|
||||
}
|
||||
Taro.redirectTo({ url });
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user