155 lines
4.2 KiB
HTML
155 lines
4.2 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="utf-8" />
|
|
<meta
|
|
name="viewport"
|
|
content="width=device-width, initial-scale=1, maximum-scale=1"
|
|
/>
|
|
<title>BAISHUN Mock</title>
|
|
<style>
|
|
body {
|
|
margin: 0;
|
|
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
|
|
background: linear-gradient(180deg, #07110f 0%, #11342d 100%);
|
|
color: #f4fffb;
|
|
}
|
|
.page {
|
|
min-height: 100vh;
|
|
padding: 24px;
|
|
box-sizing: border-box;
|
|
}
|
|
h1 {
|
|
margin: 0 0 8px;
|
|
font-size: 24px;
|
|
}
|
|
p {
|
|
margin: 0 0 18px;
|
|
line-height: 1.5;
|
|
color: rgba(244, 255, 251, 0.8);
|
|
}
|
|
.panel {
|
|
padding: 16px;
|
|
border-radius: 16px;
|
|
background: rgba(255, 255, 255, 0.08);
|
|
border: 1px solid rgba(255, 255, 255, 0.08);
|
|
}
|
|
.row {
|
|
display: flex;
|
|
flex-wrap: wrap;
|
|
gap: 10px;
|
|
margin-top: 16px;
|
|
}
|
|
button {
|
|
border: 0;
|
|
border-radius: 999px;
|
|
background: #2ae0a1;
|
|
color: #03231c;
|
|
padding: 10px 16px;
|
|
font-weight: 700;
|
|
}
|
|
pre {
|
|
margin-top: 16px;
|
|
white-space: pre-wrap;
|
|
word-break: break-word;
|
|
background: rgba(0, 0, 0, 0.24);
|
|
padding: 12px;
|
|
border-radius: 12px;
|
|
min-height: 160px;
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<div class="page">
|
|
<h1>BAISHUN Mock H5</h1>
|
|
<p>
|
|
This page is only for Flutter bridge bring-up. It exercises
|
|
getConfig, gameLoaded, gameRecharge, destroy and walletUpdate.
|
|
</p>
|
|
<div class="panel">
|
|
<div class="row">
|
|
<button onclick="requestConfig()">getConfig</button>
|
|
<button onclick="notifyLoaded()">gameLoaded</button>
|
|
<button onclick="requestRecharge()">gameRecharge</button>
|
|
<button onclick="requestDestroy()">destroy</button>
|
|
</div>
|
|
<pre id="log"></pre>
|
|
</div>
|
|
</div>
|
|
<script>
|
|
const logEl = document.getElementById("log");
|
|
|
|
function writeLog(title, payload) {
|
|
const line = `[${new Date().toLocaleTimeString()}] ${title}\n${JSON.stringify(
|
|
payload,
|
|
null,
|
|
2
|
|
)}\n\n`;
|
|
logEl.textContent = line + logEl.textContent;
|
|
}
|
|
|
|
let hasLoadedGame = false;
|
|
|
|
function requestConfig() {
|
|
if (!window.NativeBridge || typeof window.NativeBridge.getConfig !== "function") {
|
|
writeLog("getConfig", { error: "NativeBridge not ready" });
|
|
return;
|
|
}
|
|
window.NativeBridge.getConfig(function (config) {
|
|
writeLog("getConfig callback", config);
|
|
if (!hasLoadedGame) {
|
|
setTimeout(notifyLoaded, 300);
|
|
}
|
|
});
|
|
}
|
|
|
|
function notifyLoaded() {
|
|
hasLoadedGame = true;
|
|
window.NativeBridge &&
|
|
window.NativeBridge.gameLoaded &&
|
|
window.NativeBridge.gameLoaded({ status: "loaded" });
|
|
writeLog("gameLoaded", { status: "sent" });
|
|
}
|
|
|
|
function requestRecharge() {
|
|
window.NativeBridge &&
|
|
window.NativeBridge.gameRecharge &&
|
|
window.NativeBridge.gameRecharge({ source: "mock-h5" });
|
|
writeLog("gameRecharge", { source: "mock-h5" });
|
|
}
|
|
|
|
function requestDestroy() {
|
|
window.NativeBridge &&
|
|
window.NativeBridge.destroy &&
|
|
window.NativeBridge.destroy({ source: "mock-h5" });
|
|
writeLog("destroy", { source: "mock-h5" });
|
|
}
|
|
|
|
window.walletUpdate = function (payload) {
|
|
writeLog("walletUpdate", payload || {});
|
|
};
|
|
|
|
window.addEventListener("walletUpdate", function (event) {
|
|
writeLog("walletUpdate event", event.detail || {});
|
|
});
|
|
|
|
window.addEventListener("baishunBridgeReady", function () {
|
|
writeLog("baishunBridgeReady", { status: "received" });
|
|
requestConfig();
|
|
});
|
|
|
|
window.addEventListener("baishunConfig", function (event) {
|
|
writeLog("baishunConfig event", event.detail || {});
|
|
});
|
|
|
|
window.addEventListener("load", function () {
|
|
setTimeout(function () {
|
|
if (!hasLoadedGame) {
|
|
requestConfig();
|
|
}
|
|
}, 150);
|
|
});
|
|
</script>
|
|
</body>
|
|
</html>
|