Merge pull request #839 from nofficalfs/PR-Branch

在浏览器加载`entry.js`失败时显示当前浏览器的UserAgent
This commit is contained in:
Spmario233 2024-01-22 22:34:08 +08:00 committed by GitHub
commit ed02cb1953
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 38 additions and 36 deletions

View File

@ -1,34 +1,35 @@
/*
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"
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);
/*
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 { userAgent } from "../noname/util/index.js";
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目前使用的浏览器UA信息为\n${userAgent}\n点击“确认”以前往GitHub下载最新版无名杀客户端可能需要科学上网`;
if (confirm(redirect_tip)) {
window.open('https://github.com/libccy/noname/releases/tag/chromium77-client');
}
}
boot().then(lib.other.ignore);

View File

@ -62,6 +62,7 @@ new Promise(resolve => {
const regex = /(firefox|chrome|safari)\/([\d.]+)/;
let result;
if (!(result = userAgent.match(regex))) return ["other", NaN];
// @ts-ignore
if (result[1] !== "safari") return [result[1], parseInt(result[2])];
result = userAgent.match(/version\/([\d.]+).*safari/);
// @ts-ignore
@ -78,7 +79,7 @@ new Promise(resolve => {
if (core in supportMap && supportMap[core] > version) {
const tip = '检测到您的浏览器内核版本无法支持ES Module请立即升级浏览器或手机webview内核';
console.error(tip);
const redirect_tip = '您使用的浏览器或无名杀客户端内核版本过低,已经无法正常运行无名杀!\n点击“确认”以前往GitHub下载最新版无名杀客户端可能需要科学上网。\n稍后您的无名杀将自动退出可能的话';
const redirect_tip = `您使用的浏览器或无名杀客户端内核版本过低,已经无法正常运行无名杀!\n目前使用的浏览器UA信息为\n${userAgent}\n点击“确认”以前往GitHub下载最新版无名杀客户端可能需要科学上网\n稍后您的无名杀将自动退出(可能的话)`;
if (confirm(redirect_tip)) {
window.open('https://github.com/libccy/noname/releases/tag/chromium77-client');
}
@ -91,7 +92,7 @@ new Promise(resolve => {
script.async = true
script.onerror = (event) => {
console.error(event)
const message = `您使用的浏览器或《无名杀》客户端加载内容失败!\n若您使用的客户端为自带内核的旧版“兼容版”,请及时更新客户端版本!\n若您使用的客户端为手机端的非兼容版《无名杀》请尝试更新手机的WebView内核或者更换为1.8.2版本及以上的兼容版!\n若您是直接使用浏览器加载index.html进行游戏请改为运行文件夹内的“noname-server.exe”或使用VSCode等工具启动Live Server以动态服务器的方式启动《无名杀》`;
const message = `您使用的浏览器或《无名杀》客户端加载内容失败!\n目前使用的浏览器UA信息为\n${userAgent}\n若您使用的客户端为自带内核的旧版“兼容版”,请及时更新客户端版本!\n若您使用的客户端为手机端的非兼容版《无名杀》请尝试更新手机的WebView内核或者更换为1.8.2版本及以上的兼容版!\n若您是直接使用浏览器加载index.html进行游戏请改为运行文件夹内的“noname-server.exe”或使用VSCode等工具启动Live Server以动态服务器的方式启动《无名杀》`;
console.error(message);
alert(message);
exit()