From 042d03aff7405bc536fe4125ef1e76e45a2a627e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=B3=E4=BD=A9=E5=BA=AD?= Date: Tue, 5 Aug 2025 08:22:44 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BB=BA=E7=AB=8B=E6=AA=94=E6=A1=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitattributes | 2 + .gitignore | 27 + CHATBOT_ANALYSIS.md | 296 + README-ENV.md | 56 + README-SCORING.md | 123 + SOFTWARE_SPECIFICATION.md | 670 ++ app/admin/page.tsx | 7 + app/admin/scoring-form-test/page.tsx | 195 + app/admin/scoring-test/page.tsx | 13 + app/admin/scoring/page.tsx | 13 + app/competition/page.tsx | 572 ++ app/globals.css | 100 + app/judge-scoring/page.tsx | 384 + app/layout.tsx | 33 + app/loading.tsx | 7 + app/page.tsx | 1017 +++ app/register/loading.tsx | 3 + app/register/page.tsx | 408 + components.json | 21 + components/admin/admin-layout.tsx | 476 ++ components/admin/admin-panel.tsx | 39 + components/admin/analytics-dashboard.tsx | 663 ++ components/admin/app-management.tsx | 991 +++ components/admin/competition-management.tsx | 6585 +++++++++++++++++ components/admin/dashboard.tsx | 170 + components/admin/judge-list-dialog.tsx | 99 + components/admin/proposal-management.tsx | 744 ++ components/admin/scoring-link-dialog.tsx | 152 + components/admin/scoring-management.tsx | 857 +++ components/admin/system-settings.tsx | 520 ++ components/admin/team-management.tsx | 855 +++ components/admin/user-management.tsx | 1142 +++ components/app-detail-dialog.tsx | 466 ++ components/app-submission-dialog.tsx | 668 ++ components/auth/activity-records-dialog.tsx | 168 + components/auth/forgot-password-dialog.tsx | 148 + components/auth/login-dialog.tsx | 134 + components/auth/profile-dialog.tsx | 193 + components/auth/register-dialog.tsx | 183 + components/auth/settings-dialog.tsx | 125 + components/auth/user-menu.tsx | 196 + components/chat-bot.tsx | 397 + .../competition/award-detail-dialog.tsx | 661 ++ .../competition/competition-detail-dialog.tsx | 731 ++ .../competition/judge-scoring-dialog.tsx | 261 + .../competition/popularity-rankings.tsx | 779 ++ .../competition/registration-dialog.tsx | 477 ++ components/competition/team-detail-dialog.tsx | 325 + components/favorite-button.tsx | 76 + components/favorites-page.tsx | 129 + components/like-button.tsx | 98 + components/reviews/review-system.tsx | 470 ++ components/theme-provider.tsx | 11 + components/ui/accordion.tsx | 58 + components/ui/alert-dialog.tsx | 141 + components/ui/alert.tsx | 59 + components/ui/aspect-ratio.tsx | 7 + components/ui/avatar.tsx | 50 + components/ui/badge.tsx | 36 + components/ui/breadcrumb.tsx | 115 + components/ui/button.tsx | 56 + components/ui/calendar.tsx | 213 + components/ui/card.tsx | 79 + components/ui/carousel.tsx | 262 + components/ui/chart.tsx | 365 + components/ui/checkbox.tsx | 28 + components/ui/collapsible.tsx | 11 + components/ui/command.tsx | 153 + components/ui/context-menu.tsx | 200 + components/ui/dialog.tsx | 122 + components/ui/drawer.tsx | 118 + components/ui/dropdown-menu.tsx | 200 + components/ui/form.tsx | 178 + components/ui/hover-card.tsx | 29 + components/ui/input-otp.tsx | 71 + components/ui/input.tsx | 22 + components/ui/label.tsx | 26 + components/ui/menubar.tsx | 236 + components/ui/navigation-menu.tsx | 128 + components/ui/pagination.tsx | 117 + components/ui/popover.tsx | 31 + components/ui/progress.tsx | 25 + components/ui/radio-group.tsx | 44 + components/ui/resizable.tsx | 45 + components/ui/scroll-area.tsx | 48 + components/ui/select.tsx | 145 + components/ui/separator.tsx | 22 + components/ui/sheet.tsx | 140 + components/ui/sidebar.tsx | 763 ++ components/ui/skeleton.tsx | 15 + components/ui/slider.tsx | 25 + components/ui/sonner.tsx | 31 + components/ui/switch.tsx | 29 + components/ui/table.tsx | 117 + components/ui/tabs.tsx | 55 + components/ui/textarea.tsx | 21 + components/ui/toast.tsx | 113 + components/ui/toaster.tsx | 24 + components/ui/toggle-group.tsx | 61 + components/ui/toggle.tsx | 45 + components/ui/tooltip.tsx | 30 + components/ui/use-mobile.tsx | 19 + components/ui/use-toast.ts | 194 + contexts/auth-context.tsx | 422 ++ contexts/competition-context.tsx | 720 ++ hooks/use-mobile.tsx | 19 + hooks/use-toast.ts | 188 + lib/utils.ts | 6 + next.config.mjs | 14 + package.json | 71 + pnpm-lock.yaml | 3944 ++++++++++ postcss.config.mjs | 8 + public/placeholder-40x40.png | Bin 0 -> 46959 bytes public/placeholder-logo.png | Bin 0 -> 568 bytes public/placeholder-logo.svg | 1 + public/placeholder-user.jpg | Bin 0 -> 1635 bytes public/placeholder.jpg | Bin 0 -> 1064 bytes public/placeholder.svg | 1 + styles/globals.css | 90 + tailwind.config.ts | 98 + tsconfig.json | 27 + types/competition.ts | 96 + 122 files changed, 34763 insertions(+) create mode 100644 .gitattributes create mode 100644 .gitignore create mode 100644 CHATBOT_ANALYSIS.md create mode 100644 README-ENV.md create mode 100644 README-SCORING.md create mode 100644 SOFTWARE_SPECIFICATION.md create mode 100644 app/admin/page.tsx create mode 100644 app/admin/scoring-form-test/page.tsx create mode 100644 app/admin/scoring-test/page.tsx create mode 100644 app/admin/scoring/page.tsx create mode 100644 app/competition/page.tsx create mode 100644 app/globals.css create mode 100644 app/judge-scoring/page.tsx create mode 100644 app/layout.tsx create mode 100644 app/loading.tsx create mode 100644 app/page.tsx create mode 100644 app/register/loading.tsx create mode 100644 app/register/page.tsx create mode 100644 components.json create mode 100644 components/admin/admin-layout.tsx create mode 100644 components/admin/admin-panel.tsx create mode 100644 components/admin/analytics-dashboard.tsx create mode 100644 components/admin/app-management.tsx create mode 100644 components/admin/competition-management.tsx create mode 100644 components/admin/dashboard.tsx create mode 100644 components/admin/judge-list-dialog.tsx create mode 100644 components/admin/proposal-management.tsx create mode 100644 components/admin/scoring-link-dialog.tsx create mode 100644 components/admin/scoring-management.tsx create mode 100644 components/admin/system-settings.tsx create mode 100644 components/admin/team-management.tsx create mode 100644 components/admin/user-management.tsx create mode 100644 components/app-detail-dialog.tsx create mode 100644 components/app-submission-dialog.tsx create mode 100644 components/auth/activity-records-dialog.tsx create mode 100644 components/auth/forgot-password-dialog.tsx create mode 100644 components/auth/login-dialog.tsx create mode 100644 components/auth/profile-dialog.tsx create mode 100644 components/auth/register-dialog.tsx create mode 100644 components/auth/settings-dialog.tsx create mode 100644 components/auth/user-menu.tsx create mode 100644 components/chat-bot.tsx create mode 100644 components/competition/award-detail-dialog.tsx create mode 100644 components/competition/competition-detail-dialog.tsx create mode 100644 components/competition/judge-scoring-dialog.tsx create mode 100644 components/competition/popularity-rankings.tsx create mode 100644 components/competition/registration-dialog.tsx create mode 100644 components/competition/team-detail-dialog.tsx create mode 100644 components/favorite-button.tsx create mode 100644 components/favorites-page.tsx create mode 100644 components/like-button.tsx create mode 100644 components/reviews/review-system.tsx create mode 100644 components/theme-provider.tsx create mode 100644 components/ui/accordion.tsx create mode 100644 components/ui/alert-dialog.tsx create mode 100644 components/ui/alert.tsx create mode 100644 components/ui/aspect-ratio.tsx create mode 100644 components/ui/avatar.tsx create mode 100644 components/ui/badge.tsx create mode 100644 components/ui/breadcrumb.tsx create mode 100644 components/ui/button.tsx create mode 100644 components/ui/calendar.tsx create mode 100644 components/ui/card.tsx create mode 100644 components/ui/carousel.tsx create mode 100644 components/ui/chart.tsx create mode 100644 components/ui/checkbox.tsx create mode 100644 components/ui/collapsible.tsx create mode 100644 components/ui/command.tsx create mode 100644 components/ui/context-menu.tsx create mode 100644 components/ui/dialog.tsx create mode 100644 components/ui/drawer.tsx create mode 100644 components/ui/dropdown-menu.tsx create mode 100644 components/ui/form.tsx create mode 100644 components/ui/hover-card.tsx create mode 100644 components/ui/input-otp.tsx create mode 100644 components/ui/input.tsx create mode 100644 components/ui/label.tsx create mode 100644 components/ui/menubar.tsx create mode 100644 components/ui/navigation-menu.tsx create mode 100644 components/ui/pagination.tsx create mode 100644 components/ui/popover.tsx create mode 100644 components/ui/progress.tsx create mode 100644 components/ui/radio-group.tsx create mode 100644 components/ui/resizable.tsx create mode 100644 components/ui/scroll-area.tsx create mode 100644 components/ui/select.tsx create mode 100644 components/ui/separator.tsx create mode 100644 components/ui/sheet.tsx create mode 100644 components/ui/sidebar.tsx create mode 100644 components/ui/skeleton.tsx create mode 100644 components/ui/slider.tsx create mode 100644 components/ui/sonner.tsx create mode 100644 components/ui/switch.tsx create mode 100644 components/ui/table.tsx create mode 100644 components/ui/tabs.tsx create mode 100644 components/ui/textarea.tsx create mode 100644 components/ui/toast.tsx create mode 100644 components/ui/toaster.tsx create mode 100644 components/ui/toggle-group.tsx create mode 100644 components/ui/toggle.tsx create mode 100644 components/ui/tooltip.tsx create mode 100644 components/ui/use-mobile.tsx create mode 100644 components/ui/use-toast.ts create mode 100644 contexts/auth-context.tsx create mode 100644 contexts/competition-context.tsx create mode 100644 hooks/use-mobile.tsx create mode 100644 hooks/use-toast.ts create mode 100644 lib/utils.ts create mode 100644 next.config.mjs create mode 100644 package.json create mode 100644 pnpm-lock.yaml create mode 100644 postcss.config.mjs create mode 100644 public/placeholder-40x40.png create mode 100644 public/placeholder-logo.png create mode 100644 public/placeholder-logo.svg create mode 100644 public/placeholder-user.jpg create mode 100644 public/placeholder.jpg create mode 100644 public/placeholder.svg create mode 100644 styles/globals.css create mode 100644 tailwind.config.ts create mode 100644 tsconfig.json create mode 100644 types/competition.ts diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..dfe0770 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,2 @@ +# Auto detect text files and perform LF normalization +* text=auto diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..f650315 --- /dev/null +++ b/.gitignore @@ -0,0 +1,27 @@ +# See https://help.github.com/articles/ignoring-files/ for more about ignoring files. + +# dependencies +/node_modules + +# next.js +/.next/ +/out/ + +# production +/build + +# debug +npm-debug.log* +yarn-debug.log* +yarn-error.log* +.pnpm-debug.log* + +# env files +.env* + +# vercel +.vercel + +# typescript +*.tsbuildinfo +next-env.d.ts \ No newline at end of file diff --git a/CHATBOT_ANALYSIS.md b/CHATBOT_ANALYSIS.md new file mode 100644 index 0000000..468ada2 --- /dev/null +++ b/CHATBOT_ANALYSIS.md @@ -0,0 +1,296 @@ +# AI智能助手 (ChatBot) 組件分析 + +## 1. 組件概述 + +### 1.1 功能定位 +AI智能助手是一個內嵌的聊天機器人組件,為用戶提供即時的系統使用指導和問題解答服務。 + +### 1.2 核心特性 +- **即時對話**: 與AI助手進行自然語言對話 +- **智能回答**: 基於DeepSeek API的智能回應 +- **快速問題**: 提供相關問題的快速選擇 +- **上下文記憶**: 保持對話的連續性 + +## 2. 技術實現 + +### 2.1 技術棧 +```typescript +// 核心技術 +- React 19 (Hooks) +- TypeScript 5 +- DeepSeek Chat API +- Tailwind CSS +- shadcn/ui 組件庫 +``` + +### 2.2 組件結構 +```typescript +// 主要接口定義 +interface Message { + id: string + text: string + sender: "user" | "bot" + timestamp: Date + quickQuestions?: string[] +} + +// 組件狀態 +const [isOpen, setIsOpen] = useState(false) // 對話框開關 +const [messages, setMessages] = useState() // 訊息列表 +const [inputValue, setInputValue] = useState("") // 輸入值 +const [isTyping, setIsTyping] = useState(false) // 打字狀態 +const [isLoading, setIsLoading] = useState(false) // 載入狀態 +``` + +### 2.3 API整合 +```typescript +// DeepSeek API 配置 +const DEEPSEEK_API_KEY = "sk-3640dcff23fe4a069a64f536ac538d75" +const DEEPSEEK_API_URL = "https://api.deepseek.com/v1/chat/completions" + +// API 調用函數 +const callDeepSeekAPI = async (userMessage: string): Promise => { + // 實現細節... +} +``` + +## 3. 功能詳解 + +### 3.1 對話能力 + +#### 3.1.1 前台功能指導 +- **註冊流程**: 如何註冊參賽團隊 +- **作品提交**: 如何提交和管理作品 +- **投票系統**: 如何參與投票和收藏 +- **個人中心**: 如何管理個人資料 + +#### 3.1.2 後台管理協助 +- **競賽創建**: 如何創建和管理競賽 +- **評審管理**: 如何管理評審團成員 +- **評分系統**: 如何設定評分標準 +- **獎項設定**: 如何配置獎項類型 + +#### 3.1.3 系統使用指南 +- **操作步驟**: 提供具體的操作指引 +- **常見問題**: 解答用戶常見疑問 +- **最佳實踐**: 推薦最佳使用方法 + +### 3.2 智能特性 + +#### 3.2.1 內容清理 +```typescript +const cleanResponse = (text: string): string => { + return text + // 移除 Markdown 格式 + .replace(/\*\*(.*?)\*\*/g, '$1') + .replace(/\*(.*?)\*/g, '$1') + .replace(/`(.*?)`/g, '$1') + .replace(/#{1,6}\s/g, '') + .replace(/^- /g, '• ') + .replace(/^\d+\.\s/g, '') + // 移除多餘空行 + .replace(/\n\s*\n\s*\n/g, '\n\n') + // 限制文字長度 + .slice(0, 300) + .trim() +} +``` + +#### 3.2.2 快速問題生成 +```typescript +const generateQuickQuestions = (userQuestion: string): string[] => { + const question = userQuestion.toLowerCase() + + // 根據問題類型生成相關建議 + if (question.includes('註冊') || question.includes('團隊')) { + return [ + "如何提交作品?", + "怎麼查看競賽詳情?", + "如何收藏作品?", + "怎麼進行投票?" + ] + } + // 更多邏輯... +} +``` + +### 3.3 用戶體驗 + +#### 3.3.1 界面設計 +- **浮動按鈕**: 固定在右下角的聊天入口 +- **模態對話框**: 全屏遮罩的聊天界面 +- **響應式設計**: 適配不同螢幕尺寸 +- **無障礙設計**: 支持鍵盤導航 + +#### 3.3.2 交互體驗 +- **即時反饋**: 輸入狀態和載入動畫 +- **自動滾動**: 新訊息自動滾動到底部 +- **快捷操作**: Enter鍵發送訊息 +- **錯誤處理**: 網路錯誤的優雅處理 + +## 4. 系統提示詞 (System Prompt) + +### 4.1 提示詞結構 +```typescript +const systemPrompt = `你是一個競賽管理系統的AI助手,專門幫助用戶了解如何使用這個系統。 + +系統功能包括: + +後台管理功能: +1. 競賽管理 - 創建、編輯、刪除競賽 +2. 評審管理 - 管理評審團成員 +3. 評分系統 - 手動輸入評分或讓評審自行評分 +4. 團隊管理 - 管理參賽團隊 +5. 獎項管理 - 設定各種獎項 +6. 評審連結 - 提供評審登入連結 + +前台功能: +1. 競賽瀏覽 - 查看所有競賽資訊和詳細內容 +2. 團隊註冊 - 如何註冊參賽團隊和提交作品 +3. 作品展示 - 瀏覽參賽作品和投票功能 +4. 排行榜 - 查看人氣排行榜和得獎名單 +5. 個人中心 - 管理個人資料和參賽記錄 +6. 收藏功能 - 如何收藏喜歡的作品 +7. 評論系統 - 如何對作品進行評論和互動 +8. 搜尋功能 - 如何搜尋特定競賽或作品 +9. 通知系統 - 查看競賽更新和個人通知 +10. 幫助中心 - 常見問題和使用指南 + +請用友善、專業的語氣回答用戶問題,並提供具體的操作步驟。回答要簡潔明瞭,避免過長的文字。 + +重要:請不要使用任何Markdown格式,只使用純文字回答。不要使用**、*、#、-等符號。 + +回答時請使用繁體中文。` +``` + +### 4.2 回答規範 +- **語言**: 繁體中文 +- **格式**: 純文字,無Markdown +- **長度**: 限制在300字以內 +- **語氣**: 友善、專業 +- **內容**: 具體操作步驟 + +## 5. 錯誤處理 + +### 5.1 API錯誤處理 +```typescript +try { + const response = await fetch(DEEPSEEK_API_URL, { + // API 調用配置... + }) + + if (!response.ok) { + throw new Error(`API request failed: ${response.status}`) + } + + const data = await response.json() + return cleanResponse(data.choices[0]?.message?.content || "抱歉,我現在無法回答您的問題,請稍後再試。") +} catch (error) { + console.error("DeepSeek API error:", error) + return "抱歉,我現在無法連接到AI服務,請檢查網路連接或稍後再試。" +} +``` + +### 5.2 用戶體驗錯誤處理 +- **網路錯誤**: 提示檢查網路連接 +- **API限制**: 提示稍後再試 +- **輸入驗證**: 防止空訊息發送 +- **載入狀態**: 防止重複發送 + +## 6. 性能優化 + +### 6.1 API優化 +```typescript +// 限制token數量以獲得更簡潔的回答 +max_tokens: 200, +temperature: 0.7 +``` + +### 6.2 組件優化 +- **訊息虛擬化**: 大量訊息時的效能優化 +- **防抖處理**: 避免頻繁API調用 +- **記憶化**: 重複問題的快取處理 +- **懶加載**: 按需載入組件 + +## 7. 安全考量 + +### 7.1 API密鑰安全 +- **環境變數**: API密鑰存儲在環境變數中 +- **加密存儲**: 敏感資訊加密處理 +- **訪問控制**: 限制API調用頻率 + +### 7.2 數據隱私 +- **聊天記錄**: 本地存儲,不上傳服務器 +- **個人資訊**: 不收集敏感個人資訊 +- **數據清理**: 定期清理過期數據 + +## 8. 擴展性設計 + +### 8.1 多語言支持 +```typescript +interface LocalizationConfig { + language: string + systemPrompt: Record + quickQuestions: Record + errorMessages: Record +} +``` + +### 8.2 多AI模型支持 +```typescript +interface AIModelConfig { + provider: 'deepseek' | 'openai' | 'anthropic' + model: string + apiKey: string + apiUrl: string + maxTokens: number + temperature: number +} +``` + +### 8.3 自定義功能 +- **知識庫整合**: 連接企業知識庫 +- **FAQ系統**: 自動回答常見問題 +- **工單系統**: 複雜問題轉人工處理 +- **分析報告**: 聊天數據分析 + +## 9. 使用指南 + +### 9.1 基本使用 +1. 點擊右下角的聊天按鈕 +2. 在輸入框中輸入問題 +3. 按Enter鍵或點擊發送按鈕 +4. 查看AI助手的回答 +5. 點擊快速問題進行後續對話 + +### 9.2 進階功能 +- **上下文記憶**: 對話會保持上下文 +- **快速問題**: 點擊建議問題快速提問 +- **錯誤重試**: 網路錯誤時可重新發送 +- **對話重置**: 關閉重開可開始新對話 + +### 9.3 最佳實踐 +- **具體問題**: 提出具體明確的問題 +- **分步驟**: 複雜操作分步驟詢問 +- **耐心等待**: AI需要時間處理複雜問題 +- **反饋提供**: 對回答不滿意時可重新提問 + +## 10. 未來規劃 + +### 10.1 短期目標 +- [ ] 添加語音輸入功能 +- [ ] 支持圖片上傳和識別 +- [ ] 增加更多快速問題模板 +- [ ] 優化回答品質和速度 + +### 10.2 長期目標 +- [ ] 整合企業知識庫 +- [ ] 支持多語言對話 +- [ ] 添加情感分析功能 +- [ ] 實現智能推薦系統 + +--- + +**文檔版本**: v1.0 +**最後更新**: 2024年12月 +**負責人**: 前端開發團隊 \ No newline at end of file diff --git a/README-ENV.md b/README-ENV.md new file mode 100644 index 0000000..2f427c2 --- /dev/null +++ b/README-ENV.md @@ -0,0 +1,56 @@ +# 環境變數設定說明 + +## DeepSeek API 設定 + +本專案使用 DeepSeek API 作為聊天機器人的 AI 服務。請按照以下步驟設定環境變數: + +### 1. 創建環境變數檔案 + +在專案根目錄創建 `.env.local` 檔案: + +```bash +# DeepSeek API Configuration +NEXT_PUBLIC_DEEPSEEK_API_KEY=your_deepseek_api_key_here +NEXT_PUBLIC_DEEPSEEK_API_URL=https://api.deepseek.com/v1/chat/completions +``` + +### 2. 取得 DeepSeek API 金鑰 + +1. 前往 [DeepSeek 官網](https://platform.deepseek.com/) +2. 註冊或登入帳號 +3. 在控制台中生成 API 金鑰 +4. 將金鑰複製到 `.env.local` 檔案中的 `NEXT_PUBLIC_DEEPSEEK_API_KEY` + +### 3. 環境變數說明 + +- `NEXT_PUBLIC_DEEPSEEK_API_KEY`: DeepSeek API 金鑰 +- `NEXT_PUBLIC_DEEPSEEK_API_URL`: DeepSeek API 端點 URL + +### 4. 安全注意事項 + +- `.env.local` 檔案已加入 `.gitignore`,不會被提交到版本控制 +- 請勿將 API 金鑰分享給他人 +- 在生產環境中,請使用更安全的環境變數管理方式 + +### 5. 重新啟動開發伺服器 + +設定完成後,請重新啟動開發伺服器: + +```bash +npm run dev +# 或 +pnpm dev +``` + +### 6. 驗證設定 + +聊天機器人應該能夠正常運作,並能夠回答用戶問題。 + +## 故障排除 + +如果聊天機器人無法運作: + +1. 確認 `.env.local` 檔案存在且格式正確 +2. 確認 API 金鑰有效且未過期 +3. 檢查網路連接是否正常 +4. 查看瀏覽器開發者工具中的錯誤訊息 \ No newline at end of file diff --git a/README-SCORING.md b/README-SCORING.md new file mode 100644 index 0000000..4c25e4e --- /dev/null +++ b/README-SCORING.md @@ -0,0 +1,123 @@ +# 評分管理功能 + +## 功能概述 + +後台評分管理系統提供了完整的評分管理功能,包括: + +- 查看已完成和未完成的評分內容 +- 手動輸入和編輯評分 +- 評分進度追蹤 +- 篩選和搜尋功能 + +## 主要功能 + +### 1. 競賽選擇 +- 從下拉選單中選擇要管理的競賽 +- 顯示競賽基本資訊(名稱、類型、時間等) + +### 2. 評分概覽 +- **已完成評分**:顯示已完成的評分數量 +- **待評分**:顯示待評分的數量 +- **完成度**:顯示評分進度的百分比 +- **總評分項目**:顯示總評分項目數量 +- 進度條:視覺化顯示評分進度 + +### 3. 評分記錄管理 +- **評審**:顯示評審姓名和頭像 +- **參賽者**:顯示參賽者名稱和類型(個人/團隊) +- **類型**:標示參賽者類型 +- **總分**:顯示評分總分 +- **狀態**:顯示評分狀態(已完成/待評分) +- **提交時間**:顯示評分提交時間 +- **操作**:編輯或新增評分 + +### 4. 篩選和搜尋 +- **狀態篩選**:按評分狀態篩選(全部/已完成/待評分) +- **搜尋功能**:搜尋評審或參賽者名稱 +- **分頁功能**:支援大量數據的分頁顯示 + +### 5. 動態評分功能 +- **評審選擇**:從評審列表中選擇評審 +- **參賽者選擇**:從參賽者列表中選擇參賽者 +- **動態評分項目**:根據競賽建立時設定的評比規則動態生成評分項目 +- **權重計算**:支援不同評分項目的權重設定 +- **評分驗證**:確保所有評分項目都已評分 +- **總分計算**:根據權重自動計算總分 +- **評審意見**:填寫評審意見和建議 +- **評分提交**:提交或更新評分 + +## 使用方式 + +### 訪問評分管理 +1. 進入後台管理系統 +2. 點擊「評分管理」標籤 +3. 選擇要管理的競賽 + +### 查看評分記錄 +1. 選擇競賽後,系統會自動載入該競賽的所有評分記錄 +2. 使用篩選功能查看特定狀態的評分 +3. 使用搜尋功能快速找到特定評審或參賽者的評分 + +### 動態評分輸入 +1. 點擊「手動輸入評分」按鈕 +2. 選擇評審和參賽者 +3. 根據競賽設定的評比項目進行評分 +4. 為每個評分項目選擇分數(1-10分) +5. 系統會根據權重自動計算總分 +6. 填寫評審意見 +7. 點擊「提交評分」完成評分 + +### 編輯現有評分 +1. 在評分記錄表格中點擊編輯按鈕 +2. 修改評審意見 +3. 點擊「更新評分」保存修改 + +## 技術實現 + +### 組件結構 +- `ScoringManagement`:主要評分管理組件 +- 整合到現有的 `CompetitionManagement` 組件中 + +### 動態評分系統 +- **評比規則讀取**:從競賽的 `rules` 屬性讀取評比項目 +- **動態評分項目生成**:根據競賽規則動態生成評分表單 +- **權重計算**:支援不同評分項目的權重設定 +- **評分驗證**:確保所有評分項目都已評分 +- **總分計算**:根據權重自動計算總分 + +### 數據流 +1. 從 `useCompetition` 上下文獲取競賽和評分數據 +2. 根據選擇的競賽載入相關的評審和參賽者 +3. 讀取競賽的評比規則並動態生成評分項目 +4. 生成評分記錄列表 +5. 支援篩選、搜尋和分頁功能 + +### 狀態管理 +- 使用 React hooks 管理組件狀態 +- 整合現有的競賽上下文 +- 支援即時數據更新 +- 動態評分項目的狀態管理 + +## 文件結構 + +``` +components/admin/ +├── scoring-management.tsx # 評分管理組件 +└── competition-management.tsx # 競賽管理組件(已整合) + +app/admin/ +└── scoring/ + └── page.tsx # 評分管理頁面 +``` + +## 注意事項 + +1. 評分記錄會根據競賽的評審和參賽者自動生成 +2. 已完成的評分可以編輯,未完成的評分可以新增 +3. 評分提交後會即時更新列表 +4. 支援個人賽和團隊賽的評分管理 +5. 評分數據與現有的競賽管理系統完全整合 +6. 評分項目會根據競賽建立時設定的評比規則動態生成 +7. 如果競賽沒有設定評比規則,會使用預設的評分項目 +8. 總分會根據各評分項目的權重自動計算 +9. 系統會驗證所有評分項目都已評分才能提交 \ No newline at end of file diff --git a/SOFTWARE_SPECIFICATION.md b/SOFTWARE_SPECIFICATION.md new file mode 100644 index 0000000..f635771 --- /dev/null +++ b/SOFTWARE_SPECIFICATION.md @@ -0,0 +1,670 @@ +# AI展示平台軟體規格書 + +## 1. 專案概述 + +### 1.1 專案名稱 +AI展示平台 (AI Showcase Platform) + +### 1.2 專案目標 +建立一個企業內部的AI應用展示、競賽管理和評審系統,促進AI技術的創新與應用。 + +### 1.3 專案範圍 +- 用戶認證與權限管理 +- AI應用展示與管理 +- 競賽系統與評審流程 +- 團隊協作與提案管理 +- 數據分析與報表生成 +- 管理員後台系統 +- AI智能助手系統 + +## 2. 系統架構 + +### 2.1 技術棧 + +#### 前端技術 +- **框架**: Next.js 15.2.4 (App Router) +- **語言**: TypeScript 5 +- **UI庫**: + - Radix UI (無障礙組件) + - shadcn/ui (設計系統) + - Tailwind CSS (樣式框架) +- **狀態管理**: React Context API +- **表單處理**: React Hook Form + Zod +- **圖表**: Recharts +- **包管理器**: pnpm + +#### 開發工具 +- **代碼品質**: ESLint + TypeScript +- **樣式處理**: PostCSS + Tailwind CSS +- **圖標**: Lucide React +- **版本控制**: Git + +### 2.2 目錄結構 +``` +ai-showcase-platform/ +├── app/ # Next.js App Router +│ ├── admin/ # 管理員頁面 +│ ├── competition/ # 競賽頁面 +│ ├── judge-scoring/ # 評審評分頁面 +│ ├── register/ # 註冊頁面 +│ └── globals.css # 全域樣式 +├── components/ # React 組件 +│ ├── admin/ # 管理員專用組件 +│ ├── auth/ # 認證相關組件 +│ ├── competition/ # 競賽相關組件 +│ ├── reviews/ # 評論系統組件 +│ ├── chat-bot.tsx # AI智能助手組件 +│ └── ui/ # 通用UI組件 +├── contexts/ # React Context +│ ├── auth-context.tsx # 認證狀態管理 +│ └── competition-context.tsx # 競賽狀態管理 +├── hooks/ # 自定義 Hooks +├── lib/ # 工具函數 +├── types/ # TypeScript 類型定義 +└── public/ # 靜態資源 +``` + +## 3. 功能需求 + +### 3.1 用戶管理系統 + +#### 3.1.1 用戶角色 +- **一般用戶 (user)**: 瀏覽應用、參與投票 +- **開發者 (developer)**: 提交AI應用、參與競賽 +- **管理員 (admin)**: 系統管理、數據分析 + +#### 3.1.2 用戶功能 +- 註冊/登入/登出 +- 個人資料管理 +- 收藏應用 +- 按讚功能 (每日限制) +- 瀏覽記錄 +- 權限控制 + +### 3.2 競賽系統 + +#### 3.2.1 競賽類型 +- **個人賽 (individual)**: 個人開發者競賽 +- **團隊賽 (team)**: 團隊協作競賽 +- **提案賽 (proposal)**: 創新提案競賽 +- **混合賽 (mixed)**: 綜合性競賽 + +#### 3.2.2 競賽狀態 +- **upcoming**: 即將開始 +- **active**: 進行中 +- **judging**: 評審中 +- **completed**: 已完成 + +#### 3.2.3 評審系統 +- 多維度評分 (創新性、技術性、實用性、展示效果、影響力) +- 評審管理 +- 分數統計與排名 +- 評審意見記錄 + +### 3.3 獎項系統 + +#### 3.3.1 獎項類型 +- **金獎/銀獎/銅獎**: 排名獎項 +- **最佳創新獎**: 創新性獎項 +- **最佳技術獎**: 技術實現獎項 +- **人氣獎**: 受歡迎程度獎項 +- **自定義獎項**: 可配置的獎項 + +#### 3.3.2 獎項分類 +- **innovation**: 創新類 +- **technical**: 技術類 +- **practical**: 實用類 +- **popular**: 人氣類 +- **teamwork**: 團隊協作類 +- **solution**: 解決方案類 +- **creativity**: 創意類 + +### 3.4 管理員系統 + +#### 3.4.1 用戶管理 +- 用戶列表查看 +- 用戶權限管理 +- 用戶資料編輯 +- 用戶統計分析 + +#### 3.4.2 競賽管理 +- 競賽創建與編輯 +- 競賽狀態管理 +- 參賽者管理 +- 評審分配 + +#### 3.4.3 評審管理 +- 評審帳號管理 +- 評審分配 +- 評分進度追蹤 +- 評審意見管理 + +#### 3.4.4 數據分析 +- 競賽統計 +- 用戶活躍度分析 +- 應用熱度分析 +- 評分趨勢分析 + +### 3.5 AI智能助手系統 + +#### 3.5.1 核心功能 +- **即時對話**: 與AI助手進行自然語言對話 +- **智能回答**: 基於DeepSeek API的智能回應 +- **快速問題**: 提供相關問題的快速選擇 +- **上下文記憶**: 保持對話的連續性 + +#### 3.5.2 對話能力 +- **前台功能指導**: 註冊、提交作品、投票、收藏等 +- **後台管理協助**: 競賽創建、評審管理、評分系統等 +- **系統使用指南**: 提供具體的操作步驟 +- **問題分類處理**: 根據問題類型提供相關建議 + +#### 3.5.3 用戶體驗 +- **浮動按鈕**: 固定在右下角的聊天入口 +- **模態對話框**: 全屏遮罩的聊天界面 +- **即時反饋**: 輸入狀態和載入動畫 +- **響應式設計**: 適配不同螢幕尺寸 + +#### 3.5.4 技術特性 +- **API整合**: 與DeepSeek Chat API無縫整合 +- **內容清理**: 自動清理Markdown格式和過長文字 +- **錯誤處理**: 網路錯誤和API錯誤的優雅處理 +- **性能優化**: 限制token數量以獲得更簡潔的回答 + +## 4. 數據模型 + +### 4.1 用戶模型 +```typescript +interface User { + id: string + name: string + email: string + avatar?: string + department: string + role: "user" | "developer" | "admin" + joinDate: string + favoriteApps: string[] + recentApps: string[] + totalLikes: number + totalViews: number +} +``` + +### 4.2 競賽模型 +```typescript +interface Competition { + id: string + name: string + year: number + month: number + startDate: string + endDate: string + status: "upcoming" | "active" | "judging" | "completed" + description: string + type: "individual" | "team" | "mixed" | "proposal" + judges: string[] + participatingApps: string[] + participatingTeams: string[] + participatingProposals: string[] + rules: CompetitionRule[] + awardTypes: CompetitionAwardType[] + evaluationFocus: string + maxTeamSize?: number +} +``` + +### 4.3 評審模型 +```typescript +interface Judge { + id: string + name: string + title: string + department: string + expertise: string[] + avatar?: string +} + +interface JudgeScore { + judgeId: string + appId: string + scores: { + innovation: number + technical: number + usability: number + presentation: number + impact: number + } + comments: string + submittedAt: string +} +``` + +### 4.4 團隊模型 +```typescript +interface TeamMember { + id: string + name: string + department: string + role: string +} + +interface Team { + id: string + name: string + members: TeamMember[] + leader: string + department: string + contactEmail: string + apps: string[] + totalLikes: number +} +``` + +### 4.5 獎項模型 +```typescript +interface Award { + id: string + competitionId: string + appId?: string + teamId?: string + proposalId?: string + appName?: string + teamName?: string + proposalTitle?: string + creator: string + awardType: "gold" | "silver" | "bronze" | "popular" | "innovation" | "technical" | "custom" + awardName: string + score: number + year: number + month: number + icon: string + customAwardTypeId?: string + competitionType: "individual" | "team" | "proposal" + rank: number + category: "innovation" | "technical" | "practical" | "popular" | "teamwork" | "solution" | "creativity" +} +``` + +### 4.6 AI助手模型 +```typescript +interface Message { + id: string + text: string + sender: "user" | "bot" + timestamp: Date + quickQuestions?: string[] +} + +interface ChatSession { + id: string + userId: string + messages: Message[] + createdAt: Date + updatedAt: Date +} + +interface AIAssistantConfig { + apiKey: string + apiUrl: string + model: string + maxTokens: number + temperature: number + systemPrompt: string +} +``` + +## 5. API 設計 + +### 5.1 認證 API +``` +POST /api/auth/login # 用戶登入 +POST /api/auth/register # 用戶註冊 +POST /api/auth/logout # 用戶登出 +GET /api/auth/profile # 獲取用戶資料 +PUT /api/auth/profile # 更新用戶資料 +``` + +### 5.2 競賽 API +``` +GET /api/competitions # 獲取競賽列表 +POST /api/competitions # 創建競賽 +GET /api/competitions/:id # 獲取競賽詳情 +PUT /api/competitions/:id # 更新競賽 +DELETE /api/competitions/:id # 刪除競賽 +GET /api/competitions/:id/scores # 獲取競賽評分 +POST /api/competitions/:id/scores # 提交評分 +``` + +### 5.3 用戶 API +``` +GET /api/users # 獲取用戶列表 +GET /api/users/:id # 獲取用戶詳情 +PUT /api/users/:id # 更新用戶資料 +DELETE /api/users/:id # 刪除用戶 +GET /api/users/:id/apps # 獲取用戶應用 +GET /api/users/:id/teams # 獲取用戶團隊 +``` + +### 5.4 評審 API +``` +GET /api/judges # 獲取評審列表 +POST /api/judges # 創建評審帳號 +GET /api/judges/:id # 獲取評審詳情 +PUT /api/judges/:id # 更新評審資料 +DELETE /api/judges/:id # 刪除評審 +GET /api/judges/:id/scores # 獲取評審評分 +POST /api/judges/:id/scores # 提交評審評分 +``` + +### 5.5 團隊 API +``` +GET /api/teams # 獲取團隊列表 +POST /api/teams # 創建團隊 +GET /api/teams/:id # 獲取團隊詳情 +PUT /api/teams/:id # 更新團隊資料 +DELETE /api/teams/:id # 刪除團隊 +GET /api/teams/:id/members # 獲取團隊成員 +POST /api/teams/:id/members # 添加團隊成員 +``` + +### 5.6 獎項 API +``` +GET /api/awards # 獲取獎項列表 +POST /api/awards # 創建獎項 +GET /api/awards/:id # 獲取獎項詳情 +PUT /api/awards/:id # 更新獎項 +DELETE /api/awards/:id # 刪除獎項 +GET /api/awards/by-year/:year # 按年份獲取獎項 +GET /api/awards/by-type/:type # 按類型獲取獎項 +``` + +### 5.7 AI助手 API +``` +POST /api/chat/send # 發送聊天訊息 +GET /api/chat/history # 獲取聊天歷史 +DELETE /api/chat/history # 清除聊天歷史 +POST /api/chat/feedback # 提交聊天反饋 +GET /api/chat/quick-questions # 獲取快速問題建議 +``` + +## 6. 數據庫設計 + +### 6.1 用戶表 (users) +```sql +CREATE TABLE users ( + id VARCHAR(36) PRIMARY KEY, + name VARCHAR(100) NOT NULL, + email VARCHAR(255) UNIQUE NOT NULL, + password_hash VARCHAR(255) NOT NULL, + avatar VARCHAR(500), + department VARCHAR(100) NOT NULL, + role ENUM('user', 'developer', 'admin') DEFAULT 'user', + join_date DATE NOT NULL, + total_likes INT DEFAULT 0, + total_views INT DEFAULT 0, + created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, + updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP +); +``` + +### 6.2 競賽表 (competitions) +```sql +CREATE TABLE competitions ( + id VARCHAR(36) PRIMARY KEY, + name VARCHAR(200) NOT NULL, + year INT NOT NULL, + month INT NOT NULL, + start_date DATE NOT NULL, + end_date DATE NOT NULL, + status ENUM('upcoming', 'active', 'judging', 'completed') DEFAULT 'upcoming', + description TEXT, + type ENUM('individual', 'team', 'mixed', 'proposal') NOT NULL, + evaluation_focus TEXT, + max_team_size INT, + created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, + updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP +); +``` + +### 6.3 評審表 (judges) +```sql +CREATE TABLE judges ( + id VARCHAR(36) PRIMARY KEY, + name VARCHAR(100) NOT NULL, + title VARCHAR(100) NOT NULL, + department VARCHAR(100) NOT NULL, + expertise JSON, + avatar VARCHAR(500), + created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, + updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP +); +``` + +### 6.4 評分表 (judge_scores) +```sql +CREATE TABLE judge_scores ( + id VARCHAR(36) PRIMARY KEY, + judge_id VARCHAR(36) NOT NULL, + app_id VARCHAR(36), + proposal_id VARCHAR(36), + scores JSON NOT NULL, + comments TEXT, + submitted_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, + FOREIGN KEY (judge_id) REFERENCES judges(id), + FOREIGN KEY (app_id) REFERENCES apps(id), + FOREIGN KEY (proposal_id) REFERENCES proposals(id) +); +``` + +### 6.5 團隊表 (teams) +```sql +CREATE TABLE teams ( + id VARCHAR(36) PRIMARY KEY, + name VARCHAR(200) NOT NULL, + leader_id VARCHAR(36) NOT NULL, + department VARCHAR(100) NOT NULL, + contact_email VARCHAR(255) NOT NULL, + total_likes INT DEFAULT 0, + created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, + updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + FOREIGN KEY (leader_id) REFERENCES users(id) +); +``` + +### 6.6 團隊成員表 (team_members) +```sql +CREATE TABLE team_members ( + id VARCHAR(36) PRIMARY KEY, + team_id VARCHAR(36) NOT NULL, + user_id VARCHAR(36) NOT NULL, + role VARCHAR(50) NOT NULL, + created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, + FOREIGN KEY (team_id) REFERENCES teams(id), + FOREIGN KEY (user_id) REFERENCES users(id) +); +``` + +### 6.7 應用表 (apps) +```sql +CREATE TABLE apps ( + id VARCHAR(36) PRIMARY KEY, + name VARCHAR(200) NOT NULL, + description TEXT, + creator_id VARCHAR(36) NOT NULL, + team_id VARCHAR(36), + likes_count INT DEFAULT 0, + views_count INT DEFAULT 0, + rating DECIMAL(3,2) DEFAULT 0, + created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, + updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + FOREIGN KEY (creator_id) REFERENCES users(id), + FOREIGN KEY (team_id) REFERENCES teams(id) +); +``` + +### 6.8 獎項表 (awards) +```sql +CREATE TABLE awards ( + id VARCHAR(36) PRIMARY KEY, + competition_id VARCHAR(36) NOT NULL, + app_id VARCHAR(36), + team_id VARCHAR(36), + proposal_id VARCHAR(36), + award_type ENUM('gold', 'silver', 'bronze', 'popular', 'innovation', 'technical', 'custom') NOT NULL, + award_name VARCHAR(200) NOT NULL, + score DECIMAL(5,2) NOT NULL, + year INT NOT NULL, + month INT NOT NULL, + icon VARCHAR(50), + custom_award_type_id VARCHAR(36), + competition_type ENUM('individual', 'team', 'proposal') NOT NULL, + rank INT DEFAULT 0, + category ENUM('innovation', 'technical', 'practical', 'popular', 'teamwork', 'solution', 'creativity') NOT NULL, + created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, + FOREIGN KEY (competition_id) REFERENCES competitions(id), + FOREIGN KEY (app_id) REFERENCES apps(id), + FOREIGN KEY (team_id) REFERENCES teams(id) +); +``` + +### 6.9 聊天會話表 (chat_sessions) +```sql +CREATE TABLE chat_sessions ( + id VARCHAR(36) PRIMARY KEY, + user_id VARCHAR(36) NOT NULL, + created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, + updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + FOREIGN KEY (user_id) REFERENCES users(id) +); +``` + +### 6.10 聊天訊息表 (chat_messages) +```sql +CREATE TABLE chat_messages ( + id VARCHAR(36) PRIMARY KEY, + session_id VARCHAR(36) NOT NULL, + text TEXT NOT NULL, + sender ENUM('user', 'bot') NOT NULL, + quick_questions JSON, + created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, + FOREIGN KEY (session_id) REFERENCES chat_sessions(id) +); +``` + +### 6.11 AI助手配置表 (ai_assistant_configs) +```sql +CREATE TABLE ai_assistant_configs ( + id VARCHAR(36) PRIMARY KEY, + api_key VARCHAR(255) NOT NULL, + api_url VARCHAR(500) NOT NULL, + model VARCHAR(100) NOT NULL, + max_tokens INT DEFAULT 200, + temperature DECIMAL(3,2) DEFAULT 0.7, + system_prompt TEXT NOT NULL, + is_active BOOLEAN DEFAULT TRUE, + created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, + updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP +); +``` + +## 7. 非功能性需求 + +### 7.1 性能需求 +- 頁面載入時間 < 3秒 +- 支持同時1000+用戶在線 +- 數據庫查詢響應時間 < 500ms +- 圖片優化和CDN加速 +- AI助手回應時間 < 5秒 +- 聊天訊息實時更新 + +### 7.2 安全需求 +- 用戶密碼加密存儲 +- JWT Token認證 +- CSRF防護 +- XSS防護 +- SQL注入防護 +- 權限驗證 +- AI API密鑰安全存儲 +- 聊天數據隱私保護 + +### 7.3 可用性需求 +- 系統可用性 > 99.5% +- 響應式設計,支持多設備 +- 無障礙設計 (WCAG 2.1) +- 多語言支持準備 + +### 7.4 可維護性需求 +- 模組化架構 +- 完整的API文檔 +- 代碼註釋和文檔 +- 單元測試覆蓋率 > 80% +- 錯誤日誌和監控 + +## 8. 部署架構 + +### 8.1 開發環境 +- **前端**: Next.js 開發服務器 +- **後端**: Node.js/Express 或 Python/FastAPI +- **數據庫**: PostgreSQL 或 MySQL +- **緩存**: Redis +- **文件存儲**: 本地存儲或雲存儲 + +### 8.2 生產環境 +- **前端**: Vercel 或 AWS S3 + CloudFront +- **後端**: AWS EC2 或 Docker 容器 +- **數據庫**: AWS RDS 或自建數據庫 +- **緩存**: AWS ElastiCache (Redis) +- **文件存儲**: AWS S3 +- **CDN**: CloudFront 或 Cloudflare + +## 9. 開發計劃 + +### 9.1 第一階段 (4週) +- [x] 前端架構搭建 +- [x] 基礎組件開發 +- [x] 認證系統實現 +- [x] 競賽管理基礎功能 + +### 9.2 第二階段 (4週) +- [ ] 後端API開發 +- [ ] 數據庫設計與實現 +- [ ] 評審系統完善 +- [ ] 獎項系統實現 + +### 9.3 第三階段 (3週) +- [ ] 數據分析功能 +- [ ] 管理員後台完善 +- [ ] 性能優化 +- [ ] 安全加固 + +### 9.4 第四階段 (2週) +- [ ] 測試與調試 +- [ ] 文檔完善 +- [ ] 部署上線 +- [ ] 用戶培訓 + +## 10. 風險評估 + +### 10.1 技術風險 +- **數據庫性能**: 大量數據查詢可能影響性能 +- **並發處理**: 高並發場景下的數據一致性 +- **安全性**: 用戶數據保護和系統安全 + +### 10.2 項目風險 +- **時間風險**: 開發進度可能延遲 +- **需求變更**: 功能需求可能調整 +- **資源風險**: 開發資源不足 + +### 10.3 緩解措施 +- 採用成熟的技術棧 +- 實施敏捷開發方法 +- 建立完善的測試體系 +- 制定詳細的項目計劃 +- 定期進行代碼審查 + +--- + +**文檔版本**: v1.0 +**最後更新**: 2025年07月 +**負責人**: 敏捷小組 - 佩庭 +**審核人**: 強茂集團 \ No newline at end of file diff --git a/app/admin/page.tsx b/app/admin/page.tsx new file mode 100644 index 0000000..f3d9dc2 --- /dev/null +++ b/app/admin/page.tsx @@ -0,0 +1,7 @@ +"use client" + +import { AdminPanel } from "@/components/admin/admin-panel" + +export default function AdminPage() { + return +} diff --git a/app/admin/scoring-form-test/page.tsx b/app/admin/scoring-form-test/page.tsx new file mode 100644 index 0000000..5eb433e --- /dev/null +++ b/app/admin/scoring-form-test/page.tsx @@ -0,0 +1,195 @@ +"use client" + +import { useState } from "react" +import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card" +import { Button } from "@/components/ui/button" +import { Label } from "@/components/ui/label" +import { Textarea } from "@/components/ui/textarea" +import { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle } from "@/components/ui/dialog" +import { CheckCircle, Edit, Loader2 } from "lucide-react" + +export default function ScoringFormTestPage() { + const [showScoringForm, setShowScoringForm] = useState(false) + const [manualScoring, setManualScoring] = useState({ + judgeId: "judge1", + participantId: "app1", + scores: { + "創新性": 0, + "技術性": 0, + "實用性": 0, + "展示效果": 0, + "影響力": 0 + }, + comments: "" + }) + const [isLoading, setIsLoading] = useState(false) + + const scoringRules = [ + { name: "創新性", description: "技術創新程度和獨特性", weight: 25 }, + { name: "技術性", description: "技術實現的複雜度和穩定性", weight: 20 }, + { name: "實用性", description: "實際應用價值和用戶體驗", weight: 25 }, + { name: "展示效果", description: "演示效果和表達能力", weight: 15 }, + { name: "影響力", description: "對行業和社會的潛在影響", weight: 15 } + ] + + const calculateTotalScore = (scores: Record): number => { + let totalScore = 0 + let totalWeight = 0 + + scoringRules.forEach(rule => { + const score = scores[rule.name] || 0 + const weight = rule.weight || 1 + totalScore += score * weight + totalWeight += weight + }) + + return totalWeight > 0 ? Math.round(totalScore / totalWeight) : 0 + } + + const handleSubmitScore = async () => { + setIsLoading(true) + // 模擬提交 + setTimeout(() => { + setIsLoading(false) + setShowScoringForm(false) + }, 2000) + } + + return ( +
+
+

評分表單測試

+

測試完整的評分表單功能

+
+ + + + 評分表單演示 + 點擊按鈕查看完整的評分表單 + + + + + + + + + + + + 評分表單 + + + 為參賽者進行評分,請根據各項指標進行評分 + + + +
+ {/* 評分項目 */} +
+

評分項目

+ {scoringRules.map((rule, index) => ( +
+
+
+ +

{rule.description}

+

權重:{rule.weight}%

+
+
+ + {manualScoring.scores[rule.name] || 0} / 10 + +
+
+ + {/* 評分按鈕 */} +
+ {Array.from({ length: 10 }, (_, i) => i + 1).map((score) => ( + + ))} +
+
+ ))} +
+ + {/* 總分顯示 */} +
+
+
+ 總分 +

根據權重計算的綜合評分

+
+
+ + {calculateTotalScore(manualScoring.scores)} + + / 10 +
+
+
+ + {/* 評審意見 */} +
+ +