From 195967b2a176f48d5df1a8982e93b686f4585970 Mon Sep 17 00:00:00 2001 From: nonameShijian <2954700422@qq.com> Date: Mon, 29 Jan 2024 17:30:41 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=A4=E6=96=ADexe=E5=A6=82=E6=9E=9C?= =?UTF-8?q?=E6=9C=89=E5=90=AF=E5=8A=A8=E5=8F=82=E6=95=B0=E5=88=99=E4=B8=8D?= =?UTF-8?q?=E8=87=AA=E5=8A=A8=E6=89=93=E5=BC=80=E9=BB=98=E8=AE=A4=E6=B5=8F?= =?UTF-8?q?=E8=A7=88=E5=99=A8=EF=BC=8C=E7=BB=A7=E7=BB=AD=E4=B8=BA=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=E4=B8=BAhttp=E5=8D=8F=E8=AE=AE=E5=81=9A=E5=87=86?= =?UTF-8?q?=E5=A4=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- game/entry.js | 34 ++++++---------------------------- game/game.js | 17 +++++++++++++++++ noname-server.exe | Bin 70686208 -> 70686720 bytes noname/init/index.js | 13 ++++++++----- 4 files changed, 31 insertions(+), 33 deletions(-) diff --git a/game/entry.js b/game/entry.js index c450e7350..1c5249e6c 100644 --- a/game/entry.js +++ b/game/entry.js @@ -1,24 +1,5 @@ -/* - const module = import('../noname.js'); - - module.then(({ ai, game, get, lib, _status, ui, boot }) => { - const coreAndVersion = get.coreInfo(); - const core = coreAndVersion[0], version = coreAndVersion[1]; - if (core === 'chrome' && !isNaN(version) && version < 77) { - const tip = '检测到您的浏览器内核版本小于77,请及时升级浏览器或手机webview内核!'; - console.warn(tip); - game.print(tip); - const redirect_tip = '您使用的浏览器或无名杀客户端内核版本过低,将在未来的版本被废弃!\n点击“确认”以前往GitHub下载最新版无名杀客户端(可能需要科学上网)。'; - if (confirm(redirect_tip)) { - window.open('https://github.com/libccy/noname/releases/tag/chromium77-client'); - } - } - boot().then(lib.other.ignore); - }); - */ - import { game, get, lib, boot } from "../noname.js"; -// import { canUseHttpProtocol } from "../noname/init/index.js"; +import { canUseHttpProtocol } from "../noname/init/index.js"; import { userAgent } from "../noname/util/index.js"; const coreAndVersion = get.coreInfo(); @@ -34,20 +15,17 @@ if (core === 'chrome' && !isNaN(version) && version < 77) { } // 判断是否从file协议切换到http/s协议 -// if (canUseHttpProtocol()) { + if (canUseHttpProtocol()) { /* - 升级方法一: + 升级方法: 1. 导出数据,然后以http/s协议重启 2. 以http/s协议导入数据 3. 保存http/s协议的状态,以后不再以file协议启动 - 升级方法二: - 1. app默认以http/s协议启动,发现没有数据后,以file协议重启 - 2. 以file协议导出数据 - 3. 以http/s协议重启,导入数据 */ // 导出数据到根目录的noname.config.txt // 成功导入后应删除noname.config.txt -// } else { boot().then(lib.other.ignore); -// } + } else { + boot().then(lib.other.ignore); + } diff --git a/game/game.js b/game/game.js index 0e4a4181e..11484dfec 100644 --- a/game/game.js +++ b/game/game.js @@ -86,6 +86,23 @@ new Promise(resolve => { exit() } else { + // 在http环境下修改__dirname + if (location.protocol.startsWith('http') && + typeof window.require == 'function' && + typeof window.process == 'object' && + typeof window.__dirname == 'string' && + window.__dirname.endsWith('electron.asar\\renderer')) { + const path = require('path'); + window.__dirname = path.join(path.resolve(), 'resources/app'); + // @ts-ignore + window.require = function (moduleId) { + try { + return module.require(moduleId); + } catch { + return module.require(path.join(window.__dirname, moduleId)); + } + }; + } const script = document.createElement('script') script.type = "module"; script.src = `${assetURL}game/entry.js`; diff --git a/noname-server.exe b/noname-server.exe index 02b6d56299b85505265ef586bb210104172f97f5..b2c2b1f2abed449eb95592f023fbd96bbf2e71b7 100644 GIT binary patch delta 5323 zcmXZcXIKtw7>9As<++Xi2YD>CXR6@F2!c>DHZtgTg6GKK~njz3&onezD%gXkqEEyAOXPsO- zt3eqRvq@PfOJ$|9DQlHo*{B@KR^?Q7DwoQw@+fDx?Z4 zSLLSMRS{KG6;s7k3FVgVLRFX=tin}<8lr}(VQRP4v zYP5<}W7JqRPD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