5 Commits

Author SHA1 Message Date
Liushiqi1542
a0f66d5043 Merge 6f63d63cff into 6e442c14c1 2024-09-29 11:14:28 +08:00
Vick Scarlet
6e442c14c1 update: afd url 2024-09-17 18:31:30 +08:00
Liushiqi1542
6f63d63cff add workbench config 2021-09-15 00:00:31 +08:00
Liushiqi1542
7c002c1896 add workbench config 2021-09-14 19:06:13 +08:00
Liushiqi1542
a57889e848 add workbench config 2021-09-14 19:06:12 +08:00
3 changed files with 104 additions and 26 deletions

74
.github/workflows/fe.cdDaily.yaml vendored Normal file
View File

@@ -0,0 +1,74 @@
name: FE Project CI
on:
workflow_dispatch:
inputs:
version:
description: 'version'
required: false
default: '1.0.0'
oss_region:
description: 'oss region'
required: true
default: 'oss-cn-shanghai'
oss_bucket:
description: 'oss bucket'
required: true
default: ''
oss_path:
description: 'oss path'
required: false
default: ''
upload_path:
description: 'upload path'
required: true
default: './build'
pure_static_project:
description: 'project is a static project'
required: true
default: 'false'
compile_command:
description: 'code compile command'
required: true
default: 'true'
jobs:
pre-check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: check package.json
run: ${{github.event.inputs.pure_static_project}} || ( test -f ./package.json && exit 0 || (echo 'package.json is not exist!' && exit 1))
build-and-deploy:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [12.x]
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}
- name: install deps and build
run: ${{github.event.inputs.pure_static_project}} || ${{github.event.inputs.compile_command}}
- name: deploy to oss
id: upload_to_oss
uses: AliyunWorkbench/workbench-oss@1.0.0
with:
ACCESS_KEY: ${{ secrets.AK }}
ACCESS_SECRET: ${{ secrets.SK }}
OSS_REGION: ${{github.event.inputs.oss_region}}
OSS_BUCKET: ${{github.event.inputs.oss_bucket}}
OSS_PATH: ${{github.event.inputs.oss_path}}
UPLOAD_PATH: ${{github.event.inputs.upload_path}}

4
build.sh Normal file
View File

@@ -0,0 +1,4 @@
#!/bin/sh
# 前端应用存在NPM依赖时的默认编译脚本
npm install
npm run build

View File

@@ -7,21 +7,21 @@ import UIManager from './ui/uiManager.js';
import * as utils from './functions/util.js'; import * as utils from './functions/util.js';
globalThis.UIManager = globalThis.UIManager =
globalThis.UI = globalThis.UI =
UIManager; UIManager;
globalThis.$_ = utils; globalThis.$_ = utils;
globalThis.goto = async tag => { globalThis.goto = async tag => {
let url; let url;
switch(tag) { switch (tag) {
case 'github': url = 'https://github.com/VickScarlet/lifeRestart'; break; case 'github': url = 'https://github.com/VickScarlet/lifeRestart'; break;
case 'discord': url = 'https://discord.gg/U3qrf49NMQ'; break; case 'discord': url = 'https://discord.gg/U3qrf49NMQ'; break;
case 'sponsor_afd': url = 'https://afdian.net/@LifeRestart'; break; case 'sponsor_afd': url = 'https://afdian.com/a/LifeRestart'; break;
case 'sponsor_ddf': url = 'https://dun.mianbaoduo.com/@vickscarlet'; break; case 'sponsor_ddf': url = 'https://dun.mianbaoduo.com/@vickscarlet'; break;
} }
try { try {
if(Laya.Browser.onIOS) { if (Laya.Browser.onIOS) {
window.location.href = url; window.location.href = url;
} else { } else {
window.open(url, '_blank'); window.open(url, '_blank');
@@ -30,8 +30,8 @@ globalThis.goto = async tag => {
console.error(error); console.error(error);
} }
} }
class App{ class App {
constructor(){ constructor() {
this.name = 'lifeRestart'; this.name = 'lifeRestart';
this.version = '2.0.0'; this.version = '2.0.0';
console.log(`${this.name} ${this.version}`); console.log(`${this.name} ${this.version}`);
@@ -50,10 +50,10 @@ class App{
//class laya.webgl.text.CharSegment //class laya.webgl.text.CharSegment
class CharSegment { class CharSegment {
constructor() { constructor() {
this._sourceStr=null; this._sourceStr = null;
} }
textToSpit(str) { textToSpit(str) {
this._sourceStr=str; this._sourceStr = str;
var texLen = str.length; var texLen = str.length;
var idx = -1; var idx = -1;
this._words = []; this._words = [];
@@ -67,18 +67,18 @@ class App{
} }
} }
} }
getChar(i){ getChar(i) {
return this._words; return this._words;
} }
getCharCode(i){ getCharCode(i) {
return this._words[i].codePointAt(0); return this._words[i].codePointAt(0);
} }
length(){ length() {
return this._words.length; return this._words.length;
} }
} }
Laya.class(CharSegment,'laya.webgl.text.CharSegment'); Laya.class(CharSegment, 'laya.webgl.text.CharSegment');
Laya.imps(CharSegment.prototype,{"laya.webgl.text.ICharSegment":true}) Laya.imps(CharSegment.prototype, { "laya.webgl.text.ICharSegment": true })
// Laya.init(1125, 2436, Laya.WebGL); // Laya.init(1125, 2436, Laya.WebGL);
@@ -103,15 +103,15 @@ class App{
const screenWidth = window.innerWidth; const screenWidth = window.innerWidth;
const screenHeight = window.innerHeight; const screenHeight = window.innerHeight;
const screenRatio = screenWidth / screenHeight; const screenRatio = screenWidth / screenHeight;
if(screenRatio > designRatio) { if (screenRatio > designRatio) {
return [ return [
Math.min(screenWidth*designHeight/screenHeight, maxWidth), Math.min(screenWidth * designHeight / screenHeight, maxWidth),
designHeight designHeight
] ]
} else { } else {
return [ return [
designWidth, designWidth,
Math.min(screenHeight*designWidth/screenWidth, maxHeight) Math.min(screenHeight * designWidth / screenWidth, maxHeight)
] ]
} }
} }
@@ -121,7 +121,7 @@ class App{
} }
async #setLanguage(language) { async #setLanguage(language) {
switch(language) { switch (language) {
case App.languages['en-us']: case App.languages['en-us']:
case App.languages['zh-cn']: case App.languages['zh-cn']:
this.#language = language; this.#language = language;
@@ -131,23 +131,23 @@ class App{
break; break;
} }
globalThis.$lang = globalThis.$lang =
Laya.Text.langPacks = Laya.Text.langPacks =
(await import(`./i18n/${this.#language}.js`)).default; (await import(`./i18n/${this.#language}.js`)).default;
} }
resigterEvent() { resigterEvent() {
$$on('achievement', achievement => { $$on('achievement', achievement => {
$ui.popup(UI.popups.ACHIEVEMENT, {achievement}); $ui.popup(UI.popups.ACHIEVEMENT, { achievement });
}) })
$$on('message', ([message, ...args]) => { $$on('message', ([message, ...args]) => {
if(Array.isArray(message)) { if (Array.isArray(message)) {
message = message.map(([m, ...a]) => $_.format($lang[m], ...a)) .join('\n'); message = message.map(([m, ...a]) => $_.format($lang[m], ...a)).join('\n');
} else { } else {
message = $_.format( message = $_.format(
$lang[message], ...args $lang[message], ...args
); );
} }
$ui.popup(UI.popups.MESSAGE, {message}); $ui.popup(UI.popups.MESSAGE, { message });
}) })
} }
@@ -159,7 +159,7 @@ class App{
this.#initLaya(); this.#initLaya();
globalThis.$ui = UIManager.getInstance(); globalThis.$ui = UIManager.getInstance();
if(theme=='default') { if (theme == 'default') {
theme = localStorage.getItem('theme') || 'default'; theme = localStorage.getItem('theme') || 'default';
} }
@@ -168,8 +168,8 @@ class App{
await $ui.setLoading(UI.pages.LOADING); await $ui.setLoading(UI.pages.LOADING);
await $ui.switchView(UI.pages.LOADING); await $ui.switchView(UI.pages.LOADING);
await core.initial( await core.initial(
dataSet=>Laya.promises.loader.load(`data/${this.#language}/${dataSet}.json`, null, Laya.Loader.JSON), dataSet => Laya.promises.loader.load(`data/${this.#language}/${dataSet}.json`, null, Laya.Loader.JSON),
dataSet=>Laya.promises.loader.load(`data/${dataSet}.json`, null, Laya.Loader.JSON), dataSet => Laya.promises.loader.load(`data/${dataSet}.json`, null, Laya.Loader.JSON),
); );
await $ui.switchView(UI.pages.MAIN); await $ui.switchView(UI.pages.MAIN);