fix: 修正boss-battle.js相對匯入路徑由./js/改為./,補上✕與返回地圖防禦性回呼,升級驗證守門員
Browse files- boss.html +2 -2
- js/boss-battle.js +4 -4
- tools/verify-integrity.mjs +13 -3
boss.html
CHANGED
|
@@ -23,7 +23,7 @@
|
|
| 23 |
<div class="scene-bg" id="introSceneBg"></div>
|
| 24 |
<div class="intro-wrap">
|
| 25 |
<div class="intro-card" style="position: relative;">
|
| 26 |
-
<button class="btn-card-close" id="btnExitToMapTop" type="button" title="返回九州大地圖">✕</button>
|
| 27 |
<div class="intro-portrait">
|
| 28 |
<img id="introBossImg" src="assets/boss_taotie.png" alt="上古・饕餮">
|
| 29 |
</div>
|
|
@@ -117,7 +117,7 @@
|
|
| 117 |
</div>
|
| 118 |
|
| 119 |
<div style="display:flex; gap:12px; align-items:stretch; margin-top:4px;">
|
| 120 |
-
<button class="btn-exit-map" id="btnExitToMap" type="button">🚪 返回地圖</button>
|
| 121 |
<button class="btn-start" id="btnStart" type="button" style="flex:1;">開始討伐(3/3)</button>
|
| 122 |
</div>
|
| 123 |
</div>
|
|
|
|
| 23 |
<div class="scene-bg" id="introSceneBg"></div>
|
| 24 |
<div class="intro-wrap">
|
| 25 |
<div class="intro-card" style="position: relative;">
|
| 26 |
+
<button class="btn-card-close" id="btnExitToMapTop" type="button" title="返回九州大地圖" onclick="window.exitBattleToMap ? window.exitBattleToMap() : (window.parent !== window ? window.parent.postMessage({type:'BOSS_BATTLE_EXIT'}, '*') : window.location.href='index.html?from=boss')">✕</button>
|
| 27 |
<div class="intro-portrait">
|
| 28 |
<img id="introBossImg" src="assets/boss_taotie.png" alt="上古・饕餮">
|
| 29 |
</div>
|
|
|
|
| 117 |
</div>
|
| 118 |
|
| 119 |
<div style="display:flex; gap:12px; align-items:stretch; margin-top:4px;">
|
| 120 |
+
<button class="btn-exit-map" id="btnExitToMap" type="button" onclick="window.exitBattleToMap ? window.exitBattleToMap() : (window.parent !== window ? window.parent.postMessage({type:'BOSS_BATTLE_EXIT'}, '*') : window.location.href='index.html?from=boss')">🚪 返回地圖</button>
|
| 121 |
<button class="btn-start" id="btnStart" type="button" style="flex:1;">開始討伐(3/3)</button>
|
| 122 |
</div>
|
| 123 |
</div>
|
js/boss-battle.js
CHANGED
|
@@ -2,10 +2,10 @@
|
|
| 2 |
// js/boss-battle.js
|
| 3 |
// 世界 Boss 決戰殿堂:戰鬥流程、音效合成、題庫連動、血量同步與即時傷害結算
|
| 4 |
// ============================================================================
|
| 5 |
-
import { getDB, DBError, defaultBossState } from './
|
| 6 |
-
import { loadBank, loadBankIndex } from './
|
| 7 |
-
import { recordMistake, recordCorrect, derive, totalProd, grantGrain, grantTally, grantScroll, WORLD_BOSS_ROSTER, getActiveWorldBossConfig, calcWorldBossRewards, calcWorldBossStatus } from './
|
| 8 |
-
import { todayStr, fmt, shuffle, renderRichQuizText } from './
|
| 9 |
|
| 10 |
// ==========================================
|
| 11 |
// 1. 全域與連線狀態
|
|
|
|
| 2 |
// js/boss-battle.js
|
| 3 |
// 世界 Boss 決戰殿堂:戰鬥流程、音效合成、題庫連動、血量同步與即時傷害結算
|
| 4 |
// ============================================================================
|
| 5 |
+
import { getDB, DBError, defaultBossState } from './db.js?v=20261031_v1';
|
| 6 |
+
import { loadBank, loadBankIndex } from './quiz.js?v=20261031_v1';
|
| 7 |
+
import { recordMistake, recordCorrect, derive, totalProd, grantGrain, grantTally, grantScroll, WORLD_BOSS_ROSTER, getActiveWorldBossConfig, calcWorldBossRewards, calcWorldBossStatus } from './engine.js?v=20261031_v1';
|
| 8 |
+
import { todayStr, fmt, shuffle, renderRichQuizText } from './util.js?v=20261031_v1';
|
| 9 |
|
| 10 |
// ==========================================
|
| 11 |
// 1. 全域與連線狀態
|
tools/verify-integrity.mjs
CHANGED
|
@@ -49,14 +49,24 @@ function ok(label) {
|
|
| 49 |
console.log('🛡️ 啟動《爭霸天下》工程防呆與完整性自動檢驗...');
|
| 50 |
|
| 51 |
// ----------------------------------------------------------------------------
|
| 52 |
-
// 1. JS 模組語法檢驗 (Syntax Check)
|
| 53 |
// ----------------------------------------------------------------------------
|
| 54 |
const jsDir = path.join(ROOT, 'js');
|
| 55 |
const jsFiles = fs.readdirSync(jsDir).filter(f => f.endsWith('.js'));
|
| 56 |
for (const file of jsFiles) {
|
| 57 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 58 |
}
|
| 59 |
-
ok(`JS 語法檢
|
| 60 |
|
| 61 |
// ----------------------------------------------------------------------------
|
| 62 |
// 2. 靜態掃描:攔截已知常見「自創幽靈欄位」寫法 (Static Ghost-Field Scan)
|
|
|
|
| 49 |
console.log('🛡️ 啟動《爭霸天下》工程防呆與完整性自動檢驗...');
|
| 50 |
|
| 51 |
// ----------------------------------------------------------------------------
|
| 52 |
+
// 1. JS 模組語法與模組路徑解析檢驗 (Syntax & Import Resolution Check)
|
| 53 |
// ----------------------------------------------------------------------------
|
| 54 |
const jsDir = path.join(ROOT, 'js');
|
| 55 |
const jsFiles = fs.readdirSync(jsDir).filter(f => f.endsWith('.js'));
|
| 56 |
for (const file of jsFiles) {
|
| 57 |
+
const filePath = path.join(jsDir, file);
|
| 58 |
+
execFileSync(process.execPath, ['--check', filePath], { stdio: 'pipe' });
|
| 59 |
+
const code = fs.readFileSync(filePath, 'utf8');
|
| 60 |
+
const importMatches = [...code.matchAll(/from\s+['"](\.[^'"]+)['"]/g)];
|
| 61 |
+
for (const m of importMatches) {
|
| 62 |
+
const cleanSpec = m[1].split('?')[0];
|
| 63 |
+
const resolved = path.resolve(jsDir, cleanSpec);
|
| 64 |
+
if (!fs.existsSync(resolved)) {
|
| 65 |
+
throw new Error(`❌ [Import Guard] js/${file} 參照的模組 '${m[1]}' 不存在 (解析路徑: ${resolved})`);
|
| 66 |
+
}
|
| 67 |
+
}
|
| 68 |
}
|
| 69 |
+
ok(`JS 語法與模組匯入路徑檢驗通過(共 ${jsFiles.length} 個模組)`);
|
| 70 |
|
| 71 |
// ----------------------------------------------------------------------------
|
| 72 |
// 2. 靜態掃描:攔截已知常見「自創幽靈欄位」寫法 (Static Ghost-Field Scan)
|