nonameShijian/noname-server

游戏似乎未正常载入,是否重置游戏?能修复下吗🙏谢谢

Closed this issue · 8 comments

大佬我输入127.0.0.1:8089最新火狐浏览器打不开游戏 游戏似乎未正常载入,是否重置游戏?能修复下吗🙏谢谢🥹

自己看浏览器控制台有没有报错。
也可能是因为加载时间过长导致的,可以点取消

@nonameShijian 火狐控制台报错sizeToContent 已弃用,未来将被移除。 commonDialog.js:132:10

sizeToContent 已弃用,未来将被移除。 2 commonDialog.js:132:10

sizeToContent 已弃用,未来将被移除。 2 commonDialog.js:132:10

sizeToContent 已弃用,未来将被移除。

6
WebExtensions: NS_ERROR_FAILURE: Component returned failure code: 0x80004005 (NS_ERROR_FAILURE) [nsIPropertyBag.getProperty]
stopListener jar:file:///Applications/Firefox.app/Contents/Resources/browser/omni.ja!/chrome/browser/builtin-addons/search-detection/api.js:186
api.js:188
WebExtensions: NS_ERROR_FAILURE: Component returned failure code: 0x80004005 (NS_ERROR_FAILURE) [nsIPropertyBag.getProperty]
stopListener jar:file:///Applications/Firefox.app/Contents/Resources/browser/omni.ja!/chrome/browser/builtin-addons/search-detection/api.js:186
api.js:188
HTTPS-Only Mode: 由于受到豁免,并未升级不安全的请求“http://ocsp.pki.goog/gts1c3”。
4
Referrer 策略:针对跨站请求,忽略对其限制较宽松的 referrer 策略 - “unsafe-url”:https://www.youtube.com/embed/?enablejsapi=1&rel=0&autoplay=0&playsinline=1&expflag=embeds_enable_muted_autoplay%3Atrue&fs=1 embed
HTTPS-Only Mode: 由于受到豁免,并未升级不安全的请求“http://ocsp.pki.goog/gts1c3”。
2
HTTPS-Only Mode: 由于受到豁免,并未升级不安全的请求“http://o.pki.goog/wr2”。
4
HTTPS-Only Mode: 已将不安全的推断式 TCP 连接“http://chat.openai.com/”升级至使用“https”协议。

HTTPS-Only Mode: 由于受到豁免,并未升级不安全的请求“http://ocsp.pki.goog/s/gts1d4/nM1NWPoK4h4”。
2
X-Content-Type-Options 头警告:值是“nosniff;”;是否本意为发送“nosniff”? 2
WebExtensions: NS_ERROR_FAILURE: Component returned failure code: 0x80004005 (NS_ERROR_FAILURE) [nsIPropertyBag.getProperty]
stopListener jar:file:///Applications/Firefox.app/Contents/Resources/browser/omni.ja!/chrome/browser/builtin-addons/search-detection/api.js:186
api.js:188
2
sizeToContent 已弃用,未来将被移除。 3 commonDialog.js:132:10

sizeToContent 已弃用,未来将被移除。 2 commonDialog.js:132:10
2
Content-Security-Policy:由于违反了下列指令:“default-src chrome: resource:”,此页面的内联样式(style-src-attr)无法应用 2 customElements.js:499:25
Content-Security-Policy:由于违反了下列指令:“default-src chrome: resource:”,此页面的内联样式(style-src-attr)无法应用 panel.js:62:23
Content-Security-Policy:由于违反了下列指令:“default-src chrome: resource:”,此页面的内联样式(style-src-attr)无法应用 2 customElements.js:499:25
Content-Security-Policy:由于违反了下列指令:“default-src chrome: resource:”,此页面的内联样式(style-src-attr)无法应用 panel.js:62:23
Content-Security-Policy:由于违反了下列指令:“default-src chrome: resource:”,此页面的内联样式(style-src-attr)无法应用 2 customElements.js:499:25
Content-Security-Policy:由于违反了下列指令:“default-src chrome: resource:”,此页面的内联样式(style-src-attr)无法应用 panel.js:62:23
sizeToContent 已弃用,未来将被移除。

弹出开源弹窗点确定进不了游戏过一回出现游戏似乎未正常载入,是否重置游戏?不管选是否都进不了游戏

serviceWorker加载失败: TypeError: ServiceWorker script at http://127.0.0.1:8089/service-worker.js for scope http://127.0.0.1:8089/ threw an exception during script evaluation. game.js:165:12
该页面使用非标准属性“zoom”。请考虑在相关属性值中使用 calc(),或将“transform”与“transform-origin: 0 0”一同使用。

我觉得你应该用localhost启动,别的不清楚

@nonameShijian 根据GPT修改后后的代码火狐能打开了能看看有什么问题嘛try {
const express = require("express");
const minimist = require("minimist");
const bodyParser = require('body-parser');
const app = express();
const fs = require('fs');
const path = require('path');

const oneYear = 60 * 1000 * 60 * 24 * 365;

// 解析命令行参数
// 示例: -s --maxAge 100
const argv = minimist(process.argv.slice(2), {
    alias: { "server": "s" },
    default: { maxAge: oneYear }
});

app.use(bodyParser.json({
    limit: '10240mb'
}));
app.use(bodyParser.urlencoded({
    limit: "10240mb",
    extended: true, //需明确设置
}));

function join(url) {
    return path.join(__dirname, url);
}

function isInProject(url) {
    return path.normalize(join(url)).startsWith(__dirname);
}

// 全局中间件解决所有路由的跨域问题
app.use((req, res, next) => {
    res.header('Access-Control-Allow-Origin', '*');
    res.header('Access-Control-Allow-Methods', 'GET,POST,OPTIONS');
    res.header('Access-Control-Allow-Headers', 'Origin, X-Requested-With, Content-Type, Accept');
    next();
});

// 根据参数设置 maxAge
const maxAge = argv.server ? argv.maxAge : 0;

app.use(express.static(__dirname, { maxAge: maxAge }));

app.get("/", (req, res) => {
    res.send(fs.readFileSync(join('index.html')));
});

app.get("/createDir", (req, res) => {
    const { dir } = req.query;
    if (!isInProject(dir)) {
        throw new Error(`只能访问${__dirname}的文件或文件夹`);
    }
    if (!fs.existsSync(join(dir))) {
        fs.mkdirSync(join(dir), { recursive: true });
    } else {
        if (!fs.statSync(join(dir)).isDirectory()) {
            throw new Error(`${join(dir)}不是文件夹`);
        }
    }
    res.json(successfulJson(true));
});

app.get("/removeDir", (req, res) => {
    const { dir } = req.query;
    if (!isInProject(dir)) {
        throw new Error(`只能访问${__dirname}的文件或文件夹`);
    }
    if (fs.existsSync(join(dir))) {
        if (!fs.statSync(join(dir)).isDirectory()) {
            throw new Error(`${join(dir)}不是文件夹`);
        }
        fs.rmdirSync(join(dir), { recursive: true });
    }
    res.json(successfulJson(true));
});

app.get("/readFile", (req, res) => {
    const { fileName } = req.query;
    if (!isInProject(fileName)) {
        throw new Error(`只能访问${__dirname}的文件或文件夹`);
    }
    if (fs.existsSync(join(fileName))) {
        res.json(successfulJson(
            Array.prototype.slice.call(
                new Uint8Array(
                    fs.readFileSync(join(fileName))
                )
            )
        ));
    } else {
        res.json(failedJson(404, '文件不存在'));
    }
});

app.get("/readFileAsText", (req, res) => {
    const { fileName } = req.query;
    if (!isInProject(fileName)) {
        throw new Error(`只能访问${__dirname}的文件或文件夹`);
    }
    if (fs.existsSync(join(fileName))) {
        res.json(successfulJson(fs.readFileSync(join(fileName), 'utf-8')));
    } else {
        res.json(failedJson(404, '文件不存在'));
    }
});

app.post("/writeFile", (req, res) => {
    const { path: p, data } = req.body;
    if (!isInProject(p)) {
        throw new Error(`只能访问${__dirname}的文件或文件夹`);
    }
    fs.mkdirSync(path.dirname(join(p)), { recursive: true });
    fs.writeFileSync(join(p), Buffer.from(data));
    res.json(successfulJson(true));
});

app.get("/removeFile", (req, res) => {
    const { fileName } = req.query;
    if (!isInProject(fileName)) {
        throw new Error(`只能访问${__dirname}的文件或文件夹`);
    }
    if (!fs.existsSync(join(fileName))) {
        throw new Error(`文件不存在`);
    }
    const stat = fs.statSync(join(fileName));
    if (stat.isDirectory()) {
        throw new Error("不能删除文件夹");
    }
    fs.unlinkSync(join(fileName));
    res.json(successfulJson(true));
});

app.get("/getFileList", (req, res) => {
    const { dir } = req.query;
    if (!isInProject(dir)) {
        throw new Error(`只能访问${__dirname}的文件或文件夹`);
    }
    if (!fs.existsSync(join(dir))) {
        throw new Error(`文件夹不存在`);
    }
    const stat = fs.statSync(join(dir));
    if (stat.isFile()) {
        throw new Error("getFileList只适用于文件夹而不是文件");
    }
    const files = [], folders = [];
    try {
        fs.readdir(join(dir), (err, filelist) => {
            if (err) {
                res.json(failedJson(500, String(err)));
                return;
            }
            for (let i = 0; i < filelist.length; i++) {
                if (filelist[i][0] != '.' && filelist[i][0] != '_') {
                    if (fs.statSync(join(dir) + '/' + filelist[i]).isDirectory()) {
                        folders.push(filelist[i]);
                    }
                    else {
                        files.push(filelist[i]);
                    }
                }
            }
            res.json(successfulJson({ folders, files }));
        });
    }
    catch (e) {
        res.json(failedJson(500, String(e)));
    }
});

app.get("/checkFile", (req, res) => {
    const { fileName } = req.query;
    if (!isInProject(fileName)) {
        throw new Error(`只能访问${__dirname}的文件或文件夹`);
    }
    try {
        if (fs.statSync(join(fileName)).isFile()) {
            res.json(successfulJson());
        } else {
            res.json(failedJson(404, '不是一个文件'));
        }
    } catch (error) {
        res.json(failedJson(404, '文件不存在或无法访问'));
    }
});

app.get("/checkDir", (req, res) => {
    const { dir } = req.query;
    if (!isInProject(dir)) {
        throw new Error(`只能访问${__dirname}的文件或文件夹`);
    }
    try {
        if (fs.statSync(join(dir)).isDirectory()) {
            res.json(successfulJson());
        } else {
            res.json(failedJson(404, '不是一个文件夹'));
        }
    } catch (error) {
        res.json(failedJson(404, '文件夹不存在或无法访问'));
    }
});

app.use((req, res, next) => {
    res.status(404).send("Sorry can't find that!");
});

app.use(function (err, req, res, next) {
    console.log(err);
    return res.json(failedJson(400, String(err)));
});

app.options('*', (req, res) => {
    res.header('Access-Control-Allow-Methods', 'GET,POST,OPTIONS');
    res.header('Access-Control-Allow-Headers', 'Origin, X-Requested-With, Content-Type, Accept');
    res.sendStatus(200);
});

app.listen(8089, () => {
    console.log("应用正在使用 8089 端口以提供无名杀本地服务器功能!");
    if (!process.argv[2]) require('child_process').exec('start http://localhost:8089/');
});

class ReturnData {
    success;
    code;
    errorMsg;
    data;
    constructor() { }
    getSuccess() { return this.success; }
    setSuccess(success) { this.success = success; }
    getCode() { return this.code; }
    setCode(errorCode) { this.code = errorCode; }
    getErrorMsg() { return this.errorMsg; }
    setErrorMsg(errorMsg) { this.errorMsg = errorMsg; }
    getData() { this.data; }
    setData(data) { this.data = data; }
}

function successfulJson(data) {
    const returnData = new ReturnData();
    returnData.setSuccess(true);
    returnData.setCode(200);
    returnData.setData(data);
    return returnData;
}

function failedJson(code, message) {
    const returnData = new ReturnData();
    returnData.setSuccess(false);
    returnData.setCode(code);
    returnData.setErrorMsg(message);
    return returnData;
}

} catch (e) {
console.error("本地服务器启动失败: ");
console.error(e);
}

已解决