Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
hello_uni-id-pages
提交
7deb731a
H
hello_uni-id-pages
项目概览
DCloud
/
hello_uni-id-pages
通知
1054
Star
31
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看板
提交
7deb731a
编写于
7月 06, 2022
作者:
DCloud_JSON
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
发布1.0.4版
上级
84b5d237
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
306 addition
and
80 deletion
+306
-80
manifest.json
manifest.json
+1
-1
uni_modules/uni-id-pages/changelog.md
uni_modules/uni-id-pages/changelog.md
+1
-0
uni_modules/uni-id-pages/init.js
uni_modules/uni-id-pages/init.js
+79
-79
uni_modules/uni-id-pages/uniCloud/database/opendb-device.schema.json
.../uni-id-pages/uniCloud/database/opendb-device.schema.json
+142
-0
uni_modules/uni-id-pages/uniCloud/database/uni-id-device.schema.json
.../uni-id-pages/uniCloud/database/uni-id-device.schema.json
+83
-0
未找到文件。
manifest.json
浏览文件 @
7deb731a
...
...
@@ -116,7 +116,7 @@
},
"usingComponents"
:
true
,
"unipush"
:
{
"enable"
:
tru
e
"enable"
:
fals
e
}
},
"mp-alipay"
:
{
...
...
uni_modules/uni-id-pages/changelog.md
浏览文件 @
7deb731a
## 1.0.4(2022-07-06)
-
uni-id-co增加clientInfo字段类型校验
-
监听token更新时机,同步客户端push_clientid至uni-id-device表,改为:同步客户端push_clientid至uni-id-device表和opendb-device表
## 1.0.3(2022-07-05)
新增监听token更新时机,同步客户端push_clientid至uni-id-device表
## 1.0.2(2022-07-04)
...
...
uni_modules/uni-id-pages/init.js
浏览文件 @
7deb731a
...
...
@@ -12,88 +12,88 @@ const {
export
default
async
function
()
{
// 有打开调试模式的情况下
if
(
debug
)
{
// 1. 检查本地uni-id-pages中配置的登录方式,服务器端是否已经配置正确。否则提醒并引导去配置
//调用云对象,获取服务端已正确配置的登录方式
let
{
supportedLoginType
}
=
await
uniIdCo
.
getSupportedLoginType
()
console
.
log
(
"
supportedLoginType:
"
+
JSON
.
stringify
(
supportedLoginType
));
//登录方式,服务端和客户端的映射关系
let
data
=
{
smsCode
:
'
mobile-code
'
,
univerify
:
'
univerify
'
,
username
:
'
username-password
'
,
weixin
:
'
weixin
'
,
qq
:
'
qq
'
,
xiaomi
:
'
xiaomi
'
,
sinaweibo
:
'
sinaweibo
'
,
taobao
:
'
taobao
'
,
facebook
:
'
facebook
'
,
google
:
'
google
'
,
alipay
:
'
alipay
'
,
apple
:
"
apple
"
}
//遍历客户端配置的登录方式,与服务端比对。并在错误时抛出错误提示
let
list
=
loginTypes
.
filter
(
type
=>
!
supportedLoginType
.
includes
(
data
[
type
]))
if
(
list
.
length
)
{
console
.
error
(
`错误:前端启用的登录方式:
${
list
.
join
(
'
,
'
)}
;没有在服务端完成配置。配置文件路径:"/uni_modules/uni-config-center/uniCloud/cloudfunctions/common/uni-config-center/uni-id/config.json"`
);
}
// 有打开调试模式的情况下
if
(
debug
)
{
// 1. 检查本地uni-id-pages中配置的登录方式,服务器端是否已经配置正确。否则提醒并引导去配置
//调用云对象,获取服务端已正确配置的登录方式
let
{
supportedLoginType
}
=
await
uniIdCo
.
getSupportedLoginType
()
console
.
log
(
"
supportedLoginType:
"
+
JSON
.
stringify
(
supportedLoginType
));
//登录方式,服务端和客户端的映射关系
let
data
=
{
smsCode
:
'
mobile-code
'
,
univerify
:
'
univerify
'
,
username
:
'
username-password
'
,
weixin
:
'
weixin
'
,
qq
:
'
qq
'
,
xiaomi
:
'
xiaomi
'
,
sinaweibo
:
'
sinaweibo
'
,
taobao
:
'
taobao
'
,
facebook
:
'
facebook
'
,
google
:
'
google
'
,
alipay
:
'
alipay
'
,
apple
:
"
apple
"
}
// #ifdef APP-PLUS
//如果uni-id-pages配置的登录功能有一键登录,有则执行预登录(异步)
if
(
loginTypes
.
includes
(
'
univerify
'
))
{
uni
.
preLogin
({
provider
:
'
univerify
'
,
complete
:
e
=>
{
console
.
log
(
e
);
}
})
//遍历客户端配置的登录方式,与服务端比对。并在错误时抛出错误提示
let
list
=
loginTypes
.
filter
(
type
=>
!
supportedLoginType
.
includes
(
data
[
type
]))
if
(
list
.
length
)
{
console
.
error
(
`错误:前端启用的登录方式:
${
list
.
join
(
'
,
'
)}
;没有在服务端完成配置。配置文件路径:"/uni_modules/uni-config-center/uniCloud/cloudfunctions/common/uni-config-center/uni-id/config.json"`
);
}
// #endif
}
// #ifdef APP-PLUS
//如果uni-id-pages配置的登录功能有一键登录,有则执行预登录(异步)
if
(
loginTypes
.
includes
(
'
univerify
'
))
{
uni
.
preLogin
({
provider
:
'
univerify
'
,
complete
:
e
=>
{
console
.
log
(
e
);
}
})
}
// #endif
//3. 绑定clientDB错误事件
// clientDB对象
const
db
=
uniCloud
.
database
()
db
.
on
(
'
error
'
,
onDBError
)
//clientDB的错误提示
function
onDBError
({
code
,
// 错误码详见https://uniapp.dcloud.net.cn/uniCloud/clientdb?id=returnvalue
//3. 绑定clientDB错误事件
// clientDB对象
const
db
=
uniCloud
.
database
()
db
.
on
(
'
error
'
,
onDBError
)
//clientDB的错误提示
function
onDBError
({
code
,
// 错误码详见https://uniapp.dcloud.net.cn/uniCloud/clientdb?id=returnvalue
message
})
{
console
.
error
(
'
onDBError
'
,
{
code
,
message
})
{
console
.
error
(
'
onDBError
'
,
{
code
,
message
});
}
// 解绑clientDB错误事件
//db.off('error', onDBError)
});
}
// 解绑clientDB错误事件
//db.off('error', onDBError)
//4. 同步客户端push_clientid至device表
if
(
uniCloud
.
onRefreshToken
)
{
uniCloud
.
onRefreshToken
(()
=>
{
console
.
log
(
'
onRefreshToken
'
);
if
(
uni
.
canIUse
(
'
getPushClientId
'
))
{
uni
.
getPushClientId
({
success
:
async
function
(
e
)
{
console
.
log
(
e
)
let
pushClientId
=
e
.
cid
console
.
log
(
pushClientId
);
let
res
=
await
uniIdCo
.
setPushCid
({
pushClientId
})
console
.
log
(
res
);
},
fail
(
e
)
{
console
.
log
(
e
)
}
})
}
})
}
//4. 同步客户端push_clientid至device表
if
(
uniCloud
.
onRefreshToken
)
{
uniCloud
.
onRefreshToken
(()
=>
{
console
.
log
(
'
onRefreshToken
'
);
if
(
uni
.
getPushClientId
)
{
uni
.
getPushClientId
({
success
:
async
function
(
e
)
{
console
.
log
(
e
)
let
pushClientId
=
e
.
cid
console
.
log
(
pushClientId
);
let
res
=
await
uniIdCo
.
setPushCid
({
pushClientId
})
console
.
log
(
'
getPushClientId
'
,
res
);
},
fail
(
e
)
{
console
.
log
(
e
)
}
})
}
})
}
}
uni_modules/uni-id-pages/uniCloud/database/opendb-device.schema.json
0 → 100644
浏览文件 @
7deb731a
{
"bsonType"
:
"object"
,
"required"
:
[],
"permission"
:
{
"read"
:
false
,
"create"
:
false
,
"update"
:
false
,
"delete"
:
false
},
"properties"
:
{
"_id"
:
{
"description"
:
"ID,系统自动生成"
},
"appid"
:
{
"bsonType"
:
"string"
,
"description"
:
"DCloud appid"
},
"device_id"
:
{
"bsonType"
:
"string"
,
"description"
:
"设备唯一标识"
},
"vendor"
:
{
"bsonType"
:
"string"
,
"description"
:
"设备厂商"
},
"push_clientid"
:
{
"bsonType"
:
"string"
,
"description"
:
"推送设备客户端标识"
},
"imei"
:
{
"bsonType"
:
"string"
,
"description"
:
"国际移动设备识别码IMEI(International Mobile Equipment Identity)"
},
"oaid"
:
{
"bsonType"
:
"string"
,
"description"
:
"移动智能设备标识公共服务平台提供的匿名设备标识符(OAID)"
},
"idfa"
:
{
"bsonType"
:
"string"
,
"description"
:
"iOS平台配置应用使用广告标识(IDFA)"
},
"imsi"
:
{
"bsonType"
:
"string"
,
"description"
:
"国际移动用户识别码(International Mobile Subscriber Identification Number)"
},
"model"
:
{
"bsonType"
:
"string"
,
"description"
:
"设备型号"
},
"platform"
:
{
"bsonType"
:
"string"
,
"description"
:
"平台类型"
},
"uni_platform"
:
{
"bsonType"
:
"string"
,
"description"
:
"uni-app 运行平台,与条件编译平台相同。"
},
"os_name"
:
{
"bsonType"
:
"string"
,
"description"
:
"ios|android|windows|mac|linux "
},
"os_version"
:
{
"bsonType"
:
"string"
,
"description"
:
"操作系统版本号 "
},
"os_language"
:
{
"bsonType"
:
"string"
,
"description"
:
"操作系统语言 "
},
"os_theme"
:
{
"bsonType"
:
"string"
,
"description"
:
"操作系统主题 light|dark"
},
"pixel_ratio"
:
{
"bsonType"
:
"string"
,
"description"
:
"设备像素比 "
},
"network_model"
:
{
"bsonType"
:
"string"
,
"description"
:
"设备网络型号wifi/3G/4G/"
},
"window_width"
:
{
"bsonType"
:
"string"
,
"description"
:
"设备窗口宽度 "
},
"window_height"
:
{
"bsonType"
:
"string"
,
"description"
:
"设备窗口高度"
},
"screen_width"
:
{
"bsonType"
:
"string"
,
"description"
:
"设备屏幕宽度"
},
"screen_height"
:
{
"bsonType"
:
"string"
,
"description"
:
"设备屏幕高度"
},
"rom_name"
:
{
"bsonType"
:
"string"
,
"description"
:
"rom 名称"
},
"rom_version"
:
{
"bsonType"
:
"string"
,
"description"
:
"rom 版本"
},
"location_latitude"
:
{
"bsonType"
:
"double"
,
"description"
:
"纬度"
},
"location_longitude"
:
{
"bsonType"
:
"double"
,
"description"
:
"经度"
},
"location_country"
:
{
"bsonType"
:
"string"
,
"description"
:
"国家"
},
"location_province"
:
{
"bsonType"
:
"string"
,
"description"
:
"省份"
},
"location_city"
:
{
"bsonType"
:
"string"
,
"description"
:
"城市"
},
"create_date"
:
{
"bsonType"
:
"timestamp"
,
"description"
:
"创建时间"
,
"forceDefaultValue"
:
{
"$env"
:
"now"
}
},
"last_update_date"
:
{
"bsonType"
:
"timestamp"
,
"description"
:
"最后一次修改时间"
,
"forceDefaultValue"
:
{
"$env"
:
"now"
}
}
},
"version"
:
"0.0.1"
}
\ No newline at end of file
uni_modules/uni-id-pages/uniCloud/database/uni-id-device.schema.json
0 → 100644
浏览文件 @
7deb731a
{
"bsonType"
:
"object"
,
"required"
:
[
"user_id"
],
"properties"
:
{
"_id"
:
{
"description"
:
"ID,系统自动生成"
},
"user_id"
:
{
"bsonType"
:
"string"
,
"description"
:
"用户id,参考uni-id-users表"
},
"ua"
:
{
"bsonType"
:
"string"
,
"description"
:
"userAgent"
},
"uuid"
:
{
"bsonType"
:
"string"
,
"description"
:
"设备唯一标识(需要加密存储)"
},
"os_name"
:
{
"bsonType"
:
"string"
,
"description"
:
"ios|android|windows|mac|linux "
},
"os_version"
:
{
"bsonType"
:
"string"
,
"description"
:
"操作系统版本号 "
},
"os_language"
:
{
"bsonType"
:
"string"
,
"description"
:
"操作系统语言 "
},
"os_theme"
:
{
"bsonType"
:
"string"
,
"description"
:
"操作系统主题 light|dark"
},
"vendor"
:
{
"bsonType"
:
"string"
,
"description"
:
"设备厂商"
},
"push_clientid"
:
{
"bsonType"
:
"string"
,
"description"
:
"推送设备客户端标识"
},
"imei"
:
{
"bsonType"
:
"string"
,
"description"
:
"国际移动设备识别码IMEI(International Mobile Equipment Identity)"
},
"oaid"
:
{
"bsonType"
:
"string"
,
"description"
:
"移动智能设备标识公共服务平台提供的匿名设备标识符(OAID)"
},
"idfa"
:
{
"bsonType"
:
"string"
,
"description"
:
"iOS平台配置应用使用广告标识(IDFA)"
},
"model"
:
{
"bsonType"
:
"string"
,
"description"
:
"设备型号"
},
"platform"
:
{
"bsonType"
:
"string"
,
"description"
:
"平台类型"
},
"create_date"
:
{
"bsonType"
:
"timestamp"
,
"description"
:
"创建时间"
,
"forceDefaultValue"
:
{
"$env"
:
"now"
}
},
"last_active_date"
:
{
"bsonType"
:
"timestamp"
,
"description"
:
"最后登录时间"
},
"last_active_ip"
:
{
"bsonType"
:
"string"
,
"description"
:
"最后登录IP"
}
},
"version"
:
"0.0.1"
}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录