郑荣升
5 years ago
23 changed files with 93697 additions and 101641 deletions
-
3.gitignore
-
47govue/bindata.go
-
2govue/cmd/main.go
-
30govue/govue-js-src/build.js
-
123370govue/govue-js-src/dist/index.js
-
14govue/govue-js-src/package.json
-
12govue/govue-js-src/predo.js
-
9govue/govue-js-src/replace.tp
-
1govue/govue-js-src/replace2.tp
-
74govue/govue-js-src/src/browser.js
-
104govue/govue-js-src/src/goruntime.js
-
120govue/govue-js-src/src/index.js
-
54852govue/govue-runtime/govue.js
-
109govue/govue-runtime/header.js
-
7203govue/govue-runtime/polyfill.js
-
79govue/govue-runtime/runtime.js
-
8959govue/govue-runtime/vuessr.js
-
110govue/govue.go
-
122jsruntime/runtime.go
-
36jsruntime/timeout.go
-
10pool/pool.go
-
49static/index.html
-
23static/use.js
47
govue/bindata.go
File diff suppressed because it is too large
View File
File diff suppressed because it is too large
View File
123370
govue/govue-js-src/dist/index.js
File diff suppressed because it is too large
View File
File diff suppressed because it is too large
View File
@ -1,15 +1,9 @@ |
|||||
var fs = require("fs"); |
var fs = require("fs"); |
||||
|
|
||||
var retemp = fs.readFileSync("./replace.tp") |
|
||||
var retemp2 = fs.readFileSync("./replace2.tp") |
|
||||
|
|
||||
var content = fs.readFileSync("./dist/index.js") |
var content = fs.readFileSync("./dist/index.js") |
||||
|
|
||||
retemp = retemp.toString().replace(/\r\n/g,"\n") |
|
||||
|
|
||||
var test = content.toString().indexOf(retemp) |
|
||||
console.log(test) |
|
||||
|
// content = content.toString().replace(`_m("`, `this._m("`).replace(`var isHTMLTag = `, `var isHTMLTag = makeMap('html,body,base,head,link,meta,style,title');var _isHTMLTag = `)
|
||||
|
|
||||
|
// fs.writeFileSync("./dist/index.js", content)
|
||||
|
|
||||
|
|
||||
content = content.toString().replace(retemp, `NodeList`).replace(retemp2, ``) |
|
||||
fs.writeFileSync("./dist/index.js", content) |
|
@ -1,9 +0,0 @@ |
|||||
class NodeList extends Array { |
|
||||
constructor(a) { |
|
||||
super((a && a.length) || 0); |
|
||||
if (a) { |
|
||||
for (var idx in a) { this[idx] = a[idx]; } |
|
||||
} |
|
||||
} |
|
||||
item(i) { return this[i] || null; } |
|
||||
} |
|
@ -1 +0,0 @@ |
|||||
throw new Error("NotYetImplemented"); |
|
@ -1,74 +0,0 @@ |
|||||
|
|
||||
console.log("浏览器端") |
|
||||
|
|
||||
|
|
||||
Promise = require('es6-promise').Promise; |
|
||||
|
|
||||
window.Vue = require('vue'); |
|
||||
window.VueRouter = require('vue-router'); |
|
||||
Vue.use(VueRouter) |
|
||||
|
|
||||
|
|
||||
window.$ = window.jQuery = require('jquery'); |
|
||||
require('jquery-bbq'); |
|
||||
|
|
||||
window.axios = require('axios'); |
|
||||
|
|
||||
import VueAxios from 'vue-axios' |
|
||||
window.Vue.use(VueAxios, window.axios) |
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
window.GoQuery = location.search; |
|
||||
window.GoParam = jQuery.deparam(GoQuery); |
|
||||
window.GoUse = function (cb) { |
|
||||
var path = location.pathname |
|
||||
if (path.indexOf(".html") < 0) { |
|
||||
if (path[path.length - 1] == "/" && path.length > 1) { |
|
||||
path = path + "index.html" |
|
||||
} else { |
|
||||
path = path + ".html" |
|
||||
} |
|
||||
} |
|
||||
if (cb) cb(path, location.search) |
|
||||
} |
|
||||
|
|
||||
window.GoUseRegistered = function (id, cb) { |
|
||||
var govueId = ""; |
|
||||
if (document.getElementsByTagName("html").length > 0) { |
|
||||
govueId = document.getElementsByTagName("html")[0].getAttribute("govue-id") |
|
||||
} |
|
||||
var path = location.pathname |
|
||||
if (path.indexOf(".html") < 0) { |
|
||||
if (path[path.length - 1] == "/" && path.length > 1) { |
|
||||
path = path + "index.html" |
|
||||
} else { |
|
||||
path = path + ".html" |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
if (govueId == id || path == id) { |
|
||||
if (cb) cb(location.search) |
|
||||
} |
|
||||
|
|
||||
}; |
|
||||
|
|
||||
|
|
||||
window.GoUseCall = function (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) |
|
||||
} |
|
@ -1,104 +0,0 @@ |
|||||
domino = require('domino'); |
|
||||
window = domino.createWindow("", "http://127.0.0.1/"); |
|
||||
document = window.document; |
|
||||
location = window.location; |
|
||||
|
|
||||
Promise = require('es6-promise').Promise; |
|
||||
|
|
||||
Vue = require('vue'); |
|
||||
$ = 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 |
|
||||
} |
|
@ -1,8 +1,118 @@ |
|||||
|
domino = require('../domino/lib/index'); |
||||
|
window = domino.createWindow("", "http://127.0.0.1/"); |
||||
|
document = window.document; |
||||
|
location = window.location; |
||||
|
|
||||
if (window) { |
|
||||
|
|
||||
require("./browser") |
|
||||
} else { |
|
||||
require("./goruntime") |
|
||||
|
Intl = require('./Intl'); |
||||
|
|
||||
|
Vue = require('vue'); |
||||
|
|
||||
|
VueRouter = require('vue-router'); |
||||
|
Vue.use(VueRouter) |
||||
|
vuessr = require('vue-server-renderer') |
||||
|
$ = jQuery = require('jquery'); |
||||
|
require('jquery-bbq'); |
||||
|
qs = require('qs'); |
||||
|
|
||||
|
Promise = require('es6-promise').Promise; |
||||
|
|
||||
|
|
||||
|
|
||||
|
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] |
||||
} |
} |
||||
|
|
54852
govue/govue-runtime/govue.js
File diff suppressed because it is too large
View File
File diff suppressed because it is too large
View File
7203
govue/govue-runtime/polyfill.js
File diff suppressed because it is too large
View File
File diff suppressed because it is too large
View File
@ -1,34 +1,69 @@ |
|||||
window = domino.createWindow(GoHtmlSrc, GoHref); |
|
||||
|
if (!IS_VUE_SSR) { |
||||
|
|
||||
document = window.document; |
|
||||
|
try { |
||||
|
LoadPage(GoHtmlSrc, GoHref); |
||||
|
} catch (e) { |
||||
|
console.log("LoadPage:" + e); |
||||
|
} |
||||
|
|
||||
location = window.location; |
|
||||
|
try { |
||||
|
var govueId = GetGoVueId(); |
||||
|
} catch (e) { |
||||
|
console.log("GetGoVueId:" + e); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
|
||||
try { |
|
||||
|
|
||||
var govueId = GetGoVueId(); |
|
||||
|
|
||||
LoadGoParam(); |
LoadGoParam(); |
||||
|
|
||||
var goVueIgnore = new GoVueIgnore(); |
|
||||
goVueIgnore.ignore(); |
|
||||
|
try { |
||||
|
var goVueIgnore = new GoVueIgnore(); |
||||
|
|
||||
|
goVueIgnore.ignore(); |
||||
|
|
||||
|
} catch (e) { |
||||
|
console.log("goVueIgnore.ignore:" + e); |
||||
|
} |
||||
|
|
||||
GoUseCall({ |
|
||||
id: govueId, |
|
||||
path: GoPath, |
|
||||
query: jQuery.deparam(GoQuery) |
|
||||
}); |
|
||||
|
try { |
||||
|
GoUseCall({ |
||||
|
id: govueId, |
||||
|
path: GoPath, |
||||
|
query: jQuery.deparam(GoQuery) |
||||
|
}); |
||||
|
} catch (e) { |
||||
|
console.log("GoUseCall:" + e); |
||||
|
} |
||||
|
|
||||
RunInlineCode(); |
|
||||
|
try { |
||||
|
RunInlineCode(); |
||||
|
} catch (e) { |
||||
|
console.log("RunInlineCode:" + e); |
||||
|
} |
||||
|
|
||||
goVueIgnore.restore() |
|
||||
|
try { |
||||
|
goVueIgnore.restore(); |
||||
|
|
||||
|
} catch (e) { |
||||
|
console.log("goVueIgnore.restore:" + e); |
||||
|
} |
||||
|
|
||||
} catch (e) { |
|
||||
console.log("VM Uncaught:", e); |
|
||||
} |
|
||||
// console.log(document.innerHTML);
|
|
||||
GoReturn(document.innerHTML); |
|
||||
|
try { |
||||
|
GoReturn(document.innerHTML); |
||||
|
} catch (e) { |
||||
|
console.log("GoReturn:" + e) |
||||
|
} |
||||
|
} else { |
||||
|
try { |
||||
|
LoadPage(GoHtmlSrc, GoHref); |
||||
|
} catch (e) { |
||||
|
console.log("LoadPage:" + e); |
||||
|
} |
||||
|
try { |
||||
|
GoUseCall({ |
||||
|
path: GoPath, |
||||
|
query: jQuery.deparam(GoQuery) |
||||
|
}); |
||||
|
} catch (e) { |
||||
|
console.log("GoUseCall:" + e); |
||||
|
} |
||||
|
} |
8959
govue/govue-runtime/vuessr.js
File diff suppressed because it is too large
View File
File diff suppressed because it is too large
View File
Write
Preview
Loading…
Cancel
Save
Reference in new issue