From 7d34a7238e69836f35b0c83e41fa63f4d102d750 Mon Sep 17 00:00:00 2001 From: linju-json Date: Wed, 1 Sep 2021 13:34:22 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=BA=E4=BA=86=E6=9B=B4=E7=9B=B4=E8=A7=82?= =?UTF-8?q?=E7=90=86=E8=A7=A3=E8=B7=AF=E7=94=B1=E6=8B=A6=E6=88=AA=E3=80=82?= =?UTF-8?q?=E7=A7=BB=E9=99=A4=E8=B7=AF=E7=94=B1=E6=8B=A6=E6=88=AA=E5=99=A8?= =?UTF-8?q?=E4=B8=AD=EF=BC=8C=E9=BB=98=E8=AE=A4=E8=BF=87=E6=BB=A4=E7=99=BB?= =?UTF-8?q?=E9=99=86=E7=9B=B8=E5=85=B3=E9=A1=B5=E9=9D=A2=E6=8B=A6=E6=88=AA?= =?UTF-8?q?=E7=9A=84=E9=80=BB=E8=BE=91=E3=80=82=E7=A1=AE=E4=BF=9D=E6=89=80?= =?UTF-8?q?=E6=9C=89=E7=99=BD=E5=90=8D=E5=8D=95=E9=A1=B5=E9=9D=A2=E5=9D=87?= =?UTF-8?q?=E5=9C=A8=E9=85=8D=E7=BD=AE=E6=96=87=E4=BB=B6router.visitor?= =?UTF-8?q?=E4=B8=AD=E4=BD=93=E7=8E=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- changelog.md | 2 + common/appInit.js | 880 +++++++++--------- package.json | 2 +- pages/common/webview/webview.vue | 11 +- pages/list/list.nvue | 7 +- uni-starter.config.js | 4 +- .../database/uni-id-users.schema.json | 1 + 7 files changed, 457 insertions(+), 450 deletions(-) diff --git a/changelog.md b/changelog.md index 4b2dd092..5815b1bc 100644 --- a/changelog.md +++ b/changelog.md @@ -1,3 +1,5 @@ +## 1.1.5(2021-09-01) +为了更直观理解路由拦截。移除路由拦截器中,默认过滤登陆相关页面拦截的逻辑。确保所有白名单页面均在配置文件router.visitor中体现 ## 1.1.4(2021-08-31) 修改错误的文章表`SChema`的读权限表达式 ## 1.1.3(2021-08-31) diff --git a/common/appInit.js b/common/appInit.js index 8f94ba79..35bb9c7d 100644 --- a/common/appInit.js +++ b/common/appInit.js @@ -1,297 +1,297 @@ -import uniStarterConfig from '@/uni-starter.config.js'; -import store from '@/store' -//应用初始化页 -// #ifdef APP-PLUS -import checkUpdate from '@/uni_modules/uni-upgrade-center-app/utils/check-update'; -import callCheckVersion from '@/uni_modules/uni-upgrade-center-app/utils/call-check-version'; -import interceptorChooseImage from '@/uni_modules/json-interceptor-chooseImage/js_sdk/main.js'; -// #endif -const db = uniCloud.database() -export default async function() { - let loginConfig = uniStarterConfig.router.login - //清除有配置但设备环境不支持的登陆项 - // #ifdef APP-PLUS - await new Promise((callBack) => { - plus.oauth.getServices(oauthServices => { - loginConfig = loginConfig.filter(item => { - if (["univerify", "weixin", "apple"].includes(item)) { - let index = oauthServices.findIndex(e => e.id == item) - if (index == -1) { - return false - } else { - return oauthServices[index].nativeClient - } - } else { - return true - } - }) - if (loginConfig.includes('univerify')) { //一键登录 功能预登录 - uni.preLogin({ - provider: 'univerify', - complete: e => { - console.log(e); - } - }) - } - callBack() - }, err => { - console.error('获取服务供应商失败:' + JSON.stringify(err)); - }) - }) - // #endif - - //非app移除:一键登录、苹果登陆;h5移除微信登陆,如果你做微信公众号登陆需要将此行移除 - // #ifndef APP-PLUS - loginConfig = loginConfig.filter(item => { - return ![ - 'univerify', - 'apple', - // #ifdef H5 - 'weixin' - // #endif - ].includes(item) - }) - // #endif - - uniStarterConfig.router.login = loginConfig - - // uniStarterConfig挂载到getApp().globalData.config - setTimeout(() => { - getApp({ - allowDefault: true - }).globalData.config = uniStarterConfig; - }, 1) - - - // 初始化appVersion(仅app生效) - initAppVersion(); - - // #ifdef APP-PLUS - // 实现,路由拦截。当应用无访问摄像头/相册权限,引导跳到设置界面 - interceptorChooseImage() - // #endif - - - //clientDB的错误提示 - function onDBError({ - code, // 错误码详见https://uniapp.dcloud.net.cn/uniCloud/clientdb?id=returnvalue - message - }) { - console.log('onDBError', { - code, - message - }); - // 处理错误 - console.error(code, message); - if ([ - 'TOKEN_INVALID_INVALID_CLIENTID', - 'TOKEN_INVALID', - 'TOKEN_INVALID_TOKEN_EXPIRED', - 'TOKEN_INVALID_WRONG_TOKEN', - 'TOKEN_INVALID_ANONYMOUS_USER', - - ].includes(code)) { - uni.navigateTo({ - url: '/pages/ucenter/login-page/index/index' - }) - } - } - // 绑定clientDB错误事件 - db.on('error', onDBError) - - // 解绑clientDB错误事件 - //db.off('error', onDBError) - db.on('refreshToken', function({ - token, - tokenExpired - }) { - console.log('监听到clientDB的refreshToken', { - token, - tokenExpired - }); - store.commit('user/login', { - token, - tokenExpired - }) - }) - - const Debug = true; - //拦截器封装callFunction - let callFunctionOption; - uniCloud.addInterceptor('callFunction', { - async invoke(option) { - // #ifdef APP-PLUS - // 判断如果是执行登陆(无论是哪种登陆方式),就记录用户的相关设备id - if (option.name == 'uni-id-cf' && (option.data.action == 'register' || option.data.action - .slice(0, 5) == 'login')) { - let oaid = await new Promise((callBack, fail) => { - if (uni.getSystemInfoSync().platform == "android") { - plus.device.getOAID({ - success: function(e) { - callBack(e.oaid) - // console.log('getOAID success: '+JSON.stringify(e)); - }, - fail: function(e) { - callBack() - console.log('getOAID failed: ' + JSON.stringify(e)); - } - }); - } else { - callBack() - } - }) - - let imei = await new Promise((callBack, fail) => { - if (uni.getSystemInfoSync().platform == "android") { - plus.device.getInfo({ - success: function(e) { - callBack(e.imei) - // console.log('getOAID success: '+JSON.stringify(e)); - }, - fail: function(e) { - callBack() - console.log('getOAID failed: ' + JSON.stringify(e)); - } - }); - } else { - callBack() - } - }) - - let push_clientid = '', - idfa = plus.storage.getItem('idfa') || ''; //idfa有需要的用户在应用首次启动时自己获取存储到storage中 - - try { - push_clientid = plus.push.getClientInfo().clientid - } catch (e) { - uni.showModal({ - content: '获取推送标识失败。如果你的应用不需要推送功能,请注释掉本代码块', - showCancel: false, - confirmText: "好的" - }); - console.log(e) - } - - let deviceInfo = { - push_clientid, // 获取匿名设备标识符 - imei, - oaid, - idfa - } - console.log("重新登陆/注册,获取设备id", deviceInfo); - option.data.deviceInfo = deviceInfo - - // #ifndef H5 - //注册可能不仅仅走register接口,还有登陆并注册的接口 - option.data.inviteCode = await new Promise((callBack) => { - uni.getClipboardData({ - success: function(res) { - if (res.data.slice(0, 18) == 'uniInvitationCode:') { - let uniInvitationCode = res.data.slice(18, 38) - console.log('当前用户是其他用户推荐下载的,推荐者的code是:' + - uniInvitationCode); - // uni.showModal({ - // content: '当前用户是其他用户推荐下载的,推荐者的code是:'+uniInvitationCode, - // showCancel: false - // }); - callBack(uniInvitationCode) - //当前用户是其他用户推荐下载的。这里登记他的推荐者id 为当前用户的myInviteCode。判断如果是注册 - } else { - callBack(false) - } - }, - fail() { - callBack(false) - } - }); - }) - // #endif - } - // #endif - // console.log(JSON.stringify(option)); - callFunctionOption = option - }, - complete(e) { - // console.log(JSON.stringify(e)); - }, - fail(e) { // 失败回调拦截 - if (Debug) { - uni.showModal({ - content: JSON.stringify(e), - showCancel: false - }); - console.error(e); - } else { - uni.showModal({ - content: "系统错误请稍后再试!", - showCancel: false, - confirmText: "知道了" - }); - } - //如果执行错误,检查是否断网 - uni.getNetworkType({ - complete: res => { - // console.log(res); - if (res.networkType == 'none') { - uni.showToast({ - title: '手机网络异常', - icon: 'none' - }); - console.log('手机网络异常'); - let callBack = res => { - console.log(res); - if (res.isConnected) { - uni.showToast({ - title: '恢复联网自动重新执行', - icon: 'none' - }); - console.log(res.networkType, "恢复联网自动重新执行"); - uni.offNetworkStatusChange(e => { - console.log("移除监听成功", e); - }) - //恢复联网自动重新执行 - uniCloud.callFunction(callFunctionOption) - uni.offNetworkStatusChange(callBack); - } - } - uni.onNetworkStatusChange(callBack); - } - } - }); - }, - success: (e) => { - console.log(e); - const { - token, - tokenExpired - } = e.result - if (token && tokenExpired) { - store.commit('user/login', { - token, - tokenExpired - }) - } +import uniStarterConfig from '@/uni-starter.config.js'; +import store from '@/store' +//应用初始化页 +// #ifdef APP-PLUS +import checkUpdate from '@/uni_modules/uni-upgrade-center-app/utils/check-update'; +import callCheckVersion from '@/uni_modules/uni-upgrade-center-app/utils/call-check-version'; +import interceptorChooseImage from '@/uni_modules/json-interceptor-chooseImage/js_sdk/main.js'; +// #endif +const db = uniCloud.database() +export default async function() { + let loginConfig = uniStarterConfig.router.login + //清除有配置但设备环境不支持的登陆项 + // #ifdef APP-PLUS + await new Promise((callBack) => { + plus.oauth.getServices(oauthServices => { + loginConfig = loginConfig.filter(item => { + if (["univerify", "weixin", "apple"].includes(item)) { + let index = oauthServices.findIndex(e => e.id == item) + if (index == -1) { + return false + } else { + return oauthServices[index].nativeClient + } + } else { + return true + } + }) + if (loginConfig.includes('univerify')) { //一键登录 功能预登录 + uni.preLogin({ + provider: 'univerify', + complete: e => { + console.log(e); + } + }) + } + callBack() + }, err => { + console.error('获取服务供应商失败:' + JSON.stringify(err)); + }) + }) + // #endif + + //非app移除:一键登录、苹果登陆;h5移除微信登陆,如果你做微信公众号登陆需要将此行移除 + // #ifndef APP-PLUS + loginConfig = loginConfig.filter(item => { + return ![ + 'univerify', + 'apple', + // #ifdef H5 + 'weixin' + // #endif + ].includes(item) + }) + // #endif + + uniStarterConfig.router.login = loginConfig + + // uniStarterConfig挂载到getApp().globalData.config + setTimeout(() => { + getApp({ + allowDefault: true + }).globalData.config = uniStarterConfig; + }, 1) + + + // 初始化appVersion(仅app生效) + initAppVersion(); + + // #ifdef APP-PLUS + // 实现,路由拦截。当应用无访问摄像头/相册权限,引导跳到设置界面 + interceptorChooseImage() + // #endif + + + //clientDB的错误提示 + function onDBError({ + code, // 错误码详见https://uniapp.dcloud.net.cn/uniCloud/clientdb?id=returnvalue + message + }) { + console.log('onDBError', { + code, + message + }); + // 处理错误 + console.error(code, message); + if ([ + 'TOKEN_INVALID_INVALID_CLIENTID', + 'TOKEN_INVALID', + 'TOKEN_INVALID_TOKEN_EXPIRED', + 'TOKEN_INVALID_WRONG_TOKEN', + 'TOKEN_INVALID_ANONYMOUS_USER', + + ].includes(code)) { + uni.navigateTo({ + url: '/pages/ucenter/login-page/index/index' + }) + } + } + // 绑定clientDB错误事件 + db.on('error', onDBError) + + // 解绑clientDB错误事件 + //db.off('error', onDBError) + db.on('refreshToken', function({ + token, + tokenExpired + }) { + console.log('监听到clientDB的refreshToken', { + token, + tokenExpired + }); + store.commit('user/login', { + token, + tokenExpired + }) + }) + + const Debug = true; + //拦截器封装callFunction + let callFunctionOption; + uniCloud.addInterceptor('callFunction', { + async invoke(option) { + // #ifdef APP-PLUS + // 判断如果是执行登陆(无论是哪种登陆方式),就记录用户的相关设备id + if (option.name == 'uni-id-cf' && (option.data.action == 'register' || option.data.action + .slice(0, 5) == 'login')) { + let oaid = await new Promise((callBack, fail) => { + if (uni.getSystemInfoSync().platform == "android") { + plus.device.getOAID({ + success: function(e) { + callBack(e.oaid) + // console.log('getOAID success: '+JSON.stringify(e)); + }, + fail: function(e) { + callBack() + console.log('getOAID failed: ' + JSON.stringify(e)); + } + }); + } else { + callBack() + } + }) + + let imei = await new Promise((callBack, fail) => { + if (uni.getSystemInfoSync().platform == "android") { + plus.device.getInfo({ + success: function(e) { + callBack(e.imei) + // console.log('getOAID success: '+JSON.stringify(e)); + }, + fail: function(e) { + callBack() + console.log('getOAID failed: ' + JSON.stringify(e)); + } + }); + } else { + callBack() + } + }) + + let push_clientid = '', + idfa = plus.storage.getItem('idfa') || ''; //idfa有需要的用户在应用首次启动时自己获取存储到storage中 + + try { + push_clientid = plus.push.getClientInfo().clientid + } catch (e) { + uni.showModal({ + content: '获取推送标识失败。如果你的应用不需要推送功能,请注释掉本代码块', + showCancel: false, + confirmText: "好的" + }); + console.log(e) + } + + let deviceInfo = { + push_clientid, // 获取匿名设备标识符 + imei, + oaid, + idfa + } + console.log("重新登陆/注册,获取设备id", deviceInfo); + option.data.deviceInfo = deviceInfo + + // #ifndef H5 + //注册可能不仅仅走register接口,还有登陆并注册的接口 + option.data.inviteCode = await new Promise((callBack) => { + uni.getClipboardData({ + success: function(res) { + if (res.data.slice(0, 18) == 'uniInvitationCode:') { + let uniInvitationCode = res.data.slice(18, 38) + console.log('当前用户是其他用户推荐下载的,推荐者的code是:' + + uniInvitationCode); + // uni.showModal({ + // content: '当前用户是其他用户推荐下载的,推荐者的code是:'+uniInvitationCode, + // showCancel: false + // }); + callBack(uniInvitationCode) + //当前用户是其他用户推荐下载的。这里登记他的推荐者id 为当前用户的myInviteCode。判断如果是注册 + } else { + callBack(false) + } + }, + fail() { + callBack(false) + } + }); + }) + // #endif + } + // #endif + // console.log(JSON.stringify(option)); + callFunctionOption = option + }, + complete(e) { + // console.log(JSON.stringify(e)); + }, + fail(e) { // 失败回调拦截 + if (Debug) { + uni.showModal({ + content: JSON.stringify(e), + showCancel: false + }); + console.error(e); + } else { + uni.showModal({ + content: "系统错误请稍后再试!", + showCancel: false, + confirmText: "知道了" + }); + } + //如果执行错误,检查是否断网 + uni.getNetworkType({ + complete: res => { + // console.log(res); + if (res.networkType == 'none') { + uni.showToast({ + title: '手机网络异常', + icon: 'none' + }); + console.log('手机网络异常'); + let callBack = res => { + console.log(res); + if (res.isConnected) { + uni.showToast({ + title: '恢复联网自动重新执行', + icon: 'none' + }); + console.log(res.networkType, "恢复联网自动重新执行"); + uni.offNetworkStatusChange(e => { + console.log("移除监听成功", e); + }) + //恢复联网自动重新执行 + uniCloud.callFunction(callFunctionOption) + uni.offNetworkStatusChange(callBack); + } + } + uni.onNetworkStatusChange(callBack); + } + } + }); + }, + success: (e) => { + console.log(e); + const { + token, + tokenExpired + } = e.result + if (token && tokenExpired) { + store.commit('user/login', { + token, + tokenExpired + }) + } switch (e.result.code) { - case 403: - uni.navigateTo({ - url: "/pages/ucenter/login-page/index/index" - }) - break; - case 30203: - uni.navigateTo({ - url: "/pages/ucenter/login-page/index/index" - }) - break; - case 50101: - uni.showToast({ - title: e.result.msg, - icon: 'none', - duration: 2000 - }); - break; - default: - console.log('code的值是:' + e.result.code, '可以在上面添加case,自动处理响应体'); - break; + case 403: + uni.navigateTo({ + url: "/pages/ucenter/login-page/index/index" + }) + break; + case 30203: + uni.navigateTo({ + url: "/pages/ucenter/login-page/index/index" + }) + break; + case 50101: + uni.showToast({ + title: e.result.msg, + icon: 'none', + duration: 2000 + }); + break; + default: + console.log('code的值是:' + e.result.code, '可以在上面添加case,自动处理响应体'); + break; } switch (e.result.errCode){ @@ -306,151 +306,151 @@ export default async function() { break; default: break; - } - } - }) - - //自定义路由拦截 - const { - "router": { - needLogin, - visitor, - login - } - } = uniStarterConfig //需要登录的页面 - - let list = ["navigateTo", "redirectTo", "reLaunch", "switchTab"]; - list.forEach(item => { //用遍历的方式分别为,uni.navigateTo,uni.redirectTo,uni.reLaunch,uni.switchTab这4个路由方法添加拦截器 - uni.addInterceptor(item, { - invoke(e) { // 调用前拦截 - //获取用户的token - const token = uni.getStorageSync('uni_id_token'), - //token是否已失效 - tokenExpired = uni.getStorageSync('uni_id_token_expired') < Date.now(), - //获取要跳转的页面路径(url去掉"?"和"?"后的参数) - url = e.url.split('?')[0]; - //获取要前往的页面路径(即url去掉"?"和"?"后的参数) - const pages = getCurrentPages(); - if (!pages.length) { - console.log("首页启动调用了"); - return e - } - const fromUrl = pages[pages.length - 1].route; - - let inLoginPage = fromUrl.split('/')[2] == 'login-page' - - //控制登录优先级 - if ( //判断当前窗口是否为登陆页面,如果是则不重定向路由 - url == '/pages/ucenter/login-page/index/index' && - !inLoginPage - ) { - //一键登录(univerify)、账号(username)、验证码登录(短信smsCode) - if (login[0] == 'username') { - e.url = "/pages/ucenter/login-page/pwd-login/pwd-login" - } else { - if (e.url == url) { - e.url += '?' - } //添加参数之前判断是否带了`?`号如果没有就补上,因为当开发场景本身有参数的情况下是已经带了`?`号 - e.url += "type=" + login[0] - } - } else { - //拦截强制登录页面 - let pass = true - //pattern - if (needLogin) { - pass = needLogin.every((item) => { - if (typeof(item) == 'object' && item.pattern) { - return !item.pattern.test(url) - } - return url != item - }) - // console.log({pass}) - } - if (visitor && !inLoginPage) { - pass = visitor.some((item) => { - if (typeof(item) == 'object' && item.pattern) { - return item.pattern.test(url) - } - return url == item - }) - // console.log({pass}) - } - - if (!pass && (token == '' || tokenExpired)) { - uni.showToast({ - title: '请先登录', - icon: 'none' - }) - uni.navigateTo({ - url: "/pages/ucenter/login-page/index/index" - }) - return false - } - } - return e - }, - fail(err) { // 失败回调拦截 - console.log(err); - if (Debug) { - console.log(err); - uni.showModal({ - content: JSON.stringify(err), - showCancel: false - }); - } - } - }) - }) - - // #ifdef APP-PLUS - // 监听并提示设备网络状态变化 - uni.onNetworkStatusChange(res => { - console.log(res.isConnected); - console.log(res.networkType); - if (res.networkType != 'none') { - uni.showToast({ - title: '当前网络类型:' + res.networkType, - icon: 'none', - duration: 3000 - }) - } else { - uni.showToast({ - title: '网络类型:' + res.networkType, - icon: 'none', - duration: 3000 - }) - } - }); - // #endif - -} -/** - * // 初始化appVersion - */ -function initAppVersion() { - // #ifdef APP-PLUS - let appid = plus.runtime.appid; - plus.runtime.getProperty(appid, (wgtInfo) => { - let appVersion = plus.runtime; - let currentVersion = appVersion.versionCode > wgtInfo.versionCode ? appVersion : wgtInfo; - getApp({ - allowDefault: true - }).appVersion = { - ...currentVersion, - appid, - hasNew: false - } - // 检查更新小红点 - callCheckVersion().then(res => { - // console.log('检查是否有可以更新的版本', res); - if (res.result.code > 0) { - // 有新版本 - getApp({ - allowDefault: true - }).appVersion.hasNew = true; - } - }) - }); - // 检查更新 - // #endif + } + } + }) + + //自定义路由拦截 + const { + "router": { + needLogin, + visitor, + login + } + } = uniStarterConfig //需要登录的页面 + + let list = ["navigateTo", "redirectTo", "reLaunch", "switchTab"]; + list.forEach(item => { //用遍历的方式分别为,uni.navigateTo,uni.redirectTo,uni.reLaunch,uni.switchTab这4个路由方法添加拦截器 + uni.addInterceptor(item, { + invoke(e) { // 调用前拦截 + //获取用户的token + const token = uni.getStorageSync('uni_id_token'), + //token是否已失效 + tokenExpired = uni.getStorageSync('uni_id_token_expired') < Date.now(), + //获取要跳转的页面路径(url去掉"?"和"?"后的参数) + url = e.url.split('?')[0]; + //获取要前往的页面路径(即url去掉"?"和"?"后的参数) + const pages = getCurrentPages(); + if (!pages.length) { + console.log("首页启动调用了"); + return e + } + const fromUrl = pages[pages.length - 1].route; + + let inLoginPage = fromUrl.split('/')[2] == 'login-page' + + //控制登录优先级 + if ( //判断当前窗口是否为登陆页面,如果是则不重定向路由 + url == '/pages/ucenter/login-page/index/index' && + !inLoginPage + ) { + //一键登录(univerify)、账号(username)、验证码登录(短信smsCode) + if (login[0] == 'username') { + e.url = "/pages/ucenter/login-page/pwd-login/pwd-login" + } else { + if (e.url == url) { + e.url += '?' + } //添加参数之前判断是否带了`?`号如果没有就补上,因为当开发场景本身有参数的情况下是已经带了`?`号 + e.url += "type=" + login[0] + } + } else { + //拦截强制登录页面 + let pass = true + //pattern + if (needLogin) { + pass = needLogin.every((item) => { + if (typeof(item) == 'object' && item.pattern) { + return !item.pattern.test(url) + } + return url != item + }) + // console.log({pass}) + } + if (visitor) { + pass = visitor.some((item) => { + if (typeof(item) == 'object' && item.pattern) { + return item.pattern.test(url) + } + return url == item + }) + // console.log({pass}) + } + + if (!pass && (token == '' || tokenExpired)) { + uni.showToast({ + title: '请先登录', + icon: 'none' + }) + uni.navigateTo({ + url: "/pages/ucenter/login-page/index/index" + }) + return false + } + } + return e + }, + fail(err) { // 失败回调拦截 + console.log(err); + if (Debug) { + console.log(err); + uni.showModal({ + content: JSON.stringify(err), + showCancel: false + }); + } + } + }) + }) + + // #ifdef APP-PLUS + // 监听并提示设备网络状态变化 + uni.onNetworkStatusChange(res => { + console.log(res.isConnected); + console.log(res.networkType); + if (res.networkType != 'none') { + uni.showToast({ + title: '当前网络类型:' + res.networkType, + icon: 'none', + duration: 3000 + }) + } else { + uni.showToast({ + title: '网络类型:' + res.networkType, + icon: 'none', + duration: 3000 + }) + } + }); + // #endif + +} +/** + * // 初始化appVersion + */ +function initAppVersion() { + // #ifdef APP-PLUS + let appid = plus.runtime.appid; + plus.runtime.getProperty(appid, (wgtInfo) => { + let appVersion = plus.runtime; + let currentVersion = appVersion.versionCode > wgtInfo.versionCode ? appVersion : wgtInfo; + getApp({ + allowDefault: true + }).appVersion = { + ...currentVersion, + appid, + hasNew: false + } + // 检查更新小红点 + callCheckVersion().then(res => { + // console.log('检查是否有可以更新的版本', res); + if (res.result.code > 0) { + // 有新版本 + getApp({ + allowDefault: true + }).appVersion.hasNew = true; + } + }) + }); + // 检查更新 + // #endif } diff --git a/package.json b/package.json index bb78a484..f7c51cf2 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "id": "uni-starter", "displayName": "uni-starter", - "version": "1.1.4", + "version": "1.1.5", "description": "云端一体应用快速开发基本项目模版", "keywords": [ "login", diff --git a/pages/common/webview/webview.vue b/pages/common/webview/webview.vue index bbe7141c..5fa64b98 100644 --- a/pages/common/webview/webview.vue +++ b/pages/common/webview/webview.vue @@ -1,6 +1,6 @@ @@ -8,7 +8,7 @@ export default { onLoad({url,title}) { if(url.substring(0, 4) != 'http'){ - return uni.showModal({ + uni.showModal({ title:"错误", content: '不是一个有效的网站链接,'+'"'+url+'"', showCancel: false, @@ -17,10 +17,11 @@ uni.navigateBack() } }); - + title = "页面路径错误" + }else{ + console.log(url,title); + this.url = url; } - console.log(url,title); - this.url = url; if(title){ uni.setNavigationBarTitle({title}); } diff --git a/pages/list/list.nvue b/pages/list/list.nvue index 53ae47b2..fa53e5c0 100644 --- a/pages/list/list.nvue +++ b/pages/list/list.nvue @@ -72,11 +72,12 @@ } }, watch: { - keyword(keyword, oldValue) { + keyword(keyword, oldValue) { + let where = '"article_status" == 1 ' if (keyword) { - this.where = `/${keyword}/.test(title)`; + this.where = where + `/${keyword}/.test(title)`; } else { - this.where = ''; + this.where = where; } } }, diff --git a/uni-starter.config.js b/uni-starter.config.js index cec59759..4aee92f3 100644 --- a/uni-starter.config.js +++ b/uni-starter.config.js @@ -36,9 +36,11 @@ export default { "visitor" : [ "/",//注意入口页必须直接写 "/" {"pattern":/^\/pages\/list.*/}, //支持正则表达式 + {"pattern":/^\/pages\/ucenter\/login-page.*/}, + "/pages/common/webview/webview", "/pages/grid/grid", "/pages/ucenter/ucenter", - "/pages/ucenter/about/about", + "/pages/ucenter/guestbook/guestbook", "/pages/ucenter/guestbook/guestbook" ], /* diff --git a/uniCloud-aliyun/database/uni-id-users.schema.json b/uniCloud-aliyun/database/uni-id-users.schema.json index b1e9939f..c32b8289 100644 --- a/uniCloud-aliyun/database/uni-id-users.schema.json +++ b/uniCloud-aliyun/database/uni-id-users.schema.json @@ -1,6 +1,7 @@ { "bsonType": "object", "permission":{ + "read":true, "update":"doc._id == auth.uid" }, "required": [], -- GitLab