| | |
| | | "version" : "0.0", |
| | | "configurations" : [ |
| | | { |
| | | "app-plus" : { |
| | | "launchtype" : "local" |
| | | }, |
| | | "default" : { |
| | | "launchtype" : "local" |
| | | }, |
| | | "h5" : { |
| | | "launchtype" : "local" |
| | | }, |
| | | "mp-weixin" : { |
| | | "launchtype" : "local" |
| | | }, |
| | | "type" : "uniCloud" |
| | | "app-plus" : |
| | | { |
| | | "launchtype" : "remote" |
| | | }, |
| | | "default" : |
| | | { |
| | | "launchtype" : "local" |
| | | }, |
| | | "h5" : |
| | | { |
| | | "launchtype" : "local" |
| | | }, |
| | | "mp-weixin" : |
| | | { |
| | | "launchtype" : "local" |
| | | }, |
| | | "type" : "uniCloud" |
| | | }, |
| | | { |
| | | "openVueDevtools" : true, |
| | |
| | | <view class="saleNum-box" v-if="items.monthSales!=''"> |
| | | å·²å®{{items.monthSales}} |
| | | </view> |
| | | |
| | | <!-- <view class="saleNum-box" v-if="items.shopName!=''"> |
| | | åºéºï¼{{items.shopName}} |
| | | </view> --> |
| | | </view> |
| | | <view class="shopname">{{items.shopName}}</view> |
| | | </view> |
| | | </view> |
| | | </view> |
| | |
| | | </script> |
| | | |
| | | <style lang="scss"> |
| | | .shopname{ |
| | | font-size: 11px; |
| | | display: flex; |
| | | align-items: flex-start; |
| | | width: 100%; |
| | | color: #999999; |
| | | margin: 2px 0; |
| | | |
| | | } |
| | | .items-container { |
| | | width: 346rpx; |
| | | height: 100%; |
| | |
| | | <view class="saleNum-content" v-if="items.monthSales!=''"> |
| | | å·²å®{{items.monthSales}} |
| | | </view> |
| | | |
| | | <view class="saleNum-content" v-if="items.shopName!=''"> |
| | | {{items.shopName}} |
| | | </view> |
| | | <view class="shopEnter-bar rowCen"> |
| | | <!-- <view class="storename"> |
| | | {{items.shopName}} |
| | |
| | | "name" : "大è¿å®", |
| | | "appid" : "__UNI__FC8858A", |
| | | "description" : "大è¿å®app", |
| | | "versionName" : "1.1.0", |
| | | "versionCode" : 110, |
| | | "versionName" : "1.1.1", |
| | | "versionCode" : 111, |
| | | "transformPx" : false, |
| | | /* 5+Appç¹æç¸å
³ */ |
| | | "app-plus" : { |
| | |
| | | "appid" : "wx275c371de3f6791e", |
| | | "appsecret" : "68af726473c8ee8c42d6a29fc0014fe4", |
| | | "UniversalLinks" : "https://verification.ushopvip.com/uni-universallinks/__UNI__FC8858A/" |
| | | } |
| | | }, |
| | | "univerify" : {} |
| | | }, |
| | | "maps" : { |
| | | "amap" : { |
| | |
| | | } |
| | | } |
| | | }, |
| | | // çº¿æ¥ |
| | | { |
| | | "path": "pages/rankinglist/xianbao", |
| | | "style": { |
| | | "navigationStyle": "custom", |
| | | "app-plus": { |
| | | "titleNView": false |
| | | } |
| | | } |
| | | }, |
| | | // è¶
级åç±» |
| | | /* { |
| | | "path": "pages/classify/classify", |
| | |
| | | "text": "ç¯æ¢æ¦" |
| | | }, |
| | | { |
| | | "pagePath": "pages/find/find", |
| | | "pagePath": "pages/rankinglist/xianbao", |
| | | "iconPath": "static/images/tabBar/find.png", |
| | | "selectedIconPath": "static/images/tabBar/findactive.png", |
| | | "text": "éé" |
| | | "text": "线æ¥" |
| | | }, |
| | | { |
| | | "pagePath": "pages/community/community", |
| | |
| | | } |
| | | }, |
| | | onLoad() { |
| | | this.getCategoryList(); |
| | | this.getPopBannerInfo(); |
| | | }, |
| | | onShow() { |
| | | if(!this.hasLogin){ |
| | | setTimeout(function(){ |
| | | |
| | | uni.reLaunch({ |
| | | url:"/pages/login/wxlogin" |
| | | }) |
| | | },3000); |
| | | },1000); |
| | | return; |
| | | } |
| | | var user= uni.getStorageSync('userInfo'); |
| | |
| | | uni.reLaunch({ |
| | | url:"/pages/login/wxlogin" |
| | | }) |
| | | },3000); |
| | | },1000); |
| | | return; |
| | | } |
| | | else |
| | | { |
| | | this.getCategoryList(); |
| | | this.getPopBannerInfo(); |
| | | } |
| | | }, |
| | | onShow() { |
| | | if(this.categoryList){ |
| | | this.getCategoryList(); |
| | | } |
| | |
| | | confirmText:'èç³»æ¨è人', |
| | | success:function(res) |
| | | { |
| | | that.isShowCode=res.cancel; |
| | | console.log(that.isShowCode) |
| | | if (res.confirm) { |
| | | that.isShowCode=true; |
| | | } else if (res.cancel) { |
| | | that.isShowCode=false; |
| | | } |
| | | } |
| | | }); |
| | | }, |
| | |
| | | <image class="logoIcon" src="../../static/images/mine/wxwhite.png" mode=""></image> |
| | | <view>微信ä¸é®ç»å½</view> |
| | | </view> |
| | | <view class="goaccount rowCenCen" @tap="goaccount()"> |
| | | <view v-if="isSupportMob" class="goaccount rowCenCen" @tap="mobileLogin()"> |
| | | <view>æ¬æºææºå·ä¸é®ç»å½/注å</view> |
| | | </view> |
| | | <view v-else class="goaccount rowCenCen" @tap="goaccount()"> |
| | | <view>ææºå·ç»å½/注å</view> |
| | | </view> |
| | | <view style="margin-top: 20px;" v-if="isother" @tap="goaccount()"> |
| | | ææºå·ç»å½/注å |
| | | </view> |
| | | |
| | | </view> |
| | | |
| | | <view class="bottom-fixed colCen"> |
| | |
| | | mapMutations |
| | | } from 'vuex'; |
| | | import titleBar from '../../components/backTitlebar.vue' |
| | | const univerifyManager = uni.getUniverifyManager(); |
| | | export default { |
| | | components: { |
| | | titleBar |
| | |
| | | appInfo: '', |
| | | ifPasslogin: false, |
| | | isread: false, |
| | | haswxlogin: false |
| | | haswxlogin: false, |
| | | isSupportMob:false, |
| | | isother:false |
| | | } |
| | | }, |
| | | onLoad() { |
| | |
| | | console.log(getApp().globalData.ifwt) |
| | | //this.haswxlogin = this.appInfo.iosExamine ? false : (getApp().globalData.ifwt == 1 ? true : false) |
| | | this.haswxlogin = getApp().globalData.ifwt == 1 ? true :false; |
| | | this.isSupportMoblie(); |
| | | }, |
| | | methods: { |
| | | ...mapMutations(['login']), |
| | |
| | | }) |
| | | } |
| | | }, |
| | | isSupportMoblie() |
| | | { |
| | | var that=this; |
| | | uni.preLogin({ |
| | | provider: 'univerify', |
| | | success(){ //é¢ç»å½æå |
| | | // æ¾ç¤ºä¸é®ç»å½é项 |
| | | that.isSupportMob=true; |
| | | }, |
| | | fail(res){ // é¢ç»å½å¤±è´¥ |
| | | // 䏿¾ç¤ºä¸é®ç»å½éé¡¹ï¼æç½®ç°ï¼ |
| | | // æ ¹æ®é误信æ¯å¤æå¤±è´¥åå ï¼å¦æéè¦å¯å°é误æäº¤ç»ç»è®¡æå¡å¨ |
| | | console.log(res) |
| | | console.log(res.errMsg) |
| | | } |
| | | }) |
| | | }, |
| | | doMobileLogin(mobRes) |
| | | { |
| | | var that=this; |
| | | uniCloud.callFunction({ |
| | | name: 'getPhoneNumber', // ä½ çäºå½æ°åç§° |
| | | data: { |
| | | 'access_token': mobRes.access_token, // 客æ·ç«¯ä¸é®ç»å½æ¥å£è¿åçaccess_token |
| | | 'openid': mobRes.openid // 客æ·ç«¯ä¸é®ç»å½æ¥å£è¿åçopenid |
| | | } |
| | | }).then(res => { |
| | | console.log(res) |
| | | that.targetToIndex(res.result.data); |
| | | // ç»å½æåï¼å¯ä»¥å
³éä¸é®ç»å½ææçé¢äº |
| | | univerifyManager.close(); |
| | | }).catch(err=>{ |
| | | // å¤çé误 |
| | | console.log(err) |
| | | uni.hideLoading(); |
| | | |
| | | that.$alert('è·åææºå·ç 失败ï¼è¯·ä½¿ç¨å
¶ä»æ¹å¼ç»å½') |
| | | |
| | | setTimeout(function(){ |
| | | univerifyManager.close(); |
| | | },2000); |
| | | |
| | | }) |
| | | }, |
| | | mobileLogin() |
| | | { |
| | | var that=this; |
| | | if (this.isread) { |
| | | univerifyManager.login({ |
| | | provider: 'univerify', |
| | | univerifyStyle: { // èªå®ä¹ç»å½æ¡æ ·å¼ |
| | | "fullScreen":false, |
| | | "authButton": |
| | | { |
| | | "normalColor":"#F73314", |
| | | "highlightColor":"#F73314" |
| | | } |
| | | |
| | | }, |
| | | success(res){ // ç»å½æå |
| | | console.log(res.authResult); |
| | | that.doMobileLogin(res.authResult); |
| | | }, |
| | | fail(res){ // ç»å½å¤±è´¥ |
| | | console.log(res) |
| | | if(res.errCode==30002) |
| | | {//忢ç»å½æ¹å¼ |
| | | that.isother=true; |
| | | } |
| | | else |
| | | { |
| | | that.$alert('è·åææºå·ç 失败ï¼è¯·ä½¿ç¨å
¶ä»æ¹å¼ç»å½') |
| | | setTimeout(function(){ |
| | | univerifyManager.close(); |
| | | },2000); |
| | | } |
| | | that.isother=true; |
| | | } |
| | | }) |
| | | |
| | | } |
| | | else |
| | | { |
| | | uni.showToast({ |
| | | title: '请å
é
读并åæãç¨æ·åè®®ãåãéç§åè®®ã', |
| | | icon: "none", |
| | | }) |
| | | } |
| | | |
| | | }, |
| | | targetToIndex(e) |
| | | { |
| | | var that = this; |
¶Ô±ÈÐÂÎļþ |
| | |
| | | <template> |
| | | <view> |
| | | <web-view :webview-styles="webviewStyles" :src="webviewUrl" @message='received'></web-view> |
| | | </view> |
| | | </template> |
| | | |
| | | <script> |
| | | //var wv |
| | | export default { |
| | | data() { |
| | | return { |
| | | webviewUrl: '', |
| | | webviewStyles: { |
| | | progress: { |
| | | color: '#EE1B14' |
| | | } |
| | | }, |
| | | } |
| | | }, |
| | | onLoad(options) { |
| | | if(!this.hasLogin){ |
| | | uni.reLaunch({ |
| | | url:"/pages/login/wxlogin" |
| | | }) |
| | | } |
| | | else{ |
| | | const value = uni.getStorageSync('userInfo'); |
| | | this.webviewUrl = encodeURI('http://dfgapp.ushopvip.com/html/xianbao.html?token='+value.token); |
| | | } |
| | | |
| | | }, |
| | | onReady() { |
| | | this.clearMuiBack(); |
| | | }, |
| | | methods: { |
| | | received(e) { |
| | | console.log(e.detail.data[0].type) |
| | | if(e.detail.data[0].type=='getToken'){ |
| | | const token = uni.getStorageSync('userInfo').token; |
| | | var currentWebview = this.$scope.$getAppWebview() |
| | | var wv = currentWebview.children()[0] |
| | | wv.evalJS('localStorage.setItem("ZZTOKEN",' + JSON.stringify(token) + ')'); |
| | | } |
| | | }, |
| | | |
| | | // å
³émuiè¿å |
| | | clearMuiBack() { |
| | | // #ifdef APP-PLUS |
| | | var currentWebview = this.$scope.$getAppWebview().children()[0]; |
| | | //ç嬿³¨å
¥çjs |
| | | currentWebview.addEventListener("loaded", function() { |
| | | currentWebview.evalJS("mui.init({keyEventBind: {backbutton: false }});"); |
| | | }); |
| | | // #endif |
| | | }, |
| | | |
| | | }, |
| | | onNavigationBarButtonTap(e) { |
| | | // #ifdef APP-PLUS |
| | | const currentWebview = this.$scope.$getAppWebview(); //æ¤å¯¹è±¡ç¸å½äºhtml5pluséçplus.webview.currentWebview()ãå¨uni-appévue页é¢ç´æ¥ä½¿ç¨plus.webview.currentWebview()æ æï¼év3ç¼è¯æ¨¡å¼ä½¿ç¨this.$mp.page.$getAppWebview() |
| | | var wv = currentWebview.children()[0] |
| | | wv.reload(); |
| | | // #endif |
| | | console.log(JSON.stringify(e)) |
| | | }, |
| | | } |
| | | </script> |
| | | |
| | | <style> |
| | | |
| | | </style> |
| | |
| | | }).then(e => { |
| | | if (e.code != 0) return that.$alert(e.msg) |
| | | uni.stopPullDownRefresh(); |
| | | console.log(e.data) |
| | | var res = e.data; |
| | | if (res.list.length < 10) { |
| | | that.canloadmore = false |
¶Ô±ÈÐÂÎļþ |
| | |
| | | // æ¬æä»¶ä¸çjsonå
容å°å¨äºå½æ°ãè¿è¡ãæ¶ä½ä¸ºåæ°ä¼ ç»äºå½æ°ã |
| | | // é
ç½®æç¨åèï¼https://uniapp.dcloud.net.cn/uniCloud/rundebug.html#runparam |
| | | { |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | 'use strict'; |
| | | exports.main = async (event, context) => { |
| | | // eventéå
å«ç客æ·ç«¯æäº¤çåæ° |
| | | const res = await uniCloud.getPhoneNumber({ |
| | | appid: '__UNI__FC8858A', // æ¿æ¢æèªå·±å¼éä¸é®ç»å½çåºç¨çDCloud appid |
| | | provider: 'univerify', |
| | | apiKey: 'df2247e74aa8dae4f9f26e7bbd3d2cc5', // å¨å¼åè
ä¸å¿å¼éæå¡å¹¶è·åapiKey |
| | | apiSecret: '6dbc847c9605c8bb5ed8a9afa4e72ceb', // å¨å¼åè
ä¸å¿å¼éæå¡å¹¶è·åapiSecret |
| | | access_token: event.access_token, |
| | | openid: event.openid |
| | | }) |
| | | if(!res.success) |
| | | { |
| | | return { |
| | | code:-1, |
| | | msg:'è·åææºå·å¤±è´¥' |
| | | } |
| | | } |
| | | var apiUrl='http://dfgapp.ushopvip.com/api/user/mobilelogin'; |
| | | const apiRes = await uniCloud.httpclient.request(apiUrl, { |
| | | method: 'POST', |
| | | data: { |
| | | mobile: res.phoneNumber, |
| | | captcha:'000', |
| | | ismobouth:true |
| | | }, |
| | | contentType: 'json', // æå®ä»¥application/jsonåédataå
çæ°æ® |
| | | dataType: 'json' // æå®è¿åå¼ä¸ºjsonæ ¼å¼ï¼èªå¨è¿è¡parse |
| | | }) |
| | | //console.log(res); // reséå
嫿æºå· |
| | | // æ§è¡ç¨æ·ä¿¡æ¯å
¥åºçæä½ï¼æ£å¸¸æ
åµä¸ä¸è¦æå®æ´ææºå·è¿åç»å端 |
| | | // å¦ææ°æ®åºå¨uniCloudä¸ï¼å¯ä»¥ç´æ¥å
¥åº |
| | | // å¦ææ°æ®åºä¸å¨uniCloudä¸ï¼å¯ä»¥éè¿ uniCloud.httpclient APIï¼å°ææºå·éè¿httpæ¹å¼ä¼ éç»å
¶ä»æå¡å¨çæ¥å£ï¼è¯¦è§ï¼https://uniapp.dcloud.net.cn/uniCloud/cf-functions?id=httpclient |
| | | return apiRes |
| | | }; |
¶Ô±ÈÐÂÎļþ |
| | |
| | | { |
| | | "name": "getPhoneNumber", |
| | | "dependencies": {}, |
| | | "extensions": { |
| | | "uni-cloud-jql": {} |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | ## 0.0.3ï¼2022-11-11ï¼ |
| | | - ä¿®å¤ config æ¹æ³è·åæ ¹èç¹ä¸ºæ°ç»æ ¼å¼é
ç½®æ¶é误ç转å为äºå¯¹è±¡çBug |
| | | ## 0.0.2ï¼2021-04-16ï¼ |
| | | - ä¿®æ¹æä»¶packageä¿¡æ¯ |
| | | ## 0.0.1ï¼2021-03-15ï¼ |
| | | - åå§åé¡¹ç® |
¶Ô±ÈÐÂÎļþ |
| | |
| | | { |
| | | "id": "uni-config-center", |
| | | "displayName": "uni-config-center", |
| | | "version": "0.0.3", |
| | | "description": "uniCloud é
ç½®ä¸å¿", |
| | | "keywords": [ |
| | | "é
ç½®", |
| | | "é
ç½®ä¸å¿" |
| | | ], |
| | | "repository": "", |
| | | "engines": { |
| | | "HBuilderX": "^3.1.0" |
| | | }, |
| | | "dcloudext": { |
| | | "sale": { |
| | | "regular": { |
| | | "price": "0.00" |
| | | }, |
| | | "sourcecode": { |
| | | "price": "0.00" |
| | | } |
| | | }, |
| | | "contact": { |
| | | "qq": "" |
| | | }, |
| | | "declaration": { |
| | | "ads": "æ ", |
| | | "data": "æ ", |
| | | "permissions": "æ " |
| | | }, |
| | | "npmurl": "", |
| | | "type": "unicloud-template-function" |
| | | }, |
| | | "directories": { |
| | | "example": "../../../scripts/dist" |
| | | }, |
| | | "uni_modules": { |
| | | "dependencies": [], |
| | | "encrypt": [], |
| | | "platforms": { |
| | | "cloud": { |
| | | "tcb": "y", |
| | | "aliyun": "y" |
| | | }, |
| | | "client": { |
| | | "App": { |
| | | "app-vue": "u", |
| | | "app-nvue": "u" |
| | | }, |
| | | "H5-mobile": { |
| | | "Safari": "u", |
| | | "Android Browser": "u", |
| | | "微信æµè§å¨(Android)": "u", |
| | | "QQæµè§å¨(Android)": "u" |
| | | }, |
| | | "H5-pc": { |
| | | "Chrome": "u", |
| | | "IE": "u", |
| | | "Edge": "u", |
| | | "Firefox": "u", |
| | | "Safari": "u" |
| | | }, |
| | | "å°ç¨åº": { |
| | | "微信": "u", |
| | | "é¿é": "u", |
| | | "ç¾åº¦": "u", |
| | | "åèè·³å¨": "u", |
| | | "QQ": "u" |
| | | }, |
| | | "å¿«åºç¨": { |
| | | "å为": "u", |
| | | "èç": "u" |
| | | }, |
| | | "Vue": { |
| | | "vue2": "y", |
| | | "vue3": "u" |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | # 为ä»ä¹ä½¿ç¨uni-config-center |
| | | |
| | | å®é
å¼åä¸å¾å¤æä»¶éè¦é
ç½®æä»¶æå¯ä»¥æ£å¸¸è¿è¡ï¼å¦ææ¯ä¸ªæä»¶é½åç¬è¿è¡é
ç½®çè¯å°±ä¼äº§çä¸é¢è¿æ ·çç®å½ç»æ |
| | | |
| | | ```bash |
| | | cloudfunctions |
| | | ââââââcommon å
Œ
±æ¨¡å |
| | | ââplugin-a // æä»¶A对åºçç®å½ |
| | | â ââindex.js |
| | | â ââconfig.json // plugin-a对åºçé
ç½®æä»¶ |
| | | â ââother-file.cert // plugin-aä¾èµçå
¶ä»æä»¶ |
| | | ââplugin-b // plugin-b对åºçç®å½ |
| | | ââindex.js |
| | | ââconfig.json // plugin-b对åºçé
ç½®æä»¶ |
| | | ``` |
| | | |
| | | å设æä»¶ä½è
è¦åå¸ä¸ä¸ªé¡¹ç®æ¨¡æ¿ï¼éé¢ä½¿ç¨äºå¾å¤éè¦é
ç½®çæä»¶ï¼æ 论æ¯ä½è
åå¸è¿æ¯ç¨æ·ä½¿ç¨é½æ¯ä¸ä¸ªå¤§éº»ç¦ã |
| | | |
| | | uni-config-centerå°±æ¯ç¨äºç»ä¸ç®¡çè¿äºé
ç½®æä»¶çï¼ä½¿ç¨uni-config-centeråçç®å½ç»æå¦ä¸ |
| | | |
| | | ```bash |
| | | cloudfunctions |
| | | ââââââcommon å
Œ
±æ¨¡å |
| | | ââplugin-a // æä»¶A对åºçç®å½ |
| | | â ââindex.js |
| | | ââplugin-b // plugin-b对åºçç®å½ |
| | | â ââindex.js |
| | | ââuni-config-center |
| | | ââindex.js // config-centerå
¥å£æä»¶ |
| | | ââplugin-a |
| | | â ââconfig.json // plugin-a对åºçé
ç½®æä»¶ |
| | | â ââother-file.cert // plugin-aä¾èµçå
¶ä»æä»¶ |
| | | ââplugin-b |
| | | ââconfig.json // plugin-b对åºçé
ç½®æä»¶ |
| | | ``` |
| | | |
| | | 使ç¨uni-config-centeråçä¼å¿ |
| | | |
| | | - é
ç½®æä»¶ç»ä¸ç®¡çï¼å离æä»¶ä¸»ä½åé
置信æ¯ï¼æ´æ°æä»¶æ´æ¹ä¾¿ |
| | | - æ¯æå¯¹config.json设置schemaï¼æä»¶ä½¿ç¨è
å¨HBuilderXå
ç¼åconfig.jsonæä»¶æ¶ä¼ææ´å¥½çæç¤ºï¼åç»HBuilderX伿便¯æï¼ |
| | | |
| | | # ç¨æ³ |
| | | |
| | | å¨è¦ä½¿ç¨uni-config-centerçå
Œ
±æ¨¡åæäºå½æ°å
å¼å
¥uni-config-centerä¾èµï¼è¯·åèï¼[使ç¨å
Œ
±æ¨¡å](https://uniapp.dcloud.net.cn/uniCloud/cf-common) |
| | | |
| | | ```js |
| | | const createConfig = require('uni-config-center') |
| | | |
| | | const uniIdConfig = createConfig({ |
| | | pluginId: 'uni-id', // æä»¶id |
| | | defaultConfig: { // é»è®¤é
ç½® |
| | | tokenExpiresIn: 7200, |
| | | tokenExpiresThreshold: 600, |
| | | }, |
| | | customMerge: function(defaultConfig, userConfig) { // èªå®ä¹é»è®¤é
ç½®åç¨æ·é
ç½®çåå¹¶è§åï¼ä¸è®¾ç½®çæ
åµä¾ ä¼å¯¹é»è®¤é
ç½®åç¨æ·é
ç½®è¿è¡æ·±åº¦åå¹¶ |
| | | // defaudltConfig é»è®¤é
ç½® |
| | | // userConfig ç¨æ·é
ç½® |
| | | return Object.assign(defaultConfig, userConfig) |
| | | } |
| | | }) |
| | | |
| | | |
| | | // 以å¦ä¸é
ç½®ä¸ºä¾ |
| | | // { |
| | | // "tokenExpiresIn": 7200, |
| | | // "passwordErrorLimit": 6, |
| | | // "bindTokenToDevice": false, |
| | | // "passwordErrorRetryTime": 3600, |
| | | // "app-plus": { |
| | | // "tokenExpiresIn": 2592000 |
| | | // }, |
| | | // "service": { |
| | | // "sms": { |
| | | // "codeExpiresIn": 300 |
| | | // } |
| | | // } |
| | | // } |
| | | |
| | | // è·åé
ç½® |
| | | uniIdConfig.config() // è·åå
¨é¨é
ç½®ï¼æ³¨æï¼uni-config-centerå
ä¸åå¨å¯¹åºæä»¶ç®å½æ¶ä¼è¿å空对象 |
| | | uniIdConfig.config('tokenExpiresIn') // æå®é®å¼è·åé
ç½®ï¼è¿åï¼7200 |
| | | uniIdConfig.config('service.sms.codeExpiresIn') // æå®é®å¼è·åé
ç½®ï¼è¿åï¼300 |
| | | uniIdConfig.config('tokenExpiresThreshold', 600) // æå®é®å¼è·åé
ç½®ï¼å¦æä¸åå¨ååä¼ å
¥çé»è®¤å¼ï¼è¿åï¼600 |
| | | |
| | | // è·åæä»¶ç»å¯¹è·¯å¾ |
| | | uniIdConfig.resolve('custom-token.js') // è·åuni-config-center/uni-id/custom-token.jsæä»¶çè·¯å¾ |
| | | |
| | | // å¼ç¨æä»¶ï¼requireï¼ |
| | | uniIDConfig.requireFile('custom-token.js') // 使ç¨requireæ¹å¼å¼ç¨uni-config-center/uni-id/custom-token.jsæä»¶ãæä»¶ä¸å卿¶è¿åundefinedï¼æä»¶å
æå
¶ä»é误导è´require失败æ¶ä¼æåºé误ã |
| | | |
| | | // 夿æ¯å¦å
嫿æä»¶ |
| | | uniIDConfig.hasFile('custom-token.js') // é
ç½®ç®å½æ¯å¦å
嫿æä»¶ï¼true: æä»¶åå¨ï¼false: æä»¶ä¸åå¨ |
| | | ``` |
¶Ô±ÈÐÂÎļþ |
| | |
| | | "use strict";var t=require("fs"),r=require("path");function e(t){return t&&"object"==typeof t&&"default"in t?t:{default:t}}var n=e(t),o=e(r),i="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};var u=function(t){var r={exports:{}};return t(r,r.exports),r.exports}((function(t,r){var e="__lodash_hash_undefined__",n=9007199254740991,o="[object Arguments]",u="[object Function]",c="[object Object]",a=/^\[object .+?Constructor\]$/,f=/^(?:0|[1-9]\d*)$/,s={};s["[object Float32Array]"]=s["[object Float64Array]"]=s["[object Int8Array]"]=s["[object Int16Array]"]=s["[object Int32Array]"]=s["[object Uint8Array]"]=s["[object Uint8ClampedArray]"]=s["[object Uint16Array]"]=s["[object Uint32Array]"]=!0,s[o]=s["[object Array]"]=s["[object ArrayBuffer]"]=s["[object Boolean]"]=s["[object DataView]"]=s["[object Date]"]=s["[object Error]"]=s[u]=s["[object Map]"]=s["[object Number]"]=s[c]=s["[object RegExp]"]=s["[object Set]"]=s["[object String]"]=s["[object WeakMap]"]=!1;var l="object"==typeof i&&i&&i.Object===Object&&i,h="object"==typeof self&&self&&self.Object===Object&&self,p=l||h||Function("return this")(),_=r&&!r.nodeType&&r,v=_&&t&&!t.nodeType&&t,d=v&&v.exports===_,y=d&&l.process,g=function(){try{var t=v&&v.require&&v.require("util").types;return t||y&&y.binding&&y.binding("util")}catch(t){}}(),b=g&&g.isTypedArray;function j(t,r,e){switch(e.length){case 0:return t.call(r);case 1:return t.call(r,e[0]);case 2:return t.call(r,e[0],e[1]);case 3:return t.call(r,e[0],e[1],e[2])}return t.apply(r,e)}var w,O,m,A=Array.prototype,z=Function.prototype,M=Object.prototype,x=p["__core-js_shared__"],C=z.toString,F=M.hasOwnProperty,U=(w=/[^.]+$/.exec(x&&x.keys&&x.keys.IE_PROTO||""))?"Symbol(src)_1."+w:"",S=M.toString,I=C.call(Object),P=RegExp("^"+C.call(F).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),T=d?p.Buffer:void 0,q=p.Symbol,E=p.Uint8Array,$=T?T.allocUnsafe:void 0,D=(O=Object.getPrototypeOf,m=Object,function(t){return O(m(t))}),k=Object.create,B=M.propertyIsEnumerable,N=A.splice,L=q?q.toStringTag:void 0,R=function(){try{var t=vt(Object,"defineProperty");return t({},"",{}),t}catch(t){}}(),G=T?T.isBuffer:void 0,V=Math.max,W=Date.now,H=vt(p,"Map"),J=vt(Object,"create"),K=function(){function t(){}return function(r){if(!xt(r))return{};if(k)return k(r);t.prototype=r;var e=new t;return t.prototype=void 0,e}}();function Q(t){var r=-1,e=null==t?0:t.length;for(this.clear();++r<e;){var n=t[r];this.set(n[0],n[1])}}function X(t){var r=-1,e=null==t?0:t.length;for(this.clear();++r<e;){var n=t[r];this.set(n[0],n[1])}}function Y(t){var r=-1,e=null==t?0:t.length;for(this.clear();++r<e;){var n=t[r];this.set(n[0],n[1])}}function Z(t){var r=this.__data__=new X(t);this.size=r.size}function tt(t,r){var e=Ot(t),n=!e&&wt(t),o=!e&&!n&&At(t),i=!e&&!n&&!o&&Ft(t),u=e||n||o||i,c=u?function(t,r){for(var e=-1,n=Array(t);++e<t;)n[e]=r(e);return n}(t.length,String):[],a=c.length;for(var f in t)!r&&!F.call(t,f)||u&&("length"==f||o&&("offset"==f||"parent"==f)||i&&("buffer"==f||"byteLength"==f||"byteOffset"==f)||dt(f,a))||c.push(f);return c}function rt(t,r,e){(void 0!==e&&!jt(t[r],e)||void 0===e&&!(r in t))&&ot(t,r,e)}function et(t,r,e){var n=t[r];F.call(t,r)&&jt(n,e)&&(void 0!==e||r in t)||ot(t,r,e)}function nt(t,r){for(var e=t.length;e--;)if(jt(t[e][0],r))return e;return-1}function ot(t,r,e){"__proto__"==r&&R?R(t,r,{configurable:!0,enumerable:!0,value:e,writable:!0}):t[r]=e}Q.prototype.clear=function(){this.__data__=J?J(null):{},this.size=0},Q.prototype.delete=function(t){var r=this.has(t)&&delete this.__data__[t];return this.size-=r?1:0,r},Q.prototype.get=function(t){var r=this.__data__;if(J){var n=r[t];return n===e?void 0:n}return F.call(r,t)?r[t]:void 0},Q.prototype.has=function(t){var r=this.__data__;return J?void 0!==r[t]:F.call(r,t)},Q.prototype.set=function(t,r){var n=this.__data__;return this.size+=this.has(t)?0:1,n[t]=J&&void 0===r?e:r,this},X.prototype.clear=function(){this.__data__=[],this.size=0},X.prototype.delete=function(t){var r=this.__data__,e=nt(r,t);return!(e<0)&&(e==r.length-1?r.pop():N.call(r,e,1),--this.size,!0)},X.prototype.get=function(t){var r=this.__data__,e=nt(r,t);return e<0?void 0:r[e][1]},X.prototype.has=function(t){return nt(this.__data__,t)>-1},X.prototype.set=function(t,r){var e=this.__data__,n=nt(e,t);return n<0?(++this.size,e.push([t,r])):e[n][1]=r,this},Y.prototype.clear=function(){this.size=0,this.__data__={hash:new Q,map:new(H||X),string:new Q}},Y.prototype.delete=function(t){var r=_t(this,t).delete(t);return this.size-=r?1:0,r},Y.prototype.get=function(t){return _t(this,t).get(t)},Y.prototype.has=function(t){return _t(this,t).has(t)},Y.prototype.set=function(t,r){var e=_t(this,t),n=e.size;return e.set(t,r),this.size+=e.size==n?0:1,this},Z.prototype.clear=function(){this.__data__=new X,this.size=0},Z.prototype.delete=function(t){var r=this.__data__,e=r.delete(t);return this.size=r.size,e},Z.prototype.get=function(t){return this.__data__.get(t)},Z.prototype.has=function(t){return this.__data__.has(t)},Z.prototype.set=function(t,r){var e=this.__data__;if(e instanceof X){var n=e.__data__;if(!H||n.length<199)return n.push([t,r]),this.size=++e.size,this;e=this.__data__=new Y(n)}return e.set(t,r),this.size=e.size,this};var it,ut=function(t,r,e){for(var n=-1,o=Object(t),i=e(t),u=i.length;u--;){var c=i[it?u:++n];if(!1===r(o[c],c,o))break}return t};function ct(t){return null==t?void 0===t?"[object Undefined]":"[object Null]":L&&L in Object(t)?function(t){var r=F.call(t,L),e=t[L];try{t[L]=void 0;var n=!0}catch(t){}var o=S.call(t);n&&(r?t[L]=e:delete t[L]);return o}(t):function(t){return S.call(t)}(t)}function at(t){return Ct(t)&&ct(t)==o}function ft(t){return!(!xt(t)||function(t){return!!U&&U in t}(t))&&(zt(t)?P:a).test(function(t){if(null!=t){try{return C.call(t)}catch(t){}try{return t+""}catch(t){}}return""}(t))}function st(t){if(!xt(t))return function(t){var r=[];if(null!=t)for(var e in Object(t))r.push(e);return r}(t);var r=yt(t),e=[];for(var n in t)("constructor"!=n||!r&&F.call(t,n))&&e.push(n);return e}function lt(t,r,e,n,o){t!==r&&ut(r,(function(i,u){if(o||(o=new Z),xt(i))!function(t,r,e,n,o,i,u){var a=gt(t,e),f=gt(r,e),s=u.get(f);if(s)return void rt(t,e,s);var l=i?i(a,f,e+"",t,r,u):void 0,h=void 0===l;if(h){var p=Ot(f),_=!p&&At(f),v=!p&&!_&&Ft(f);l=f,p||_||v?Ot(a)?l=a:Ct(j=a)&&mt(j)?l=function(t,r){var e=-1,n=t.length;r||(r=Array(n));for(;++e<n;)r[e]=t[e];return r}(a):_?(h=!1,l=function(t,r){if(r)return t.slice();var e=t.length,n=$?$(e):new t.constructor(e);return t.copy(n),n}(f,!0)):v?(h=!1,d=f,y=!0?(g=d.buffer,b=new g.constructor(g.byteLength),new E(b).set(new E(g)),b):d.buffer,l=new d.constructor(y,d.byteOffset,d.length)):l=[]:function(t){if(!Ct(t)||ct(t)!=c)return!1;var r=D(t);if(null===r)return!0;var e=F.call(r,"constructor")&&r.constructor;return"function"==typeof e&&e instanceof e&&C.call(e)==I}(f)||wt(f)?(l=a,wt(a)?l=function(t){return function(t,r,e,n){var o=!e;e||(e={});var i=-1,u=r.length;for(;++i<u;){var c=r[i],a=n?n(e[c],t[c],c,e,t):void 0;void 0===a&&(a=t[c]),o?ot(e,c,a):et(e,c,a)}return e}(t,Ut(t))}(a):xt(a)&&!zt(a)||(l=function(t){return"function"!=typeof t.constructor||yt(t)?{}:K(D(t))}(f))):h=!1}var d,y,g,b;var j;h&&(u.set(f,l),o(l,f,n,i,u),u.delete(f));rt(t,e,l)}(t,r,u,e,lt,n,o);else{var a=n?n(gt(t,u),i,u+"",t,r,o):void 0;void 0===a&&(a=i),rt(t,u,a)}}),Ut)}function ht(t,r){return bt(function(t,r,e){return r=V(void 0===r?t.length-1:r,0),function(){for(var n=arguments,o=-1,i=V(n.length-r,0),u=Array(i);++o<i;)u[o]=n[r+o];o=-1;for(var c=Array(r+1);++o<r;)c[o]=n[o];return c[r]=e(u),j(t,this,c)}}(t,r,Pt),t+"")}var pt=R?function(t,r){return R(t,"toString",{configurable:!0,enumerable:!1,value:(e=r,function(){return e}),writable:!0});var e}:Pt;function _t(t,r){var e,n,o=t.__data__;return("string"==(n=typeof(e=r))||"number"==n||"symbol"==n||"boolean"==n?"__proto__"!==e:null===e)?o["string"==typeof r?"string":"hash"]:o.map}function vt(t,r){var e=function(t,r){return null==t?void 0:t[r]}(t,r);return ft(e)?e:void 0}function dt(t,r){var e=typeof t;return!!(r=null==r?n:r)&&("number"==e||"symbol"!=e&&f.test(t))&&t>-1&&t%1==0&&t<r}function yt(t){var r=t&&t.constructor;return t===("function"==typeof r&&r.prototype||M)}function gt(t,r){if(("constructor"!==r||"function"!=typeof t[r])&&"__proto__"!=r)return t[r]}var bt=function(t){var r=0,e=0;return function(){var n=W(),o=16-(n-e);if(e=n,o>0){if(++r>=800)return arguments[0]}else r=0;return t.apply(void 0,arguments)}}(pt);function jt(t,r){return t===r||t!=t&&r!=r}var wt=at(function(){return arguments}())?at:function(t){return Ct(t)&&F.call(t,"callee")&&!B.call(t,"callee")},Ot=Array.isArray;function mt(t){return null!=t&&Mt(t.length)&&!zt(t)}var At=G||function(){return!1};function zt(t){if(!xt(t))return!1;var r=ct(t);return r==u||"[object GeneratorFunction]"==r||"[object AsyncFunction]"==r||"[object Proxy]"==r}function Mt(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=n}function xt(t){var r=typeof t;return null!=t&&("object"==r||"function"==r)}function Ct(t){return null!=t&&"object"==typeof t}var Ft=b?function(t){return function(r){return t(r)}}(b):function(t){return Ct(t)&&Mt(t.length)&&!!s[ct(t)]};function Ut(t){return mt(t)?tt(t,!0):st(t)}var St,It=(St=function(t,r,e){lt(t,r,e)},ht((function(t,r){var e=-1,n=r.length,o=n>1?r[n-1]:void 0,i=n>2?r[2]:void 0;for(o=St.length>3&&"function"==typeof o?(n--,o):void 0,i&&function(t,r,e){if(!xt(e))return!1;var n=typeof r;return!!("number"==n?mt(e)&&dt(r,e.length):"string"==n&&r in e)&&jt(e[r],t)}(r[0],r[1],i)&&(o=n<3?void 0:o,n=1),t=Object(t);++e<n;){var u=r[e];u&&St(t,u,e,o)}return t})));function Pt(t){return t}t.exports=It}));const c=Object.prototype.hasOwnProperty,a=(t,r)=>c.call(t,r);class f{constructor({pluginId:t,defaultConfig:r={},customMerge:e,root:n}){this.pluginId=t,this.defaultConfig=r,this.pluginConfigPath=o.default.resolve(n||__dirname,t),this.customMerge=e,this._config=void 0}resolve(t){return o.default.resolve(this.pluginConfigPath,t)}hasFile(t){return n.default.existsSync(this.resolve(t))}requireFile(t){try{return require(this.resolve(t))}catch(t){if("MODULE_NOT_FOUND"===t.code)return;throw t}}_getUserConfig(){return this.requireFile("config.json")}config(t,r){if(!this._config){const t=this._getUserConfig();this._config=Array.isArray(t)?t:(this.customMerge||u)(this.defaultConfig,t)}let e=this._config;return t?function(t,r,e){if("number"==typeof r)return t[r];if("symbol"==typeof r)return a(t,r)?t[r]:e;const n="string"!=typeof(o=r)?o:o.split(".").reduce(((t,r)=>(r.split(/\[([^}]+)\]/g).forEach((r=>r&&t.push(r))),t)),[]);var o;let i=t;for(let t=0;t<n.length;t++){const r=n[t];if(!a(i,r))return e;i=i[r]}return i}(e,t,r):e}}const s=new class{constructor(){this._configMap=new Map}plugin({pluginId:t,defaultConfig:r,customMerge:e,root:n=__dirname,cache:o=!0}){if(this._configMap.has(t)&&o)return this._configMap.get(t);const i=new f({pluginId:t,defaultConfig:r,customMerge:e,root:n});return o&&this._configMap.set(t,i),i}};var l=s.plugin.bind(s);module.exports=l; |
¶Ô±ÈÐÂÎļþ |
| | |
| | | { |
| | | "name": "uni-config-center", |
| | | "version": "0.0.3", |
| | | "description": "é
ç½®ä¸å¿", |
| | | "main": "index.js", |
| | | "keywords": [], |
| | | "author": "DCloud", |
| | | "license": "Apache-2.0" |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | ## 1.0.16ï¼2023-04-25ï¼ |
| | | - æ°å¢maxTokenLengthé
ç½®ï¼ç¨äºéå¶æ°æ®åºç¨æ·è®°å½tokenæ°ç»çæå¤§é¿åº¦ |
| | | ## 1.0.15ï¼2023-04-06ï¼ |
| | | - ä¿®å¤é¨åè¯è¨å½é
ååºéçBug |
| | | ## 1.0.14ï¼2023-03-07ï¼ |
| | | - ä¿®å¤ adminç¨æ·å
å«å
¶ä»è§è²æ¶æªå
å«å¨tokençBug |
| | | ## 1.0.13ï¼2022-07-21ï¼ |
| | | - ä¿®å¤ å建tokenæ¶æªä¼ è§è²æéä¿¡æ¯çæçtoken䏿£ç¡®çbug |
| | | ## 1.0.12ï¼2022-07-15ï¼ |
| | | - æå䏿§çæ¬uni-idçå
¼å®¹æ§ï¼è¡¥å
读åé
ç½®æä»¶æ¶åéå¹³å°app-plusãh5ï¼ï¼ä½æ¯ä»æ¨èä½¿ç¨æ°å¹³å°åè¿è¡é
ç½®ï¼appãwebï¼ |
| | | ## 1.0.11ï¼2022-07-14ï¼ |
| | | - ä¿®å¤ é¨åæ
åµä¸æ¥`read property 'reduce' of undefined`çé误 |
| | | ## 1.0.10ï¼2022-07-11ï¼ |
| | | - å°tokenåå¨å¨ç¨æ·è¡¨çtokenåæ®µå
ï¼ä¸æ§çæ¬uni-idä¿æä¸è´ |
| | | ## 1.0.9ï¼2022-07-01ï¼ |
| | | - checkTokenå
¼å®¹tokenå
æªç¼åè§è²æéçæ
åµï¼æ¤æ¶å°æ¥åºè·åè§è²æé |
| | | ## 1.0.8ï¼2022-07-01ï¼ |
| | | - ä¿®å¤clientDBé»è®¤ä¾èµæ¶é¨åæ
åµä¸è·åä¸å°uni-idé
ç½®çBug |
| | | ## 1.0.7ï¼2022-06-30ï¼ |
| | | - ä¿®å¤configæä»¶ä¸åæ³æ¶æªæåºå
·ä½é误çBug |
| | | ## 1.0.6ï¼2022-06-28ï¼ |
| | | - ç§»é¤æä»¶å
çæ°æ®è¡¨schema |
| | | ## 1.0.5ï¼2022-06-27ï¼ |
| | | - ä¿®å¤ä½¿ç¨å¤åºç¨é
ç½®æ¶æ¥`Cannot read property 'appId' of undefined`çBug |
| | | ## 1.0.4ï¼2022-06-27ï¼ |
| | | - ä¿®å¤ä½¿ç¨èªå®ä¹tokenå
容åè½æ¥éçBug [详æ
](https://ask.dcloud.net.cn/question/147945) |
| | | ## 1.0.2ï¼2022-06-23ï¼ |
| | | - 坹齿§çæ¬uni-idé»è®¤é
ç½® |
| | | ## 1.0.1ï¼2022-06-22ï¼ |
| | | - è¡¥å
对uni-config-centerçä¾èµ |
| | | ## 1.0.0ï¼2022-06-21ï¼ |
| | | - æä¾uni-id tokenåå»ºãæ ¡éªãå·æ°æ¥å£ï¼ç®åæ§çuni-idå
Œ
±æ¨¡å |
¶Ô±ÈÐÂÎļþ |
| | |
| | | { |
| | | "id": "uni-id-common", |
| | | "displayName": "uni-id-common", |
| | | "version": "1.0.16", |
| | | "description": "å
å«uni-id tokençæãæ ¡éªãå·æ°åè½çäºå½æ°å
Œ
±æ¨¡å", |
| | | "keywords": [ |
| | | "uni-id-common", |
| | | "uniCloud", |
| | | "token", |
| | | "æé" |
| | | ], |
| | | "repository": "https://gitcode.net/dcloud/uni-id-common", |
| | | "engines": { |
| | | "HBuilderX": "^3.1.0" |
| | | }, |
| | | "dcloudext": { |
| | | "sale": { |
| | | "regular": { |
| | | "price": "0.00" |
| | | }, |
| | | "sourcecode": { |
| | | "price": "0.00" |
| | | } |
| | | }, |
| | | "contact": { |
| | | "qq": "" |
| | | }, |
| | | "declaration": { |
| | | "ads": "æ ", |
| | | "data": "æ ", |
| | | "permissions": "æ " |
| | | }, |
| | | "npmurl": "", |
| | | "type": "unicloud-template-function" |
| | | }, |
| | | "uni_modules": { |
| | | "dependencies": ["uni-config-center"], |
| | | "encrypt": [], |
| | | "platforms": { |
| | | "cloud": { |
| | | "tcb": "y", |
| | | "aliyun": "y" |
| | | }, |
| | | "client": { |
| | | "Vue": { |
| | | "vue2": "u", |
| | | "vue3": "u" |
| | | }, |
| | | "App": { |
| | | "app-vue": "u", |
| | | "app-nvue": "u" |
| | | }, |
| | | "H5-mobile": { |
| | | "Safari": "u", |
| | | "Android Browser": "u", |
| | | "微信æµè§å¨(Android)": "u", |
| | | "QQæµè§å¨(Android)": "u" |
| | | }, |
| | | "H5-pc": { |
| | | "Chrome": "u", |
| | | "IE": "u", |
| | | "Edge": "u", |
| | | "Firefox": "u", |
| | | "Safari": "u" |
| | | }, |
| | | "å°ç¨åº": { |
| | | "微信": "u", |
| | | "é¿é": "u", |
| | | "ç¾åº¦": "u", |
| | | "åèè·³å¨": "u", |
| | | "QQ": "u", |
| | | "éé": "u", |
| | | "å¿«æ": "u", |
| | | "é£ä¹¦": "u", |
| | | "京ä¸": "u" |
| | | }, |
| | | "å¿«åºç¨": { |
| | | "å为": "u", |
| | | "èç": "u" |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | # uni-id-common |
| | | |
| | | ææ¡£è¯·åèï¼[uni-id-common](https://uniapp.dcloud.net.cn/uniCloud/uni-id-common.html) |
¶Ô±ÈÐÂÎļþ |
| | |
| | | "use strict";var e,t=(e=require("crypto"))&&"object"==typeof e&&"default"in e?e.default:e;const n={TOKEN_EXPIRED:"uni-id-token-expired",CHECK_TOKEN_FAILED:"uni-id-check-token-failed",PARAM_REQUIRED:"uni-id-param-required",ACCOUNT_EXISTS:"uni-id-account-exists",ACCOUNT_NOT_EXISTS:"uni-id-account-not-exists",ACCOUNT_CONFLICT:"uni-id-account-conflict",ACCOUNT_BANNED:"uni-id-account-banned",ACCOUNT_AUDITING:"uni-id-account-auditing",ACCOUNT_AUDIT_FAILED:"uni-id-account-audit-failed",ACCOUNT_CLOSED:"uni-id-account-closed"};function i(e){return!!e&&("object"==typeof e||"function"==typeof e)&&"function"==typeof e.then}function r(e){if(!e)return;const t=e.match(/^(\d+).(\d+).(\d+)/);return t?t.slice(1,4).map(e=>parseInt(e)):void 0}function o(e,t){const n=r(e),i=r(t);return n?i?function(e,t){const n=Math.max(e.length,t.length);for(let i=0;i<n;i++){const n=e[i],r=t[i];if(n>r)return 1;if(n<r)return-1}return 0}(n,i):1:i?-1:0}const s={"uni-id-token-expired":30203,"uni-id-check-token-failed":30202};function c(e){const{errCode:t,errMsgValue:n}=e;e.errMsg=this._t(t,n),t in s&&(e.code=s[t]),delete e.errMsgValue}function a(e){return"object"===(i=e,Object.prototype.toString.call(i).slice(8,-1).toLowerCase())&&e.errCode&&(t=e.errCode,Object.values(n).includes(t))&&!!e.errCode;var t,i}let u={"zh-Hans":{"uni-id-token-expired":"ç»å½ç¶æå¤±æï¼tokenå·²è¿æ","uni-id-check-token-failed":"tokenæ ¡éªæªéè¿","uni-id-param-required":"缺å°åæ°: {param}","uni-id-account-exists":"æ¤è´¦å·å·²æ³¨å","uni-id-account-not-exists":"æ¤è´¦å·æªæ³¨å","uni-id-account-conflict":"ç¨æ·è´¦å·å²çª","uni-id-account-banned":"ä»è´¦å·å·²å°ç¦","uni-id-account-auditing":"æ¤è´¦å·æ£å¨å®¡æ ¸ä¸","uni-id-account-audit-failed":"æ¤è´¦å·å®¡æ ¸å¤±è´¥","uni-id-account-closed":"æ¤è´¦å·å·²æ³¨é"},en:{"uni-id-token-expired":"The login status is invalid, token has expired","uni-id-check-token-failed":"Check token failed","uni-id-param-required":"Parameter required: {param}","uni-id-account-exists":"Account exists","uni-id-account-not-exists":"Account does not exists","uni-id-account-conflict":"User account conflict","uni-id-account-banned":"Account has been banned","uni-id-account-auditing":"Account audit in progress","uni-id-account-audit-failed":"Account audit failed","uni-id-account-closed":"Account has been closed"}};try{const e=require.resolve("uni-config-center/uni-id/lang/index.js");u=function(e,t){const n=Object.keys(e);n.push(...Object.keys(t));const i={};for(let r=0;r<n.length;r++){const o=n[r];i[o]=Object.assign({},e[o],t[o])}return i}(u,require(e))}catch(e){}var d=u;function l(e){return e.replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}function h(e){return JSON.parse((t=function(e){var t=4-(e=e.toString()).length%4;if(4!==t)for(var n=0;n<t;++n)e+="=";return e.replace(/-/g,"+").replace(/_/g,"/")}(e),Buffer.from(t,"base64").toString("utf-8")));var t}function f(e){return l((t=JSON.stringify(e),Buffer.from(t,"utf-8").toString("base64")));var t}function p(e,n){return l(t.createHmac("sha256",n).update(e).digest("base64"))}const k=function(e,t){if("string"!=typeof e)throw new Error("Invalid token");const n=e.split(".");if(3!==n.length)throw new Error("Invalid token");const[i,r,o]=n;if(p(i+"."+r,t)!==o)throw new Error("Invalid token");const s=h(i);if("HS256"!==s.alg||"JWT"!==s.typ)throw new Error("Invalid token");const c=h(r);if(1e3*c.exp<Date.now()){const e=new Error("Token expired");throw e.name="TokenExpiredError",e}return c},g=function(e,t,n={}){const{expiresIn:i}=n;if(!i)throw new Error("expiresIn is required");const r=parseInt(Date.now()/1e3),o={...e,iat:r,exp:r+n.expiresIn},s=f({alg:"HS256",typ:"JWT"})+"."+f(o);return s+"."+p(s,t)},I=uniCloud.database(),_=I.command,C=I.collection("uni-id-users"),T=I.collection("uni-id-roles");class m{constructor({uniId:e}={}){this.uid=null,this.userRecord=null,this.userPermission=null,this.oldToken=null,this.oldTokenPayload=null,this.uniId=e,this.config=this.uniId._getConfig(),this.clientInfo=this.uniId._clientInfo,this.checkConfig()}checkConfig(){const{tokenExpiresIn:e,tokenExpiresThreshold:t}=this.config;if(t>=e)throw new Error("Config error, tokenExpiresThreshold should be less than tokenExpiresIn");t>e/2&&console.warn(`Please check whether the tokenExpiresThreshold configuration is set too large, tokenExpiresThreshold: ${t}, tokenExpiresIn: ${e}`)}get customToken(){return this.uniId.interceptorMap.get("customToken")}isTokenInDb(e){return o(e,"1.0.10")>=0}async getUserRecord(){if(this.userRecord)return this.userRecord;const e=await C.doc(this.uid).get();if(this.userRecord=e.data[0],!this.userRecord)throw{errCode:n.ACCOUNT_NOT_EXISTS};switch(this.userRecord.status){case void 0:case 0:break;case 1:throw{errCode:n.ACCOUNT_BANNED};case 2:throw{errCode:n.ACCOUNT_AUDITING};case 3:throw{errCode:n.ACCOUNT_AUDIT_FAILED};case 4:throw{errCode:n.ACCOUNT_CLOSED}}if(this.oldTokenPayload){if(this.isTokenInDb(this.oldTokenPayload.uniIdVersion)){if(-1===(this.userRecord.token||[]).indexOf(this.oldToken))throw{errCode:n.CHECK_TOKEN_FAILED}}if(this.userRecord.valid_token_date&&this.userRecord.valid_token_date>1e3*this.oldTokenPayload.iat)throw{errCode:n.TOKEN_EXPIRED}}return this.userRecord}async updateUserRecord(e){await C.doc(this.uid).update(e)}async getUserPermission(){if(this.userPermission)return this.userPermission;const e=(await this.getUserRecord()).role||[];if(0===e.length)return this.userPermission={role:[],permission:[]},this.userPermission;if(e.includes("admin"))return this.userPermission={role:e,permission:[]},this.userPermission;const t=await T.where({role_id:_.in(e)}).get(),n=(i=t.data.reduce((e,t)=>(t.permission&&e.push(...t.permission),e),[]),Array.from(new Set(i)));var i;return this.userPermission={role:e,permission:n},this.userPermission}async _createToken({uid:e,role:t,permission:i}={}){if(!t||!i){const e=await this.getUserPermission();t=e.role,i=e.permission}let r={uid:e,role:t,permission:i};if(this.uniId.interceptorMap.has("customToken")){const n=this.uniId.interceptorMap.get("customToken");if("function"!=typeof n)throw new Error("Invalid custom token file");r=await n({uid:e,role:t,permission:i})}const o=Date.now(),{tokenSecret:s,tokenExpiresIn:c,maxTokenLength:a=10}=this.config,u=g({...r,uniIdVersion:"1.0.16"},s,{expiresIn:c}),d=await this.getUserRecord(),l=(d.token||[]).filter(e=>{try{const t=this._checkToken(e);if(d.valid_token_date&&d.valid_token_date>1e3*t.iat)return!1}catch(e){if(e.errCode===n.TOKEN_EXPIRED)return!1}return!0});return l.push(u),l.length>a&&l.splice(0,l.length-a),await this.updateUserRecord({last_login_ip:this.clientInfo.clientIP,last_login_date:o,token:l}),{token:u,tokenExpired:o+1e3*c}}async createToken({uid:e,role:t,permission:i}={}){if(!e)throw{errCode:n.PARAM_REQUIRED,errMsgValue:{param:"uid"}};this.uid=e;const{token:r,tokenExpired:o}=await this._createToken({uid:e,role:t,permission:i});return{errCode:0,token:r,tokenExpired:o}}async refreshToken({token:e}={}){if(!e)throw{errCode:n.PARAM_REQUIRED,errMsgValue:{param:"token"}};this.oldToken=e;const t=this._checkToken(e);this.uid=t.uid,this.oldTokenPayload=t;const{uid:i}=t,{role:r,permission:o}=await this.getUserPermission(),{token:s,tokenExpired:c}=await this._createToken({uid:i,role:r,permission:o});return{errCode:0,token:s,tokenExpired:c}}_checkToken(e){const{tokenSecret:t}=this.config;let i;try{i=k(e,t)}catch(e){if("TokenExpiredError"===e.name)throw{errCode:n.TOKEN_EXPIRED};throw{errCode:n.CHECK_TOKEN_FAILED}}return i}async checkToken(e,{autoRefresh:t=!0}={}){if(!e)throw{errCode:n.PARAM_REQUIRED,errMsgValue:{param:"token"}};this.oldToken=e;const i=this._checkToken(e);this.uid=i.uid,this.oldTokenPayload=i;const{tokenExpiresThreshold:r}=this.config,{uid:o,role:s,permission:c}=i,a={role:s,permission:c};if(!s&&!c){const{role:e,permission:t}=await this.getUserPermission();a.role=e,a.permission=t}if(!r||!t){const e={code:0,errCode:0,...i,...a};return delete e.uniIdVersion,e}const u=Date.now();let d={};1e3*i.exp-u<1e3*r&&(d=await this._createToken({uid:o}));const l={code:0,errCode:0,...i,...a,...d};return delete l.uniIdVersion,l}}var E=Object.freeze({__proto__:null,checkToken:async function(e,{autoRefresh:t=!0}={}){return new m({uniId:this}).checkToken(e,{autoRefresh:t})},createToken:async function({uid:e,role:t,permission:n}={}){return new m({uniId:this}).createToken({uid:e,role:t,permission:n})},refreshToken:async function({token:e}={}){return new m({uniId:this}).refreshToken({token:e})}});const w=require("uni-config-center")({pluginId:"uni-id"});class x{constructor({context:e,clientInfo:t,config:n}={}){this._clientInfo=e?function(e){return{appId:e.APPID,platform:e.PLATFORM,locale:e.LOCALE,clientIP:e.CLIENTIP,deviceId:e.DEVICEID}}(e):t,this.config=n||this._getOriginConfig(),this.interceptorMap=new Map,w.hasFile("custom-token.js")&&this.setInterceptor("customToken",require(w.resolve("custom-token.js")));this._i18n=uniCloud.initI18n({locale:this._clientInfo.locale,fallbackLocale:"zh-Hans",messages:JSON.parse(JSON.stringify(d))}),d[this._i18n.locale]||this._i18n.setLocale("zh-Hans")}setInterceptor(e,t){this.interceptorMap.set(e,t)}_t(...e){return this._i18n.t(...e)}_parseOriginConfig(e){return Array.isArray(e)?e:e[0]?Object.values(e):e}_getOriginConfig(){if(w.hasFile("config.json")){let e;try{e=w.config()}catch(e){throw new Error("Invalid uni-id config file\n"+e.message)}return this._parseOriginConfig(e)}try{return this._parseOriginConfig(require("uni-id/config.json"))}catch(e){throw new Error("Invalid uni-id config file")}}_getAppConfig(){const e=this._getOriginConfig();return Array.isArray(e)?e.find(e=>e.dcloudAppid===this._clientInfo.appId)||e.find(e=>e.isDefaultConfig):e}_getPlatformConfig(){const e=this._getAppConfig();if(!e)throw new Error(`Config for current app (${this._clientInfo.appId}) was not found, please check your config file or client appId`);let t;switch("app-plus"===this._clientInfo.platform&&(this._clientInfo.platform="app"),"h5"===this._clientInfo.platform&&(this._clientInfo.platform="web"),this._clientInfo.platform){case"web":t="h5";break;case"app":t="app-plus"}const n=[{tokenExpiresIn:7200,tokenExpiresThreshold:1200,passwordErrorLimit:6,passwordErrorRetryTime:3600},e];t&&e[t]&&n.push(e[t]),n.push(e[this._clientInfo.platform]);const i=Object.assign(...n);return["tokenSecret","tokenExpiresIn"].forEach(e=>{if(!i||!i[e])throw new Error(`Config parameter missing, ${e} is required`)}),i}_getConfig(){return this._getPlatformConfig()}}for(const e in E)x.prototype[e]=E[e];function y(e){const t=new x(e);return new Proxy(t,{get(e,t){if(t in e&&0!==t.indexOf("_")){if("function"==typeof e[t])return(n=e[t],function(){let e;try{e=n.apply(this,arguments)}catch(e){if(a(e))return c.call(this,e),e;throw e}return i(e)?e.then(e=>(a(e)&&c.call(this,e),e),e=>{if(a(e))return c.call(this,e),e;throw e}):(a(e)&&c.call(this,e),e)}).bind(e);if("context"!==t&&"config"!==t)return e[t]}var n}})}x.prototype.createInstance=y;const A={createInstance:y};module.exports=A; |
¶Ô±ÈÐÂÎļþ |
| | |
| | | { |
| | | "name": "uni-id-common", |
| | | "version": "1.0.16", |
| | | "description": "uni-id tokençæãæ ¡éªãå·æ°", |
| | | "main": "index.js", |
| | | "homepage": "https://uniapp.dcloud.io/uniCloud/uni-id-common.html", |
| | | "repository": { |
| | | "type": "git", |
| | | "url": "git+https://gitee.com/dcloud/uni-id-common.git" |
| | | }, |
| | | "author": "DCloud", |
| | | "license": "Apache-2.0", |
| | | "dependencies": { |
| | | "uni-config-center": "file:../../../../../uni-config-center/uniCloud/cloudfunctions/common/uni-config-center" |
| | | } |
| | | } |