release: bump version to 0.62.0
This commit is contained in:
1 parent
5c65ee24d6
commit
fbca381512
138 files changed
+21303
-5721
No files matched your search
@@ -30,8 +30,10 @@ What belongs here:
|
||||
- [Collector Settings and Connectivity Validation](/home/ray/dev/linkong/planet/docs/technical/en/datasource-collector-settings-connectivity.md): Data source catalog, collector settings, connectivity validation, and BarentsWatch credentials
|
||||
- [Shared Location Resolution Pipeline Development Guide](/home/ray/dev/linkong/planet/docs/technical/en/location-pipeline-development.md): Backend location resolver / pipeline interfaces, registries, and extension points
|
||||
- [Docs Gatekeeper Development Guide](/home/ray/dev/linkong/planet/docs/technical/en/docs-gatekeeper-development.md): Backend Docs catalog, Markdown content loading, and Gatekeeper permission groups
|
||||
- [Naming Glossary](/home/ray/dev/linkong/planet/docs/technical/en/naming-glossary.md): English/Chinese term mapping for the console, Earth, backend, and docs
|
||||
- [Earth Interactable Usage](/home/ray/dev/linkong/planet/docs/technical/en/earth-interactable-usage.md): API, lifecycle, and integration examples for Earth surface icon Interactable
|
||||
- [Earth Toolbar and Overlay Coordination](/home/ray/dev/linkong/planet/docs/technical/en/earth-toolbar-overlay-coordination.md): Closing matrix and integration rules for toolbar buttons, search, settings, news, and layer overlays
|
||||
- [Tactile UI Components](/home/ray/dev/linkong/planet/docs/technical/en/tactile-ui-components.md): Portable button, switch, tooltip, and scrollbar APIs, theme tokens, and migration rules
|
||||
|
||||
What does not belong here:
|
||||
|
||||
|
||||
@@ -101,6 +101,19 @@ The AI settings page uses:
|
||||
|
||||
These endpoints require an authenticated user. The `secrets` endpoint is only used when the settings page reveals a key or token; hiding the field restores the masked preview.
|
||||
|
||||
Admin Next keeps the AI page aligned with the legacy information architecture:
|
||||
|
||||
- `Model Providers`
|
||||
- Manages provider, wire adapter, default model, LLM API key, proxy URL, proxy token, model refresh, set-as-default, and lightweight connectivity testing.
|
||||
- `Tool Calling`
|
||||
- Manages tools such as WebSearch and OCR. Each tool first selects a provider, then edits that provider's API, key, and advanced parameters.
|
||||
- `Prompts`
|
||||
- Edits system/user prompts by prompt group and task key. Save and reset only affect the current task.
|
||||
- `Playground`
|
||||
- Runs real conversations with the active provider and prompt configuration. AI responses are rendered as Markdown.
|
||||
|
||||
Save, set-as-default, and connectivity testing are separate responsibilities: save only persists the form, set-as-default only changes the active provider/tool, and connectivity testing only validates the current draft. It must not implicitly save or switch defaults.
|
||||
|
||||
The `ai-prompts` endpoints back the Prompts tab in AI settings. Shipped defaults come from versioned backend resources, while business code references stable task keys. The API stores only operator overrides. Resetting a prompt removes the override and falls back to the current shipped default.
|
||||
|
||||
### Prompt Boundary
|
||||
@@ -259,6 +272,34 @@ Each provider has its own key slot. Resolution order is:
|
||||
|
||||
`.env` is only a fallback. After the settings page saves successfully, or after the connection test succeeds, PostgreSQL becomes the global default source.
|
||||
|
||||
Admin Next must compute key status per provider or tool:
|
||||
|
||||
- If the database has a key for the current provider/tool, show `configured`.
|
||||
- If the database has no key but the fallback provider, model, or tool matches the current item, show the fallback masked preview.
|
||||
- If neither database nor matching fallback exists, show `not configured`; a generic `.env` key for another provider must not make this item appear configured.
|
||||
- Masking keeps the prefix before the first `-`, for example `sk-********`. Plaintext reveal is only available inside the authorized configuration page.
|
||||
|
||||
Tool keys follow the same rule. WebSearch and OCR must match the current tool and provider before they can use fallback credentials.
|
||||
|
||||
### Lightweight Connectivity Testing
|
||||
|
||||
The Admin Next plug button performs a lightweight connectivity check and does not save configuration. Common API-platform practice is two-tiered:
|
||||
|
||||
- Check a provider catalog or low-cost endpoint to validate base URL, authentication, and model reachability.
|
||||
- Send full model requests only when the user explicitly runs Playground or a business task.
|
||||
|
||||
Connectivity results should be explicit:
|
||||
|
||||
- `ok`: authentication, route, and model catalog are usable.
|
||||
- `warning`: service is reachable, but the current model is missing from the catalog or capability metadata is incomplete.
|
||||
- `error`: authentication, network, protocol, or model lookup failed.
|
||||
|
||||
Toast titles must match the result; failures must not be titled as a successful connection.
|
||||
|
||||
### OpenCode Go Routing Model
|
||||
|
||||
Subscription channels such as OpenCode Go should not be handled by hard-coded frontend model sets. Prefer provider catalog or backend capability discovery that records per-model capabilities such as `chat_completions`, `anthropic_messages`, `models_endpoint`, and whether a subscription key is required. The frontend should display capabilities; the backend should map provider, base URL, model, and adapter into the real request.
|
||||
|
||||
#### Settings Page Behavior
|
||||
|
||||
- The Provider select controls the global default provider.
|
||||
|
||||
@@ -93,6 +93,16 @@ Earth boundaries are no longer data collectors. They are Earth static rendering
|
||||
|
||||
TOP500 and Epoch AI compute sources do not always provide usable coordinates. The unified Earth compute-center endpoint uses only valid source-provided coordinates or `compute_center_locations` dimension-table coordinates during the main map startup path; records without coordinates are returned as `unresolved` instead of being rendered from a local registry, country centroid, or guessed city. When users manually collect candidates, the backend queries ROR and Nominatim/OpenStreetMap from source fields; accepted candidates are saved into `compute_center_locations` and rendered from that table on the next layer refresh.
|
||||
|
||||
Admin Next collection management follows the business hierarchy instead of flattening every endpoint into one table:
|
||||
|
||||
- `Collectors`: endpoint, authentication, headers, base parameters, enabled state, and credential guides.
|
||||
- `Collection Schedule`: scheduler state and task controls.
|
||||
- `Collection History / Snapshots`: history grouped by collector, with a detail-side snapshot selector for versions.
|
||||
|
||||
Snapshot lists should not show every snapshot of the same collector as separate top-level records. The top-level list selects a collector; the detail area switches between time versions.
|
||||
|
||||
Credential guides are maintained by `backend/app/services/credential_guides.py`. The console uses read / generate / reset actions to load or create Markdown instructions. The frontend should render the guide Markdown for operators, not expose generation prompts or raw metadata.
|
||||
|
||||
## IV. Data Format (stored in CollectedData table)
|
||||
|
||||
```python
|
||||
|
||||
@@ -32,8 +32,8 @@ If endpoint, headers, base configuration, or credential fingerprint changes afte
|
||||
|
||||
Files:
|
||||
|
||||
- [DataSources.tsx](/home/ray/dev/linkong/planet/frontend/src/pages/DataSources/DataSources.tsx)
|
||||
- [index.css](/home/ray/dev/linkong/planet/frontend/src/index.css)
|
||||
- [PlainResourcePages.tsx](/home/ray/dev/linkong/planet/frontend/src/admin-next/pages/PlainResourcePages.tsx)
|
||||
- [AdminNextRoutes.tsx](/home/ray/dev/linkong/planet/frontend/src/admin-next/AdminNextRoutes.tsx)
|
||||
|
||||
Current behavior:
|
||||
|
||||
@@ -53,30 +53,35 @@ Current behavior:
|
||||
|
||||
`data-source-bulk-toolbar__running-pill` is the styling entry point for the "Collecting" pill. It is aligned with other status tags, while hover treatment, arrow affordance, and blue outline indicate interactivity.
|
||||
|
||||
### Collectors
|
||||
### Collection Management
|
||||
|
||||
File:
|
||||
|
||||
- [Settings.tsx](/home/ray/dev/linkong/planet/frontend/src/pages/Settings/Settings.tsx)
|
||||
- [PlainResourcePages.tsx](/home/ray/dev/linkong/planet/frontend/src/admin-next/pages/PlainResourcePages.tsx)
|
||||
|
||||
Current behavior:
|
||||
|
||||
- The `collector_credentials` tab is displayed as "Collectors" under `/collection-management`.
|
||||
- A select lists built-in collectors and supports maintaining custom supplemental sources that merge into built-in data.
|
||||
- The only button beside the select is a plug icon for health checks.
|
||||
- Status tags below the select show:
|
||||
- `Credentials required` / `No credentials required`
|
||||
- Module
|
||||
- `Enabled` / `Disabled`
|
||||
- `Unchecked` / `Available` / `Unavailable`
|
||||
- Whether the endpoint is overridden
|
||||
- Collectors that require credentials place the credential card above base configuration.
|
||||
- Collectors without credentials only show base configuration.
|
||||
- `/collection-management` follows the legacy hierarchy: `Collectors`, `Collection Schedule`, and `Collection History / Snapshots`.
|
||||
- `Collectors` is the configuration page. The left list shows collector configs; the right form edits endpoint, authentication, headers, collection parameters, and enabled state.
|
||||
- New collectors and target schemas use draft detail pages instead of transparent JSON modals; save persists the draft, while cancel destroys it.
|
||||
- The connection button only tests connectivity and does not save. The save button only persists the form.
|
||||
- Credential guides open in a draggable Markdown modal. When no guide exists, the modal still opens and offers a generate action. Generation shows a centered waiting state; reset confirmation must render above the guide modal.
|
||||
- `Collection History / Snapshots` groups by collector. The list must not repeat every snapshot for the same datasource; detail view switches versions through a Time Capsule / Time Machine style selector.
|
||||
- The AISStream collector uses WebSocket semantics: connecting, streaming, reconnecting, or stopped. It does not use a fixed completion percentage.
|
||||
- Custom source editing lives in collector settings. The data source catalog keeps overview, run controls, and read-only drawers.
|
||||
|
||||
The connection button uses an inline Tabler-style plug icon with `plug-connected` semantics, avoiding the older refresh icon for a connection action.
|
||||
|
||||
### Mapping Templates and Target Schemas
|
||||
|
||||
Mapping remains part of collection management, but not the main collector tab:
|
||||
|
||||
- `Mapping Templates` owns sample payload, AI propose, preview, create/update, and activate.
|
||||
- `Target Schemas` maintains writable target structures.
|
||||
- `run-mapped`, `stop-mapped`, and `stream-status` run mapped custom collectors.
|
||||
|
||||
The new UI should keep these paths form-first. Only advanced fields should collapse into JSON. Do not flatten templates, schemas, runtime status, and collector configuration into one table.
|
||||
|
||||
## Backend APIs
|
||||
|
||||
### Data Source Configuration List
|
||||
@@ -140,6 +145,26 @@ Successful responses include:
|
||||
- `credential_provider`
|
||||
- `credential_source`
|
||||
|
||||
### Credential Guides
|
||||
|
||||
```http
|
||||
GET /api/v1/datasources/credential-guides/{provider}
|
||||
POST /api/v1/datasources/credential-guides/{provider}/generate
|
||||
POST /api/v1/datasources/credential-guides/{provider}/reset
|
||||
```
|
||||
|
||||
Purpose:
|
||||
|
||||
- Read the Markdown credential guide for a provider.
|
||||
- Generate a guide from collector metadata when none exists.
|
||||
- Reset back to the backend default guide.
|
||||
|
||||
Frontend rules:
|
||||
|
||||
- Render Markdown, not backend prompts or metadata.
|
||||
- Generate/reset actions belong inside the guide modal, not in the collector configuration toolbar.
|
||||
- Missing guides still open a modal so the user can generate one from there.
|
||||
|
||||
### BarentsWatch AIS Connectivity Validation
|
||||
|
||||
```http
|
||||
|
||||
@@ -151,6 +151,15 @@ Each module is responsible for its own:
|
||||
|
||||
`brand.js` manages Earth HUD brand resources. Static assets provide the default brand; runtime overrides come from `/api/v1/earth/brand`, and uploaded images are served from `/earth-brand-assets/...`. The frontend must treat logo/title images and text fallback separately: if an image fails, show the text title; if text fields are empty, rely on backend defaults so the HUD brand area never renders blank. The console Earth Content page owns saving and resetting brand configuration; the Earth frontend only consumes it.
|
||||
|
||||
The Admin Next Earth Content page must preserve runtime semantics:
|
||||
|
||||
- `Brand`: brand preview should use the same dark starfield background, size, spacing, logo/title rendering, and text fallback as the Earth HUD top-left brand block, not a generic form preview.
|
||||
- `Boundary Precision`: build boundary, refresh status, and restore defaults belong inside this section, not in the global page toolbar.
|
||||
- `TV`: the list distinguishes built-in, collected, and custom sources. Card state represents enabled, disabled, draft, or error. Built-in sources cannot be deleted; collected and custom sources can. A new live source only enters draft state after the plus button is clicked; save persists it into the list, while cancel destroys the draft.
|
||||
- `Basemap`, `Layer Resources`, `3D Models`, and `News Anchor Strategy`: if backend capability is not available yet, the console should show an explicit pending state instead of mixing those items into TV or brand configuration.
|
||||
|
||||
TV preview should reuse the Earth runtime live-card structure and state labels as closely as possible so built-in markers, live loading state, stream source, region, and language match what users see on Earth.
|
||||
|
||||
The compute-center layer row has a notification badge for GeoJSON `unresolved` records. The badge means "no trustworthy coordinates, cannot render on the globe"; it is different from the `?` marker drawn on already positioned but unconfirmed compute centers. Clicking the badge opens a fixed info card beside the layer panel. Row-level `采集` fetches candidates only. Header-level `一键采用` processes the queue top-to-bottom, saves the highest-confidence valid candidate, removes successful rows, renumbers the list, and dispatches `earth:compute-center-unresolved-count-change` so the badge updates immediately. When the batch ends, `earth:compute-center-location-saved` refreshes the real layer.
|
||||
|
||||
Location candidate state in the details card is cached in [info-card.js](/home/ray/dev/linkong/planet/frontend/public/earth/js/info-card.js) by `entityType:entityId`. If the user closes the details card or unresolved queue and reopens the same compute center / BGP collector, previously collected candidates and status text are restored. Header-level `一键采用` prefers cached candidates, avoiding repeated online geocoding or LLM factcheck calls. After a location is saved, that entity's candidate list is cleared to a "refreshing layer" status so stale candidates do not keep misleading the user.
|
||||
|
||||
@@ -22,7 +22,7 @@ Main entry point:
|
||||
|
||||
- [App.tsx](/home/ray/dev/linkong/planet/frontend/src/App.tsx)
|
||||
|
||||
Current admin-related routes:
|
||||
Admin Next now owns the official admin routes:
|
||||
|
||||
- `/admin`
|
||||
- `/users`
|
||||
@@ -37,15 +37,45 @@ Current admin-related routes:
|
||||
- `/collection-management`
|
||||
- `/settings`
|
||||
|
||||
These routes render [AdminNextRoutes.tsx](/home/ray/dev/linkong/planet/frontend/src/admin-next/AdminNextRoutes.tsx). Page metadata and menu entries come from [manifest.tsx](/home/ray/dev/linkong/planet/frontend/src/admin-next/routes/manifest.tsx). `/admin-next/*` remains only as a compatibility entry and redirects to the official route; it is no longer a parallel primary entry.
|
||||
|
||||
The old AntD console remains available under `/legacy/admin/*` for comparison and rollback:
|
||||
|
||||
- `/legacy/admin`
|
||||
- `/legacy/admin/datasources`
|
||||
- `/legacy/admin/data`
|
||||
- `/legacy/admin/collection-management`
|
||||
- `/legacy/admin/earth-content`
|
||||
- `/legacy/admin/ai`
|
||||
- `/legacy/admin/logs`
|
||||
- `/legacy/admin/settings`
|
||||
- `/legacy/admin/users`
|
||||
- `/legacy/admin/bgp`
|
||||
- `/legacy/admin/alerts/*`
|
||||
|
||||
Legacy pages, `AppLayout`, `antd`, and `@ant-design/icons` stay in place during the legacy validation window. Do not remove them before Admin Next parity is accepted.
|
||||
|
||||
`/earth` is a standalone display page and is not part of the console shell.
|
||||
|
||||
## Current Page Shell
|
||||
|
||||
The console shared shell is at:
|
||||
The official admin shell is at:
|
||||
|
||||
- [AdminNextLayout.tsx](/home/ray/dev/linkong/planet/frontend/src/admin-next/components/layout/AdminNextLayout.tsx)
|
||||
|
||||
Responsibilities:
|
||||
|
||||
- Left navigation, grouped collapse, and mobile drawer
|
||||
- Current account, version, logout, and theme switching
|
||||
- Top search, breadcrumbs, and page shortcuts
|
||||
- Single-screen content-area height closure
|
||||
- Coordination for Admin Next internal scrolling, tables, detail panels, and mobile detail views
|
||||
|
||||
The old AntD legacy shell remains at:
|
||||
|
||||
- [AppLayout.tsx](/home/ray/dev/linkong/planet/frontend/src/components/AppLayout/AppLayout.tsx)
|
||||
|
||||
Responsibilities:
|
||||
Legacy responsibilities:
|
||||
|
||||
- Left-side navigation
|
||||
- Collapse and expand
|
||||
@@ -66,7 +96,19 @@ Current structure:
|
||||
</Layout>
|
||||
```
|
||||
|
||||
Future console pages should adapt to this shell rather than redefining full-page height semantics.
|
||||
Future official admin pages should adapt to `AdminNextLayout` and Admin Next page patterns rather than adding new capability to the old `AppLayout`. Only `/legacy/admin/*` maintenance should change the old shell.
|
||||
|
||||
## Admin Next Section Loading
|
||||
|
||||
Multi-tab pages are currently coordinated by [PlainResourcePages.tsx](/home/ray/dev/linkong/planet/frontend/src/admin-next/pages/PlainResourcePages.tsx), which hosts the current management and information workbench patterns. Section loading follows these rules:
|
||||
|
||||
- Initial page load requests only the active tab; it does not prefetch every tab endpoint.
|
||||
- Switching tabs lazily loads that tab. Loaded tabs stay cached in local `states`, so returning to a tab reuses the previous data.
|
||||
- Explicit actions such as refresh, save, test, upload, and credential-guide generation refresh only the current section instead of fanning out to unrelated sections.
|
||||
- Datasource directory filter changes clear the built-in-source section cache and reload the current section with the new filters.
|
||||
- Top summary metrics count loaded sections only, so unopened tabs are not reported as failed interfaces.
|
||||
|
||||
This keeps Earth, AI, collection management, and other multi-section pages from flooding backend APIs on cold start while preserving a fast cached tab-switching experience. Full health checks should use backend health endpoints or explicit refresh flows rather than relying on page initialization to touch every business endpoint.
|
||||
|
||||
## Current Shared Components
|
||||
|
||||
@@ -74,7 +116,8 @@ Future console pages should adapt to this shell rather than redefining full-page
|
||||
|
||||
File:
|
||||
|
||||
- [Scrollbar.tsx](/home/ray/dev/linkong/planet/frontend/src/components/Scrollbar/Scrollbar.tsx)
|
||||
- [Scrollbar.tsx](/home/ray/dev/linkong/planet/frontend/src/components/tactile-ui/Scrollbar.tsx)
|
||||
- [Tactile UI Components](/home/ray/dev/linkong/planet/docs/technical/en/tactile-ui-components.md)
|
||||
|
||||
Purpose:
|
||||
|
||||
@@ -91,7 +134,7 @@ Current constraint:
|
||||
|
||||
File:
|
||||
|
||||
- [ScrollbarOverlay.tsx](/home/ray/dev/linkong/planet/frontend/src/components/Scrollbar/ScrollbarOverlay.tsx)
|
||||
- [ScrollbarOverlay.tsx](/home/ray/dev/linkong/planet/frontend/src/components/tactile-ui/ScrollbarOverlay.tsx)
|
||||
|
||||
Purpose:
|
||||
|
||||
@@ -100,25 +143,42 @@ Purpose:
|
||||
|
||||
Current usage:
|
||||
|
||||
- Data sources
|
||||
- Collected data
|
||||
- User management
|
||||
- Settings page
|
||||
- Alerts page
|
||||
- BGP page
|
||||
- Admin Next data sources, collected data, collection management, logs, alerts, and BGP pages
|
||||
- Old AntD legacy pages continue using shared scrolling behavior through compatibility wrappers
|
||||
|
||||
### 3. `TableScrollRegion`
|
||||
|
||||
File:
|
||||
|
||||
- [TableScrollRegion.tsx](/home/ray/dev/linkong/planet/frontend/src/components/Scrollbar/TableScrollRegion.tsx)
|
||||
- [TableScrollRegion.tsx](/home/ray/dev/linkong/planet/frontend/src/components/tactile-ui/TableScrollRegion.tsx)
|
||||
|
||||
Purpose:
|
||||
|
||||
- Provides a unified wrapper for table scroll areas
|
||||
- New table pages should reuse this rather than repeating the "table area + overlay scrollbar" boilerplate
|
||||
|
||||
### 4. `SegmentedControl`
|
||||
### 4. `TactileButton` / `TactileSwitch` / `ControlGroup`
|
||||
|
||||
Files:
|
||||
|
||||
- [Button.tsx](/home/ray/dev/linkong/planet/frontend/src/components/tactile-ui/Button.tsx)
|
||||
- [Switch.tsx](/home/ray/dev/linkong/planet/frontend/src/components/tactile-ui/Switch.tsx)
|
||||
- [ControlGroup.tsx](/home/ray/dev/linkong/planet/frontend/src/components/tactile-ui/ControlGroup.tsx)
|
||||
|
||||
Purpose:
|
||||
|
||||
- Admin Next global tool buttons and detail-panel toolbars
|
||||
- Icon-only ordinary actions with tooltips
|
||||
- Strong-intent actions such as save, create, confirm, delete, and stop
|
||||
- Compact switches aligned with the Docs theme slider
|
||||
|
||||
Current constraints:
|
||||
|
||||
- Neutral buttons default to a white tactile surface with external shadow
|
||||
- Unambiguous actions prefer icon + tooltip; strong-intent actions like save may keep text
|
||||
- Feature pages should customize through props and CSS variables, not by rewriting core button CSS
|
||||
|
||||
### 5. `SegmentedControl`
|
||||
|
||||
Files:
|
||||
|
||||
@@ -146,7 +206,7 @@ Current constraints:
|
||||
- Prefer CSS variable overrides for colors instead of hard-coding theme colors in feature components
|
||||
- Best for a small set of mutually exclusive choices; do not use it as a long list, navigation menu, or select replacement
|
||||
|
||||
### 5. `MarkdownRenderer`
|
||||
### 6. `MarkdownRenderer`
|
||||
|
||||
File:
|
||||
|
||||
@@ -165,7 +225,7 @@ Current constraints:
|
||||
- Internal document links should be converted to `/docs/:slug` through `transformLink`
|
||||
- Heading anchors are injected through `getHeadingId`, keeping route state outside the renderer
|
||||
|
||||
### 6. `ConnectionTestInput`
|
||||
### 7. `ConnectionTestInput`
|
||||
|
||||
File:
|
||||
|
||||
@@ -183,7 +243,7 @@ Current constraints:
|
||||
- Disabled integrations must grey out both the input and its connection-test action
|
||||
- The component only combines the input and action; callers still own form state, loading, disabled state, and the request itself
|
||||
|
||||
### 7. `TableActions`
|
||||
### 8. `TableActions`
|
||||
|
||||
File:
|
||||
|
||||
|
||||
@@ -0,0 +1,99 @@
|
||||
# Naming Glossary
|
||||
|
||||
This document standardizes terms used across the Planet console, Earth, backend APIs, and documentation. When adding Chinese UI labels, chart labels, or translated documentation, prefer the Chinese display names listed here to avoid unnecessary mixed Chinese/English copy.
|
||||
|
||||
## Usage Rules
|
||||
|
||||
- Chinese UI should use the Chinese display name.
|
||||
- API fields, database fields, code identifiers, and external brand names keep their original English or snake_case form.
|
||||
- On first mention in long-form docs, use “Chinese Display Name (English Term)” when clarification helps; subsequent mentions can use the Chinese display name.
|
||||
- Industry abbreviations such as BGP, AI, API, URL, ID, TLE, ASN, GPU, and AIS may remain English.
|
||||
- External service brands keep their official English names, such as PeeringDB, Space-Track, BarentsWatch, AISStream, and GitHub.
|
||||
|
||||
## Core Product Terms
|
||||
|
||||
| English / Key | Chinese Display Name | Usage |
|
||||
| --- | --- | --- |
|
||||
| Planet | Planet | Product name |
|
||||
| Admin Next | 新控制台 | New admin console |
|
||||
| Earth | Earth | Visualization product name |
|
||||
| datasource | 数据源 | APIs, lists, filters |
|
||||
| collector | 采集器 | Collection jobs and credential configuration |
|
||||
| collected data | 采集数据 | Data list and statistics |
|
||||
| snapshot | 快照 | Collection history |
|
||||
| mapping | 映射 | Field mapping |
|
||||
| target schema | 目标 Schema | Mapping target structure |
|
||||
| credential | 凭证 | Secrets, account passwords, OAuth material |
|
||||
| secret reveal | 密钥 reveal | Explicit administrator secret reveal action |
|
||||
| AI Provider | AI Provider | Service name |
|
||||
| tool | 工具 | Web Search, OCR, and similar integrations |
|
||||
| Playground | Playground | Interactive debugging entry |
|
||||
|
||||
## Data Types
|
||||
|
||||
| data_type | Chinese Display Name | Meaning |
|
||||
| --- | --- | --- |
|
||||
| `supercomputer` | 超算 | TOP500 supercomputer record |
|
||||
| `gpu_cluster` | GPU 集群 | Epoch AI GPU cluster |
|
||||
| `model` | 模型 | Hugging Face model |
|
||||
| `dataset` | 数据集 | Hugging Face dataset |
|
||||
| `space` | 空间 | Hugging Face Space |
|
||||
| `ixp` | 互联网交换点 | PeeringDB IXP |
|
||||
| `network` | 网络 | PeeringDB network |
|
||||
| `facility` | 设施 | PeeringDB facility |
|
||||
| `submarine_cable` | 海底光缆 | Submarine cable route |
|
||||
| `landing_point` | 登陆点 | Cable landing point |
|
||||
| `cable_system` | 海缆系统 | TeleGeography cable system |
|
||||
| `cable_landing_relation` | 海缆登陆关系 | Cable-to-landing-point relation |
|
||||
| `satellite_tle` | 卫星轨道根数 | CelesTrak / Space-Track TLE |
|
||||
| `bgp_rib` | BGP 路由表 | BGP RIB snapshot |
|
||||
| `bgp_update` | BGP 更新 | BGP update event |
|
||||
| `prefix_geography` | 前缀地理位置 | IP prefix geography |
|
||||
| `vessel_ais` | AIS 船舶 | AIS vessel observation |
|
||||
| `vessel` | 船舶 | Aggregated vessel object |
|
||||
| `news_live_stream` | 新闻直播源 | News live stream source |
|
||||
| `news_item` | 新闻条目 | Archived news item |
|
||||
| `device_stats` | 设备统计 | Cloudflare Radar device statistics |
|
||||
| `traffic_stats` | 流量统计 | Cloudflare Radar traffic statistics |
|
||||
| `as_stats` | 自治系统统计 | Cloudflare Radar AS statistics |
|
||||
| `compute_center` | 算力中心 | Aggregated Earth compute-center object |
|
||||
| `generic` | 通用数据 | Generic collector output |
|
||||
| `generic_records` | 通用记录 | Generic mapping output |
|
||||
|
||||
## Datasources And External Services
|
||||
|
||||
| English / Key | Chinese Display Name | Notes |
|
||||
| --- | --- | --- |
|
||||
| TOP500 | TOP500 超算榜单 | Keep TOP500 as the external list name |
|
||||
| Epoch AI | Epoch AI GPU 集群 | Keep Epoch AI as the service name |
|
||||
| Hugging Face | Hugging Face | Official brand name |
|
||||
| PeeringDB IXP | PeeringDB 交换中心 | IXP can also be explained as 互联网交换点 |
|
||||
| PeeringDB Networks | PeeringDB 网络 | Network entity |
|
||||
| PeeringDB Facilities | PeeringDB 设施 | Facility entity |
|
||||
| Submarine Cables | 海底光缆 | Prefer Chinese in charts and lists |
|
||||
| Cable Landing Points | 海缆登陆点 | Use 登陆点 consistently |
|
||||
| CelesTrak TLE | CelesTrak 轨道根数 | TLE may remain abbreviated |
|
||||
| Space-Track TLE | Space-Track 轨道根数 | Keep Space-Track as brand name |
|
||||
| RIPE RIS Live BGP | RIPE RIS Live BGP | Keep service name and BGP abbreviation |
|
||||
| IPtoASN Prefix Geography | IPtoASN 前缀地理位置 | Keep IPtoASN as dataset name |
|
||||
| OpenGeoFeed Prefix Geography | OpenGeoFeed 前缀地理位置 | Keep OpenGeoFeed as brand name |
|
||||
| NRO Delegated Prefix Geography | NRO Delegated 前缀地理位置 | Keep NRO Delegated as dataset name |
|
||||
| BarentsWatch AIS Vessels | BarentsWatch AIS 船舶 | Keep BarentsWatch / AIS |
|
||||
| AISStream Vessels | AISStream 船舶 | Keep AISStream as brand name |
|
||||
|
||||
## UI Actions And Statuses
|
||||
|
||||
| English / Key | Chinese Display Name | Usage |
|
||||
| --- | --- | --- |
|
||||
| success | 成功 | Status badge |
|
||||
| failed | 失败 | Status badge |
|
||||
| running | 运行中 | Task status |
|
||||
| completed | 已完成 | Task status |
|
||||
| cancelled | 已取消 | Task status |
|
||||
| enabled | 已启用 | Toggle state |
|
||||
| disabled | 已停用 | Toggle state |
|
||||
| configured | 已配置 | Credential / integration state |
|
||||
| unconfigured | 未配置 | Credential / integration state |
|
||||
| refresh | 刷新 | Button |
|
||||
| copy | 复制 | Button |
|
||||
| reveal | reveal | Keep English for audited secret reveal semantics |
|
||||
@@ -87,8 +87,8 @@ Recent logs:
|
||||
Follow:
|
||||
|
||||
```bash
|
||||
./planet.sh log -f # frontend: /tmp/planet_frontend.log
|
||||
./planet.sh log -b # backend: /tmp/planet_backend.log
|
||||
./planet.sh log -f # frontend: ~/.local/state/planet/frontend.log
|
||||
./planet.sh log -b # backend: ~/.local/state/planet/backend.log
|
||||
./planet.sh log -a # AI Provider: planet_aiprovider container logs
|
||||
```
|
||||
|
||||
@@ -234,6 +234,20 @@ Validate the frontend build:
|
||||
source ~/.zshrc && bun run build
|
||||
```
|
||||
|
||||
Use `bun run dev` during development; Vite HMR refreshes the browser after source saves. `bun run build` only writes the `dist` artifact and does not refresh an already-open dev page.
|
||||
|
||||
To inspect the production bundle with automatic reload after successful builds:
|
||||
|
||||
```bash
|
||||
bun run preview:auto
|
||||
```
|
||||
|
||||
To watch sources and rebuild continuously without starting the preview server:
|
||||
|
||||
```bash
|
||||
bun run build:watch
|
||||
```
|
||||
|
||||
Backend dependencies are managed with uv:
|
||||
|
||||
```bash
|
||||
|
||||
@@ -0,0 +1,205 @@
|
||||
# Tactile UI Components
|
||||
|
||||
Tactile UI is Planet's portable React control layer. It was extracted from the Admin Next button, switch, scrollbar, and tooltip work, but the components themselves do not depend on Admin Next, AntD, Radix, Tailwind, or `an-*` classes. The immediate goal is stable in-repo usage; the structure is intentionally close to something that can later be published as an npm package.
|
||||
|
||||
## Design Goals
|
||||
|
||||
- **Light tactile feel**: controls default to a white or themed surface, thin borders, and external shadow, matching the subtle depth of the Docs theme slider rather than large colored blocks or glow.
|
||||
- **Portable styling**: classes use the `tui-*` prefix and styles live in `frontend/src/components/tactile-ui/styles.css`.
|
||||
- **Low dependency surface**: components assume React and React DOM. Preset icons currently use `lucide-react`, and callers may also pass custom React nodes.
|
||||
- **Theme friendly**: CSS variables expose the default styling surface. Planet pages adapt the library through theme variables and props.
|
||||
- **Clear semantics**: unambiguous actions should prefer icon-only buttons with tooltips; strong-intent actions such as save, confirm, create, and run can keep text.
|
||||
|
||||
## Import
|
||||
|
||||
In this repository:
|
||||
|
||||
```tsx
|
||||
import { TactileButton, TactileSwitch, ControlGroup } from '@/components/tactile-ui'
|
||||
import '@/components/tactile-ui/styles.css'
|
||||
```
|
||||
|
||||
After a future package extraction:
|
||||
|
||||
```tsx
|
||||
import { TactileButton, TactileSwitch } from '@planet/tactile-ui'
|
||||
import '@planet/tactile-ui/styles.css'
|
||||
```
|
||||
|
||||
## Theme Tokens
|
||||
|
||||
Core tokens are exposed as `--tui-*` CSS variables. Product themes should override variables instead of rewriting internal component classes.
|
||||
|
||||
```css
|
||||
:root {
|
||||
--tui-surface: #ffffff;
|
||||
--tui-surface-raised-hover: #f8fbff;
|
||||
--tui-border-soft: #d6dfeb;
|
||||
--tui-border-hover: #b8c6d9;
|
||||
--tui-text: #0f172a;
|
||||
--tui-primary: #2563eb;
|
||||
--tui-danger: #dc2626;
|
||||
}
|
||||
|
||||
[data-theme='dark'] {
|
||||
--tui-surface: #111827;
|
||||
--tui-text: #e5edf8;
|
||||
}
|
||||
```
|
||||
|
||||
Most controls also accept a `tactile` prop for local width, height, radius, background, border, and shadow overrides. Use local overrides for small special cases; use CSS variables for product-wide styling.
|
||||
|
||||
## `TactileButton`
|
||||
|
||||
The button component covers regular buttons, icon buttons, strong-intent buttons, and link-like buttons.
|
||||
|
||||
Common props:
|
||||
|
||||
| Prop | Description |
|
||||
| --- | --- |
|
||||
| `variant` | `neutral`, `primary`, `danger`, `subtle`, or `ghost` |
|
||||
| `size` | `sm`, `md`, `lg`, or `icon` |
|
||||
| `shape` | `square` or `pill` |
|
||||
| `icon` | Preset icon name or a custom React node |
|
||||
| `iconOnly` | Fixed-size icon button; provide `tooltip` or `aria-label` |
|
||||
| `tooltip` | Rendered through a portal and offset away from the cursor |
|
||||
| `loading` | Disables the button and exposes `aria-disabled` |
|
||||
| `tactile` | Overrides size, radius, shadow, background, and dark-mode variables |
|
||||
|
||||
```tsx
|
||||
<TactileButton icon="refresh" iconOnly tooltip="Refresh" />
|
||||
<TactileButton variant="primary" icon="save">Save</TactileButton>
|
||||
<TactileButton variant="danger" icon="delete" iconOnly tooltip="Delete" />
|
||||
```
|
||||
|
||||
`variant="neutral"` defaults to a white tactile button. Colored buttons should still keep the same height and external shadow instead of relying on page-specific CSS overrides.
|
||||
|
||||
## Icon Presets
|
||||
|
||||
Preset icons are maintained in `tactileIconPresets`. Feature pages should call icons by semantic name so actions remain consistent across the console.
|
||||
|
||||
Common semantics:
|
||||
|
||||
| Name | Use |
|
||||
| --- | --- |
|
||||
| `refresh` | Refresh data |
|
||||
| `save` | Save |
|
||||
| `delete` | Delete |
|
||||
| `trigger` / `collect` | Trigger collection |
|
||||
| `start` / `play` | Start |
|
||||
| `stop` | Stop |
|
||||
| `connect` / `test` | Connectivity check |
|
||||
| `guide` | Credential guide |
|
||||
| `generate` | AI generation |
|
||||
| `reset` | Restore defaults |
|
||||
| `detail` | View details |
|
||||
| `copy` | Copy |
|
||||
| `upload` | Upload |
|
||||
|
||||
Custom icons are also supported:
|
||||
|
||||
```tsx
|
||||
<TactileButton icon={<MyIcon aria-hidden="true" />} iconOnly tooltip="Custom action" />
|
||||
```
|
||||
|
||||
## `TactileSwitch`
|
||||
|
||||
`TactileSwitch` is for binary settings. It is not a large iOS-style switch; it matches the compact tactile slider used by Docs.
|
||||
|
||||
```tsx
|
||||
<TactileSwitch
|
||||
checked={enabled}
|
||||
onCheckedChange={setEnabled}
|
||||
label="Enable WebSearch"
|
||||
tooltip="Enable WebSearch"
|
||||
/>
|
||||
```
|
||||
|
||||
The label defaults to tooltip content. If visible text is needed, render it in the surrounding layout rather than inside the switch.
|
||||
|
||||
## `ControlGroup`
|
||||
|
||||
`ControlGroup` arranges action buttons with consistent spacing and alignment. It has no grey base by default; use `withBase` or `baseTactile` only when a base surface is intentional.
|
||||
|
||||
```tsx
|
||||
<ControlGroup align="end" gap={8}>
|
||||
<TactileButton icon="refresh" iconOnly tooltip="Refresh" />
|
||||
<TactileButton variant="primary" icon="save">Save</TactileButton>
|
||||
</ControlGroup>
|
||||
```
|
||||
|
||||
In list footers, the group should appear at the end of the scroll content, not float in the middle of the list. In detail toolbars, size and shadow should come from the shared component defaults.
|
||||
|
||||
## `TactileTooltip`
|
||||
|
||||
Tooltips render to `document.body` via `createPortal`, support `top`, `right`, `bottom`, and `left`, and perform simple collision correction. The default position is offset down and to the right from the trigger so it does not sit under the cursor.
|
||||
|
||||
```tsx
|
||||
<TactileTooltip label="Refresh" anchor={buttonRef.current} open={open} side="bottom" />
|
||||
```
|
||||
|
||||
Application code usually does not need to use it directly because `TactileButton` and `TactileSwitch` include tooltip handling.
|
||||
|
||||
## `Scrollbar`
|
||||
|
||||
`Scrollbar` wraps ordinary scrollable content. Native scrolling remains on the viewport; Tactile UI only renders the overlay track and thumb.
|
||||
|
||||
```tsx
|
||||
<Scrollbar axis="both" minThumbSize={28} autoHide>
|
||||
<LongContent />
|
||||
</Scrollbar>
|
||||
```
|
||||
|
||||
Common props:
|
||||
|
||||
| Prop | Description |
|
||||
| --- | --- |
|
||||
| `axis` | `x`, `y`, or `both` |
|
||||
| `autoHide` | Fade/soften when not hovered or dragged |
|
||||
| `alwaysVisible` | Keep scrollbars visible |
|
||||
| `trackSize` / `thumbSize` | Track and thumb dimensions |
|
||||
| `inset` / `radius` | Edge inset and radius |
|
||||
| `thumbColor` / `trackColor` | Local color overrides |
|
||||
| `viewportRef` | External real scroll node |
|
||||
|
||||
Do not force overlay scrollbars onto textareas. Text selection and the resize grip need native behavior. If a consistent textarea look is needed, use a dedicated resizable textarea style that preserves the native grip hit area.
|
||||
|
||||
## `ScrollbarOverlay`
|
||||
|
||||
`ScrollbarOverlay` is for areas that already own a scroll node, such as a third-party table or custom viewport. It does not create a new scroll container; it observes the target and paints overlay scrollbars.
|
||||
|
||||
```tsx
|
||||
<div ref={hostRef}>
|
||||
<ThirdPartyTable />
|
||||
<ScrollbarOverlay containerRef={hostRef} targetSelector=".tui-scroll-target" />
|
||||
</div>
|
||||
```
|
||||
|
||||
## `TableScrollRegion`
|
||||
|
||||
`TableScrollRegion` is a convenience wrapper for table scroll areas. The default target selector is `.tui-scroll-target`; Admin Next passes its table viewport selector explicitly so package code does not contain product-specific names.
|
||||
|
||||
```tsx
|
||||
<TableScrollRegion targetSelector=".table-viewport">
|
||||
<EntityTable />
|
||||
</TableScrollRegion>
|
||||
```
|
||||
|
||||
## Accessibility
|
||||
|
||||
- `iconOnly` buttons must provide `tooltip` or `aria-label`.
|
||||
- `TactileSwitch` uses `role="switch"` and `aria-checked`.
|
||||
- Tooltip text is explanatory only; state must still be represented by text, badges, or `aria-*` attributes.
|
||||
- Disabled and loading states set `aria-disabled`; real `button` elements also receive `disabled`.
|
||||
|
||||
## Admin Next Migration Rules
|
||||
|
||||
Admin Next should use Tactile UI for global tool buttons, detail-panel toolbars, and list footer actions:
|
||||
|
||||
- Unambiguous actions: `TactileButton iconOnly tooltip`
|
||||
- Save/create/confirm: `TactileButton variant="primary"`, usually with text
|
||||
- Delete/stop: `TactileButton variant="danger"`, with text only when risk or ambiguity requires it
|
||||
- Switches: `TactileSwitch`
|
||||
- Long lists, tables, logs, and Markdown: `Scrollbar` / `ScrollbarOverlay` / `TableScrollRegion`
|
||||
|
||||
The boundary is deliberate: Tactile UI owns touch feel, size, shadow, tooltip, and scrollbar behavior; feature pages own APIs, state machines, permissions, and copy.
|
||||
@@ -28,8 +28,10 @@
|
||||
- [数据源、采集器设置与连接验证](/home/ray/dev/linkong/planet/docs/technical/zh/datasource-collector-settings-connectivity.md):数据源目录、采集器设置、连接验证、BarentsWatch 凭证链路
|
||||
- [通用位置估算管线开发说明](/home/ray/dev/linkong/planet/docs/technical/zh/location-pipeline-development.md):后端 location resolver / pipeline 的接口、注册表和扩展方式
|
||||
- [Docs Gatekeeper 开发说明](/home/ray/dev/linkong/planet/docs/technical/zh/docs-gatekeeper-development.md):后端 Docs 目录、正文读取和 Gatekeeper 权限组实现
|
||||
- [命名与术语对照](/home/ray/dev/linkong/planet/docs/technical/zh/naming-glossary.md):控制台、Earth、后端和文档常见名词的中英对照
|
||||
- [Earth 可交互图标接入](/home/ray/dev/linkong/planet/docs/technical/zh/earth-interactable-usage.md):Earth 地表可交互图标 `Interactable` 的接口、生命周期和接入示例
|
||||
- [Earth 工具栏与浮层协同](/home/ray/dev/linkong/planet/docs/technical/zh/earth-toolbar-overlay-coordination.md):工具栏按钮与搜索 / 设置 / 新闻 / 图层浮层之间的关闭矩阵和接入规则
|
||||
- [Tactile UI 组件库](/home/ray/dev/linkong/planet/docs/technical/zh/tactile-ui-components.md):可移植按钮、开关、tooltip 和滚动条组件的 API、主题 token 与迁移约定
|
||||
|
||||
不适合放入这里的内容:
|
||||
|
||||
|
||||
@@ -101,6 +101,19 @@ AI 配置页使用的接口:
|
||||
|
||||
这些接口都需要用户登录。`secrets` 接口只用于配置页点击显示 key/token 时取回明文,隐藏时前端恢复为脱敏预览。
|
||||
|
||||
Admin Next 的 AI 页面按旧版信息架构组织为:
|
||||
|
||||
- `模型供应商`
|
||||
- 管理 provider、协议适配、默认模型、LLM API Key、代理地址、代理 token、模型列表刷新、设为默认和轻量连通性测试。
|
||||
- `工具调用`
|
||||
- 管理 WebSearch、OCR 等工具。工具内部先选 provider,再编辑该 provider 的 API、key 和高级参数。
|
||||
- `提示词`
|
||||
- 按 prompt 分组和 task key 编辑系统提示词 / 用户提示词;保存和重置只作用于当前 task。
|
||||
- `Playground`
|
||||
- 使用当前默认 provider 和 prompt 配置发起真实会话;AI 回复使用 Markdown 渲染。
|
||||
|
||||
保存、设为默认和连通性测试是三个独立职责:保存只持久化表单,设为默认只切换默认 provider/tool,连通性测试只验证当前草稿是否可用,不应隐式保存或切换默认项。
|
||||
|
||||
`ai-prompts` 接口用于运维配置页的“提示词”Tab。默认提示词来自后端随发布包携带的版本化资源,业务代码只引用稳定 task key;接口只保存运维覆盖值。重置时删除覆盖值并恢复当前发布包中的缺省提示词。
|
||||
|
||||
### 提示词边界
|
||||
@@ -259,6 +272,34 @@ AI 配置仍保存在 PostgreSQL,不写入 JSON 文件。核心结构如下:
|
||||
|
||||
`.env` 只是兜底。配置页保存或测试连接成功后,PostgreSQL 中的配置会成为全局默认。
|
||||
|
||||
Admin Next 的密钥状态必须按 provider / tool 精确判断:
|
||||
|
||||
- 数据库中当前 provider/tool 有密钥时,显示为“已配置”。
|
||||
- 数据库没有密钥,但 fallback provider、model 或 tool 与当前项匹配时,可以显示 fallback 的脱敏预览。
|
||||
- 数据库没有密钥且 fallback 不匹配当前项时,显示为“未配置”,不能把其它 provider 的 `.env` 通用 key 当成当前项已配置。
|
||||
- 脱敏规则保留 key 第一个 `-` 之前的前缀,例如 `sk-********`;明文显示只在有权限的配置页面内按需触发。
|
||||
|
||||
工具 key 使用同样规则。WebSearch、OCR 这类工具必须先匹配当前工具和 provider,再决定能否使用 fallback。
|
||||
|
||||
### 轻量连通性测试
|
||||
|
||||
Admin Next 的插头按钮走轻量连通性测试,不承担保存职责。业界常见做法是分两层:
|
||||
|
||||
- 快速检查 provider 目录或低成本 endpoint,确认 base URL、鉴权和当前模型是否可达。
|
||||
- 只有在用户明确运行 Playground 或业务任务时才发完整模型请求。
|
||||
|
||||
因此,连通性测试应尽量使用低成本请求,并返回明确状态:
|
||||
|
||||
- `ok`: 鉴权、路由和模型目录可用。
|
||||
- `warning`: 服务可达,但当前模型不在目录或能力声明不完整。
|
||||
- `error`: 鉴权失败、网络失败、协议错误或模型不可用。
|
||||
|
||||
错误 toast 标题必须和结果一致,不能在失败时显示“连通性正常”。
|
||||
|
||||
### OpenCode Go 路由模型
|
||||
|
||||
OpenCode Go 这类订阅通道不要靠前端硬编码模型集合判断协议。推荐在 provider catalog 或后端能力发现中记录每个模型的协议能力,例如 `chat_completions`、`anthropic_messages`、`models_endpoint` 和是否需要订阅 key。前端只展示能力结果;后端负责把 provider、base URL、model 和协议适配映射为实际请求。
|
||||
|
||||
#### 配置页行为
|
||||
|
||||
- Provider 下拉框决定当前默认 provider。
|
||||
|
||||
@@ -228,9 +228,22 @@ if datasource.last_status == "success":
|
||||
|
||||
这个记录用于控制台“采集管理 -> 采集器”中的连接状态判断:如果当前配置和成功采集时的 checksum 一致,就视为已连接,不要求用户再手动点击连接按钮。只有 endpoint、请求头、基础配置或凭证指纹变化时,才需要重新验证。
|
||||
|
||||
### 采集管理与快照
|
||||
|
||||
Admin Next 的采集管理入口按业务层级组织:
|
||||
|
||||
- `采集器`:配置 endpoint、认证方式、请求头、基础参数、启用状态和凭证教程。
|
||||
- `采集调度`:查看和调整调度状态,触发、停止或刷新采集任务。
|
||||
- `采集历史 / 快照`:按采集器聚合展示历史,详情中用快照选择器查看同一采集器的不同版本。
|
||||
|
||||
快照列表不应把同一个采集器的每次快照都拍平成独立主列表项。主列表负责选择采集器,详情区负责时间版本切换。
|
||||
|
||||
凭证教程由 `backend/app/services/credential_guides.py` 维护,控制台通过 read / generate / reset 三个动作读取或生成 Markdown 教程。教程面向运维配置人员,前端应渲染 Markdown 正文,而不是展示生成 prompt 或原始元数据。
|
||||
|
||||
相关实现见:
|
||||
|
||||
- [datasource_connectivity.py](/home/ray/dev/linkong/planet/backend/app/services/datasource_connectivity.py)
|
||||
- [credential_guides.py](/home/ray/dev/linkong/planet/backend/app/services/credential_guides.py)
|
||||
- [数据源、采集器设置与连接验证](/home/ray/dev/linkong/planet/docs/technical/zh/datasource-collector-settings-connectivity.md)
|
||||
|
||||
## 八、相关代码文件
|
||||
|
||||
@@ -32,8 +32,8 @@
|
||||
|
||||
文件:
|
||||
|
||||
- [DataSources.tsx](/home/ray/dev/linkong/planet/frontend/src/pages/DataSources/DataSources.tsx)
|
||||
- [index.css](/home/ray/dev/linkong/planet/frontend/src/index.css)
|
||||
- [PlainResourcePages.tsx](/home/ray/dev/linkong/planet/frontend/src/admin-next/pages/PlainResourcePages.tsx)
|
||||
- [AdminNextRoutes.tsx](/home/ray/dev/linkong/planet/frontend/src/admin-next/AdminNextRoutes.tsx)
|
||||
|
||||
当前行为:
|
||||
|
||||
@@ -53,30 +53,35 @@
|
||||
|
||||
`data-source-bulk-toolbar__running-pill` 是“采集中”标签的样式入口。它和其他状态标签同排,但通过 hover、箭头和蓝色描边表达可交互性。
|
||||
|
||||
### 采集器
|
||||
### 采集管理
|
||||
|
||||
文件:
|
||||
|
||||
- [Settings.tsx](/home/ray/dev/linkong/planet/frontend/src/pages/Settings/Settings.tsx)
|
||||
- [PlainResourcePages.tsx](/home/ray/dev/linkong/planet/frontend/src/admin-next/pages/PlainResourcePages.tsx)
|
||||
|
||||
当前行为:
|
||||
|
||||
- `collector_credentials` tab 在 `/collection-management` 下展示为“采集器”。
|
||||
- 下拉框列出内置采集器,并支持维护合并到内置数据的自定义补充源。
|
||||
- 下拉框右侧只有一个插头图标按钮,用于健康检查。
|
||||
- 下拉框下方用状态标签展示:
|
||||
- `需要凭证` / `无需凭证`
|
||||
- 模块
|
||||
- `启用` / `禁用`
|
||||
- `未检查` / `可用` / `不可用`
|
||||
- 是否覆盖 endpoint
|
||||
- 需要凭证的采集器把凭证卡片放在基础配置上方。
|
||||
- 不需要凭证的采集器只显示基础配置。
|
||||
- `/collection-management` 按旧版层级收敛为 `采集器`、`采集调度`、`采集历史 / 快照`。
|
||||
- `采集器` 是配置页,左侧列表展示采集器配置;右侧表单编辑 endpoint、认证、请求头、采集参数和启用状态。
|
||||
- 新增采集器和目标 Schema 使用草稿详情页,不再用透明 JSON 弹窗;保存后才固化到列表,取消会销毁草稿。
|
||||
- 连接按钮只做连通性测试,不保存配置;保存按钮只持久化表单。
|
||||
- 凭证教程以可拖拽 Markdown 弹窗展示。没有教程时仍打开弹窗并提供生成入口;生成时显示中心等待状态;重置确认层级必须高于教程弹窗。
|
||||
- `采集历史 / 快照` 按采集器聚合。列表不再重复展示同一数据源的所有快照;详情页内部用 Time Capsule / Time Machine 式选择器切换快照版本。
|
||||
- AISStream 采集器使用 WebSocket 语义,状态会显示为连接中、实时接收、重连或停止,不使用固定百分比表达完成度。
|
||||
- 自定义源入口放在采集器设置内,不在数据源目录里重复提供编辑入口;数据源目录只保留总览、运行和只读抽屉。
|
||||
|
||||
连接按钮使用内联 Tabler 风格插头图标,来源语义对应 `plug-connected`,避免继续使用刷新图标表达连接动作。
|
||||
|
||||
### 映射模板和目标 Schema
|
||||
|
||||
映射能力仍属于采集管理,但不是采集器主 tab:
|
||||
|
||||
- `映射模板` 承担 sample payload、AI propose、preview、create/update、activate。
|
||||
- `目标 Schema` 维护可写入目标结构。
|
||||
- `run-mapped`、`stop-mapped`、`stream-status` 负责运行映射后的自定义采集器。
|
||||
|
||||
这些入口在新版中需要表单化,只有高级字段才折叠为 JSON。不要把模板、Schema、运行状态和采集器配置拍平成同一张表。
|
||||
|
||||
## 后端接口
|
||||
|
||||
### 数据源配置列表
|
||||
@@ -140,6 +145,26 @@ POST /api/v1/datasources/configs/builtin/connect
|
||||
- `credential_provider`
|
||||
- `credential_source`
|
||||
|
||||
### 凭证教程
|
||||
|
||||
```http
|
||||
GET /api/v1/datasources/credential-guides/{provider}
|
||||
POST /api/v1/datasources/credential-guides/{provider}/generate
|
||||
POST /api/v1/datasources/credential-guides/{provider}/reset
|
||||
```
|
||||
|
||||
用途:
|
||||
|
||||
- 读取当前 provider 的 Markdown 凭证教程。
|
||||
- 没有教程时,由 AI 根据采集器元数据生成教程。
|
||||
- 重置时恢复后端默认教程。
|
||||
|
||||
前端展示规则:
|
||||
|
||||
- 展示渲染后的 Markdown,不展示后端 prompt 或元数据。
|
||||
- 生成/重置是教程弹窗内部动作,不放在采集器配置主工具栏。
|
||||
- 没有教程也要打开弹窗,让用户能从弹窗里生成教程。
|
||||
|
||||
### BarentsWatch AIS 连接验证
|
||||
|
||||
```http
|
||||
|
||||
@@ -162,6 +162,15 @@ Earth 地表是多层近似同心球,不是单一 mesh。`earth.js` 的基座
|
||||
|
||||
`brand.js` 管理 Earth HUD 品牌资源。默认品牌来自静态资源,运行时覆盖值来自 `/api/v1/earth/brand`,上传的图片通过 `/earth-brand-assets/...` 读取。前端必须把 logo/title 图片和文本 fallback 分开处理:图片加载失败时显示文本标题,文本字段为空时使用后端默认值,避免 HUD 品牌区空白。控制台的 Earth 内容页负责保存和重置品牌配置,Earth 前端只消费结果。
|
||||
|
||||
Admin Next 的 Earth 内容页必须按运行时语义组织这些配置:
|
||||
|
||||
- `品牌标识`:品牌预览应使用与 Earth HUD 左上角一致的深色星空背景、尺寸、间距、logo/title 渲染和文本 fallback,而不是普通表单预览。
|
||||
- `国界精度`:构建边界、刷新状态和恢复默认属于这个分区内部动作,不应放在页面全局工具栏。
|
||||
- `电视直播`:列表同时区分内置源、采集源和自定义源;卡片状态表达启用、停用、新建或错误。内置源不能删除,采集源和自定义源可以删除。新增直播源在点击加号后才进入草稿状态,保存后固化到列表,取消则销毁草稿。
|
||||
- `底图资源`、`图层资源`、`3D 模型`、`新闻锚点策略`:如果后端能力未接入,控制台应明确显示待接入空态,不应混入 TV 或品牌配置。
|
||||
|
||||
TV 预览需要尽量复用 Earth 运行时的直播卡片结构和状态标签,这样控制台看到的内置、直播加载中、播放源、地区、语言等信息与 Earth 中实际显示保持一致。
|
||||
|
||||
其中 Earth 启动加载链现在也拆成了两层:
|
||||
|
||||
- `controls.js`
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
|
||||
- [App.tsx](/home/ray/dev/linkong/planet/frontend/src/App.tsx)
|
||||
|
||||
当前后台相关路由包括:
|
||||
当前正式后台路由已经由 Admin Next 接管:
|
||||
|
||||
- `/admin`
|
||||
- `/users`
|
||||
@@ -37,15 +37,45 @@
|
||||
- `/collection-management`
|
||||
- `/settings`
|
||||
|
||||
这些路径渲染 [AdminNextRoutes.tsx](/home/ray/dev/linkong/planet/frontend/src/admin-next/AdminNextRoutes.tsx),页面清单和菜单元信息来自 [manifest.tsx](/home/ray/dev/linkong/planet/frontend/src/admin-next/routes/manifest.tsx)。`/admin-next/*` 仅作为兼容入口存在,会重定向到上面的正式路径,不再作为并行主入口。
|
||||
|
||||
旧 AntD 控制台保留在 `/legacy/admin/*`,用于对照和回退:
|
||||
|
||||
- `/legacy/admin`
|
||||
- `/legacy/admin/datasources`
|
||||
- `/legacy/admin/data`
|
||||
- `/legacy/admin/collection-management`
|
||||
- `/legacy/admin/earth-content`
|
||||
- `/legacy/admin/ai`
|
||||
- `/legacy/admin/logs`
|
||||
- `/legacy/admin/settings`
|
||||
- `/legacy/admin/users`
|
||||
- `/legacy/admin/bgp`
|
||||
- `/legacy/admin/alerts/*`
|
||||
|
||||
旧页面、`AppLayout`、`antd` 和 `@ant-design/icons` 在 legacy 验收期继续保留。不要在新版 parity 验收前删除这些文件或依赖。
|
||||
|
||||
`/earth` 是独立展示页,不属于控制台骨架。
|
||||
|
||||
## 当前页面骨架
|
||||
|
||||
控制台公共壳层在:
|
||||
正式后台公共壳层在:
|
||||
|
||||
- [AdminNextLayout.tsx](/home/ray/dev/linkong/planet/frontend/src/admin-next/components/layout/AdminNextLayout.tsx)
|
||||
|
||||
职责:
|
||||
|
||||
- 左侧导航、分组折叠和移动端抽屉
|
||||
- 当前账号、版本、退出登录和主题切换
|
||||
- 顶部搜索、面包屑和页面快捷入口
|
||||
- 内容区单屏高度闭合
|
||||
- Admin Next 内部滚动、表格、详情面板和移动端详情视图协调
|
||||
|
||||
旧 AntD legacy 壳层仍在:
|
||||
|
||||
- [AppLayout.tsx](/home/ray/dev/linkong/planet/frontend/src/components/AppLayout/AppLayout.tsx)
|
||||
|
||||
职责:
|
||||
legacy 职责:
|
||||
|
||||
- 左侧导航
|
||||
- 折叠与展开
|
||||
@@ -66,7 +96,19 @@
|
||||
</Layout>
|
||||
```
|
||||
|
||||
后续控制台页面应优先适配这套壳层,而不是重新定义全页高度语义。
|
||||
后续正式控制台页面应优先适配 `AdminNextLayout` 和 Admin Next 页面模式,而不是继续往旧 `AppLayout` 增加新能力。只有维护 `/legacy/admin/*` 时才应修改旧壳层。
|
||||
|
||||
## Admin Next 分区加载策略
|
||||
|
||||
多 tab 页面由 [PlainResourcePages.tsx](/home/ray/dev/linkong/planet/frontend/src/admin-next/pages/PlainResourcePages.tsx) 统一承载当前的管理型和信息型工作台。分区加载规则是:
|
||||
|
||||
- 初次进入页面只请求当前 active tab,不预先拉取所有 tab 的接口。
|
||||
- 用户切换 tab 时懒加载该 tab;已经加载过的 tab 保留在本地 `states` 缓存中,切回时直接复用。
|
||||
- 手动刷新、保存、测试、上传、生成教程等明确动作只刷新当前分区,避免把无关分区的接口一起打出去。
|
||||
- 数据源目录的筛选条件变化会清掉内置源分区缓存,并按新筛选重新请求当前分区。
|
||||
- 顶部 summary 只统计“已加载分区”,不把未访问 tab 误报成异常接口。
|
||||
|
||||
这样做是为了降低 Earth、AI、采集管理等多分区页面的冷启动压力,同时保留 tab 数量、状态和用户切换后的缓存体验。需要全量健康巡检时应走后端健康接口或显式刷新流程,不要依赖页面初始化时顺手拉所有业务接口。
|
||||
|
||||
## 当前共享组件
|
||||
|
||||
@@ -74,7 +116,8 @@
|
||||
|
||||
文件:
|
||||
|
||||
- [Scrollbar.tsx](/home/ray/dev/linkong/planet/frontend/src/components/Scrollbar/Scrollbar.tsx)
|
||||
- [Scrollbar.tsx](/home/ray/dev/linkong/planet/frontend/src/components/tactile-ui/Scrollbar.tsx)
|
||||
- [Tactile UI 组件库](/home/ray/dev/linkong/planet/docs/technical/zh/tactile-ui-components.md)
|
||||
|
||||
用途:
|
||||
|
||||
@@ -91,7 +134,7 @@
|
||||
|
||||
文件:
|
||||
|
||||
- [ScrollbarOverlay.tsx](/home/ray/dev/linkong/planet/frontend/src/components/Scrollbar/ScrollbarOverlay.tsx)
|
||||
- [ScrollbarOverlay.tsx](/home/ray/dev/linkong/planet/frontend/src/components/tactile-ui/ScrollbarOverlay.tsx)
|
||||
|
||||
用途:
|
||||
|
||||
@@ -100,25 +143,42 @@
|
||||
|
||||
当前使用场景:
|
||||
|
||||
- 数据源
|
||||
- 采集数据
|
||||
- 用户管理
|
||||
- 设置页
|
||||
- 告警页
|
||||
- BGP 页面
|
||||
- Admin Next 数据源、采集数据、采集管理、日志、告警和 BGP 页面
|
||||
- 旧 AntD legacy 页面通过兼容封装继续使用共享滚动能力
|
||||
|
||||
### 3. `TableScrollRegion`
|
||||
|
||||
文件:
|
||||
|
||||
- [TableScrollRegion.tsx](/home/ray/dev/linkong/planet/frontend/src/components/Scrollbar/TableScrollRegion.tsx)
|
||||
- [TableScrollRegion.tsx](/home/ray/dev/linkong/planet/frontend/src/components/tactile-ui/TableScrollRegion.tsx)
|
||||
|
||||
用途:
|
||||
|
||||
- 为表格滚动区提供统一包裹层
|
||||
- 后续新表格页优先复用,不要重复写“表格区域 + overlay scrollbar”样板
|
||||
|
||||
### 4. `SegmentedControl`
|
||||
### 4. `TactileButton` / `TactileSwitch` / `ControlGroup`
|
||||
|
||||
文件:
|
||||
|
||||
- [Button.tsx](/home/ray/dev/linkong/planet/frontend/src/components/tactile-ui/Button.tsx)
|
||||
- [Switch.tsx](/home/ray/dev/linkong/planet/frontend/src/components/tactile-ui/Switch.tsx)
|
||||
- [ControlGroup.tsx](/home/ray/dev/linkong/planet/frontend/src/components/tactile-ui/ControlGroup.tsx)
|
||||
|
||||
用途:
|
||||
|
||||
- Admin Next 全局工具按钮和详情页工具按钮
|
||||
- icon-only + tooltip 的普通操作
|
||||
- 保存、创建、确认、删除、停止等强意图操作
|
||||
- 与 Docs 主题滑块一致的紧凑开关
|
||||
|
||||
当前约束:
|
||||
|
||||
- 默认按钮是白色触感按钮,通过外部投影表达轻微立体感
|
||||
- 无歧义动作优先图标 + tooltip;保存这类强意图动作可保留文字
|
||||
- 业务页面通过 props 和 CSS variables 调整,不要直接手写按钮核心样式
|
||||
|
||||
### 5. `SegmentedControl`
|
||||
|
||||
文件:
|
||||
|
||||
@@ -146,7 +206,7 @@
|
||||
- 颜色优先通过 CSS 变量覆盖,避免在业务组件里硬编码主题色
|
||||
- 适合少量互斥选项,不适合用作长列表、导航菜单或表单下拉
|
||||
|
||||
### 5. `MarkdownRenderer`
|
||||
### 6. `MarkdownRenderer`
|
||||
|
||||
文件:
|
||||
|
||||
@@ -165,7 +225,7 @@
|
||||
- 文档内部链接应通过 `transformLink` 转成 `/docs/:slug`
|
||||
- 标题锚点由 `getHeadingId` 注入,避免渲染器自己理解路由状态
|
||||
|
||||
### 6. `ConnectionTestInput`
|
||||
### 7. `ConnectionTestInput`
|
||||
|
||||
文件:
|
||||
|
||||
@@ -183,7 +243,7 @@
|
||||
- 禁用的集成能力必须同时置灰输入框和连接测试按钮
|
||||
- 组件只负责输入框与测试入口组合,不保存业务状态;调用方仍负责表单值、loading、disabled 和连接请求
|
||||
|
||||
### 7. `TableActions`
|
||||
### 8. `TableActions`
|
||||
|
||||
文件:
|
||||
|
||||
|
||||
@@ -0,0 +1,99 @@
|
||||
# 命名与术语对照
|
||||
|
||||
本文约定 Planet 控制台、Earth、后端 API 和文档中的常见名词。新增 UI 文案、接口字段展示、图表标签和文档说明时,优先使用这里的中文名,避免同一页面中出现不必要的中英混合。
|
||||
|
||||
## 使用规则
|
||||
|
||||
- 面向中文界面的可见标签使用“中文显示名”。
|
||||
- API 字段、数据库字段、代码类型和外部品牌名保留英文或 snake_case。
|
||||
- 专有名词第一次出现时可以写成“中文显示名(English Term)”,之后使用中文显示名。
|
||||
- BGP、AI、API、URL、ID、TLE、ASN、GPU、AIS 等行业缩写可保留英文。
|
||||
- 外部服务品牌保留官方英文名,例如 PeeringDB、Space-Track、BarentsWatch、AISStream、GitHub。
|
||||
|
||||
## 核心产品名词
|
||||
|
||||
| English / Key | 中文显示名 | 使用场景 |
|
||||
| --- | --- | --- |
|
||||
| Planet | Planet | 产品名,保留英文 |
|
||||
| Admin Next | 新控制台 | 新版管理端上下文 |
|
||||
| Earth | Earth | 地球可视化产品名,保留英文 |
|
||||
| datasource | 数据源 | API、列表、筛选 |
|
||||
| collector | 采集器 | 采集任务、凭证配置 |
|
||||
| collected data | 采集数据 | 数据列表、统计 |
|
||||
| snapshot | 快照 | 采集历史 |
|
||||
| mapping | 映射 | 采集字段映射 |
|
||||
| target schema | 目标 Schema | 映射目标结构 |
|
||||
| credential | 凭证 | 密钥、账号密码、OAuth 信息 |
|
||||
| secret reveal | 密钥 reveal | 管理员显式查看密钥动作,保留 reveal 表示审计语义 |
|
||||
| AI Provider | AI Provider | 服务名,保留英文 |
|
||||
| tool | 工具 | Web Search、OCR 等工具配置 |
|
||||
| Playground | Playground | 交互调试入口,保留英文 |
|
||||
|
||||
## 数据类型
|
||||
|
||||
| data_type | 中文显示名 | 说明 |
|
||||
| --- | --- | --- |
|
||||
| `supercomputer` | 超算 | TOP500 超算记录 |
|
||||
| `gpu_cluster` | GPU 集群 | Epoch AI GPU 集群 |
|
||||
| `model` | 模型 | Hugging Face 模型 |
|
||||
| `dataset` | 数据集 | Hugging Face 数据集 |
|
||||
| `space` | 空间 | Hugging Face Spaces |
|
||||
| `ixp` | 互联网交换点 | PeeringDB IXP |
|
||||
| `network` | 网络 | PeeringDB 网络 |
|
||||
| `facility` | 设施 | PeeringDB 设施 |
|
||||
| `submarine_cable` | 海底光缆 | 海缆线路 |
|
||||
| `landing_point` | 登陆点 | 海缆登陆点 |
|
||||
| `cable_system` | 海缆系统 | TeleGeography cable system |
|
||||
| `cable_landing_relation` | 海缆登陆关系 | 海缆与登陆点关系 |
|
||||
| `satellite_tle` | 卫星轨道根数 | CelesTrak / Space-Track TLE |
|
||||
| `bgp_rib` | BGP 路由表 | BGP RIB 快照 |
|
||||
| `bgp_update` | BGP 更新 | BGP update 事件 |
|
||||
| `prefix_geography` | 前缀地理位置 | IP 前缀地理位置 |
|
||||
| `vessel_ais` | AIS 船舶 | AIS 船舶观测 |
|
||||
| `vessel` | 船舶 | 聚合后的船舶对象 |
|
||||
| `news_live_stream` | 新闻直播源 | 新闻直播源配置 |
|
||||
| `news_item` | 新闻条目 | 新闻归档条目 |
|
||||
| `device_stats` | 设备统计 | Cloudflare Radar 设备统计 |
|
||||
| `traffic_stats` | 流量统计 | Cloudflare Radar 流量统计 |
|
||||
| `as_stats` | 自治系统统计 | Cloudflare Radar AS 统计 |
|
||||
| `compute_center` | 算力中心 | Earth 聚合展示对象 |
|
||||
| `generic` | 通用数据 | 通用采集输出 |
|
||||
| `generic_records` | 通用记录 | 通用映射输出 |
|
||||
|
||||
## 数据源与外部服务
|
||||
|
||||
| English / Key | 中文显示名 | 说明 |
|
||||
| --- | --- | --- |
|
||||
| TOP500 | TOP500 超算榜单 | 外部榜单名保留 TOP500 |
|
||||
| Epoch AI | Epoch AI GPU 集群 | 外部服务名保留 Epoch AI |
|
||||
| Hugging Face | Hugging Face | 官方品牌名 |
|
||||
| PeeringDB IXP | PeeringDB 交换中心 | IXP 可补充写作“互联网交换点” |
|
||||
| PeeringDB Networks | PeeringDB 网络 | 网络实体 |
|
||||
| PeeringDB Facilities | PeeringDB 设施 | 机房 / 设施 |
|
||||
| Submarine Cables | 海底光缆 | 图表和列表优先用中文 |
|
||||
| Cable Landing Points | 海缆登陆点 | 不是“着陆点” |
|
||||
| CelesTrak TLE | CelesTrak 轨道根数 | TLE 可保留缩写 |
|
||||
| Space-Track TLE | Space-Track 轨道根数 | Space-Track 保留品牌名 |
|
||||
| RIPE RIS Live BGP | RIPE RIS Live BGP | 外部服务名和 BGP 缩写保留英文 |
|
||||
| IPtoASN Prefix Geography | IPtoASN 前缀地理位置 | IPtoASN 保留品牌 / 数据集名 |
|
||||
| OpenGeoFeed Prefix Geography | OpenGeoFeed 前缀地理位置 | OpenGeoFeed 保留品牌名 |
|
||||
| NRO Delegated Prefix Geography | NRO Delegated 前缀地理位置 | NRO Delegated 保留数据集名 |
|
||||
| BarentsWatch AIS Vessels | BarentsWatch AIS 船舶 | BarentsWatch / AIS 保留 |
|
||||
| AISStream Vessels | AISStream 船舶 | AISStream 保留品牌名 |
|
||||
|
||||
## 界面动作与状态
|
||||
|
||||
| English / Key | 中文显示名 | 使用场景 |
|
||||
| --- | --- | --- |
|
||||
| success | 成功 | 状态徽标 |
|
||||
| failed | 失败 | 状态徽标 |
|
||||
| running | 运行中 | 任务状态 |
|
||||
| completed | 已完成 | 任务状态 |
|
||||
| cancelled | 已取消 | 任务状态 |
|
||||
| enabled | 已启用 | 开关状态 |
|
||||
| disabled | 已停用 | 开关状态 |
|
||||
| configured | 已配置 | 凭证 / 集成状态 |
|
||||
| unconfigured | 未配置 | 凭证 / 集成状态 |
|
||||
| refresh | 刷新 | 按钮 |
|
||||
| copy | 复制 | 按钮 |
|
||||
| reveal | reveal | 密钥显示动作,因审计语义保留英文 |
|
||||
@@ -87,8 +87,8 @@
|
||||
持续跟随:
|
||||
|
||||
```bash
|
||||
./planet.sh log -f # 前端: /tmp/planet_frontend.log
|
||||
./planet.sh log -b # 后端: /tmp/planet_backend.log
|
||||
./planet.sh log -f # 前端: ~/.local/state/planet/frontend.log
|
||||
./planet.sh log -b # 后端: ~/.local/state/planet/backend.log
|
||||
./planet.sh log -a # AI Provider: planet_aiprovider 容器日志
|
||||
```
|
||||
|
||||
@@ -234,6 +234,20 @@ bun run build
|
||||
source ~/.zshrc && bun run build
|
||||
```
|
||||
|
||||
开发时继续使用 `bun run dev`,Vite HMR 会在保存源码后刷新浏览器。`bun run build` 只生成 `dist` 产物,不会刷新已经打开的 dev 页面。
|
||||
|
||||
需要看生产包并在构建成功后自动刷新时使用:
|
||||
|
||||
```bash
|
||||
bun run preview:auto
|
||||
```
|
||||
|
||||
只想监听源码并持续构建,不启动预览服务时使用:
|
||||
|
||||
```bash
|
||||
bun run build:watch
|
||||
```
|
||||
|
||||
后端依赖通过 uv 管理:
|
||||
|
||||
```bash
|
||||
|
||||
@@ -0,0 +1,205 @@
|
||||
# Tactile UI 组件库
|
||||
|
||||
Tactile UI 是 Planet 内部抽出的可移植 React 控件层。它来自 Admin Next 的按钮、开关、滚动条和 tooltip 收口,但组件本身不依赖 Admin Next、AntD、Radix、Tailwind 或 `an-*` class。目标是先在仓库内稳定使用,后续可以作为独立 npm 包发布。
|
||||
|
||||
## 设计目标
|
||||
|
||||
- **轻触感**:默认控件使用白色或主题表面、细边框和外部投影,接近 Docs 主题滑块的轻微立体感,不使用大色块或发光效果。
|
||||
- **可移植**:组件 class 使用 `tui-*` 前缀,样式集中在 `frontend/src/components/tactile-ui/styles.css`。
|
||||
- **低依赖**:组件只假设 React/React DOM;图标预设当前使用 `lucide-react`,调用方也可以传自定义 React 节点。
|
||||
- **主题友好**:默认样式通过 CSS variables 暴露,Planet 可以在 Admin Next 或其它页面按主题覆盖 token。
|
||||
- **语义清楚**:无歧义操作优先 icon-only + tooltip;保存、确认、创建、执行这类强意图操作可以保留文字。
|
||||
|
||||
## 导入
|
||||
|
||||
仓库内使用:
|
||||
|
||||
```tsx
|
||||
import { TactileButton, TactileSwitch, ControlGroup } from '@/components/tactile-ui'
|
||||
import '@/components/tactile-ui/styles.css'
|
||||
```
|
||||
|
||||
未来拆包后建议导入形式:
|
||||
|
||||
```tsx
|
||||
import { TactileButton, TactileSwitch } from '@planet/tactile-ui'
|
||||
import '@planet/tactile-ui/styles.css'
|
||||
```
|
||||
|
||||
## 主题 Token
|
||||
|
||||
核心 token 在 CSS 中以 `--tui-*` 暴露。业务主题只需要覆盖变量,不应直接重写组件内部 class。
|
||||
|
||||
```css
|
||||
:root {
|
||||
--tui-surface: #ffffff;
|
||||
--tui-surface-raised-hover: #f8fbff;
|
||||
--tui-border-soft: #d6dfeb;
|
||||
--tui-border-hover: #b8c6d9;
|
||||
--tui-text: #0f172a;
|
||||
--tui-primary: #2563eb;
|
||||
--tui-danger: #dc2626;
|
||||
}
|
||||
|
||||
[data-theme='dark'] {
|
||||
--tui-surface: #111827;
|
||||
--tui-text: #e5edf8;
|
||||
}
|
||||
```
|
||||
|
||||
组件还支持通过 `tactile` prop 传入局部尺寸、圆角、背景、边框和阴影参数。局部参数适合少量特殊按钮;全局视觉应优先走 CSS variables。
|
||||
|
||||
## `TactileButton`
|
||||
|
||||
按钮组件覆盖普通按钮、图标按钮、强意图按钮和链接式按钮。
|
||||
|
||||
常用 props:
|
||||
|
||||
| Prop | 说明 |
|
||||
| --- | --- |
|
||||
| `variant` | `neutral`、`primary`、`danger`、`subtle`、`ghost` |
|
||||
| `size` | `sm`、`md`、`lg`、`icon` |
|
||||
| `shape` | `square`、`pill` |
|
||||
| `icon` | 预设图标名称或自定义 React 节点 |
|
||||
| `iconOnly` | 图标按钮固定尺寸,并要求提供 `tooltip` 或 `aria-label` |
|
||||
| `tooltip` | 通过 portal 渲染,默认避开光标位置 |
|
||||
| `loading` | 禁用按钮并暴露 `aria-disabled` |
|
||||
| `tactile` | 覆盖宽高、圆角、阴影、背景和深色模式变量 |
|
||||
|
||||
```tsx
|
||||
<TactileButton icon="refresh" iconOnly tooltip="刷新" />
|
||||
<TactileButton variant="primary" icon="save">保存</TactileButton>
|
||||
<TactileButton variant="danger" icon="delete" iconOnly tooltip="删除" />
|
||||
```
|
||||
|
||||
`variant="neutral"` 的默认按钮是白色触感按钮。彩色按钮仍应保留外部投影和统一高度,不应在业务 CSS 中手写新的阴影体系。
|
||||
|
||||
## 图标预设
|
||||
|
||||
预设图标由 `tactileIconPresets` 统一维护,业务页面通过语义名称调用,避免每个页面随意选择图标。
|
||||
|
||||
常用语义:
|
||||
|
||||
| 名称 | 用途 |
|
||||
| --- | --- |
|
||||
| `refresh` | 刷新数据 |
|
||||
| `save` | 保存 |
|
||||
| `delete` | 删除 |
|
||||
| `trigger` / `collect` | 触发采集 |
|
||||
| `start` / `play` | 启动 |
|
||||
| `stop` | 停止 |
|
||||
| `connect` / `test` | 连接或连通性测试 |
|
||||
| `guide` | 凭证教程 |
|
||||
| `generate` | AI 生成 |
|
||||
| `reset` | 恢复默认 |
|
||||
| `detail` | 查看详情 |
|
||||
| `copy` | 复制 |
|
||||
| `upload` | 上传 |
|
||||
|
||||
如果预设不足,可以直接传 React 节点:
|
||||
|
||||
```tsx
|
||||
<TactileButton icon={<MyIcon aria-hidden="true" />} iconOnly tooltip="自定义动作" />
|
||||
```
|
||||
|
||||
## `TactileSwitch`
|
||||
|
||||
开关组件用于二元设置。它不是 iOS 风格大开关,而是与 Docs 主题滑块一致的小型轻触感控件。
|
||||
|
||||
```tsx
|
||||
<TactileSwitch
|
||||
checked={enabled}
|
||||
onCheckedChange={setEnabled}
|
||||
label="启用 WebSearch"
|
||||
tooltip="启用 WebSearch"
|
||||
/>
|
||||
```
|
||||
|
||||
文案默认进入 tooltip。需要显示文字时,由调用方在布局中单独放 label,不应把长文案塞进 switch 内部。
|
||||
|
||||
## `ControlGroup`
|
||||
|
||||
`ControlGroup` 用于把一组按钮按统一间距和对齐方式排列。默认没有灰色底座;只有显式传 `withBase` 或 `baseTactile` 时才显示底座。
|
||||
|
||||
```tsx
|
||||
<ControlGroup align="end" gap={8}>
|
||||
<TactileButton icon="refresh" iconOnly tooltip="刷新" />
|
||||
<TactileButton variant="primary" icon="save">保存</TactileButton>
|
||||
</ControlGroup>
|
||||
```
|
||||
|
||||
用于列表底部时,按钮应随着列表滚动出现,而不是固定漂浮在列表中部。用于详情页工具栏时,按钮高度和阴影应由组件默认值统一。
|
||||
|
||||
## `TactileTooltip`
|
||||
|
||||
Tooltip 使用 `createPortal` 挂到 `document.body`,支持 `top`、`right`、`bottom`、`left` 和 collision 修正。默认位置会相对触发元素向右下偏移,避免被鼠标指针挡住。
|
||||
|
||||
```tsx
|
||||
<TactileTooltip label="刷新" anchor={buttonRef.current} open={open} side="bottom" />
|
||||
```
|
||||
|
||||
应用层通常不需要直接使用它,`TactileButton` 和 `TactileSwitch` 已经内置 tooltip。
|
||||
|
||||
## `Scrollbar`
|
||||
|
||||
`Scrollbar` 包裹普通滚动容器。真实滚动仍由内部 viewport 承担,Tactile UI 只提供覆盖式 track/thumb。
|
||||
|
||||
```tsx
|
||||
<Scrollbar axis="both" minThumbSize={28} autoHide>
|
||||
<LongContent />
|
||||
</Scrollbar>
|
||||
```
|
||||
|
||||
常用 props:
|
||||
|
||||
| Prop | 说明 |
|
||||
| --- | --- |
|
||||
| `axis` | `x`、`y`、`both` |
|
||||
| `autoHide` | 非 hover/拖拽时自动弱化 |
|
||||
| `alwaysVisible` | 始终显示滚动条 |
|
||||
| `trackSize` / `thumbSize` | 控制轨道和 thumb 尺寸 |
|
||||
| `inset` / `radius` | 控制贴边距离和圆角 |
|
||||
| `thumbColor` / `trackColor` | 局部颜色覆盖 |
|
||||
| `viewportRef` | 由外部提供真实滚动节点 |
|
||||
|
||||
Textarea 不建议强行套 overlay 滚动条,因为浏览器 resize grip 和文本选择需要原生交互。需要统一外观时,应使用专门的 resizable textarea 样式,让原生 grip 保留可点击区域。
|
||||
|
||||
## `ScrollbarOverlay`
|
||||
|
||||
`ScrollbarOverlay` 适合已经存在滚动节点的区域,例如第三方表格或自定义 viewport。它不会创建新的滚动容器,只会监听目标节点并画覆盖式滚动条。
|
||||
|
||||
```tsx
|
||||
<div ref={hostRef}>
|
||||
<ThirdPartyTable />
|
||||
<ScrollbarOverlay containerRef={hostRef} targetSelector=".tui-scroll-target" />
|
||||
</div>
|
||||
```
|
||||
|
||||
## `TableScrollRegion`
|
||||
|
||||
`TableScrollRegion` 是表格滚动区域的便利封装。默认目标选择器是 `.tui-scroll-target`,Admin Next 会显式传自己的 table viewport selector,避免组件库里出现业务命名。
|
||||
|
||||
```tsx
|
||||
<TableScrollRegion targetSelector=".table-viewport">
|
||||
<EntityTable />
|
||||
</TableScrollRegion>
|
||||
```
|
||||
|
||||
## 可访问性
|
||||
|
||||
- `iconOnly` 按钮必须提供 `tooltip` 或 `aria-label`。
|
||||
- `TactileSwitch` 使用 `role="switch"` 和 `aria-checked`。
|
||||
- tooltip 只是说明,不承担唯一状态表达;状态仍应通过文本、badge 或 `aria-*` 呈现。
|
||||
- 禁用和 loading 状态会设置 `aria-disabled`,button 元素会同步 `disabled`。
|
||||
|
||||
## Admin Next 迁移约定
|
||||
|
||||
Admin Next 中所有全局工具按钮、详情页工具按钮和列表底部动作应使用 Tactile UI:
|
||||
|
||||
- 无歧义动作:`TactileButton iconOnly tooltip`
|
||||
- 保存/创建/确认:`TactileButton variant="primary"`,通常保留文字
|
||||
- 删除/停止:`TactileButton variant="danger"`,根据风险决定是否保留文字
|
||||
- 开关:`TactileSwitch`
|
||||
- 长列表、表格、日志、Markdown:`Scrollbar` / `ScrollbarOverlay` / `TableScrollRegion`
|
||||
|
||||
这样做的边界是:组件负责触感、尺寸、阴影、tooltip 和滚动条行为;业务页面负责 API、状态机、权限和文案。
|
||||
Reference in new issue
Block a user