forgeplus-react/server/window.js

33 lines
847 B
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

const jsdom = require("jsdom");
import fs from 'fs'
import path from 'path';
import axios from "axios";
const { JSDOM } = jsdom;
const html = fs.readFileSync(path.join(path.resolve('./build'),'index.html'),'utf-8');
const { window } = new JSDOM(html);
const $ = require( "jquery" )( window )
global.window = window;
global.document = window.document;
global.navigator = window.navigator;
global.localStorage = {}
export const getDomObj = () => {
return new JSDOM(html)
}
// axios.get('https://gw.alipayobjects.com/os/lib/alipay/alex/2.0.19/bundle/alex.all.global.min.js')
// .then(response => {
// // 处理响应
// if (response) {
// // 这里你可以直接使用response.data而不是eval
// eval(response);
// }
// })
// .catch(error => {
// console.error('Error fetching data:', error);
// });