移除Reflect.has解决浏览器端不能启动的问题
This commit is contained in:
parent
30becb29b8
commit
43baade7a5
|
@ -29,7 +29,7 @@ declare interface Window {
|
||||||
|
|
||||||
resetGameTimeout: number;
|
resetGameTimeout: number;
|
||||||
|
|
||||||
cordovaLoadTimeout: number;
|
cordovaLoadTimeout?: number;
|
||||||
|
|
||||||
/** window.onerror的参数列表 */
|
/** window.onerror的参数列表 */
|
||||||
ea?: any[];
|
ea?: any[];
|
||||||
|
|
|
@ -110,9 +110,9 @@ export async function boot() {
|
||||||
// 现在不暴露到全局变量里了,直接传给onload
|
// 现在不暴露到全局变量里了,直接传给onload
|
||||||
const resetGameTimeout = setTimeout(lib.init.reset, configLoadTime ? parseInt(configLoadTime) : 10000);
|
const resetGameTimeout = setTimeout(lib.init.reset, configLoadTime ? parseInt(configLoadTime) : 10000);
|
||||||
|
|
||||||
if (Reflect.has(window, 'cordovaLoadTimeout')) {
|
if (typeof window.cordovaLoadTimeout != 'undefined') {
|
||||||
clearTimeout(Reflect.get(window, 'cordovaLoadTimeout'));
|
clearTimeout(window.cordovaLoadTimeout);
|
||||||
Reflect.deleteProperty(window, 'cordovaLoadTimeout');
|
delete window.cordovaLoadTimeout;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const link of document.head.querySelectorAll('link')) {
|
for (const link of document.head.querySelectorAll('link')) {
|
||||||
|
@ -166,7 +166,7 @@ export async function boot() {
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Reflect.set(lib, 'path', (await import('../library/path.js')).default)
|
Reflect.set(lib, 'path', (await import('../library/path.js')).default)
|
||||||
if (Reflect.has(lib, 'device')) {
|
if (typeof lib.device != 'undefined') {
|
||||||
const script = document.createElement('script')
|
const script = document.createElement('script')
|
||||||
script.src = 'cordova.js'
|
script.src = 'cordova.js'
|
||||||
document.body.appendChild(script)
|
document.body.appendChild(script)
|
||||||
|
@ -318,7 +318,7 @@ export async function boot() {
|
||||||
lib.configMenu.appearence.config.image_background.item.default = '默认';
|
lib.configMenu.appearence.config.image_background.item.default = '默认';
|
||||||
}
|
}
|
||||||
if (pack.music) {
|
if (pack.music) {
|
||||||
if (Reflect.has(lib, 'device') || typeof window.require === 'function') {
|
if (typeof lib.device != 'undefined' || typeof window.require === 'function') {
|
||||||
lib.configMenu.audio.config.background_music.item.music_custom = '自定义音乐';
|
lib.configMenu.audio.config.background_music.item.music_custom = '自定义音乐';
|
||||||
}
|
}
|
||||||
config.get('all').background_music = ['music_default'];
|
config.get('all').background_music = ['music_default'];
|
||||||
|
@ -369,7 +369,7 @@ export async function boot() {
|
||||||
if ('ontouchstart' in document) {
|
if ('ontouchstart' in document) {
|
||||||
if (!config.get('totouched')) {
|
if (!config.get('totouched')) {
|
||||||
game.saveConfig('totouched', true);
|
game.saveConfig('totouched', true);
|
||||||
if (Reflect.has(lib, 'device')) {
|
if (typeof lib.device != 'undefined') {
|
||||||
game.saveConfig('low_performance', true);
|
game.saveConfig('low_performance', true);
|
||||||
game.saveConfig('confirm_exit', true);
|
game.saveConfig('confirm_exit', true);
|
||||||
game.saveConfig('touchscreen', true);
|
game.saveConfig('touchscreen', true);
|
||||||
|
@ -888,7 +888,7 @@ async function setOnError() {
|
||||||
if (tip) str += `\n错误提示: ${tip}`;
|
if (tip) str += `\n错误提示: ${tip}`;
|
||||||
str += `\n行号: ${line}`;
|
str += `\n行号: ${line}`;
|
||||||
str += `\n列号: ${column}`;
|
str += `\n列号: ${column}`;
|
||||||
const version = Reflect.has(lib, 'version') ? Reflect.get(lib, 'version') : '';
|
const version = typeof lib.version != 'undefined' ? lib.version : '';
|
||||||
const reg = /[^\d.]/;
|
const reg = /[^\d.]/;
|
||||||
const match = version.match(reg) != null;
|
const match = version.match(reg) != null;
|
||||||
str += '\n' + `${match ? '游戏' : '无名杀'}版本: ${version || '未知版本'}`;
|
str += '\n' + `${match ? '游戏' : '无名杀'}版本: ${version || '未知版本'}`;
|
||||||
|
@ -995,7 +995,7 @@ async function setOnError() {
|
||||||
|
|
||||||
function setWindowListener() {
|
function setWindowListener() {
|
||||||
window.onkeydown = function (e) {
|
window.onkeydown = function (e) {
|
||||||
if (!Reflect.has(ui, 'menuContainer') || !Reflect.get(ui, 'menuContainer').classList.contains('hidden')) {
|
if (typeof ui.menuContainer == 'undefined' || !ui.menuContainer.classList.contains('hidden')) {
|
||||||
if (e.keyCode == 116 || ((e.ctrlKey || e.metaKey) && e.keyCode == 82)) {
|
if (e.keyCode == 116 || ((e.ctrlKey || e.metaKey) && e.keyCode == 82)) {
|
||||||
if (e.shiftKey) {
|
if (e.shiftKey) {
|
||||||
if (confirm('是否重置游戏?')) {
|
if (confirm('是否重置游戏?')) {
|
||||||
|
@ -1018,15 +1018,15 @@ function setWindowListener() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (e.keyCode == 83 && (e.ctrlKey || e.metaKey)) {
|
else if (e.keyCode == 83 && (e.ctrlKey || e.metaKey)) {
|
||||||
if (Reflect.has(window, 'saveNonameInput')) {
|
if (typeof window.saveNonameInput == 'function') {
|
||||||
Reflect.get(window, 'saveNonameInput')();
|
window.saveNonameInput();
|
||||||
}
|
}
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
else if (e.keyCode == 74 && (e.ctrlKey || e.metaKey) && Reflect.has(lib, 'node')) {
|
else if (e.keyCode == 74 && (e.ctrlKey || e.metaKey) && typeof lib.node != 'undefined') {
|
||||||
Reflect.get(lib, 'node').debug();
|
lib.node.debug();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -1037,7 +1037,7 @@ function setWindowListener() {
|
||||||
dialogs[i].delete();
|
dialogs[i].delete();
|
||||||
}
|
}
|
||||||
if (e.keyCode == 32) {
|
if (e.keyCode == 32) {
|
||||||
var node = Reflect.get(ui, 'window').querySelector('pausedbg');
|
var node = ui.window.querySelector('pausedbg');
|
||||||
if (node) {
|
if (node) {
|
||||||
node.click();
|
node.click();
|
||||||
}
|
}
|
||||||
|
@ -1046,15 +1046,14 @@ function setWindowListener() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (e.keyCode == 65) {
|
else if (e.keyCode == 65) {
|
||||||
if (Reflect.has(ui, 'auto'))
|
if (typeof ui.auto != 'undefined') ui.auto.click();
|
||||||
Reflect.get(ui, 'auto').click();
|
|
||||||
}
|
}
|
||||||
else if (e.keyCode == 87) {
|
else if (e.keyCode == 87) {
|
||||||
if (Reflect.has(ui, 'wuxie') && Reflect.get(ui, 'wuxie').style.display != 'none') {
|
if (typeof ui.wuxie != 'undefined' && ui.wuxie.style.display != 'none') {
|
||||||
Reflect.get(ui, 'wuxie').classList.toggle('glow');
|
ui.wuxie.classList.toggle('glow');
|
||||||
}
|
}
|
||||||
else if (Reflect.has(ui, 'tempnowuxie')) {
|
else if (typeof ui.tempnowuxie != 'undefined') {
|
||||||
Reflect.get(ui, 'tempnowuxie').classList.toggle('glow');
|
ui.tempnowuxie.classList.toggle('glow');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (e.keyCode == 116 || ((e.ctrlKey || e.metaKey) && e.keyCode == 82)) {
|
else if (e.keyCode == 116 || ((e.ctrlKey || e.metaKey) && e.keyCode == 82)) {
|
||||||
|
@ -1083,8 +1082,8 @@ function setWindowListener() {
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
else if (e.keyCode == 74 && (e.ctrlKey || e.metaKey) && Reflect.has(lib, 'node')) {
|
else if (e.keyCode == 74 && (e.ctrlKey || e.metaKey) && typeof lib.node != 'undefined') {
|
||||||
Reflect.get(lib, 'node').debug();
|
lib.node.debug();
|
||||||
}
|
}
|
||||||
// else if(e.keyCode==27){
|
// else if(e.keyCode==27){
|
||||||
// if(!ui.arena.classList.contains('paused')) ui.click.config();
|
// if(!ui.arena.classList.contains('paused')) ui.click.config();
|
||||||
|
|
|
@ -123,6 +123,22 @@ export class UI extends Uninstantable {
|
||||||
* @type {() => void}
|
* @type {() => void}
|
||||||
*/
|
*/
|
||||||
static updateVideoMenu;
|
static updateVideoMenu;
|
||||||
|
/**
|
||||||
|
* @type {HTMLDivElement}
|
||||||
|
*/
|
||||||
|
static menuContainer;
|
||||||
|
/**
|
||||||
|
* @type {HTMLDivElement}
|
||||||
|
*/
|
||||||
|
static auto;
|
||||||
|
/**
|
||||||
|
* @type {HTMLDivElement}
|
||||||
|
*/
|
||||||
|
static wuxie;
|
||||||
|
/**
|
||||||
|
* @type {HTMLDivElement}
|
||||||
|
*/
|
||||||
|
static tempnowuxie;
|
||||||
static refresh(node) {
|
static refresh(node) {
|
||||||
void window.getComputedStyle(node, null).getPropertyValue("opacity");
|
void window.getComputedStyle(node, null).getPropertyValue("opacity");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue