59 lines
1.7 KiB
TypeScript
59 lines
1.7 KiB
TypeScript
// @ts-nocheck
|
|
import './core/polyfill';
|
|
import '@@/core/devScripts';
|
|
import { plugin } from './core/plugin';
|
|
import './core/pluginRegister';
|
|
import { createHistory } from './core/history';
|
|
import { ApplyPluginsType } from '/Users/teddyj/Library/Mobile Documents/com~apple~CloudDocs/Documents/workspace/dev/nicenote/node_modules/_@umijs_runtime@3.5.41@@umijs/runtime';
|
|
import { renderClient } from '/Users/teddyj/Library/Mobile Documents/com~apple~CloudDocs/Documents/workspace/dev/nicenote/node_modules/_@umijs_renderer-react@3.5.41@@umijs/renderer-react/dist/index.js';
|
|
import { getRoutes } from './core/routes';
|
|
|
|
|
|
|
|
|
|
const getClientRender = (args: { hot?: boolean; routes?: any[] } = {}) => plugin.applyPlugins({
|
|
key: 'render',
|
|
type: ApplyPluginsType.compose,
|
|
initialValue: () => {
|
|
const opts = plugin.applyPlugins({
|
|
key: 'modifyClientRenderOpts',
|
|
type: ApplyPluginsType.modify,
|
|
initialValue: {
|
|
routes: args.routes || getRoutes(),
|
|
plugin,
|
|
history: createHistory(args.hot),
|
|
isServer: process.env.__IS_SERVER,
|
|
rootElement: 'root',
|
|
defaultTitle: ``,
|
|
},
|
|
});
|
|
return renderClient(opts);
|
|
},
|
|
args,
|
|
});
|
|
|
|
const clientRender = getClientRender();
|
|
export default clientRender();
|
|
|
|
|
|
window.g_umi = {
|
|
version: '3.5.41',
|
|
};
|
|
|
|
|
|
// hot module replacement
|
|
// @ts-ignore
|
|
if (module.hot) {
|
|
// @ts-ignore
|
|
module.hot.accept('./core/routes', () => {
|
|
const ret = require('./core/routes');
|
|
if (ret.then) {
|
|
ret.then(({ getRoutes }) => {
|
|
getClientRender({ hot: true, routes: getRoutes() })();
|
|
});
|
|
} else {
|
|
getClientRender({ hot: true, routes: ret.getRoutes() })();
|
|
}
|
|
});
|
|
}
|