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.
153 lines
3.8 KiB
153 lines
3.8 KiB
process = require('process');
|
|
|
|
|
|
domino = require('../domino/lib/index');
|
|
window = domino.createWindow("", "http://127.0.0.1/");
|
|
document = window.document;
|
|
location = window.location;
|
|
|
|
Intl = require('./Intl');
|
|
|
|
Promise = require('es6-promise').Promise;
|
|
if (process.env.NODE_ENV == "production") {
|
|
Vue = require('../node_modules/vue/dist/vue.min');
|
|
} else {
|
|
Vue = require('../node_modules/vue/dist/vue');
|
|
}
|
|
|
|
Vue.config.ignoredElements = [/^b-/, /^gv-/];
|
|
|
|
|
|
Vue.GoVueExtend = Vue.extend;
|
|
Vue.UseRaw = function () {
|
|
Vue.use_raw = true
|
|
return Vue
|
|
};
|
|
function HTMLEncode(html) {
|
|
var temp = document.createElement("div");
|
|
(temp.textContent != null) ? (temp.textContent = html) : (temp.innerText = html);
|
|
var output = temp.innerHTML;
|
|
temp = null;
|
|
return output;
|
|
}
|
|
Vue.extend = function (a, b) {
|
|
if (Vue.use_raw) {
|
|
var template = HTMLEncode(a.template)
|
|
a.template = "<gv-template-html>" + template + "<gv-template-html>"
|
|
Vue.use_raw = false;
|
|
}
|
|
|
|
return Vue.GoVueExtend(a, b)
|
|
}
|
|
|
|
|
|
vuessr = require('vue-server-renderer')
|
|
|
|
VueRouter = require('vue-router');
|
|
Vue.use(VueRouter)
|
|
|
|
|
|
$ = jQuery = require('jquery');
|
|
require('jquery-bbq');
|
|
qs = require('qs');
|
|
|
|
|
|
|
|
axios = require('axios');
|
|
|
|
var buildURL = require('axios/lib/helpers/buildURL');
|
|
var buildFullPath = require('axios/lib/core/buildFullPath');
|
|
var settle = require('axios/lib/core/settle');
|
|
var createError = require('axios/lib/core/createError');
|
|
|
|
function transformResponse(mpResponse, config, mpRequestOption) {
|
|
var headers = mpResponse.header || mpResponse.headers;
|
|
var status = mpResponse.statusCode || mpResponse.status;
|
|
var statusText = '';
|
|
if (status === 200) {
|
|
statusText = 'OK';
|
|
}
|
|
else if (status === 400) {
|
|
statusText = 'Bad Request';
|
|
}
|
|
var response = {
|
|
data: mpResponse.data,
|
|
status: status,
|
|
statusText: statusText,
|
|
headers: headers,
|
|
config: config,
|
|
request: mpRequestOption
|
|
};
|
|
return response;
|
|
}
|
|
axios.defaults.adapter = function (config) {
|
|
return new Promise(function (resolve, reject) {
|
|
// console.log("resolve", JSON.stringify(resolve));
|
|
// console.log("reject", JSON.stringify(reject));
|
|
// console.log("config", JSON.stringify(config));
|
|
// console.log("axios.defaults.headers", JSON.stringify(axios.defaults.headers));
|
|
|
|
|
|
var mpRequestOption = {
|
|
url: buildURL(buildFullPath(config.baseURL, config.url), config.params, config.paramsSerializer),
|
|
method: config["method"].toUpperCase(),
|
|
data: config["data"],
|
|
header: config["headers"],
|
|
timeout: config["timeout"],
|
|
success: function (mpResponse) {
|
|
// console.log("success");
|
|
// console.log(JSON.stringify(mpResponse));
|
|
|
|
var response = transformResponse(mpResponse, config, mpRequestOption);
|
|
settle(resolve, reject, response);
|
|
},
|
|
fail: function (error) {
|
|
reject(createError(error.data));
|
|
},
|
|
};
|
|
net.request(mpRequestOption)
|
|
})
|
|
};
|
|
|
|
|
|
|
|
useRoute = {};
|
|
GoUseRegistered = function (id, cb) {
|
|
useRoute[id] = cb
|
|
};
|
|
|
|
|
|
goUseCallCache
|
|
GoUseCall = function (e) {
|
|
// console.log("GoUseCall", 1)
|
|
if (goUseCallCache) {
|
|
goUseCallCache(e)
|
|
}
|
|
|
|
// console.log("GoUseCall", 2)
|
|
var id = e["id"];
|
|
var path = e["path"];
|
|
var query = e["query"];
|
|
if (useRoute[id]) {
|
|
// console.log(useRoute[id])
|
|
useRoute[id](query);
|
|
return
|
|
}
|
|
// console.log("GoUseCall", 3)
|
|
if (useRoute[path]) {
|
|
useRoute[path](query);
|
|
return
|
|
}
|
|
// console.log("路由未找到:", id, "-", path)
|
|
|
|
}
|
|
GoUse = function (cb) {
|
|
goUseCallCache = cb
|
|
}
|
|
|
|
|
|
|
|
for (var i in global) {
|
|
window[i] = global[i]
|
|
}
|
|
|