From b27ad374b710be16d14f980d2063022a64d70b65 Mon Sep 17 00:00:00 2001 From: nonameShijian <2954700422@qq.com> Date: Wed, 24 Apr 2024 01:47:20 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E7=94=B1=E7=90=86?= =?UTF-8?q?=E7=89=88=E5=8D=87=E7=BA=A7=E9=80=BB=E8=BE=91=E5=88=A4=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- game/entry.js | 34 +++++++++++++++++----------------- noname/init/index.js | 18 ++++++++++++++++-- 2 files changed, 33 insertions(+), 19 deletions(-) diff --git a/game/entry.js b/game/entry.js index c4cae30cc..0ec019a12 100644 --- a/game/entry.js +++ b/game/entry.js @@ -22,6 +22,23 @@ if (core === "chrome" && !isNaN(version) && version < 77) { boot().then(() => { // 判断是否从file协议切换到http/s协议 if (canUseHttpProtocol()) { + // 保存协议的切换状态 + const saveProtocol = () => { + const url = sendUpdate(); + if (typeof url == "string") { + if ( + typeof window.require == "function" && + typeof window.process == "object" + ) { + // @ts-ignore + const remote = require("@electron/remote"); + const thisWindow = remote.getCurrentWindow(); + thisWindow.loadURL(url); + } else { + location.href = url; + } + } + }; /* 升级方法: 1. 游戏启动后导出数据,然后以http/s协议重启 @@ -61,23 +78,6 @@ boot().then(() => { }); }); } - // 保存协议的切换状态 - function saveProtocol() { - const url = sendUpdate(); - if (typeof url == "string") { - if ( - typeof window.require == "function" && - typeof window.process == "object" - ) { - // @ts-ignore - const remote = require("@electron/remote"); - const thisWindow = remote.getCurrentWindow(); - thisWindow.loadURL(url); - } else { - location.href = url; - } - } - } } else { // 成功导入后删除noname.config.txt let searchParams = new URLSearchParams(location.search); diff --git a/noname/init/index.js b/noname/init/index.js index 0ce2386db..e18c29876 100644 --- a/noname/init/index.js +++ b/noname/init/index.js @@ -21,11 +21,17 @@ export function canUseHttpProtocol() { // 手机端 if (window.cordova) { // 直接确定包名 - if (nonameInitialized.endsWith("com.noname.shijian/")) { + // 因为懒人包作者不一定会改成什么版本 + if (nonameInitialized.endsWith("com.noname.shijian/") && window.noname_shijianInterfaces && typeof window.noname_shijianInterfaces.sendUpdate === 'function') { // 每个app自定义能升级的渠道,比如判断版本 // @ts-ignore return window.noname_shijianInterfaces.getApkVersion() >= 16000; } + // 由理版判断 + // @ts-ignore + if (window.noname_yuriInterfaces) { + return true; + } } // 电脑端 else if (typeof window.require == "function" && typeof window.process == "object") { @@ -55,11 +61,19 @@ export function sendUpdate() { // 手机端 if (window.cordova) { // 直接确定包名 - if (nonameInitialized && nonameInitialized.includes("com.noname.shijian")) { + // @ts-ignore + if (nonameInitialized && nonameInitialized.includes("com.noname.shijian") && window.noname_shijianInterfaces && typeof window.noname_shijianInterfaces.sendUpdate === 'function') { // 给诗笺版apk的java层传递升级完成的信息 // @ts-ignore return window.noname_shijianInterfaces.sendUpdate() + "?sendUpdate=true"; } + // 由理版判断 + // @ts-ignore + if (window.noname_yuriInterfaces && typeof window.noname_yuriInterfaces.sendUpdate === 'function') { + // 给由理版apk的java层传递升级完成的信息 + // @ts-ignore + return window.noname_yuriInterfaces.sendUpdate() + "?sendUpdate=true"; + } } // 电脑端 else if (typeof window.require == "function" && typeof window.process == "object") { From 255b49a20200664c7861cd8690bfacb927bb9da9 Mon Sep 17 00:00:00 2001 From: nonameShijian <2954700422@qq.com> Date: Wed, 24 Apr 2024 14:10:09 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E4=BF=AE=E6=94=B9APi=E5=90=8D=E7=A7=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- noname/init/index.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/noname/init/index.js b/noname/init/index.js index e18c29876..ae4f58fc8 100644 --- a/noname/init/index.js +++ b/noname/init/index.js @@ -22,14 +22,15 @@ export function canUseHttpProtocol() { if (window.cordova) { // 直接确定包名 // 因为懒人包作者不一定会改成什么版本 + // @ts-ignore if (nonameInitialized.endsWith("com.noname.shijian/") && window.noname_shijianInterfaces && typeof window.noname_shijianInterfaces.sendUpdate === 'function') { // 每个app自定义能升级的渠道,比如判断版本 // @ts-ignore return window.noname_shijianInterfaces.getApkVersion() >= 16000; } - // 由理版判断 + // 由理版判断,后续所有app都通过此接口来升级协议 // @ts-ignore - if (window.noname_yuriInterfaces) { + if (window.NonameAndroidBridge && typeof window.NonameAndroidBridge.sendUpdate === 'function') { return true; } } @@ -69,10 +70,10 @@ export function sendUpdate() { } // 由理版判断 // @ts-ignore - if (window.noname_yuriInterfaces && typeof window.noname_yuriInterfaces.sendUpdate === 'function') { + if (window.NonameAndroidBridge && typeof window.NonameAndroidBridge.sendUpdate === 'function') { // 给由理版apk的java层传递升级完成的信息 // @ts-ignore - return window.noname_yuriInterfaces.sendUpdate() + "?sendUpdate=true"; + return window.NonameAndroidBridge.sendUpdate() + "?sendUpdate=true"; } } // 电脑端