@hupu-tech/shaper 0.2.12 → 0.2.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/README.md +6 -0
- package/dist/cli.js +2 -2
- package/dist/cloud/client.d.ts +0 -1
- package/dist/cloud/service-build.d.ts +2 -4
- package/dist/index.js +1 -1
- package/dist/project/create.d.ts +9 -3
- package/dist/project/delivery.d.ts +5 -5
- package/dist/runtime.d.ts +2 -1
- package/dist/runtime.js +1 -1
- package/dist/shared-2WDEQ3AQ.js +19 -0
- package/package.json +1 -1
- package/skills/business/SKILL.md +158 -0
- package/skills/business/activity/README.md +14 -0
- package/skills/business/activity/hupu-leaderboard-template/SKILL.md +52 -0
- package/skills/business/activity/hupu-leaderboard-template/example/README.md +20 -0
- package/skills/business/activity/hupu-leaderboard-template/example/cloudfunctions/activity_api/.cloudignore +3 -0
- package/skills/business/activity/hupu-leaderboard-template/example/cloudfunctions/activity_api/index.js +218 -0
- package/skills/business/activity/hupu-leaderboard-template/example/cloudfunctions/activity_api/package.json +15 -0
- package/skills/business/activity/hupu-leaderboard-template/example/cloudfunctions/activity_api/scf_bootstrap +3 -0
- package/skills/business/activity/hupu-leaderboard-template/example/index.html +291 -0
- package/skills/business/activity/hupu-leaderboard-template/example/migrations/20260828210000_create_leaderboard.sql +54 -0
- package/skills/business/activity/hupu-lottery-draw/SKILL.md +50 -0
- package/skills/business/activity/hupu-lottery-draw/example/README.md +21 -0
- package/skills/business/activity/hupu-lottery-draw/example/cloudfunctions/activity_api/.cloudignore +3 -0
- package/skills/business/activity/hupu-lottery-draw/example/cloudfunctions/activity_api/index.js +142 -0
- package/skills/business/activity/hupu-lottery-draw/example/cloudfunctions/activity_api/package.json +9 -0
- package/skills/business/activity/hupu-lottery-draw/example/cloudfunctions/activity_api/scf_bootstrap +3 -0
- package/skills/business/activity/hupu-lottery-draw/example/index.html +178 -0
- package/skills/business/activity/hupu-lottery-draw/example/migrations/20260828220000_create_draw.sql +193 -0
- package/skills/business/activity/hupu-pk-voting/SKILL.md +54 -0
- package/skills/business/activity/hupu-pk-voting/example/README.md +44 -0
- package/skills/business/activity/hupu-pk-voting/example/cloudfunctions/activity_api/.cloudignore +3 -0
- package/skills/business/activity/hupu-pk-voting/example/cloudfunctions/activity_api/index.js +370 -0
- package/skills/business/activity/hupu-pk-voting/example/cloudfunctions/activity_api/package.json +15 -0
- package/skills/business/activity/hupu-pk-voting/example/cloudfunctions/activity_api/scf_bootstrap +2 -0
- package/skills/business/activity/hupu-pk-voting/example/index.html +729 -0
- package/skills/business/activity/hupu-pk-voting/example/migrations/20260828220000_create_pk_vote.sql +168 -0
- package/skills/business/activity/hupu-request-activity-execute-vote-task/SKILL.md +77 -0
- package/skills/business/activity/hupu-request-activity-get-vote-detail/SKILL.md +84 -0
- package/skills/business/activity/hupu-request-activity-get-vote-task-list/SKILL.md +86 -0
- package/skills/business/activity/hupu-request-activity-list-by-biz-keys/SKILL.md +153 -0
- package/skills/business/activity/hupu-request-activity-report-vote-task/SKILL.md +58 -0
- package/skills/business/activity/hupu-request-activity-submit-vote/SKILL.md +58 -0
- package/skills/business/activity/hupu-vote-task/SKILL.md +47 -0
- package/skills/business/community/README.md +13 -0
- package/skills/business/community/hupu-request-bbs-detail/SKILL.md +197 -0
- package/skills/business/community/hupu-request-bbs-get-tag-thread-list/SKILL.md +257 -0
- package/skills/business/community/hupu-request-bbs-get-topic-threads/SKILL.md +159 -0
- package/skills/business/community/hupu-request-bbs-gets-thread-post-list/SKILL.md +124 -0
- package/skills/business/community/hupu-request-bbs-open-post-editor/SKILL.md +75 -0
- package/skills/business/community/hupu-request-bbs-reply-post/SKILL.md +59 -0
- package/skills/business/community/hupu-score-add-score/SKILL.md +57 -0
- package/skills/business/community/hupu-score-get-item-detail/SKILL.md +173 -0
- package/skills/business/community/hupu-score-get-score/SKILL.md +263 -0
- package/skills/business/quality/README.md +7 -0
- package/skills/business/quality/hupu-security-check-audit/SKILL.md +39 -0
- package/skills/business/quality/hupu-wasm-compression/SKILL.md +69 -0
- package/skills/business/quality/hupu-wasm-compression/agents/openai.yaml +4 -0
- package/skills/business/quality/hupu-wasm-compression/tool/checks.mjs +90 -0
- package/skills/business/quality/hupu-wasm-compression/tool/compress-worker.mjs +40 -0
- package/skills/business/quality/hupu-wasm-compression/tool/public/app.js +84 -0
- package/skills/business/quality/hupu-wasm-compression/tool/public/index.html +80 -0
- package/skills/business/quality/hupu-wasm-compression/tool/public/style.css +3 -0
- package/skills/business/quality/hupu-wasm-compression/tool/server.mjs +126 -0
- package/skills/business/quality/hupu-web-security-audit/SKILL.md +45 -0
- package/skills/business/quality/hupu-web-security-audit/agents/openai.yaml +4 -0
- package/skills/business/rewards/README.md +13 -0
- package/skills/business/rewards/hupu-vacoin/SKILL.md +70 -0
- package/skills/business/rewards/hupu-vacoin-consume-coins/SKILL.md +47 -0
- package/skills/business/rewards/hupu-vacoin-get-coin-overview/SKILL.md +52 -0
- package/skills/business/rewards/hupu-vacoin-get-session-coins/SKILL.md +44 -0
- package/skills/business/rewards/hupu-vacoin-reset-session-id/SKILL.md +39 -0
- package/skills/business/rewards/hupu-vatask/SKILL.md +63 -0
- package/skills/business/rewards/hupu-vatask-complete-reward-video/SKILL.md +43 -0
- package/skills/business/rewards/hupu-vatask-consume-activity-chance/SKILL.md +48 -0
- package/skills/business/rewards/hupu-vatask-get-activity-task-state/SKILL.md +49 -0
- package/skills/business/runtime/README.md +13 -0
- package/skills/business/runtime/hupu-add-to-desktop/SKILL.md +51 -0
- package/skills/business/runtime/hupu-close-webview/SKILL.md +48 -0
- package/skills/business/runtime/hupu-cloud-auth/SKILL.md +43 -0
- package/skills/business/runtime/hupu-cloud-request/SKILL.md +56 -0
- package/skills/business/runtime/hupu-fullscreen-safe-top/SKILL.md +33 -0
- package/skills/business/runtime/hupu-navigate-to/SKILL.md +45 -0
- package/skills/business/runtime/hupu-request/SKILL.md +67 -0
- package/skills/business/runtime/hupu-seer-chat/SKILL.md +183 -0
- package/skills/business/runtime/hupu-track-report/SKILL.md +71 -0
- package/skills/business/sharing/README.md +7 -0
- package/skills/business/sharing/hupu-oss-upload-file/SKILL.md +40 -0
- package/skills/business/sharing/hupu-result-poster-posting/SKILL.md +37 -0
- package/skills/business/sharing/hupu-result-poster-posting/example/README.md +14 -0
- package/skills/business/sharing/hupu-result-poster-posting/example/cloudfunctions/activity_api/.cloudignore +3 -0
- package/skills/business/sharing/hupu-result-poster-posting/example/cloudfunctions/activity_api/index.js +187 -0
- package/skills/business/sharing/hupu-result-poster-posting/example/cloudfunctions/activity_api/package.json +15 -0
- package/skills/business/sharing/hupu-result-poster-posting/example/cloudfunctions/activity_api/scf_bootstrap +3 -0
- package/skills/business/sharing/hupu-result-poster-posting/example/index.html +256 -0
- package/skills/business/sharing/hupu-result-poster-posting/example/migrations/20260828213000_create_result_poster_results.sql +60 -0
- package/skills/business/sharing/hupu-result-poster-posting/references/api-contract.md +46 -0
- package/skills/business/sharing/hupu-social-share/SKILL.md +27 -0
- package/skills/business/sports/README.md +27 -0
- package/skills/business/sports/hupu-request-basketball-player-info/SKILL.md +131 -0
- package/skills/business/sports/hupu-request-basketball-single-match/SKILL.md +158 -0
- package/skills/business/sports/hupu-request-basketball-team-info/SKILL.md +96 -0
- package/skills/business/sports/hupu-request-basketball-team-player-list/SKILL.md +108 -0
- package/skills/business/sports/hupu-request-basketball-team-salary-info/SKILL.md +85 -0
- package/skills/business/sports/hupu-request-football-coach-info/SKILL.md +76 -0
- package/skills/business/sports/hupu-request-football-live-room-news-list/SKILL.md +85 -0
- package/skills/business/sports/hupu-request-football-match-info/SKILL.md +126 -0
- package/skills/business/sports/hupu-request-football-player-info/SKILL.md +82 -0
- package/skills/business/sports/hupu-request-football-team-info/SKILL.md +83 -0
- package/skills/business/sports/hupu-request-football-team-player-season-stats/SKILL.md +73 -0
- package/skills/business/sports/hupu-request-football-team-season-year/SKILL.md +68 -0
- package/skills/business/sports/hupu-request-kog-playbyplay/SKILL.md +77 -0
- package/skills/business/sports/hupu-request-live-tab-info-list/SKILL.md +85 -0
- package/skills/business/sports/hupu-request-live-tab-list/SKILL.md +66 -0
- package/skills/business/sports/hupu-request-lol-playbyplay/SKILL.md +77 -0
- package/skills/business/sports/hupu-request-match-get-tab-detail-schedule-list/SKILL.md +113 -0
- package/skills/business/sports/hupu-request-match-query-all-diagram-info-by-id/SKILL.md +79 -0
- package/skills/business/sports/hupu-request-match-query-match-stats-by-match-info/SKILL.md +85 -0
- package/skills/business/sports/hupu-request-news-news-common-list/SKILL.md +90 -0
- package/skills/business/sports/hupu-request-news-player-news-list/SKILL.md +79 -0
- package/skills/business/sports/hupu-request-news-subject-news/SKILL.md +89 -0
- package/skills/business/sports/hupu-request-news-team-news-list/SKILL.md +76 -0
- package/skills/business/storage/README.md +9 -0
- package/skills/business/storage/hupu-cloud-save/SKILL.md +129 -0
- package/skills/business/storage/hupu-cloud-save/references/legacy-migration.md +111 -0
- package/skills/business/storage/hupu-cloud-save-load/SKILL.md +41 -0
- package/skills/business/storage/hupu-cloud-save-save/SKILL.md +45 -0
- package/skills/business/storage/hupu-storage-get-value/SKILL.md +26 -0
- package/skills/business/storage/hupu-storage-set-value/SKILL.md +42 -0
- package/skills/business/user/README.md +6 -0
- package/skills/business/user/hupu-auth-get-user-info/SKILL.md +47 -0
- package/skills/business/user/hupu-game-auth/SKILL.md +46 -0
- package/skills/core/hupu-business/SKILL.md +1 -1
- package/skills/core/hupu-business/references/runtime.md +17 -11
- package/skills/core/shaper-backend/SKILL.md +1 -1
- package/skills/core/shaper-backend/references/database.md +2 -2
- package/skills/core/shaper-backend/references/legacy.md +1 -1
- package/skills/core/shaper-backend/references/node-server.md +29 -20
- package/skills/core/shaper-development/SKILL.md +5 -1
- package/skills/core/shaper-development/references/project-setup.md +1 -1
- package/skills/core/shaper-game-development/SKILL.md +1 -1
- package/skills/core/shaper-release/SKILL.md +1 -1
- package/templates/cloud-service/README.md +4 -30
- package/templates/cloud-service/cloud.json +5 -8
- package/templates/cloud-service/package-lock.json +922 -15
- package/templates/cloud-service/release.json +4 -4
- package/templates/cloud-service/server.cjs +37 -0
- package/templates/leaderboard/README.md +3 -0
- package/templates/leaderboard/cloud/database/migrations/202611130001_leaderboard.sql +6 -0
- package/templates/leaderboard/cloud/functions/api/cloud.json +10 -0
- package/templates/leaderboard/cloud/functions/api/leaderboard.cjs +49 -0
- package/templates/leaderboard/cloud/functions/api/package-lock.json +1093 -0
- package/templates/leaderboard/cloud/functions/api/package.json +19 -0
- package/templates/leaderboard/cloud/functions/api/server.cjs +25 -0
- package/templates/leaderboard/cloud/gateway/routes.json +15 -0
- package/templates/leaderboard/docs/design.md +1 -0
- package/templates/leaderboard/docs/integration.md +12 -0
- package/templates/leaderboard/docs/product.md +1 -0
- package/templates/leaderboard/docs/validation.md +1 -0
- package/templates/leaderboard/index.html +12 -0
- package/templates/leaderboard/package-lock.json +828 -0
- package/templates/leaderboard/package.json +17 -0
- package/templates/leaderboard/public/.gitkeep +1 -0
- package/templates/leaderboard/shaper.config.json +7 -0
- package/templates/leaderboard/src/main.js +67 -0
- package/templates/leaderboard/src/style.css +69 -0
- package/templates/leaderboard/test/leaderboard.test.cjs +93 -0
- package/templates/offline-game/README.md +3 -0
- package/templates/offline-game/docs/design.md +1 -0
- package/templates/offline-game/docs/integration.md +10 -0
- package/templates/offline-game/docs/product.md +1 -0
- package/templates/offline-game/docs/validation.md +1 -0
- package/templates/offline-game/index.html +1 -0
- package/templates/offline-game/package-lock.json +828 -0
- package/templates/offline-game/package.json +16 -0
- package/templates/offline-game/public/.gitkeep +1 -0
- package/templates/offline-game/shaper.config.json +7 -0
- package/templates/offline-game/src/game.js +11 -0
- package/templates/offline-game/src/main.js +12 -0
- package/templates/offline-game/src/style.css +1 -0
- package/templates/offline-game/test/game.test.js +7 -0
- package/dist/shared-APGA5MU5.js +0 -19
- package/templates/cloud-service/handlers.cjs +0 -46
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "shaper-leaderboard",
|
|
3
|
+
"version": "0.0.0",
|
|
4
|
+
"private": true,
|
|
5
|
+
"type": "module",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"dev": "vite",
|
|
8
|
+
"build": "vite build",
|
|
9
|
+
"preview": "vite preview",
|
|
10
|
+
"check": "node --check src/main.js",
|
|
11
|
+
"test": "node --test test/*.test.cjs",
|
|
12
|
+
"backend:install": "npm ci --prefix cloud/functions/api"
|
|
13
|
+
},
|
|
14
|
+
"devDependencies": {
|
|
15
|
+
"vite": "8.3.4"
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import "./style.css";
|
|
2
|
+
document.querySelector("#app").innerHTML =
|
|
3
|
+
`<main><small>SHAPER · LEADERBOARD</small><h1>一起刷新纪录。</h1><p>记录个人最佳成绩,看看大家的表现。</p><section><h2>挑战榜</h2><ol id="ranking"></ol><button id="refresh">刷新榜单</button></section><section><h2>提交我的成绩</h2><p>这是自报成绩示例,不用于有奖排名。</p><form id="submit"><label>展示昵称<input name="displayName" maxlength="24" required autocomplete="nickname"></label><label>成绩<input name="score" type="number" min="0" max="1000000" step="1" required></label><button>保存最佳成绩</button></form><p id="message" role="status"></p></section></main>`;
|
|
4
|
+
const message = document.querySelector("#message");
|
|
5
|
+
let busy = false;
|
|
6
|
+
async function request(args) {
|
|
7
|
+
const sdk = window.ShaperAI ?? window.ColorboxAI;
|
|
8
|
+
if (!sdk?.cloud?.request)
|
|
9
|
+
throw Error("请从 Shaper 预览入口打开;提交成绩需要登录。");
|
|
10
|
+
const r = await sdk.cloud.request(args);
|
|
11
|
+
if (r.statusCode < 200 || r.statusCode >= 300)
|
|
12
|
+
throw Error(r.message || "排行榜暂不可用,请稍后重试。");
|
|
13
|
+
return r.data;
|
|
14
|
+
}
|
|
15
|
+
async function load() {
|
|
16
|
+
const data = await request({ path: "/api/leaderboard" });
|
|
17
|
+
const list = document.querySelector("#ranking");
|
|
18
|
+
list.replaceChildren();
|
|
19
|
+
for (const row of data.rows) {
|
|
20
|
+
const li = document.createElement("li");
|
|
21
|
+
li.textContent = `${row.display_name} · ${row.score} 分`;
|
|
22
|
+
list.append(li);
|
|
23
|
+
}
|
|
24
|
+
if (!data.rows.length) {
|
|
25
|
+
const li = document.createElement("li");
|
|
26
|
+
li.textContent = "还没有成绩,成为第一位挑战者吧。";
|
|
27
|
+
list.append(li);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
document.querySelector("#refresh").onclick = async () => {
|
|
31
|
+
try {
|
|
32
|
+
await load();
|
|
33
|
+
message.textContent = "榜单已更新。";
|
|
34
|
+
} catch (e) {
|
|
35
|
+
message.textContent = e.message;
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
document.querySelector("#submit").onsubmit = async (e) => {
|
|
39
|
+
e.preventDefault();
|
|
40
|
+
if (busy) return;
|
|
41
|
+
busy = true;
|
|
42
|
+
const button = e.target.querySelector("button");
|
|
43
|
+
button.disabled = true;
|
|
44
|
+
try {
|
|
45
|
+
const form = new FormData(e.target);
|
|
46
|
+
const result = await request({
|
|
47
|
+
path: "/api/leaderboard",
|
|
48
|
+
method: "POST",
|
|
49
|
+
data: {
|
|
50
|
+
displayName: form.get("displayName"),
|
|
51
|
+
score: Number(form.get("score")),
|
|
52
|
+
},
|
|
53
|
+
});
|
|
54
|
+
message.textContent = result.improved
|
|
55
|
+
? "新纪录已保存。"
|
|
56
|
+
: "已保留你的最佳成绩。";
|
|
57
|
+
await load();
|
|
58
|
+
} catch (e) {
|
|
59
|
+
message.textContent = e.message;
|
|
60
|
+
} finally {
|
|
61
|
+
busy = false;
|
|
62
|
+
button.disabled = false;
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
load().catch((e) => {
|
|
66
|
+
message.textContent = e.message;
|
|
67
|
+
});
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
* {
|
|
2
|
+
box-sizing: border-box;
|
|
3
|
+
}
|
|
4
|
+
body {
|
|
5
|
+
margin: 0;
|
|
6
|
+
background: #f4f7f6;
|
|
7
|
+
color: #173c39;
|
|
8
|
+
font:
|
|
9
|
+
16px/1.7 system-ui,
|
|
10
|
+
sans-serif;
|
|
11
|
+
}
|
|
12
|
+
main {
|
|
13
|
+
max-width: 760px;
|
|
14
|
+
margin: auto;
|
|
15
|
+
padding: 60px 24px;
|
|
16
|
+
}
|
|
17
|
+
small {
|
|
18
|
+
letter-spacing: 0.15em;
|
|
19
|
+
color: #587e78;
|
|
20
|
+
}
|
|
21
|
+
h1 {
|
|
22
|
+
font-size: clamp(32px, 6vw, 52px);
|
|
23
|
+
line-height: 1.2;
|
|
24
|
+
}
|
|
25
|
+
section {
|
|
26
|
+
background: white;
|
|
27
|
+
padding: 28px;
|
|
28
|
+
margin: 24px 0;
|
|
29
|
+
border: 1px solid #dce7e3;
|
|
30
|
+
border-radius: 18px;
|
|
31
|
+
}
|
|
32
|
+
button {
|
|
33
|
+
background: #256b5e;
|
|
34
|
+
color: white;
|
|
35
|
+
border: 0;
|
|
36
|
+
border-radius: 10px;
|
|
37
|
+
padding: 13px 22px;
|
|
38
|
+
font: inherit;
|
|
39
|
+
cursor: pointer;
|
|
40
|
+
margin: 8px 10px 8px 0;
|
|
41
|
+
}
|
|
42
|
+
button:disabled {
|
|
43
|
+
opacity: 0.5;
|
|
44
|
+
cursor: default;
|
|
45
|
+
}
|
|
46
|
+
input {
|
|
47
|
+
font: inherit;
|
|
48
|
+
width: 100%;
|
|
49
|
+
padding: 12px;
|
|
50
|
+
border: 1px solid #bdd0ca;
|
|
51
|
+
border-radius: 8px;
|
|
52
|
+
}
|
|
53
|
+
label {
|
|
54
|
+
display: block;
|
|
55
|
+
margin-top: 14px;
|
|
56
|
+
}
|
|
57
|
+
p {
|
|
58
|
+
color: #54716b;
|
|
59
|
+
}
|
|
60
|
+
strong {
|
|
61
|
+
font-size: 28px;
|
|
62
|
+
}
|
|
63
|
+
li {
|
|
64
|
+
padding: 12px;
|
|
65
|
+
border-bottom: 1px solid #e4ece9;
|
|
66
|
+
}
|
|
67
|
+
#message {
|
|
68
|
+
min-height: 2em;
|
|
69
|
+
}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
const test = require("node:test");
|
|
2
|
+
const assert = require("node:assert/strict");
|
|
3
|
+
const {
|
|
4
|
+
registerLeaderboard,
|
|
5
|
+
} = require("../cloud/functions/api/leaderboard.cjs");
|
|
6
|
+
function setup() {
|
|
7
|
+
const routes = {};
|
|
8
|
+
const calls = [];
|
|
9
|
+
registerLeaderboard(
|
|
10
|
+
{ get: (p, f) => (routes.get = f), post: (p, f) => (routes.post = f) },
|
|
11
|
+
{
|
|
12
|
+
auth: { requireUser: async () => ({ puid: "verified-user" }) },
|
|
13
|
+
db: {
|
|
14
|
+
query: async (sql, args) => {
|
|
15
|
+
calls.push({ sql, args });
|
|
16
|
+
return { rows: [], rowCount: 1 };
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
);
|
|
21
|
+
return { routes, calls };
|
|
22
|
+
}
|
|
23
|
+
function response() {
|
|
24
|
+
return {
|
|
25
|
+
statusCode: 200,
|
|
26
|
+
status(n) {
|
|
27
|
+
this.statusCode = n;
|
|
28
|
+
return this;
|
|
29
|
+
},
|
|
30
|
+
json(body) {
|
|
31
|
+
this.body = body;
|
|
32
|
+
return this;
|
|
33
|
+
},
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
test("submission uses verified identity and parameterized SQL", async () => {
|
|
37
|
+
const { routes, calls } = setup();
|
|
38
|
+
const res = response();
|
|
39
|
+
await routes.post(
|
|
40
|
+
{
|
|
41
|
+
get: () => "",
|
|
42
|
+
body: { puid: "forged", score: 100, displayName: "Player" },
|
|
43
|
+
},
|
|
44
|
+
res,
|
|
45
|
+
(e) => {
|
|
46
|
+
throw e;
|
|
47
|
+
},
|
|
48
|
+
);
|
|
49
|
+
assert.equal(calls[0].args[0], "verified-user");
|
|
50
|
+
assert.equal(calls[0].args[3], 100);
|
|
51
|
+
assert.equal(res.body.improved, true);
|
|
52
|
+
});
|
|
53
|
+
test("invalid scores cannot reach the database", async () => {
|
|
54
|
+
for (const score of [-1, 1.5, 1000001, "100"]) {
|
|
55
|
+
const { routes, calls } = setup();
|
|
56
|
+
const res = response();
|
|
57
|
+
await routes.post(
|
|
58
|
+
{ get: () => "", body: { score, displayName: "Player" } },
|
|
59
|
+
res,
|
|
60
|
+
(e) => {
|
|
61
|
+
throw e;
|
|
62
|
+
},
|
|
63
|
+
);
|
|
64
|
+
assert.equal(res.statusCode, 400);
|
|
65
|
+
assert.equal(calls.length, 0);
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
test("authentication failures propagate before writing", async () => {
|
|
69
|
+
let handler;
|
|
70
|
+
registerLeaderboard(
|
|
71
|
+
{
|
|
72
|
+
get() {},
|
|
73
|
+
post(p, f) {
|
|
74
|
+
handler = f;
|
|
75
|
+
},
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
auth: {
|
|
79
|
+
requireUser: async () => {
|
|
80
|
+
throw Error("unauthorized");
|
|
81
|
+
},
|
|
82
|
+
},
|
|
83
|
+
db: {
|
|
84
|
+
query() {
|
|
85
|
+
throw Error("should not run");
|
|
86
|
+
},
|
|
87
|
+
},
|
|
88
|
+
},
|
|
89
|
+
);
|
|
90
|
+
let error;
|
|
91
|
+
await handler({ get: () => "" }, response(), (e) => (error = e));
|
|
92
|
+
assert.equal(error.message, "unauthorized");
|
|
93
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
状态和结算逻辑集中在 src/game.js,页面负责交互与保存。存档按版本校验;结算后立即保存,重复刷新不重复领取。设备时间和本地存档可修改,因此不具备防作弊能力。当前只支持单标签页,不跨设备同步;多标签共享存档须在实际项目增加互斥或冲突处理。
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
# 集成离线养成
|
|
2
|
+
|
|
3
|
+
新项目:先 init 关联应用,再 shaper create --template offline-game。已有工程:只读本模板,保留原入口、技术栈和存档。
|
|
4
|
+
|
|
5
|
+
1. 先找现有资源余额、升级规则、计时和存档模块;已有能力直接复用,不新建第二套余额。
|
|
6
|
+
2. 参考 src/game.js 的 settle/upgrade,映射到现有字段和经济规则。存档 key 用项目自己的名称;已有存档增加版本迁移,不清空。
|
|
7
|
+
3. 将结算接到恢复页面、切回前台和保存时机;先结算再保存,避免反复领取。页面参考 src/main.js,按现有组件体系重写。
|
|
8
|
+
4. 验证退出再进入、8小时上限、重复刷新、时间倒退、损坏存档、存储不可用、升级扣费;多标签需求另补一致性保护。
|
|
9
|
+
|
|
10
|
+
完成条件:原业务仍可用、已有存档保留、新规则通过测试,docs/validation.md 记录实测。只生成文件不代表完成。涉及真实奖励或多人竞争时改用服务端权威时间与计分,不直接把本地余额上传成可信成绩。
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
离线小花园:收集阳光→升级产出→离开→返回结算。每秒产出等于等级,升级消耗当前等级×20,等级上限50,离线收益上限8小时。不接云服务,不作为有奖活动计分依据。
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
尚未验证。分别记录本地测试、浏览器体验;排行榜还须记录真实登录、数据库迁移和云部署结果。
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<!doctype html><html lang="zh-CN"><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1"><title>离线小花园</title></head><body><div id="app"></div><script type="module" src="/src/main.js"></script></body></html>
|