Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
hello uni-id-pages-x
提交
70e37cfc
H
hello uni-id-pages-x
项目概览
DCloud
/
hello uni-id-pages-x
通知
40
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
H
hello uni-id-pages-x
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
70e37cfc
编写于
12月 08, 2023
作者:
DCloud_JSON
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
去掉配置项config.needLogin,并提示
上级
bec2bb35
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
141 addition
and
128 deletion
+141
-128
pages.json
pages.json
+95
-90
uni_modules/uni-id-pages-x/config.uts
uni_modules/uni-id-pages-x/config.uts
+0
-3
uni_modules/uni-id-pages-x/init.uts
uni_modules/uni-id-pages-x/init.uts
+46
-35
未找到文件。
pages.json
浏览文件 @
70e37cfc
{
"pages"
:
[
//pages数组中第一项表示应用启动页,参考:https://uniapp.dcloud.io/collocation/pages
{
"path"
:
"pages/index/index"
,
"style"
:
{
"navigationBarTitleText"
:
"uni-id-pages-x"
}
},
{
"path"
:
"uni_modules/uni-id-pages-x/pages/login/login"
,
"style"
:
{
"navigationBarTitleText"
:
"登录账号"
,
"enablePullDownRefresh"
:
false
}
},
{
"path"
:
"uni_modules/uni-id-pages-x/pages/userinfo/userinfo"
,
"style"
:
{
"navigationBarTitleText"
:
"我的资料"
,
"enablePullDownRefresh"
:
false
}
},
{
"path"
:
"uni_modules/uni-id-pages-x/pages/register/register"
,
"style"
:
{
"navigationBarTitleText"
:
"注册"
,
"enablePullDownRefresh"
:
false
}
},
{
"path"
:
"uni_modules/uni-id-pages-x/pages/retrieve/retrieve"
,
"style"
:
{
"navigationBarTitleText"
:
"重置密码"
,
"enablePullDownRefresh"
:
false
}
},
{
"path"
:
"uni_modules/uni-id-pages-x/pages/common/webview/webview"
,
"style"
:
{
"navigationBarTitleText"
:
""
,
"enablePullDownRefresh"
:
false
}
},
{
"path"
:
"uni_modules/uni-id-pages-x/pages/userinfo/deactivate/deactivate"
,
"style"
:
{
"navigationBarTitleText"
:
"注销账号"
,
"enablePullDownRefresh"
:
false
}
},
{
"path"
:
"uni_modules/uni-id-pages-x/pages/userinfo/bindMobile/bindMobile"
,
"style"
:
{
"navigationBarTitleText"
:
"绑定手机号码"
,
"enablePullDownRefresh"
:
false
}
},
{
"path"
:
"uni_modules/uni-id-pages-x/pages/userinfo/setNickname/setNickname"
,
"style"
:
{
"navigationBarTitleText"
:
"设置昵称"
,
"enablePullDownRefresh"
:
false
,
"navigationStyle"
:
"custom"
//
"app-plus"
:
{
//
"titleNView"
:
{
//
"buttons"
:
[
//
{
//
"color"
:
"#fff"
,
//
"text"
:
"完成"
,
//
"float"
:
"right"
,
//
"fontWeight"
:
"normal"
//
}
//
]
//
}
//
}
}
},
{
"path"
:
"uni_modules/uni-id-pages-x/pages/userinfo/realnameAuth/realnameAuth"
,
"style"
:
{
"navigationBarTitleText"
:
"实名认证"
,
"enablePullDownRefresh"
:
false
}
}
],
"globalStyle"
:
{
"navigationBarTextStyle"
:
"black"
,
"navigationBarTitleText"
:
"uni-app"
,
"navigationBarBackgroundColor"
:
"#F8F8F8"
,
"backgroundColor"
:
"#F8F8F8"
},
"uniIdRouter"
:
{}
}
"pages"
:
[
//pages数组中第一项表示应用启动页,参考:https://uniapp.dcloud.io/collocation/pages
{
"path"
:
"pages/index/index"
,
"style"
:
{
"navigationBarTitleText"
:
"uni-id-pages-x"
}
},
{
"path"
:
"uni_modules/uni-id-pages-x/pages/login/login"
,
"style"
:
{
"navigationBarTitleText"
:
"登录账号"
,
"enablePullDownRefresh"
:
false
}
},
{
"path"
:
"uni_modules/uni-id-pages-x/pages/userinfo/userinfo"
,
"style"
:
{
"navigationBarTitleText"
:
"我的资料"
,
"enablePullDownRefresh"
:
false
}
},
{
"path"
:
"uni_modules/uni-id-pages-x/pages/register/register"
,
"style"
:
{
"navigationBarTitleText"
:
"注册"
,
"enablePullDownRefresh"
:
false
}
},
{
"path"
:
"uni_modules/uni-id-pages-x/pages/retrieve/retrieve"
,
"style"
:
{
"navigationBarTitleText"
:
"重置密码"
,
"enablePullDownRefresh"
:
false
}
},
{
"path"
:
"uni_modules/uni-id-pages-x/pages/common/webview/webview"
,
"style"
:
{
"navigationBarTitleText"
:
""
,
"enablePullDownRefresh"
:
false
}
},
{
"path"
:
"uni_modules/uni-id-pages-x/pages/userinfo/deactivate/deactivate"
,
"style"
:
{
"navigationBarTitleText"
:
"注销账号"
,
"enablePullDownRefresh"
:
false
}
},
{
"path"
:
"uni_modules/uni-id-pages-x/pages/userinfo/bindMobile/bindMobile"
,
"style"
:
{
"navigationBarTitleText"
:
"绑定手机号码"
,
"enablePullDownRefresh"
:
false
}
},
{
"path"
:
"uni_modules/uni-id-pages-x/pages/userinfo/setNickname/setNickname"
,
"style"
:
{
"navigationBarTitleText"
:
"设置昵称"
,
"enablePullDownRefresh"
:
false
,
"navigationStyle"
:
"custom"
//
"app-plus"
:
{
//
"titleNView"
:
{
//
"buttons"
:
[
//
{
//
"color"
:
"#fff"
,
//
"text"
:
"完成"
,
//
"float"
:
"right"
,
//
"fontWeight"
:
"normal"
//
}
//
]
//
}
//
}
}
},
{
"path"
:
"uni_modules/uni-id-pages-x/pages/userinfo/realnameAuth/realnameAuth"
,
"style"
:
{
"navigationBarTitleText"
:
"实名认证"
,
"enablePullDownRefresh"
:
false
}
}
],
"globalStyle"
:
{
"navigationBarTextStyle"
:
"black"
,
"navigationBarTitleText"
:
"uni-app"
,
"navigationBarBackgroundColor"
:
"#F8F8F8"
,
"backgroundColor"
:
"#F8F8F8"
},
"uniIdRouter"
:
{
"loginPage"
:
"/uni_modules/uni-id-pages-x/pages/login/login"
,
"needLogin"
:
[
"/uni_modules/uni-id-pages-x/pages/userinfo/*"
]
}
}
uni_modules/uni-id-pages-x/config.uts
浏览文件 @
70e37cfc
...
...
@@ -12,9 +12,6 @@ export default {
"register","login","realNameVerify"
]
},
"needLogin":[
"/uni_modules/uni-id-pages-x/pages/userinfo/*"
],
"loginTypes":[
"username",
"smsCode",
...
...
uni_modules/uni-id-pages-x/init.uts
浏览文件 @
70e37cfc
...
...
@@ -52,7 +52,7 @@ export default async function () {
console.error(
`错误:前端启用的登录方式:${list?.join(',')};没有在服务端完成配置。配置文件路径:"/uni_modules/uni-config-center/uniCloud/cloudfunctions/common/uni-config-center/uni-id/config.json"`
)
}
}
}
// #ifdef UNI-APP-X
...
...
@@ -80,44 +80,55 @@ export default async function () {
// }
// // 解绑clientDB错误事件
// // db.off('error', onDBError)
const checkNeedLogin = (url:string):boolean=>{
if(state.isLogin){
return false
}
const needLogin = config.getArray<string>('needLogin')
if (needLogin != null) {
return needLogin.every((item:string):boolean => {
return item == url || new RegExp(item).test(url)
})
}else{
return false
}
}
uni.addInterceptor('navigateTo',{
invoke:(e:NavigateToOptions)=>{
if (checkNeedLogin(e.url)) {
uni.showToast({
title: '请先登录',
icon: 'none'
})
e.url = "/uni_modules/uni-id-pages-x/pages/login/login?uniIdRedirectUrl=" + encodeURIComponent(e.url)
// needLogin相关代码-start(此代码仅为版本兼容提示使用,如已知晓可删除)
const needLogin = config.getArray<string>('needLogin')
const uniCompileVersionCode = uni.getSystemInfoSync().get('uniCompileVersionCode') as number
if(needLogin != null && (uniCompileVersionCode > 3.99 || uniCompileVersionCode == 3.99) ){
const tipText = "uni-id-pages x v1.0.4+ 不再支持配置项config.needLogin,请升级HBuilderX 版本为3.99+,使用更强大 uni-id-router替代。详情查看:https://uniapp.dcloud.net.cn/uniCloud/uni-id/summary.html#uni-id-router"
console.error(tipText)
uni.showModal({
content: tipText,
showCancel: false,
confirmText:"知道了"
});
}else{
const checkNeedLogin = (url:string):boolean=>{
if(state.isLogin){
return false
}
}
})
uni.addInterceptor('redirectTo',{
invoke:(e:RedirectToOptions)=>{
if (checkNeedLogin(e.url)) {
uni.showToast({
title: '请先登录',
icon: 'none'
if (needLogin != null) {
return needLogin.every((item:string):boolean => {
return item == url || new RegExp(item).test(url)
})
e.url = "/uni_modules/uni-id-pages-x/pages/login/login?uniIdRedirectUrl=" + encodeURIComponent(e.url)
}else{
return false
}
}
})
uni.addInterceptor('navigateTo',{
invoke:(e:NavigateToOptions)=>{
if (checkNeedLogin(e.url)) {
uni.showToast({
title: '请先登录',
icon: 'none'
})
e.url = "/uni_modules/uni-id-pages-x/pages/login/login?uniIdRedirectUrl=" + encodeURIComponent(e.url)
}
}
})
uni.addInterceptor('redirectTo',{
invoke:(e:RedirectToOptions)=>{
if (checkNeedLogin(e.url)) {
uni.showToast({
title: '请先登录',
icon: 'none'
})
e.url = "/uni_modules/uni-id-pages-x/pages/login/login?uniIdRedirectUrl=" + encodeURIComponent(e.url)
}
}
})
}
// needLogin相关代码-end
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录