上传开发服
This commit is contained in:
parent
1efb2c2319
commit
05f45617fc
@ -417,7 +417,6 @@ export class HistoryDetail extends Component {
|
|||||||
}
|
}
|
||||||
if (pan.WinInfo && pan.WinInfo.MultPos) {
|
if (pan.WinInfo && pan.WinInfo.MultPos) {
|
||||||
for (let key in pan.WinInfo.MultPos) {
|
for (let key in pan.WinInfo.MultPos) {
|
||||||
console.log('key', key)
|
|
||||||
showMultiNode.getChildByName('bg').children[key].getChildByName('multi').setPosition(0, 110, 0)
|
showMultiNode.getChildByName('bg').children[key].getChildByName('multi').setPosition(0, 110, 0)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
141
build-templates/common/application.ejs
Normal file
141
build-templates/common/application.ejs
Normal file
@ -0,0 +1,141 @@
|
|||||||
|
<%- include(versionCheckTemplate, { version: '1.0.0'}) %>
|
||||||
|
let cc;
|
||||||
|
|
||||||
|
function gameStarted() {
|
||||||
|
return cc?.director?.getScene()
|
||||||
|
}
|
||||||
|
|
||||||
|
export class Application {
|
||||||
|
constructor () {
|
||||||
|
this.settingsPath = '<%= settingsJsonPath %>';
|
||||||
|
this.showFPS = <%= showFPS %>;
|
||||||
|
this.isRB7 = (new URLSearchParams(window.location.search).get('brand') || '').toLowerCase() === 'rb7';
|
||||||
|
}
|
||||||
|
|
||||||
|
init (engine) {
|
||||||
|
cc = engine;
|
||||||
|
cc.game.onPostBaseInitDelegate.add(this.onPostInitBase.bind(this));
|
||||||
|
cc.game.onPostSubsystemInitDelegate.add(this.onPostSystemInit.bind(this));
|
||||||
|
|
||||||
|
let hasGameStarted = false;
|
||||||
|
let hasAnimationFinished = false;
|
||||||
|
const self = this;
|
||||||
|
|
||||||
|
const loadLottie = () =>{
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
const lottie = document.createElement('script');
|
||||||
|
lottie.src = 'https://cdnjs.cloudflare.com/ajax/libs/lottie-web/5.9.6/lottie.min.js';
|
||||||
|
lottie.onload = () => resolve();
|
||||||
|
lottie.onerror = () => reject(new Error('Failed to load lottie'));
|
||||||
|
document.head.appendChild(lottie);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
const hideLogoScreen = () => {
|
||||||
|
if (hasGameStarted && hasAnimationFinished) {
|
||||||
|
document.getElementById('VideoWrapper').style.display = 'none';
|
||||||
|
document.getElementById('RB7Wrapper').style.display = 'none';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const initSplashScreen = () => {
|
||||||
|
const videoWrapper = document.getElementById('VideoWrapper');
|
||||||
|
const rb7Wrapper = document.getElementById('RB7Wrapper');
|
||||||
|
|
||||||
|
if(self.isRB7) {
|
||||||
|
rb7Wrapper.style.display = 'block';
|
||||||
|
loadLottie().then(() => {
|
||||||
|
initRB7Animation();
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
videoWrapper.style.display = 'block';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const initRB7Animation = () => {
|
||||||
|
// 设置容器样式
|
||||||
|
const rb7Wrapper = document.getElementById('RB7Wrapper');
|
||||||
|
const rb7Animation = document.getElementById('rb7Animation');
|
||||||
|
|
||||||
|
// 设置包裹容器样式
|
||||||
|
rb7Wrapper.style.position = 'fixed';
|
||||||
|
rb7Wrapper.style.width = '100%';
|
||||||
|
rb7Wrapper.style.height = '100%';
|
||||||
|
rb7Wrapper.style.top = '0';
|
||||||
|
rb7Wrapper.style.left = '0';
|
||||||
|
rb7Wrapper.style.background = 'black';
|
||||||
|
|
||||||
|
// 设置动画容器样式
|
||||||
|
rb7Animation.style.position = 'absolute';
|
||||||
|
rb7Animation.style.top = '50%';
|
||||||
|
rb7Animation.style.left = '50%';
|
||||||
|
|
||||||
|
if (window.innerWidth > window.innerHeight) {
|
||||||
|
rb7Animation.style.transform = 'translate(-50%, -50%) scale(0.7)';
|
||||||
|
} else {
|
||||||
|
rb7Animation.style.width = '100%';
|
||||||
|
rb7Animation.style.height = '100%';
|
||||||
|
rb7Animation.style.transform = 'translate(-50%, -50%) scale(1)';
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const animation = lottie.loadAnimation({
|
||||||
|
container: rb7Animation,
|
||||||
|
renderer: 'svg',
|
||||||
|
loop: false,
|
||||||
|
autoplay: true,
|
||||||
|
path: '/shared/rb7/introl_RB7.json',
|
||||||
|
rendererSettings: {
|
||||||
|
preserveAspectRatio: 'xMidYMid meet' // 保持宽高比并居中
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
animation.addEventListener('complete', () => {
|
||||||
|
hasAnimationFinished = true;
|
||||||
|
hideLogoScreen();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
const delayTime = self.isRB7 ? 5400 : 2000;
|
||||||
|
if(!self.isRB7){
|
||||||
|
setTimeout(() => {
|
||||||
|
hasAnimationFinished = true;
|
||||||
|
hideLogoScreen();
|
||||||
|
}, delayTime);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Init
|
||||||
|
initSplashScreen();
|
||||||
|
|
||||||
|
cc.game.onStart = function () {
|
||||||
|
console.log('on game start!');
|
||||||
|
hasGameStarted = true;
|
||||||
|
hideLogoScreen();
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
onPostInitBase () {
|
||||||
|
// cc.settings.overrideSettings('assets', 'server', '');
|
||||||
|
// do custom logic
|
||||||
|
}
|
||||||
|
|
||||||
|
onPostSystemInit () {
|
||||||
|
// do custom logic
|
||||||
|
}
|
||||||
|
|
||||||
|
start () {
|
||||||
|
return cc.game.init({
|
||||||
|
debugMode: <%= debugMode %> ? cc.DebugMode.INFO : cc.DebugMode.ERROR,
|
||||||
|
settingsPath: this.settingsPath,
|
||||||
|
overrideSettings: {
|
||||||
|
// assets: {
|
||||||
|
// preloadBundles: [{ bundle: 'main', version: 'xxx' }],
|
||||||
|
// }
|
||||||
|
profiling: {
|
||||||
|
showFPS: this.showFPS,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}).then(() => cc.game.run());
|
||||||
|
}
|
||||||
|
}
|
||||||
3
build-templates/templates-version.json
Normal file
3
build-templates/templates-version.json
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"web-mobile": "1.0.0"
|
||||||
|
}
|
||||||
113
build-templates/web-mobile/index.ejs
Normal file
113
build-templates/web-mobile/index.ejs
Normal file
@ -0,0 +1,113 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
|
||||||
|
<title>Hot pot carnival</title>
|
||||||
|
|
||||||
|
<link rel="icon" href="/shared/favicon.ico">
|
||||||
|
|
||||||
|
<!--http://www.html5rocks.com/en/mobile/mobifying/-->
|
||||||
|
<meta name="viewport"
|
||||||
|
content="width=device-width,user-scalable=no,initial-scale=1,minimum-scale=1,maximum-scale=1,minimal-ui=true" />
|
||||||
|
|
||||||
|
<!--https://developer.apple.com/library/safari/documentation/AppleApplications/Reference/SafariHTMLRef/Articles/MetaTags.html-->
|
||||||
|
<meta name="apple-mobile-web-app-capable" content="yes">
|
||||||
|
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
|
||||||
|
<meta name="format-detection" content="telephone=no">
|
||||||
|
|
||||||
|
<!-- force webkit on 360 -->
|
||||||
|
<meta name="renderer" content="webkit" />
|
||||||
|
<meta name="force-rendering" content="webkit" />
|
||||||
|
<!-- force edge on IE -->
|
||||||
|
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
|
||||||
|
<meta name="msapplication-tap-highlight" content="no">
|
||||||
|
|
||||||
|
<!-- force full screen on some browser -->
|
||||||
|
<meta name="full-screen" content="yes" />
|
||||||
|
<meta name="x5-fullscreen" content="true" />
|
||||||
|
<meta name="360-fullscreen" content="true" />
|
||||||
|
|
||||||
|
<!-- 强制竖屏 -->
|
||||||
|
<meta name="screen-orientation" content="portrait">
|
||||||
|
|
||||||
|
<!--fix fireball/issues/3568 -->
|
||||||
|
<!--<meta name="browsermode" content="application">-->
|
||||||
|
<meta name="x5-page-mode" content="app">
|
||||||
|
|
||||||
|
<!--<link rel="apple-touch-icon" href=".png" />-->
|
||||||
|
<!--<link rel="apple-touch-icon-precomposed" href=".png" />-->
|
||||||
|
|
||||||
|
<link rel="stylesheet" type="text/css" href="<%= cssUrl %>" />
|
||||||
|
|
||||||
|
<style>
|
||||||
|
#VideoWrapper,
|
||||||
|
#RB7Wrapper {
|
||||||
|
position: absolute;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
background-color: black;
|
||||||
|
z-index: 9999;
|
||||||
|
}
|
||||||
|
|
||||||
|
#video1 {
|
||||||
|
position: absolute;
|
||||||
|
top: 0px;
|
||||||
|
right: 0px;
|
||||||
|
bottom: 0px;
|
||||||
|
left: 0px;
|
||||||
|
max-height: 100%;
|
||||||
|
max-width: 100%;
|
||||||
|
margin: auto;
|
||||||
|
|
||||||
|
object-fit: contain;
|
||||||
|
overflow-clip-margin: content-box;
|
||||||
|
overflow: clip;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#VideoWrapper,
|
||||||
|
#RB7Wrapper {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<!-- Video elements -->
|
||||||
|
<div id="VideoWrapper">
|
||||||
|
<img id="video1" src="/shared/LogoAnimation.png" style="display: block;">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- 新增RB7动画容器 -->
|
||||||
|
<div id="RB7Wrapper">
|
||||||
|
<div id="rb7Animation"></div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="GameDiv" cc_exact_fit_screen="true">
|
||||||
|
<div id="Cocos3dGameContainer">
|
||||||
|
<canvas id="GameCanvas" oncontextmenu="event.preventDefault()" tabindex="99"></canvas>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- 添加 Service Worker 注册代码 -->
|
||||||
|
<script>
|
||||||
|
if ('serviceWorker' in navigator) {
|
||||||
|
window.addEventListener('load', () => {
|
||||||
|
navigator.serviceWorker.register('./service-worker.js')
|
||||||
|
.then(registration => {
|
||||||
|
})
|
||||||
|
.catch(err => {
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
</script>
|
||||||
|
<%- include(cocosTemplate, {}) %>
|
||||||
|
</body>
|
||||||
|
|
||||||
|
</html>
|
||||||
BIN
build-templates/web-mobile/logo1.png
Normal file
BIN
build-templates/web-mobile/logo1.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 18 KiB |
119
build-templates/web-mobile/service-worker.js
Normal file
119
build-templates/web-mobile/service-worker.js
Normal file
@ -0,0 +1,119 @@
|
|||||||
|
const CacheManager = (function () {
|
||||||
|
const CACHE_NAME = 'game-cache-v2';
|
||||||
|
const DEBUG = false;
|
||||||
|
|
||||||
|
function log(...args) {
|
||||||
|
if (DEBUG) {
|
||||||
|
console.log('[CacheManager]', ...args);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const CACHE_PATTERNS = [
|
||||||
|
/assets\/.*?\.png$/i, // assets 目录及其子目录下的所有 PNG 文件
|
||||||
|
/assets\/.*?\.jpg$/i, // assets 目录及其子目录下的所有 JPG 文件
|
||||||
|
/assets\/.*?\.jpeg$/i, // assets 目录及其子目录下的所有 JPEG 文件
|
||||||
|
/assets\/.*?\.json$/i, // assets 目录及其子目录下的所有 JSON 文件
|
||||||
|
/assets\/.*?\.mp3$/i, // assets 目录及其子目录下的所有 MP3 文件
|
||||||
|
/assets\/.*?\.wav$/i, // assets 目录及其子目录下的所有 WAV 文件
|
||||||
|
];
|
||||||
|
|
||||||
|
// 添加调试日志
|
||||||
|
function shouldCacheRequest(url) {
|
||||||
|
const shouldCache = CACHE_PATTERNS.some(pattern => {
|
||||||
|
const matches = url.match(pattern);
|
||||||
|
return matches;
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
return shouldCache;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 处理安装事件
|
||||||
|
function handleInstall(event) {
|
||||||
|
log('Service Worker installing...');
|
||||||
|
// 跳过等待,直接激活
|
||||||
|
self.skipWaiting();
|
||||||
|
|
||||||
|
event.waitUntil(
|
||||||
|
caches.open(CACHE_NAME).then(cache => {
|
||||||
|
log('Cache opened');
|
||||||
|
})
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 处理请求
|
||||||
|
async function handleFetch(event) {
|
||||||
|
const request = event.request;
|
||||||
|
|
||||||
|
if (request.method !== 'GET' || !shouldCacheRequest(request.url)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
event.respondWith(
|
||||||
|
(async () => {
|
||||||
|
try {
|
||||||
|
// 先尝试从缓存获取
|
||||||
|
const cachedResponse = await caches.match(request);
|
||||||
|
if (cachedResponse) {
|
||||||
|
log('Cache hit:', request.url);
|
||||||
|
return cachedResponse;
|
||||||
|
}
|
||||||
|
|
||||||
|
log('Cache miss:', request.url);
|
||||||
|
// 从网络获取
|
||||||
|
const networkResponse = await fetch(request);
|
||||||
|
if (!networkResponse || networkResponse.status !== 200) {
|
||||||
|
return networkResponse;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 缓存响应
|
||||||
|
const responseToCache = networkResponse.clone();
|
||||||
|
const cache = await caches.open(CACHE_NAME);
|
||||||
|
await cache.put(request, responseToCache);
|
||||||
|
log('Cached:', request.url);
|
||||||
|
|
||||||
|
return networkResponse;
|
||||||
|
} catch (error) {
|
||||||
|
log('Fetch error:', error);
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
})()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 处理激活事件
|
||||||
|
function handleActivate(event) {
|
||||||
|
log('Service Worker activating...');
|
||||||
|
event.waitUntil(
|
||||||
|
Promise.all([
|
||||||
|
// 清理旧缓存
|
||||||
|
caches.keys().then(cacheNames => {
|
||||||
|
return Promise.all(
|
||||||
|
cacheNames.map(cacheName => {
|
||||||
|
if (cacheName !== CACHE_NAME) {
|
||||||
|
log('Deleting old cache:', cacheName);
|
||||||
|
return caches.delete(cacheName);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
);
|
||||||
|
}),
|
||||||
|
// 立即接管页面
|
||||||
|
clients.claim()
|
||||||
|
])
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 初始化
|
||||||
|
function init() {
|
||||||
|
self.addEventListener('install', handleInstall);
|
||||||
|
self.addEventListener('fetch', handleFetch);
|
||||||
|
self.addEventListener('activate', handleActivate);
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
init: init
|
||||||
|
};
|
||||||
|
})();
|
||||||
|
|
||||||
|
// 初始化缓存管理器
|
||||||
|
CacheManager.init();
|
||||||
74
buildConfig_web-mobile.json
Normal file
74
buildConfig_web-mobile.json
Normal file
@ -0,0 +1,74 @@
|
|||||||
|
{
|
||||||
|
"name": "rp_11001",
|
||||||
|
"server": "",
|
||||||
|
"platform": "web-mobile",
|
||||||
|
"buildPath": "project://build",
|
||||||
|
"debug": false,
|
||||||
|
"buildMode": "normal",
|
||||||
|
"mangleProperties": false,
|
||||||
|
"md5Cache": true,
|
||||||
|
"skipCompressTexture": false,
|
||||||
|
"sourceMaps": "false",
|
||||||
|
"overwriteProjectSettings": {
|
||||||
|
"includeModules": {
|
||||||
|
"gfx-webgl2": "on",
|
||||||
|
"physics": "inherit-project-setting",
|
||||||
|
"physics-2d": "inherit-project-setting"
|
||||||
|
},
|
||||||
|
"macroConfig": {
|
||||||
|
"cleanupImageCache": "off"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"nativeCodeBundleMode": "both",
|
||||||
|
"polyfills": {
|
||||||
|
"asyncFunctions": true
|
||||||
|
},
|
||||||
|
"experimentalEraseModules": false,
|
||||||
|
"startSceneAssetBundle": false,
|
||||||
|
"bundleConfigs": [],
|
||||||
|
"inlineEnum": true,
|
||||||
|
"useBuiltinServer": false,
|
||||||
|
"md5CacheOptions": {
|
||||||
|
"excludes": [],
|
||||||
|
"includes": [],
|
||||||
|
"replaceOnly": [],
|
||||||
|
"handleTemplateMd5Link": true
|
||||||
|
},
|
||||||
|
"mainBundleIsRemote": false,
|
||||||
|
"mainBundleCompressionType": "merge_dep",
|
||||||
|
"useSplashScreen": false,
|
||||||
|
"bundleCommonChunk": false,
|
||||||
|
"packAutoAtlas": true,
|
||||||
|
"startScene": "6c29a3fe-b10e-44a5-98e3-55595b231767",
|
||||||
|
"outputName": "web-mobile",
|
||||||
|
"taskName": "web-mobile",
|
||||||
|
"scenes": [
|
||||||
|
{
|
||||||
|
"url": "db://assets/Loading/game.scene",
|
||||||
|
"uuid": "6c29a3fe-b10e-44a5-98e3-55595b231767"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"wasmCompressionMode": false,
|
||||||
|
"packages": {
|
||||||
|
"web-mobile": {
|
||||||
|
"useWebGPU": false,
|
||||||
|
"orientation": "auto",
|
||||||
|
"embedWebDebugger": false,
|
||||||
|
"__version__": "1.0.1"
|
||||||
|
},
|
||||||
|
"adsense-h5g-plugin": {
|
||||||
|
"enableAdsense": false,
|
||||||
|
"enableTestAd": false,
|
||||||
|
"__version__": "1.0.1",
|
||||||
|
"AFPHostPropertyCode": "other",
|
||||||
|
"AFPHostDomain": "douyougame.com",
|
||||||
|
"otherAFPHostPropertyCode": "",
|
||||||
|
"otherAFPDomain": ""
|
||||||
|
},
|
||||||
|
"cocos-service": {
|
||||||
|
"configID": "7476c6",
|
||||||
|
"services": []
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"__version__": "1.3.9"
|
||||||
|
}
|
||||||
22
package-lock.json
generated
Normal file
22
package-lock.json
generated
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
{
|
||||||
|
"name": "rp_11001",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"lockfileVersion": 3,
|
||||||
|
"requires": true,
|
||||||
|
"packages": {
|
||||||
|
"": {
|
||||||
|
"name": "rp_11001",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"license": "ISC",
|
||||||
|
"dependencies": {
|
||||||
|
"nosleep.js": "^0.12.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/nosleep.js": {
|
||||||
|
"version": "0.12.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/nosleep.js/-/nosleep.js-0.12.0.tgz",
|
||||||
|
"integrity": "sha512-9d1HbpKLh3sdWlhXMhU6MMH+wQzKkrgfRkYV0EBdvt99YJfj0ilCJrWRDYG2130Tm4GXbEoTCx5b34JSaP+HhA==",
|
||||||
|
"license": "MIT"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user