|
@ -1,20 +1,24 @@ |
|
|
GV.init(function (_require) { |
|
|
GV.init(function (_require) { |
|
|
new (function () { |
|
|
new (function () { |
|
|
this.require = _require; |
|
|
this.require = _require; |
|
|
this.Vue = _require('Vue'); |
|
|
|
|
|
|
|
|
var Vue = this.Vue = _require('Vue'); |
|
|
|
|
|
|
|
|
this.VueRouter = _require('vue-router'); |
|
|
this.VueRouter = _require('vue-router'); |
|
|
this.Vue.use(this.VueRouter) |
|
|
|
|
|
|
|
|
this.Vue.use(this.VueRouter); |
|
|
this.axios = _require('axios'); |
|
|
this.axios = _require('axios'); |
|
|
var htmlparser2 = _require('htmlparser2'); |
|
|
var htmlparser2 = _require('htmlparser2'); |
|
|
axiosUse(this); |
|
|
axiosUse(this); |
|
|
this.qs = _require('qs'); |
|
|
this.qs = _require('qs'); |
|
|
this.GoVueMount = function (app, context) { |
|
|
this.GoVueMount = function (app, context) { |
|
|
var ctx = GetGoVueTemplate(GoHtmlSrc) |
|
|
|
|
|
|
|
|
var ctx = GetGoVueTemplate(GoHtmlSrc); |
|
|
|
|
|
var cleanInlineJsCtx = GetGoVueTemplateInlineJs(ctx.template); |
|
|
|
|
|
|
|
|
app.$options.template = ctx.content; |
|
|
app.$options.template = ctx.content; |
|
|
|
|
|
|
|
|
// console.log(ctx.template)
|
|
|
// console.log(ctx.template)
|
|
|
var renderer = _require('vue-server-renderer').createRenderer({ |
|
|
var renderer = _require('vue-server-renderer').createRenderer({ |
|
|
template: ctx.template |
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
template: cleanInlineJsCtx.template |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
if (!context) { |
|
|
if (!context) { |
|
|
context = {} |
|
|
context = {} |
|
@ -23,8 +27,10 @@ GV.init(function (_require) { |
|
|
context.GoVueData = "<go-vue-data style='display: none'>" + Base64Encode(encodeURIComponent(JSON.stringify(app.$data))) + "</go-vue-data>" |
|
|
context.GoVueData = "<go-vue-data style='display: none'>" + Base64Encode(encodeURIComponent(JSON.stringify(app.$data))) + "</go-vue-data>" |
|
|
renderer.renderToString(app, context, function (err, html) { |
|
|
renderer.renderToString(app, context, function (err, html) { |
|
|
if (err) { |
|
|
if (err) { |
|
|
|
|
|
Vue.options = {}; |
|
|
throw err |
|
|
throw err |
|
|
} else { |
|
|
} else { |
|
|
|
|
|
html = html.replace("<!--gv-js-outlet-->",cleanInlineJsCtx.content); |
|
|
GoReturn(html); |
|
|
GoReturn(html); |
|
|
} |
|
|
} |
|
|
}) |
|
|
}) |
|
@ -37,7 +43,8 @@ GV.init(function (_require) { |
|
|
GoSetError(JSON.stringify({ |
|
|
GoSetError(JSON.stringify({ |
|
|
code: GoUseCallback, |
|
|
code: GoUseCallback, |
|
|
error: e.toString(), |
|
|
error: e.toString(), |
|
|
})) |
|
|
|
|
|
|
|
|
})); |
|
|
|
|
|
Vue.options = {}; |
|
|
throw e |
|
|
throw e |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -52,9 +59,13 @@ GV.init(function (_require) { |
|
|
GoSetError(JSON.stringify({ |
|
|
GoSetError(JSON.stringify({ |
|
|
code: "with(this){\n" + codes[i] + "\n}", |
|
|
code: "with(this){\n" + codes[i] + "\n}", |
|
|
error: e.toString(), |
|
|
error: e.toString(), |
|
|
})) |
|
|
|
|
|
|
|
|
})); |
|
|
|
|
|
Vue.options = {}; |
|
|
throw e |
|
|
throw e |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
Vue.options = {}; |
|
|
|
|
|
|
|
|
})() |
|
|
})() |
|
|
}) |
|
|
}) |