From 39f90bd575ca9b1ba55a88983f1b9e0ccd832165 Mon Sep 17 00:00:00 2001 From: linkong Date: Thu, 9 Apr 2026 15:23:10 +0800 Subject: [PATCH] fix: polish playground routing and bundle splits --- VERSION | 2 +- docs/CHANGELOG.md | 20 +++++++ docs/version-history.md | 3 +- frontend/package.json | 2 +- frontend/src/App.tsx | 56 ++++++++++++-------- frontend/src/index.css | 42 ++++++--------- frontend/src/pages/Playground/Playground.tsx | 35 ++++++------ frontend/vite.config.ts | 32 +++++++++++ pyproject.toml | 2 +- uv.lock | 2 +- 10 files changed, 126 insertions(+), 70 deletions(-) diff --git a/VERSION b/VERSION index 48b91fd8..8b95abd9 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.24.1 +0.24.2 diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 3304dd88..b050dcb3 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -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 diff --git a/docs/version-history.md b/docs/version-history.md index 83b26d9c..922dded0 100644 --- a/docs/version-history.md +++ b/docs/version-history.md @@ -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 diff --git a/frontend/package.json b/frontend/package.json index 6ae13209..95656b0d 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -1,6 +1,6 @@ { "name": "planet-frontend", - "version": "0.24.1", + "version": "0.24.2", "private": true, "packageManager": "bun@1", "dependencies": { diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx index a5a8c337..a99042dd 100644 --- a/frontend/src/App.tsx +++ b/frontend/src/App.tsx @@ -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 } return ( - - } /> - } /> - } /> - } /> - } /> - } /> - } /> - } /> - } /> - } /> - + + + + )} + > + + } /> + } /> + } /> + } /> + } /> + } /> + } /> + } /> + } /> + } /> + + ) } diff --git a/frontend/src/index.css b/frontend/src/index.css index efcce359..bb495c92 100644 --- a/frontend/src/index.css +++ b/frontend/src/index.css @@ -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 { diff --git a/frontend/src/pages/Playground/Playground.tsx b/frontend/src/pages/Playground/Playground.tsx index 684b540e..38c22231 100644 --- a/frontend/src/pages/Playground/Playground.tsx +++ b/frontend/src/pages/Playground/Playground.tsx @@ -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: ( - - 当前链路: - frontend /playground - {' -> '} - backend /api/v1/ai/* - {' -> '} - aiprovider /v1/* - - )} - /> +
+ + 当前链路: + frontend /playground + {' -> '} + backend /api/v1/ai/* + {' -> '} + aiprovider /v1/* + + )} + /> +
), }, ]} diff --git a/frontend/vite.config.ts b/frontend/vite.config.ts index b4323c34..2a61f691 100644 --- a/frontend/vite.config.ts +++ b/frontend/vite.config.ts @@ -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' + } + }, + }, + }, + }, }) diff --git a/pyproject.toml b/pyproject.toml index 6141523c..94ce09c3 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "planet" -version = "0.24.1" +version = "0.24.2" description = "智能星球计划 - 态势感知系统" requires-python = ">=3.14" dependencies = [ diff --git a/uv.lock b/uv.lock index da25f7ce..dc11f79c 100644 --- a/uv.lock +++ b/uv.lock @@ -475,7 +475,7 @@ wheels = [ [[package]] name = "planet" -version = "0.24.1" +version = "0.24.2" source = { virtual = "." } dependencies = [ { name = "aiofiles" },