代码拉取完成,页面将自动刷新
var fs = require('fs');
// 后端服务器地址和端口
var proxyTarget = '120.26.76.247';
var proxyTargetPort = 8090;
// mockup开关
var MOCKUP = false;
// mockup目录
var mockupDir = '/mockup';
exports.port = 8848;
exports.directoryIndexes = true;
exports.documentRoot = __dirname;
exports.getLocations = function () {
return [
{
location: /\/$/,
handler: home( 'index.html' )
},
{
location: /^\/redirect-local/,
handler: redirect('redirect-target', false)
},
{
location: /^\/redirect-remote/,
handler: redirect('http://www.baidu.com', false)
},
{
location: '/empty',
handler: empty()
},
{
location: /\.css($|\?)/,
handler: [
autocss()
]
},
{
location: /uploadimage$/,
handler: [
function (context) {
context.content = JSON.stringify(
{
"url":"http://img.wxplaymall.com/336eba80b4d3ac466e8d4f068c490558/6eb21c482b50318f4f97721150f483e1.jpg",
"state":"SUCCESS"
}
);
context.status = 200;
}
]
},
{
location: /\.less($|\?)/,
handler: [
file(),
less()
]
},
{
location: /^\/api\/.*$/,
handler: [
function(context) {
var pathname = context.request.pathname;
var method = context.request.method;
var conf = context.conf;
var docRoot = conf.documentRoot;
var prefix = docRoot + mockupDir + pathname.replace(/^\/api/, '').replace(/\/\d+$/g, '');
var filePath = prefix;
if (MOCKUP) {
addJSONSuffix();
console.log('[MOCKUP]', pathname, '[' + method + ']', ' --> ', filePath);
file(filePath)(context);
}
else {
context.status = 404;
}
function addJSONSuffix() {
if (!/\.\w+$/.test(pathname)) {
filePath += '.json';
context.header[ 'Content-Type' ] = 'application/json';
}
}
},
function (context) {
if (MOCKUP) {
}
},
function(context) {
if (context.status == 404 || context.status == 302) {
proxy(proxyTarget, proxyTargetPort)(context);
}
}
]
},
{
location: /^.*$/,
handler: [
file()
]
}
];
};
exports.injectResource = function ( res ) {
for ( var key in res ) {
global[ key ] = res[ key ];
}
};
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。