Repository navigation
Expand file tree
/
Copy pathapp-config.js
More file actions
50 lines (46 loc) · 2.3 KB
/
Copy pathapp-config.js
File metadata and controls
50 lines (46 loc) · 2.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
// ★ 部署配置(可选)★
// 填入 Supabase 项目凭证即可启用在线排行榜 / 实时新纪录推送。
// 未填写时游戏自动降级为纯本地模式(localStorage 个人最高分),不影响游玩。
//
// 快速开始(详见项目根 sql/init.sql 与 spec 文档):
// 1. 注册 supabase.com(免费版 $0,无需绑卡)→ 创建项目(区域选 Singapore/Tokyo,国内访问较快)
// 2. SQL Editor 中粘贴执行 sql/init.sql(建表 scores + 公开读写 RLS + 启用 Realtime)
// 3. 项目设置 → API:复制 Project URL 填入 url;复制 anon public key 填入 anonKey
// 4. 保存后刷新游戏即可生效(anon key 设计上公开可暴露,仅配合 RLS 使用,无泄露风险)
//
// 免费版额度(2026-07 核实):500MB 数据库 / 5GB 流量每月 / 200 并发 Realtime 连接,
// 项目 7 天无访问自动暂停(数据保留,控制台一键恢复)——个人游戏排行榜绰绰有余。
window.SUPABASE_CFG = {
url: 'https://fypacgpgvaponiwqvsne.supabase.co',
anonKey: 'sb_publishable_qloV7a-oIY_Tb4dZgjutvw_eEmSq4k0',
};
// 若未配置,自动置空(恢复本地模式)
if (!window.SUPABASE_CFG.url || !window.SUPABASE_CFG.anonKey) {
window.SUPABASE_CFG = null;
}
// ============ PWA:离线可用 + 可安装(全屏无浏览器栏) ============
if ('serviceWorker' in navigator && location.protocol === 'https:') {
window.addEventListener('load', function () {
navigator.serviceWorker.register('./sw.js').catch(function () {});
});
}
// 安装提示:独立窗口(PWA)内隐藏;浏览器内按平台给出操作指引
(function () {
function isStandalone() {
return (
window.matchMedia('(display-mode: standalone)').matches ||
window.navigator.standalone === true ||
document.documentElement.style.webkitAppRegion === 'drag'
);
}
function setHint() {
var hint = document.getElementById('appHint');
if (!hint) return;
if (isStandalone()) { hint.style.display = 'none'; return; }
var isIOS = /iphone|ipad|ipod/i.test(navigator.userAgent);
hint.textContent = isIOS
? '📱 Safari 分享 → 添加到主屏幕,全屏畅玩无遮挡'
: '📱 菜单/设置 → 安装应用,全屏畅玩无遮挡';
}
window.addEventListener('DOMContentLoaded', setHint);
})();