mirror of
https://github.com/VickScarlet/lifeRestart.git
synced 2025-07-17 17:43:54 +08:00
update: afd url
This commit is contained in:
52
src/app.js
52
src/app.js
@@ -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);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user