Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
wechaty
wechaty
提交
691209a6
W
wechaty
项目概览
wechaty
/
wechaty
上一次同步 大约 3 年
通知
304
Star
10499
Fork
6
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
152
列表
看板
标记
里程碑
合并请求
1
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
W
wechaty
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
152
Issue
152
列表
看板
标记
里程碑
合并请求
1
合并请求
1
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
691209a6
编写于
10月 08, 2017
作者:
Huan (李卓桓)
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
use WECHATY_HEAD env var to control headless
上级
37c0fd72
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
18 addition
and
12 deletion
+18
-12
src/config.ts
src/config.ts
+5
-3
src/puppet-web/bridge.ts
src/puppet-web/bridge.ts
+3
-0
src/puppet-web/puppet-web.ts
src/puppet-web/puppet-web.ts
+9
-8
src/puppet-web/wechaty-bro.js
src/puppet-web/wechaty-bro.js
+1
-1
未找到文件。
src/config.ts
浏览文件 @
691209a6
...
...
@@ -87,6 +87,7 @@ export type PuppetName = 'web'
export
interface
ConfigSetting
{
DEFAULT_HEAD
:
number
DEFAULT_PUPPET
:
PuppetName
DEFAULT_APIHOST
:
string
DEFAULT_PROFILE
:
string
...
...
@@ -97,6 +98,7 @@ export interface ConfigSetting {
token
:
string
debug
:
boolean
head
:
boolean
puppet
:
PuppetName
apihost
:
string
...
...
@@ -123,9 +125,9 @@ export const config: ConfigSetting = require('../package.json').wechaty
* 1. ENVIRONMENT VARIABLES + PACKAGES.JSON (default)
*/
Object
.
assign
(
config
,
{
apihost
:
process
.
env
[
'
WECHATY_APIHOST
'
]
||
config
.
DEFAULT_APIHOST
,
// head: process.env['WECHATY_HEAD'] || config.DEFAULT_HEAD
,
puppet
:
process
.
env
[
'
WECHATY_PUPPET
'
]
||
config
.
DEFAULT_PUPPET
,
apihost
:
process
.
env
[
'
WECHATY_APIHOST
'
]
||
config
.
DEFAULT_APIHOST
,
head
:
(
'
WECHATY_HEAD
'
in
process
.
env
)
?
(
!!
process
.
env
[
'
WECHATY_HEAD
'
])
:
(
!!
(
config
.
DEFAULT_HEAD
))
,
puppet
:
process
.
env
[
'
WECHATY_PUPPET
'
]
||
config
.
DEFAULT_PUPPET
,
validApiHost
,
})
...
...
src/puppet-web/bridge.ts
浏览文件 @
691209a6
...
...
@@ -96,6 +96,8 @@ export class Bridge extends EventEmitter {
}
public
async
initPage
(
browser
:
Browser
):
Promise
<
Page
>
{
log
.
verbose
(
'
PuppetWebBridge
'
,
'
initPage()
'
)
const
page
=
await
browser
.
newPage
()
const
cookieList
=
this
.
options
.
profile
.
get
(
'
cookies
'
)
as
Cookie
[]
...
...
@@ -106,6 +108,7 @@ export class Bridge extends EventEmitter {
if
(
cookieList
&&
cookieList
.
length
)
{
await
page
.
setCookie
(...
cookieList
)
log
.
silly
(
'
PuppetWebBridge
'
,
'
initPage() page.setCookie() %s cookies set back
'
,
cookieList
.
length
)
}
await
page
.
exposeFunction
(
'
emit
'
,
this
.
emit
.
bind
(
this
))
...
...
src/puppet-web/puppet-web.ts
浏览文件 @
691209a6
...
...
@@ -17,6 +17,7 @@
*
*/
import
{
config
,
log
,
Raven
,
}
from
'
../config
'
...
...
@@ -91,13 +92,6 @@ export class PuppetWeb extends Puppet {
await
this
.
initWatchdogForPuppet
()
await
this
.
initWatchdogForScan
()
const
throttleQueue
=
new
RxQueue
(
'
throttle
'
,
5
*
60
*
1000
)
this
.
on
(
'
heartbeat
'
,
data
=>
throttleQueue
.
emit
(
'
i
'
,
data
))
throttleQueue
.
on
(
'
o
'
,
async
()
=>
{
log
.
verbose
(
'
Wechaty
'
,
'
init() throttleQueue.on(o)
'
)
await
this
.
saveCookie
()
})
this
.
bridge
=
await
this
.
initBridge
(
this
.
options
.
profile
)
log
.
verbose
(
'
PuppetWeb
'
,
'
initBridge() done
'
)
...
...
@@ -118,6 +112,13 @@ export class PuppetWeb extends Puppet {
}
this
.
emit
(
'
watchdog
'
,
food
)
const
throttleQueue
=
new
RxQueue
(
'
throttle
'
,
5
*
60
*
1000
)
this
.
on
(
'
heartbeat
'
,
data
=>
throttleQueue
.
emit
(
'
i
'
,
data
))
throttleQueue
.
on
(
'
o
'
,
async
()
=>
{
log
.
verbose
(
'
Wechaty
'
,
'
init() throttleQueue.on(o)
'
)
await
this
.
saveCookie
()
})
log
.
verbose
(
'
PuppetWeb
'
,
'
init() done
'
)
return
...
...
@@ -238,7 +239,7 @@ export class PuppetWeb extends Puppet {
throw
e
}
const
head
=
false
const
head
=
config
.
head
// we have to set this.bridge right now,
// because the Event.onXXX might arrive while we are initializing.
this
.
bridge
=
new
Bridge
({
...
...
src/puppet-web/wechaty-bro.js
浏览文件 @
691209a6
...
...
@@ -186,7 +186,7 @@
}
function
checkScan
()
{
log
(
'
checkScan()
'
)
//
log('checkScan()')
if
(
isLogin
())
{
log
(
'
checkScan() - already login, no more check, and return(only)
'
)
//but I will emit a login event')
// login('checkScan found already login')
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录