Merge pull request '优化' (#614) from Eeeros/forgeplus-react:gitlink_ssr_test into gitlink_ssr
1
This commit is contained in:
commit
193d4a0376
|
|
@ -1,6 +1,6 @@
|
|||
import express from "express";
|
||||
import "./window"
|
||||
import {render} from "./render";
|
||||
import { getDomObj } from "./window"
|
||||
import { render } from "./render";
|
||||
import { url } from "../src/ssrUrl";
|
||||
const { createProxyMiddleware } = require('http-proxy-middleware');
|
||||
|
||||
|
|
@ -38,6 +38,7 @@ function excludePath(req, res, next) {
|
|||
app.use(excludePath);
|
||||
|
||||
app.get('*',function (req,res) {
|
||||
global.domObj = getDomObj()
|
||||
render(req,res);
|
||||
})
|
||||
|
||||
|
|
|
|||
|
|
@ -6,17 +6,19 @@ import axios from "axios";
|
|||
const { JSDOM } = jsdom;
|
||||
|
||||
const html = fs.readFileSync(path.join(path.resolve('./build'),'index.html'),'utf-8');
|
||||
const dom = new JSDOM(html);
|
||||
const { window } = dom;
|
||||
const { window } = new JSDOM(html);
|
||||
|
||||
const $ = require( "jquery" )( window )
|
||||
|
||||
global.window = window;
|
||||
global.domObj = dom;
|
||||
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 => {
|
||||
// // 处理响应
|
||||
|
|
|
|||
Loading…
Reference in New Issue