2023-12-29 16:43:14 +08:00
|
|
|
|
const jsdom = require("jsdom");
|
|
|
|
|
|
import fs from 'fs'
|
|
|
|
|
|
import path from 'path';
|
2024-01-05 15:01:16 +08:00
|
|
|
|
import axios from "axios";
|
2023-12-29 16:43:14 +08:00
|
|
|
|
|
|
|
|
|
|
const { JSDOM } = jsdom;
|
|
|
|
|
|
|
2024-01-05 15:01:16 +08:00
|
|
|
|
const html = fs.readFileSync(path.join(path.resolve('./build'),'index.html'),'utf-8');
|
2024-01-19 17:34:43 +08:00
|
|
|
|
const { window } = new JSDOM(html);
|
2023-12-29 16:43:14 +08:00
|
|
|
|
|
2024-01-05 15:01:16 +08:00
|
|
|
|
const $ = require( "jquery" )( window )
|
|
|
|
|
|
|
2023-12-29 16:43:14 +08:00
|
|
|
|
global.window = window;
|
|
|
|
|
|
global.document = window.document;
|
|
|
|
|
|
global.navigator = window.navigator;
|
2024-01-05 15:01:16 +08:00
|
|
|
|
global.localStorage = {}
|
|
|
|
|
|
|
2024-01-19 17:34:43 +08:00
|
|
|
|
export const getDomObj = () => {
|
|
|
|
|
|
return new JSDOM(html)
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-01-12 11:16:01 +08:00
|
|
|
|
// 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);
|
|
|
|
|
|
// });
|