Browse Source

fix

tags/v0.9.2 v0.9.2
郑荣升 5 years ago
parent
commit
ce956aaeb7
  1. 35
      govue/bindata.go
  2. 10
      govue/govue-js-src/build.js
  3. 67
      govue/govue-js-src/dist/index.js
  4. 3
      govue/govue-js-src/src/index.js
  5. 85427
      govue/govue-runtime/govue.js
  6. 6
      govue/govue-runtime/header.js
  7. 9
      govue/govue-runtime/runtime.js
  8. 53
      govue/govue.go
  9. 4
      readme.md
  10. 61
      static/index.html
  11. 11965
      static/js/vue.js
  12. 6
      static/js/vue.min.js
  13. 13
      static/ssr.vue
  14. 20
      static/use.js

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

10
govue/govue-js-src/build.js

@ -11,11 +11,11 @@ browserify("./src/index.js")
// "transform-remove-strict-mode"
// ]
// })
// .transform(
// // 用来处理 `node_modules` 文件
// { global: true },
// envify({ NODE_ENV: 'production' })
// )
.transform(
// 用来处理 `node_modules` 文件
{ global: true },
envify({ NODE_ENV: 'production' })
)
.bundle()
.pipe(fs.createWriteStream("./dist/index.js"));

67
govue/govue-js-src/dist/index.js
File diff suppressed because it is too large
View File

3
govue/govue-js-src/src/index.js

@ -7,9 +7,10 @@ Intl = require('./Intl');
Vue = require('vue');
vuessr = require('vue-server-renderer')
VueRouter = require('vue-router');
Vue.use(VueRouter)
vuessr = require('vue-server-renderer')
$ = jQuery = require('jquery');
require('jquery-bbq');
qs = require('qs');

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

6
govue/govue-runtime/header.js

@ -126,11 +126,7 @@ function LoadPage(src, href) {
* @return {string}
*/
function GetGoVueId() {
var id = "";
if (document.getElementsByTagName("html").length > 0) {
id = document.getElementsByTagName("html")[0].getAttribute("gv-id")
}
return id;
return document.querySelector("[gv-id]").getAttribute("gv-id");
}
/**

9
govue/govue-runtime/runtime.js

@ -8,6 +8,7 @@ if (!IS_VUE_SSR) {
try {
var govueId = GetGoVueId();
// console.log("govueId",govueId);
} catch (e) {
console.log("GetGoVueId:" + e);
}
@ -53,6 +54,7 @@ if (!IS_VUE_SSR) {
console.log("GoReturn:" + e)
}
} else {
console.log("vue-ssr模式");
try {
LoadPage(GoHtmlSrc, GoHref);
} catch (e) {
@ -66,4 +68,11 @@ if (!IS_VUE_SSR) {
} catch (e) {
console.log("GoUseCall:" + e);
}
try {
RunInlineCode();
} catch (e) {
console.log("RunInlineCode:" + e);
}
}

53
govue/govue.go

@ -60,49 +60,54 @@ func (gv *GoVue) initRender(debug bool) (err error) {
gv.UseJsPath = filepath.Join(gv.StaticPath, "use.js")
}
vuessr, err := ioutil.ReadFile(filepath.Join("govue", "govue-runtime", "vuessr.js"))
//vuessr, err := ioutil.ReadFile(filepath.Join("govue", "govue-runtime", "vuessr.js"))
//if err != nil {
// return
//}
//polyfill, err := ioutil.ReadFile(filepath.Join("govue", "govue-runtime", "polyfill.js"))
//if err != nil {
// return
//}
//
//mainScript, err := ioutil.ReadFile(filepath.Join("govue", "govue-runtime", "runtime.js"))
//if err != nil {
// return
//}
//
//headerScript, err := ioutil.ReadFile(filepath.Join("govue", "govue-runtime", "header.js"))
//if err != nil {
// return
//}
//
//govueScript, err := ioutil.ReadFile(filepath.Join("govue", "govue-js-src", "dist", "index.js"))
//if err != nil {
// return
//}
vuessr, err := gv.Resources.Asset(filepath.Join("govue-runtime", "vuessr.js"))
if err != nil {
return
}
polyfill, err := ioutil.ReadFile(filepath.Join("govue", "govue-runtime", "polyfill.js"))
polyfill, err := gv.Resources.Asset(filepath.Join("govue-runtime", "polyfill.js"))
if err != nil {
return
}
mainScript, err := ioutil.ReadFile(filepath.Join("govue", "govue-runtime", "runtime.js"))
mainScript, err := gv.Resources.Asset(filepath.Join("govue-runtime", "runtime.js"))
if err != nil {
return
}
headerScript, err := ioutil.ReadFile(filepath.Join("govue", "govue-runtime", "header.js"))
govueScript, err := gv.Resources.Asset(filepath.Join("govue-runtime", "govue.js"))
if err != nil {
return
}
govueScript, err := ioutil.ReadFile(filepath.Join("govue", "govue-js-src", "dist", "index.js"))
headerScript, err := gv.Resources.Asset(filepath.Join("govue-runtime", "header.js"))
if err != nil {
return
}
//mainScript, err := gv.Resources.Asset(filepath.Join("govue-runtime", "runtime.js"))
//if err != nil {
// return
//}
//govueScript, err := gv.Resources.Asset(filepath.Join("govue-runtime", "govue.js"))
//if err != nil {
// return
//}
//headerScript, err := gv.Resources.Asset(filepath.Join("govue-runtime", "header.js"))
//if err != nil {
// return
//}
//vueScript, err := ioutil.ReadFile(filepath.Join("static", "js", "vue.js"))
//if err != nil {
// return
//}
gv.jsRuntimePool = pool.NewJsRuntimePool(string(mainScript), gv.UseJsPath, gv.StaticPath, jsruntime.Relys{
jsruntime.Rely{
Src: string(polyfill),

4
readme.md

@ -61,4 +61,6 @@
+ gv-ignore标签,gv-ignore块下的标签不会被服务器渲染
+ class='gv-ignore' 含有class为gv-ignore的标签,属性不会被渲染
+ class='gv-ignore' 含有class为gv-ignore的标签,属性不会被渲染[新版本已经作废]
+ gv-ignore='@|v-on' 含有gv-ignore为属性的标签内的属性,所在值不会被vue服务端渲染,"|" 隔开,如果留空则当前标签内所有属性均不会被渲染

61
static/index.html

@ -4,58 +4,33 @@
<meta charset="utf-8">
<meta name="keywords" content="">
<link rel="stylesheet" href="css/main.css">
<script src="js/vue.js" gv-src></script>
<script src="js/vue.js"></script>
</head>
<body>
<div id="demo">
<div>searchShops</div>
<div id="app">
<div class="content">
<my-title></my-title>
<a v-on:click="click" gv-ignore>{{desc}}</a>
<br>
<br>
<br>
<a href="#" v-on:click="ssr" gv-ignore>{{a}}</a>
</div>
</div>
</body>
<script gv-src>
a = function () {
this.m5 = function () {
this.m(this.c)
};
this.m2 = (new Function("with(this){m(c)}"))
this.m3 = (new Function("with(this){m4('hello')}"))
};
a.prototype.c = "hello";
a.prototype.m = function () {
console.log("c:", this.c)
};
a.prototype.m4 = function (a) {
console.log(this);
console.log("c:", a)
};
b = new a();
b.m5();
b.m3();
b.m2();
</script>
<script gv-src>
var a = new Vue({
el: "#demo",
data: {
title: "两端通用加载",
categoryList: [],
swiperList: [],
searchShops: "123",
},
<script>
new Vue({
el: "#app",
methods: {
click: function () {
alert("点击触发");
}
},
ssr: function () {
location.href = "ssr.html?test"
},
}
});
</script>
</html>

11965
static/js/vue.js
File diff suppressed because it is too large
View File

6
static/js/vue.min.js
File diff suppressed because it is too large
View File

13
static/ssr.vue

@ -0,0 +1,13 @@
<div id="app">访问的 URL {{ url }}</div>
<script gv-src>
var context = {
title: 'hello'
};
var app = new Vue({
el:"#app",
data: {
url: location.href
}
});
GoVueRender("template/ssr.html", app, context)
</script>

20
static/use.js

@ -2,12 +2,28 @@
GoUse(function () {
});
//分页面
GoUseRegistered("index", function (query) {
// 定义一个名为 button-counter 的新组件
document.title = "govue";
document
.getElementsByName("keywords")[0]
.setAttribute("content", "govue,服务端渲染,ssr");
Vue.component('my-title', {
template: '<h1 id="title">govue</h1>'
});
//分页面
GoUseRegistered("index", function (query) {
new Vue({
el: "#app",
data: {
"desc": "基础golang开发的一套vue服务端渲染方案",
"a": "官方ssr模式",
},
});
});
Loading…
Cancel
Save