MoYuan
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note No publishing access yet

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.

      Your account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

      Your team account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

      Explore these features while you wait
      Complete general settings
      Bookmark and like published notes
      Write a few more notes
      Complete general settings
      Write a few more notes
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights New
    • Engagement control
    • Make a copy
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Note Insights Versions and GitHub Sync Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control Make a copy Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note No publishing access yet

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.

    Your account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

    Your team account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

    Explore these features while you wait
    Complete general settings
    Bookmark and like published notes
    Write a few more notes
    Complete general settings
    Write a few more notes
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       Owned this note    Owned this note      
    Published Linked with GitHub
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    # 1. 專案簡介(Project Overview) ## 使用技術 **前端框架**:React + Vite **後端技術**:Node.js **資料庫**:PostgreSQL **部署平台**:Render + Firebase **CSS 技術**:Bootstrap 5 + SCSS ## 主要使用的套件 * Bootstrap 5 * React Router * React Hook Form * react-helmet-async * Redux Toolkit * Sweetalert2 * Swiper * Axios * AOS * ReactQuill (文字編輯器) * styled-components (CSS-in-JS) * clsx * React Datepicker * DOMPurify (HTML 清理,阻擋 XSS 惡意攻擊) * react-rating-stars-component (評分星星) * react-medium-image-zoom (圖片放大) ## 專案目錄結構 ``` 📂 src/ # 主程式碼目錄 ├── 📂 api/ # API 請求管理 │ ├── 📂 assets/ # 靜態資源 │ └── 📂 scss/ # SCSS 樣式 │ ├── 📂 base/ # 基本樣式 │ ├── 📂 components/ # 元件樣式 │ ├── 📂 layout/ # 佈局樣式 │ ├── 📂 pages/ # 頁面樣式 │ ├── 📂 utils/ # 工具類樣式 │ └── 📂 vendors/ # 第三方樣式 │ ├── 📂 components/ # 可重複使用的元件 │ ├── 📂 auth/ # 登入註冊頁面相關元件 │ ├── 📂 common/ # 公用元件 │ │ ├── 📂 booking-record/ # 預約紀錄元件 │ │ ├── 📂 payment-form/ # 付款表單元件 │ │ └── 📂 profile/ # 個人檔案元件 │ ├── 📂 course/ # 課程頁面相關元件 │ │ └── 📂 detail-page/ # 課程詳情頁元件 │ ├── 📂 custom-course/ # 客製化課程頁面相關元件 │ ├── 📂 help-center/ # 幫助中心頁面相關元件 │ ├── 📂 layout/ # 佈局元件 │ ├── 📂 subscription/ # 訂閱頁面相關元件 │ ├── 📂 tutor/ # 講師頁面相關元件 │ └── 📂 tutor-panel/ # 講師後台 │ ├── 📂 booking/ # 預約管理 │ │ ├── 📂 all-bookings/ # 所有預約 │ │ └── 📂 available-time/ # 可預約時間 │ ├── 📂 course/ # 課程管理 │ │ ├── 📂 add/ # 新增課程 │ │ ├── 📂 course-list/ # 課程列表 │ │ └── 📂 edit/ # 編輯課程 │ └── 📂 profile/ # 講師個人檔案 │ ├── 📂 data/ # 存放資料數據的資料夾 (未使用 API 獲取的資料) │ ├── 📂 hooks/ # React 自訂 Hook │ ├── 📂 pages/ # 頁面 │ ├── 📂 student/ # 學生專區 │ ├── 📂 tutor/ # 講師專區 │ │ ├── 📂 bookings/ # 預約管理頁面 │ │ ├── 📂 courses/ # 課程管理頁面 │ │ │ ├── 📂 course/ # 課程 │ │ │ └── 📂 video/ # 影片 │ │ └── 📂 profile/ # 講師個人資料 │ └── 📂 user/ # 前台使用者相關頁面 │ ├── 📂 auth/ # 登入註冊相關頁面 │ ├── 📂 course/ # 課程相關頁面 │ │ └── 📂 detail-page/ # 課程詳情頁 │ ├── 📂 custom-course/ # 客製化課程相關頁面 │ ├── 📂 subscription/ # 訂閱流程相關頁面 │ └── 📂 tutor/ # 講師相關頁面 │ ├── 📂 router/ # 路由管理 │ └── 📂 utils/ # 工具函式 ├── 📂 schema/ # 資料驗證 Schema └── 📂 slice/ # Redux 切片 ``` # 2. 環境設定(Setup Instructions) ### 安裝依賴 ```npm install``` ### 啟動開發環境 ```npm run dev``` ### 環境變數(.env 設定) # 待更新 ```VITE_API_BASE``` # 3. 路由規則(Routing Guidelines) 使用 **巢狀路由** ## 路由設定的存放位置 src/router/routes.jsx ## 路由命名規範 烤肉串命名法 kebab-case 例如:/custom-course-list ## 動態路由的使用方式 動態路由使用 **:參數名稱** 來表示變數部分,例如 **/course/:id**,這樣的路徑可以匹配 /course/123 或 /course/abc。 ### 課程相關 /course/category/:category * category → 語言類別,例如:Vue、React 等 /course/:id * id → 課程的唯一識別碼 /course/:id/chapter/:videoId /video/:videoId * videoId → 影片的唯一識別碼 ### 訂閱相關 /subscription/:subscriptionPlan/:duration * subscriptionPlan → 訂閱方案類型 * duration → 訂閱時長 (例如 monthly 或 yearly) ### 講師預約相關 /tutor/:id * id → 講師的唯一識別碼 ### 後台相關 /video/:type/add/:courseId/:id * type → 三大課程類別 (one of topicSeries, freeTipShorts and customLearning) * courseId → 課程的唯一識別碼 # 4. API 串接(API Integration) ## API 介面管理方式 ### 存放資料夾 ```src/api/``` ![image](https://hackmd.io/_uploads/r1Qg8ihdke.png) * apiClient → 統一管理 API 請求,在這裡設定 **基礎 URL**、**請求攔截器**、**錯誤處理** 等功能 * courseApi、tutorApi 等 → 所有相關類別的 API 都放在各自的檔案中 ## 如何在元件中呼叫 API ```ja import courseApi from "../../api/courseApi"; // 取得課程資料函式 const [courseList, setCourseList] = useState([]); const getCoursesData = async () => { setLoadingState(true); try { const result = await courseApi.getCourses("topicSeries"); setCourseList(result); } catch (error) { console.log("錯誤", error); } finally { setLoadingState(false); } }; ``` # 5. 程式碼風格(Coding Style) 使用 Prettier / ESLint 格式化程式碼 ## 元件命名規範 大駝峰命名法 PascalCase 例如:CustomCourseList ![image](https://hackmd.io/_uploads/SJ9bpi3dJg.png) ## 檔案命名規範 ### 如果該檔案是頁面 (在 src/pages 裡面) 烤肉串命名法 kebab-case 例如:/custom-course-list ![image](https://hackmd.io/_uploads/SJlNas3_Jl.png) ### 如果該檔案只用來存放函式 / 方法 / 純資料 烤肉串命名法 kebab-case 檔名用 .js (沒有改到的話請幫忙改) 例如:/utils ![image](https://hackmd.io/_uploads/H1Nd-SRdJg.png) ### 如果該檔案是元件 (在 src/components 裡面) 大駝峰命名法 PascalCase 例如:CourseCard ![image](https://hackmd.io/_uploads/HyDOTsnOkx.png) # 6. 共用元件(Reusable Components) ## 元件存放位置 src/components/ ## 元件撰寫原則 ![image](https://hackmd.io/_uploads/Bkf4Co3ukg.png) * 程式碼過多,移出去另外的檔案撰寫 (命名方式:-Section) * 重用性高 (命名方式:大駝峰,以用途取名) # 7. 開發流程(Development Workflow) ## Git 分支命名規則 * feature-功能或區塊名稱/撰寫人 * fix-功能或區塊名稱/撰寫人 ![image](https://hackmd.io/_uploads/rJ5-Jn3OJx.png) ## PR(Pull Request)流程 0. 開新分支 1. pull main 的最新進度 2. 製作功能 3. commit 4. push 到自己的分支 5. 發 PR (發完請到 DC 通知幫忙審核的人) 6. 審核並 merge ## Commit Message [參考](https://wadehuanglearning.blogspot.com/2019/05/commit-commit-commit-why-what-commit.html) ![image](https://hackmd.io/_uploads/SkefzSR_Jg.png) # 8. 其他(Other Guidelines) ## import 順序 ![image](https://hackmd.io/_uploads/rygAsg6dke.png) 1. React 相關方法 2. 第三方套件的引入 3. Api 引入 4. 元件引入 5. 內建資料引入 (較少) 如果沒有依照此方法做,應該是沒處理到 (請幫忙調整一下順序)

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password
    or
    Sign in via Facebook Sign in via X(Twitter) Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    By signing in, you agree to our terms of service.

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully