線上 Demo: https://elf-express.github.io/DM_NewWeb_React/
現代化的集運管理平台
基於 Next.js 16 + TypeScript + next-intl 構建的現代化集運管理系統。,支持多主題、多語言,完全符合官方最佳實踐。
✅ 帳戶概覽統計 ✅ 包裹入庫管理 ✅ 訂單追蹤查詢
✅ 客服中心 ✅ 快捷操作面板 ✅ 實時數據圖表
src/
├── components/ # UI組件(ui/common/Dashboard)
├── contexts/ # React Context(主題管理)
新集運首頁/
├── app/ # Next.js App Router
│ ├── [locale]/ # 動態語言路由
│ │ ├── layout.tsx # 語言布局
│ │ ├── page.tsx # 首頁
│ │ └── inbound/ # 入庫頁面
│ │ └── page.tsx # 已到站頁面
│ └── layout.tsx # 根布局樣式
✅ 完全符合 React/TypeScript/Vite/i18next 官方標準
✅ 完整的路徑別名配置(@/)
✅ 模組化設計,易於擴展
# 安裝依賴
npm install --legacy-peer-deps
# 開發模式
npm run dev # http://localhost:5173/DM_NewWeb_React/
# 建置
npm run build
# 部署
npm run deploy
git config user.name "你的用戶名"
git config user.email "你的郵箱"
npm run deploy
GitHub 專案 → Settings → Pages → Source 選擇 gh-pages → Save
等待 1-2 分鐘後訪問: https://[用戶名].github.io/[專案名]/
@/ → src/
@/components/ → src/components/
@/types/ → src/types/
@/constants/ → src/constants/
@/utils/ → src/utils/
@/i18n/ → src/i18n/
@/contexts/ → src/contexts/
@/styles/ → src/styles/
import { useTranslation } from 'react-i18next';
function MyComponent() {
const { t, i18n } = useTranslation();
return <h1>{t('common.search')}</h1>;
// 切換語言
i18n.changeLanguage('zh-CN');
}
點擊導航欄的調色盤圖標切換主題,設置會自動保存到 localStorage。
src/styles/globals.css 定義CSS變量src/constants/themes.ts 添加配置ThemeContext 中註冊主題mkdir -p src/features/my-feature/{components,hooks,types}
touch src/features/my-feature/index.tsx
# 開發模式
npm run dev
# 訪問: http://localhost:3000/zh-TW
# 類型檢查
npm run typecheck
# 構建生產版本 (使用生產配置)
npm run build
# 啟動生產服務器
npm run start
# 部署到 GitHub Pages
npm run deploy
最大寬度: max-w-7xl (1280px)
容器內距: px-4 (左右各 16px)
響應式斷點: 2xl 最大 1400px
gap-4 (16px) - 主要區塊之間gap-3 (12px) - 卡片內部元素gap-2 (8px) - 小組件如按鈕內的圖標py-3 (上下 12px)p-4 或 p-6 (16px 或 24px)// 三欄佈局 (桌面版)
<div className="grid gap-4 lg:grid-cols-12">
{/* 左側主內容區 - 8 欄 */}
<div className="lg:col-span-8 space-y-4">
{/* 右側邊欄 - 4 欄 */}
<div className="lg:col-span-4 space-y-4">
</div>
<Card>
<CardHeader>
<CardTitle>標題</CardTitle>
</CardHeader>
<CardContent>
內容區域
</CardContent>
</Card>
bg-whiteborder0.5rem (由 CSS 變量 --radius 控制)p-6, Content p-6 pt-0gap-2 圖標間距<Table> 組件ResponsiveContainer 自適應h-[200px] 或 h-[300px]所有顏色使用 HSL 格式定義在 CSS 變量中:
--primary: 221.2 83.2% 53.3%; /* 主色 */
--secondary: 210 40% 96.1%; /* 次要色 */
--muted: 210 40% 96.1%; /* 柔和色 */
--accent: 210 40% 96.1%; /* 強調色 */
--destructive: 0 84.2% 60.2%; /* 危險色 */
#3b82f6 (藍)#171717 (黑)#a855f7 (紫)#22c55e (綠)#f97316 (橙)#f43f5e (粉)#06b6d4 (青)sm: '640px' // 手機橫屏
md: '768px' // 平板
lg: '1024px' // 筆電
xl: '1280px' // 桌面
2xl: '1400px' // 大屏
// 手機: 單欄
// 桌面: 左右 8:4 分欄
<div className="grid gap-4 lg:grid-cols-12">
<div className="lg:col-span-8">主內容</div>
<div className="lg:col-span-4">側邊欄</div>
</div>
text-2xl font-semibold (24px)text-lg font-semibold (18px)text-sm font-medium (14px)text-base (16px)text-sm text-muted-foreground (14px)text-xs (12px)font-bold (700) - 很少使用font-semibold (600) - 標題、重要內容font-medium (500) - 次標題、標籤font-normal (400) - 正文// 主要按鈕
<Button>操作</Button>
// 次要按鈕
<Button variant="outline">次要操作</Button>
// 幽靈按鈕 (僅圖標)
<Button variant="ghost" size="icon">
<Icon className="h-5 w-5"/>
</Button>
// 帶圖標的按鈕
<Button className="gap-2">
<Icon className="h-4 w-4"/>
文字
</Button>
// 狀態標籤
<Badge variant="secondary">已入庫</Badge>
<Badge variant="default">處理中</Badge>
<Badge variant="destructive">待付款</Badge>
// 搜索框 (帶圖標)
<div className="relative">
<Search className="absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4"/>
<Input className="pl-9" placeholder="搜索"/>
</div>
// 淡入動畫
<motion.div
initial=
animate=
transition=
>
hover:shadow-lg transition-shadow0.2s 或 0.3s<ResponsiveContainer width="100%" height={200}>
<AreaChart data={data}>
<defs>
<linearGradient id="gradient" x1="0" y1="0" x2="0" y2="1">
<stop offset="5%" stopColor={theme.primary} stopOpacity={0.3}/>
<stop offset="95%" stopColor={theme.primary} stopOpacity={0}/>
</linearGradient>
</defs>
<Area
type="monotone"
stroke={theme.primary}
fill="url(#gradient)"
/>
</AreaChart>
</ResponsiveContainer>
truncate 或 line-clamp 防止溢出min-w-[100px] 確保最小寬度gap 系統導航欄高度: auto (py-3 約 60px)
頁面左右邊距: px-4 (16px)
最大內容寬度: max-w-7xl (1280px)
卡片圓角: 0.5rem (8px)
卡片間距: gap-4 (16px)
圖標大小:
- 小: h-4 w-4 (16px)
- 中: h-5 w-5 (20px)
- 大: h-6 w-6 (24px)
按鈕內距: px-4 py-2
輸入框高度: h-10 (40px)
next.config.mjs(無 basePath,middleware 可用)next.config.production.mjs(有 basePath,靜態導出)app/[locale]/ 下創建新路由src/components/ 下創建組件messages/ 中添加翻譯文本'use client' 指令useTranslations() 處理多語言useTheme() 適配主題/inbound)MIT License
Built with ❤️ using Next.js + TypeScript + next-intl