Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
hello_uni-id-pages
提交
64d83cac
H
hello_uni-id-pages
项目概览
DCloud
/
hello_uni-id-pages
通知
1078
Star
34
Fork
43
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
4
列表
看板
标记
里程碑
合并请求
2
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
H
hello_uni-id-pages
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
4
Issue
4
列表
看板
标记
里程碑
合并请求
2
合并请求
2
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
64d83cac
编写于
8月 23, 2022
作者:
雪洛
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
deps: update uni-open-bridge-common
上级
565c9cc0
变更
21
隐藏空白更改
内联
并排
Showing
21 changed file
with
15 addition
and
705 deletion
+15
-705
uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/package.json
...i-id-pages/uniCloud/cloudfunctions/uni-id-co/package.json
+2
-1
uni_modules/uni-open-bridge-common/changelog.md
uni_modules/uni-open-bridge-common/changelog.md
+2
-0
uni_modules/uni-open-bridge-common/package.json
uni_modules/uni-open-bridge-common/package.json
+6
-10
uni_modules/uni-open-bridge-common/readme.md
uni_modules/uni-open-bridge-common/readme.md
+5
-0
uni_modules/uni-open-bridge-common/uniCloud/cloudfunctions/common/uni-open-bridge-common/bridge-error.js
...udfunctions/common/uni-open-bridge-common/bridge-error.js
+0
-0
uni_modules/uni-open-bridge-common/uniCloud/cloudfunctions/common/uni-open-bridge-common/config.js
...ud/cloudfunctions/common/uni-open-bridge-common/config.js
+0
-0
uni_modules/uni-open-bridge-common/uniCloud/cloudfunctions/common/uni-open-bridge-common/consts.js
...ud/cloudfunctions/common/uni-open-bridge-common/consts.js
+0
-0
uni_modules/uni-open-bridge-common/uniCloud/cloudfunctions/common/uni-open-bridge-common/index.js
...oud/cloudfunctions/common/uni-open-bridge-common/index.js
+0
-0
uni_modules/uni-open-bridge-common/uniCloud/cloudfunctions/common/uni-open-bridge-common/package.json
...cloudfunctions/common/uni-open-bridge-common/package.json
+0
-0
uni_modules/uni-open-bridge-common/uniCloud/cloudfunctions/common/uni-open-bridge-common/storage.js
...d/cloudfunctions/common/uni-open-bridge-common/storage.js
+0
-0
uni_modules/uni-open-bridge-common/uniCloud/cloudfunctions/common/uni-open-bridge-common/uni-cloud-cache.js
...unctions/common/uni-open-bridge-common/uni-cloud-cache.js
+0
-0
uni_modules/uni-open-bridge-common/uniCloud/cloudfunctions/common/uni-open-bridge-common/validator.js
...cloudfunctions/common/uni-open-bridge-common/validator.js
+0
-0
uni_modules/uni-open-bridge-common/uniCloud/cloudfunctions/common/uni-open-bridge-common/weixin-server.js
...dfunctions/common/uni-open-bridge-common/weixin-server.js
+0
-0
uni_modules/uni-open-bridge/readme.md
uni_modules/uni-open-bridge/readme.md
+0
-5
uni_modules/uni-open-bridge/uniCloud/cloudfunctions/uni-open-bridge/basic.js
...n-bridge/uniCloud/cloudfunctions/uni-open-bridge/basic.js
+0
-131
uni_modules/uni-open-bridge/uniCloud/cloudfunctions/uni-open-bridge/bridge.js
...-bridge/uniCloud/cloudfunctions/uni-open-bridge/bridge.js
+0
-126
uni_modules/uni-open-bridge/uniCloud/cloudfunctions/uni-open-bridge/config.js
...-bridge/uniCloud/cloudfunctions/uni-open-bridge/config.js
+0
-153
uni_modules/uni-open-bridge/uniCloud/cloudfunctions/uni-open-bridge/index.obj.js
...idge/uniCloud/cloudfunctions/uni-open-bridge/index.obj.js
+0
-94
uni_modules/uni-open-bridge/uniCloud/cloudfunctions/uni-open-bridge/index.task.js
...dge/uniCloud/cloudfunctions/uni-open-bridge/index.task.js
+0
-83
uni_modules/uni-open-bridge/uniCloud/cloudfunctions/uni-open-bridge/package.json
...idge/uniCloud/cloudfunctions/uni-open-bridge/package.json
+0
-22
uni_modules/uni-open-bridge/uniCloud/cloudfunctions/uni-open-bridge/task-weixin.js
...ge/uniCloud/cloudfunctions/uni-open-bridge/task-weixin.js
+0
-80
未找到文件。
uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/package.json
浏览文件 @
64d83cac
...
...
@@ -10,7 +10,8 @@
"lodash.merge"
:
"^4.6.2"
,
"uni-captcha"
:
"file:../../../../uni-captcha/uniCloud/cloudfunctions/common/uni-captcha"
,
"uni-config-center"
:
"file:../../../../uni-config-center/uniCloud/cloudfunctions/common/uni-config-center"
,
"uni-id-common"
:
"file:../../../../uni-id-common/uniCloud/cloudfunctions/common/uni-id-common"
"uni-id-common"
:
"file:../../../../uni-id-common/uniCloud/cloudfunctions/common/uni-id-common"
,
"uni-open-bridge-common"
:
"file:../../../../uni-open-bridge-common/uniCloud/cloudfunctions/common/uni-open-bridge-common"
},
"extensions"
:
{}
}
\ No newline at end of file
uni_modules/uni-open-bridge/changelog.md
→
uni_modules/uni-open-bridge
-common
/changelog.md
浏览文件 @
64d83cac
## 1.0.0(2022-08-
1
2)
## 1.0.0(2022-08-
2
2)
-
首次发布
uni_modules/uni-open-bridge/package.json
→
uni_modules/uni-open-bridge
-common
/package.json
浏览文件 @
64d83cac
{
"id"
:
"uni-open-bridge"
,
"displayName"
:
"uni-open-bridge"
,
"id"
:
"uni-open-bridge
-common
"
,
"displayName"
:
"uni-open-bridge
-common
"
,
"version"
:
"1.0.0"
,
"description"
:
"
uni-open-bridge 是统一接管微信等三方平台认证的开源库
"
,
"description"
:
"
统一接管微信等三方平台认证凭据
"
,
"keywords"
:
[
"uni-open-bridge-common"
,
"access_token"
,
"session_key"
,
"ticket"
,
"微信"
"ticket"
],
"repository"
:
""
,
"engines"
:
{
"HBuilderX"
:
"^3.5.
1
"
"HBuilderX"
:
"^3.5.
2
"
},
"dcloudext"
:
{
"category"
:
[
"uniCloud"
,
"云函数模板"
],
"type"
:
"unicloud-template-function"
,
"sale"
:
{
"regular"
:
{
"price"
:
"0.00"
...
...
uni_modules/uni-open-bridge-common/readme.md
0 → 100644
浏览文件 @
64d83cac
# uni-open-bridge-common
`uni-open-bridge-common`
是统一接管微信等三方平台认证凭据(包括但不限于
`access_token`
、
`session_key`
、
`encrypt_key`
、
`ticket`
)的开源库。
文档链接
[
https://uniapp.dcloud.net.cn/uniCloud/uni-open-bridge#common
](
https://uniapp.dcloud.net.cn/uniCloud/uni-open-bridge#common
)
uni_modules/uni-open-bridge/uniCloud/cloudfunctions/common/uni-open-bridge-common/bridge-error.js
→
uni_modules/uni-open-bridge
-common
/uniCloud/cloudfunctions/common/uni-open-bridge-common/bridge-error.js
浏览文件 @
64d83cac
文件已移动
uni_modules/uni-open-bridge/uniCloud/cloudfunctions/common/uni-open-bridge-common/config.js
→
uni_modules/uni-open-bridge
-common
/uniCloud/cloudfunctions/common/uni-open-bridge-common/config.js
浏览文件 @
64d83cac
文件已移动
uni_modules/uni-open-bridge/uniCloud/cloudfunctions/common/uni-open-bridge-common/consts.js
→
uni_modules/uni-open-bridge
-common
/uniCloud/cloudfunctions/common/uni-open-bridge-common/consts.js
浏览文件 @
64d83cac
文件已移动
uni_modules/uni-open-bridge/uniCloud/cloudfunctions/common/uni-open-bridge-common/index.js
→
uni_modules/uni-open-bridge
-common
/uniCloud/cloudfunctions/common/uni-open-bridge-common/index.js
浏览文件 @
64d83cac
文件已移动
uni_modules/uni-open-bridge/uniCloud/cloudfunctions/common/uni-open-bridge-common/package.json
→
uni_modules/uni-open-bridge
-common
/uniCloud/cloudfunctions/common/uni-open-bridge-common/package.json
浏览文件 @
64d83cac
文件已移动
uni_modules/uni-open-bridge/uniCloud/cloudfunctions/common/uni-open-bridge-common/storage.js
→
uni_modules/uni-open-bridge
-common
/uniCloud/cloudfunctions/common/uni-open-bridge-common/storage.js
浏览文件 @
64d83cac
文件已移动
uni_modules/uni-open-bridge/uniCloud/cloudfunctions/common/uni-open-bridge-common/uni-cloud-cache.js
→
uni_modules/uni-open-bridge
-common
/uniCloud/cloudfunctions/common/uni-open-bridge-common/uni-cloud-cache.js
浏览文件 @
64d83cac
文件已移动
uni_modules/uni-open-bridge/uniCloud/cloudfunctions/common/uni-open-bridge-common/validator.js
→
uni_modules/uni-open-bridge
-common
/uniCloud/cloudfunctions/common/uni-open-bridge-common/validator.js
浏览文件 @
64d83cac
文件已移动
uni_modules/uni-open-bridge/uniCloud/cloudfunctions/common/uni-open-bridge-common/weixin-server.js
→
uni_modules/uni-open-bridge
-common
/uniCloud/cloudfunctions/common/uni-open-bridge-common/weixin-server.js
浏览文件 @
64d83cac
文件已移动
uni_modules/uni-open-bridge/readme.md
已删除
100644 → 0
浏览文件 @
565c9cc0
# uni-open-bridge
`uni-open-bridge`
是统一接管微信等三方平台认证凭据(包括但不限于
`access_token`
、
`session_key`
、
`encrypt_key`
、
`ticket`
)的开源库。
文档链接
[
https://uniapp.dcloud.net.cn/uniCloud/uni-open-bridge
](
https://uniapp.dcloud.net.cn/uniCloud/uni-open-bridge
)
uni_modules/uni-open-bridge/uniCloud/cloudfunctions/uni-open-bridge/basic.js
已删除
100644 → 0
浏览文件 @
565c9cc0
'
use strict
'
;
class
Command
{
constructor
()
{
this
.
_registered
=
{}
}
async
execute
(
name
,
args
)
{
if
(
this
.
_registered
[
name
])
{
return
await
this
.
_registered
[
name
].
execute
(
args
)
}
}
canExecute
(
name
,
args
)
{
if
(
this
.
_registered
[
name
]
&&
this
.
_registered
[
name
].
canExecute
)
{
this
.
_registered
[
name
].
canExecute
(
args
)
}
return
false
}
register
(
name
,
execute
,
canExecute
)
{
this
.
_registered
[
name
]
=
{
execute
,
canExecute
}
}
}
class
Task
{
constructor
(
id
)
{
this
.
_id
=
id
||
this
.
_newTaskId
()
this
.
_state
=
Task
.
TASK_STATE
.
WAITING
}
async
run
()
{}
async
cancel
()
{}
async
taskAction
()
{}
_newTaskId
()
{
let
guid
=
''
const
format
=
'
xxxxxxxx-xxxx-4xxx-xxxx-xxxxxxxxxxxx
'
for
(
let
i
=
0
;
i
<
format
.
length
;
i
++
)
{
if
(
format
[
i
]
===
'
x
'
)
{
guid
+=
(
Math
.
random
()
*
16
|
0
).
toString
(
16
)
}
else
{
guid
+=
format
[
i
]
}
}
return
guid
.
toUpperCase
()
}
get
id
()
{
return
this
.
_id
}
set
id
(
value
)
{
this
.
_id
=
value
}
get
state
()
{
return
this
.
_state
}
set
state
(
value
)
{
this
.
_state
=
value
}
}
Task
.
TASK_STATE
=
{
WAITING
:
"
WAITING
"
,
RESOLVING
:
"
RESOLVING
"
,
RESOLVED
:
"
RESOLVED
"
,
EXECUTING
:
"
EXECUTING
"
,
ERROR
:
"
ERROR
"
,
COMPLETED
:
"
COMPLETED
"
,
CANCELLING
:
"
CANCELLING
"
,
CANCELLED
:
"
CANCELLED
"
}
class
TaskManager
{
constructor
()
{
this
.
_tasks
=
[]
}
get
tasks
()
{
return
this
.
_tasks
}
clear
()
{
this
.
_tasks
.
length
=
0
}
getTask
(
id
)
{
return
this
.
_tasks
.
find
((
item
)
=>
{
return
(
item
.
id
==
id
)
})
}
addTask
(
task
)
{
this
.
_tasks
.
push
(
task
)
}
deleteTask
(
id
)
{
const
index
=
this
.
findIndex
(
id
)
if
(
index
<
0
)
{
return
}
this
.
_tasks
[
index
].
cancel
()
if
(
index
>
-
1
)
{
this
.
_tasks
.
splice
(
index
,
1
)
}
}
findIndex
(
id
)
{
return
this
.
_tasks
.
findIndex
((
item
)
=>
{
return
(
item
.
id
==
id
)
})
}
}
module
.
exports
=
{
Command
,
Task
,
TaskManager
};
uni_modules/uni-open-bridge/uniCloud/cloudfunctions/uni-open-bridge/bridge.js
已删除
100644 → 0
浏览文件 @
565c9cc0
'
use strict
'
;
const
{
getAccessToken
,
setAccessToken
,
removeAccessToken
,
getUserAccessToken
,
setUserAccessToken
,
removeUserAccessToken
,
getSessionKey
,
setSessionKey
,
removeSessionKey
,
getEncryptKey
,
setEncryptKey
,
removeEncryptKey
,
getTicket
,
setTicket
,
removeTicket
}
=
require
(
'
uni-open-bridge-common
'
)
const
{
Command
}
=
require
(
'
./basic.js
'
);
const
{
OpenBridgeConfig
}
=
require
(
'
./config.js
'
)
const
openBridgeConfig
=
new
OpenBridgeConfig
()
const
Commands
=
[
'
getAccessToken
'
,
'
setAccessToken
'
,
'
removeAccessToken
'
,
'
getUserAccessToken
'
,
'
setUserAccessToken
'
,
'
removeUserAccessToken
'
,
'
getSessionKey
'
,
'
setSessionKey
'
,
'
removeSessionKey
'
,
'
getEncryptKey
'
,
'
setEncryptKey
'
,
'
removeEncryptKey
'
,
'
getTicket
'
,
'
setTicket
'
,
'
removeTicket
'
]
class
MainFrame
extends
Command
{
constructor
()
{
super
()
Commands
.
forEach
((
name
)
=>
{
this
.
register
(
name
,
this
[
name
].
bind
(
this
))
})
}
async
getAccessToken
(
parameters
)
{
return
await
getAccessToken
(
parameters
)
}
async
setAccessToken
(
parameters
)
{
return
await
setAccessToken
(
parameters
,
parameters
.
value
,
parameters
.
expiresIn
)
}
async
removeAccessToken
(
parameters
)
{
return
await
removeAccessToken
(
parameters
)
}
async
getUserAccessToken
(
parameters
)
{
return
await
getUserAccessToken
(
parameters
)
}
async
setUserAccessToken
(
parameters
)
{
return
await
setUserAccessToken
(
parameters
,
parameters
.
value
,
parameters
.
expiresIn
)
}
async
removeUserAccessToken
(
parameters
)
{
return
await
removeUserAccessToken
(
parameters
)
}
async
getSessionKey
(
parameters
)
{
return
await
getSessionKey
(
parameters
,
parameters
.
fallback
||
null
)
}
async
setSessionKey
(
parameters
)
{
return
await
setSessionKey
(
parameters
,
parameters
.
value
,
parameters
.
expiresIn
)
}
async
removeSessionKey
(
parameters
)
{
return
await
removeSessionKey
(
parameters
)
}
async
getEncryptKey
(
parameters
)
{
return
await
getEncryptKey
(
parameters
,
null
)
}
async
setEncryptKey
(
parameters
)
{
return
await
setEncryptKey
(
parameters
,
parameters
.
value
,
parameters
.
expiresIn
)
}
async
removeEncryptKey
(
parameters
)
{
return
await
removeEncryptKey
(
parameters
)
}
async
getTicket
(
parameters
)
{
return
await
getTicket
(
parameters
,
null
)
}
async
setTicket
(
parameters
)
{
return
await
setTicket
(
parameters
,
parameters
.
value
,
parameters
.
expiresIn
)
}
async
removeTicket
(
parameters
)
{
return
await
removeTicket
(
parameters
)
}
checkIP
(
ip
)
{
return
openBridgeConfig
.
inWhiteList
(
ip
)
}
}
const
mainFrame
=
new
MainFrame
();
module
.
exports
=
mainFrame
;
uni_modules/uni-open-bridge/uniCloud/cloudfunctions/uni-open-bridge/config.js
已删除
100644 → 0
浏览文件 @
565c9cc0
'
use strict
'
;
const
configCenter
=
require
(
'
uni-config-center
'
)
class
TaskConfig
{
constructor
(
options
)
{
this
.
_dcloudAppid
=
options
.
dcloudAppid
this
.
_appid
=
options
.
appid
this
.
_secret
=
options
.
secret
this
.
_platform
=
options
.
platform
this
.
_tasks
=
options
.
tasks
this
.
_timeout
=
1000
*
10
}
get
dcloudAppid
()
{
return
this
.
_dcloudAppid
}
get
appid
()
{
return
this
.
_appid
}
get
secret
()
{
return
this
.
_secret
}
get
platform
()
{
return
this
.
_platform
}
get
tasks
()
{
return
this
.
_tasks
}
}
class
ConfigBase
{
constructor
()
{
const
uniIdConfig
=
configCenter
({
pluginId
:
'
uni-id
'
})
const
openBridgeConfig
=
configCenter
({
pluginId
:
'
uni-open-bridge
'
})
this
.
_uniId
=
uniIdConfig
.
config
()
this
.
_openBridge
=
openBridgeConfig
.
config
()
this
.
_ready
=
true
}
getAppConfig
(
appid
)
{
if
(
Array
.
isArray
(
this
.
_uniId
))
{
return
this
.
_uniId
.
find
((
item
)
=>
{
return
(
item
.
dcloudAppid
===
appid
)
})
}
if
(
this
.
_uniId
.
dcloudAppid
===
appid
)
{
return
this
.
_uniId
}
return
null
}
inWhiteList
(
ip
)
{
return
(
this
.
ipWhiteList
.
indexOf
(
ip
)
>
-
1
)
}
get
openBridge
()
{
return
this
.
_openBridge
}
get
ipWhiteList
()
{
return
this
.
_openBridge
.
ipWhiteList
}
get
ready
()
{
return
this
.
_ready
}
}
class
OpenBridgeConfig
extends
ConfigBase
{
constructor
()
{
super
()
this
.
_tasks
=
[]
this
.
resolve
()
}
get
tasks
()
{
return
this
.
_tasks
}
resolve
()
{
this
.
_tasks
.
length
=
0
const
appids
=
Object
.
keys
(
this
.
openBridge
.
schedule
)
for
(
let
i
=
0
;
i
<
appids
.
length
;
i
++
)
{
const
appid
=
appids
[
i
]
let
appConfig
=
this
.
getAppConfig
(
appid
)
if
(
appConfig
!=
null
)
{
const
schedule
=
this
.
openBridge
.
schedule
[
appid
]
if
(
schedule
)
{
this
.
resolveSchedule
(
appid
,
appConfig
,
schedule
)
}
}
}
}
resolveSchedule
(
dcloudAppid
,
appConfig
,
schedule
)
{
if
(
schedule
.
enable
!==
true
)
{
return
}
const
schedulePlatforms
=
Object
.
keys
(
schedule
)
for
(
let
i
=
0
;
i
<
schedulePlatforms
.
length
;
i
++
)
{
const
platformName
=
schedulePlatforms
[
i
]
const
scheduleTask
=
schedule
[
platformName
]
if
(
!
scheduleTask
.
enable
)
{
continue
}
if
(
!
this
.
isSupport
(
platformName
))
{
continue
}
this
.
_tasks
.
push
({
dcloudAppid
:
dcloudAppid
,
platform
:
platformName
,
tasks
:
scheduleTask
.
tasks
})
}
}
isSupport
(
platformName
)
{
return
(
OpenBridgeConfig
.
Support_Platforms
.
indexOf
(
platformName
)
>=
0
)
}
}
OpenBridgeConfig
.
Support_Platforms
=
[
'
weixin-mp
'
,
'
weixin-h5
'
]
module
.
exports
=
{
OpenBridgeConfig
};
uni_modules/uni-open-bridge/uniCloud/cloudfunctions/uni-open-bridge/index.obj.js
已删除
100644 → 0
浏览文件 @
565c9cc0
'
use strict
'
;
const
runTask
=
require
(
'
./index.task.js
'
)
const
command
=
require
(
'
./bridge.js
'
)
async
function
executeCommand
()
{
const
methodName
=
this
.
getMethodName
()
const
clientInfo
=
this
.
getClientInfo
()
let
parameters
if
(
clientInfo
.
source
===
'
http
'
)
{
const
postData
=
this
.
getHttpInfo
().
body
if
(
!
postData
||
postData
.
length
<
4
)
{
throw
new
Error
(
'
Invalid parameter(s)::
'
+
postData
)
}
parameters
=
JSON
.
parse
(
postData
)
}
else
if
(
clientInfo
.
source
===
'
function
'
)
{
const
args
=
this
.
getParams
()
parameters
=
args
[
0
]
if
(
args
.
length
===
2
)
{
parameters
.
value
=
args
[
1
]
}
if
(
args
.
length
===
3
)
{
parameters
.
expiresIn
=
args
[
2
]
}
}
else
{
throw
new
Error
(
'
Invalid
'
)
}
return
await
command
.
execute
(
methodName
,
parameters
)
}
module
.
exports
=
{
async
_timing
()
{
console
.
log
(
'
triggered by timing
'
)
await
runTask
()
},
async
_before
()
{
const
clientInfo
=
this
.
getClientInfo
()
if
(
clientInfo
.
source
===
'
http
'
&&
!
command
.
checkIP
(
clientInfo
.
clientIP
))
{
throw
new
Error
(
'
Invalid IP::
'
+
clientInfo
.
clientIP
)
}
},
/// AccessToken
async
getAccessToken
()
{
return
await
executeCommand
.
call
(
this
)
},
async
setAccessToken
()
{
return
await
executeCommand
.
call
(
this
)
},
async
removeAccessToken
()
{
return
await
executeCommand
.
call
(
this
)
},
/// UserAccessToken
async
getUserAccessToken
()
{
return
await
executeCommand
.
call
(
this
)
},
async
setUserAccessToken
()
{
return
await
executeCommand
.
call
(
this
)
},
async
removeUserAccessToken
()
{
return
await
executeCommand
.
call
(
this
)
},
/// SessionKey
async
getSessionKey
()
{
return
await
executeCommand
.
call
(
this
)
},
async
setSessionKey
()
{
return
await
executeCommand
.
call
(
this
)
},
async
removeSessionKey
()
{
return
await
executeCommand
.
call
(
this
)
},
/// EncryptKey
async
getEncryptKey
()
{
return
await
executeCommand
.
call
(
this
)
},
async
setEncryptKey
()
{
return
await
executeCommand
.
call
(
this
)
},
async
removeEncryptKey
()
{
return
await
executeCommand
.
call
(
this
)
},
/// Ticket
async
getTicket
()
{
return
await
executeCommand
.
call
(
this
)
},
async
setTicket
()
{
return
await
executeCommand
.
call
(
this
)
},
async
removeTicket
()
{
return
await
executeCommand
.
call
(
this
)
}
}
uni_modules/uni-open-bridge/uniCloud/cloudfunctions/uni-open-bridge/index.task.js
已删除
100644 → 0
浏览文件 @
565c9cc0
'
use strict
'
;
const
{
OpenBridgeConfig
}
=
require
(
'
./config.js
'
)
const
{
TaskManager
}
=
require
(
'
./basic.js
'
)
const
{
TaskAccessTokenMP
,
TaskAccessTokenH5
,
TaskTicket
}
=
require
(
'
./task-weixin.js
'
)
const
TaskMapping
=
{
'
weixin-mp
'
:
{
'
accessToken
'
:
TaskAccessTokenMP
},
'
weixin-h5
'
:
{
'
accessToken
'
:
TaskAccessTokenH5
,
'
ticket
'
:
TaskTicket
}
}
class
ScheduleManager
extends
TaskManager
{
constructor
()
{
super
()
}
async
runAll
()
{
for
(
let
i
=
0
;
i
<
this
.
tasks
.
length
;
i
++
)
{
const
task
=
this
.
tasks
[
i
]
try
{
await
task
.
run
()
}
catch
(
e
)
{
console
.
log
(
"
task.run::
"
,
e
)
}
}
}
newTask
(
T
,
config
)
{
const
newTask
=
new
T
(
config
)
super
.
addTask
(
newTask
)
return
newTask
}
}
ScheduleManager
.
instance
=
function
()
{
if
(
!
ScheduleManager
.
_instance
)
{
ScheduleManager
.
_instance
=
new
ScheduleManager
()
}
return
ScheduleManager
.
_instance
}
async
function
main
()
{
const
openBridgeConfig
=
new
OpenBridgeConfig
()
ScheduleManager
.
instance
().
clear
()
for
(
let
taskConfig
of
openBridgeConfig
.
tasks
)
{
let
{
platform
,
tasks
}
=
taskConfig
for
(
let
taskName
of
tasks
)
{
const
platformTask
=
TaskMapping
[
platform
]
if
(
platformTask
)
{
ScheduleManager
.
instance
().
newTask
(
platformTask
[
taskName
],
taskConfig
)
}
}
}
await
ScheduleManager
.
instance
().
runAll
()
}
module
.
exports
=
main
;
uni_modules/uni-open-bridge/uniCloud/cloudfunctions/uni-open-bridge/package.json
已删除
100644 → 0
浏览文件 @
565c9cc0
{
"name"
:
"uni-open-bridge"
,
"dependencies"
:
{
"uni-open-bridge-common"
:
"file:../common/uni-open-bridge-common"
,
"uni-config-center"
:
"file:../../../../uni-config-center/uniCloud/cloudfunctions/common/uni-config-center"
},
"cloudfunction-config"
:
{
"memorySize"
:
256
,
"timeout"
:
60
,
"triggers"
:
[{
"name"
:
"uni-open-bridge"
,
"type"
:
"timer"
,
"config"
:
"0 0 * * * * *"
}],
"path"
:
""
,
"runtime"
:
"Nodejs8"
},
"extensions"
:
{
"uni-cloud-jql"
:
{},
"uni-cloud-redis"
:
{}
}
}
uni_modules/uni-open-bridge/uniCloud/cloudfunctions/uni-open-bridge/task-weixin.js
已删除
100644 → 0
浏览文件 @
565c9cc0
'
use strict
'
;
const
{
getAccessToken
,
getTicket
,
PlatformType
}
=
require
(
'
uni-open-bridge-common
'
)
const
{
Task
}
=
require
(
'
./basic.js
'
)
class
TaskAccessTokenMP
extends
Task
{
constructor
(
config
)
{
super
()
this
.
_config
=
config
||
null
}
async
run
()
{
const
key
=
{
dcloudAppid
:
this
.
_config
.
dcloudAppid
,
platform
:
PlatformType
.
WEIXIN_MP
}
const
result
=
await
getAccessToken
(
key
)
console
.
log
(
"
setAccessToken...
"
,
key
,
result
)
}
}
TaskAccessTokenMP
.
ID
=
'
TaskAccessTokenMP
'
class
TaskAccessTokenH5
extends
Task
{
constructor
(
config
)
{
super
()
this
.
_config
=
config
||
null
}
async
run
()
{
const
key
=
{
dcloudAppid
:
this
.
_config
.
dcloudAppid
,
platform
:
PlatformType
.
WEIXIN_H5
}
const
result
=
await
getAccessToken
(
key
)
console
.
log
(
"
setAccessToken...
"
,
key
,
result
)
}
}
TaskAccessTokenH5
.
ID
=
'
TaskAccessTokenH5
'
class
TaskTicket
extends
Task
{
constructor
(
config
)
{
super
()
this
.
_config
=
config
||
null
}
async
run
()
{
const
key
=
{
dcloudAppid
:
this
.
_config
.
dcloudAppid
,
platform
:
PlatformType
.
WEIXIN_H5
}
const
result
=
await
getTicket
(
key
)
console
.
log
(
"
setTicket...
"
,
key
,
result
)
}
}
TaskTicket
.
ID
=
'
TaskTicket
'
module
.
exports
=
{
TaskAccessTokenMP
,
TaskAccessTokenH5
,
TaskTicket
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录