mirror of
https://gitee.com/jisol/jisol-game/
synced 2025-06-25 19:04:43 +00:00
56 lines
1.8 KiB
JavaScript
56 lines
1.8 KiB
JavaScript
// const URL = "http://192.168.0.174:7457/web-desktop/web-desktop/index.html"
|
|
// const express = require("express");
|
|
// const app = express();
|
|
const URL = "http://192.168.207.76:7456/web-desktop/web-desktop/index.html"
|
|
|
|
// const runCocos = () => {
|
|
const { JSDOM,ResourceLoader } = require('jsdom')
|
|
const fetch = (...args) => import('node-fetch').then(({default: fetch}) => fetch(...args));
|
|
const axios = require('axios').default;
|
|
const WebGL = require('gl');
|
|
const { request } = require('express');
|
|
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",
|
|
});
|
|
|
|
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";
|
|
window['axios'] = axios;
|
|
})
|
|
|
|
setTimeout(() => {}, 999999999999);
|
|
// }
|
|
// app.use('/static', express.static('static'))
|
|
// app.listen(3000, () => {
|
|
// console.log("服务启动");
|
|
// runCocos();
|
|
// });
|