Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
陈庄旺
uni-app
提交
98d7eb02
U
uni-app
项目概览
陈庄旺
/
uni-app
与 Fork 源项目一致
Fork自
DCloud / uni-app
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
U
uni-app
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
98d7eb02
编写于
8月 07, 2019
作者:
Q
qiang
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'dev'
上级
5a549d15
37c99d8f
变更
23
展开全部
隐藏空白更改
内联
并排
Showing
23 changed file
with
1431 addition
and
103 deletion
+1431
-103
docs/collocation/_sidebar.md
docs/collocation/_sidebar.md
+1
-0
docs/collocation/manifest.md
docs/collocation/manifest.md
+26
-1
docs/collocation/package.md
docs/collocation/package.md
+36
-0
docs/collocation/vue-config.md
docs/collocation/vue-config.md
+18
-0
packages/uni-app-plus/dist/index.js
packages/uni-app-plus/dist/index.js
+217
-11
packages/uni-app-plus/package.json
packages/uni-app-plus/package.json
+1
-1
packages/uni-h5/dist/index.umd.min.js
packages/uni-h5/dist/index.umd.min.js
+1
-1
packages/uni-h5/package.json
packages/uni-h5/package.json
+1
-1
packages/uni-mp-alipay/dist/index.js
packages/uni-mp-alipay/dist/index.js
+216
-10
packages/uni-mp-alipay/package.json
packages/uni-mp-alipay/package.json
+1
-1
packages/uni-mp-baidu/dist/index.js
packages/uni-mp-baidu/dist/index.js
+223
-12
packages/uni-mp-baidu/package.json
packages/uni-mp-baidu/package.json
+1
-1
packages/uni-mp-qq/dist/index.js
packages/uni-mp-qq/dist/index.js
+216
-10
packages/uni-mp-qq/package.json
packages/uni-mp-qq/package.json
+1
-1
packages/uni-mp-toutiao/dist/index.js
packages/uni-mp-toutiao/dist/index.js
+216
-10
packages/uni-mp-toutiao/package.json
packages/uni-mp-toutiao/package.json
+1
-1
packages/uni-mp-weixin/dist/index.js
packages/uni-mp-weixin/dist/index.js
+216
-10
packages/uni-mp-weixin/package.json
packages/uni-mp-weixin/package.json
+1
-1
src/core/helpers/protocol/popup.js
src/core/helpers/protocol/popup.js
+0
-4
src/core/service/api/popup.js
src/core/service/api/popup.js
+1
-1
src/platforms/app-plus-nvue/services/api/util.js
src/platforms/app-plus-nvue/services/api/util.js
+10
-13
src/platforms/h5/components/app/popup/mixins/toast.js
src/platforms/h5/components/app/popup/mixins/toast.js
+18
-9
src/platforms/mp-baidu/service/api/protocols.js
src/platforms/mp-baidu/service/api/protocols.js
+9
-4
未找到文件。
docs/collocation/_sidebar.md
浏览文件 @
98d7eb02
...
@@ -2,6 +2,7 @@
...
@@ -2,6 +2,7 @@
*
[
pages.json
](
collocation/pages.md
)
*
[
pages.json
](
collocation/pages.md
)
*
[
manifest.json
](
collocation/manifest.md
)
*
[
manifest.json
](
collocation/manifest.md
)
*
[
uni.scss
](
collocation/uni-scss.md
)
*
[
uni.scss
](
collocation/uni-scss.md
)
*
[
vue-config.js
](
collocation/vue-config.md
)
*
框架接口
*
框架接口
*
[
日志打印
](
collocation/frame/log.md
)
*
[
日志打印
](
collocation/frame/log.md
)
*
[
定时器
](
collocation/frame/timer.md
)
*
[
定时器
](
collocation/frame/timer.md
)
...
...
docs/collocation/manifest.md
浏览文件 @
98d7eb02
...
@@ -144,7 +144,9 @@ splash(启动封面)是App必然存在的、不可取消的。
...
@@ -144,7 +144,9 @@ splash(启动封面)是App必然存在的、不可取消的。
|async|Object|参考:
[
async
](
collocation/manifest?id=h5-async
)
|
|async|Object|参考:
[
async
](
collocation/manifest?id=h5-async
)
|
|devServer|Object|开发环境 server 配置,参考:
[
devServer
](
collocation/manifest?id=devserver
)
|
|devServer|Object|开发环境 server 配置,参考:
[
devServer
](
collocation/manifest?id=devserver
)
|
|publicPath|String|引用资源的地址前缀,仅发布时生效。参考:
[
publicPath
](
collocation/manifest?id=publicPath
)
|
|publicPath|String|引用资源的地址前缀,仅发布时生效。参考:
[
publicPath
](
collocation/manifest?id=publicPath
)
|
|sdkConfigs|String|SDK配置,例如地图... 参考:
[
sdkConfigs
](
collocation/manifest?id=h5sdkconfig
)
|
|sdkConfigs|String|SDK配置,例如地图... 参考:
[
sdkConfigs
](
collocation/manifest?id=h5sdkconfig
)
|
|optimization|Object|打包优化配置(HBuilderX 2.1.5 以上支持),参考
[
optimization
](
collocation/manifest?id=optimization
)
|
#### 自定义模板@h5-template
#### 自定义模板@h5-template
需要使用自定义模板的场景,通常有以下几种情况:
需要使用自定义模板的场景,通常有以下几种情况:
...
@@ -254,7 +256,30 @@ Tips:`uni-app` 中 `manifest.json->h5->devServer` 实际上对应 `webpack`
...
@@ -254,7 +256,30 @@ Tips:`uni-app` 中 `manifest.json->h5->devServer` 实际上对应 `webpack`
}
}
```
```
#### optimization
|属性|类型|默认值|说明|
|:-|:-|:-|:-|
|prefetch|Boolean|false|资源预取|
|preload|Boolean|false|资源预加载|
|treeShaking|Object||摇树优化,根据项目需求,动态打包框架所需的组件及API,保持框架代码最精简化,参考
[
treeShaking
](
collocation/manifest?id=treeshaking
)
|
##### treeShaking
|属性|类型|默认值|说明|
|:-|:-|:-|:-|
|enable|Boolean|false|是否启用摇树优化|
**示例:**
```
json
"h5"
:
{
"optimization"
:
{
"treeShaking"
:
{
"enable"
:
true
}
}
}
```
### mp-weixin
### mp-weixin
...
...
docs/collocation/package.md
0 → 100644
浏览文件 @
98d7eb02
package.json 是一个可选的配置文件,如果项目的根目录中存在这个文件,且根节点下含有
`uni-app`
节点,则支持自定义条件编译平台(如钉钉小程序、H5-weixin等)。
如下是一个自定义微信服务号平台(H5-WEIXIN)的示例配置:
```
json
"uni-app"
:
{
"scripts"
:
{
"h5-weixin"
:
{
//自定义编译平台配置,可通过cli方式调用
"env"
:
{
//环境变量
"UNI_PLATFORM"
:
"h5"
//基准平台
},
"define"
:
{
//自定义条件编译
"H5-WEIXIN"
:
true
//自定义常量,建议为大写
}
}
}
}
```
开发者可在代码块中使用
`H5-WEIXIN`
变量,如下:
```
// #ifdef H5-WEIXIN
微信服务号特有代码
// #endif
```
开发者可通过如下命令,启动微信服务号平台(H5-WEIXIN)平台的编译:
```
npm run dev:custom h5-weixin
npm run build:custom h5-weixin
```
Tips:
-
`UNI_PLATFORM`
仅支持填写
`uni-app`
默认支持的基准平台,目前仅限如下枚举值:
`app-plus`
、
`h5`
、
`mp-weixin`
、
`mp-alipay`
、
`mp-baidu`
、
`mp-toutiao`
、
`mp-qq`
。
docs/collocation/vue-config.md
0 → 100644
浏览文件 @
98d7eb02
vue.config.js 是一个可选的配置文件,如果项目的根目录中存在这个文件,那么它会被自动加载,具体规范参考:
[
vue-config.js
](
https://cli.vuejs.org/zh/config/#vue-config-js
)
**支持情况**
*
CLI 工程
*
HBuilderX 2.1.5 及以上版本
**注意事项**
部分配置项会被编译配置覆盖,例如:
*
publicPath 不支持,如果需要配置,请在 manifest.json->h5->router->base 中配置,参考文档:
[
h5-router
](
collocation/manifest?id=h5-router
)
*
outputDir 不支持
*
assetsDir 固定 static
*
pages 不支持
*
runtimeCompiler 固定 false
*
productionSourceMap 固定 false
*
css.extract H5 平台固定 false,其他平台固定 true
*
parallel 固定 false
\ No newline at end of file
packages/uni-app-plus/dist/index.js
浏览文件 @
98d7eb02
...
@@ -40,7 +40,198 @@ const camelize = cached((str) => {
...
@@ -40,7 +40,198 @@ const camelize = cached((str) => {
return
str
.
replace
(
camelizeRE
,
(
_
,
c
)
=>
c
?
c
.
toUpperCase
()
:
''
)
return
str
.
replace
(
camelizeRE
,
(
_
,
c
)
=>
c
?
c
.
toUpperCase
()
:
''
)
});
});
const
SYNC_API_RE
=
/^
\$
|getSubNVueById|requireNativePlugin|upx2px|hideKeyboard|canIUse|^create|Sync$|Manager$|base64ToArrayBuffer|arrayBufferToBase64/
;
const
HOOKS
=
[
'
invoke
'
,
'
success
'
,
'
fail
'
,
'
complete
'
,
'
returnValue
'
];
const
globalInterceptors
=
{};
const
scopedInterceptors
=
{};
function
mergeHook
(
parentVal
,
childVal
)
{
const
res
=
childVal
?
parentVal
?
parentVal
.
concat
(
childVal
)
:
Array
.
isArray
(
childVal
)
?
childVal
:
[
childVal
]
:
parentVal
;
return
res
?
dedupeHooks
(
res
)
:
res
}
function
dedupeHooks
(
hooks
)
{
const
res
=
[];
for
(
let
i
=
0
;
i
<
hooks
.
length
;
i
++
)
{
if
(
res
.
indexOf
(
hooks
[
i
])
===
-
1
)
{
res
.
push
(
hooks
[
i
]);
}
}
return
res
}
function
removeHook
(
hooks
,
hook
)
{
const
index
=
hooks
.
indexOf
(
hook
);
if
(
index
!==
-
1
)
{
hooks
.
splice
(
index
,
1
);
}
}
function
mergeInterceptorHook
(
interceptor
,
option
)
{
Object
.
keys
(
option
).
forEach
(
hook
=>
{
if
(
HOOKS
.
indexOf
(
hook
)
!==
-
1
&&
isFn
(
option
[
hook
]))
{
interceptor
[
hook
]
=
mergeHook
(
interceptor
[
hook
],
option
[
hook
]);
}
});
}
function
removeInterceptorHook
(
interceptor
,
option
)
{
if
(
!
interceptor
||
!
option
)
{
return
}
Object
.
keys
(
option
).
forEach
(
hook
=>
{
if
(
HOOKS
.
indexOf
(
hook
)
!==
-
1
&&
isFn
(
option
[
hook
]))
{
removeHook
(
interceptor
[
hook
],
option
[
hook
]);
}
});
}
function
addInterceptor
(
method
,
option
)
{
if
(
typeof
method
===
'
string
'
&&
isPlainObject
(
option
))
{
mergeInterceptorHook
(
scopedInterceptors
[
method
]
||
(
scopedInterceptors
[
method
]
=
{}),
option
);
}
else
if
(
isPlainObject
(
method
))
{
mergeInterceptorHook
(
globalInterceptors
,
method
);
}
}
function
removeInterceptor
(
method
,
option
)
{
if
(
typeof
method
===
'
string
'
)
{
if
(
isPlainObject
(
option
))
{
removeInterceptorHook
(
scopedInterceptors
[
method
],
option
);
}
else
{
delete
scopedInterceptors
[
method
];
}
}
else
if
(
isPlainObject
(
method
))
{
removeInterceptorHook
(
globalInterceptors
,
method
);
}
}
function
wrapperHook
(
hook
)
{
return
function
(
data
)
{
return
hook
(
data
)
||
data
}
}
function
isPromise
(
obj
)
{
return
!!
obj
&&
(
typeof
obj
===
'
object
'
||
typeof
obj
===
'
function
'
)
&&
typeof
obj
.
then
===
'
function
'
}
function
queue
(
hooks
,
data
)
{
let
promise
=
false
;
for
(
let
i
=
0
;
i
<
hooks
.
length
;
i
++
)
{
const
hook
=
hooks
[
i
];
if
(
promise
)
{
promise
=
Promise
.
then
(
wrapperHook
(
hook
));
}
else
{
const
res
=
hook
(
data
);
if
(
isPromise
(
res
))
{
promise
=
Promise
.
resolve
(
res
);
}
if
(
res
===
false
)
{
return
{
then
()
{}
}
}
}
}
return
promise
||
{
then
(
callback
)
{
return
callback
(
data
)
}
}
}
function
wrapperOptions
(
interceptor
,
options
=
{})
{
[
'
success
'
,
'
fail
'
,
'
complete
'
].
forEach
(
name
=>
{
if
(
Array
.
isArray
(
interceptor
[
name
]))
{
const
oldCallback
=
options
[
name
];
options
[
name
]
=
function
callbackInterceptor
(
res
)
{
queue
(
interceptor
[
name
],
res
).
then
((
res
)
=>
{
/* eslint-disable no-mixed-operators */
return
isFn
(
oldCallback
)
&&
oldCallback
(
res
)
||
res
});
};
}
});
return
options
}
function
wrapperReturnValue
(
method
,
returnValue
)
{
const
returnValueHooks
=
[];
if
(
Array
.
isArray
(
globalInterceptors
.
returnValue
))
{
returnValueHooks
.
push
(...
globalInterceptors
.
returnValue
);
}
const
interceptor
=
scopedInterceptors
[
method
];
if
(
interceptor
&&
Array
.
isArray
(
interceptor
.
returnValue
))
{
returnValueHooks
.
push
(...
interceptor
.
returnValue
);
}
returnValueHooks
.
forEach
(
hook
=>
{
returnValue
=
hook
(
returnValue
)
||
returnValue
;
});
return
returnValue
}
function
getApiInterceptorHooks
(
method
)
{
const
interceptor
=
Object
.
create
(
null
);
Object
.
keys
(
globalInterceptors
).
forEach
(
hook
=>
{
if
(
hook
!==
'
returnValue
'
)
{
interceptor
[
hook
]
=
globalInterceptors
[
hook
].
slice
();
}
});
const
scopedInterceptor
=
scopedInterceptors
[
method
];
if
(
scopedInterceptor
)
{
Object
.
keys
(
scopedInterceptor
).
forEach
(
hook
=>
{
if
(
hook
!==
'
returnValue
'
)
{
interceptor
[
hook
]
=
(
interceptor
[
hook
]
||
[]).
concat
(
scopedInterceptor
[
hook
]);
}
});
}
return
interceptor
}
function
invokeApi
(
method
,
api
,
options
,
...
params
)
{
const
interceptor
=
getApiInterceptorHooks
(
method
);
if
(
interceptor
&&
Object
.
keys
(
interceptor
).
length
)
{
if
(
Array
.
isArray
(
interceptor
.
invoke
))
{
const
res
=
queue
(
interceptor
.
invoke
,
options
);
return
res
.
then
((
options
)
=>
{
return
api
(
wrapperOptions
(
interceptor
,
options
),
...
params
)
})
}
else
{
return
api
(
wrapperOptions
(
interceptor
,
options
),
...
params
)
}
}
return
api
(
options
,
...
params
)
}
const
promiseInterceptor
=
{
returnValue
(
res
)
{
if
(
!
isPromise
(
res
))
{
return
res
}
return
res
.
then
(
res
=>
{
return
res
[
1
]
}).
catch
(
res
=>
{
return
res
[
0
]
})
}
};
const
SYNC_API_RE
=
/^
\$
|interceptors|Interceptor$|getSubNVueById|requireNativePlugin|upx2px|hideKeyboard|canIUse|^create|Sync$|Manager$|base64ToArrayBuffer|arrayBufferToBase64/
;
const
CONTEXT_API_RE
=
/^create|Manager$/
;
const
CONTEXT_API_RE
=
/^create|Manager$/
;
...
@@ -81,10 +272,10 @@ function promisify (name, api) {
...
@@ -81,10 +272,10 @@ function promisify (name, api) {
}
}
return
function
promiseApi
(
options
=
{},
...
params
)
{
return
function
promiseApi
(
options
=
{},
...
params
)
{
if
(
isFn
(
options
.
success
)
||
isFn
(
options
.
fail
)
||
isFn
(
options
.
complete
))
{
if
(
isFn
(
options
.
success
)
||
isFn
(
options
.
fail
)
||
isFn
(
options
.
complete
))
{
return
api
(
options
,
...
params
)
return
wrapperReturnValue
(
name
,
invokeApi
(
name
,
api
,
options
,
...
params
)
)
}
}
return
handlePromise
(
new
Promise
((
resolve
,
reject
)
=>
{
return
wrapperReturnValue
(
name
,
handlePromise
(
new
Promise
((
resolve
,
reject
)
=>
{
api
(
Object
.
assign
({},
options
,
{
invokeApi
(
name
,
api
,
Object
.
assign
({},
options
,
{
success
:
resolve
,
success
:
resolve
,
fail
:
reject
fail
:
reject
}),
...
params
);
}),
...
params
);
...
@@ -100,7 +291,7 @@ function promisify (name, api) {
...
@@ -100,7 +291,7 @@ function promisify (name, api) {
)
)
};
};
}
}
}))
}))
)
}
}
}
}
...
@@ -146,6 +337,19 @@ function upx2px (number, newDeviceWidth) {
...
@@ -146,6 +337,19 @@ function upx2px (number, newDeviceWidth) {
return
number
<
0
?
-
result
:
result
return
number
<
0
?
-
result
:
result
}
}
const
interceptors
=
{
promiseInterceptor
};
var
baseApi
=
/*#__PURE__*/
Object
.
freeze
({
upx2px
:
upx2px
,
interceptors
:
interceptors
,
addInterceptor
:
addInterceptor
,
removeInterceptor
:
removeInterceptor
});
const
protocols
=
{};
const
protocols
=
{};
const
todos
=
[];
const
todos
=
[];
const
canIUses
=
[];
const
canIUses
=
[];
...
@@ -1224,8 +1428,8 @@ let uni = {};
...
@@ -1224,8 +1428,8 @@ let uni = {};
if
(
typeof
Proxy
!==
'
undefined
'
&&
"
app-plus
"
!==
'
app-plus
'
)
{
if
(
typeof
Proxy
!==
'
undefined
'
&&
"
app-plus
"
!==
'
app-plus
'
)
{
uni
=
new
Proxy
({},
{
uni
=
new
Proxy
({},
{
get
(
target
,
name
)
{
get
(
target
,
name
)
{
if
(
name
===
'
upx2px
'
)
{
if
(
baseApi
[
name
]
)
{
return
upx2px
return
baseApi
[
name
]
}
}
if
(
api
[
name
])
{
if
(
api
[
name
])
{
return
promisify
(
name
,
api
[
name
])
return
promisify
(
name
,
api
[
name
])
...
@@ -1239,8 +1443,10 @@ if (typeof Proxy !== 'undefined' && "app-plus" !== 'app-plus') {
...
@@ -1239,8 +1443,10 @@ if (typeof Proxy !== 'undefined' && "app-plus" !== 'app-plus') {
return
promisify
(
name
,
wrapper
(
name
,
wx
[
name
]))
return
promisify
(
name
,
wrapper
(
name
,
wx
[
name
]))
}
}
});
});
}
else
{
}
else
{
uni
.
upx2px
=
upx2px
;
Object
.
keys
(
baseApi
).
forEach
(
name
=>
{
uni
[
name
]
=
baseApi
[
name
];
});
Object
.
keys
(
eventApi
).
forEach
(
name
=>
{
Object
.
keys
(
eventApi
).
forEach
(
name
=>
{
uni
[
name
]
=
eventApi
[
name
];
uni
[
name
]
=
eventApi
[
name
];
...
@@ -1258,12 +1464,12 @@ if (typeof Proxy !== 'undefined' && "app-plus" !== 'app-plus') {
...
@@ -1258,12 +1464,12 @@ if (typeof Proxy !== 'undefined' && "app-plus" !== 'app-plus') {
}
}
{
{
if
(
typeof
global
!==
'
undefined
'
)
{
if
(
typeof
global
!==
'
undefined
'
)
{
global
.
uni
=
uni
;
global
.
uni
=
uni
;
global
.
UniEmitter
=
eventApi
;
global
.
UniEmitter
=
eventApi
;
}
}
}
}
wx
.
createApp
=
createApp
;
wx
.
createApp
=
createApp
;
wx
.
createPage
=
createPage
;
wx
.
createPage
=
createPage
;
wx
.
createComponent
=
createComponent
;
wx
.
createComponent
=
createComponent
;
...
...
packages/uni-app-plus/package.json
浏览文件 @
98d7eb02
{
{
"name"
:
"@dcloudio/uni-app-plus"
,
"name"
:
"@dcloudio/uni-app-plus"
,
"version"
:
"0.0.24
7
"
,
"version"
:
"0.0.24
8
"
,
"description"
:
"uni-app app-plus"
,
"description"
:
"uni-app app-plus"
,
"main"
:
"dist/index.js"
,
"main"
:
"dist/index.js"
,
"scripts"
:
{
"scripts"
:
{
...
...
packages/uni-h5/dist/index.umd.min.js
浏览文件 @
98d7eb02
此差异已折叠。
点击以展开。
packages/uni-h5/package.json
浏览文件 @
98d7eb02
{
{
"name"
:
"@dcloudio/uni-h5"
,
"name"
:
"@dcloudio/uni-h5"
,
"version"
:
"0.7.
2
"
,
"version"
:
"0.7.
3
"
,
"description"
:
"uni-app h5"
,
"description"
:
"uni-app h5"
,
"main"
:
"dist/index.umd.min.js"
,
"main"
:
"dist/index.umd.min.js"
,
"scripts"
:
{
"scripts"
:
{
...
...
packages/uni-mp-alipay/dist/index.js
浏览文件 @
98d7eb02
...
@@ -40,7 +40,198 @@ const camelize = cached((str) => {
...
@@ -40,7 +40,198 @@ const camelize = cached((str) => {
return
str
.
replace
(
camelizeRE
,
(
_
,
c
)
=>
c
?
c
.
toUpperCase
()
:
''
)
return
str
.
replace
(
camelizeRE
,
(
_
,
c
)
=>
c
?
c
.
toUpperCase
()
:
''
)
});
});
const
SYNC_API_RE
=
/^
\$
|getSubNVueById|requireNativePlugin|upx2px|hideKeyboard|canIUse|^create|Sync$|Manager$|base64ToArrayBuffer|arrayBufferToBase64/
;
const
HOOKS
=
[
'
invoke
'
,
'
success
'
,
'
fail
'
,
'
complete
'
,
'
returnValue
'
];
const
globalInterceptors
=
{};
const
scopedInterceptors
=
{};
function
mergeHook
(
parentVal
,
childVal
)
{
const
res
=
childVal
?
parentVal
?
parentVal
.
concat
(
childVal
)
:
Array
.
isArray
(
childVal
)
?
childVal
:
[
childVal
]
:
parentVal
;
return
res
?
dedupeHooks
(
res
)
:
res
}
function
dedupeHooks
(
hooks
)
{
const
res
=
[];
for
(
let
i
=
0
;
i
<
hooks
.
length
;
i
++
)
{
if
(
res
.
indexOf
(
hooks
[
i
])
===
-
1
)
{
res
.
push
(
hooks
[
i
]);
}
}
return
res
}
function
removeHook
(
hooks
,
hook
)
{
const
index
=
hooks
.
indexOf
(
hook
);
if
(
index
!==
-
1
)
{
hooks
.
splice
(
index
,
1
);
}
}
function
mergeInterceptorHook
(
interceptor
,
option
)
{
Object
.
keys
(
option
).
forEach
(
hook
=>
{
if
(
HOOKS
.
indexOf
(
hook
)
!==
-
1
&&
isFn
(
option
[
hook
]))
{
interceptor
[
hook
]
=
mergeHook
(
interceptor
[
hook
],
option
[
hook
]);
}
});
}
function
removeInterceptorHook
(
interceptor
,
option
)
{
if
(
!
interceptor
||
!
option
)
{
return
}
Object
.
keys
(
option
).
forEach
(
hook
=>
{
if
(
HOOKS
.
indexOf
(
hook
)
!==
-
1
&&
isFn
(
option
[
hook
]))
{
removeHook
(
interceptor
[
hook
],
option
[
hook
]);
}
});
}
function
addInterceptor
(
method
,
option
)
{
if
(
typeof
method
===
'
string
'
&&
isPlainObject
(
option
))
{
mergeInterceptorHook
(
scopedInterceptors
[
method
]
||
(
scopedInterceptors
[
method
]
=
{}),
option
);
}
else
if
(
isPlainObject
(
method
))
{
mergeInterceptorHook
(
globalInterceptors
,
method
);
}
}
function
removeInterceptor
(
method
,
option
)
{
if
(
typeof
method
===
'
string
'
)
{
if
(
isPlainObject
(
option
))
{
removeInterceptorHook
(
scopedInterceptors
[
method
],
option
);
}
else
{
delete
scopedInterceptors
[
method
];
}
}
else
if
(
isPlainObject
(
method
))
{
removeInterceptorHook
(
globalInterceptors
,
method
);
}
}
function
wrapperHook
(
hook
)
{
return
function
(
data
)
{
return
hook
(
data
)
||
data
}
}
function
isPromise
(
obj
)
{
return
!!
obj
&&
(
typeof
obj
===
'
object
'
||
typeof
obj
===
'
function
'
)
&&
typeof
obj
.
then
===
'
function
'
}
function
queue
(
hooks
,
data
)
{
let
promise
=
false
;
for
(
let
i
=
0
;
i
<
hooks
.
length
;
i
++
)
{
const
hook
=
hooks
[
i
];
if
(
promise
)
{
promise
=
Promise
.
then
(
wrapperHook
(
hook
));
}
else
{
const
res
=
hook
(
data
);
if
(
isPromise
(
res
))
{
promise
=
Promise
.
resolve
(
res
);
}
if
(
res
===
false
)
{
return
{
then
()
{}
}
}
}
}
return
promise
||
{
then
(
callback
)
{
return
callback
(
data
)
}
}
}
function
wrapperOptions
(
interceptor
,
options
=
{})
{
[
'
success
'
,
'
fail
'
,
'
complete
'
].
forEach
(
name
=>
{
if
(
Array
.
isArray
(
interceptor
[
name
]))
{
const
oldCallback
=
options
[
name
];
options
[
name
]
=
function
callbackInterceptor
(
res
)
{
queue
(
interceptor
[
name
],
res
).
then
((
res
)
=>
{
/* eslint-disable no-mixed-operators */
return
isFn
(
oldCallback
)
&&
oldCallback
(
res
)
||
res
});
};
}
});
return
options
}
function
wrapperReturnValue
(
method
,
returnValue
)
{
const
returnValueHooks
=
[];
if
(
Array
.
isArray
(
globalInterceptors
.
returnValue
))
{
returnValueHooks
.
push
(...
globalInterceptors
.
returnValue
);
}
const
interceptor
=
scopedInterceptors
[
method
];
if
(
interceptor
&&
Array
.
isArray
(
interceptor
.
returnValue
))
{
returnValueHooks
.
push
(...
interceptor
.
returnValue
);
}
returnValueHooks
.
forEach
(
hook
=>
{
returnValue
=
hook
(
returnValue
)
||
returnValue
;
});
return
returnValue
}
function
getApiInterceptorHooks
(
method
)
{
const
interceptor
=
Object
.
create
(
null
);
Object
.
keys
(
globalInterceptors
).
forEach
(
hook
=>
{
if
(
hook
!==
'
returnValue
'
)
{
interceptor
[
hook
]
=
globalInterceptors
[
hook
].
slice
();
}
});
const
scopedInterceptor
=
scopedInterceptors
[
method
];
if
(
scopedInterceptor
)
{
Object
.
keys
(
scopedInterceptor
).
forEach
(
hook
=>
{
if
(
hook
!==
'
returnValue
'
)
{
interceptor
[
hook
]
=
(
interceptor
[
hook
]
||
[]).
concat
(
scopedInterceptor
[
hook
]);
}
});
}
return
interceptor
}
function
invokeApi
(
method
,
api
,
options
,
...
params
)
{
const
interceptor
=
getApiInterceptorHooks
(
method
);
if
(
interceptor
&&
Object
.
keys
(
interceptor
).
length
)
{
if
(
Array
.
isArray
(
interceptor
.
invoke
))
{
const
res
=
queue
(
interceptor
.
invoke
,
options
);
return
res
.
then
((
options
)
=>
{
return
api
(
wrapperOptions
(
interceptor
,
options
),
...
params
)
})
}
else
{
return
api
(
wrapperOptions
(
interceptor
,
options
),
...
params
)
}
}
return
api
(
options
,
...
params
)
}
const
promiseInterceptor
=
{
returnValue
(
res
)
{
if
(
!
isPromise
(
res
))
{
return
res
}
return
res
.
then
(
res
=>
{
return
res
[
1
]
}).
catch
(
res
=>
{
return
res
[
0
]
})
}
};
const
SYNC_API_RE
=
/^
\$
|interceptors|Interceptor$|getSubNVueById|requireNativePlugin|upx2px|hideKeyboard|canIUse|^create|Sync$|Manager$|base64ToArrayBuffer|arrayBufferToBase64/
;
const
CONTEXT_API_RE
=
/^create|Manager$/
;
const
CONTEXT_API_RE
=
/^create|Manager$/
;
...
@@ -81,10 +272,10 @@ function promisify (name, api) {
...
@@ -81,10 +272,10 @@ function promisify (name, api) {
}
}
return
function
promiseApi
(
options
=
{},
...
params
)
{
return
function
promiseApi
(
options
=
{},
...
params
)
{
if
(
isFn
(
options
.
success
)
||
isFn
(
options
.
fail
)
||
isFn
(
options
.
complete
))
{
if
(
isFn
(
options
.
success
)
||
isFn
(
options
.
fail
)
||
isFn
(
options
.
complete
))
{
return
api
(
options
,
...
params
)
return
wrapperReturnValue
(
name
,
invokeApi
(
name
,
api
,
options
,
...
params
)
)
}
}
return
handlePromise
(
new
Promise
((
resolve
,
reject
)
=>
{
return
wrapperReturnValue
(
name
,
handlePromise
(
new
Promise
((
resolve
,
reject
)
=>
{
api
(
Object
.
assign
({},
options
,
{
invokeApi
(
name
,
api
,
Object
.
assign
({},
options
,
{
success
:
resolve
,
success
:
resolve
,
fail
:
reject
fail
:
reject
}),
...
params
);
}),
...
params
);
...
@@ -100,7 +291,7 @@ function promisify (name, api) {
...
@@ -100,7 +291,7 @@ function promisify (name, api) {
)
)
};
};
}
}
}))
}))
)
}
}
}
}
...
@@ -146,6 +337,19 @@ function upx2px (number, newDeviceWidth) {
...
@@ -146,6 +337,19 @@ function upx2px (number, newDeviceWidth) {
return
number
<
0
?
-
result
:
result
return
number
<
0
?
-
result
:
result
}
}
const
interceptors
=
{
promiseInterceptor
};
var
baseApi
=
/*#__PURE__*/
Object
.
freeze
({
upx2px
:
upx2px
,
interceptors
:
interceptors
,
addInterceptor
:
addInterceptor
,
removeInterceptor
:
removeInterceptor
});
// 不支持的 API 列表
// 不支持的 API 列表
const
todos
=
[
const
todos
=
[
'
saveImageToPhotosAlbum
'
,
'
saveImageToPhotosAlbum
'
,
...
@@ -1796,8 +2000,8 @@ let uni = {};
...
@@ -1796,8 +2000,8 @@ let uni = {};
if
(
typeof
Proxy
!==
'
undefined
'
&&
"
mp-alipay
"
!==
'
app-plus
'
)
{
if
(
typeof
Proxy
!==
'
undefined
'
&&
"
mp-alipay
"
!==
'
app-plus
'
)
{
uni
=
new
Proxy
({},
{
uni
=
new
Proxy
({},
{
get
(
target
,
name
)
{
get
(
target
,
name
)
{
if
(
name
===
'
upx2px
'
)
{
if
(
baseApi
[
name
]
)
{
return
upx2px
return
baseApi
[
name
]
}
}
if
(
api
[
name
])
{
if
(
api
[
name
])
{
return
promisify
(
name
,
api
[
name
])
return
promisify
(
name
,
api
[
name
])
...
@@ -1819,8 +2023,10 @@ if (typeof Proxy !== 'undefined' && "mp-alipay" !== 'app-plus') {
...
@@ -1819,8 +2023,10 @@ if (typeof Proxy !== 'undefined' && "mp-alipay" !== 'app-plus') {
return
promisify
(
name
,
wrapper
(
name
,
my
[
name
]))
return
promisify
(
name
,
wrapper
(
name
,
my
[
name
]))
}
}
});
});
}
else
{
}
else
{
uni
.
upx2px
=
upx2px
;
Object
.
keys
(
baseApi
).
forEach
(
name
=>
{
uni
[
name
]
=
baseApi
[
name
];
});
{
{
Object
.
keys
(
todoApis
).
forEach
(
name
=>
{
Object
.
keys
(
todoApis
).
forEach
(
name
=>
{
...
@@ -1845,7 +2051,7 @@ if (typeof Proxy !== 'undefined' && "mp-alipay" !== 'app-plus') {
...
@@ -1845,7 +2051,7 @@ if (typeof Proxy !== 'undefined' && "mp-alipay" !== 'app-plus') {
}
}
});
});
}
}
my
.
createApp
=
createApp
;
my
.
createApp
=
createApp
;
my
.
createPage
=
createPage
;
my
.
createPage
=
createPage
;
my
.
createComponent
=
createComponent
;
my
.
createComponent
=
createComponent
;
...
...
packages/uni-mp-alipay/package.json
浏览文件 @
98d7eb02
{
{
"name"
:
"@dcloudio/uni-mp-alipay"
,
"name"
:
"@dcloudio/uni-mp-alipay"
,
"version"
:
"0.0.82
1
"
,
"version"
:
"0.0.82
2
"
,
"description"
:
"uni-app mp-alipay"
,
"description"
:
"uni-app mp-alipay"
,
"main"
:
"dist/index.js"
,
"main"
:
"dist/index.js"
,
"scripts"
:
{
"scripts"
:
{
...
...
packages/uni-mp-baidu/dist/index.js
浏览文件 @
98d7eb02
...
@@ -40,7 +40,198 @@ const camelize = cached((str) => {
...
@@ -40,7 +40,198 @@ const camelize = cached((str) => {
return
str
.
replace
(
camelizeRE
,
(
_
,
c
)
=>
c
?
c
.
toUpperCase
()
:
''
)
return
str
.
replace
(
camelizeRE
,
(
_
,
c
)
=>
c
?
c
.
toUpperCase
()
:
''
)
});
});
const
SYNC_API_RE
=
/^
\$
|getSubNVueById|requireNativePlugin|upx2px|hideKeyboard|canIUse|^create|Sync$|Manager$|base64ToArrayBuffer|arrayBufferToBase64/
;
const
HOOKS
=
[
'
invoke
'
,
'
success
'
,
'
fail
'
,
'
complete
'
,
'
returnValue
'
];
const
globalInterceptors
=
{};
const
scopedInterceptors
=
{};
function
mergeHook
(
parentVal
,
childVal
)
{
const
res
=
childVal
?
parentVal
?
parentVal
.
concat
(
childVal
)
:
Array
.
isArray
(
childVal
)
?
childVal
:
[
childVal
]
:
parentVal
;
return
res
?
dedupeHooks
(
res
)
:
res
}
function
dedupeHooks
(
hooks
)
{
const
res
=
[];
for
(
let
i
=
0
;
i
<
hooks
.
length
;
i
++
)
{
if
(
res
.
indexOf
(
hooks
[
i
])
===
-
1
)
{
res
.
push
(
hooks
[
i
]);
}
}
return
res
}
function
removeHook
(
hooks
,
hook
)
{
const
index
=
hooks
.
indexOf
(
hook
);
if
(
index
!==
-
1
)
{
hooks
.
splice
(
index
,
1
);
}
}
function
mergeInterceptorHook
(
interceptor
,
option
)
{
Object
.
keys
(
option
).
forEach
(
hook
=>
{
if
(
HOOKS
.
indexOf
(
hook
)
!==
-
1
&&
isFn
(
option
[
hook
]))
{
interceptor
[
hook
]
=
mergeHook
(
interceptor
[
hook
],
option
[
hook
]);
}
});
}
function
removeInterceptorHook
(
interceptor
,
option
)
{
if
(
!
interceptor
||
!
option
)
{
return
}
Object
.
keys
(
option
).
forEach
(
hook
=>
{
if
(
HOOKS
.
indexOf
(
hook
)
!==
-
1
&&
isFn
(
option
[
hook
]))
{
removeHook
(
interceptor
[
hook
],
option
[
hook
]);
}
});
}
function
addInterceptor
(
method
,
option
)
{
if
(
typeof
method
===
'
string
'
&&
isPlainObject
(
option
))
{
mergeInterceptorHook
(
scopedInterceptors
[
method
]
||
(
scopedInterceptors
[
method
]
=
{}),
option
);
}
else
if
(
isPlainObject
(
method
))
{
mergeInterceptorHook
(
globalInterceptors
,
method
);
}
}
function
removeInterceptor
(
method
,
option
)
{
if
(
typeof
method
===
'
string
'
)
{
if
(
isPlainObject
(
option
))
{
removeInterceptorHook
(
scopedInterceptors
[
method
],
option
);
}
else
{
delete
scopedInterceptors
[
method
];
}
}
else
if
(
isPlainObject
(
method
))
{
removeInterceptorHook
(
globalInterceptors
,
method
);
}
}
function
wrapperHook
(
hook
)
{
return
function
(
data
)
{
return
hook
(
data
)
||
data
}
}
function
isPromise
(
obj
)
{
return
!!
obj
&&
(
typeof
obj
===
'
object
'
||
typeof
obj
===
'
function
'
)
&&
typeof
obj
.
then
===
'
function
'
}
function
queue
(
hooks
,
data
)
{
let
promise
=
false
;
for
(
let
i
=
0
;
i
<
hooks
.
length
;
i
++
)
{
const
hook
=
hooks
[
i
];
if
(
promise
)
{
promise
=
Promise
.
then
(
wrapperHook
(
hook
));
}
else
{
const
res
=
hook
(
data
);
if
(
isPromise
(
res
))
{
promise
=
Promise
.
resolve
(
res
);
}
if
(
res
===
false
)
{
return
{
then
()
{}
}
}
}
}
return
promise
||
{
then
(
callback
)
{
return
callback
(
data
)
}
}
}
function
wrapperOptions
(
interceptor
,
options
=
{})
{
[
'
success
'
,
'
fail
'
,
'
complete
'
].
forEach
(
name
=>
{
if
(
Array
.
isArray
(
interceptor
[
name
]))
{
const
oldCallback
=
options
[
name
];
options
[
name
]
=
function
callbackInterceptor
(
res
)
{
queue
(
interceptor
[
name
],
res
).
then
((
res
)
=>
{
/* eslint-disable no-mixed-operators */
return
isFn
(
oldCallback
)
&&
oldCallback
(
res
)
||
res
});
};
}
});
return
options
}
function
wrapperReturnValue
(
method
,
returnValue
)
{
const
returnValueHooks
=
[];
if
(
Array
.
isArray
(
globalInterceptors
.
returnValue
))
{
returnValueHooks
.
push
(...
globalInterceptors
.
returnValue
);
}
const
interceptor
=
scopedInterceptors
[
method
];
if
(
interceptor
&&
Array
.
isArray
(
interceptor
.
returnValue
))
{
returnValueHooks
.
push
(...
interceptor
.
returnValue
);
}
returnValueHooks
.
forEach
(
hook
=>
{
returnValue
=
hook
(
returnValue
)
||
returnValue
;
});
return
returnValue
}
function
getApiInterceptorHooks
(
method
)
{
const
interceptor
=
Object
.
create
(
null
);
Object
.
keys
(
globalInterceptors
).
forEach
(
hook
=>
{
if
(
hook
!==
'
returnValue
'
)
{
interceptor
[
hook
]
=
globalInterceptors
[
hook
].
slice
();
}
});
const
scopedInterceptor
=
scopedInterceptors
[
method
];
if
(
scopedInterceptor
)
{
Object
.
keys
(
scopedInterceptor
).
forEach
(
hook
=>
{
if
(
hook
!==
'
returnValue
'
)
{
interceptor
[
hook
]
=
(
interceptor
[
hook
]
||
[]).
concat
(
scopedInterceptor
[
hook
]);
}
});
}
return
interceptor
}
function
invokeApi
(
method
,
api
,
options
,
...
params
)
{
const
interceptor
=
getApiInterceptorHooks
(
method
);
if
(
interceptor
&&
Object
.
keys
(
interceptor
).
length
)
{
if
(
Array
.
isArray
(
interceptor
.
invoke
))
{
const
res
=
queue
(
interceptor
.
invoke
,
options
);
return
res
.
then
((
options
)
=>
{
return
api
(
wrapperOptions
(
interceptor
,
options
),
...
params
)
})
}
else
{
return
api
(
wrapperOptions
(
interceptor
,
options
),
...
params
)
}
}
return
api
(
options
,
...
params
)
}
const
promiseInterceptor
=
{
returnValue
(
res
)
{
if
(
!
isPromise
(
res
))
{
return
res
}
return
res
.
then
(
res
=>
{
return
res
[
1
]
}).
catch
(
res
=>
{
return
res
[
0
]
})
}
};
const
SYNC_API_RE
=
/^
\$
|interceptors|Interceptor$|getSubNVueById|requireNativePlugin|upx2px|hideKeyboard|canIUse|^create|Sync$|Manager$|base64ToArrayBuffer|arrayBufferToBase64/
;
const
CONTEXT_API_RE
=
/^create|Manager$/
;
const
CONTEXT_API_RE
=
/^create|Manager$/
;
...
@@ -81,10 +272,10 @@ function promisify (name, api) {
...
@@ -81,10 +272,10 @@ function promisify (name, api) {
}
}
return
function
promiseApi
(
options
=
{},
...
params
)
{
return
function
promiseApi
(
options
=
{},
...
params
)
{
if
(
isFn
(
options
.
success
)
||
isFn
(
options
.
fail
)
||
isFn
(
options
.
complete
))
{
if
(
isFn
(
options
.
success
)
||
isFn
(
options
.
fail
)
||
isFn
(
options
.
complete
))
{
return
api
(
options
,
...
params
)
return
wrapperReturnValue
(
name
,
invokeApi
(
name
,
api
,
options
,
...
params
)
)
}
}
return
handlePromise
(
new
Promise
((
resolve
,
reject
)
=>
{
return
wrapperReturnValue
(
name
,
handlePromise
(
new
Promise
((
resolve
,
reject
)
=>
{
api
(
Object
.
assign
({},
options
,
{
invokeApi
(
name
,
api
,
Object
.
assign
({},
options
,
{
success
:
resolve
,
success
:
resolve
,
fail
:
reject
fail
:
reject
}),
...
params
);
}),
...
params
);
...
@@ -100,7 +291,7 @@ function promisify (name, api) {
...
@@ -100,7 +291,7 @@ function promisify (name, api) {
)
)
};
};
}
}
}))
}))
)
}
}
}
}
...
@@ -146,6 +337,19 @@ function upx2px (number, newDeviceWidth) {
...
@@ -146,6 +337,19 @@ function upx2px (number, newDeviceWidth) {
return
number
<
0
?
-
result
:
result
return
number
<
0
?
-
result
:
result
}
}
const
interceptors
=
{
promiseInterceptor
};
var
baseApi
=
/*#__PURE__*/
Object
.
freeze
({
upx2px
:
upx2px
,
interceptors
:
interceptors
,
addInterceptor
:
addInterceptor
,
removeInterceptor
:
removeInterceptor
});
var
previewImage
=
{
var
previewImage
=
{
args
(
fromArgs
)
{
args
(
fromArgs
)
{
let
currentIndex
=
parseInt
(
fromArgs
.
current
);
let
currentIndex
=
parseInt
(
fromArgs
.
current
);
...
@@ -229,9 +433,14 @@ const protocols = {
...
@@ -229,9 +433,14 @@ const protocols = {
// TODO
// TODO
// data 不支持 ArrayBuffer
// data 不支持 ArrayBuffer
// method 不支持 TRACE, CONNECT
// method 不支持 TRACE, CONNECT
// dataType 可取值为 string/json
return
{
return
{
method
:
'
method
'
method
:
'
method
'
,
dataType
(
type
)
{
return
{
name
:
'
dataType
'
,
value
:
type
===
'
json
'
?
type
:
'
string
'
}
}
}
}
}
}
},
},
...
@@ -1377,8 +1586,8 @@ let uni = {};
...
@@ -1377,8 +1586,8 @@ let uni = {};
if
(
typeof
Proxy
!==
'
undefined
'
&&
"
mp-baidu
"
!==
'
app-plus
'
)
{
if
(
typeof
Proxy
!==
'
undefined
'
&&
"
mp-baidu
"
!==
'
app-plus
'
)
{
uni
=
new
Proxy
({},
{
uni
=
new
Proxy
({},
{
get
(
target
,
name
)
{
get
(
target
,
name
)
{
if
(
name
===
'
upx2px
'
)
{
if
(
baseApi
[
name
]
)
{
return
upx2px
return
baseApi
[
name
]
}
}
if
(
api
[
name
])
{
if
(
api
[
name
])
{
return
promisify
(
name
,
api
[
name
])
return
promisify
(
name
,
api
[
name
])
...
@@ -1400,8 +1609,10 @@ if (typeof Proxy !== 'undefined' && "mp-baidu" !== 'app-plus') {
...
@@ -1400,8 +1609,10 @@ if (typeof Proxy !== 'undefined' && "mp-baidu" !== 'app-plus') {
return
promisify
(
name
,
wrapper
(
name
,
swan
[
name
]))
return
promisify
(
name
,
wrapper
(
name
,
swan
[
name
]))
}
}
});
});
}
else
{
}
else
{
uni
.
upx2px
=
upx2px
;
Object
.
keys
(
baseApi
).
forEach
(
name
=>
{
uni
[
name
]
=
baseApi
[
name
];
});
{
{
Object
.
keys
(
todoApis
).
forEach
(
name
=>
{
Object
.
keys
(
todoApis
).
forEach
(
name
=>
{
...
@@ -1426,7 +1637,7 @@ if (typeof Proxy !== 'undefined' && "mp-baidu" !== 'app-plus') {
...
@@ -1426,7 +1637,7 @@ if (typeof Proxy !== 'undefined' && "mp-baidu" !== 'app-plus') {
}
}
});
});
}
}
swan
.
createApp
=
createApp
;
swan
.
createApp
=
createApp
;
swan
.
createPage
=
createPage
;
swan
.
createPage
=
createPage
;
swan
.
createComponent
=
createComponent
;
swan
.
createComponent
=
createComponent
;
...
...
packages/uni-mp-baidu/package.json
浏览文件 @
98d7eb02
{
{
"name"
:
"@dcloudio/uni-mp-baidu"
,
"name"
:
"@dcloudio/uni-mp-baidu"
,
"version"
:
"0.0.85
0
"
,
"version"
:
"0.0.85
2
"
,
"description"
:
"uni-app mp-baidu"
,
"description"
:
"uni-app mp-baidu"
,
"main"
:
"dist/index.js"
,
"main"
:
"dist/index.js"
,
"scripts"
:
{
"scripts"
:
{
...
...
packages/uni-mp-qq/dist/index.js
浏览文件 @
98d7eb02
...
@@ -40,7 +40,198 @@ const camelize = cached((str) => {
...
@@ -40,7 +40,198 @@ const camelize = cached((str) => {
return
str
.
replace
(
camelizeRE
,
(
_
,
c
)
=>
c
?
c
.
toUpperCase
()
:
''
)
return
str
.
replace
(
camelizeRE
,
(
_
,
c
)
=>
c
?
c
.
toUpperCase
()
:
''
)
});
});
const
SYNC_API_RE
=
/^
\$
|getSubNVueById|requireNativePlugin|upx2px|hideKeyboard|canIUse|^create|Sync$|Manager$|base64ToArrayBuffer|arrayBufferToBase64/
;
const
HOOKS
=
[
'
invoke
'
,
'
success
'
,
'
fail
'
,
'
complete
'
,
'
returnValue
'
];
const
globalInterceptors
=
{};
const
scopedInterceptors
=
{};
function
mergeHook
(
parentVal
,
childVal
)
{
const
res
=
childVal
?
parentVal
?
parentVal
.
concat
(
childVal
)
:
Array
.
isArray
(
childVal
)
?
childVal
:
[
childVal
]
:
parentVal
;
return
res
?
dedupeHooks
(
res
)
:
res
}
function
dedupeHooks
(
hooks
)
{
const
res
=
[];
for
(
let
i
=
0
;
i
<
hooks
.
length
;
i
++
)
{
if
(
res
.
indexOf
(
hooks
[
i
])
===
-
1
)
{
res
.
push
(
hooks
[
i
]);
}
}
return
res
}
function
removeHook
(
hooks
,
hook
)
{
const
index
=
hooks
.
indexOf
(
hook
);
if
(
index
!==
-
1
)
{
hooks
.
splice
(
index
,
1
);
}
}
function
mergeInterceptorHook
(
interceptor
,
option
)
{
Object
.
keys
(
option
).
forEach
(
hook
=>
{
if
(
HOOKS
.
indexOf
(
hook
)
!==
-
1
&&
isFn
(
option
[
hook
]))
{
interceptor
[
hook
]
=
mergeHook
(
interceptor
[
hook
],
option
[
hook
]);
}
});
}
function
removeInterceptorHook
(
interceptor
,
option
)
{
if
(
!
interceptor
||
!
option
)
{
return
}
Object
.
keys
(
option
).
forEach
(
hook
=>
{
if
(
HOOKS
.
indexOf
(
hook
)
!==
-
1
&&
isFn
(
option
[
hook
]))
{
removeHook
(
interceptor
[
hook
],
option
[
hook
]);
}
});
}
function
addInterceptor
(
method
,
option
)
{
if
(
typeof
method
===
'
string
'
&&
isPlainObject
(
option
))
{
mergeInterceptorHook
(
scopedInterceptors
[
method
]
||
(
scopedInterceptors
[
method
]
=
{}),
option
);
}
else
if
(
isPlainObject
(
method
))
{
mergeInterceptorHook
(
globalInterceptors
,
method
);
}
}
function
removeInterceptor
(
method
,
option
)
{
if
(
typeof
method
===
'
string
'
)
{
if
(
isPlainObject
(
option
))
{
removeInterceptorHook
(
scopedInterceptors
[
method
],
option
);
}
else
{
delete
scopedInterceptors
[
method
];
}
}
else
if
(
isPlainObject
(
method
))
{
removeInterceptorHook
(
globalInterceptors
,
method
);
}
}
function
wrapperHook
(
hook
)
{
return
function
(
data
)
{
return
hook
(
data
)
||
data
}
}
function
isPromise
(
obj
)
{
return
!!
obj
&&
(
typeof
obj
===
'
object
'
||
typeof
obj
===
'
function
'
)
&&
typeof
obj
.
then
===
'
function
'
}
function
queue
(
hooks
,
data
)
{
let
promise
=
false
;
for
(
let
i
=
0
;
i
<
hooks
.
length
;
i
++
)
{
const
hook
=
hooks
[
i
];
if
(
promise
)
{
promise
=
Promise
.
then
(
wrapperHook
(
hook
));
}
else
{
const
res
=
hook
(
data
);
if
(
isPromise
(
res
))
{
promise
=
Promise
.
resolve
(
res
);
}
if
(
res
===
false
)
{
return
{
then
()
{}
}
}
}
}
return
promise
||
{
then
(
callback
)
{
return
callback
(
data
)
}
}
}
function
wrapperOptions
(
interceptor
,
options
=
{})
{
[
'
success
'
,
'
fail
'
,
'
complete
'
].
forEach
(
name
=>
{
if
(
Array
.
isArray
(
interceptor
[
name
]))
{
const
oldCallback
=
options
[
name
];
options
[
name
]
=
function
callbackInterceptor
(
res
)
{
queue
(
interceptor
[
name
],
res
).
then
((
res
)
=>
{
/* eslint-disable no-mixed-operators */
return
isFn
(
oldCallback
)
&&
oldCallback
(
res
)
||
res
});
};
}
});
return
options
}
function
wrapperReturnValue
(
method
,
returnValue
)
{
const
returnValueHooks
=
[];
if
(
Array
.
isArray
(
globalInterceptors
.
returnValue
))
{
returnValueHooks
.
push
(...
globalInterceptors
.
returnValue
);
}
const
interceptor
=
scopedInterceptors
[
method
];
if
(
interceptor
&&
Array
.
isArray
(
interceptor
.
returnValue
))
{
returnValueHooks
.
push
(...
interceptor
.
returnValue
);
}
returnValueHooks
.
forEach
(
hook
=>
{
returnValue
=
hook
(
returnValue
)
||
returnValue
;
});
return
returnValue
}
function
getApiInterceptorHooks
(
method
)
{
const
interceptor
=
Object
.
create
(
null
);
Object
.
keys
(
globalInterceptors
).
forEach
(
hook
=>
{
if
(
hook
!==
'
returnValue
'
)
{
interceptor
[
hook
]
=
globalInterceptors
[
hook
].
slice
();
}
});
const
scopedInterceptor
=
scopedInterceptors
[
method
];
if
(
scopedInterceptor
)
{
Object
.
keys
(
scopedInterceptor
).
forEach
(
hook
=>
{
if
(
hook
!==
'
returnValue
'
)
{
interceptor
[
hook
]
=
(
interceptor
[
hook
]
||
[]).
concat
(
scopedInterceptor
[
hook
]);
}
});
}
return
interceptor
}
function
invokeApi
(
method
,
api
,
options
,
...
params
)
{
const
interceptor
=
getApiInterceptorHooks
(
method
);
if
(
interceptor
&&
Object
.
keys
(
interceptor
).
length
)
{
if
(
Array
.
isArray
(
interceptor
.
invoke
))
{
const
res
=
queue
(
interceptor
.
invoke
,
options
);
return
res
.
then
((
options
)
=>
{
return
api
(
wrapperOptions
(
interceptor
,
options
),
...
params
)
})
}
else
{
return
api
(
wrapperOptions
(
interceptor
,
options
),
...
params
)
}
}
return
api
(
options
,
...
params
)
}
const
promiseInterceptor
=
{
returnValue
(
res
)
{
if
(
!
isPromise
(
res
))
{
return
res
}
return
res
.
then
(
res
=>
{
return
res
[
1
]
}).
catch
(
res
=>
{
return
res
[
0
]
})
}
};
const
SYNC_API_RE
=
/^
\$
|interceptors|Interceptor$|getSubNVueById|requireNativePlugin|upx2px|hideKeyboard|canIUse|^create|Sync$|Manager$|base64ToArrayBuffer|arrayBufferToBase64/
;
const
CONTEXT_API_RE
=
/^create|Manager$/
;
const
CONTEXT_API_RE
=
/^create|Manager$/
;
...
@@ -81,10 +272,10 @@ function promisify (name, api) {
...
@@ -81,10 +272,10 @@ function promisify (name, api) {
}
}
return
function
promiseApi
(
options
=
{},
...
params
)
{
return
function
promiseApi
(
options
=
{},
...
params
)
{
if
(
isFn
(
options
.
success
)
||
isFn
(
options
.
fail
)
||
isFn
(
options
.
complete
))
{
if
(
isFn
(
options
.
success
)
||
isFn
(
options
.
fail
)
||
isFn
(
options
.
complete
))
{
return
api
(
options
,
...
params
)
return
wrapperReturnValue
(
name
,
invokeApi
(
name
,
api
,
options
,
...
params
)
)
}
}
return
handlePromise
(
new
Promise
((
resolve
,
reject
)
=>
{
return
wrapperReturnValue
(
name
,
handlePromise
(
new
Promise
((
resolve
,
reject
)
=>
{
api
(
Object
.
assign
({},
options
,
{
invokeApi
(
name
,
api
,
Object
.
assign
({},
options
,
{
success
:
resolve
,
success
:
resolve
,
fail
:
reject
fail
:
reject
}),
...
params
);
}),
...
params
);
...
@@ -100,7 +291,7 @@ function promisify (name, api) {
...
@@ -100,7 +291,7 @@ function promisify (name, api) {
)
)
};
};
}
}
}))
}))
)
}
}
}
}
...
@@ -146,6 +337,19 @@ function upx2px (number, newDeviceWidth) {
...
@@ -146,6 +337,19 @@ function upx2px (number, newDeviceWidth) {
return
number
<
0
?
-
result
:
result
return
number
<
0
?
-
result
:
result
}
}
const
interceptors
=
{
promiseInterceptor
};
var
baseApi
=
/*#__PURE__*/
Object
.
freeze
({
upx2px
:
upx2px
,
interceptors
:
interceptors
,
addInterceptor
:
addInterceptor
,
removeInterceptor
:
removeInterceptor
});
var
previewImage
=
{
var
previewImage
=
{
args
(
fromArgs
)
{
args
(
fromArgs
)
{
let
currentIndex
=
parseInt
(
fromArgs
.
current
);
let
currentIndex
=
parseInt
(
fromArgs
.
current
);
...
@@ -1263,8 +1467,8 @@ let uni = {};
...
@@ -1263,8 +1467,8 @@ let uni = {};
if
(
typeof
Proxy
!==
'
undefined
'
&&
"
mp-qq
"
!==
'
app-plus
'
)
{
if
(
typeof
Proxy
!==
'
undefined
'
&&
"
mp-qq
"
!==
'
app-plus
'
)
{
uni
=
new
Proxy
({},
{
uni
=
new
Proxy
({},
{
get
(
target
,
name
)
{
get
(
target
,
name
)
{
if
(
name
===
'
upx2px
'
)
{
if
(
baseApi
[
name
]
)
{
return
upx2px
return
baseApi
[
name
]
}
}
if
(
api
[
name
])
{
if
(
api
[
name
])
{
return
promisify
(
name
,
api
[
name
])
return
promisify
(
name
,
api
[
name
])
...
@@ -1286,8 +1490,10 @@ if (typeof Proxy !== 'undefined' && "mp-qq" !== 'app-plus') {
...
@@ -1286,8 +1490,10 @@ if (typeof Proxy !== 'undefined' && "mp-qq" !== 'app-plus') {
return
promisify
(
name
,
wrapper
(
name
,
wx
[
name
]))
return
promisify
(
name
,
wrapper
(
name
,
wx
[
name
]))
}
}
});
});
}
else
{
}
else
{
uni
.
upx2px
=
upx2px
;
Object
.
keys
(
baseApi
).
forEach
(
name
=>
{
uni
[
name
]
=
baseApi
[
name
];
});
{
{
Object
.
keys
(
todoApis
).
forEach
(
name
=>
{
Object
.
keys
(
todoApis
).
forEach
(
name
=>
{
...
@@ -1312,7 +1518,7 @@ if (typeof Proxy !== 'undefined' && "mp-qq" !== 'app-plus') {
...
@@ -1312,7 +1518,7 @@ if (typeof Proxy !== 'undefined' && "mp-qq" !== 'app-plus') {
}
}
});
});
}
}
wx
.
createApp
=
createApp
;
wx
.
createApp
=
createApp
;
wx
.
createPage
=
createPage
;
wx
.
createPage
=
createPage
;
wx
.
createComponent
=
createComponent
;
wx
.
createComponent
=
createComponent
;
...
...
packages/uni-mp-qq/package.json
浏览文件 @
98d7eb02
{
{
"name"
:
"@dcloudio/uni-mp-qq"
,
"name"
:
"@dcloudio/uni-mp-qq"
,
"version"
:
"0.0.10
5
"
,
"version"
:
"0.0.10
6
"
,
"description"
:
"uni-app mp-qq"
,
"description"
:
"uni-app mp-qq"
,
"main"
:
"dist/index.js"
,
"main"
:
"dist/index.js"
,
"scripts"
:
{
"scripts"
:
{
...
...
packages/uni-mp-toutiao/dist/index.js
浏览文件 @
98d7eb02
...
@@ -40,7 +40,198 @@ const camelize = cached((str) => {
...
@@ -40,7 +40,198 @@ const camelize = cached((str) => {
return
str
.
replace
(
camelizeRE
,
(
_
,
c
)
=>
c
?
c
.
toUpperCase
()
:
''
)
return
str
.
replace
(
camelizeRE
,
(
_
,
c
)
=>
c
?
c
.
toUpperCase
()
:
''
)
});
});
const
SYNC_API_RE
=
/^
\$
|getSubNVueById|requireNativePlugin|upx2px|hideKeyboard|canIUse|^create|Sync$|Manager$|base64ToArrayBuffer|arrayBufferToBase64/
;
const
HOOKS
=
[
'
invoke
'
,
'
success
'
,
'
fail
'
,
'
complete
'
,
'
returnValue
'
];
const
globalInterceptors
=
{};
const
scopedInterceptors
=
{};
function
mergeHook
(
parentVal
,
childVal
)
{
const
res
=
childVal
?
parentVal
?
parentVal
.
concat
(
childVal
)
:
Array
.
isArray
(
childVal
)
?
childVal
:
[
childVal
]
:
parentVal
;
return
res
?
dedupeHooks
(
res
)
:
res
}
function
dedupeHooks
(
hooks
)
{
const
res
=
[];
for
(
let
i
=
0
;
i
<
hooks
.
length
;
i
++
)
{
if
(
res
.
indexOf
(
hooks
[
i
])
===
-
1
)
{
res
.
push
(
hooks
[
i
]);
}
}
return
res
}
function
removeHook
(
hooks
,
hook
)
{
const
index
=
hooks
.
indexOf
(
hook
);
if
(
index
!==
-
1
)
{
hooks
.
splice
(
index
,
1
);
}
}
function
mergeInterceptorHook
(
interceptor
,
option
)
{
Object
.
keys
(
option
).
forEach
(
hook
=>
{
if
(
HOOKS
.
indexOf
(
hook
)
!==
-
1
&&
isFn
(
option
[
hook
]))
{
interceptor
[
hook
]
=
mergeHook
(
interceptor
[
hook
],
option
[
hook
]);
}
});
}
function
removeInterceptorHook
(
interceptor
,
option
)
{
if
(
!
interceptor
||
!
option
)
{
return
}
Object
.
keys
(
option
).
forEach
(
hook
=>
{
if
(
HOOKS
.
indexOf
(
hook
)
!==
-
1
&&
isFn
(
option
[
hook
]))
{
removeHook
(
interceptor
[
hook
],
option
[
hook
]);
}
});
}
function
addInterceptor
(
method
,
option
)
{
if
(
typeof
method
===
'
string
'
&&
isPlainObject
(
option
))
{
mergeInterceptorHook
(
scopedInterceptors
[
method
]
||
(
scopedInterceptors
[
method
]
=
{}),
option
);
}
else
if
(
isPlainObject
(
method
))
{
mergeInterceptorHook
(
globalInterceptors
,
method
);
}
}
function
removeInterceptor
(
method
,
option
)
{
if
(
typeof
method
===
'
string
'
)
{
if
(
isPlainObject
(
option
))
{
removeInterceptorHook
(
scopedInterceptors
[
method
],
option
);
}
else
{
delete
scopedInterceptors
[
method
];
}
}
else
if
(
isPlainObject
(
method
))
{
removeInterceptorHook
(
globalInterceptors
,
method
);
}
}
function
wrapperHook
(
hook
)
{
return
function
(
data
)
{
return
hook
(
data
)
||
data
}
}
function
isPromise
(
obj
)
{
return
!!
obj
&&
(
typeof
obj
===
'
object
'
||
typeof
obj
===
'
function
'
)
&&
typeof
obj
.
then
===
'
function
'
}
function
queue
(
hooks
,
data
)
{
let
promise
=
false
;
for
(
let
i
=
0
;
i
<
hooks
.
length
;
i
++
)
{
const
hook
=
hooks
[
i
];
if
(
promise
)
{
promise
=
Promise
.
then
(
wrapperHook
(
hook
));
}
else
{
const
res
=
hook
(
data
);
if
(
isPromise
(
res
))
{
promise
=
Promise
.
resolve
(
res
);
}
if
(
res
===
false
)
{
return
{
then
()
{}
}
}
}
}
return
promise
||
{
then
(
callback
)
{
return
callback
(
data
)
}
}
}
function
wrapperOptions
(
interceptor
,
options
=
{})
{
[
'
success
'
,
'
fail
'
,
'
complete
'
].
forEach
(
name
=>
{
if
(
Array
.
isArray
(
interceptor
[
name
]))
{
const
oldCallback
=
options
[
name
];
options
[
name
]
=
function
callbackInterceptor
(
res
)
{
queue
(
interceptor
[
name
],
res
).
then
((
res
)
=>
{
/* eslint-disable no-mixed-operators */
return
isFn
(
oldCallback
)
&&
oldCallback
(
res
)
||
res
});
};
}
});
return
options
}
function
wrapperReturnValue
(
method
,
returnValue
)
{
const
returnValueHooks
=
[];
if
(
Array
.
isArray
(
globalInterceptors
.
returnValue
))
{
returnValueHooks
.
push
(...
globalInterceptors
.
returnValue
);
}
const
interceptor
=
scopedInterceptors
[
method
];
if
(
interceptor
&&
Array
.
isArray
(
interceptor
.
returnValue
))
{
returnValueHooks
.
push
(...
interceptor
.
returnValue
);
}
returnValueHooks
.
forEach
(
hook
=>
{
returnValue
=
hook
(
returnValue
)
||
returnValue
;
});
return
returnValue
}
function
getApiInterceptorHooks
(
method
)
{
const
interceptor
=
Object
.
create
(
null
);
Object
.
keys
(
globalInterceptors
).
forEach
(
hook
=>
{
if
(
hook
!==
'
returnValue
'
)
{
interceptor
[
hook
]
=
globalInterceptors
[
hook
].
slice
();
}
});
const
scopedInterceptor
=
scopedInterceptors
[
method
];
if
(
scopedInterceptor
)
{
Object
.
keys
(
scopedInterceptor
).
forEach
(
hook
=>
{
if
(
hook
!==
'
returnValue
'
)
{
interceptor
[
hook
]
=
(
interceptor
[
hook
]
||
[]).
concat
(
scopedInterceptor
[
hook
]);
}
});
}
return
interceptor
}
function
invokeApi
(
method
,
api
,
options
,
...
params
)
{
const
interceptor
=
getApiInterceptorHooks
(
method
);
if
(
interceptor
&&
Object
.
keys
(
interceptor
).
length
)
{
if
(
Array
.
isArray
(
interceptor
.
invoke
))
{
const
res
=
queue
(
interceptor
.
invoke
,
options
);
return
res
.
then
((
options
)
=>
{
return
api
(
wrapperOptions
(
interceptor
,
options
),
...
params
)
})
}
else
{
return
api
(
wrapperOptions
(
interceptor
,
options
),
...
params
)
}
}
return
api
(
options
,
...
params
)
}
const
promiseInterceptor
=
{
returnValue
(
res
)
{
if
(
!
isPromise
(
res
))
{
return
res
}
return
res
.
then
(
res
=>
{
return
res
[
1
]
}).
catch
(
res
=>
{
return
res
[
0
]
})
}
};
const
SYNC_API_RE
=
/^
\$
|interceptors|Interceptor$|getSubNVueById|requireNativePlugin|upx2px|hideKeyboard|canIUse|^create|Sync$|Manager$|base64ToArrayBuffer|arrayBufferToBase64/
;
const
CONTEXT_API_RE
=
/^create|Manager$/
;
const
CONTEXT_API_RE
=
/^create|Manager$/
;
...
@@ -81,10 +272,10 @@ function promisify (name, api) {
...
@@ -81,10 +272,10 @@ function promisify (name, api) {
}
}
return
function
promiseApi
(
options
=
{},
...
params
)
{
return
function
promiseApi
(
options
=
{},
...
params
)
{
if
(
isFn
(
options
.
success
)
||
isFn
(
options
.
fail
)
||
isFn
(
options
.
complete
))
{
if
(
isFn
(
options
.
success
)
||
isFn
(
options
.
fail
)
||
isFn
(
options
.
complete
))
{
return
api
(
options
,
...
params
)
return
wrapperReturnValue
(
name
,
invokeApi
(
name
,
api
,
options
,
...
params
)
)
}
}
return
handlePromise
(
new
Promise
((
resolve
,
reject
)
=>
{
return
wrapperReturnValue
(
name
,
handlePromise
(
new
Promise
((
resolve
,
reject
)
=>
{
api
(
Object
.
assign
({},
options
,
{
invokeApi
(
name
,
api
,
Object
.
assign
({},
options
,
{
success
:
resolve
,
success
:
resolve
,
fail
:
reject
fail
:
reject
}),
...
params
);
}),
...
params
);
...
@@ -100,7 +291,7 @@ function promisify (name, api) {
...
@@ -100,7 +291,7 @@ function promisify (name, api) {
)
)
};
};
}
}
}))
}))
)
}
}
}
}
...
@@ -146,6 +337,19 @@ function upx2px (number, newDeviceWidth) {
...
@@ -146,6 +337,19 @@ function upx2px (number, newDeviceWidth) {
return
number
<
0
?
-
result
:
result
return
number
<
0
?
-
result
:
result
}
}
const
interceptors
=
{
promiseInterceptor
};
var
baseApi
=
/*#__PURE__*/
Object
.
freeze
({
upx2px
:
upx2px
,
interceptors
:
interceptors
,
addInterceptor
:
addInterceptor
,
removeInterceptor
:
removeInterceptor
});
var
previewImage
=
{
var
previewImage
=
{
args
(
fromArgs
)
{
args
(
fromArgs
)
{
let
currentIndex
=
parseInt
(
fromArgs
.
current
);
let
currentIndex
=
parseInt
(
fromArgs
.
current
);
...
@@ -1442,8 +1646,8 @@ let uni = {};
...
@@ -1442,8 +1646,8 @@ let uni = {};
if
(
typeof
Proxy
!==
'
undefined
'
&&
"
mp-toutiao
"
!==
'
app-plus
'
)
{
if
(
typeof
Proxy
!==
'
undefined
'
&&
"
mp-toutiao
"
!==
'
app-plus
'
)
{
uni
=
new
Proxy
({},
{
uni
=
new
Proxy
({},
{
get
(
target
,
name
)
{
get
(
target
,
name
)
{
if
(
name
===
'
upx2px
'
)
{
if
(
baseApi
[
name
]
)
{
return
upx2px
return
baseApi
[
name
]
}
}
if
(
api
[
name
])
{
if
(
api
[
name
])
{
return
promisify
(
name
,
api
[
name
])
return
promisify
(
name
,
api
[
name
])
...
@@ -1465,8 +1669,10 @@ if (typeof Proxy !== 'undefined' && "mp-toutiao" !== 'app-plus') {
...
@@ -1465,8 +1669,10 @@ if (typeof Proxy !== 'undefined' && "mp-toutiao" !== 'app-plus') {
return
promisify
(
name
,
wrapper
(
name
,
tt
[
name
]))
return
promisify
(
name
,
wrapper
(
name
,
tt
[
name
]))
}
}
});
});
}
else
{
}
else
{
uni
.
upx2px
=
upx2px
;
Object
.
keys
(
baseApi
).
forEach
(
name
=>
{
uni
[
name
]
=
baseApi
[
name
];
});
{
{
Object
.
keys
(
todoApis
).
forEach
(
name
=>
{
Object
.
keys
(
todoApis
).
forEach
(
name
=>
{
...
@@ -1491,7 +1697,7 @@ if (typeof Proxy !== 'undefined' && "mp-toutiao" !== 'app-plus') {
...
@@ -1491,7 +1697,7 @@ if (typeof Proxy !== 'undefined' && "mp-toutiao" !== 'app-plus') {
}
}
});
});
}
}
tt
.
createApp
=
createApp
;
tt
.
createApp
=
createApp
;
tt
.
createPage
=
createPage
;
tt
.
createPage
=
createPage
;
tt
.
createComponent
=
createComponent
;
tt
.
createComponent
=
createComponent
;
...
...
packages/uni-mp-toutiao/package.json
浏览文件 @
98d7eb02
{
{
"name"
:
"@dcloudio/uni-mp-toutiao"
,
"name"
:
"@dcloudio/uni-mp-toutiao"
,
"version"
:
"0.0.34
5
"
,
"version"
:
"0.0.34
6
"
,
"description"
:
"uni-app mp-toutiao"
,
"description"
:
"uni-app mp-toutiao"
,
"main"
:
"dist/index.js"
,
"main"
:
"dist/index.js"
,
"scripts"
:
{
"scripts"
:
{
...
...
packages/uni-mp-weixin/dist/index.js
浏览文件 @
98d7eb02
...
@@ -40,7 +40,198 @@ const camelize = cached((str) => {
...
@@ -40,7 +40,198 @@ const camelize = cached((str) => {
return
str
.
replace
(
camelizeRE
,
(
_
,
c
)
=>
c
?
c
.
toUpperCase
()
:
''
)
return
str
.
replace
(
camelizeRE
,
(
_
,
c
)
=>
c
?
c
.
toUpperCase
()
:
''
)
});
});
const
SYNC_API_RE
=
/^
\$
|getSubNVueById|requireNativePlugin|upx2px|hideKeyboard|canIUse|^create|Sync$|Manager$|base64ToArrayBuffer|arrayBufferToBase64/
;
const
HOOKS
=
[
'
invoke
'
,
'
success
'
,
'
fail
'
,
'
complete
'
,
'
returnValue
'
];
const
globalInterceptors
=
{};
const
scopedInterceptors
=
{};
function
mergeHook
(
parentVal
,
childVal
)
{
const
res
=
childVal
?
parentVal
?
parentVal
.
concat
(
childVal
)
:
Array
.
isArray
(
childVal
)
?
childVal
:
[
childVal
]
:
parentVal
;
return
res
?
dedupeHooks
(
res
)
:
res
}
function
dedupeHooks
(
hooks
)
{
const
res
=
[];
for
(
let
i
=
0
;
i
<
hooks
.
length
;
i
++
)
{
if
(
res
.
indexOf
(
hooks
[
i
])
===
-
1
)
{
res
.
push
(
hooks
[
i
]);
}
}
return
res
}
function
removeHook
(
hooks
,
hook
)
{
const
index
=
hooks
.
indexOf
(
hook
);
if
(
index
!==
-
1
)
{
hooks
.
splice
(
index
,
1
);
}
}
function
mergeInterceptorHook
(
interceptor
,
option
)
{
Object
.
keys
(
option
).
forEach
(
hook
=>
{
if
(
HOOKS
.
indexOf
(
hook
)
!==
-
1
&&
isFn
(
option
[
hook
]))
{
interceptor
[
hook
]
=
mergeHook
(
interceptor
[
hook
],
option
[
hook
]);
}
});
}
function
removeInterceptorHook
(
interceptor
,
option
)
{
if
(
!
interceptor
||
!
option
)
{
return
}
Object
.
keys
(
option
).
forEach
(
hook
=>
{
if
(
HOOKS
.
indexOf
(
hook
)
!==
-
1
&&
isFn
(
option
[
hook
]))
{
removeHook
(
interceptor
[
hook
],
option
[
hook
]);
}
});
}
function
addInterceptor
(
method
,
option
)
{
if
(
typeof
method
===
'
string
'
&&
isPlainObject
(
option
))
{
mergeInterceptorHook
(
scopedInterceptors
[
method
]
||
(
scopedInterceptors
[
method
]
=
{}),
option
);
}
else
if
(
isPlainObject
(
method
))
{
mergeInterceptorHook
(
globalInterceptors
,
method
);
}
}
function
removeInterceptor
(
method
,
option
)
{
if
(
typeof
method
===
'
string
'
)
{
if
(
isPlainObject
(
option
))
{
removeInterceptorHook
(
scopedInterceptors
[
method
],
option
);
}
else
{
delete
scopedInterceptors
[
method
];
}
}
else
if
(
isPlainObject
(
method
))
{
removeInterceptorHook
(
globalInterceptors
,
method
);
}
}
function
wrapperHook
(
hook
)
{
return
function
(
data
)
{
return
hook
(
data
)
||
data
}
}
function
isPromise
(
obj
)
{
return
!!
obj
&&
(
typeof
obj
===
'
object
'
||
typeof
obj
===
'
function
'
)
&&
typeof
obj
.
then
===
'
function
'
}
function
queue
(
hooks
,
data
)
{
let
promise
=
false
;
for
(
let
i
=
0
;
i
<
hooks
.
length
;
i
++
)
{
const
hook
=
hooks
[
i
];
if
(
promise
)
{
promise
=
Promise
.
then
(
wrapperHook
(
hook
));
}
else
{
const
res
=
hook
(
data
);
if
(
isPromise
(
res
))
{
promise
=
Promise
.
resolve
(
res
);
}
if
(
res
===
false
)
{
return
{
then
()
{}
}
}
}
}
return
promise
||
{
then
(
callback
)
{
return
callback
(
data
)
}
}
}
function
wrapperOptions
(
interceptor
,
options
=
{})
{
[
'
success
'
,
'
fail
'
,
'
complete
'
].
forEach
(
name
=>
{
if
(
Array
.
isArray
(
interceptor
[
name
]))
{
const
oldCallback
=
options
[
name
];
options
[
name
]
=
function
callbackInterceptor
(
res
)
{
queue
(
interceptor
[
name
],
res
).
then
((
res
)
=>
{
/* eslint-disable no-mixed-operators */
return
isFn
(
oldCallback
)
&&
oldCallback
(
res
)
||
res
});
};
}
});
return
options
}
function
wrapperReturnValue
(
method
,
returnValue
)
{
const
returnValueHooks
=
[];
if
(
Array
.
isArray
(
globalInterceptors
.
returnValue
))
{
returnValueHooks
.
push
(...
globalInterceptors
.
returnValue
);
}
const
interceptor
=
scopedInterceptors
[
method
];
if
(
interceptor
&&
Array
.
isArray
(
interceptor
.
returnValue
))
{
returnValueHooks
.
push
(...
interceptor
.
returnValue
);
}
returnValueHooks
.
forEach
(
hook
=>
{
returnValue
=
hook
(
returnValue
)
||
returnValue
;
});
return
returnValue
}
function
getApiInterceptorHooks
(
method
)
{
const
interceptor
=
Object
.
create
(
null
);
Object
.
keys
(
globalInterceptors
).
forEach
(
hook
=>
{
if
(
hook
!==
'
returnValue
'
)
{
interceptor
[
hook
]
=
globalInterceptors
[
hook
].
slice
();
}
});
const
scopedInterceptor
=
scopedInterceptors
[
method
];
if
(
scopedInterceptor
)
{
Object
.
keys
(
scopedInterceptor
).
forEach
(
hook
=>
{
if
(
hook
!==
'
returnValue
'
)
{
interceptor
[
hook
]
=
(
interceptor
[
hook
]
||
[]).
concat
(
scopedInterceptor
[
hook
]);
}
});
}
return
interceptor
}
function
invokeApi
(
method
,
api
,
options
,
...
params
)
{
const
interceptor
=
getApiInterceptorHooks
(
method
);
if
(
interceptor
&&
Object
.
keys
(
interceptor
).
length
)
{
if
(
Array
.
isArray
(
interceptor
.
invoke
))
{
const
res
=
queue
(
interceptor
.
invoke
,
options
);
return
res
.
then
((
options
)
=>
{
return
api
(
wrapperOptions
(
interceptor
,
options
),
...
params
)
})
}
else
{
return
api
(
wrapperOptions
(
interceptor
,
options
),
...
params
)
}
}
return
api
(
options
,
...
params
)
}
const
promiseInterceptor
=
{
returnValue
(
res
)
{
if
(
!
isPromise
(
res
))
{
return
res
}
return
res
.
then
(
res
=>
{
return
res
[
1
]
}).
catch
(
res
=>
{
return
res
[
0
]
})
}
};
const
SYNC_API_RE
=
/^
\$
|interceptors|Interceptor$|getSubNVueById|requireNativePlugin|upx2px|hideKeyboard|canIUse|^create|Sync$|Manager$|base64ToArrayBuffer|arrayBufferToBase64/
;
const
CONTEXT_API_RE
=
/^create|Manager$/
;
const
CONTEXT_API_RE
=
/^create|Manager$/
;
...
@@ -81,10 +272,10 @@ function promisify (name, api) {
...
@@ -81,10 +272,10 @@ function promisify (name, api) {
}
}
return
function
promiseApi
(
options
=
{},
...
params
)
{
return
function
promiseApi
(
options
=
{},
...
params
)
{
if
(
isFn
(
options
.
success
)
||
isFn
(
options
.
fail
)
||
isFn
(
options
.
complete
))
{
if
(
isFn
(
options
.
success
)
||
isFn
(
options
.
fail
)
||
isFn
(
options
.
complete
))
{
return
api
(
options
,
...
params
)
return
wrapperReturnValue
(
name
,
invokeApi
(
name
,
api
,
options
,
...
params
)
)
}
}
return
handlePromise
(
new
Promise
((
resolve
,
reject
)
=>
{
return
wrapperReturnValue
(
name
,
handlePromise
(
new
Promise
((
resolve
,
reject
)
=>
{
api
(
Object
.
assign
({},
options
,
{
invokeApi
(
name
,
api
,
Object
.
assign
({},
options
,
{
success
:
resolve
,
success
:
resolve
,
fail
:
reject
fail
:
reject
}),
...
params
);
}),
...
params
);
...
@@ -100,7 +291,7 @@ function promisify (name, api) {
...
@@ -100,7 +291,7 @@ function promisify (name, api) {
)
)
};
};
}
}
}))
}))
)
}
}
}
}
...
@@ -146,6 +337,19 @@ function upx2px (number, newDeviceWidth) {
...
@@ -146,6 +337,19 @@ function upx2px (number, newDeviceWidth) {
return
number
<
0
?
-
result
:
result
return
number
<
0
?
-
result
:
result
}
}
const
interceptors
=
{
promiseInterceptor
};
var
baseApi
=
/*#__PURE__*/
Object
.
freeze
({
upx2px
:
upx2px
,
interceptors
:
interceptors
,
addInterceptor
:
addInterceptor
,
removeInterceptor
:
removeInterceptor
});
var
previewImage
=
{
var
previewImage
=
{
args
(
fromArgs
)
{
args
(
fromArgs
)
{
let
currentIndex
=
parseInt
(
fromArgs
.
current
);
let
currentIndex
=
parseInt
(
fromArgs
.
current
);
...
@@ -1194,8 +1398,8 @@ let uni = {};
...
@@ -1194,8 +1398,8 @@ let uni = {};
if
(
typeof
Proxy
!==
'
undefined
'
&&
"
mp-weixin
"
!==
'
app-plus
'
)
{
if
(
typeof
Proxy
!==
'
undefined
'
&&
"
mp-weixin
"
!==
'
app-plus
'
)
{
uni
=
new
Proxy
({},
{
uni
=
new
Proxy
({},
{
get
(
target
,
name
)
{
get
(
target
,
name
)
{
if
(
name
===
'
upx2px
'
)
{
if
(
baseApi
[
name
]
)
{
return
upx2px
return
baseApi
[
name
]
}
}
if
(
api
[
name
])
{
if
(
api
[
name
])
{
return
promisify
(
name
,
api
[
name
])
return
promisify
(
name
,
api
[
name
])
...
@@ -1217,8 +1421,10 @@ if (typeof Proxy !== 'undefined' && "mp-weixin" !== 'app-plus') {
...
@@ -1217,8 +1421,10 @@ if (typeof Proxy !== 'undefined' && "mp-weixin" !== 'app-plus') {
return
promisify
(
name
,
wrapper
(
name
,
wx
[
name
]))
return
promisify
(
name
,
wrapper
(
name
,
wx
[
name
]))
}
}
});
});
}
else
{
}
else
{
uni
.
upx2px
=
upx2px
;
Object
.
keys
(
baseApi
).
forEach
(
name
=>
{
uni
[
name
]
=
baseApi
[
name
];
});
{
{
Object
.
keys
(
todoApis
).
forEach
(
name
=>
{
Object
.
keys
(
todoApis
).
forEach
(
name
=>
{
...
@@ -1243,7 +1449,7 @@ if (typeof Proxy !== 'undefined' && "mp-weixin" !== 'app-plus') {
...
@@ -1243,7 +1449,7 @@ if (typeof Proxy !== 'undefined' && "mp-weixin" !== 'app-plus') {
}
}
});
});
}
}
wx
.
createApp
=
createApp
;
wx
.
createApp
=
createApp
;
wx
.
createPage
=
createPage
;
wx
.
createPage
=
createPage
;
wx
.
createComponent
=
createComponent
;
wx
.
createComponent
=
createComponent
;
...
...
packages/uni-mp-weixin/package.json
浏览文件 @
98d7eb02
{
{
"name"
:
"@dcloudio/uni-mp-weixin"
,
"name"
:
"@dcloudio/uni-mp-weixin"
,
"version"
:
"0.0.96
6
"
,
"version"
:
"0.0.96
7
"
,
"description"
:
"uni-app mp-weixin"
,
"description"
:
"uni-app mp-weixin"
,
"main"
:
"dist/index.js"
,
"main"
:
"dist/index.js"
,
"scripts"
:
{
"scripts"
:
{
...
...
src/core/helpers/protocol/popup.js
浏览文件 @
98d7eb02
...
@@ -90,10 +90,6 @@ export const showLoading = {
...
@@ -90,10 +90,6 @@ export const showLoading = {
visible
:
{
visible
:
{
type
:
Boolean
,
type
:
Boolean
,
default
:
true
default
:
true
},
isShowLoading
:
{
type
:
Boolean
,
default
:
true
}
}
}
}
...
...
src/core/service/api/popup.js
浏览文件 @
98d7eb02
...
@@ -22,7 +22,7 @@ export function hideToast () {
...
@@ -22,7 +22,7 @@ export function hideToast () {
}
}
export
function
showLoading
(
args
)
{
export
function
showLoading
(
args
)
{
emit
(
'
onShow
Toast
'
,
args
)
emit
(
'
onShow
Loading
'
,
args
)
return
{}
return
{}
}
}
...
...
src/platforms/app-plus-nvue/services/api/util.js
浏览文件 @
98d7eb02
...
@@ -51,27 +51,24 @@ export function invokeVmMethod (vm, method, args, extras) {
...
@@ -51,27 +51,24 @@ export function invokeVmMethod (vm, method, args, extras) {
}
}
export
function
findRefById
(
id
,
vm
)
{
export
function
findRefById
(
id
,
vm
)
{
return
findRefBy
VNode
(
id
,
vm
.
_vnode
)
return
findRefBy
Elm
(
id
,
vm
.
$el
)
}
}
function
findRefBy
VNode
(
id
,
vnode
)
{
function
findRefBy
Elm
(
id
,
elm
)
{
if
(
!
id
||
!
vnode
)
{
if
(
!
id
||
!
elm
)
{
return
return
}
}
if
(
vnode
.
data
&&
if
(
elm
.
attr
.
id
===
id
)
{
vnode
.
data
.
ref
&&
return
elm
vnode
.
data
.
attrs
&&
vnode
.
data
.
attrs
.
id
===
id
)
{
return
vnode
.
data
.
ref
}
}
const
children
=
vnode
.
children
const
children
=
elm
.
children
if
(
!
children
)
{
if
(
!
children
)
{
return
return
}
}
for
(
let
i
=
0
,
len
=
children
.
length
;
i
<
len
;
i
++
)
{
for
(
let
i
=
0
,
len
=
children
.
length
;
i
<
len
;
i
++
)
{
const
ref
=
findRefByVNode
(
id
,
children
[
i
])
const
elm
=
findRefByElm
(
id
,
children
[
i
])
if
(
ref
)
{
if
(
elm
)
{
return
ref
return
elm
}
}
}
}
}
}
...
@@ -116,4 +113,4 @@ function normalizeCallback (method, callbacks) {
...
@@ -116,4 +113,4 @@ function normalizeCallback (method, callbacks) {
isFn
(
complete
)
&&
complete
(
ret
)
isFn
(
complete
)
&&
complete
(
ret
)
}
}
}
}
}
}
src/platforms/h5/components/app/popup/mixins/toast.js
浏览文件 @
98d7eb02
...
@@ -7,28 +7,37 @@ export default {
...
@@ -7,28 +7,37 @@ export default {
}
}
},
},
created
()
{
created
()
{
UniServiceJSBridge
.
on
(
'
onShowToast
'
,
args
=>
{
let
showType
=
''
setTimeout
(()
=>
{
// 延迟一下 show 可解决窗口打开前调用 showToast 在 onHidePopup 之后触发
this
.
showToast
=
args
const
createOnShow
=
(
type
)
=>
{
},
10
)
return
(
args
)
=>
{
})
showType
=
type
setTimeout
(()
=>
{
// 延迟一下 show 可解决窗口打开前调用 showToast 在 onHidePopup 之后触发
this
.
showToast
=
args
},
10
)
}
}
UniServiceJSBridge
.
on
(
'
onShowToast
'
,
createOnShow
(
'
onShowToast
'
))
UniServiceJSBridge
.
on
(
'
onShowLoading
'
,
createOnShow
(
'
onShowLoading
'
))
const
createOnHide
=
(
type
)
=>
{
const
createOnHide
=
(
type
)
=>
{
return
()
=>
{
return
()
=>
{
let
warnMsg
=
''
let
warnMsg
=
''
if
(
type
===
'
onHideToast
'
&&
this
.
showToast
.
isShowLoading
)
{
if
(
type
===
'
onHideToast
'
&&
showType
!==
'
onShowToast
'
)
{
warnMsg
=
'
请注意 showToast 与 hideToast 必须配对使用
'
warnMsg
=
'
请注意 showToast 与 hideToast 必须配对使用
'
}
else
if
(
type
===
'
onHideLoading
'
&&
!
this
.
showToast
.
isShowLoading
)
{
}
else
if
(
type
===
'
onHideLoading
'
&&
showType
!==
'
onShowLoading
'
)
{
warnMsg
=
'
请注意 showLoading 与 hideLoading 必须配对使用
'
warnMsg
=
'
请注意 showLoading 与 hideLoading 必须配对使用
'
}
}
if
(
warnMsg
)
{
if
(
warnMsg
)
{
return
console
.
warn
(
warnMsg
)
return
console
.
warn
(
warnMsg
)
}
}
showType
=
''
setTimeout
(()
=>
{
// 与 show 对应延迟10ms,避免快速调用 show,hide 导致无法关闭
setTimeout
(()
=>
{
// 与 show 对应延迟10ms,避免快速调用 show,hide 导致无法关闭
this
.
showToast
.
visible
=
false
this
.
showToast
.
visible
=
false
},
10
)
},
10
)
}
}
}
}
UniServiceJSBridge
.
on
(
'
onHidePopup
'
,
createOnHide
(
'
onHidePopup
'
))
UniServiceJSBridge
.
on
(
'
onHidePopup
'
,
createOnHide
(
'
onHidePopup
'
))
UniServiceJSBridge
.
on
(
'
onHideToast
'
,
createOnHide
(
'
onHideToast
'
))
UniServiceJSBridge
.
on
(
'
onHideToast
'
,
createOnHide
(
'
onHideToast
'
))
...
...
src/platforms/mp-baidu/service/api/protocols.js
浏览文件 @
98d7eb02
import
previewImage
from
'
../../../mp-weixin/helpers/normalize-preview-image
'
import
previewImage
from
'
../../../mp-weixin/helpers/normalize-preview-image
'
// 不支持的 API 列表
// 不支持的 API 列表
const
todos
=
[
const
todos
=
[
'
hideKeyboard
'
,
'
hideKeyboard
'
,
...
@@ -48,9 +48,14 @@ const protocols = {
...
@@ -48,9 +48,14 @@ const protocols = {
// TODO
// TODO
// data 不支持 ArrayBuffer
// data 不支持 ArrayBuffer
// method 不支持 TRACE, CONNECT
// method 不支持 TRACE, CONNECT
// dataType 可取值为 string/json
return
{
return
{
method
:
'
method
'
method
:
'
method
'
,
dataType
(
type
)
{
return
{
name
:
'
dataType
'
,
value
:
type
===
'
json
'
?
type
:
'
string
'
}
}
}
}
}
}
},
},
...
@@ -96,4 +101,4 @@ export {
...
@@ -96,4 +101,4 @@ export {
protocols
,
protocols
,
todos
,
todos
,
canIUses
canIUses
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录