@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
|
@@ -8,6 +8,10 @@ import {
|
|
|
8
8
|
base64ToArrayBuffer
|
|
9
9
|
} from '../../bridge'
|
|
10
10
|
|
|
11
|
+
import {
|
|
12
|
+
invoke
|
|
13
|
+
} from 'uni-core/service/bridge'
|
|
14
|
+
|
|
11
15
|
let requestTaskId = 0
|
|
12
16
|
const requestTasks = {}
|
|
13
17
|
|
|
@@ -46,6 +50,7 @@ export function createRequestTaskById (requestTaskId, {
|
|
|
46
50
|
responseType,
|
|
47
51
|
sslVerify = true,
|
|
48
52
|
firstIpv4 = false,
|
|
53
|
+
tls,
|
|
49
54
|
timeout = (__uniConfig.networkTimeout && __uniConfig.networkTimeout.request) || 60 * 1000
|
|
50
55
|
} = {}) {
|
|
51
56
|
const stream = requireNativePlugin('stream')
|
|
@@ -99,7 +104,8 @@ export function createRequestTaskById (requestTaskId, {
|
|
|
99
104
|
timeout: timeout || 6e5,
|
|
100
105
|
// 配置和weex模块内相反
|
|
101
106
|
sslVerify: !sslVerify,
|
|
102
|
-
firstIpv4: firstIpv4
|
|
107
|
+
firstIpv4: firstIpv4,
|
|
108
|
+
tls
|
|
103
109
|
}
|
|
104
110
|
if (method !== 'GET') {
|
|
105
111
|
options.body = typeof data === 'string' ? data : JSON.stringify(data)
|
|
@@ -186,3 +192,23 @@ export function operateRequestTask ({
|
|
|
186
192
|
errMsg: 'operateRequestTask:fail'
|
|
187
193
|
}
|
|
188
194
|
}
|
|
195
|
+
|
|
196
|
+
export function configMTLS ({ certificates }, callbackId) {
|
|
197
|
+
const stream = requireNativePlugin('stream')
|
|
198
|
+
stream.configMTLS(certificates, ({ type, code, message }) => {
|
|
199
|
+
switch (type) {
|
|
200
|
+
case 'success':
|
|
201
|
+
invoke(callbackId, {
|
|
202
|
+
errMsg: 'configMTLS:ok',
|
|
203
|
+
code
|
|
204
|
+
})
|
|
205
|
+
break
|
|
206
|
+
case 'fail':
|
|
207
|
+
invoke(callbackId, {
|
|
208
|
+
errMsg: 'configMTLS:fail ' + message,
|
|
209
|
+
code
|
|
210
|
+
})
|
|
211
|
+
break
|
|
212
|
+
}
|
|
213
|
+
})
|
|
214
|
+
}
|
|
@@ -62,7 +62,7 @@ const createUploadTaskById = function (uploadTaskId, {
|
|
|
62
62
|
}
|
|
63
63
|
if (files && files.length) {
|
|
64
64
|
files.forEach(file => {
|
|
65
|
-
uploader.addFile(getRealPath(file.uri), {
|
|
65
|
+
uploader.addFile(getRealPath(file.uri || file.filePath), {
|
|
66
66
|
key: file.name || 'file'
|
|
67
67
|
})
|
|
68
68
|
})
|
|
@@ -5,6 +5,9 @@ import {
|
|
|
5
5
|
warpPlusSuccessCallback,
|
|
6
6
|
warpPlusErrorCallback
|
|
7
7
|
} from '../util'
|
|
8
|
+
import { isPlainObject, toRawType, callback } from 'uni-shared'
|
|
9
|
+
|
|
10
|
+
let univerifyManager
|
|
8
11
|
|
|
9
12
|
function getService (provider) {
|
|
10
13
|
return new Promise((resolve, reject) => {
|
|
@@ -18,20 +21,36 @@ function getService (provider) {
|
|
|
18
21
|
/**
|
|
19
22
|
* 微信登录
|
|
20
23
|
*/
|
|
21
|
-
export function login (params, callbackId) {
|
|
24
|
+
export function login (params, callbackId, plus = true) {
|
|
22
25
|
const provider = params.provider || 'weixin'
|
|
23
|
-
const errorCallback =
|
|
26
|
+
const errorCallback = warpErrorCallback(callbackId, 'login', plus)
|
|
27
|
+
const authOptions = provider === 'apple'
|
|
28
|
+
? { scope: 'email' }
|
|
29
|
+
: params.univerifyStyle
|
|
30
|
+
? { univerifyStyle: univerifyButtonsClickHandling(params.univerifyStyle, errorCallback) }
|
|
31
|
+
: {}
|
|
32
|
+
const _invoke = plus ? invoke : callback.invoke
|
|
24
33
|
|
|
25
34
|
getService(provider).then(service => {
|
|
26
35
|
function login () {
|
|
36
|
+
if (params.onlyAuthorize && provider === 'weixin') {
|
|
37
|
+
service.authorize(({ code }) => {
|
|
38
|
+
_invoke(callbackId, {
|
|
39
|
+
code,
|
|
40
|
+
authResult: '',
|
|
41
|
+
errMsg: 'login:ok'
|
|
42
|
+
})
|
|
43
|
+
}, errorCallback)
|
|
44
|
+
return
|
|
45
|
+
}
|
|
27
46
|
service.login(res => {
|
|
28
47
|
const authResult = res.target.authResult
|
|
29
|
-
|
|
48
|
+
_invoke(callbackId, {
|
|
30
49
|
code: authResult.code,
|
|
31
50
|
authResult: authResult,
|
|
32
51
|
errMsg: 'login:ok'
|
|
33
52
|
})
|
|
34
|
-
}, errorCallback,
|
|
53
|
+
}, errorCallback, authOptions)
|
|
35
54
|
}
|
|
36
55
|
// 先注销再登录
|
|
37
56
|
// apple登录logout之后无法重新触发获取email,fullname;一键登录无logout
|
|
@@ -99,6 +118,12 @@ export function getUserInfo (params, callbackId) {
|
|
|
99
118
|
})
|
|
100
119
|
})
|
|
101
120
|
}
|
|
121
|
+
/**
|
|
122
|
+
* 获取用户信息-兼容
|
|
123
|
+
*/
|
|
124
|
+
export function getUserProfile (params, callbackId) {
|
|
125
|
+
return getUserInfo(params, callbackId)
|
|
126
|
+
}
|
|
102
127
|
|
|
103
128
|
/**
|
|
104
129
|
* 获取用户信息
|
|
@@ -115,12 +140,119 @@ export function operateWXData (params, callbackId) {
|
|
|
115
140
|
}
|
|
116
141
|
}
|
|
117
142
|
|
|
118
|
-
export function preLogin (params, callbackId) {
|
|
119
|
-
const successCallback =
|
|
120
|
-
const errorCallback =
|
|
143
|
+
export function preLogin (params, callbackId, plus) {
|
|
144
|
+
const successCallback = warpSuccessCallback(callbackId, 'preLogin', plus)
|
|
145
|
+
const errorCallback = warpErrorCallback(callbackId, 'preLogin', plus)
|
|
121
146
|
getService(params.provider).then(service => service.preLogin(successCallback, errorCallback)).catch(errorCallback)
|
|
122
147
|
}
|
|
123
148
|
|
|
124
149
|
export function closeAuthView () {
|
|
125
|
-
getService('univerify').then(service => service.closeAuthView())
|
|
150
|
+
return getService('univerify').then(service => service.closeAuthView())
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
export function getCheckBoxState (params, callbackId, plus) {
|
|
154
|
+
const successCallback = warpSuccessCallback(callbackId, 'getCheckBoxState', plus)
|
|
155
|
+
const errorCallback = warpErrorCallback(callbackId, 'getCheckBoxState', plus)
|
|
156
|
+
try {
|
|
157
|
+
getService('univerify').then(service => {
|
|
158
|
+
const state = service.getCheckBoxState()
|
|
159
|
+
successCallback({ state })
|
|
160
|
+
})
|
|
161
|
+
} catch (error) {
|
|
162
|
+
errorCallback(error)
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* 一键登录自定义登陆按钮点击处理
|
|
168
|
+
*/
|
|
169
|
+
function univerifyButtonsClickHandling (univerifyStyle, errorCallback) {
|
|
170
|
+
if (isPlainObject(univerifyStyle) && isPlainObject(univerifyStyle.buttons) && toRawType(univerifyStyle.buttons.list) === 'Array') {
|
|
171
|
+
univerifyStyle.buttons.list.forEach((button, index) => {
|
|
172
|
+
univerifyStyle.buttons.list[index].onclick = function () {
|
|
173
|
+
const res = {
|
|
174
|
+
code: '30008',
|
|
175
|
+
message: '用户点击了自定义按钮',
|
|
176
|
+
index,
|
|
177
|
+
provider: button.provider
|
|
178
|
+
}
|
|
179
|
+
isPlainObject(univerifyManager)
|
|
180
|
+
? univerifyManager._triggerUniverifyButtonsClick(res)
|
|
181
|
+
: closeAuthView().then(() => {
|
|
182
|
+
errorCallback(res)
|
|
183
|
+
})
|
|
184
|
+
}
|
|
185
|
+
})
|
|
186
|
+
}
|
|
187
|
+
return univerifyStyle
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
class UniverifyManager {
|
|
191
|
+
constructor () {
|
|
192
|
+
this.provider = 'univerify'
|
|
193
|
+
this.eventName = 'api.univerifyButtonsClick'
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
close () {
|
|
197
|
+
closeAuthView()
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
login (options) {
|
|
201
|
+
this._warp((data, callbackId) => login(data, callbackId, false), this._getOptions(options))
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
getCheckBoxState (options) {
|
|
205
|
+
this._warp((_, callbackId) => getCheckBoxState(_, callbackId, false), options)
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
preLogin (options) {
|
|
209
|
+
this._warp((data, callbackId) => preLogin(data, callbackId, false), this._getOptions(options))
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
onButtonsClick (callback) {
|
|
213
|
+
UniServiceJSBridge.on(this.eventName, callback)
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
offButtonsClick (callback) {
|
|
217
|
+
UniServiceJSBridge.off(this.eventName, callback)
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
_triggerUniverifyButtonsClick (res) {
|
|
221
|
+
UniServiceJSBridge.emit(this.eventName, res)
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
_warp (fn, options) {
|
|
225
|
+
return callback.warp(fn)(this._getOptions(options))
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
_getOptions (options = {}) {
|
|
229
|
+
return Object.assign({}, options, { provider: this.provider })
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
export function getUniverifyManager () {
|
|
234
|
+
return univerifyManager || (univerifyManager = new UniverifyManager())
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
function warpSuccessCallback (callbackId, name, plus = true) {
|
|
238
|
+
return plus
|
|
239
|
+
? warpPlusSuccessCallback(callbackId, name)
|
|
240
|
+
: (options) => {
|
|
241
|
+
callback.invoke(callbackId, Object.assign({}, options, {
|
|
242
|
+
errMsg: `${name}:ok`
|
|
243
|
+
}))
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
function warpErrorCallback (callbackId, name, plus = true) {
|
|
248
|
+
return plus
|
|
249
|
+
? warpPlusErrorCallback(callbackId, name)
|
|
250
|
+
: (error) => {
|
|
251
|
+
const { code = 0, message: errorMessage } = error
|
|
252
|
+
callback.invoke(callbackId, {
|
|
253
|
+
errMsg: `${name}:fail ${errorMessage || ''}`,
|
|
254
|
+
errCode: code,
|
|
255
|
+
code
|
|
256
|
+
})
|
|
257
|
+
}
|
|
126
258
|
}
|
|
@@ -185,7 +185,7 @@ export function getStorageInfo () {
|
|
|
185
185
|
let currentSize = 0
|
|
186
186
|
for (let index = 0; index < length; index++) {
|
|
187
187
|
const key = plus.storage.key(index)
|
|
188
|
-
if (key !== STORAGE_KEYS && key.indexOf(STORAGE_DATA_TYPE) + STORAGE_DATA_TYPE.length !== key.length) {
|
|
188
|
+
if (key !== STORAGE_KEYS && (key.indexOf(STORAGE_DATA_TYPE) < 0 || key.indexOf(STORAGE_DATA_TYPE) + STORAGE_DATA_TYPE.length !== key.length)) {
|
|
189
189
|
const value = plus.storage.getItem(key)
|
|
190
190
|
currentSize += key.length + value.length
|
|
191
191
|
keys.push(key)
|
|
@@ -43,7 +43,7 @@ export function showToast ({
|
|
|
43
43
|
})
|
|
44
44
|
toast = true
|
|
45
45
|
} else {
|
|
46
|
-
if (icon && !~['success', 'loading', 'none'].indexOf(icon)) {
|
|
46
|
+
if (icon && !~['success', 'loading', 'error', 'none'].indexOf(icon)) {
|
|
47
47
|
icon = 'success'
|
|
48
48
|
}
|
|
49
49
|
const waitingOptions = {
|
|
@@ -70,11 +70,11 @@ export function showToast ({
|
|
|
70
70
|
interval: duration
|
|
71
71
|
}
|
|
72
72
|
} else {
|
|
73
|
-
if (
|
|
73
|
+
if (['success', 'error'].indexOf(icon) !== -1) {
|
|
74
74
|
waitingOptions.loading = {
|
|
75
75
|
display: 'block',
|
|
76
76
|
height: '55px',
|
|
77
|
-
icon: '__uniappsuccess.png',
|
|
77
|
+
icon: icon === 'success' ? '__uniappsuccess.png' : '__uniapperror.png',
|
|
78
78
|
interval: duration
|
|
79
79
|
}
|
|
80
80
|
}
|
|
@@ -121,24 +121,34 @@ export function showModal ({
|
|
|
121
121
|
cancelText,
|
|
122
122
|
cancelColor,
|
|
123
123
|
confirmText,
|
|
124
|
-
confirmColor
|
|
124
|
+
confirmColor,
|
|
125
|
+
editable = false,
|
|
126
|
+
placeholderText = ''
|
|
125
127
|
} = {}, callbackId) {
|
|
128
|
+
const buttons = showCancel ? [cancelText, confirmText] : [confirmText]
|
|
129
|
+
const tip = editable ? placeholderText : buttons
|
|
130
|
+
|
|
126
131
|
content = content || ' '
|
|
127
|
-
plus.nativeUI
|
|
132
|
+
plus.nativeUI[editable ? 'prompt' : 'confirm'](content, (e) => {
|
|
128
133
|
if (showCancel) {
|
|
129
|
-
|
|
134
|
+
const isConfirm = e.index === 1
|
|
135
|
+
const res = {
|
|
130
136
|
errMsg: 'showModal:ok',
|
|
131
|
-
confirm:
|
|
137
|
+
confirm: isConfirm,
|
|
132
138
|
cancel: e.index === 0 || e.index === -1
|
|
133
|
-
}
|
|
139
|
+
}
|
|
140
|
+
isConfirm && editable && (res.content = e.value)
|
|
141
|
+
invoke(callbackId, res)
|
|
134
142
|
} else {
|
|
135
|
-
|
|
143
|
+
const res = {
|
|
136
144
|
errMsg: 'showModal:ok',
|
|
137
145
|
confirm: e.index === 0,
|
|
138
146
|
cancel: false
|
|
139
|
-
}
|
|
147
|
+
}
|
|
148
|
+
editable && (res.content = e.value)
|
|
149
|
+
invoke(callbackId, res)
|
|
140
150
|
}
|
|
141
|
-
}, title,
|
|
151
|
+
}, title, tip, buttons)
|
|
142
152
|
}
|
|
143
153
|
export function showActionSheet ({
|
|
144
154
|
itemList = [],
|
|
@@ -20,9 +20,10 @@ export function setTabBarItem ({
|
|
|
20
20
|
text,
|
|
21
21
|
iconPath,
|
|
22
22
|
selectedIconPath,
|
|
23
|
-
pagePath
|
|
23
|
+
pagePath,
|
|
24
|
+
visible
|
|
24
25
|
}) {
|
|
25
|
-
tabBar.setTabBarItem(index, text, iconPath, selectedIconPath)
|
|
26
|
+
tabBar.setTabBarItem(index, text, iconPath, selectedIconPath, visible)
|
|
26
27
|
const route = pagePath && __uniRoutes.find(({ path }) => path === pagePath)
|
|
27
28
|
if (route) {
|
|
28
29
|
const meta = route.meta
|
|
@@ -60,7 +60,7 @@ export function getRealPath (filePath) {
|
|
|
60
60
|
|
|
61
61
|
// 无协议的情况补全 https
|
|
62
62
|
if (filePath.indexOf('//') === 0) {
|
|
63
|
-
|
|
63
|
+
return 'https:' + filePath
|
|
64
64
|
}
|
|
65
65
|
|
|
66
66
|
// 网络资源或base64
|
|
@@ -75,6 +75,10 @@ export function getRealPath (filePath) {
|
|
|
75
75
|
const wwwPath = 'file://' + _handleLocalPath('_www')
|
|
76
76
|
// 绝对路径转换为本地文件系统路径
|
|
77
77
|
if (filePath.indexOf('/') === 0) {
|
|
78
|
+
// 平台绝对路径 安卓、iOS
|
|
79
|
+
if (filePath.startsWith('/storage/') || filePath.startsWith('/sdcard/') || filePath.includes('/Containers/Data/Application/')) {
|
|
80
|
+
return 'file://' + filePath
|
|
81
|
+
}
|
|
78
82
|
return wwwPath + filePath
|
|
79
83
|
}
|
|
80
84
|
// 相对资源
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
import {
|
|
2
|
+
initAppLocale
|
|
3
|
+
} from 'uni-helpers/i18n'
|
|
4
|
+
|
|
1
5
|
import {
|
|
2
6
|
callAppHook
|
|
3
7
|
} from 'uni-core/service/plugins/util'
|
|
@@ -93,10 +97,15 @@ function initGlobalListeners () {
|
|
|
93
97
|
})
|
|
94
98
|
})
|
|
95
99
|
|
|
100
|
+
let keyboardHeightChange = 0
|
|
96
101
|
plus.globalEvent.addEventListener('KeyboardHeightChange', function (event) {
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
102
|
+
// 安卓设备首次获取高度为 0
|
|
103
|
+
if (keyboardHeightChange !== event.height) {
|
|
104
|
+
keyboardHeightChange = event.height
|
|
105
|
+
publish('onKeyboardHeightChange', {
|
|
106
|
+
height: keyboardHeightChange
|
|
107
|
+
})
|
|
108
|
+
}
|
|
100
109
|
})
|
|
101
110
|
|
|
102
111
|
globalEvent.addEventListener('uistylechange', function (event) {
|
|
@@ -142,6 +151,12 @@ function initAppLaunch (appVm) {
|
|
|
142
151
|
|
|
143
152
|
callAppHook(appVm, 'onLaunch', args)
|
|
144
153
|
callAppHook(appVm, 'onShow', args)
|
|
154
|
+
// https://tower.im/teams/226535/todos/16905/
|
|
155
|
+
const getAppState = weex.requireModule('plus').getAppState
|
|
156
|
+
const appState = getAppState && Number(getAppState())
|
|
157
|
+
if (appState === 2) {
|
|
158
|
+
callAppHook(appVm, 'onHide', args)
|
|
159
|
+
}
|
|
145
160
|
}
|
|
146
161
|
|
|
147
162
|
function initTabBar () {
|
|
@@ -202,12 +217,13 @@ export function clearTempFile () {
|
|
|
202
217
|
})
|
|
203
218
|
}
|
|
204
219
|
|
|
205
|
-
export function registerApp (appVm) {
|
|
220
|
+
export function registerApp (appVm, Vue) {
|
|
206
221
|
if (process.env.NODE_ENV !== 'production') {
|
|
207
222
|
console.log('[uni-app] registerApp')
|
|
208
223
|
}
|
|
209
224
|
appCtx = appVm
|
|
210
225
|
appCtx.$vm = appVm
|
|
226
|
+
initAppLocale(Vue, appVm)
|
|
211
227
|
|
|
212
228
|
Object.assign(appCtx, defaultApp) // 拷贝默认实现
|
|
213
229
|
|
|
@@ -236,4 +252,4 @@ export function registerApp (appVm) {
|
|
|
236
252
|
__uniConfig.ready = true
|
|
237
253
|
|
|
238
254
|
process.env.NODE_ENV !== 'production' && perf('registerApp')
|
|
239
|
-
}
|
|
255
|
+
}
|
|
@@ -22,6 +22,10 @@ import {
|
|
|
22
22
|
vdSyncCallbacks
|
|
23
23
|
} from '../subscribe-handlers/on-vd-sync-callback'
|
|
24
24
|
|
|
25
|
+
import {
|
|
26
|
+
uniIdMixin
|
|
27
|
+
} from 'uni-shared'
|
|
28
|
+
|
|
25
29
|
export default {
|
|
26
30
|
install (Vue, options) {
|
|
27
31
|
initVue(Vue)
|
|
@@ -31,6 +35,8 @@ export default {
|
|
|
31
35
|
|
|
32
36
|
initPolyfill(Vue)
|
|
33
37
|
|
|
38
|
+
uniIdMixin(Vue)
|
|
39
|
+
|
|
34
40
|
Vue.prototype.getOpenerEventChannel = function () {
|
|
35
41
|
if (!this.$root.$scope.eventChannel) {
|
|
36
42
|
this.$root.$scope.eventChannel = new EventChannel()
|
|
@@ -66,12 +72,12 @@ export default {
|
|
|
66
72
|
console.log('[uni-app] launchApp')
|
|
67
73
|
}
|
|
68
74
|
plus.updateConfigInfo && plus.updateConfigInfo()
|
|
69
|
-
registerApp(this)
|
|
75
|
+
registerApp(this, Vue)
|
|
70
76
|
oldMount.call(this, el, hydrating)
|
|
71
77
|
})
|
|
72
78
|
return
|
|
73
79
|
}
|
|
74
|
-
registerApp(this)
|
|
80
|
+
registerApp(this, Vue)
|
|
75
81
|
}
|
|
76
82
|
return oldMount.call(this, el, hydrating)
|
|
77
83
|
}
|
|
@@ -55,7 +55,7 @@ function parsePageCreateOptions (vm, route) {
|
|
|
55
55
|
|
|
56
56
|
return {
|
|
57
57
|
version: VD_SYNC_VERSION,
|
|
58
|
-
locale: plus.
|
|
58
|
+
locale: weex.requireModule('plus').getLanguage(),
|
|
59
59
|
disableScroll,
|
|
60
60
|
onPageScroll,
|
|
61
61
|
onPageReachBottom,
|
|
@@ -121,4 +121,4 @@ export function initLifecycle (Vue) {
|
|
|
121
121
|
}
|
|
122
122
|
}
|
|
123
123
|
})
|
|
124
|
-
}
|
|
124
|
+
}
|
|
@@ -49,7 +49,7 @@ function setTabBarBadge (type, index, text) {
|
|
|
49
49
|
/**
|
|
50
50
|
* 动态设置 tabBar 某一项的内容
|
|
51
51
|
*/
|
|
52
|
-
function setTabBarItem (index, text, iconPath, selectedIconPath) {
|
|
52
|
+
function setTabBarItem (index, text, iconPath, selectedIconPath, visible) {
|
|
53
53
|
const item = {
|
|
54
54
|
index
|
|
55
55
|
}
|
|
@@ -62,7 +62,17 @@ function setTabBarItem (index, text, iconPath, selectedIconPath) {
|
|
|
62
62
|
if (selectedIconPath) {
|
|
63
63
|
item.selectedIconPath = getRealPath(selectedIconPath)
|
|
64
64
|
}
|
|
65
|
-
|
|
65
|
+
if (visible !== undefined) {
|
|
66
|
+
item.visible = config.list[index].visible = visible
|
|
67
|
+
delete item.index
|
|
68
|
+
|
|
69
|
+
const tabbarItems = config.list.map(item => ({ visible: item.visible }))
|
|
70
|
+
tabbarItems[index] = item
|
|
71
|
+
|
|
72
|
+
tabBar && tabBar.setTabBarItems({ list: tabbarItems })
|
|
73
|
+
} else {
|
|
74
|
+
tabBar && tabBar.setTabBarItem(item)
|
|
75
|
+
}
|
|
66
76
|
}
|
|
67
77
|
/**
|
|
68
78
|
* 动态设置 tabBar 的整体样式
|
|
@@ -152,7 +152,7 @@ export function initWebview (webview, routeOptions, path, query) {
|
|
|
152
152
|
|
|
153
153
|
export function createPreloadWebview () {
|
|
154
154
|
if (!preloadWebview || preloadWebview.__uniapp_route) { // 不存在,或已被使用
|
|
155
|
-
preloadWebview = plus.webview.create(VIEW_WEBVIEW_PATH, String(id++))
|
|
155
|
+
preloadWebview = plus.webview.create(VIEW_WEBVIEW_PATH, String(id++), { contentAdjust: false })
|
|
156
156
|
if (process.env.NODE_ENV !== 'production') {
|
|
157
157
|
console.log(`[uni-app] preloadWebview[${preloadWebview.id}]`)
|
|
158
158
|
}
|
|
@@ -170,4 +170,4 @@ export function consumeWebviewReady (pageId) {
|
|
|
170
170
|
const callbacks = webviewReadyCallbacks[pageId]
|
|
171
171
|
Array.isArray(callbacks) && callbacks.forEach(callback => callback())
|
|
172
172
|
delete webviewReadyCallbacks[pageId]
|
|
173
|
-
}
|
|
173
|
+
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
}
|
|
4
|
-
from 'uni-shared'
|
|
1
|
+
import { isPlainObject } from 'uni-shared'
|
|
2
|
+
|
|
3
|
+
import { initNavigationBarI18n } from 'uni-helpers/i18n'
|
|
5
4
|
|
|
6
5
|
function createButtonOnClick (index) {
|
|
7
6
|
return function onClick (btn) {
|
|
@@ -28,20 +27,18 @@ function parseTitleNViewButtons (titleNView) {
|
|
|
28
27
|
return titleNView
|
|
29
28
|
}
|
|
30
29
|
|
|
31
|
-
export function parseTitleNView (routeOptions) {
|
|
30
|
+
export function parseTitleNView (id, routeOptions) {
|
|
32
31
|
const windowOptions = routeOptions.window
|
|
33
32
|
const titleNView = windowOptions.titleNView
|
|
34
|
-
routeOptions.meta.statusBarStyle =
|
|
35
|
-
|
|
33
|
+
routeOptions.meta.statusBarStyle =
|
|
34
|
+
windowOptions.navigationBarTextStyle === 'black' ? 'dark' : 'light'
|
|
35
|
+
if (
|
|
36
|
+
// 无头
|
|
36
37
|
titleNView === false ||
|
|
37
38
|
titleNView === 'false' ||
|
|
38
|
-
(
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
) || (
|
|
42
|
-
windowOptions.transparentTitle === 'always' &&
|
|
43
|
-
!isPlainObject(titleNView)
|
|
44
|
-
)
|
|
39
|
+
(windowOptions.navigationStyle === 'custom' &&
|
|
40
|
+
!isPlainObject(titleNView)) ||
|
|
41
|
+
(windowOptions.transparentTitle === 'always' && !isPlainObject(titleNView))
|
|
45
42
|
) {
|
|
46
43
|
return false
|
|
47
44
|
}
|
|
@@ -54,28 +51,74 @@ export function parseTitleNView (routeOptions) {
|
|
|
54
51
|
always: 'float'
|
|
55
52
|
}
|
|
56
53
|
|
|
57
|
-
const navigationBarBackgroundColor =
|
|
54
|
+
const navigationBarBackgroundColor =
|
|
55
|
+
windowOptions.navigationBarBackgroundColor
|
|
58
56
|
const ret = {
|
|
59
57
|
autoBackButton: !routeOptions.meta.isQuit,
|
|
60
|
-
titleText:
|
|
61
|
-
|
|
58
|
+
titleText:
|
|
59
|
+
titleImage === '' ? windowOptions.navigationBarTitleText || '' : '',
|
|
60
|
+
titleColor:
|
|
61
|
+
windowOptions.navigationBarTextStyle === 'black' ? '#000000' : '#ffffff',
|
|
62
62
|
type: titleNViewTypeList[transparentTitle],
|
|
63
|
-
backgroundColor:
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
63
|
+
backgroundColor:
|
|
64
|
+
/^#[a-z0-9]{6}$/i.test(navigationBarBackgroundColor) ||
|
|
65
|
+
navigationBarBackgroundColor === 'transparent'
|
|
66
|
+
? navigationBarBackgroundColor
|
|
67
|
+
: '#f7f7f7',
|
|
68
|
+
tags:
|
|
69
|
+
titleImage === ''
|
|
70
|
+
? []
|
|
71
|
+
: [
|
|
72
|
+
{
|
|
73
|
+
tag: 'img',
|
|
74
|
+
src: titleImage,
|
|
75
|
+
position: {
|
|
76
|
+
left: 'auto',
|
|
77
|
+
top: 'auto',
|
|
78
|
+
width: 'auto',
|
|
79
|
+
height: '26px'
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
]
|
|
74
83
|
}
|
|
75
84
|
|
|
76
85
|
if (isPlainObject(titleNView)) {
|
|
77
|
-
return
|
|
86
|
+
return initTitleNViewI18n(
|
|
87
|
+
id,
|
|
88
|
+
Object.assign(ret, parseTitleNViewButtons(titleNView))
|
|
89
|
+
)
|
|
78
90
|
}
|
|
91
|
+
return initTitleNViewI18n(id, ret)
|
|
92
|
+
}
|
|
79
93
|
|
|
80
|
-
|
|
94
|
+
function initTitleNViewI18n (id, titleNView) {
|
|
95
|
+
const i18nResult = initNavigationBarI18n(titleNView)
|
|
96
|
+
if (!i18nResult) {
|
|
97
|
+
return titleNView
|
|
98
|
+
}
|
|
99
|
+
const [titleTextI18n, searchInputPlaceholderI18n] = i18nResult
|
|
100
|
+
if (titleTextI18n || searchInputPlaceholderI18n) {
|
|
101
|
+
uni.onLocaleChange(() => {
|
|
102
|
+
const webview = plus.webview.getWebviewById(id + '')
|
|
103
|
+
if (!webview) {
|
|
104
|
+
return
|
|
105
|
+
}
|
|
106
|
+
const newTitleNView = {}
|
|
107
|
+
if (titleTextI18n) {
|
|
108
|
+
newTitleNView.titleText = titleNView.titleText
|
|
109
|
+
}
|
|
110
|
+
if (searchInputPlaceholderI18n) {
|
|
111
|
+
newTitleNView.searchInput = {
|
|
112
|
+
placeholder: titleNView.searchInput.placeholder
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
116
|
+
console.log('[uni-app] updateWebview', webview.id, newTitleNView)
|
|
117
|
+
}
|
|
118
|
+
webview.setStyle({
|
|
119
|
+
titleNView: newTitleNView
|
|
120
|
+
})
|
|
121
|
+
})
|
|
122
|
+
}
|
|
123
|
+
return titleNView
|
|
81
124
|
}
|