From f3a89e3776b054d973a98a6e59d5730fe14782ed Mon Sep 17 00:00:00 2001 From: tcandicetc Date: Mon, 12 May 2025 14:48:30 +0800 Subject: [PATCH 01/13] feat: add room page --- .vitepress/config/zh_tw.ts | 1 + content/zh_tw/room/index.md | 5 ++ content/zh_tw/room/index.vue | 138 ++++++++++++++++++++++++++++++++++ content/zh_tw/room/status.vue | 70 +++++++++++++++++ 4 files changed, 214 insertions(+) create mode 100644 content/zh_tw/room/index.md create mode 100644 content/zh_tw/room/index.vue create mode 100644 content/zh_tw/room/status.vue diff --git a/.vitepress/config/zh_tw.ts b/.vitepress/config/zh_tw.ts index 4d757ff2..f980fb37 100644 --- a/.vitepress/config/zh_tw.ts +++ b/.vitepress/config/zh_tw.ts @@ -8,6 +8,7 @@ export const zh_tw = defineConfig({ { text: '首頁', link: '/' }, { text: '年會資訊', link: '/event' }, { text: '關於我們', link: '/about' }, + { text: '會場狀態', link: '/room' }, ], sidebar: {}, socialLinks: [ diff --git a/content/zh_tw/room/index.md b/content/zh_tw/room/index.md new file mode 100644 index 00000000..c363c5a3 --- /dev/null +++ b/content/zh_tw/room/index.md @@ -0,0 +1,5 @@ + + + diff --git a/content/zh_tw/room/index.vue b/content/zh_tw/room/index.vue new file mode 100644 index 00000000..183dcce4 --- /dev/null +++ b/content/zh_tw/room/index.vue @@ -0,0 +1,138 @@ + + + + + diff --git a/content/zh_tw/room/status.vue b/content/zh_tw/room/status.vue new file mode 100644 index 00000000..ee6b1c00 --- /dev/null +++ b/content/zh_tw/room/status.vue @@ -0,0 +1,70 @@ + + + + + From cd2a4475fd783bab02dcc3abe02650ae5242e938 Mon Sep 17 00:00:00 2001 From: tcandicetc Date: Mon, 12 May 2025 16:02:27 +0800 Subject: [PATCH 02/13] Rename index.vue to Room.vue --- content/zh_tw/room/{index.vue => Room.vue} | 4 ++-- content/zh_tw/room/index.md | 6 +----- 2 files changed, 3 insertions(+), 7 deletions(-) rename content/zh_tw/room/{index.vue => Room.vue} (98%) diff --git a/content/zh_tw/room/index.vue b/content/zh_tw/room/Room.vue similarity index 98% rename from content/zh_tw/room/index.vue rename to content/zh_tw/room/Room.vue index 183dcce4..114ce9c2 100644 --- a/content/zh_tw/room/index.vue +++ b/content/zh_tw/room/Room.vue @@ -1,9 +1,9 @@ - - + From 4d076902926079286a24878bd502f9bcd21fc16a Mon Sep 17 00:00:00 2001 From: tcandicetc <52348208+tcandicetc@users.noreply.github.com> Date: Mon, 12 May 2025 16:07:07 +0800 Subject: [PATCH 03/13] Rename status.vue to Status.vue --- content/zh_tw/room/{status.vue => Status.vue} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename content/zh_tw/room/{status.vue => Status.vue} (100%) diff --git a/content/zh_tw/room/status.vue b/content/zh_tw/room/Status.vue similarity index 100% rename from content/zh_tw/room/status.vue rename to content/zh_tw/room/Status.vue From faf7bd8dd971ca52d8f4226c9798ff32309498e3 Mon Sep 17 00:00:00 2001 From: tcandicetc Date: Tue, 13 May 2025 22:15:35 +0800 Subject: [PATCH 04/13] refactor: convert from Options API to Composition API --- content/zh_tw/room/Room.vue | 147 ++++++++++++++++------------------ content/zh_tw/room/status.vue | 44 +++++----- 2 files changed, 91 insertions(+), 100 deletions(-) diff --git a/content/zh_tw/room/Room.vue b/content/zh_tw/room/Room.vue index 114ce9c2..fcbed410 100644 --- a/content/zh_tw/room/Room.vue +++ b/content/zh_tw/room/Room.vue @@ -1,87 +1,80 @@ - diff --git a/content/zh_tw/room/status.vue b/content/zh_tw/room/status.vue index ee6b1c00..a14d1717 100644 --- a/content/zh_tw/room/status.vue +++ b/content/zh_tw/room/status.vue @@ -1,23 +1,21 @@ - @@ -25,16 +23,16 @@ export default {

- {{ formatTime(data.start) }} + {{ formatTime(props.data.start) }}

- {{ data.title }} + {{ props.data.title }}

- {{ formatTime(data.end) }} + {{ formatTime(props.data.end) }}

From 853f8795a8cb2c86433ce4482be9fa72a9da7145 Mon Sep 17 00:00:00 2001 From: tcandicetc Date: Mon, 12 May 2025 14:48:30 +0800 Subject: [PATCH 05/13] feat: add room page --- .vitepress/config/zh_tw.ts | 1 + content/zh_tw/room/index.md | 5 ++ content/zh_tw/room/index.vue | 138 ++++++++++++++++++++++++++++++++++ content/zh_tw/room/status.vue | 70 +++++++++++++++++ 4 files changed, 214 insertions(+) create mode 100644 content/zh_tw/room/index.md create mode 100644 content/zh_tw/room/index.vue create mode 100644 content/zh_tw/room/status.vue diff --git a/.vitepress/config/zh_tw.ts b/.vitepress/config/zh_tw.ts index 4d757ff2..f980fb37 100644 --- a/.vitepress/config/zh_tw.ts +++ b/.vitepress/config/zh_tw.ts @@ -8,6 +8,7 @@ export const zh_tw = defineConfig({ { text: '首頁', link: '/' }, { text: '年會資訊', link: '/event' }, { text: '關於我們', link: '/about' }, + { text: '會場狀態', link: '/room' }, ], sidebar: {}, socialLinks: [ diff --git a/content/zh_tw/room/index.md b/content/zh_tw/room/index.md new file mode 100644 index 00000000..c363c5a3 --- /dev/null +++ b/content/zh_tw/room/index.md @@ -0,0 +1,5 @@ + + + diff --git a/content/zh_tw/room/index.vue b/content/zh_tw/room/index.vue new file mode 100644 index 00000000..183dcce4 --- /dev/null +++ b/content/zh_tw/room/index.vue @@ -0,0 +1,138 @@ + + + + + diff --git a/content/zh_tw/room/status.vue b/content/zh_tw/room/status.vue new file mode 100644 index 00000000..ee6b1c00 --- /dev/null +++ b/content/zh_tw/room/status.vue @@ -0,0 +1,70 @@ + + + + + From fb3fe908e22c4ddc5084e3344493e91cce03b15c Mon Sep 17 00:00:00 2001 From: tcandicetc Date: Mon, 12 May 2025 16:02:27 +0800 Subject: [PATCH 06/13] Rename index.vue to Room.vue --- content/zh_tw/room/{index.vue => Room.vue} | 4 ++-- content/zh_tw/room/index.md | 6 +----- 2 files changed, 3 insertions(+), 7 deletions(-) rename content/zh_tw/room/{index.vue => Room.vue} (98%) diff --git a/content/zh_tw/room/index.vue b/content/zh_tw/room/Room.vue similarity index 98% rename from content/zh_tw/room/index.vue rename to content/zh_tw/room/Room.vue index 183dcce4..114ce9c2 100644 --- a/content/zh_tw/room/index.vue +++ b/content/zh_tw/room/Room.vue @@ -1,9 +1,9 @@ - - + From c0855320caaec91012cf259644c24170822bb3e3 Mon Sep 17 00:00:00 2001 From: tcandicetc Date: Tue, 13 May 2025 22:15:35 +0800 Subject: [PATCH 07/13] refactor: convert from Options API to Composition API --- content/zh_tw/room/Room.vue | 147 ++++++++++++++++------------------ content/zh_tw/room/status.vue | 44 +++++----- 2 files changed, 91 insertions(+), 100 deletions(-) diff --git a/content/zh_tw/room/Room.vue b/content/zh_tw/room/Room.vue index 114ce9c2..fcbed410 100644 --- a/content/zh_tw/room/Room.vue +++ b/content/zh_tw/room/Room.vue @@ -1,87 +1,80 @@ - diff --git a/content/zh_tw/room/status.vue b/content/zh_tw/room/status.vue index ee6b1c00..a14d1717 100644 --- a/content/zh_tw/room/status.vue +++ b/content/zh_tw/room/status.vue @@ -1,23 +1,21 @@ - @@ -25,16 +23,16 @@ export default {

- {{ formatTime(data.start) }} + {{ formatTime(props.data.start) }}

- {{ data.title }} + {{ props.data.title }}

- {{ formatTime(data.end) }} + {{ formatTime(props.data.end) }}

From 9ac7af6b4876e2687faa801d6e4390dc1fe8183e Mon Sep 17 00:00:00 2001 From: tcandicetc <52348208+tcandicetc@users.noreply.github.com> Date: Mon, 12 May 2025 16:07:07 +0800 Subject: [PATCH 08/13] Rename status.vue to Status.vue --- content/zh_tw/room/{status.vue => Status.vue} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename content/zh_tw/room/{status.vue => Status.vue} (100%) diff --git a/content/zh_tw/room/status.vue b/content/zh_tw/room/Status.vue similarity index 100% rename from content/zh_tw/room/status.vue rename to content/zh_tw/room/Status.vue From 927729d44b2dbb24f82711cbbf7dd63952ebd1e3 Mon Sep 17 00:00:00 2001 From: tcandicetc Date: Sat, 17 May 2025 16:44:26 +0800 Subject: [PATCH 09/13] style: fix layout issues --- content/zh_tw/room/Room.vue | 6 +++++- content/zh_tw/room/Status.vue | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/content/zh_tw/room/Room.vue b/content/zh_tw/room/Room.vue index fcbed410..943530ae 100644 --- a/content/zh_tw/room/Room.vue +++ b/content/zh_tw/room/Room.vue @@ -123,7 +123,11 @@ table th { padding: 0; } table th:first-child { - width: 7em; + width: 15%; + min-width: 7em; +} +table th:nth-child(2) { + width: 85%; } .empty-room { text-align: center; diff --git a/content/zh_tw/room/Status.vue b/content/zh_tw/room/Status.vue index a14d1717..c56ddbd9 100644 --- a/content/zh_tw/room/Status.vue +++ b/content/zh_tw/room/Status.vue @@ -47,7 +47,7 @@ function formatTime(time) { position: absolute; top: 0; left: 0; - background-color: rgb(0, 0, 0, 0.05); + background-color: var(--vp-c-default-soft); height: 100%; } p { From 1fe32615873c523a4a2a61c3062a34ee9e2b2b34 Mon Sep 17 00:00:00 2001 From: tcandicetc Date: Sat, 24 May 2025 22:42:53 +0800 Subject: [PATCH 10/13] feat: show room congestion level and next session --- content/zh_tw/room/Room.vue | 224 +++++++++++++++++++++++++--------- content/zh_tw/room/Status.vue | 45 ++++--- content/zh_tw/room/index.md | 4 + 3 files changed, 200 insertions(+), 73 deletions(-) diff --git a/content/zh_tw/room/Room.vue b/content/zh_tw/room/Room.vue index 943530ae..d4bca871 100644 --- a/content/zh_tw/room/Room.vue +++ b/content/zh_tw/room/Room.vue @@ -3,38 +3,58 @@ import { computed, onMounted, ref } from 'vue' import Status from './Status.vue' const sessions = ref([]) +const session_types = ref([]) const rooms = ref([]) const testMode = ref(false) const currentTime = ref(new Date()) const timer = ref(null) +const crowd = ref([]) const roomStatus = computed(() => { - const activeSessions = sessions.value.filter( - (session) => { + return rooms.value.map((room) => { + const roomSessions = sessions.value[room] + const now = currentTime.value + + const currentSession = roomSessions.find((session) => { const start = new Date(session.start) const end = new Date(session.end) - return start <= currentTime.value && currentTime.value <= end - }, - ) - - return rooms.value.map((room) => { - const currentCourse = activeSessions.find((course) => course.room === room) + return start <= now && now <= end + }) - if (currentCourse) { + if (currentSession) { return { room, course: { - title: currentCourse.zh.title, - start: currentCourse.start, - end: currentCourse.end, + title: currentSession.zh.title, + start: currentSession.start, + end: currentSession.end, + uri: currentSession.uri, }, + type: currentSession.type, } - } else { - return { - room, - course: '無', + } + + // no currentSession => find nextSession + + const nextSession = roomSessions.find((session) => new Date(session.start) > now) + if (nextSession) { + const nextSessionStart = new Date(nextSession.start) + if (nextSessionStart.getDate() === now.getDate()) { + return { + room, + course: `下一場 ${nextSession.zh.title} 將於 ${formatTime(nextSession.start, false)} 開始`, + uri: nextSession.uri, + type: nextSession.type, + } } } + + // no nextSession + return { + room, + course: '今日議程已結束', + type: '', + } }) }) @@ -45,9 +65,20 @@ onMounted(() => { fetch('https://coscup.org/2024/json/session.json') .then((res) => res.json()) .then((data) => { - sessions.value = data.sessions - rooms.value = new Set(sessions.value.map((session) => session.room)) + session_types.value = data.session_types.reduce((acc, item) => { + acc[item.id] = item.zh.name + return acc + }, {}) + rooms.value = new Set(data.sessions.map((session) => session.room)) rooms.value = [...rooms.value].sort((a, b) => a.localeCompare(b)) + crowd.value = rooms.value.reduce((acc, item) => { + acc[item] = Math.round(Math.random() * 100) + return acc + }, {}) + sessions.value = rooms.value.reduce((acc, item) => { + acc[item] = data.sessions.filter((session) => session.room === item).sort((a, b) => new Date(a.start) - new Date(b.start)) + return acc + }, {}) }) }) @@ -65,7 +96,7 @@ function startClock() { } } -function formatTime(time) { +function formatTime(time, date = true) { const d = new Date(time) const MM = String(d.getMonth() + 1).padStart(2, '0') const DD = String(d.getDate()).padStart(2, '0') @@ -74,62 +105,143 @@ function formatTime(time) { const weekdays = ['日', '一', '二', '三', '四', '五', '六'] const dayName = weekdays[d.getDay()] - return `${MM}/${DD}(${dayName}) ${hh}:${mm}` + if (date) { + return `${MM}/${DD}(${dayName}) ${hh}:${mm}` + } else { + return `${hh}:${mm}` + } +} + +function interpolateColor(color1, color2, factor) { + const result = color1.map((c, i) => Math.round(c + factor * (color2[i] - c))) + return `rgb(${result[0]}, ${result[1]}, ${result[2]}, 0.6)` +} + +function getColor(type, value) { + if (typeof type === 'string') { + return 'transparent' + } + const green = [189, 252, 201] + const yellow = [255, 255, 153] + const red = [255, 181, 181] + + if (value <= 50) { + return interpolateColor(green, yellow, value / 50) + } else { + return interpolateColor(yellow, red, (value - 50) / 50) + } +} + +function getStatusText(type, value) { + if (typeof type === 'string') { + return '' + } + const words = ['空曠', '寬敞', '適中', '熱絡', '滿座'] + return words[Math.min(Math.round(value / 20), 4)] } diff --git a/content/zh_tw/room/Status.vue b/content/zh_tw/room/Status.vue index c56ddbd9..09d89ec6 100644 --- a/content/zh_tw/room/Status.vue +++ b/content/zh_tw/room/Status.vue @@ -15,31 +15,38 @@ function getProgress(startTime, endTime) { function formatTime(time) { const d = new Date(time) - return `${d.getHours().toString().padStart(2, '0')}:${d.getMinutes().toString().padStart(2, '0')}` + const hh = String(d.getHours()).padStart(2, '0') + const mm = String(d.getMinutes()).padStart(2, '0') + + return `${hh}:${mm}` } diff --git a/content/zh_tw/room/index.md b/content/zh_tw/room/index.md index ac039e39..a15f4d1b 100644 --- a/content/zh_tw/room/index.md +++ b/content/zh_tw/room/index.md @@ -1 +1,5 @@ +--- +aside: false +--- + From faf1d2f5e0360f6e650db9ca89bafbf66448c9fe Mon Sep 17 00:00:00 2001 From: tcandicetc Date: Tue, 27 May 2025 02:09:05 +0800 Subject: [PATCH 11/13] feat: move data fetching to build stage and improve performance - Use CSS variables for color management - Add setInterval cleanup - Hide session track column on narrow screens --- .vitepress/theme/style.css | 5 ++ content/zh_tw/room/Room.vue | 95 +++++++++++++++++++------------- loaders/room.data.ts | 106 ++++++++++++++++++++++++++++++++++++ 3 files changed, 167 insertions(+), 39 deletions(-) create mode 100644 loaders/room.data.ts diff --git a/.vitepress/theme/style.css b/.vitepress/theme/style.css index b8463b5a..71b92180 100644 --- a/.vitepress/theme/style.css +++ b/.vitepress/theme/style.css @@ -68,6 +68,11 @@ --vp-c-danger-2: var(--vp-c-red-2); --vp-c-danger-3: var(--vp-c-red-3); --vp-c-danger-soft: var(--vp-c-red-soft); + + --vp-c-success-1: var(--vp-c-green-1); + --vp-c-success-2: var(--vp-c-green-2); + --vp-c-success-3: var(--vp-c-green-3); + --vp-c-success-soft: var(--vp-c-green-soft); } /** diff --git a/content/zh_tw/room/Room.vue b/content/zh_tw/room/Room.vue index d4bca871..96269296 100644 --- a/content/zh_tw/room/Room.vue +++ b/content/zh_tw/room/Room.vue @@ -1,18 +1,17 @@