Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
hello_uni-id-pages
提交
6978b67d
H
hello_uni-id-pages
项目概览
DCloud
/
hello_uni-id-pages
通知
1068
Star
33
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看板
提交
6978b67d
编写于
8月 19, 2022
作者:
雪洛
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
deps: bump uni-open-bridge to pre-release version
上级
777dac29
变更
10
隐藏空白更改
内联
并排
Showing
10 changed file
with
51 addition
and
139 deletion
+51
-139
uni_modules/uni-open-bridge/changelog.md
uni_modules/uni-open-bridge/changelog.md
+1
-1
uni_modules/uni-open-bridge/readme.md
uni_modules/uni-open-bridge/readme.md
+1
-1
uni_modules/uni-open-bridge/uniCloud/cloudfunctions/common/uni-open-bridge-common/config.js
...ud/cloudfunctions/common/uni-open-bridge-common/config.js
+7
-3
uni_modules/uni-open-bridge/uniCloud/cloudfunctions/common/uni-open-bridge-common/consts.js
...ud/cloudfunctions/common/uni-open-bridge-common/consts.js
+6
-6
uni_modules/uni-open-bridge/uniCloud/cloudfunctions/common/uni-open-bridge-common/index.js
...oud/cloudfunctions/common/uni-open-bridge-common/index.js
+5
-3
uni_modules/uni-open-bridge/uniCloud/cloudfunctions/uni-open-bridge/config.js
...-bridge/uniCloud/cloudfunctions/uni-open-bridge/config.js
+3
-47
uni_modules/uni-open-bridge/uniCloud/cloudfunctions/uni-open-bridge/consts.js
...-bridge/uniCloud/cloudfunctions/uni-open-bridge/consts.js
+0
-19
uni_modules/uni-open-bridge/uniCloud/cloudfunctions/uni-open-bridge/index.task.js
...dge/uniCloud/cloudfunctions/uni-open-bridge/index.task.js
+4
-7
uni_modules/uni-open-bridge/uniCloud/cloudfunctions/uni-open-bridge/task-mp-weixin.js
...uniCloud/cloudfunctions/uni-open-bridge/task-mp-weixin.js
+0
-41
uni_modules/uni-open-bridge/uniCloud/cloudfunctions/uni-open-bridge/task-weixin.js
...ge/uniCloud/cloudfunctions/uni-open-bridge/task-weixin.js
+24
-11
未找到文件。
uni_modules/uni-open-bridge/changelog.md
浏览文件 @
6978b67d
## 1.0.0(2022-08-
05
)
## 1.0.0(2022-08-
12
)
-
首次发布
uni_modules/uni-open-bridge/readme.md
浏览文件 @
6978b67d
# uni-open-bridge
`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/common/uni-open-bridge-common/config.js
浏览文件 @
6978b67d
'
use strict
'
;
const
{
PlatformType
}
=
require
(
'
./consts.js
'
)
const
configCenter
=
require
(
'
uni-config-center
'
)
const
OauthConfig
=
{
'
mp-weixin
'
:
[
'
mp-weixin
'
,
'
oauth
'
,
'
weixin
'
],
'
h5-weixin
'
:
[
'
web
'
,
'
oauth
'
,
'
h5-weixin
'
]
'
weixin-mp
'
:
[
'
mp-weixin
'
,
'
oauth
'
,
'
weixin
'
],
'
weixin-h5
'
:
[
'
web
'
,
'
oauth
'
,
'
weixin-h5
'
]
}
class
ConfigBase
{
...
...
@@ -83,7 +87,7 @@ class AppConfig extends ConfigBase {
}
}
AppConfig
.
Support_Platforms
=
[
'
mp-weixin
'
,
'
h5-weixin
'
]
AppConfig
.
Support_Platforms
=
[
PlatformType
.
WEIXIN_MP
,
PlatformType
.
WEIXIN_H5
]
module
.
exports
=
{
...
...
uni_modules/uni-open-bridge/uniCloud/cloudfunctions/common/uni-open-bridge-common/consts.js
浏览文件 @
6978b67d
...
...
@@ -5,12 +5,12 @@ const HTTP_STATUS = {
}
const
PlatformType
=
{
MP_WEIXIN
:
'
mp-weixin
'
,
H5_WEIXIN
:
'
h5-weixin
'
,
APP_WEIXIN
:
'
app-weixin
'
,
WE
B_WEIXIN
:
'
web-weixin
'
,
MP_QQ
:
'
mp-qq
'
,
APP_QQ
:
'
app-qq
'
WEIXIN_MP
:
'
weixin-mp
'
,
WEIXIN_H5
:
'
weixin-h5
'
,
WEIXIN_APP
:
'
weixin-app
'
,
WE
IXIN_WEB
:
'
weixin-web
'
,
QQ_MP
:
'
qq-mp
'
,
QQ_APP
:
'
qq-app
'
}
module
.
exports
=
{
...
...
uni_modules/uni-open-bridge/uniCloud/cloudfunctions/common/uni-open-bridge-common/index.js
浏览文件 @
6978b67d
...
...
@@ -31,7 +31,7 @@ class AccessToken extends Storage {
async
fallback
(
parameters
)
{
const
oauthConfig
=
appConfig
.
get
(
parameters
.
dcloudAppid
,
parameters
.
platform
)
const
methodName
=
(
parameters
.
platform
===
PlatformType
.
MP_WEIXIN
)
?
'
GetMPAccessTokenData
'
:
const
methodName
=
(
parameters
.
platform
===
PlatformType
.
WEIXIN_MP
)
?
'
GetMPAccessTokenData
'
:
'
GetH5AccessTokenData
'
const
responseData
=
await
WeixinServer
[
methodName
](
oauthConfig
)
...
...
@@ -111,7 +111,7 @@ class Ticket extends Storage {
async
fallback
(
parameters
)
{
const
accessToken
=
await
Factory
.
Get
(
AccessToken
,
{
dcloudAppid
:
parameters
.
dcloudAppid
,
platform
:
PlatformType
.
H5_WEIXIN
platform
:
PlatformType
.
WEIXIN_H5
})
const
responseData
=
await
WeixinServer
.
GetH5TicketData
(
accessToken
)
...
...
@@ -204,5 +204,7 @@ module.exports = {
removeEncryptKey
,
getTicket
,
setTicket
,
removeTicket
removeTicket
,
PlatformType
,
WeixinServer
}
uni_modules/uni-open-bridge/uniCloud/cloudfunctions/uni-open-bridge/config.js
浏览文件 @
6978b67d
'
use strict
'
;
const
{
PlatformType
}
=
require
(
'
./consts.js
'
)
const
configCenter
=
require
(
'
uni-config-center
'
)
const
OauthConfig
=
{
'
mp-weixin
'
:
[
'
oauth
'
,
'
weixin
'
],
'
h5-weixin
'
:
[
'
oauth
'
,
'
weixin
'
]
}
class
TaskConfig
{
constructor
(
options
)
{
...
...
@@ -141,17 +132,10 @@ class OpenBridgeConfig extends ConfigBase {
continue
}
const
oauthConfig
=
this
.
getOauthConfig
(
appConfig
,
platformName
)
if
(
!
oauthConfig
)
{
continue
}
this
.
_tasks
.
push
({
platform
:
platformName
,
tasks
:
scheduleTask
.
tasks
,
dcloudAppid
:
dcloudAppid
,
appid
:
oauthConfig
.
appid
,
secret
:
oauthConfig
.
secret
platform
:
platformName
,
tasks
:
scheduleTask
.
tasks
})
}
}
...
...
@@ -159,37 +143,9 @@ class OpenBridgeConfig extends ConfigBase {
isSupport
(
platformName
)
{
return
(
OpenBridgeConfig
.
Support_Platforms
.
indexOf
(
platformName
)
>=
0
)
}
getOauthConfig
(
appConfig
,
platformName
)
{
const
platformConfig
=
appConfig
[
platformName
]
if
(
!
platformConfig
)
{
return
null
}
let
tree
=
OauthConfig
[
platformName
]
let
node
=
platformConfig
for
(
let
i
=
0
;
i
<
tree
.
length
;
i
++
)
{
let
nodeName
=
tree
[
i
]
if
(
node
[
nodeName
])
{
node
=
node
[
nodeName
]
}
else
{
node
=
null
break
}
}
if
(
node
&&
node
.
appid
&&
node
.
appsecret
)
{
return
{
appid
:
node
.
appid
,
secret
:
node
.
appsecret
}
}
return
null
}
}
OpenBridgeConfig
.
Support_Platforms
=
[
'
mp-weixin
'
,
'
h5-weixin
'
]
OpenBridgeConfig
.
Support_Platforms
=
[
'
weixin-mp
'
,
'
weixin-h5
'
]
module
.
exports
=
{
...
...
uni_modules/uni-open-bridge/uniCloud/cloudfunctions/uni-open-bridge/consts.js
已删除
100644 → 0
浏览文件 @
777dac29
'
use strict
'
;
const
HTTP_STATUS
=
{
SUCCESS
:
200
}
const
PlatformType
=
{
MP_WEIXIN
:
'
mp-weixin
'
,
H5_WEIXIN
:
'
h5-weixin
'
,
APP_WEIXIN
:
'
app-weixin
'
,
WEB_WEIXIN
:
'
web-weixin
'
,
MP_QQ
:
'
mp-qq
'
,
APP_QQ
:
'
app-qq
'
}
module
.
exports
=
{
HTTP_STATUS
,
PlatformType
}
uni_modules/uni-open-bridge/uniCloud/cloudfunctions/uni-open-bridge/index.task.js
浏览文件 @
6978b67d
...
...
@@ -9,19 +9,16 @@ const {
}
=
require
(
'
./basic.js
'
)
const
{
TaskAccessTokenMP
}
=
require
(
'
./task-mp-weixin.js
'
)
const
{
TaskAccessTokenMP
,
TaskAccessTokenH5
,
TaskTicket
}
=
require
(
'
./task-
h5-
weixin.js
'
)
}
=
require
(
'
./task-weixin.js
'
)
const
TaskMapping
=
{
'
mp-weixin
'
:
{
'
weixin-mp
'
:
{
'
accessToken
'
:
TaskAccessTokenMP
},
'
h5-weixin
'
:
{
'
weixin-h5
'
:
{
'
accessToken
'
:
TaskAccessTokenH5
,
'
ticket
'
:
TaskTicket
}
...
...
uni_modules/uni-open-bridge/uniCloud/cloudfunctions/uni-open-bridge/task-mp-weixin.js
已删除
100644 → 0
浏览文件 @
777dac29
'
use strict
'
;
const
{
getAccessToken
,
setAccessToken
,
removeAccessToken
}
=
require
(
'
uni-open-bridge-common
'
)
const
{
Task
}
=
require
(
'
./basic.js
'
)
const
{
PlatformType
}
=
require
(
'
./consts.js
'
)
class
TaskAccessTokenMP
extends
Task
{
constructor
(
config
)
{
super
()
this
.
_config
=
config
||
null
}
async
run
()
{
const
key
=
{
dcloudAppid
:
this
.
_config
.
dcloudAppid
,
platform
:
PlatformType
.
MP_WEIXIN
}
const
result
=
await
getAccessToken
(
key
)
console
.
log
(
"
setAccessToken...
"
,
key
,
result
)
}
}
TaskAccessTokenMP
.
ID
=
'
TaskAccessTokenMP
'
module
.
exports
=
{
TaskAccessTokenMP
}
uni_modules/uni-open-bridge/uniCloud/cloudfunctions/uni-open-bridge/task-
h5-
weixin.js
→
uni_modules/uni-open-bridge/uniCloud/cloudfunctions/uni-open-bridge/task-weixin.js
浏览文件 @
6978b67d
...
...
@@ -2,20 +2,34 @@
const
{
getAccessToken
,
setAccessToken
,
removeAccessToken
,
getTicket
,
setTicket
,
removeTicket
PlatformType
}
=
require
(
'
uni-open-bridge-common
'
)
const
{
Task
}
=
require
(
'
./basic.js
'
)
const
{
PlatformType
}
=
require
(
'
./consts.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
{
...
...
@@ -28,7 +42,7 @@ class TaskAccessTokenH5 extends Task {
async
run
()
{
const
key
=
{
dcloudAppid
:
this
.
_config
.
dcloudAppid
,
platform
:
PlatformType
.
H5_WEIXIN
platform
:
PlatformType
.
WEIXIN_H5
}
const
result
=
await
getAccessToken
(
key
)
...
...
@@ -36,7 +50,6 @@ class TaskAccessTokenH5 extends Task {
console
.
log
(
"
setAccessToken...
"
,
key
,
result
)
}
}
TaskAccessTokenH5
.
ID
=
'
TaskAccessTokenH5
'
class
TaskTicket
extends
Task
{
...
...
@@ -50,7 +63,7 @@ class TaskTicket extends Task {
async
run
()
{
const
key
=
{
dcloudAppid
:
this
.
_config
.
dcloudAppid
,
platform
:
PlatformType
.
H5_WEIXIN
platform
:
PlatformType
.
WEIXIN_H5
}
const
result
=
await
getTicket
(
key
)
...
...
@@ -58,10 +71,10 @@ class TaskTicket extends Task {
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.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录