diff --git a/packages/uni-app-plus/dist/index.js b/packages/uni-app-plus/dist/index.js index 4a1abe22ad0d08477a1243e8819a1a381b530fcd..dd45297b87c3c74f751469fd1ccf6627232cb4f5 100644 --- a/packages/uni-app-plus/dist/index.js +++ b/packages/uni-app-plus/dist/index.js @@ -666,7 +666,7 @@ function initTriggerEvent (mpInstance) { }; } -function initHook (name, options) { +function initHook (name, options, isComponent) { const oldHook = options[name]; if (!oldHook) { options[name] = function () { diff --git a/packages/uni-mp-baidu/dist/index.js b/packages/uni-mp-baidu/dist/index.js index d2e0f673b10f714e16c3caadf5c49e09c5feeacb..ed08f1334fe802fbd7f57e300fbf128bb547d11e 100644 --- a/packages/uni-mp-baidu/dist/index.js +++ b/packages/uni-mp-baidu/dist/index.js @@ -1063,7 +1063,7 @@ function initTriggerEvent (mpInstance) { }; } -function initHook (name, options) { +function initHook (name, options, isComponent) { const oldHook = options[name]; if (!oldHook) { options[name] = function () { diff --git a/packages/uni-mp-kuaishou/dist/index.js b/packages/uni-mp-kuaishou/dist/index.js index 39d1d17572452266d65018d77d73f5e59ff04ae3..012fff1ff3dfbeb4c939db9788abccc9de753bd3 100644 --- a/packages/uni-mp-kuaishou/dist/index.js +++ b/packages/uni-mp-kuaishou/dist/index.js @@ -838,7 +838,7 @@ function initTriggerEvent (mpInstance) { }; } -function initHook (name, options) { +function initHook (name, options, isComponent) { const oldHook = options[name]; if (!oldHook) { options[name] = function () { diff --git a/packages/uni-mp-qq/dist/index.js b/packages/uni-mp-qq/dist/index.js index 5628b56b6594ac8bf7d8d1d29cdae651db84aae7..d7bdeb33c8cf5cd6e757afa48e579ec21fbb3d22 100644 --- a/packages/uni-mp-qq/dist/index.js +++ b/packages/uni-mp-qq/dist/index.js @@ -999,7 +999,7 @@ function initTriggerEvent (mpInstance) { }; } -function initHook (name, options) { +function initHook (name, options, isComponent) { const oldHook = options[name]; if (!oldHook) { options[name] = function () { diff --git a/packages/uni-mp-toutiao/dist/index.js b/packages/uni-mp-toutiao/dist/index.js index 54dcb784d122ac2eedd50490c6249a3e02515f1c..f27e6ec182ad68f0b76211f986e2141ad7317947 100644 --- a/packages/uni-mp-toutiao/dist/index.js +++ b/packages/uni-mp-toutiao/dist/index.js @@ -1,53 +1,53 @@ import Vue from 'vue'; -function b64DecodeUnicode (str) { - return decodeURIComponent(atob(str).split('').map(function (c) { - return '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2) - }).join('')) -} - -function getCurrentUserInfo () { - const token = ( tt).getStorageSync('uni_id_token') || ''; - const tokenArr = token.split('.'); - if (!token || tokenArr.length !== 3) { - return { - uid: null, - role: [], - permission: [], - tokenExpired: 0 - } - } - let userInfo; - try { - userInfo = JSON.parse(b64DecodeUnicode(tokenArr[1])); - } catch (error) { - throw new Error('获取当前用户信息出错,详细错误信息为:' + error.message) - } - userInfo.tokenExpired = userInfo.exp * 1000; - delete userInfo.exp; - delete userInfo.iat; - return userInfo -} - -function uniIdMixin (Vue) { - Vue.prototype.uniIDHasRole = function (roleId) { - const { - role - } = getCurrentUserInfo(); - return role.indexOf(roleId) > -1 - }; - Vue.prototype.uniIDHasPermission = function (permissionId) { - const { - permission - } = getCurrentUserInfo(); - return this.uniIDHasRole('admin') || permission.indexOf(permissionId) > -1 - }; - Vue.prototype.uniIDTokenValid = function () { - const { - tokenExpired - } = getCurrentUserInfo(); - return tokenExpired > Date.now() - }; +function b64DecodeUnicode (str) { + return decodeURIComponent(atob(str).split('').map(function (c) { + return '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2) + }).join('')) +} + +function getCurrentUserInfo () { + const token = ( tt).getStorageSync('uni_id_token') || ''; + const tokenArr = token.split('.'); + if (!token || tokenArr.length !== 3) { + return { + uid: null, + role: [], + permission: [], + tokenExpired: 0 + } + } + let userInfo; + try { + userInfo = JSON.parse(b64DecodeUnicode(tokenArr[1])); + } catch (error) { + throw new Error('获取当前用户信息出错,详细错误信息为:' + error.message) + } + userInfo.tokenExpired = userInfo.exp * 1000; + delete userInfo.exp; + delete userInfo.iat; + return userInfo +} + +function uniIdMixin (Vue) { + Vue.prototype.uniIDHasRole = function (roleId) { + const { + role + } = getCurrentUserInfo(); + return role.indexOf(roleId) > -1 + }; + Vue.prototype.uniIDHasPermission = function (permissionId) { + const { + permission + } = getCurrentUserInfo(); + return this.uniIDHasRole('admin') || permission.indexOf(permissionId) > -1 + }; + Vue.prototype.uniIDTokenValid = function () { + const { + tokenExpired + } = getCurrentUserInfo(); + return tokenExpired > Date.now() + }; } const _toString = Object.prototype.toString; @@ -581,44 +581,44 @@ var previewImage = { } }; -const UUID_KEY = '__DC_STAT_UUID'; -let deviceId; -function addUuid (result) { - deviceId = deviceId || tt.getStorageSync(UUID_KEY); - if (!deviceId) { - deviceId = Date.now() + '' + Math.floor(Math.random() * 1e7); - tt.setStorage({ - key: UUID_KEY, - data: deviceId - }); - } - result.deviceId = deviceId; -} - -function addSafeAreaInsets (result) { - if (result.safeArea) { - const safeArea = result.safeArea; - result.safeAreaInsets = { - top: safeArea.top, - left: safeArea.left, - right: result.windowWidth - safeArea.right, - bottom: result.windowHeight - safeArea.bottom - }; - } -} - -var getSystemInfo = { - returnValue: function (result) { - addUuid(result); - addSafeAreaInsets(result); - } +const UUID_KEY = '__DC_STAT_UUID'; +let deviceId; +function addUuid (result) { + deviceId = deviceId || tt.getStorageSync(UUID_KEY); + if (!deviceId) { + deviceId = Date.now() + '' + Math.floor(Math.random() * 1e7); + tt.setStorage({ + key: UUID_KEY, + data: deviceId + }); + } + result.deviceId = deviceId; +} + +function addSafeAreaInsets (result) { + if (result.safeArea) { + const safeArea = result.safeArea; + result.safeAreaInsets = { + top: safeArea.top, + left: safeArea.left, + right: result.windowWidth - safeArea.right, + bottom: result.windowHeight - safeArea.bottom + }; + } +} + +var getSystemInfo = { + returnValue: function (result) { + addUuid(result); + addSafeAreaInsets(result); + } }; -const oName = 'getUserInfo'; -const nName = 'getUserProfile'; - -var getUserProfile = { - name: tt.canIUse(nName) ? nName : oName +const oName = 'getUserInfo'; +const nName = 'getUserProfile'; + +var getUserProfile = { + name: tt.canIUse(nName) ? nName : oName }; // 不支持的 API 列表 @@ -978,96 +978,96 @@ var eventApi = /*#__PURE__*/Object.freeze({ $emit: $emit }); -function createMediaQueryObserver () { - const mediaQueryObserver = {}; - const { - windowWidth, - windowHeight - } = tt.getSystemInfoSync(); - - const orientation = windowWidth < windowHeight ? 'portrait' : 'landscape'; - - mediaQueryObserver.observe = (options, callback) => { - let matches = true; - for (const item in options) { - const itemValue = item === 'orientation' ? options[item] : Number(options[item]); - if (options[item] !== '') { - if (item === 'width') { - if (itemValue === windowWidth) { - matches = true; - } else { - matches = false; - callback(matches); - return matches - } - } - if (item === 'minWidth') { - if (windowWidth >= itemValue) { - matches = true; - } else { - matches = false; - callback(matches); - return matches - } - } - if (item === 'maxWidth') { - if (windowWidth <= itemValue) { - matches = true; - } else { - matches = false; - callback(matches); - return matches - } - } - - if (item === 'height') { - if (itemValue === windowHeight) { - matches = true; - } else { - matches = false; - callback(matches); - return matches - } - } - if (item === 'minHeight') { - if (windowHeight >= itemValue) { - matches = true; - } else { - matches = false; - callback(matches); - return matches - } - } - if (item === 'maxHeight') { - if (windowHeight <= itemValue) { - matches = true; - } else { - matches = false; - callback(matches); - return matches - } - } - - if (item === 'orientation') { - if (options[item] === orientation) { - matches = true; - } else { - matches = false; - callback(matches); - return matches - } - } - } - } - callback(matches); - - return matches - }; - - mediaQueryObserver.disconnect = () => { - }; - - return mediaQueryObserver +function createMediaQueryObserver () { + const mediaQueryObserver = {}; + const { + windowWidth, + windowHeight + } = tt.getSystemInfoSync(); + + const orientation = windowWidth < windowHeight ? 'portrait' : 'landscape'; + + mediaQueryObserver.observe = (options, callback) => { + let matches = true; + for (const item in options) { + const itemValue = item === 'orientation' ? options[item] : Number(options[item]); + if (options[item] !== '') { + if (item === 'width') { + if (itemValue === windowWidth) { + matches = true; + } else { + matches = false; + callback(matches); + return matches + } + } + if (item === 'minWidth') { + if (windowWidth >= itemValue) { + matches = true; + } else { + matches = false; + callback(matches); + return matches + } + } + if (item === 'maxWidth') { + if (windowWidth <= itemValue) { + matches = true; + } else { + matches = false; + callback(matches); + return matches + } + } + + if (item === 'height') { + if (itemValue === windowHeight) { + matches = true; + } else { + matches = false; + callback(matches); + return matches + } + } + if (item === 'minHeight') { + if (windowHeight >= itemValue) { + matches = true; + } else { + matches = false; + callback(matches); + return matches + } + } + if (item === 'maxHeight') { + if (windowHeight <= itemValue) { + matches = true; + } else { + matches = false; + callback(matches); + return matches + } + } + + if (item === 'orientation') { + if (options[item] === orientation) { + matches = true; + } else { + matches = false; + callback(matches); + return matches + } + } + } + } + callback(matches); + + return matches + }; + + mediaQueryObserver.disconnect = () => { + }; + + return mediaQueryObserver } var api = /*#__PURE__*/Object.freeze({ @@ -2301,23 +2301,23 @@ function createSubpackageApp (vm) { return vm } -function createPlugin (vm) { - const appOptions = parseApp(vm); - if (isFn(appOptions.onShow) && tt.onAppShow) { - tt.onAppShow((...args) => { - appOptions.onShow.apply(vm, args); - }); - } - if (isFn(appOptions.onHide) && tt.onAppHide) { - tt.onAppHide((...args) => { - appOptions.onHide.apply(vm, args); - }); - } - if (isFn(appOptions.onLaunch)) { - const args = tt.getLaunchOptionsSync && tt.getLaunchOptionsSync(); - appOptions.onLaunch.call(vm, args); - } - return vm +function createPlugin (vm) { + const appOptions = parseApp(vm); + if (isFn(appOptions.onShow) && tt.onAppShow) { + tt.onAppShow((...args) => { + appOptions.onShow.apply(vm, args); + }); + } + if (isFn(appOptions.onHide) && tt.onAppHide) { + tt.onAppHide((...args) => { + appOptions.onHide.apply(vm, args); + }); + } + if (isFn(appOptions.onLaunch)) { + const args = tt.getLaunchOptionsSync && tt.getLaunchOptionsSync(); + appOptions.onLaunch.call(vm, args); + } + return vm } todos.forEach(todoApi => { diff --git a/packages/uni-mp-weixin/dist/index.js b/packages/uni-mp-weixin/dist/index.js index b77335c9a1c2c2e32d3b7dc51bb54b49e356df5c..1b17c7d860f6cd652c7c4cd6b8bd0c699e4b54c5 100644 --- a/packages/uni-mp-weixin/dist/index.js +++ b/packages/uni-mp-weixin/dist/index.js @@ -735,7 +735,7 @@ function initTriggerEvent (mpInstance) { }; } -function initHook (name, options) { +function initHook (name, options, isComponent) { const oldHook = options[name]; if (!oldHook) { options[name] = function () { diff --git a/packages/uni-quickapp-webview/dist/index.js b/packages/uni-quickapp-webview/dist/index.js index 183e9e9f1f34b03003400e70e40a0e27ece90686..940ddadd69b9955a8d69cd1ced7f3ef671f33bb9 100644 --- a/packages/uni-quickapp-webview/dist/index.js +++ b/packages/uni-quickapp-webview/dist/index.js @@ -805,7 +805,7 @@ function initTriggerEvent (mpInstance) { }; } -function initHook (name, options) { +function initHook (name, options, isComponent) { const oldHook = options[name]; if (!oldHook) { options[name] = function () {