- 新增 WebSocket 中间件,支持连接到指定端口的 TCP 服务器 - 在 ServerEvent 中添加错误日志输出 - 优化 ClientData 解析逻辑,增加类型断言 - 更新 index.html,添加 socket 代理配置
88 lines
2.8 KiB
Go
88 lines
2.8 KiB
Go
<!DOCTYPE html>
|
|
<html lang="zh">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<title>游戏名称</title>
|
|
<link rel="stylesheet" href="style.css">
|
|
<style>
|
|
/* 确保html和body元素占满整个屏幕 */
|
|
html, body {
|
|
height: 100%;
|
|
margin: 0;
|
|
overflow: hidden; /* 隐藏滚动条 */
|
|
}
|
|
/* 使容器和Ruffle播放器全屏和自适应 */
|
|
#container {
|
|
width: 100%;
|
|
height: 100%;
|
|
display: flex;
|
|
justify-content: center;
|
|
align-items: center;
|
|
}
|
|
#container ruffle-player {
|
|
flex-shrink: 0; /* 防止播放器被压缩 */
|
|
width: 100%;
|
|
height: 100%;
|
|
|
|
}
|
|
:root {
|
|
--logo-display: block; /* 默认值,可以是 inline, flex, none 等 */
|
|
--logo-width: 150px; /* Logo 宽度 */
|
|
--logo-height: auto; /* Logo 高度,保持比例 */
|
|
}
|
|
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<div id="container" style="--logo-display: none; --splash-screen-background:rgb(97,171,245)"></div>
|
|
<script src="//unpkg.com/@ruffle-rs/ruffle"></script>
|
|
<script>
|
|
function generateAllPortsProxy(host, baseUrl = "ws://localhost:8080/ws/?port=") {
|
|
// 生成1-65535范围内的所有端口配置
|
|
const socketProxy = [];
|
|
|
|
for (let port = 1; port <= 65535; port++) {
|
|
socketProxy.push({
|
|
host: host,
|
|
port: port,
|
|
proxyUrl: `${baseUrl}${port}`
|
|
});
|
|
}
|
|
|
|
return socketProxy;
|
|
}
|
|
|
|
window.addEventListener('load', async () => {
|
|
const ruffle = window.RufflePlayer.newest();
|
|
const player = ruffle.createPlayer();
|
|
const container = document.getElementById('container');
|
|
container.appendChild(player);
|
|
window.RufflePlayer.config = {
|
|
"autoplay": "on",
|
|
"contextMenu": "off",
|
|
"numFrames":6,
|
|
// "frameRate": 60,
|
|
socketProxy: [
|
|
{
|
|
host: "127.0.0.1", // The address of the server that Flash tries to connect to
|
|
port: 12345, // The port that Flash tries to connect to
|
|
proxyUrl: "ws://localhost:8080/ws/0", // The actual proxy that Ruffle will connect to, instead of the above server
|
|
}
|
|
],
|
|
fontSources: ["fonts/simsun.ttf","fonts/Tahoma.ttf"], // load up fonts here
|
|
defaultFonts: {
|
|
sans: ["simsun"], // then replace them here.
|
|
// serif: ["simsun", ], // Multiple fonts can be provided
|
|
// typewriter: ["simsun"],
|
|
// japaneseGothic: ["font"],
|
|
// japaneseGothicMono: ["font"],
|
|
// japaneseMincho: ["font"],
|
|
}
|
|
}
|
|
window.RufflePlayer.config.socketProxy = generateAllPortsProxy("127.0.0.1");
|
|
player.load('Client.swf');
|
|
});
|
|
</script>
|
|
</body>
|
|
</html>
|