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