mirror of
https://gitee.com/jisol/jisol-game/
synced 2025-10-10 09:06:17 +00:00
无头模式测试
This commit is contained in:
@@ -1,53 +1,55 @@
|
||||
// const URL = "http://192.168.0.174:7457/web-desktop/web-desktop/index.html"
|
||||
const express = require("express");
|
||||
const app = express();
|
||||
const URL = "http://127.0.0.1:3000/static/index.html"
|
||||
// const express = require("express");
|
||||
// const app = express();
|
||||
const URL = "http://192.168.1.23:7456/web-desktop/web-desktop-001/index.html"
|
||||
|
||||
const runCocos = () => {
|
||||
// const runCocos = () => {
|
||||
const { JSDOM,ResourceLoader } = require('jsdom')
|
||||
const fetch = (...args) => import('node-fetch').then(({default: fetch}) => fetch(...args));
|
||||
|
||||
const { JSDOM,ResourceLoader } = require('jsdom')
|
||||
const fetch = (...args) => import('node-fetch').then(({default: fetch}) => fetch(...args));
|
||||
const WebGL = require('gl');
|
||||
const { request } = require('express');
|
||||
const WebGLRenderingContext = WebGL.WebGLRenderingContext;
|
||||
WebGLRenderingContext.prototype.texSubImage2D = function(){};
|
||||
const gl = WebGL(64, 64, { preserveDrawingBuffer: true });
|
||||
|
||||
const WebGL = require('gl');
|
||||
const WebGLRenderingContext = WebGL.WebGLRenderingContext;
|
||||
WebGLRenderingContext.prototype.texSubImage2D = function(){};
|
||||
const gl = WebGL(64, 64, { preserveDrawingBuffer: true });
|
||||
const resourceLoader = new ResourceLoader({
|
||||
proxy: URL,
|
||||
strictSSL: false,
|
||||
userAgent: "Mellblomenator/9000",
|
||||
});
|
||||
|
||||
const resourceLoader = new ResourceLoader({
|
||||
proxy: URL,
|
||||
strictSSL: false,
|
||||
// userAgent: "Mellblomenator/9000",
|
||||
});
|
||||
fetch(URL).then(res => res.text()).then(html => {
|
||||
console.log("HTML Index 文件: ",html)
|
||||
global.window = (new JSDOM(html, {
|
||||
url: URL,
|
||||
referrer: URL,
|
||||
contentType: "text/html; charset=utf-8",
|
||||
resources:resourceLoader,
|
||||
storageQuota: 10000000 ,
|
||||
runScripts: "dangerously"
|
||||
})).window;
|
||||
|
||||
let HGContext = window.HTMLCanvasElement.prototype.getContext;
|
||||
window.TextDecoder = global.TextDecoder;
|
||||
window.HTMLCanvasElement.prototype.getContext = function(type,data) {
|
||||
if(type == "2d") {
|
||||
const TD = HGContext.bind(this)(type,data);
|
||||
TD.RenderComponentHandle = ()=>{}
|
||||
return TD;
|
||||
}
|
||||
return gl;
|
||||
};
|
||||
window.requestAnimationFrame = global.requestAnimationFrame;
|
||||
window.fetch = fetch;
|
||||
window.GUser = "100000";
|
||||
window.GPassworld = "123456";
|
||||
})
|
||||
|
||||
fetch(URL).then(res => res.text()).then(html => {
|
||||
console.log("HTML Index 文件: ",html)
|
||||
global.window = (new JSDOM(html, {
|
||||
url: URL,
|
||||
referrer: URL,
|
||||
contentType: "text/html; charset=utf-8",
|
||||
resources:resourceLoader,
|
||||
storageQuota: 10000000 ,
|
||||
runScripts: "dangerously"
|
||||
})).window;
|
||||
|
||||
let HGContext = window.HTMLCanvasElement.prototype.getContext;
|
||||
window.TextDecoder = global.TextDecoder;
|
||||
window.HTMLCanvasElement.prototype.getContext = function(type,data) {
|
||||
if(type == "2d") {
|
||||
const TD = HGContext.bind(this)(type,data);
|
||||
TD.RenderComponentHandle = ()=>{}
|
||||
return TD;
|
||||
}
|
||||
return gl;
|
||||
};
|
||||
window.requestAnimationFrame = global.requestAnimationFrame;
|
||||
window.fetch = fetch;
|
||||
})
|
||||
|
||||
setTimeout(() => {}, 99999999);
|
||||
}
|
||||
app.use('/static', express.static('static'))
|
||||
app.listen(3000, () => {
|
||||
console.log("服务启动");
|
||||
runCocos();
|
||||
});
|
||||
setTimeout(() => {}, 99999999);
|
||||
// }
|
||||
// app.use('/static', express.static('static'))
|
||||
// app.listen(3000, () => {
|
||||
// console.log("服务启动");
|
||||
// runCocos();
|
||||
// });
|
Reference in New Issue
Block a user