升级 NUPACK 4.1 并支持混合材料设计

This commit is contained in:
Lihatoo 2026-08-20 16:33:16 +08:00
parent 5daa60a464
commit c6189d857d
33 changed files with 5830 additions and 466 deletions

28
docs/FRONTEND_OPTIONS.md Normal file
View file

@ -0,0 +1,28 @@
# Workbench Frontend Options
## Decision
The current service is a server-rendered, dependency-light HTML/CSS/JavaScript application. The first UI pass keeps that boundary: `service/index.html` still owns the existing calculation payload and result rendering, while `service/static/workspace-refresh.css` owns the workbench presentation layer.
This keeps the account/OIDC flow and calculation API stable, avoids a frontend build pipeline, and makes it possible to replace the shell incrementally later.
## Open-source shells that fit
| Option | License | Fit for this service | Trade-off |
| --- | --- | --- | --- |
| [Tabler](https://tabler.io/) | MIT | Best direct fit. Static CSS/components, strong tables, forms, navigation, and responsive layout. It can be vendored and mounted without changing the Python service. | The existing large result renderer would still need custom components. |
| [CoreUI Free](https://coreui.io/) | MIT | Good if the application grows into a full operations console with user, storage, and admin areas. | More opinionated and heavier than the current single-page workbench. |
| [Apache ECharts](https://echarts.apache.org/) | Apache-2.0 | Good for the result dashboards and concentration/defect charts. | It is a visualization layer, not a complete application shell. |
| [shadcn/ui](https://ui.shadcn.com/) | MIT components | Excellent visual quality for a future React/Next.js rewrite. | Requires introducing a Node build, React, and a new frontend boundary. |
## Recommended migration path
1. Keep `/api/*`, OIDC, duplicate detection, job polling, cancel, and exports unchanged.
2. Vendor Tabler CSS and icons locally; use its shell, tabs, cards, tables, alerts, and progress components.
3. Split the current workbench into three route-level views: `Setup`, `Run`, and `Results`. Each view reads and writes one shared draft object.
4. Move the existing result renderers into isolated modules only after the new shell is stable. The computational payload stays a versioned JSON contract.
5. Add Playwright smoke coverage for authenticated navigation, draft persistence, submit/duplicate confirmation, polling, cancel, and result export.
## Why not replace it in one step?
The current `index.html` contains the complete NUPACK result viewer, structure graph, pair heatmap, design preflight, history, and export behavior. A template can replace the shell quickly, but replacing the whole file at once would risk changing calculation semantics and result interpretation. An incremental shell migration gives the visual improvement immediately and keeps the scientific behavior testable.