You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

94 lines
3.3 KiB

"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
function _react() {
const data = _interopRequireDefault(require("react"));
_react = function _react() {
return data;
};
return data;
}
function _path() {
const data = require("path");
_path = function _path() {
return data;
};
return data;
}
function _fs() {
const data = require("fs");
_fs = function _fs() {
return data;
};
return data;
}
function _umi() {
const data = require("umi");
_umi = function _umi() {
return data;
};
return data;
}
var _scripts = _interopRequireWildcard(require("../utils/scripts"));
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; }
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
const got = _umi().utils.got,
winPath = _umi().utils.winPath;
var _default = ctx => /*#__PURE__*/function () {
var _ref = _asyncToGenerator(function* (req, res) {
const scripts = yield (0, _scripts.default)(); // Index Page
let content = null;
const localeDebug = !(0, _fs().existsSync)((0, _path().join)(winPath(__dirname), '../../web/dist/index.html'));
if (localeDebug) {
try {
const _yield$got = yield got(`http://127.0.0.1:8002${req.path}`),
body = _yield$got.body;
res.set('Content-Type', 'text/html');
res.send((0, _scripts.normalizeHtml)(body, scripts));
} catch (e) {
console.error(e);
}
} else {
if (!content) {
content = (0, _fs().readFileSync)((0, _path().join)(winPath(__dirname), '../../web/dist/index.html'), 'utf-8');
}
res.send((0, _scripts.normalizeHtml)(content, scripts));
}
});
return function (_x, _x2) {
return _ref.apply(this, arguments);
};
}();
exports.default = _default;