From 8e5fa5652e0cb0271728adface13082ea4559dd7 Mon Sep 17 00:00:00 2001 From: Edison Date: Tue, 7 Oct 2025 11:25:09 +0800 Subject: [PATCH] added current time(yellow ring) enhancement follow server time instead of user computer local time. --- backend/server.js | 16 ++++++ src/components/KillSwitchManagement.vue | 73 +++++++++++++++++++------ 2 files changed, 72 insertions(+), 17 deletions(-) diff --git a/backend/server.js b/backend/server.js index 46c9054..be75b6f 100644 --- a/backend/server.js +++ b/backend/server.js @@ -59,6 +59,22 @@ async function startServer() { app.use(cors(corsOptions)); app.use(express.json()); + // --- Public server time endpoints (no auth, no cache) --- + const timeHandler = (req, res) => { + const now = new Date(); + const ymdKL = new Intl.DateTimeFormat('en-CA', { + timeZone: 'Asia/Kuala_Lumpur', + year: 'numeric', month: '2-digit', day: '2-digit' + }).format(now); // "YYYY-MM-DD" + + res.set('Cache-Control', 'no-store, no-cache, must-revalidate, proxy-revalidate'); + res.set('Pragma', 'no-cache'); + res.set('Expires', '0'); + + res.json({ nowIso: now.toISOString(), tz: 'Asia/Kuala_Lumpur', ymdKL }); + }; + app.get('/time', timeHandler); // public path + app.get('/api/time', timeHandler); // also under /api app.use('/api/managers', managerRoutes(db)); app.use('/api', workerRoutes(db)); diff --git a/src/components/KillSwitchManagement.vue b/src/components/KillSwitchManagement.vue index 47a7bcf..6306d8c 100644 --- a/src/components/KillSwitchManagement.vue +++ b/src/components/KillSwitchManagement.vue @@ -64,7 +64,7 @@