diff --git a/assets/Game/scripts/game/HistoryDetail.ts b/assets/Game/scripts/game/HistoryDetail.ts index 3d78786..701a90a 100644 --- a/assets/Game/scripts/game/HistoryDetail.ts +++ b/assets/Game/scripts/game/HistoryDetail.ts @@ -417,7 +417,6 @@ export class HistoryDetail extends Component { } if (pan.WinInfo && 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) } } diff --git a/build-templates/common/application.ejs b/build-templates/common/application.ejs new file mode 100644 index 0000000..aa994a1 --- /dev/null +++ b/build-templates/common/application.ejs @@ -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()); + } +} diff --git a/build-templates/templates-version.json b/build-templates/templates-version.json new file mode 100644 index 0000000..eb2014e --- /dev/null +++ b/build-templates/templates-version.json @@ -0,0 +1,3 @@ +{ + "web-mobile": "1.0.0" +} diff --git a/build-templates/web-mobile/index.ejs b/build-templates/web-mobile/index.ejs new file mode 100644 index 0000000..3263443 --- /dev/null +++ b/build-templates/web-mobile/index.ejs @@ -0,0 +1,113 @@ + + + + + + + Hot pot carnival + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+ + +
+
+
+ +
+
+ +
+
+ + + + <%- include(cocosTemplate, {}) %> + + + \ No newline at end of file diff --git a/build-templates/web-mobile/logo1.png b/build-templates/web-mobile/logo1.png new file mode 100644 index 0000000..44c3878 Binary files /dev/null and b/build-templates/web-mobile/logo1.png differ diff --git a/build-templates/web-mobile/service-worker.js b/build-templates/web-mobile/service-worker.js new file mode 100644 index 0000000..8929a9e --- /dev/null +++ b/build-templates/web-mobile/service-worker.js @@ -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(); \ No newline at end of file diff --git a/buildConfig_web-mobile.json b/buildConfig_web-mobile.json new file mode 100644 index 0000000..64db8f3 --- /dev/null +++ b/buildConfig_web-mobile.json @@ -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" +} \ No newline at end of file diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 0000000..5118376 --- /dev/null +++ b/package-lock.json @@ -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" + } + } +}