ichieh commited on
Commit
3dde316
·
1 Parent(s): 29dd674

docs: 添加系統架構圖和開發 Debug 記錄

Browse files
Files changed (3) hide show
  1. README.md +175 -19
  2. static/css/style.css +112 -0
  3. templates/index.html +1 -128
README.md CHANGED
@@ -1,5 +1,5 @@
1
  ---
2
- title: Eventinvite
3
  emoji: 📈
4
  colorFrom: blue
5
  colorTo: yellow
@@ -10,35 +10,191 @@ app_port: 7860
10
  persistent_dir: ["/data"]
11
  ---
12
 
13
- # 活動座位選擇系統
14
 
15
- 這是一個簡單的活動座位選擇系統,允許參與者選擇圓桌座位並登記個人資訊。
16
 
17
- ## 功能特點
18
 
19
- - 圓桌座位視覺化顯示
20
- - 即時座位狀態更新
21
- - 參與者資訊登記(暱稱、Email、FB連結、自我介紹)
22
- - 資料持久化存儲
 
23
 
24
- ## 部署說明
 
 
 
 
 
 
 
 
25
 
26
- ### Hugging Face Spaces 部署
27
 
28
- 1. 系統會自動使用 `/data` 目錄進行持久化存儲
29
- 2. 資料庫文件會保存在 `/data/event.db`
30
- 3. 重新部署時不會影響已存在的資料
 
 
31
 
32
- ### 本地開發
 
 
 
 
33
 
34
- 1. 本地開發時資料庫文件位於 `instance/event.db`
35
- 2. 確保資料目錄有正確的讀寫權限
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
36
 
37
  ## 注意事項
38
 
39
- - 每次部署時會保留 `/data` 目錄中的資料
40
- - 不要手動刪除或修改 `/data` 目錄
41
- - 如需重置資料,請聯繫管理員
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
42
 
43
  ---
44
  Hosted on 🤗 Hugging Face Spaces
 
1
  ---
2
+ title: Event Invite - 活動座位選擇系統
3
  emoji: 📈
4
  colorFrom: blue
5
  colorTo: yellow
 
10
  persistent_dir: ["/data"]
11
  ---
12
 
13
+ # Event Invite - 活動座位選擇系統
14
 
15
+ 這是一個專為活動設計的座位選擇系統,讓參與者可以自由選擇想要坐的桌次。系統支援多桌次管理、桌長設定、付款狀態追蹤等功能。
16
 
17
+ ## 功能特色
18
 
19
+ ### 參與者功能
20
+ - 即時查看各桌剩餘座位
21
+ - 選擇想要入座的桌次
22
+ - 填寫個人資料(暱稱、Email、FB連結、自我介紹)
23
+ - 點擊參與者名字可查看詳細資訊
24
 
25
+ ### 管理者功能
26
+ - 管理者後台密碼保護
27
+ - 查看所有參與者資訊
28
+ - 設定/取消桌長身份
29
+ - 標記付款狀態
30
+ - 新增/編輯參與者備註
31
+ - 匯出參與者資料
32
+ - 備份/還原資料庫
33
+ - 與 Google Sheets 同步
34
 
35
+ ## 技術架構
36
 
37
+ ### 前端
38
+ - HTML5/CSS3
39
+ - Bootstrap 5.1.3
40
+ - SweetAlert2 (彈窗提示)
41
+ - Bootstrap Icons
42
 
43
+ ### 後端
44
+ - Python Flask
45
+ - SQLite 資料庫
46
+ - Flask-SQLAlchemy
47
+ - Google Apps Script (資料同步)
48
 
49
+ ## 系統架構圖
50
+
51
+ ```mermaid
52
+ graph TB
53
+ subgraph Frontend
54
+ A[首頁 index.html] --> B[管理者登入 admin_login.html]
55
+ B --> C[管理面板 admin.html]
56
+ end
57
+
58
+ subgraph Backend
59
+ D[Flask App] --> E[SQLite 資料庫]
60
+ D --> F[Google Apps Script]
61
+ end
62
+
63
+ subgraph 使用者流程
64
+ G[瀏覽座位] --> H[選擇座位]
65
+ H --> I[填寫資料]
66
+ I --> J[完成報名]
67
+ end
68
+
69
+ subgraph 管理者流程
70
+ K[登入驗證] --> L[查看報名]
71
+ L --> M[管理座位]
72
+ M --> N[同步資料]
73
+ end
74
+
75
+ A --> D
76
+ C --> D
77
+ D --> F
78
+ F --> O[Google Sheets]
79
+ ```
80
+
81
+ ## 主要功能流程
82
+
83
+ 1. **一般使用者流程**
84
+ - 瀏覽活動座位表
85
+ - 選擇想要的座位
86
+ - 填寫個人資料(暱稱、Email、FB連結、自我介紹)
87
+ - 完成報名
88
+
89
+ 2. **管理者流程**
90
+ - 登入管理面板
91
+ - 查看所有報名資料
92
+ - 管理座位分配
93
+ - 與 Google Sheets 同步資料
94
+
95
+ 3. **資料同步流程**
96
+ - 後端 Flask 應用程式處理請求
97
+ - 透過 Google Apps Script 進行資料同步
98
+ - 資料存儲於 SQLite 資料庫和 Google Sheets
99
+
100
+ ## 部署資訊
101
+
102
+ 本系統部署在 Hugging Face Spaces 平台,使用持久化存儲來保存資料。
103
+
104
+ ### 環境變數設定
105
+ - `ADMIN_PASSWORD`: 管理者密碼
106
+ - `SETTINGS_SCRIPT_URL`: Google Apps Script 網址(用於同步設定)
107
+
108
+ ## 本地開發
109
+
110
+ 1. 安裝依賴:
111
+ ```bash
112
+ pip install -r requirements.txt
113
+ ```
114
+
115
+ 2. 設定環境變數:
116
+ ```bash
117
+ export ADMIN_PASSWORD=your_password
118
+ export SETTINGS_SCRIPT_URL=your_script_url
119
+ ```
120
+
121
+ 3. 啟動應用:
122
+ ```bash
123
+ python app.py
124
+ ```
125
+
126
+ 應用將在 http://localhost:7860 運行
127
+
128
+ ## 資料庫結構
129
+
130
+ ### Table 資料表
131
+ - id: 桌次 ID
132
+ - name: 桌次名稱
133
+ - capacity: 座位容量
134
+ - participants: 關聯到 Participant 資料表
135
+
136
+ ### Participant 資料表
137
+ - id: 參與者 ID
138
+ - nickname: 暱稱
139
+ - email: 電子郵件
140
+ - fb_link: Facebook 連結
141
+ - introduction: 自我介紹
142
+ - table_id: 所屬桌次
143
+ - seat_number: 座位號碼
144
+ - is_table_leader: 是否為桌長
145
+ - created_at: 建立時間
146
+ - has_paid: 付款狀態
147
+ - note: 管理者備註
148
+
149
+ ## 資料備份
150
+
151
+ 系統提供兩種備份機制:
152
+ 1. 資料庫備份:完整備份所有資料
153
+ 2. Google Sheets 同步:即時同步重要設定
154
 
155
  ## 注意事項
156
 
157
+ 1. 請定期備份資料庫
158
+ 2. 管理者密碼請妥善保管
159
+ 3. 建議定期檢查 Google Sheets 同步狀態
160
+
161
+ ## 授權資訊
162
+
163
+ 本專案採用 MIT 授權條款。
164
+
165
+ ## 開發 Debug 記錄
166
+
167
+ ### 前端顯示
168
+
169
+ 1. **圓形桌位顯示溢出**
170
+ - 問題:參與者超過 5 人時,名字會溢出圓形區域
171
+ - 解決:改用長方形設計,並根據參與者數量自動調整大小
172
+
173
+ 2. **參與者資訊顯示優化**
174
+ - 問題:自我介紹和備註內容過長時影響版面
175
+ - 解決:實作文字截斷和彈出式詳細資訊視窗
176
+
177
+ ### Google Sheets 同步
178
+
179
+ 1. **跨域請求問題**
180
+ - 問題:無法直接從前端呼叫 Google Apps Script
181
+ - 解決:透過後端 API 轉發請求,並處理回應
182
+
183
+ ### 安全性問題
184
+
185
+ 1. **管理者密碼保護**
186
+ - 問題:需要保護管理者頁面的存取
187
+ - 解決:使用環境變數和 session 機制,實作管理者登入功能
188
+
189
+ ### 使用者體驗
190
+
191
+ 1. **座位選擇流程**
192
+ - 問題:原本點擊整個圓桌來選擇不夠直覺
193
+ - 解決:新增獨立的選擇按鈕,並提供視覺回饋
194
+
195
+ 2. **錯誤處理優化**
196
+ - 問題:系統錯誤訊息不夠友善
197
+ - 解決:使用 SweetAlert2 提供更好的錯誤提示
198
 
199
  ---
200
  Hosted on 🤗 Hugging Face Spaces
static/css/style.css ADDED
@@ -0,0 +1,112 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ .main-container {
2
+ display: flex;
3
+ justify-content: space-between;
4
+ padding: 20px;
5
+ gap: 20px;
6
+ }
7
+
8
+ .tables-section {
9
+ flex: 2;
10
+ display: flex;
11
+ flex-wrap: wrap;
12
+ gap: 20px;
13
+ }
14
+
15
+ .registration-section {
16
+ flex: 1;
17
+ min-width: 300px;
18
+ max-width: 400px;
19
+ padding: 20px;
20
+ background-color: #f8f9fa;
21
+ border-radius: 8px;
22
+ position: sticky;
23
+ top: 20px;
24
+ height: fit-content;
25
+ }
26
+
27
+ .table-circle {
28
+ min-width: 200px;
29
+ height: auto;
30
+ border-radius: 8px;
31
+ border: 2px solid #ddd;
32
+ display: flex;
33
+ flex-direction: column;
34
+ align-items: stretch;
35
+ padding: 15px;
36
+ margin: 15px;
37
+ background-color: white;
38
+ transition: all 0.3s ease;
39
+ }
40
+
41
+ .table-circle:hover {
42
+ border-color: #007bff;
43
+ background-color: #f8f9fa;
44
+ }
45
+
46
+ .table-circle.selected {
47
+ border-color: #007bff;
48
+ background-color: #e7f1ff;
49
+ }
50
+
51
+ .table-circle.full {
52
+ opacity: 0.7;
53
+ }
54
+
55
+ .table-header {
56
+ display: flex;
57
+ justify-content: space-between;
58
+ align-items: center;
59
+ margin-bottom: 10px;
60
+ padding-bottom: 10px;
61
+ border-bottom: 1px solid #eee;
62
+ }
63
+
64
+ .table-name {
65
+ font-size: 1.2rem;
66
+ font-weight: bold;
67
+ margin: 0;
68
+ }
69
+
70
+ .select-seat-btn {
71
+ padding: 4px 8px;
72
+ font-size: 0.9rem;
73
+ }
74
+
75
+ .participants-list {
76
+ display: flex;
77
+ flex-direction: column;
78
+ gap: 5px;
79
+ }
80
+
81
+ .participant-item {
82
+ padding: 8px;
83
+ border-radius: 4px;
84
+ background-color: #f8f9fa;
85
+ cursor: pointer;
86
+ transition: all 0.2s ease;
87
+ }
88
+
89
+ .participant-item:hover {
90
+ background-color: #e9ecef;
91
+ }
92
+
93
+ .participant-item.table-leader {
94
+ background-color: #28a745;
95
+ color: white;
96
+ border-left: 4px solid #1e7e34;
97
+ }
98
+
99
+ .table-circle.full .select-seat-btn {
100
+ display: none;
101
+ }
102
+
103
+ .seats-info {
104
+ font-size: 1rem;
105
+ color: #666;
106
+ }
107
+
108
+ .table-container {
109
+ display: inline-block;
110
+ margin: 15px;
111
+ text-align: center;
112
+ }
templates/index.html CHANGED
@@ -7,134 +7,7 @@
7
  <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet">
8
  <link href="https://cdn.jsdelivr.net/npm/sweetalert2@11.3.0/dist/sweetalert2.min.css" rel="stylesheet">
9
  <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.8.1/font/bootstrap-icons.css">
10
- <style>
11
- .main-container {
12
- display: flex;
13
- justify-content: space-between;
14
- padding: 20px;
15
- gap: 20px;
16
- }
17
-
18
- .tables-section {
19
- flex: 2;
20
- display: flex;
21
- flex-wrap: wrap;
22
- gap: 20px;
23
- }
24
-
25
- .registration-section {
26
- flex: 1;
27
- min-width: 300px;
28
- max-width: 400px;
29
- padding: 20px;
30
- background-color: #f8f9fa;
31
- border-radius: 8px;
32
- position: sticky;
33
- top: 20px;
34
- height: fit-content;
35
- }
36
-
37
- .table-circle {
38
- min-width: 200px;
39
- height: auto;
40
- border-radius: 8px;
41
- border: 2px solid #ddd;
42
- display: flex;
43
- flex-direction: column;
44
- align-items: stretch;
45
- padding: 15px;
46
- margin: 15px;
47
- background-color: white;
48
- transition: all 0.3s ease;
49
- }
50
-
51
- .table-circle:hover {
52
- border-color: #007bff;
53
- background-color: #f8f9fa;
54
- }
55
-
56
- .table-circle.selected {
57
- border-color: #007bff;
58
- background-color: #e7f1ff;
59
- }
60
-
61
- .table-circle.full {
62
- cursor: not-allowed;
63
- opacity: 0.7;
64
- }
65
-
66
- .table-header {
67
- display: flex;
68
- justify-content: space-between;
69
- align-items: center;
70
- margin-bottom: 10px;
71
- padding-bottom: 10px;
72
- border-bottom: 1px solid #eee;
73
- }
74
-
75
- .table-name {
76
- font-size: 1.2rem;
77
- font-weight: bold;
78
- margin: 0;
79
- }
80
-
81
- .select-seat-btn {
82
- padding: 4px 8px;
83
- font-size: 0.9rem;
84
- }
85
-
86
- .participants-list {
87
- display: flex;
88
- flex-direction: column;
89
- gap: 5px;
90
- }
91
-
92
- .participant-item {
93
- padding: 8px;
94
- border-radius: 4px;
95
- background-color: #f8f9fa;
96
- cursor: pointer;
97
- transition: all 0.2s ease;
98
- }
99
-
100
- .participant-item:hover {
101
- background-color: #e9ecef;
102
- }
103
-
104
- .participant-item.table-leader {
105
- background-color: #d4edda;
106
- border-left: 4px solid #28a745;
107
- }
108
-
109
- .table-circle.full .select-seat-btn {
110
- display: none;
111
- }
112
-
113
- .seats-info {
114
- font-size: 1rem;
115
- color: #666;
116
- }
117
-
118
- .table-leader {
119
- background-color: #28a745;
120
- color: white;
121
- padding: 2px 8px;
122
- border-radius: 4px;
123
- margin-bottom: 4px;
124
- }
125
-
126
- .participant {
127
- padding: 2px 8px;
128
- margin-bottom: 2px;
129
- border-radius: 4px;
130
- }
131
-
132
- .table-container {
133
- display: inline-block;
134
- margin: 15px;
135
- text-align: center;
136
- }
137
- </style>
138
  </head>
139
  <body>
140
  <div class="container">
 
7
  <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet">
8
  <link href="https://cdn.jsdelivr.net/npm/sweetalert2@11.3.0/dist/sweetalert2.min.css" rel="stylesheet">
9
  <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.8.1/font/bootstrap-icons.css">
10
+ <link rel="stylesheet" href="{{ url_for('static', filename='css/style.css') }}">
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
11
  </head>
12
  <body>
13
  <div class="container">