fix ios goto

This commit is contained in:
Vick Scarlet
2021-12-14 19:10:03 +08:00
parent 8eb8c3ca72
commit 765a69294b
4 changed files with 22 additions and 17 deletions

View File

@@ -10,6 +10,25 @@ globalThis.UI =
UIManager;
globalThis.$_ = utils;
globalThis.goto = async tag => {
let url;
switch(tag) {
case 'github': url = 'https://github.com/VickScarlet/lifeRestart'; break;
case 'discord': url = 'https://discord.gg/U3qrf49NMQ'; break;
case 'sponsor_afd': url = 'https://afdian.net/@LifeRestart'; break;
case 'sponsor_ddf': url = 'https://dun.mianbaoduo.com/@vickscarlet'; break;
}
try {
if(Laya.Browser.onIOS) {
window.location.href = url;
} else {
window.open(url, '_blank');
}
} catch (error) {
console.error(error);
}
}
class App{
constructor(){
this.name = 'lifeRestart';
@@ -156,6 +175,7 @@ class App{
dataSet=>Laya.promises.loader.load(`data/${dataSet}.json`, null, Laya.Loader.JSON),
);
await $ui.switchView(UI.pages.MAIN);
}
}

View File

@@ -1,21 +1,6 @@
import App from './app.js';
import Life from './modules/life.js';
globalThis.goto = async tag => {
let url;
switch(tag) {
case 'github': url = 'https://github.com/VickScarlet/lifeRestart'; break;
case 'discord': url = 'https://discord.gg/U3qrf49NMQ'; break;
case 'sponsor_afd': url = 'https://afdian.net/@LifeRestart'; break;
case 'sponsor_ddf': url = 'https://dun.mianbaoduo.com/@vickscarlet'; break;
}
try {
window.open(url, '_blank');
} catch (error) {
console.error(error);
}
}
globalThis.$$eventMap = new Map();
globalThis.$$event = (tag, data) => {
const listener = $$eventMap.get(tag);