pref: change init logic.

This commit is contained in:
Rintim 2023-12-25 21:05:19 +08:00
parent c9a8f3d6a3
commit 01c23586cf
No known key found for this signature in database
GPG Key ID: BE9E1EA615BACFCF
3 changed files with 54 additions and 37 deletions

View File

@ -11,12 +11,8 @@ new Promise(resolve => {
} }
}).then(() => { }).then(() => {
const userAgent = navigator.userAgent.toLowerCase(); const userAgent = navigator.userAgent.toLowerCase();
if (!localStorage.getItem('gplv3_noname_alerted')) {
if (confirm('①无名杀是一款基于GPLv3协议的开源软件\n你可以在遵守GPLv3协议的基础上任意使用修改并转发《无名杀》以及所有基于《无名杀》开发的拓展。\n点击“确定”即代表您认可并接受GPLv3协议↓\nhttps://www.gnu.org/licenses/gpl-3.0.html\n②无名杀官方发布地址仅有GitHub仓库\n其他所有的所谓“无名杀”社群包括但不限于绝大多数“官方”QQ群、QQ频道等均为玩家自发组织与无名杀官方无关')) { const exit = () => {
// @ts-ignore
localStorage.setItem('gplv3_noname_alerted', true);
}
else {
const ios = userAgent.includes('iphone') || userAgent.includes('ipad') || userAgent.includes('macintosh'); const ios = userAgent.includes('iphone') || userAgent.includes('ipad') || userAgent.includes('macintosh');
//electron //electron
if (typeof window.process == 'object' && typeof window.require == 'function') { if (typeof window.process == 'object' && typeof window.require == 'function') {
@ -41,6 +37,15 @@ new Promise(resolve => {
else if (!ios) { else if (!ios) {
window.close(); window.close();
} }
};
if (!localStorage.getItem('gplv3_noname_alerted')) {
if (confirm('①无名杀是一款基于GPLv3协议的开源软件\n你可以在遵守GPLv3协议的基础上任意使用修改并转发《无名杀》以及所有基于《无名杀》开发的拓展。\n点击“确定”即代表您认可并接受GPLv3协议↓\nhttps://www.gnu.org/licenses/gpl-3.0.html\n②无名杀官方发布地址仅有GitHub仓库\n其他所有的所谓“无名杀”社群包括但不限于绝大多数“官方”QQ群、QQ频道等均为玩家自发组织与无名杀官方无关')) {
// @ts-ignore
localStorage.setItem('gplv3_noname_alerted', true);
}
else {
exit();
} }
} }
window['b' + 'ann' + 'e' + 'dE' + 'x' + 'ten' + 's' + 'i' + 'o' + 'ns'] = ['\u4fa0\u4e49', '\u5168\u6559\u7a0b']; window['b' + 'ann' + 'e' + 'dE' + 'x' + 'ten' + 's' + 'i' + 'o' + 'ns'] = ['\u4fa0\u4e49', '\u5168\u6559\u7a0b'];

View File

@ -83,11 +83,12 @@ export async function boot() {
} }
// 在dom加载完后执行相应的操作 // 在dom加载完后执行相应的操作
const waitDomLoad = new Promise((resolve) => {
if (document.readyState !== 'complete') { if (document.readyState !== 'complete') {
window.onload = onWindowReady; window.onload = resolve;
} else { } else resolve(void 0)
onWindowReady.call(window); }).then(onWindowReady.bind(window));
}
// 闭源客户端检测并提醒 // 闭源客户端检测并提醒
if (lib.assetURL.includes('com.widget.noname.qingyao') || lib.assetURL.includes('online.nonamekill.android')) { if (lib.assetURL.includes('com.widget.noname.qingyao') || lib.assetURL.includes('online.nonamekill.android')) {
@ -555,12 +556,9 @@ export async function boot() {
delete _status.importing; delete _status.importing;
} }
if (_status.windowLoaded) { await waitDomLoad;
delete _status.windowLoaded;
lib.init.onload(); lib.init.onload();
} }
else _status.packLoaded = true;
}
/** /**
* @param {string} name - 卡牌包名 * @param {string} name - 卡牌包名
@ -744,16 +742,21 @@ async function loadCss() {
}); });
} }
function onWindowReady() { async function onWindowReady() {
if (Reflect.has(lib, 'device')) { if (Reflect.has(lib, 'device')) {
var script = document.createElement('script'); var script = document.createElement('script');
script.src = 'cordova.js'; script.src = 'cordova.js';
document.body.appendChild(script); document.body.appendChild(script);
// @ts-ignore
const { promise, resolve } = Promise.withResolvers();
document.addEventListener('deviceready', async () => { document.addEventListener('deviceready', async () => {
const { cordovaReady } = await import('./cordova.js'); const { cordovaReady } = await import('./cordova.js');
await cordovaReady(); await cordovaReady();
resolve()
}); });
await promise;
} }
/*
if (_status.packLoaded) { if (_status.packLoaded) {
delete _status.packLoaded; delete _status.packLoaded;
lib.init.onload(); lib.init.onload();
@ -761,6 +764,7 @@ function onWindowReady() {
else { else {
_status.windowLoaded = true; _status.windowLoaded = true;
} }
*/
} }
function setBackground() { function setBackground() {

View File

@ -9,8 +9,16 @@ export function nodeReady() {
lib.node = { lib.node = {
fs: require('fs'), fs: require('fs'),
path: require("path"), path: require("path"),
debug: function () { debug() {
require('electron').remote.getCurrentWindow().toggleDevTools(); let remote;
if (electronVersion >= 14) {
// @ts-ignore
remote = require('@electron/remote');
} else {
// @ts-ignore
remote = require('electron').remote;
}
remote.getCurrentWindow().toggleDevTools();
} }
}; };
lib.path = lib.node.path; lib.path = lib.node.path;