上传开发服
All checks were successful
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 4m8s
All checks were successful
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 4m8s
This commit is contained in:
parent
da8ff20aff
commit
66e5944d9d
32
.gitea/workflows/deploy.yaml
Normal file
32
.gitea/workflows/deploy.yaml
Normal file
@ -0,0 +1,32 @@
|
||||
name: Gitea Actions Demo
|
||||
on:
|
||||
push:
|
||||
tags: '*'
|
||||
|
||||
defaults:
|
||||
run:
|
||||
shell: bash
|
||||
working-directory: /Users/mac/rp_games/rp_11009
|
||||
|
||||
jobs:
|
||||
Explore-Gitea-Actions:
|
||||
runs-on: mac-local
|
||||
steps:
|
||||
- name: update code
|
||||
run: |
|
||||
pwd
|
||||
git pull
|
||||
echo "💡 The ${{ github.repository }} repository has been cloned to the runner."
|
||||
- name: build
|
||||
run: |
|
||||
echo 'build'
|
||||
code=0
|
||||
/Applications/CocosCreator/Creator/3.8.5/CocosCreator.app/Contents/MacOS/CocosCreator --project ./ --build "configPath=./buildConfig_web-mobile.json;" || code=$?
|
||||
test $code -eq 36
|
||||
- name: image compression
|
||||
run: |
|
||||
compress-imgs.sh -root ./build/web-mobile/
|
||||
- name: upload
|
||||
run: |
|
||||
rsync -av --delete build/web-mobile/ zy@dou-dev:/data/rpgames-static/$(basename $PWD)
|
||||
|
||||
@ -30,7 +30,7 @@ export function getHistoryUrl() {
|
||||
}
|
||||
|
||||
export function getLanguage() {
|
||||
return 'zh';
|
||||
// return 'zh';
|
||||
return language;
|
||||
}
|
||||
|
||||
|
||||
142
build-templates/common/application.ejs
Normal file
142
build-templates/common/application.ejs
Normal file
@ -0,0 +1,142 @@
|
||||
<%- 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) {
|
||||
videoWrapper.style.display = 'none';
|
||||
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"
|
||||
}
|
||||
123
build-templates/web-mobile/index.ejs
Normal file
123
build-templates/web-mobile/index.ejs
Normal file
File diff suppressed because one or more lines are too long
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_11009",
|
||||
"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": "inherit-project-setting"
|
||||
}
|
||||
},
|
||||
"nativeCodeBundleMode": "both",
|
||||
"polyfills": {
|
||||
"asyncFunctions": true
|
||||
},
|
||||
"experimentalEraseModules": false,
|
||||
"startSceneAssetBundle": false,
|
||||
"bundleConfigs": [],
|
||||
"inlineEnum": true,
|
||||
"useBuiltinServer": false,
|
||||
"md5CacheOptions": {
|
||||
"excludes": [],
|
||||
"includes": [],
|
||||
"replaceOnly": [],
|
||||
"handleTemplateMd5Link": true
|
||||
},
|
||||
"mainBundleIsRemote": false,
|
||||
"mainBundleCompressionType": "merge_all_json",
|
||||
"useSplashScreen": false,
|
||||
"bundleCommonChunk": false,
|
||||
"packAutoAtlas": true,
|
||||
"startScene": "047bc2a0-3759-4c52-a603-35f19f0b22ac",
|
||||
"outputName": "web-mobile",
|
||||
"taskName": "web-mobile",
|
||||
"scenes": [
|
||||
{
|
||||
"url": "db://assets/Main/main.scene",
|
||||
"uuid": "047bc2a0-3759-4c52-a603-35f19f0b22ac"
|
||||
}
|
||||
],
|
||||
"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": "ca-host-pub-5396158963872751",
|
||||
"AFPHostDomain": "douyougame.com",
|
||||
"otherAFPHostPropertyCode": "",
|
||||
"otherAFPDomain": ""
|
||||
},
|
||||
"cocos-service": {
|
||||
"configID": "cfe04d",
|
||||
"services": []
|
||||
}
|
||||
},
|
||||
"__version__": "1.3.9"
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user