Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Velpro187
uni-app
提交
6d34a5a9
U
uni-app
项目概览
Velpro187
/
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,发现更多精彩内容 >>
提交
6d34a5a9
编写于
4月 25, 2021
作者:
D
DCloud_LXH
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
chore(h5): 1、toast 2、base.css add uni-loading
上级
cdfcda6a
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
79 addition
and
35 deletion
+79
-35
packages/uni-h5/dist/uni-h5.esm.js
packages/uni-h5/dist/uni-h5.esm.js
+18
-14
packages/uni-h5/src/service/api/ui/popup/showToast.ts
packages/uni-h5/src/service/api/ui/popup/showToast.ts
+7
-7
packages/uni-h5/src/service/api/ui/popup/toast.tsx
packages/uni-h5/src/service/api/ui/popup/toast.tsx
+28
-14
packages/uni-h5/style/framework/base.css
packages/uni-h5/style/framework/base.css
+26
-0
未找到文件。
packages/uni-h5/dist/uni-h5.esm.js
浏览文件 @
6d34a5a9
...
...
@@ -13123,13 +13123,16 @@ const props = {
type
:
Boolean
}
};
const
toastIconClassName
=
"
uni-toast__icon
"
;
var
Toast
=
/* @__PURE__ */
defineComponent
({
name
:
"
Toast
"
,
props
,
setup
(
props2
)
{
initI18nShowToastMsgsOnce
();
initI18nShowLoadingMsgsOnce
();
const
{
iconClass
}
=
useToast
State
(
props2
);
Icon
}
=
useToast
Icon
(
props2
);
const
visible
=
usePopup
(
props2
,
{});
return
()
=>
{
const
{
...
...
@@ -13146,9 +13149,8 @@ var Toast = /* @__PURE__ */ defineComponent({
},
[
mask
?
createVNode
(
"
div
"
,
{
class
:
"
uni-mask
"
,
style
:
"
background: transparent;
"
,
onTouchmove
:
withModifiers
(()
=>
{
},
[
"
prevent
"
])
},
null
,
40
,
[
"
onTouchmove
"
])
:
""
,
!
image2
&&
!
iconClass
?
createVNode
(
"
div
"
,
{
onTouchmove
:
onEventPrevent
},
null
,
40
,
[
"
onTouchmove
"
])
:
""
,
!
image2
&&
!
Icon
.
value
?
createVNode
(
"
div
"
,
{
class
:
"
uni-sample-toast
"
},
[
createVNode
(
"
p
"
,
{
class
:
"
uni-simple-toast__text
"
...
...
@@ -13156,20 +13158,22 @@ var Toast = /* @__PURE__ */ defineComponent({
class
:
"
uni-toast
"
},
[
image2
?
createVNode
(
"
img
"
,
{
src
:
image2
,
class
:
"
uni-toast__icon
"
},
null
,
8
,
[
"
src
"
])
:
createVNode
(
"
i
"
,
{
class
:
[
iconClass
,
"
uni-icon_toast
"
]
},
null
,
2
),
createVNode
(
"
p
"
,
{
class
:
toastIconClassName
},
null
,
10
,
[
"
src
"
])
:
Icon
.
value
,
createVNode
(
"
p
"
,
{
class
:
"
uni-toast__content
"
},
[
title
])])],
8
,
[
"
data-duration
"
]),
[[
vShow
,
visible
.
value
]])]
});
};
}
});
function
useToastState
(
props2
)
{
const
iconClass
=
computed
(()
=>
props2
.
icon
===
"
success
"
?
"
uni-icon-success-no-circle
"
:
props2
.
icon
===
"
loading
"
?
"
uni-loading
"
:
""
);
function
useToastIcon
(
props2
)
{
const
Icon
=
computed
(()
=>
props2
.
icon
===
"
success
"
?
createVNode
(
createSvgIconVNode
(
ICON_PATH_SUCCESS_NO_CIRCLE
,
"
#fff
"
,
38
),
{
class
:
toastIconClassName
})
:
props2
.
icon
===
"
loading
"
?
createVNode
(
"
i
"
,
{
class
:
[
toastIconClassName
,
"
uni-loading
"
]
},
null
,
2
)
:
null
);
return
{
iconClass
Icon
};
}
let
showToastState
;
...
...
@@ -13194,11 +13198,12 @@ function createToast(args) {
timeoutId
=
setTimeout
(()
=>
{
hidePopup
(
"
onHideToast
"
);
},
showToastState
.
duration
);
}
else
{
timeoutId
&&
clearTimeout
(
timeoutId
);
}
});
}
const
showToast
=
defineAsyncApi
(
API_SHOW_TOAST
,
(
args
,
{
resolve
,
reject
})
=>
{
initI18nShowToastMsgsOnce
();
createToast
(
args
);
showType
=
"
onShowToast
"
;
resolve
();
...
...
@@ -13210,7 +13215,6 @@ const showLoadingDefaultState = {
};
const
showLoading
=
defineAsyncApi
(
API_SHOW_LOADING
,
(
args
,
{
resolve
,
reject
})
=>
{
extend
(
args
,
showLoadingDefaultState
);
initI18nShowLoadingMsgsOnce
();
createToast
(
args
);
showType
=
"
onShowLoading
"
;
resolve
();
...
...
packages/uni-h5/src/service/api/ui/popup/showToast.ts
浏览文件 @
6d34a5a9
//#region Functions
import
{
reactive
,
nextTick
,
watchEffect
}
from
'
vue
'
import
{
extend
}
from
'
@vue/shared
'
import
{
...
...
@@ -13,18 +14,17 @@ import {
}
from
'
@dcloudio/uni-api
'
import
Toast
,
{
ToastProps
}
from
'
./toast
'
import
{
ensureRoot
,
createRootApp
}
from
'
./utils
'
import
{
useI18n
,
initI18nShowLoadingMsgsOnce
,
initI18nShowToastMsgsOnce
,
}
from
'
@dcloudio/uni-core
'
import
{
useI18n
}
from
'
@dcloudio/uni-core
'
//#endregion
//#region Type
import
type
{
API_TYPE_SHOW_LOADING
,
API_TYPE_HIDE_TOAST
,
API_TYPE_HIDE_LOADING
,
API_TYPE_SHOW_TOAST
,
}
from
'
@dcloudio/uni-api
'
//#endregion
let
showToastState
:
ToastProps
let
showType
:
'
onShowToast
'
|
'
onShowLoading
'
|
''
=
''
...
...
@@ -52,6 +52,8 @@ function createToast(args: ToastProps) {
timeoutId
=
setTimeout
(()
=>
{
hidePopup
(
'
onHideToast
'
)
},
showToastState
.
duration
)
}
else
{
timeoutId
&&
clearTimeout
(
timeoutId
)
}
})
}
...
...
@@ -59,7 +61,6 @@ function createToast(args: ToastProps) {
export
const
showToast
=
defineAsyncApi
<
API_TYPE_SHOW_TOAST
>
(
API_SHOW_TOAST
,
(
args
,
{
resolve
,
reject
})
=>
{
initI18nShowToastMsgsOnce
()
createToast
(
args
as
ToastProps
)
showType
=
'
onShowToast
'
resolve
()
...
...
@@ -78,7 +79,6 @@ export const showLoading = defineAsyncApi<API_TYPE_SHOW_LOADING>(
API_SHOW_LOADING
,
(
args
,
{
resolve
,
reject
})
=>
{
extend
(
args
,
showLoadingDefaultState
)
initI18nShowLoadingMsgsOnce
()
createToast
(
args
as
ToastProps
)
showType
=
'
onShowLoading
'
resolve
()
...
...
packages/uni-h5/src/service/api/ui/popup/toast.tsx
浏览文件 @
6d34a5a9
...
...
@@ -2,12 +2,21 @@ import {
Transition
,
defineComponent
,
ExtractPropTypes
,
withModifiers
,
computed
,
createVNode
,
}
from
'
vue
'
import
{
SHOW_TOAST_ICON
}
from
'
@dcloudio/uni-api
'
import
type
{
API_TYPE_SHOW_TOAST_ICON
}
from
'
@dcloudio/uni-api
'
import
{
usePopup
}
from
'
./utils
'
import
{
onEventPrevent
,
createSvgIconVNode
,
ICON_PATH_SUCCESS_NO_CIRCLE
,
}
from
'
@dcloudio/uni-core
'
import
{
initI18nShowToastMsgsOnce
,
initI18nShowLoadingMsgsOnce
,
}
from
'
@dcloudio/uni-core
'
const
props
=
{
title
:
{
...
...
@@ -36,6 +45,7 @@ const props = {
type
:
Boolean
,
},
}
const
ToastIconClassName
=
'
uni-toast__icon
'
export
type
ToastProps
=
ExtractPropTypes
<
typeof
props
>
...
...
@@ -43,7 +53,9 @@ export default /*#__PURE__*/ defineComponent({
name
:
'
Toast
'
,
props
,
setup
(
props
)
{
const
{
iconClass
}
=
useToastState
(
props
)
initI18nShowToastMsgsOnce
()
initI18nShowLoadingMsgsOnce
()
const
{
Icon
}
=
useToastIcon
(
props
)
const
visible
=
usePopup
(
props
,
{})
return
()
=>
{
...
...
@@ -55,21 +67,21 @@ export default /*#__PURE__*/ defineComponent({
<
div
class
=
"uni-mask"
style
=
"background: transparent;"
onTouchmove
=
{
withModifiers
(()
=>
{},
[
'
prevent
'
])
}
onTouchmove
=
{
onEventPrevent
}
/>
)
:
(
''
)
}
{
!
image
&&
!
iconClass
?
(
{
!
image
&&
!
Icon
.
value
?
(
<
div
class
=
"uni-sample-toast"
>
<
p
class
=
"uni-simple-toast__text"
>
{
title
}
</
p
>
</
div
>
)
:
(
<
div
class
=
"uni-toast"
>
{
image
?
(
<
img
src
=
{
image
}
class
=
"uni-toast__icon"
/>
<
img
src
=
{
image
}
class
=
{
ToastIconClassName
}
/>
)
:
(
<
i
class
=
{
iconClass
}
class
=
"uni-icon_toast"
/>
Icon
.
value
)
}
<
p
class
=
"uni-toast__content"
>
{
title
}
</
p
>
</
div
>
...
...
@@ -81,16 +93,18 @@ export default /*#__PURE__*/ defineComponent({
},
})
function
useToastState
(
props
:
ToastProps
)
{
const
iconClass
=
computed
(()
=>
props
.
icon
===
'
success
'
?
'
uni-icon-success-no-circle
'
:
props
.
icon
===
'
loading
'
?
'
uni-loading
'
:
''
function
useToastIcon
(
props
:
ToastProps
)
{
const
Icon
=
computed
(()
=>
props
.
icon
===
'
success
'
?
(
createVNode
(
createSvgIconVNode
(
ICON_PATH_SUCCESS_NO_CIRCLE
,
'
#fff
'
,
38
),
{
class
:
ToastIconClassName
,
})
)
:
props
.
icon
===
'
loading
'
?
(
<
i
class
=
{
ToastIconClassName
}
class
=
"uni-loading"
></
i
>
)
:
null
)
return
{
iconClass
,
Icon
,
}
}
packages/uni-h5/style/framework/base.css
浏览文件 @
6d34a5a9
...
...
@@ -52,3 +52,29 @@ uni-page-wrapper {
.uni-fade-leave-active
{
opacity
:
0
;
}
.uni-loading
,
uni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TAgNTQuMDIgNjUpIi8+PHJlY3Qgd2lkdGg9IjciIGhlaWdodD0iMjAiIHg9IjQ2LjUiIHk9IjQwIiBmaWxsPSIjQkFCOEI5IiByeD0iNSIgcnk9IjUiIHRyYW5zZm9ybT0icm90YXRlKDE4MCA1MCA2NSkiLz48cmVjdCB3aWR0aD0iNyIgaGVpZ2h0PSIyMCIgeD0iNDYuNSIgeT0iNDAiIGZpbGw9IiNDMkMwQzEiIHJ4PSI1IiByeT0iNSIgdHJhbnNmb3JtPSJyb3RhdGUoLTE1MCA0NS45OCA2NSkiLz48cmVjdCB3aWR0aD0iNyIgaGVpZ2h0PSIyMCIgeD0iNDYuNSIgeT0iNDAiIGZpbGw9IiNDQkNCQ0IiIHJ4PSI1IiByeT0iNSIgdHJhbnNmb3JtPSJyb3RhdGUoLTEyMCA0MS4zNCA2NSkiLz48cmVjdCB3aWR0aD0iNyIgaGVpZ2h0PSIyMCIgeD0iNDYuNSIgeT0iNDAiIGZpbGw9IiNEMkQyRDIiIHJ4PSI1IiByeT0iNSIgdHJhbnNmb3JtPSJyb3RhdGUoLTkwIDM1IDY1KSIvPjxyZWN0IHdpZHRoPSI3IiBoZWlnaHQ9IjIwIiB4PSI0Ni41IiB5PSI0MCIgZmlsbD0iI0RBREFEQSIgcng9IjUiIHJ5PSI1IiB0cmFuc2Zvcm09InJvdGF0ZSgtNjAgMjQuMDIgNjUpIi8+PHJlY3Qgd2lkdGg9IjciIGhlaWdodD0iMjAiIHg9IjQ2LjUiIHk9IjQwIiBmaWxsPSIjRTJFMkUyIiByeD0iNSIgcnk9IjUiIHRyYW5zZm9ybT0icm90YXRlKC0zMCAtNS45OCA2NSkiLz48L3N2Zz4=')
no-repeat
;
}
.uni-loading
{
width
:
20px
;
height
:
20px
;
display
:
inline-block
;
vertical-align
:
middle
;
animation
:
uni-loading
1s
steps
(
12
,
end
)
infinite
;
background-size
:
100%
;
}
@keyframes
uni-loading
{
0
%
{
transform
:
rotate3d
(
0
,
0
,
1
,
0deg
);
}
100
%
{
transform
:
rotate3d
(
0
,
0
,
1
,
360deg
);
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录