这是一个巴适伙伴企业官网项目
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

2.3 KiB

bashi-website — Migrated to Pure React (Vite + React Router)

The site was migrated from Astro 5 to a pure React SPA (Vite + React Router + Tailwind v4), so every page route is now a real .tsx file as requested.

What changed

  • Removed: all .astro files (src/pages/*.astro, src/pages/en/*.astro, src/layouts/BaseLayout.astro), astro.config.mjs, and scripts/. Zero Astro dependencies remain in package.json.
  • Added: Vite + React Router toolchain, src/main.tsx, src/App.tsx (routes), src/layout/RootLayout.tsx, src/hooks/useClientEffects.ts, src/seo/Seo.tsx, and 8 src/pages/*.tsx route wrappers.
  • Reused unchanged: src/styles/global.css (full BaskBuddy design system), all existing React components (Home/About/Business/Contact/Innovation/Join/Privacy/NotFound/Header/Footer/SiteShell), and the i18n catalogs (zh.ts/en.ts).

Architecture

  • zh at / & /{page}, en at /en/{page}, unknown paths → 404.
  • RootLayout keeps Header/Footer mounted across navigations and replays the page-enter animation on routed content.
  • useClientEffects(pathname) ports the interaction logic that previously lived in Astro's <script>: flip-cards (About ICIDP), scroll-reveal (staggered), stat counters (.stat-value[data-target]), and copy-to-clipboard (Contact). The dead #star-field generation was dropped.
  • Seo recreates the per-page <head> (title, description, canonical, hreflang alternates, OG/Twitter cards, Organization JSON-LD) via direct DOM updates — faithful to the original Astro output.
  • Header mobile menu now uses React useState instead of the old id-based global script toggle.

Verification

  • npm run build → 60 modules transformed, clean dist/.
  • npx tsc --noEmit → 0 type errors.
  • Dev server live at http://localhost:4321 — /, /about, /en/innovation, /en, /privacy and all assets return HTTP 200 (SPA fallback works).

Notes / tradeoffs

  • SPA SEO: meta is set client-side (JS-executing crawlers are fine). For production, configure the host with an SPA fallback (Vite dev/preview already do this).
  • A sandbox safe-delete guard blocks Vite from bulk-clearing node_modules/.vite/deps; resolved by redirecting Vite's cacheDir to the OS temp dir in vite.config.ts.
  • Run: npm run dev (4321) · npm run build · npm run preview.