@dcloudio/uni-h5 2.0.0 → 2.0.1-32920211122002
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/automator.js +1 -1
- package/dist/index.css +1 -1
- package/dist/index.umd.min.js +1 -1
- package/lib/apis.js +14 -4
- package/lib/h5/uni.automator.js +1 -1
- package/lib/modules.json +4 -1
- package/manifest.json +49 -0
- package/package.json +2 -3
- package/src/core/helpers/api.js +1 -1
- package/src/core/helpers/constants.js +1 -0
- package/src/core/helpers/i18n/en.json +4 -2
- package/src/core/helpers/i18n/es.json +4 -1
- package/src/core/helpers/i18n/fr.json +4 -1
- package/src/core/helpers/i18n/index.js +155 -4
- package/src/core/helpers/i18n/zh-Hans.json +4 -1
- package/src/core/helpers/i18n/zh-Hant.json +4 -1
- package/src/core/helpers/index.js +1 -1
- package/src/core/helpers/interceptor.js +19 -15
- package/src/core/helpers/promise.js +1 -1
- package/src/core/helpers/protocol/device/set-clipboard-data.js +11 -2
- package/src/core/helpers/protocol/network/request.js +14 -1
- package/src/core/helpers/protocol/network/upload-file.js +1 -1
- package/src/core/helpers/protocol/ui/popup.js +2 -2
- package/src/core/runtime/base.js +2 -0
- package/src/core/runtime/locale.js +37 -0
- package/src/core/runtime/web-view/index.js +4 -0
- package/src/core/runtime/wrapper/create-subpackage-app.js +7 -6
- package/src/core/runtime/wrapper/util.js +6 -1
- package/src/core/service/api/base/interceptor.js +1 -1
- package/src/core/service/api/context/canvas.js +3 -2
- package/src/core/service/api/context/create-map-context.js +8 -1
- package/src/core/service/api/ui/locale.js +50 -0
- package/src/core/service/plugins/app/create-app.js +8 -3
- package/src/core/service/plugins/app/index.js +2 -2
- package/src/core/service/plugins/index.js +8 -2
- package/src/core/view/bridge/subscribe/api/request-component-observer.js +16 -1
- package/src/core/view/components/canvas/index.vue +3 -1
- package/src/core/view/components/editor/formats/image.js +3 -1
- package/src/core/view/components/editor/formats/index.js +3 -1
- package/src/core/view/components/editor/formats/link.js +9 -0
- package/src/core/view/components/editor/index.vue +33 -3
- package/src/core/view/components/image/index.vue +4 -5
- package/src/core/view/components/input/index.vue +53 -25
- package/src/core/view/components/picker-view-column/index.vue +1 -0
- package/src/core/view/components/progress/index.vue +20 -13
- package/src/core/view/components/rich-text/index.vue +13 -1
- package/src/core/view/components/rich-text/nodes-parser.js +23 -4
- package/src/core/view/components/scroll-view/index.vue +253 -122
- package/src/core/view/components/slider/index.vue +1 -1
- package/src/core/view/components/swiper/index.vue +3 -0
- package/src/core/view/components/textarea/index.vue +7 -3
- package/src/core/view/index.css +4 -0
- package/src/core/view/mixins/field.js +27 -9
- package/src/core/view/mixins/interact.js +13 -11
- package/src/core/view/mixins/keyboard.js +42 -26
- package/src/core/view/mixins/touchtrack.js +2 -2
- package/src/core/view/plugins/index.js +1 -1
- package/src/platforms/app-plus/constants.js +1 -0
- package/src/platforms/app-plus/helpers/get-real-path.js +7 -4
- package/src/platforms/app-plus/helpers/uuid.js +1 -1
- package/src/platforms/app-plus/service/api/ad/ad-base.js +159 -0
- package/src/platforms/app-plus/service/api/ad/ad.js +4 -8
- package/src/platforms/app-plus/service/api/ad/full-screen-video-ad.js +5 -98
- package/src/platforms/app-plus/service/api/ad/interactive-ad.js +257 -0
- package/src/platforms/app-plus/service/api/ad/interstitial-ad.js +15 -0
- package/src/platforms/app-plus/service/api/ad/rewarded-video-ad.js +15 -2
- package/src/platforms/app-plus/service/api/device/system.js +3 -2
- package/src/platforms/app-plus/service/api/file/open-document.js +7 -15
- package/src/platforms/app-plus/service/api/index.js +2 -0
- package/src/platforms/app-plus/service/api/location/get-location.js +8 -7
- package/src/platforms/app-plus/service/api/media/choose-image.js +22 -51
- package/src/platforms/app-plus/service/api/media/choose-video.js +19 -36
- package/src/platforms/app-plus/service/api/media/compress-video.js +2 -2
- package/src/platforms/app-plus/service/api/media/get-video-info.js +5 -2
- package/src/platforms/app-plus/service/api/network/request.js +27 -1
- package/src/platforms/app-plus/service/api/network/upload-file.js +1 -1
- package/src/platforms/app-plus/service/api/plugin/oauth.js +140 -8
- package/src/platforms/app-plus/service/api/storage/storage.js +1 -1
- package/src/platforms/app-plus/service/api/ui/popup.js +21 -11
- package/src/platforms/app-plus/service/api/ui/tab-bar.js +3 -2
- package/src/platforms/app-plus/service/api/util.js +5 -1
- package/src/platforms/app-plus/service/framework/app.js +21 -5
- package/src/platforms/app-plus/service/framework/config.js +1 -0
- package/src/platforms/app-plus/service/framework/plugins/index.js +8 -2
- package/src/platforms/app-plus/service/framework/plugins/lifecycle.js +2 -2
- package/src/platforms/app-plus/service/framework/subscribe-handlers/index.js +1 -1
- package/src/platforms/app-plus/service/framework/tab-bar.js +12 -2
- package/src/platforms/app-plus/service/framework/webview/index.js +2 -2
- package/src/platforms/app-plus/service/framework/webview/parser/title-nview-parser.js +73 -30
- package/src/platforms/app-plus/service/framework/webview/parser/webview-style-parser.js +16 -16
- package/src/platforms/app-plus/service/index.js +10 -3
- package/src/platforms/app-plus/service/publish-handler.js +3 -0
- package/src/platforms/app-plus/view/bridge/subscribe/index.js +5 -3
- package/src/platforms/app-plus/view/components/ad/index.vue +53 -44
- package/src/platforms/app-plus/view/components/cover-view/index.vue +13 -7
- package/src/platforms/app-plus/view/components/map/index.vue +29 -27
- package/src/platforms/app-plus/view/components/video/index.vue +40 -24
- package/src/platforms/app-plus/view/framework/plugins/gesture.js +17 -0
- package/src/platforms/app-plus/view/framework/plugins/index.js +3 -1
- package/src/platforms/app-plus/view/index.css +4 -0
- package/src/platforms/app-plus/view/mixins/cover.js +10 -15
- package/src/platforms/app-plus/view/mixins/native.js +45 -3
- package/src/platforms/app-plus-nvue/service/api/context/operate-map-player.js +3 -0
- package/src/platforms/h5/components/app/observable.js +3 -2
- package/src/platforms/h5/components/app/popup/mixins/modal.js +3 -3
- package/src/platforms/h5/components/app/popup/modal.vue +38 -2
- package/src/platforms/h5/components/app/popup/toast.vue +9 -1
- package/src/platforms/h5/components/app/tabBar.vue +39 -17
- package/src/platforms/h5/components/page/index.vue +5 -3
- package/src/platforms/h5/components/page/pageHead.vue +94 -75
- package/src/platforms/h5/components/system-routes/choose-location/index.vue +127 -66
- package/src/platforms/h5/components/system-routes/open-location/index.vue +193 -38
- package/src/platforms/h5/helpers/location.js +26 -0
- package/src/platforms/h5/helpers/todo-api.js +2 -2
- package/src/platforms/h5/service/api/device/clipboard.js +41 -0
- package/src/platforms/h5/service/api/device/get-system-info.js +75 -0
- package/src/platforms/h5/service/api/location/get-location.js +47 -18
- package/src/platforms/h5/service/api/media/MIMEType.js +53 -0
- package/src/platforms/h5/service/api/media/choose-file.js +9 -1
- package/src/platforms/h5/service/api/media/choose-image.js +9 -2
- package/src/platforms/h5/service/api/media/choose-video.js +9 -1
- package/src/platforms/h5/service/api/media/create_input.js +12 -3
- package/src/platforms/h5/service/api/ui/popup.js +3 -5
- package/src/platforms/h5/service/api/ui/tab-bar.js +1 -1
- package/src/platforms/h5/service/index.js +5 -0
- package/src/platforms/h5/view/bridge/subscribe/index.js +3 -2
- package/src/platforms/h5/view/components/ad/index.vue +112 -69
- package/src/platforms/h5/view/components/map/index.vue +96 -349
- package/src/platforms/h5/view/components/map/map-marker.js +287 -0
- package/src/platforms/h5/view/components/map/maps/callout.js +117 -0
- package/src/platforms/h5/view/components/map/maps/index.js +55 -0
- package/src/platforms/h5/view/components/video/index.vue +1 -1
- package/src/platforms/h5/view/index.css +4 -0
- package/src/platforms/mp-alipay/runtime/api/protocols.js +30 -3
- package/src/platforms/mp-baidu/runtime/api/protocols.js +5 -0
- package/src/platforms/mp-baidu/runtime/wrapper/component-parser.js +20 -18
- package/src/platforms/mp-baidu/runtime/wrapper/util.js +2 -1
- package/src/platforms/mp-kuaishou/runtime/api/protocols.js +3 -1
- package/src/platforms/mp-kuaishou/runtime/wrapper/component-parser.js +21 -1
- package/src/platforms/mp-lark/runtime/api/index.js +0 -0
- package/src/platforms/mp-lark/runtime/api/protocols.js +68 -0
- package/src/platforms/mp-lark/runtime/api/providers.js +6 -0
- package/src/platforms/mp-lark/runtime/index.js +1 -0
- package/src/platforms/mp-lark/runtime/web-view.js +11 -0
- package/src/platforms/mp-lark/runtime/wrapper/app-parser.js +33 -0
- package/src/platforms/mp-lark/runtime/wrapper/component-parser.js +50 -0
- package/src/platforms/mp-lark/runtime/wrapper/page-parser.js +39 -0
- package/src/platforms/mp-lark/runtime/wrapper/util.js +64 -0
- package/src/platforms/mp-qq/runtime/api/protocols.js +3 -1
- package/src/platforms/mp-toutiao/runtime/api/protocols.js +2 -0
- package/src/platforms/mp-toutiao/runtime/wrapper/component-parser.js +35 -19
- package/src/platforms/mp-weixin/helpers/get-user-profile.js +6 -0
- package/src/platforms/mp-weixin/runtime/index.js +6 -7
- package/src/platforms/mp-weixin/runtime/wrapper/app-base-parser.js +197 -126
- package/src/platforms/mp-weixin/runtime/wrapper/fix-set-data.js +37 -0
- package/src/shared/uni-id-mixin.js +77 -0
- package/src/shared/util.js +2 -0
|
@@ -1,126 +1,197 @@
|
|
|
1
|
-
import Vue from 'vue'
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
initHooks,
|
|
5
|
-
initMocks
|
|
6
|
-
} from 'uni-wrapper/util'
|
|
7
|
-
|
|
8
|
-
import
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
[
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
if (
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
if (
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
1
|
+
import Vue from 'vue'
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
initHooks,
|
|
5
|
+
initMocks
|
|
6
|
+
} from 'uni-wrapper/util'
|
|
7
|
+
|
|
8
|
+
import {
|
|
9
|
+
initAppLocale
|
|
10
|
+
} from 'uni-helpers/i18n/index'
|
|
11
|
+
|
|
12
|
+
import EventChannel from 'uni-helpers/EventChannel'
|
|
13
|
+
|
|
14
|
+
import {
|
|
15
|
+
getEventChannel
|
|
16
|
+
} from 'uni-helpers/navigate-to'
|
|
17
|
+
|
|
18
|
+
import {
|
|
19
|
+
uniIdMixin
|
|
20
|
+
} from 'uni-shared'
|
|
21
|
+
|
|
22
|
+
const hooks = [
|
|
23
|
+
'onShow',
|
|
24
|
+
'onHide',
|
|
25
|
+
'onError',
|
|
26
|
+
'onPageNotFound',
|
|
27
|
+
'onThemeChange',
|
|
28
|
+
'onUnhandledRejection'
|
|
29
|
+
]
|
|
30
|
+
|
|
31
|
+
if (__PLATFORM__ === 'mp-alipay') {
|
|
32
|
+
hooks.push('onShareAppMessage')
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function initEventChannel () {
|
|
36
|
+
Vue.prototype.getOpenerEventChannel = function () {
|
|
37
|
+
// 微信小程序使用自身getOpenerEventChannel
|
|
38
|
+
if (__PLATFORM__ === 'mp-weixin') {
|
|
39
|
+
return this.$scope.getOpenerEventChannel()
|
|
40
|
+
}
|
|
41
|
+
if (!this.__eventChannel__) {
|
|
42
|
+
this.__eventChannel__ = new EventChannel()
|
|
43
|
+
}
|
|
44
|
+
return this.__eventChannel__
|
|
45
|
+
}
|
|
46
|
+
const callHook = Vue.prototype.__call_hook
|
|
47
|
+
Vue.prototype.__call_hook = function (hook, args) {
|
|
48
|
+
if (hook === 'onLoad' && args && args.__id__) {
|
|
49
|
+
this.__eventChannel__ = getEventChannel(args.__id__)
|
|
50
|
+
delete args.__id__
|
|
51
|
+
}
|
|
52
|
+
return callHook.call(this, hook, args)
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function initScopedSlotsParams () {
|
|
57
|
+
const center = {}
|
|
58
|
+
const parents = {}
|
|
59
|
+
|
|
60
|
+
Vue.prototype.$hasScopedSlotsParams = function (vueId) {
|
|
61
|
+
const has = center[vueId]
|
|
62
|
+
if (!has) {
|
|
63
|
+
parents[vueId] = this
|
|
64
|
+
this.$on('hook:destroyed', () => {
|
|
65
|
+
delete parents[vueId]
|
|
66
|
+
})
|
|
67
|
+
}
|
|
68
|
+
return has
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
Vue.prototype.$getScopedSlotsParams = function (vueId, name, key) {
|
|
72
|
+
const data = center[vueId]
|
|
73
|
+
if (data) {
|
|
74
|
+
const object = data[name] || {}
|
|
75
|
+
return key ? object[key] : object
|
|
76
|
+
} else {
|
|
77
|
+
parents[vueId] = this
|
|
78
|
+
this.$on('hook:destroyed', () => {
|
|
79
|
+
delete parents[vueId]
|
|
80
|
+
})
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
Vue.prototype.$setScopedSlotsParams = function (name, value) {
|
|
85
|
+
const vueIds = this.$options.propsData.vueId
|
|
86
|
+
if (vueIds) {
|
|
87
|
+
const vueId = vueIds.split(',')[0]
|
|
88
|
+
const object = center[vueId] = center[vueId] || {}
|
|
89
|
+
object[name] = value
|
|
90
|
+
if (parents[vueId]) {
|
|
91
|
+
parents[vueId].$forceUpdate()
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
Vue.mixin({
|
|
97
|
+
destroyed () {
|
|
98
|
+
const propsData = this.$options.propsData
|
|
99
|
+
const vueId = propsData && propsData.vueId
|
|
100
|
+
if (vueId) {
|
|
101
|
+
delete center[vueId]
|
|
102
|
+
delete parents[vueId]
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
})
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
export default function parseBaseApp (vm, {
|
|
109
|
+
mocks,
|
|
110
|
+
initRefs
|
|
111
|
+
}) {
|
|
112
|
+
initEventChannel()
|
|
113
|
+
if (__PLATFORM__ === 'mp-weixin' || __PLATFORM__ === 'mp-qq' || __PLATFORM__ === 'mp-toutiao' || __PLATFORM__ ===
|
|
114
|
+
'mp-kuaishou' || __PLATFORM__ === 'mp-alipay' || __PLATFORM__ === 'mp-baidu' || __PLATFORM__ === 'mp-lark') {
|
|
115
|
+
initScopedSlotsParams()
|
|
116
|
+
}
|
|
117
|
+
if (vm.$options.store) {
|
|
118
|
+
Vue.prototype.$store = vm.$options.store
|
|
119
|
+
}
|
|
120
|
+
uniIdMixin(Vue)
|
|
121
|
+
|
|
122
|
+
Vue.prototype.mpHost = __PLATFORM__
|
|
123
|
+
|
|
124
|
+
Vue.mixin({
|
|
125
|
+
beforeCreate () {
|
|
126
|
+
if (!this.$options.mpType) {
|
|
127
|
+
return
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
this.mpType = this.$options.mpType
|
|
131
|
+
|
|
132
|
+
this.$mp = {
|
|
133
|
+
data: {},
|
|
134
|
+
[this.mpType]: this.$options.mpInstance
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
this.$scope = this.$options.mpInstance
|
|
138
|
+
|
|
139
|
+
delete this.$options.mpType
|
|
140
|
+
delete this.$options.mpInstance
|
|
141
|
+
if (this.mpType === 'page' && typeof getApp === 'function') { // hack vue-i18n
|
|
142
|
+
const app = getApp()
|
|
143
|
+
if (app.$vm && app.$vm.$i18n) {
|
|
144
|
+
this._i18n = app.$vm.$i18n
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
if (this.mpType !== 'app') {
|
|
148
|
+
initRefs(this)
|
|
149
|
+
initMocks(this, mocks)
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
})
|
|
153
|
+
|
|
154
|
+
const appOptions = {
|
|
155
|
+
onLaunch (args) {
|
|
156
|
+
if (this.$vm) { // 已经初始化过了,主要是为了百度,百度 onShow 在 onLaunch 之前
|
|
157
|
+
return
|
|
158
|
+
}
|
|
159
|
+
if (__PLATFORM__ === 'mp-weixin' || __PLATFORM__ === 'mp-qq') {
|
|
160
|
+
if (wx.canIUse && !wx.canIUse('nextTick')) { // 事实 上2.2.3 即可,简单使用 2.3.0 的 nextTick 判断
|
|
161
|
+
console.error('当前微信基础库版本过低,请将 微信开发者工具-详情-项目设置-调试基础库版本 更换为`2.3.0`以上')
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
this.$vm = vm
|
|
166
|
+
|
|
167
|
+
this.$vm.$mp = {
|
|
168
|
+
app: this
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
this.$vm.$scope = this
|
|
172
|
+
// vm 上也挂载 globalData
|
|
173
|
+
this.$vm.globalData = this.globalData
|
|
174
|
+
|
|
175
|
+
this.$vm._isMounted = true
|
|
176
|
+
this.$vm.__call_hook('mounted', args)
|
|
177
|
+
|
|
178
|
+
this.$vm.__call_hook('onLaunch', args)
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
// 兼容旧版本 globalData
|
|
183
|
+
appOptions.globalData = vm.$options.globalData || {}
|
|
184
|
+
// 将 methods 中的方法挂在 getApp() 中
|
|
185
|
+
const methods = vm.$options.methods
|
|
186
|
+
if (methods) {
|
|
187
|
+
Object.keys(methods).forEach(name => {
|
|
188
|
+
appOptions[name] = methods[name]
|
|
189
|
+
})
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
initAppLocale(Vue, vm, __GLOBAL__.getSystemInfoSync().language || 'zh-Hans')
|
|
193
|
+
|
|
194
|
+
initHooks(appOptions, hooks)
|
|
195
|
+
|
|
196
|
+
return appOptions
|
|
197
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 用于延迟调用 setData
|
|
3
|
+
* 在 setData 真实调用的时机需执行 fixSetDataEnd
|
|
4
|
+
* @param {*} mpInstance
|
|
5
|
+
*/
|
|
6
|
+
export function fixSetDataStart (mpInstance) {
|
|
7
|
+
const setData = mpInstance.setData
|
|
8
|
+
const setDataArgs = []
|
|
9
|
+
mpInstance.setData = function () {
|
|
10
|
+
setDataArgs.push(arguments)
|
|
11
|
+
}
|
|
12
|
+
mpInstance.__fixInitData = function () {
|
|
13
|
+
this.setData = setData
|
|
14
|
+
const fn = () => {
|
|
15
|
+
setDataArgs.forEach(args => {
|
|
16
|
+
setData.apply(this, args)
|
|
17
|
+
})
|
|
18
|
+
}
|
|
19
|
+
if (setDataArgs.length) {
|
|
20
|
+
if (this.groupSetData) {
|
|
21
|
+
this.groupSetData(fn)
|
|
22
|
+
} else {
|
|
23
|
+
fn()
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* 恢复真实的 setData 方法
|
|
30
|
+
* @param {*} mpInstance
|
|
31
|
+
*/
|
|
32
|
+
export function fixSetDataEnd (mpInstance) {
|
|
33
|
+
if (mpInstance.__fixInitData) {
|
|
34
|
+
mpInstance.__fixInitData()
|
|
35
|
+
delete mpInstance.__fixInitData
|
|
36
|
+
}
|
|
37
|
+
}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
let realAtob
|
|
2
|
+
|
|
3
|
+
const b64 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/='
|
|
4
|
+
const b64re = /^(?:[A-Za-z\d+/]{4})*?(?:[A-Za-z\d+/]{2}(?:==)?|[A-Za-z\d+/]{3}=?)?$/
|
|
5
|
+
|
|
6
|
+
if (typeof atob !== 'function') {
|
|
7
|
+
realAtob = function (str) {
|
|
8
|
+
str = String(str).replace(/[\t\n\f\r ]+/g, '')
|
|
9
|
+
if (!b64re.test(str)) { throw new Error("Failed to execute 'atob' on 'Window': The string to be decoded is not correctly encoded.") }
|
|
10
|
+
|
|
11
|
+
// Adding the padding if missing, for semplicity
|
|
12
|
+
str += '=='.slice(2 - (str.length & 3))
|
|
13
|
+
var bitmap; var result = ''; var r1; var r2; var i = 0
|
|
14
|
+
for (; i < str.length;) {
|
|
15
|
+
bitmap = b64.indexOf(str.charAt(i++)) << 18 | b64.indexOf(str.charAt(i++)) << 12 |
|
|
16
|
+
(r1 = b64.indexOf(str.charAt(i++))) << 6 | (r2 = b64.indexOf(str.charAt(i++)))
|
|
17
|
+
|
|
18
|
+
result += r1 === 64 ? String.fromCharCode(bitmap >> 16 & 255)
|
|
19
|
+
: r2 === 64 ? String.fromCharCode(bitmap >> 16 & 255, bitmap >> 8 & 255)
|
|
20
|
+
: String.fromCharCode(bitmap >> 16 & 255, bitmap >> 8 & 255, bitmap & 255)
|
|
21
|
+
}
|
|
22
|
+
return result
|
|
23
|
+
}
|
|
24
|
+
} else {
|
|
25
|
+
// 注意atob只能在全局对象上调用,例如:`const Base64 = {atob};Base64.atob('xxxx')`是错误的用法
|
|
26
|
+
realAtob = atob
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function b64DecodeUnicode (str) {
|
|
30
|
+
return decodeURIComponent(realAtob(str).split('').map(function (c) {
|
|
31
|
+
return '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2)
|
|
32
|
+
}).join(''))
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function getCurrentUserInfo () {
|
|
36
|
+
const token = (__PLATFORM__ === 'h5' || __PLATFORM__ === 'app-plus' ? uni : __GLOBAL__).getStorageSync('uni_id_token') || ''
|
|
37
|
+
const tokenArr = token.split('.')
|
|
38
|
+
if (!token || tokenArr.length !== 3) {
|
|
39
|
+
return {
|
|
40
|
+
uid: null,
|
|
41
|
+
role: [],
|
|
42
|
+
permission: [],
|
|
43
|
+
tokenExpired: 0
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
let userInfo
|
|
47
|
+
try {
|
|
48
|
+
userInfo = JSON.parse(b64DecodeUnicode(tokenArr[1]))
|
|
49
|
+
} catch (error) {
|
|
50
|
+
throw new Error('获取当前用户信息出错,详细错误信息为:' + error.message)
|
|
51
|
+
}
|
|
52
|
+
userInfo.tokenExpired = userInfo.exp * 1000
|
|
53
|
+
delete userInfo.exp
|
|
54
|
+
delete userInfo.iat
|
|
55
|
+
return userInfo
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export function uniIdMixin (Vue) {
|
|
59
|
+
Vue.prototype.uniIDHasRole = function (roleId) {
|
|
60
|
+
const {
|
|
61
|
+
role
|
|
62
|
+
} = getCurrentUserInfo()
|
|
63
|
+
return role.indexOf(roleId) > -1
|
|
64
|
+
}
|
|
65
|
+
Vue.prototype.uniIDHasPermission = function (permissionId) {
|
|
66
|
+
const {
|
|
67
|
+
permission
|
|
68
|
+
} = getCurrentUserInfo()
|
|
69
|
+
return this.uniIDHasRole('admin') || permission.indexOf(permissionId) > -1
|
|
70
|
+
}
|
|
71
|
+
Vue.prototype.uniIDTokenValid = function () {
|
|
72
|
+
const {
|
|
73
|
+
tokenExpired
|
|
74
|
+
} = getCurrentUserInfo()
|
|
75
|
+
return tokenExpired > Date.now()
|
|
76
|
+
}
|
|
77
|
+
}
|