fix: polish playground routing and bundle splits

This commit is contained in:
linkong
2026-04-09 15:23:10 +08:00
parent c4ea918fac
commit 39f90bd575
10 changed files with 126 additions and 70 deletions

View File

@@ -1 +1 @@
0.24.1
0.24.2

View File

@@ -7,6 +7,26 @@ This project follows the repository versioning rule:
- `feature` -> `+0.1.0`
- `bugfix` -> `+0.0.1`
## 0.24.2
Released: 2026-04-09
### Highlights
- Fixed the public-entry and AI diagnostics regressions introduced during the recent frontend routing and playground work, while also reducing the main frontend bundle by switching to route-level lazy loading and more targeted vendor chunking.
### Improved
- Improved [frontend/src/App.tsx](/home/ray/dev/linkong/planet/frontend/src/App.tsx) by lazy-loading admin pages and large workspaces through `React.lazy()` plus `Suspense`, so the initial frontend entry no longer pulls every route into the first bundle.
- Improved [frontend/vite.config.ts](/home/ray/dev/linkong/planet/frontend/vite.config.ts) by adding targeted manual chunking for React, icon, network, and Earth-related vendor dependencies instead of leaving everything in one monolithic application bundle.
- Improved [frontend/src/index.css](/home/ray/dev/linkong/planet/frontend/src/index.css) by adding a shared route-loading state and making the Playground help panel size to its content instead of stretching to fill the sidebar.
### Fixed
- Fixed [frontend/src/App.tsx](/home/ray/dev/linkong/planet/frontend/src/App.tsx) so anonymous visits to `/` once again reach the public Earth entry through the existing `/ -> /earth` redirect instead of being intercepted by the login screen.
- Fixed [frontend/src/pages/Playground/Playground.tsx](/home/ray/dev/linkong/planet/frontend/src/pages/Playground/Playground.tsx) so cached provider status is shown immediately but still refreshed from the backend, avoiding stale diagnostics after `.env` or provider changes within the same browser tab.
- Fixed [frontend/src/pages/Playground/Playground.tsx](/home/ray/dev/linkong/planet/frontend/src/pages/Playground/Playground.tsx) and [frontend/src/index.css](/home/ray/dev/linkong/planet/frontend/src/index.css) so the `测试说明` card no longer over-expands and now fits its content more naturally in the sidebar.
## 0.24.1
Released: 2026-04-09

View File

@@ -16,7 +16,7 @@
## Current Version
- `main` 当前主线历史推导到:`0.16.5`
- `dev` 当前开发分支历史推导到:`0.24.1`
- `dev` 当前开发分支历史推导到:`0.24.2`
## Timeline
@@ -74,6 +74,7 @@
| `0.23.3` | bugfix | `dev` | `pending` | refine `planet.sh` zsh runtime compatibility, startup logging, and frontend readiness feedback |
| `0.24.0` | feature | `dev` | `pending` | add AI Playground entry, provider diagnostics, and frontend layout guidance |
| `0.24.1` | bugfix | `dev` | `pending` | refactor Earth HUD into class-first CSS layers, unify Bun-only frontend tooling guidance, and auto-bootstrap Bun/uv in `planet.sh` |
| `0.24.2` | bugfix | `dev` | `pending` | restore public Earth entry, refresh Playground provider diagnostics correctly, fit help-card content, and split frontend bundles by route/vendor |
## Maintenance Commits Not Counted as Version Bumps

View File

@@ -1,6 +1,6 @@
{
"name": "planet-frontend",
"version": "0.24.1",
"version": "0.24.2",
"private": true,
"packageManager": "bun@1",
"dependencies": {

View File

@@ -1,36 +1,48 @@
import { Suspense, lazy } from 'react'
import { Spin } from 'antd'
import { Routes, Route, Navigate } from 'react-router-dom'
import { useAuthStore } from './stores/auth'
import Login from './pages/Login/Login'
import Dashboard from './pages/Dashboard/Dashboard'
import Users from './pages/Users/Users'
import DataSources from './pages/DataSources/DataSources'
import DataList from './pages/DataList/DataList'
import Earth from './pages/Earth/Earth'
import Settings from './pages/Settings/Settings'
import BGP from './pages/BGP/BGP'
import Playground from './pages/Playground/Playground'
const Dashboard = lazy(() => import('./pages/Dashboard/Dashboard'))
const Users = lazy(() => import('./pages/Users/Users'))
const DataSources = lazy(() => import('./pages/DataSources/DataSources'))
const DataList = lazy(() => import('./pages/DataList/DataList'))
const Earth = lazy(() => import('./pages/Earth/Earth'))
const Settings = lazy(() => import('./pages/Settings/Settings'))
const BGP = lazy(() => import('./pages/BGP/BGP'))
const Playground = lazy(() => import('./pages/Playground/Playground'))
function App() {
const { token } = useAuthStore()
const isEarthPage = window.location.pathname === '/earth'
const publicPaths = new Set(['/', '/earth'])
const isPublicRoute = publicPaths.has(window.location.pathname)
if (!token && !isEarthPage) {
if (!token && !isPublicRoute) {
return <Login />
}
return (
<Routes>
<Route path="/admin" element={<Dashboard />} />
<Route path="/" element={<Navigate to="/earth" replace />} />
<Route path="/earth" element={<Earth />} />
<Route path="/users" element={<Users />} />
<Route path="/datasources" element={<DataSources />} />
<Route path="/data" element={<DataList />} />
<Route path="/bgp" element={<BGP />} />
<Route path="/playground" element={<Playground />} />
<Route path="/settings" element={<Settings />} />
<Route path="*" element={<Navigate to="/admin" replace />} />
</Routes>
<Suspense
fallback={(
<div className="app-route-loading">
<Spin size="large" />
</div>
)}
>
<Routes>
<Route path="/admin" element={<Dashboard />} />
<Route path="/" element={<Navigate to="/earth" replace />} />
<Route path="/earth" element={<Earth />} />
<Route path="/users" element={<Users />} />
<Route path="/datasources" element={<DataSources />} />
<Route path="/data" element={<DataList />} />
<Route path="/bgp" element={<BGP />} />
<Route path="/playground" element={<Playground />} />
<Route path="/settings" element={<Settings />} />
<Route path="*" element={<Navigate to="/admin" replace />} />
</Routes>
</Suspense>
)
}

View File

@@ -14,6 +14,13 @@ body {
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}
.app-route-loading {
min-height: 100vh;
display: flex;
align-items: center;
justify-content: center;
}
.login-container {
min-height: 100vh;
display: flex;
@@ -472,7 +479,7 @@ body {
}
.playground-help--expanded {
flex: 1 0 auto;
flex: 0 0 auto;
}
.playground-help.ant-collapse {
@@ -493,38 +500,21 @@ body {
}
.playground-help .ant-collapse-content {
flex: 1 1 auto;
flex: 0 0 auto;
min-height: 0;
overflow: hidden;
overflow: visible;
}
.playground-help .ant-collapse-content-box {
height: 100%;
overflow: auto;
scrollbar-width: thin;
scrollbar-color: rgba(148, 163, 184, 0.88) transparent;
height: auto;
overflow: visible;
padding: 12px 16px 16px !important;
}
.playground-help .ant-collapse-content-box::-webkit-scrollbar {
width: 8px;
height: 8px;
}
.playground-help .ant-collapse-content-box::-webkit-scrollbar-thumb {
background: rgba(148, 163, 184, 0.82);
border-radius: 999px;
border: 2px solid transparent;
background-clip: padding-box;
}
.playground-help .ant-collapse-content-box::-webkit-scrollbar-thumb:hover {
background: rgba(100, 116, 139, 0.9);
background-clip: padding-box;
}
.playground-help .ant-collapse-content-box::-webkit-scrollbar-track {
background: transparent;
.playground-help__content {
display: flex;
flex-direction: column;
gap: 12px;
}
.playground-note.ant-alert {

View File

@@ -76,7 +76,6 @@ function Playground() {
if (cached) {
try {
setProviderStatus(JSON.parse(cached) as AIProviderStatus)
return
} catch {
sessionStorage.removeItem(PLAYGROUND_PROVIDER_STATUS_STORAGE_KEY)
}
@@ -207,22 +206,24 @@ function Playground() {
key: 'help',
label: '测试说明',
children: (
<Alert
type="info"
showIcon
className="playground-note"
message="用于验证 AI Provider 是否可用,以及 backend -> aiprovider 链路是否通畅。"
description={(
<span>
<Text code>frontend /playground</Text>
{' -> '}
<Text code>backend /api/v1/ai/*</Text>
{' -> '}
<Text code>aiprovider /v1/*</Text>
</span>
)}
/>
<div className="playground-help__content">
<Alert
type="info"
showIcon
className="playground-note"
message="用于验证 AI Provider 是否可用,以及 backend -> aiprovider 链路是否通畅。"
description={(
<span>
<Text code>frontend /playground</Text>
{' -> '}
<Text code>backend /api/v1/ai/*</Text>
{' -> '}
<Text code>aiprovider /v1/*</Text>
</span>
)}
/>
</div>
),
},
]}

View File

@@ -72,4 +72,36 @@ export default defineConfig({
entries: ['src/main.tsx'],
exclude: ['satellite.js'],
},
build: {
rollupOptions: {
output: {
manualChunks(id) {
if (!id.includes('node_modules')) {
return
}
if (id.includes('/@ant-design/icons/')) {
return 'icons-vendor'
}
if (
id.includes('/react/') ||
id.includes('/react-dom/') ||
id.includes('/react-router-dom/') ||
id.includes('/scheduler/')
) {
return 'react-vendor'
}
if (id.includes('/axios/')) {
return 'network-vendor'
}
if (id.includes('/three/') || id.includes('/simplex-noise/') || id.includes('/satellite.js/')) {
return 'earth-vendor'
}
},
},
},
},
})

View File

@@ -1,6 +1,6 @@
[project]
name = "planet"
version = "0.24.1"
version = "0.24.2"
description = "智能星球计划 - 态势感知系统"
requires-python = ">=3.14"
dependencies = [

2
uv.lock generated
View File

@@ -475,7 +475,7 @@ wheels = [
[[package]]
name = "planet"
version = "0.24.1"
version = "0.24.2"
source = { virtual = "." }
dependencies = [
{ name = "aiofiles" },