forgeplus-react/server/window.js

37 lines
1019 B
JavaScript
Raw Permalink 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');
// 压缩的项目详情页需要的css
const css = fs.readFileSync(path.join(path.resolve('./build/css'),'detail.css'),'utf-8');
const { window } = new JSDOM(html);
const $ = require( "jquery" )( window )
global.window = window;
global.document = window.document;
global.navigator = window.navigator;
global.localStorage = {}
// 全局缓存css
global.detailCss = css
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);
// });