Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
.Veneno.
wechaty
提交
e2a90b9b
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,发现更多精彩内容 >>
提交
e2a90b9b
编写于
10月 27, 2017
作者:
Huan (李卓桓)
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
emit error when login denied by tencent from web
上级
6854d469
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
35 addition
and
29 deletion
+35
-29
src/puppet-web/bridge.ts
src/puppet-web/bridge.ts
+35
-9
src/puppet-web/puppet-web.ts
src/puppet-web/puppet-web.ts
+0
-20
未找到文件。
src/puppet-web/bridge.ts
浏览文件 @
e2a90b9b
...
@@ -128,12 +128,17 @@ export class Bridge extends EventEmitter {
...
@@ -128,12 +128,17 @@ export class Bridge extends EventEmitter {
this
.
emit
(
'
error
'
,
new
Error
(
`
${
dialog
.
type
}
(
${
dialog
.
message
()}
)`
))
this
.
emit
(
'
error
'
,
new
Error
(
`
${
dialog
.
type
}
(
${
dialog
.
message
()}
)`
))
}
}
const
onLoad
=
async
(
done
:
()
=>
void
)
=>
{
const
onLoad
=
async
(
resolve
:
()
=>
void
,
reject
:
(
e
:
Error
)
=>
void
,
)
=>
{
log
.
verbose
(
'
PuppetWebBridge
'
,
'
initPage() on(load) %s
'
,
page
.
url
())
log
.
verbose
(
'
PuppetWebBridge
'
,
'
initPage() on(load) %s
'
,
page
.
url
())
const
stateOffError
=
new
Error
(
'
onLoad() OFF state detected
'
)
if
(
this
.
state
.
off
())
{
if
(
this
.
state
.
off
())
{
log
.
verbose
(
'
PuppetWebBridge
'
,
'
initPage() onLoad() OFF state detected. NOP
'
)
log
.
verbose
(
'
PuppetWebBridge
'
,
'
initPage() onLoad() OFF state detected. NOP
'
)
return
return
reject
(
stateOffError
)
}
}
try
{
try
{
...
@@ -141,7 +146,7 @@ export class Bridge extends EventEmitter {
...
@@ -141,7 +146,7 @@ export class Bridge extends EventEmitter {
}
catch
(
e
)
{
}
catch
(
e
)
{
if
(
this
.
state
.
off
())
{
if
(
this
.
state
.
off
())
{
log
.
verbose
(
'
PuppetWebBridge
'
,
'
initPage() onLoad() OFF state detected. NOP
'
)
log
.
verbose
(
'
PuppetWebBridge
'
,
'
initPage() onLoad() OFF state detected. NOP
'
)
return
return
reject
(
stateOffError
)
}
}
// exposed function will stay in the browser after reload the page
// exposed function will stay in the browser after reload the page
...
@@ -151,6 +156,23 @@ export class Bridge extends EventEmitter {
...
@@ -151,6 +156,23 @@ export class Bridge extends EventEmitter {
try
{
try
{
await
this
.
readyAngular
(
page
)
await
this
.
readyAngular
(
page
)
}
catch
(
e
)
{
const
text
=
await
this
.
evaluate
(()
=>
{
return
document
.
body
.
innerHTML
})
as
any
as
string
// BUG of Puppet Type Definition
try
{
// Test if Wechat account is blocked
// will throw exception if blocked
await
this
.
testBlockedMessage
(
text
)
}
catch
(
e
)
{
// Wechat Account Blocked
log
.
error
(
'
PuppetWeb
'
,
'
initBridge() Wechat Account Blocked for using Web: %s
'
,
e
.
message
)
this
.
emit
(
'
error
'
,
e
)
return
reject
(
e
)
}
}
try
{
await
this
.
inject
(
page
)
await
this
.
inject
(
page
)
const
clicked
=
await
this
.
clickSwitchAccount
(
page
)
const
clicked
=
await
this
.
clickSwitchAccount
(
page
)
...
@@ -163,20 +185,22 @@ export class Bridge extends EventEmitter {
...
@@ -163,20 +185,22 @@ export class Bridge extends EventEmitter {
}
catch
(
e
)
{
}
catch
(
e
)
{
if
(
this
.
state
.
off
())
{
if
(
this
.
state
.
off
())
{
log
.
verbose
(
'
PuppetWebBridge
'
,
'
initPage() onLoad() OFF state detected. NOP
'
)
log
.
verbose
(
'
PuppetWebBridge
'
,
'
initPage() onLoad() OFF state detected. NOP
'
)
return
return
reject
(
stateOffError
)
}
}
log
.
error
(
'
PuppetWebBridge
'
,
'
init() initPage() onLoad() exception: %s
'
,
e
)
log
.
error
(
'
PuppetWebBridge
'
,
'
init() initPage() onLoad() exception: %s
'
,
e
)
this
.
emit
(
'
error
'
,
e
)
this
.
emit
(
'
error
'
,
e
)
}
finally
{
return
reject
(
e
)
done
()
}
}
return
resolve
()
}
}
page
.
on
(
'
dialog
'
,
onDialog
)
page
.
on
(
'
dialog
'
,
onDialog
)
page
.
on
(
'
error
'
,
e
=>
this
.
emit
(
'
error
'
,
e
))
page
.
on
(
'
error
'
,
e
=>
this
.
emit
(
'
error
'
,
e
))
const
loaded
=
new
Promise
(
resolve
=>
page
.
on
(
'
load
'
,
()
=>
onLoad
(
resolve
)))
const
loaded
=
new
Promise
(
(
resolve
,
reject
)
=>
page
.
on
(
'
load
'
,
()
=>
onLoad
(
resolve
,
reject
)))
///////////////////
///////////////////
...
@@ -200,9 +224,11 @@ export class Bridge extends EventEmitter {
...
@@ -200,9 +224,11 @@ export class Bridge extends EventEmitter {
public
async
readyAngular
(
page
:
Page
):
Promise
<
void
>
{
public
async
readyAngular
(
page
:
Page
):
Promise
<
void
>
{
log
.
verbose
(
'
PuppetWebBridge
'
,
'
readyAngular()
'
)
log
.
verbose
(
'
PuppetWebBridge
'
,
'
readyAngular()
'
)
const
TIMEOUT
=
3
0
*
1000
const
TIMEOUT
=
1
0
*
1000
await
new
Promise
<
void
>
(
async
(
resolve
,
reject
)
=>
{
await
new
Promise
<
void
>
(
async
(
resolve
,
reject
)
=>
{
const
timer
=
setTimeout
(
reject
,
TIMEOUT
)
const
timer
=
setTimeout
(()
=>
{
reject
(
`readyAngular() timeout after
${
TIMEOUT
}
`
)
},
TIMEOUT
)
await
page
.
waitForFunction
(
`typeof window.angular !== 'undefined'`
)
await
page
.
waitForFunction
(
`typeof window.angular !== 'undefined'`
)
clearTimeout
(
timer
)
clearTimeout
(
timer
)
...
...
src/puppet-web/puppet-web.ts
浏览文件 @
e2a90b9b
...
@@ -276,26 +276,6 @@ export class PuppetWeb extends Puppet {
...
@@ -276,26 +276,6 @@ export class PuppetWeb extends Puppet {
log
.
error
(
'
PuppetWeb
'
,
'
initBridge() exception: %s
'
,
e
.
message
)
log
.
error
(
'
PuppetWeb
'
,
'
initBridge() exception: %s
'
,
e
.
message
)
this
.
emit
(
'
error
'
,
e
)
this
.
emit
(
'
error
'
,
e
)
// TypeError: Cannot read property 'evaluate' of undefined
if
(
!
this
.
bridge
)
{
throw
e
}
const
text
=
await
this
.
bridge
.
evaluate
(()
=>
{
return
document
.
body
.
innerHTML
})
as
any
as
string
try
{
// Test if Wechat account is blocked
// will throw exception if blocked
await
this
.
bridge
.
testBlockedMessage
(
text
)
}
catch
(
blockedError
)
{
// Wechat Account Blocked
log
.
error
(
'
PuppetWeb
'
,
'
initBridge() Wechat Account Blocked for using Web: %s
'
,
blockedError
.
message
)
this
.
emit
(
'
error
'
,
blockedError
)
throw
blockedError
}
Raven
.
captureException
(
e
)
Raven
.
captureException
(
e
)
throw
e
throw
e
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录