3136352472 5 years ago
parent
commit
28043bb6f5
  1. 18
      govue/bindata.go
  2. 9
      govue/govue-js-src/src/index.js
  3. 795
      govue/govue-runtime/govue-dev.js
  4. 795
      govue/govue-runtime/govue-release.js
  5. 2
      govue/govue-runtime/header.js
  6. 6
      jsruntime/runtime.go
  7. 4
      static/use.js

18
govue/bindata.go
File diff suppressed because it is too large
View File

9
govue/govue-js-src/src/index.js

@ -33,9 +33,16 @@ function HTMLEncode(html) {
temp = null; temp = null;
return output; return output;
} }
function Base64Encode(html) {
return new Buffer(html).toString('base64');
}
Vue.extend = function (a, b) { Vue.extend = function (a, b) {
if (Vue.use_raw) { if (Vue.use_raw) {
var template = HTMLEncode(a.template)
var template = Base64Encode(a.template)
a.template = "<gv-template-html>" + template + "</gv-template-html>" a.template = "<gv-template-html>" + template + "</gv-template-html>"
Vue.use_raw = false; Vue.use_raw = false;
} }

795
govue/govue-runtime/govue-dev.js
File diff suppressed because it is too large
View File

795
govue/govue-runtime/govue-release.js
File diff suppressed because it is too large
View File

2
govue/govue-runtime/header.js

@ -306,6 +306,6 @@ function GoVueRestoreRawTemplate() {
var template = document.getElementsByTagName("gv-template-html"); var template = document.getElementsByTagName("gv-template-html");
for (var i in template) { for (var i in template) {
template[i].outerHTML = HTMLDecode(template[i].innerHTML);
template[i].outerHTML = Base64Decode(template[i].innerHTML);
} }
} }

6
jsruntime/runtime.go

@ -2,6 +2,7 @@ package jsruntime
import ( import (
"crypto/md5" "crypto/md5"
"encoding/base64"
"fmt" "fmt"
"github.com/dop251/goja" "github.com/dop251/goja"
"html" "html"
@ -59,6 +60,11 @@ func NewJsRuntime(mainScript string, extFileDir string, rels Relys, mode RunMode
jr.EnableConsoleFun() jr.EnableConsoleFun()
jr.SetVariable("Base64Decode", func(text string) string {
code, _ := base64.StdEncoding.DecodeString(text)
return string(code)
})
jr.SetVariable("GoReadFile", func(filePath string) string { jr.SetVariable("GoReadFile", func(filePath string) string {
code, err := ioutil.ReadFile(filepath.Join(jr.ExtFileDir, filePath)) code, err := ioutil.ReadFile(filepath.Join(jr.ExtFileDir, filePath))
if err != nil { if err != nil {

4
static/use.js

@ -14,8 +14,8 @@ GoUseRegistered("index", function (query) {
.getElementsByName("keywords")[0] .getElementsByName("keywords")[0]
.setAttribute("content", "govue,服务端渲染,ssr"); .setAttribute("content", "govue,服务端渲染,ssr");
Vue.component('my-title', {
template: '<h1 id="title">govue</h1>'
Vue.UseRaw().component('my-title', {
template: '<h1 id="title">govue{{a}}</h1>'
}); });
new Vue({ new Vue({

Loading…
Cancel
Save