-
Notifications
You must be signed in to change notification settings - Fork 434
view 层代码和 service 代码做的改动
Qiming zhao edited this page Dec 26, 2016
·
5 revisions
WEPT 尽最大可能使用官方的 service 层和 view 层代码,为了支持热更新等功能,对源码进行了一些改动:
- 使用 parent.postMessage 在 iframe 之间通讯(官方使用的是 contentScript 方式)
- 去除 parent == self 判定
63c63
< i.comefrom = "webframe", i.webviewID = f.webviewID, i = JSON.parse(JSON.stringify(i)), window.parent.postMessage(i, "*")
---
> i.comefrom = "webframe", i.webviewID = f.webviewID, i = JSON.parse(JSON.stringify(i)), window.postMessage(i, "*")
362c362
< A.isWeapp && (A.isAndroid || A.isiPhone) && window.__wxConfig && window.__wxConfig.window && window.__wxConfig.window.enablePullDownRefresh && (E = e, a(), r(), d())
---
> A.isWeapp && (A.isAndroid || A.isiPhone) && window.parent === self && window.__wxConfig && window.__wxConfig.window && window.__wxConfig.window.enablePullDownRefresh && (E = e, a(), r(), d())
492c492
< i = JSON.parse(JSON.stringify(i)), window.parent.postMessage(i, "*")
---
> i = JSON.parse(JSON.stringify(i)), window.postMessage(i, "*")
- 官方版 DOMContentReady setTimeout 时间过长,改为 100ms
- 修复
invokeCanvasToDataUrl_
无法使用的 bug
612c612
< }, 1e3)
---
> }, 100)
2502c2502
< }), WeixinJSBridge.subscribe("invokeCanvasToDataUrl", function() {
---
> }), WeixinJSBridge.subscribe("invokeCanvasToDataUrl" + t._canvasNumber, function() {
- 使用 parent.postMessage 在 iframe 之间通讯(官方使用的是 contentScript 方式)
- XHR 请求使用后台 /remoteProxy 转发
- 添加 onCompassChange & onAccelerometerChange 支持
- 去除域名和 tls 验证
201c201
< t.to = "backgroundjs", t.comefrom = "webframe", t.command = "COMMAND_FROM_ASJS", t.appid = a, t.appname = u, t.apphash = s, t.webviewID = f, window.parent.postMessage(t, "*")
---
> t.to = "backgroundjs", t.comefrom = "webframe", t.command = "COMMAND_FROM_ASJS", t.appid = a, t.appname = u, t.apphash = s, t.webviewID = f, window.postMessage(t, "*")
211c211
< e.to = "contentscript", e.comefrom = "webframe", e.webviewID = f, window.parent.postMessage(e, "*")
---
> e.to = "contentscript", e.comefrom = "webframe", e.webviewID = f, window.postMessage(e, "*")
449,450d448
< onCompassChange: [],
< onAccelerometerChange: [],
674c672
< s.open(f, '/remoteProxy', !0), s.onreadystatechange = function() {
---
> s.open(f, t.url, !0), s.onreadystatechange = function() {
678d675
< s.setRequestHeader('X-Remote', t.url)
779c776,783
< return true
---
> if (a["default"].isTourist() || !__wxConfig.urlCheck) return !0;
> if (0 !== e.indexOf("https://")) return !0;
> e = r(e);
> var t = u[e];
> if (void 0 === t) return u[e] = {}, !0;
> var n = !1,
> o = t.protocol;
> return o && (o = o.replace("TLS ", ""), n = parseFloat(o) >= 1.2), n
796c800,818
< return console.warn('WEPT 请求时不检查安全域名')
---
> if (a["default"].isTourist()) return console.group(new Date + " 无 AppID 关联"), console.warn("工具未检查安全域名,更多请参考文档:https://mp.weixin.qq.com/debug/wxadoc/dev/api/network-request.html"), console.groupEnd(), !0;
> if (!__wxConfig.urlCheck) return console.group(new Date + " 配置中关闭 URL 校验"), console.warn("开发者主动关闭 URL 检查,工具未检查安全域名"), console.groupEnd(), !0;
> try {
> var n = function() {
> var n = [];
> n = "download" === t ? u.NetworkConfig.DownloadDomain : "upload" === t ? u.NetworkConfig.UploadDomain : "webscoket" === t ? u.NetworkConfig.WsRequestDomain : u.NetworkConfig.RequestDomain;
> for (var o = 0; o < n.length; o++)
> if (e && 0 === e.indexOf(n[o])) return {
> v: !0
> };
> var r = [];
> n.forEach(function(e) {
> r.push([e])
> }), console.group(new Date + " 合法域名校验出错"), console.error(" " + e + " 不在以下合法域名列表中,请参考文档:https://mp.weixin.qq.com/debug/wxadoc/dev/api/network-request.html"), console.table(r), console.groupEnd()
> }();
> if ("object" === ("undefined" == typeof n ? "undefined" : i(n))) return n.v
> } catch (o) {
> return console.error(o), !1
> }
- 使用原版文件,不进行修改。