// 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.0.170:7457/web-desktop/web-desktop-001/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(() => {}, 99999999); // } // app.use('/static', express.static('static')) // app.listen(3000, () => { // console.log("服务启动"); // runCocos(); // });