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

24 lines
882 B
JavaScript

layui.define(function (exports) {
// 根据环境获取请求地址
var host = window.location.host;
var mockUrl = "/api/";
var bossUrl = '';
if (host.indexOf('127.0.0.1') > -1 || host.indexOf('localhost') > -1 || host.indexOf('192.168.') > -1) {// 本地环境
bossUrl = 'https://127.0.0.1/';
} else if (host.indexOf('-dev') > -1) {// 开发环境
bossUrl = 'https://admin-de.ppst.top/';
} else if (host.indexOf('-te') > -1) {// 测试环境
bossUrl = 'https://admin-te.ppst.top/';
} else {// 生产环境
bossUrl = 'https://admin.ppst.top/';
}
exports('api', {
getApiUrl: function (mapping, funcName) {
return bossUrl + mapping + '/' + funcName;
},
getMockApiUrl: function (mapping, funcName) {
return mockUrl + mapping + '/' + funcName;
}
});
});