|
|
@ -3,6 +3,13 @@ GV.init(function (_require) { |
|
|
|
this.require = _require; |
|
|
|
var Vue = this.Vue = _require('Vue'); |
|
|
|
|
|
|
|
var CleanVue = function () { |
|
|
|
for (var i in Vue.options.components){ |
|
|
|
delete Vue.options.components[i]; |
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
this.VueRouter = _require('vue-router'); |
|
|
|
this.Vue.use(this.VueRouter); |
|
|
|
this.axios = _require('axios'); |
|
|
@ -15,9 +22,13 @@ GV.init(function (_require) { |
|
|
|
|
|
|
|
app.$options.template = ctx.content; |
|
|
|
|
|
|
|
// console.log(ctx.template)
|
|
|
|
var template = ctx.template; |
|
|
|
if (cleanInlineJsCtx){ |
|
|
|
template = cleanInlineJsCtx.template; |
|
|
|
} |
|
|
|
|
|
|
|
var renderer = _require('vue-server-renderer').createRenderer({ |
|
|
|
template: cleanInlineJsCtx.template |
|
|
|
template: template |
|
|
|
}); |
|
|
|
|
|
|
|
if (!context) { |
|
|
@ -27,10 +38,12 @@ GV.init(function (_require) { |
|
|
|
context.GoVueData = "<go-vue-data style='display: none'>" + Base64Encode(encodeURIComponent(JSON.stringify(app.$data))) + "</go-vue-data>" |
|
|
|
renderer.renderToString(app, context, function (err, html) { |
|
|
|
if (err) { |
|
|
|
Vue.options = {}; |
|
|
|
CleanVue(); |
|
|
|
throw err |
|
|
|
} else { |
|
|
|
if (cleanInlineJsCtx){ |
|
|
|
html = html.replace("<!--gv-js-outlet-->",cleanInlineJsCtx.content); |
|
|
|
} |
|
|
|
GoReturn(html); |
|
|
|
} |
|
|
|
}) |
|
|
@ -44,7 +57,7 @@ GV.init(function (_require) { |
|
|
|
code: GoUseCallback, |
|
|
|
error: e.toString(), |
|
|
|
})); |
|
|
|
Vue.options = {}; |
|
|
|
CleanVue(); |
|
|
|
throw e |
|
|
|
} |
|
|
|
|
|
|
@ -60,12 +73,12 @@ GV.init(function (_require) { |
|
|
|
code: "with(this){\n" + codes[i] + "\n}", |
|
|
|
error: e.toString(), |
|
|
|
})); |
|
|
|
Vue.options = {}; |
|
|
|
CleanVue(); |
|
|
|
throw e |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
Vue.options = {}; |
|
|
|
CleanVue(); |
|
|
|
|
|
|
|
})() |
|
|
|
}) |
|
|
|
}); |