Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lzb_79
uni-app
提交
eca0cc12
U
uni-app
项目概览
lzb_79
/
uni-app
与 Fork 源项目一致
Fork自
DCloud / uni-app
通知
1
Star
1
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,发现更多精彩内容 >>
提交
eca0cc12
编写于
7月 08, 2021
作者:
D
DCloud_LXH
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix(App): showToast
上级
f4330786
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
86 addition
and
104 deletion
+86
-104
packages/uni-app-plus/src/helpers/plus.ts
packages/uni-app-plus/src/helpers/plus.ts
+0
-15
packages/uni-app-plus/src/service/api/ui/popup/showToast.ts
packages/uni-app-plus/src/service/api/ui/popup/showToast.ts
+86
-89
未找到文件。
packages/uni-app-plus/src/helpers/plus.ts
浏览文件 @
eca0cc12
...
...
@@ -66,21 +66,6 @@ export function warpPlusMethod(
}
}
export
function
callApiSync
<
T
extends
(...
args
:
any
)
=>
any
>
(
api
:
T
,
args
:
Parameters
<
T
>
[
0
],
resolve
:
Function
,
reject
:
(
errMsg
?:
string
|
undefined
,
errRes
?:
any
)
=>
void
)
{
api
(
args
)
.
then
(()
=>
{
resolve
()
})
.
catch
((
errMsg
:
string
)
=>
{
reject
(
errMsg
)
})
}
export
function
isTabBarPage
(
path
=
''
)
{
if
(
!
(
__uniConfig
.
tabBar
&&
Array
.
isArray
(
__uniConfig
.
tabBar
.
list
)))
{
return
false
...
...
packages/uni-app-plus/src/service/api/ui/popup/showToast.ts
浏览文件 @
eca0cc12
import
{
extend
}
from
'
@vue/shared
'
import
{
callApiSync
}
from
'
../../../../helpers/plus
'
import
{
defineAsyncApi
,
ShowToastOptions
,
...
...
@@ -16,6 +15,9 @@ import {
API_HIDE_LOADING
,
}
from
'
@dcloudio/uni-api
'
type
Resolve
=
(
res
?:
any
)
=>
void
type
Reject
=
(
errMsg
?:
string
,
errRes
?:
any
)
=>
void
type
ToastType
=
'
loading
'
|
'
toast
'
|
''
let
toast
:
PlusNativeUIWaitingObj
|
null
...
...
@@ -25,30 +27,18 @@ let timeout: number | null
export
const
showLoading
=
defineAsyncApi
<
API_TYPE_SHOW_LOADING
>
(
API_SHOW_LOADING
,
(
args
,
{
resolve
,
reject
})
=>
{
callApiSync
<
typeof
showToast
>
(
showToast
,
(
args
,
callbacks
)
=>
_showToast
(
extend
({},
args
,
{
type
:
'
loading
'
,
}),
resolve
,
reject
)
},
callbacks
),
ShowLoadingProtocol
,
ShowLoadingOptions
)
export
const
hideLoading
=
defineAsyncApi
<
API_TYPE_HIDE_LOADING
>
(
API_HIDE_LOADING
,
(
_
,
{
resolve
,
reject
})
=>
{
callApiSync
<
typeof
hide
>
(
hide
,
'
loading
'
,
resolve
,
reject
)
}
)
export
const
showToast
=
defineAsyncApi
<
API_TYPE_SHOW_TOAST
>
(
API_SHOW_TOAST
,
(
const
_showToast
=
(
{
title
=
''
,
icon
=
'
success
'
,
...
...
@@ -60,9 +50,9 @@ export const showToast = defineAsyncApi<API_TYPE_SHOW_TOAST>(
type
=
'
toast
'
,
// @ts-ignore PlusNativeUIWaitingStyles
style
,
}
,
{
resolve
,
r
eject
}
)
=>
{
}:
UniApp
.
ShowToastOptions
,
{
resolve
,
reject
}:
{
resolve
:
Resolve
;
reject
:
R
eject
}
)
=>
{
hide
(
''
)
toastType
=
type
if
([
'
top
'
,
'
center
'
,
'
bottom
'
].
includes
(
String
(
position
)))
{
...
...
@@ -122,21 +112,30 @@ export const showToast = defineAsyncApi<API_TYPE_SHOW_TOAST>(
hide
(
''
)
},
duration
)
return
resolve
()
},
}
export
const
showToast
=
defineAsyncApi
<
API_TYPE_SHOW_TOAST
>
(
API_SHOW_TOAST
,
_showToast
,
ShowToastProtocol
,
ShowToastOptions
)
export
const
hideToast
=
defineAsyncApi
<
API_TYPE_HIDE_TOAST
>
(
API_HIDE_TOAST
,
(
_
,
{
resolve
,
reject
})
=>
{
callApiSync
<
typeof
hide
>
(
hide
,
'
toast
'
,
resolve
,
reject
)
}
(
_
,
callbacks
)
=>
hide
(
'
toast
'
,
callbacks
)
)
export
const
hideLoading
=
defineAsyncApi
<
API_TYPE_HIDE_LOADING
>
(
API_HIDE_LOADING
,
(
_
,
callbacks
)
=>
hide
(
'
loading
'
,
callbacks
)
)
export
function
hide
(
type
:
string
=
'
toast
'
)
{
function
hide
(
type
:
string
=
'
toast
'
,
callbacks
?:
{
resolve
:
Resolve
;
reject
:
Reject
}
)
{
if
(
type
&&
type
!==
toastType
)
{
return
return
callbacks
?.
reject
()
}
if
(
timeout
)
{
clearTimeout
(
timeout
)
...
...
@@ -150,7 +149,5 @@ export function hide(type: string = 'toast') {
toast
=
null
isShowToast
=
false
toastType
=
''
return
{
errMsg
:
'
hide:ok
'
,
}
return
callbacks
?.
resolve
()
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录