From bc3dcf0626514970bd2b59fd0087728b4905e4fe Mon Sep 17 00:00:00 2001 From: linju-json Date: Wed, 26 Jan 2022 15:57:57 +0800 Subject: [PATCH] =?UTF-8?q?-=20=E6=96=B0=E5=A2=9E=E9=80=BB=E8=BE=91:?= =?UTF-8?q?=E8=B0=83=E7=94=A8uni-id-cf=E7=9A=84logout=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E5=90=8E=E5=88=B7=E6=96=B0=E8=AE=BE=E5=A4=87=E4=BF=A1=E6=81=AF?= =?UTF-8?q?=E4=B8=ADtoken=E7=9A=84=E6=9C=89=E6=95=88=E6=9C=9F=20-=20?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=9F=90=E4=BA=9B=E6=83=85=E5=86=B5=E4=B8=8B?= =?UTF-8?q?=E5=89=8D=E7=AB=AF=E6=89=A7=E8=A1=8Clogout=E6=B2=A1=E8=B0=83?= =?UTF-8?q?=E7=94=A8uniID.logout=E7=9A=84=E9=97=AE=E9=A2=98=20-=20?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=9F=90=E4=BA=9B=E6=83=85=E5=86=B5=E4=B8=8B?= =?UTF-8?q?=E6=8A=A5push=5Fclientid=E6=9C=AA=E5=AE=9A=E4=B9=89=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- changelog.md | 4 ++ common/appInit.js | 41 +++++++++++-------- package.json | 2 +- .../settings/deactivate/deactivate.vue | 4 +- pages/ucenter/settings/settings.vue | 22 +++------- store/modules/user.js | 13 +++++- uni_modules/uni-id-cf/changelog.md | 2 + uni_modules/uni-id-cf/package.json | 2 +- .../cloudfunctions/uni-id-cf/index.js | 23 ++++++----- 9 files changed, 66 insertions(+), 47 deletions(-) diff --git a/changelog.md b/changelog.md index 097cf58..2aea518 100644 --- a/changelog.md +++ b/changelog.md @@ -1,3 +1,7 @@ +## 1.1.30(2022-01-26) +- 新增逻辑:调用uni-id-cf的logout接口后刷新设备信息中token的有效期 +- 修复某些情况下前端执行logout没调用uniID.logout的问题 +- 修复某些情况下报push_clientid未定义的问题 ## 1.1.29(2022-01-25) - 保存`uni_id_token`到`storage`改用异步方法,方便通过拦截器执行`token`更新后的操作 - 新增通过拦截器监听`uni_id_token`更新,调用云函数刷新刷新设备信息token有效期的API `renewDeviceTokenExpired` diff --git a/common/appInit.js b/common/appInit.js index 279adf5..ffddd6e 100644 --- a/common/appInit.js +++ b/common/appInit.js @@ -119,17 +119,30 @@ export default async function() { if (args.data && args.key == 'uni_id_token') { let oldToken = uni.getStorageSync('uni_id_token') if(oldToken.length){ - console.log('监听到token更新,就刷新push_clientid的有效期'); - uniCloud.callFunction({ - name:'uni-id-cf', - data:{ - "action": "renewDeviceTokenExpiredxpired", - "params": {push_clientid} - }, - complete: (e) => { - console.log(e); - } - }) + console.log('监听到token更新,就刷新push_clientid的有效期'); + // #ifdef APP-PLUS + let push_clientid; + try { + push_clientid = plus.push.getClientInfo().clientid + } catch (e) { + uni.showModal({ + content: '获取推送标识失败。如果你的应用不需要推送功能,请注释掉本代码块', + showCancel: false, + confirmText: "好的" + }); + console.log(e) + } + uniCloud.callFunction({ + name:'uni-id-cf', + data:{ + "action": "renewDeviceTokenExpiredxpired", + "params": {push_clientid} + }, + complete: (e) => { + console.log(e); + } + }) + // #endif } } // console.log('interceptor-complete', args) @@ -475,8 +488,7 @@ async function getDeviceInfo() { idfa = plus.storage.getItem('idfa') || '', //idfa有需要的用户在应用首次启动时自己获取存储到storage中 vendor = plus.device.vendor; try { - deviceInfo.push_clientid = uni.getStorageSync('cid') //先都走在线 - // deviceInfo.push_clientid = plus.push.getClientInfo().clientid + deviceInfo.push_clientid = plus.push.getClientInfo().clientid } catch (e) { uni.showModal({ content: '获取推送标识失败。如果你的应用不需要推送功能,请注释掉本代码块', @@ -492,8 +504,5 @@ async function getDeviceInfo() { vendor }); // #endif - // #ifndef APP-PLUS - deviceInfo.push_clientid = uni.getStorageSync('cid') - // #endif return deviceInfo } \ No newline at end of file diff --git a/package.json b/package.json index fd3f079..6f355d6 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "id": "uni-starter", "displayName": "uni-starter", - "version": "1.1.29", + "version": "1.1.30", "description": "云端一体应用快速开发基本项目模版", "keywords": [ "login", diff --git a/pages/ucenter/settings/deactivate/deactivate.vue b/pages/ucenter/settings/deactivate/deactivate.vue index e88cf44..09de453 100644 --- a/pages/ucenter/settings/deactivate/deactivate.vue +++ b/pages/ucenter/settings/deactivate/deactivate.vue @@ -23,7 +23,7 @@