Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
.Veneno.
wechaty
提交
c27b13c5
W
wechaty
项目概览
.Veneno.
/
wechaty
与 Fork 源项目一致
Fork自
wechaty / wechaty
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
W
wechaty
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
c27b13c5
编写于
10月 11, 2017
作者:
Huan (李卓桓)
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
track #870
上级
fd8b64e9
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
24 addition
and
14 deletion
+24
-14
src/puppet-web/bridge.ts
src/puppet-web/bridge.ts
+24
-14
未找到文件。
src/puppet-web/bridge.ts
浏览文件 @
c27b13c5
...
@@ -66,12 +66,15 @@ export class Bridge extends EventEmitter {
...
@@ -66,12 +66,15 @@ export class Bridge extends EventEmitter {
try
{
try
{
this
.
browser
=
await
this
.
initBrowser
()
this
.
browser
=
await
this
.
initBrowser
()
log
.
info
(
'
PuppetWebBridge
'
,
'
init() initBrowser() down
'
)
this
.
page
=
await
this
.
initPage
(
this
.
browser
)
this
.
page
=
await
this
.
initPage
(
this
.
browser
)
log
.
info
(
'
PuppetWebBridge
'
,
'
init() initPage() down
'
)
await
this
.
readyAngular
(
this
.
page
)
await
this
.
readyAngular
(
this
.
page
)
await
this
.
inject
(
this
.
page
)
await
this
.
inject
(
this
.
page
)
}
catch
(
e
)
{
}
catch
(
e
)
{
log
.
silly
(
'
PuppetWebBridge
'
,
'
init() exception: %s
'
,
e
&&
e
.
message
||
e
)
log
.
error
(
'
PuppetWebBridge
'
,
'
init() exception: %s
'
,
e
)
throw
e
throw
e
}
}
}
}
...
@@ -101,8 +104,11 @@ export class Bridge extends EventEmitter {
...
@@ -101,8 +104,11 @@ export class Bridge extends EventEmitter {
const
page
=
await
browser
.
newPage
()
const
page
=
await
browser
.
newPage
()
const
cookieList
=
this
.
options
.
profile
.
get
(
'
cookies
'
)
as
Cookie
[]
const
cookieList
=
this
.
options
.
profile
.
get
(
'
cookies
'
)
as
Cookie
[]
const
domain
=
this
.
cookieDomain
(
cookieList
)
const
url
=
this
.
entryUrl
(
cookieList
)
await
page
.
goto
(
domain
)
// Does this related to(?) the CI Error: exception: Navigation Timeout Exceeded: 30000ms exceeded
log
.
info
(
'
PuppetWebBridge
'
,
'
initPage() before page.goto(domain)
'
)
await
page
.
goto
(
url
)
// Does this related to(?) the CI Error: exception: Navigation Timeout Exceeded: 30000ms exceeded
log
.
info
(
'
PuppetWebBridge
'
,
'
initPage() after page.goto(domain)
'
)
// , {
// , {
// waitUntil: 'load', // https://github.com/GoogleChrome/puppeteer/issues/805
// waitUntil: 'load', // https://github.com/GoogleChrome/puppeteer/issues/805
...
@@ -664,48 +670,52 @@ export class Bridge extends EventEmitter {
...
@@ -664,48 +670,52 @@ export class Bridge extends EventEmitter {
/**
/**
* name
* name
*/
*/
public
cookieDomain
(
cookieList
?:
Cookie
[]):
string
{
public
entryUrl
(
cookieList
?:
Cookie
[]):
string
{
log
.
verbose
(
'
PuppetWebBridge
'
,
'
cookieDomain(%s)
'
,
cookieList
)
log
.
verbose
(
'
PuppetWebBridge
'
,
'
cookieDomain(%s)
'
,
cookieList
)
const
DEFAULT_
HOSTNAME
=
'
https://wx.qq.com
'
const
DEFAULT_
URL
=
'
https://wx.qq.com
'
if
(
!
cookieList
||
cookieList
.
length
===
0
)
{
if
(
!
cookieList
||
cookieList
.
length
===
0
)
{
log
.
silly
(
'
PuppetWebBridge
'
,
'
cookieDomain() no cookie, return default %s
'
,
DEFAULT_
HOSTNAME
)
log
.
silly
(
'
PuppetWebBridge
'
,
'
cookieDomain() no cookie, return default %s
'
,
DEFAULT_
URL
)
return
DEFAULT_
HOSTNAME
return
DEFAULT_
URL
}
}
const
wxCookieList
=
cookieList
.
filter
(
c
=>
/^webwx_auth_ticket|webwxuvid$/
.
test
(
c
.
name
))
const
wxCookieList
=
cookieList
.
filter
(
c
=>
/^webwx_auth_ticket|webwxuvid$/
.
test
(
c
.
name
))
if
(
!
wxCookieList
.
length
)
{
if
(
!
wxCookieList
.
length
)
{
log
.
silly
(
'
PuppetWebBridge
'
,
'
cookieDomain() no valid cookie, return default hostname
'
)
log
.
silly
(
'
PuppetWebBridge
'
,
'
cookieDomain() no valid cookie, return default hostname
'
)
return
DEFAULT_
HOSTNAME
return
DEFAULT_
URL
}
}
let
domain
=
wxCookieList
[
0
].
domain
let
domain
=
wxCookieList
[
0
].
domain
if
(
!
domain
)
{
if
(
!
domain
)
{
log
.
silly
(
'
PuppetWebBridge
'
,
'
cookieDomain() no valid domain in cookies, return default hostname
'
)
log
.
silly
(
'
PuppetWebBridge
'
,
'
cookieDomain() no valid domain in cookies, return default hostname
'
)
return
DEFAULT_
HOSTNAME
return
DEFAULT_
URL
}
}
domain
=
domain
.
slice
(
1
)
domain
=
domain
.
slice
(
1
)
if
(
domain
===
'
wechat.com
'
)
{
if
(
domain
===
'
wechat.com
'
)
{
domain
=
'
web.wechat.com
'
domain
=
'
web.wechat.com
'
}
}
if
(
!
/^http/
.
test
(
domain
))
{
let
url
if
(
/^http/
.
test
(
url
))
{
url
=
domain
}
else
{
// Protocol error (Page.navigate): Cannot navigate to invalid URL undefined
// Protocol error (Page.navigate): Cannot navigate to invalid URL undefined
domain
=
'
https://
'
+
domain
url
=
`https://
${
domain
}
`
}
}
log
.
silly
(
'
PuppetWebBridge
'
,
'
cookieDomain() got %s
'
,
domain
)
log
.
silly
(
'
PuppetWebBridge
'
,
'
cookieDomain() got %s
'
,
url
)
return
domain
return
url
}
}
public
async
reload
():
Promise
<
void
>
{
public
async
reload
():
Promise
<
void
>
{
log
.
verbose
(
'
PuppetWebBridge
'
,
'
reload()
'
)
await
this
.
page
.
reload
()
await
this
.
page
.
reload
()
return
return
}
}
public
async
evaluate
(...
args
:
any
[]):
Promise
<
string
>
{
public
async
evaluate
(...
args
:
any
[]):
Promise
<
string
>
{
log
.
silly
(
'
PuppetWebBridge
'
,
'
evaluate()
'
)
return
await
this
.
page
.
evaluate
.
apply
(
this
.
page
,
args
)
return
await
this
.
page
.
evaluate
.
apply
(
this
.
page
,
args
)
}
}
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录