feat(app): JSON-driven theaters, admin CRUD with login, hidden flag, image upload, PWA
This commit is contained in:
1 parent
44823a5b90
commit
5fdd78acc6
22 files changed
+2668
-108
No files matched your search
@@ -0,0 +1,192 @@
|
||||
{
|
||||
"updated_at": "2026-10-27T15:19:41.647Z",
|
||||
"theaters": [
|
||||
{
|
||||
"slug": "house-cinema-samyan",
|
||||
"name": "HOUSE CINEMA SAMYAN",
|
||||
"area": "ชั้น 5 สามย่านมิตรทาวน์ กรุงเทพฯ",
|
||||
"distance": "0 km.",
|
||||
"categories": [
|
||||
"หนังนอกกระแส"
|
||||
],
|
||||
"description": "โรงภาพยนตร์สำหรับคนที่อยากค้นพบหนังหลากหลาย เน้นภาพยนตร์นอกกระแสและเรื่องที่ไม่ได้เข้าฉายในวงกว้าง พร้อมเรื่องราวและมุมมองที่แตกต่างสำหรับคนรักหนัง",
|
||||
"address": "ชั้น 5 ศูนย์การค้าสามย่านมิตรทาวน์ 944/1 ถนนพระราม 4 แขวงวังใหม่ เขตปทุมวัน กรุงเทพฯ 10330",
|
||||
"map_url": "https://maps.google.com/?q=House+Samyan",
|
||||
"transport": [
|
||||
{
|
||||
"icon": "car",
|
||||
"label": "รถยนต์ส่วนตัว",
|
||||
"value": "ที่จอดรถภายในศูนย์การค้าสามย่านมิตรทาวน์"
|
||||
},
|
||||
{
|
||||
"icon": "train",
|
||||
"label": "รถไฟฟ้า",
|
||||
"value": "MRT สถานีสามย่าน"
|
||||
},
|
||||
{
|
||||
"icon": "bus",
|
||||
"label": "รถประจำทาง",
|
||||
"value": "29, 34, 36, 40, 47, 50"
|
||||
}
|
||||
],
|
||||
"contacts": [
|
||||
{
|
||||
"label": "Website",
|
||||
"value": "www.housesamyan.com"
|
||||
},
|
||||
{
|
||||
"label": "Mobile Application",
|
||||
"value": "House Cinema"
|
||||
},
|
||||
{
|
||||
"label": "Facebook",
|
||||
"value": "House Samyan"
|
||||
},
|
||||
{
|
||||
"label": "Call",
|
||||
"value": "098-869-0997"
|
||||
}
|
||||
],
|
||||
"payments": [
|
||||
"เงินสด",
|
||||
"บัตรเครดิต",
|
||||
"สแกนจ่าย"
|
||||
],
|
||||
"facilities": [
|
||||
{
|
||||
"icon": "sofa",
|
||||
"title": "โซนนั่งรอ",
|
||||
"sub": "บริเวณโถงโรงภาพยนตร์"
|
||||
},
|
||||
{
|
||||
"icon": "ticket",
|
||||
"title": "จุดจำหน่ายตั๋ว",
|
||||
"sub": "Box Office ชั้น 5"
|
||||
},
|
||||
{
|
||||
"icon": "food",
|
||||
"title": "ร้านอาหาร",
|
||||
"sub": "ภายในศูนย์การค้า"
|
||||
},
|
||||
{
|
||||
"icon": "cafe",
|
||||
"title": "ร้านคาเฟ่",
|
||||
"sub": "บริเวณโถงโรงภาพยนตร์"
|
||||
},
|
||||
{
|
||||
"icon": "garden",
|
||||
"title": "สวนหย่อม",
|
||||
"sub": "ลานกลางแจ้ง"
|
||||
},
|
||||
{
|
||||
"icon": "book",
|
||||
"title": "ร้านหนังสือ",
|
||||
"sub": "ภายในศูนย์การค้า"
|
||||
},
|
||||
{
|
||||
"icon": "workspace",
|
||||
"title": "Co-Learning Space",
|
||||
"sub": "บริเวณโถงโรงภาพยนตร์"
|
||||
},
|
||||
{
|
||||
"icon": "shop",
|
||||
"title": "อื่นๆ",
|
||||
"sub": "ร้านทำผม ร้านทำเล็บ"
|
||||
}
|
||||
],
|
||||
"hidden": false,
|
||||
"image": null
|
||||
},
|
||||
{
|
||||
"slug": "major-hollywood",
|
||||
"name": "MAJOR HOLLYWOOD",
|
||||
"area": "กรุงเทพฯ",
|
||||
"distance": "—",
|
||||
"categories": [
|
||||
"หนังในกระแส"
|
||||
],
|
||||
"description": null,
|
||||
"address": null,
|
||||
"map_url": null,
|
||||
"transport": [],
|
||||
"contacts": [],
|
||||
"payments": [],
|
||||
"facilities": [],
|
||||
"hidden": false,
|
||||
"image": null
|
||||
},
|
||||
{
|
||||
"slug": "century",
|
||||
"name": "CENTURY",
|
||||
"area": "กรุงเทพฯ",
|
||||
"distance": "—",
|
||||
"categories": [
|
||||
"หนังในกระแส"
|
||||
],
|
||||
"description": null,
|
||||
"address": null,
|
||||
"map_url": null,
|
||||
"transport": [],
|
||||
"contacts": [],
|
||||
"payments": [],
|
||||
"facilities": [],
|
||||
"hidden": false,
|
||||
"image": null
|
||||
},
|
||||
{
|
||||
"slug": "ck-plaza",
|
||||
"name": "CK PLAZA",
|
||||
"area": "กรุงเทพฯ",
|
||||
"distance": "—",
|
||||
"categories": [
|
||||
"หนังในกระแส"
|
||||
],
|
||||
"description": null,
|
||||
"address": null,
|
||||
"map_url": null,
|
||||
"transport": [],
|
||||
"contacts": [],
|
||||
"payments": [],
|
||||
"facilities": [],
|
||||
"hidden": false,
|
||||
"image": null
|
||||
},
|
||||
{
|
||||
"slug": "thana-cineplex",
|
||||
"name": "THANA CINEPLEX",
|
||||
"area": "กรุงเทพฯ",
|
||||
"distance": "—",
|
||||
"categories": [
|
||||
"หนังในกระแส"
|
||||
],
|
||||
"description": null,
|
||||
"address": null,
|
||||
"map_url": null,
|
||||
"transport": [],
|
||||
"contacts": [],
|
||||
"payments": [],
|
||||
"facilities": [],
|
||||
"hidden": false,
|
||||
"image": null
|
||||
},
|
||||
{
|
||||
"slug": "coliseum-paradise",
|
||||
"name": "COLISEUM PARADISE",
|
||||
"area": "กรุงเทพฯ",
|
||||
"distance": "—",
|
||||
"categories": [
|
||||
"หนังคลาสสิก",
|
||||
"อาร์ตเฮาส์"
|
||||
],
|
||||
"description": null,
|
||||
"address": null,
|
||||
"map_url": null,
|
||||
"transport": [],
|
||||
"contacts": [],
|
||||
"payments": [],
|
||||
"facilities": [],
|
||||
"hidden": false,
|
||||
"image": null
|
||||
}
|
||||
]
|
||||
}
|
||||
Whitespace-only changes.
+23
-10
@@ -1,20 +1,33 @@
|
||||
{
|
||||
"name": "App",
|
||||
"short_name": "App",
|
||||
"description": "Agent-Native app starter ready to customize",
|
||||
"start_url": "./",
|
||||
"background_color": "#111111",
|
||||
"theme_color": "#18181B",
|
||||
"name": "AlterFlixHub — โรงหนังอิสระ",
|
||||
"short_name": "AlterFlixHub",
|
||||
"description": "ค้นหาโรงภาพยนตร์อิสระ ทางเลือกในการดูหนัง",
|
||||
"lang": "th",
|
||||
"dir": "ltr",
|
||||
"start_url": "/",
|
||||
"scope": "/",
|
||||
"display": "standalone",
|
||||
"background_color": "#0D0D0D",
|
||||
"theme_color": "#0D0D0D",
|
||||
"icons": [
|
||||
{
|
||||
"src": "icon-192.svg",
|
||||
"src": "/icon-192.svg",
|
||||
"sizes": "192x192",
|
||||
"type": "image/svg+xml"
|
||||
"type": "image/svg+xml",
|
||||
"purpose": "any"
|
||||
},
|
||||
{
|
||||
"src": "icon-512.svg",
|
||||
"src": "/icon-512.svg",
|
||||
"sizes": "512x512",
|
||||
"type": "image/svg+xml"
|
||||
"type": "image/svg+xml",
|
||||
"purpose": "any"
|
||||
}
|
||||
],
|
||||
"shortcuts": [
|
||||
{
|
||||
"name": "จัดการข้อมูล",
|
||||
"short_name": "หลังบ้าน",
|
||||
"url": "/admin"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,120 @@
|
||||
/* AlterFlixHub Service Worker — PWA
|
||||
* ------------------------------------------------------------
|
||||
* ★ หน้าเว็บ (navigation) : network-first → ออฟไลน์ใช้แคช
|
||||
* ★ ข้อมูล JSON (/data/) : network-first → กันข้อมูลค้างหลังแก้ในหลังบ้าน
|
||||
* ★ ไฟล์นิ่ง (_assets, svg): cache-first + อัปเดตพื้นหลัง
|
||||
* ★ ข้าม /_agent-native/ (API ของแพลตฟอร์ม) — ห้ามแคช
|
||||
* ★ อัปเดตเวอร์ชัน: bump CACHE_VERSION แล้ว reload ครั้งเดียวตอน controllerchange
|
||||
*/
|
||||
|
||||
const CACHE_VERSION = "alterflixhub-v1.1.0";
|
||||
const PRECACHE = [
|
||||
"/",
|
||||
"/admin",
|
||||
"/data/theaters.json",
|
||||
"/manifest.json",
|
||||
"/favicon.svg",
|
||||
"/icon-192.svg",
|
||||
"/icon-512.svg",
|
||||
];
|
||||
|
||||
self.addEventListener("install", (event) => {
|
||||
event.waitUntil(
|
||||
(async () => {
|
||||
const cache = await caches.open(CACHE_VERSION);
|
||||
await Promise.all(
|
||||
PRECACHE.map((url) =>
|
||||
cache.add(new Request(url, { cache: "reload" })).catch(() => undefined),
|
||||
),
|
||||
);
|
||||
await self.skipWaiting();
|
||||
})(),
|
||||
);
|
||||
});
|
||||
|
||||
self.addEventListener("activate", (event) => {
|
||||
event.waitUntil(
|
||||
(async () => {
|
||||
const keys = await caches.keys();
|
||||
await Promise.all(
|
||||
keys.filter((key) => key !== CACHE_VERSION).map((key) => caches.delete(key)),
|
||||
);
|
||||
await self.clients.claim();
|
||||
})(),
|
||||
);
|
||||
});
|
||||
|
||||
self.addEventListener("message", (event) => {
|
||||
if (event.data === "SKIP_WAITING") self.skipWaiting();
|
||||
});
|
||||
|
||||
const isPlatformApi = (url) =>
|
||||
url.pathname.startsWith("/_agent-native/") ||
|
||||
url.pathname.startsWith("/api/") ||
|
||||
url.pathname.startsWith("/.well-known/");
|
||||
|
||||
async function networkFirst(request, fallbackUrl) {
|
||||
const cache = await caches.open(CACHE_VERSION);
|
||||
try {
|
||||
const response = await fetch(request);
|
||||
if (response && response.ok) cache.put(request, response.clone());
|
||||
return response;
|
||||
} catch {
|
||||
const cached = await cache.match(request);
|
||||
if (cached) return cached;
|
||||
if (fallbackUrl) {
|
||||
const fallback = await cache.match(fallbackUrl);
|
||||
if (fallback) return fallback;
|
||||
}
|
||||
return new Response("ออฟไลน์ — ไม่มีข้อมูลในแคช", {
|
||||
status: 503,
|
||||
headers: { "content-type": "text/plain; charset=utf-8" },
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
async function cacheFirst(request) {
|
||||
const cache = await caches.open(CACHE_VERSION);
|
||||
const cached = await cache.match(request);
|
||||
if (cached) {
|
||||
// อัปเดตพื้นหลัง (ไม่บล็อกการตอบ)
|
||||
fetch(request)
|
||||
.then((response) => {
|
||||
if (response && response.ok) cache.put(request, response.clone());
|
||||
})
|
||||
.catch(() => undefined);
|
||||
return cached;
|
||||
}
|
||||
const response = await fetch(request);
|
||||
if (response && response.ok) cache.put(request, response.clone());
|
||||
return response;
|
||||
}
|
||||
|
||||
self.addEventListener("fetch", (event) => {
|
||||
const { request } = event;
|
||||
if (request.method !== "GET") return;
|
||||
|
||||
const url = new URL(request.url);
|
||||
if (url.origin !== self.location.origin) return;
|
||||
if (isPlatformApi(url)) return;
|
||||
|
||||
// เอกสารหน้าเว็บ
|
||||
if (request.mode === "navigate") {
|
||||
event.respondWith(networkFirst(request, "/"));
|
||||
return;
|
||||
}
|
||||
|
||||
// ข้อมูลจากไฟล์ JSON
|
||||
if (url.pathname.startsWith("/data/")) {
|
||||
event.respondWith(networkFirst(request));
|
||||
return;
|
||||
}
|
||||
|
||||
// ไฟล์นิ่ง
|
||||
if (
|
||||
url.pathname.startsWith("/assets/") ||
|
||||
/\.(?:css|js|mjs|svg|png|jpg|jpeg|webp|woff2?|ttf)$/.test(url.pathname)
|
||||
) {
|
||||
event.respondWith(cacheFirst(request));
|
||||
}
|
||||
});
|
||||
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"version": "1.1.0",
|
||||
"app": "alterflixhub",
|
||||
"cache": "alterflixhub-v1.1.0",
|
||||
"updated_at": "2026-10-27T02:30:00+07:00"
|
||||
}
|
||||
Reference in new issue
Block a user