提交 d9cedce2 编写于 作者: D DCloud_LXH

chore: showToast add error type

上级 15d6373d
...@@ -3,11 +3,12 @@ import { elemInArray } from '../../helpers/protocol' ...@@ -3,11 +3,12 @@ import { elemInArray } from '../../helpers/protocol'
export const API_SHOW_TOAST = 'showToast' export const API_SHOW_TOAST = 'showToast'
export type API_TYPE_SHOW_TOAST = typeof uni.showToast export type API_TYPE_SHOW_TOAST = typeof uni.showToast
export type API_TYPE_SHOW_TOAST_ICON = 'success' | 'loading' | 'none' export type API_TYPE_SHOW_TOAST_ICON = 'success' | 'loading' | 'none' | 'error'
export const SHOW_TOAST_ICON: API_TYPE_SHOW_TOAST_ICON[] = [ export const SHOW_TOAST_ICON: API_TYPE_SHOW_TOAST_ICON[] = [
'success', 'success',
'loading', 'loading',
'none', 'none',
'error',
] ]
export const ShowToastProtocol: ApiProtocol<API_TYPE_SHOW_TOAST> = { export const ShowToastProtocol: ApiProtocol<API_TYPE_SHOW_TOAST> = {
......
...@@ -12,6 +12,7 @@ import { ...@@ -12,6 +12,7 @@ import {
onEventPrevent, onEventPrevent,
createSvgIconVNode, createSvgIconVNode,
ICON_PATH_SUCCESS_NO_CIRCLE, ICON_PATH_SUCCESS_NO_CIRCLE,
ICON_PATH_WARN,
} from '@dcloudio/uni-core' } from '@dcloudio/uni-core'
import { import {
initI18nShowToastMsgsOnce, initI18nShowToastMsgsOnce,
...@@ -94,16 +95,27 @@ export default /*#__PURE__*/ defineComponent({ ...@@ -94,16 +95,27 @@ export default /*#__PURE__*/ defineComponent({
}) })
function useToastIcon(props: ToastProps) { function useToastIcon(props: ToastProps) {
const Icon = computed(() => const Icon = computed(() => {
props.icon === 'success' ? ( switch (props.icon) {
createVNode(createSvgIconVNode(ICON_PATH_SUCCESS_NO_CIRCLE, '#fff', 38), { case 'success':
class: ToastIconClassName, return createVNode(
}) createSvgIconVNode(ICON_PATH_SUCCESS_NO_CIRCLE, '#fff', 38),
) : props.icon === 'loading' ? ( {
// @ts-ignore class: ToastIconClassName,
<i class={ToastIconClassName} class="uni-loading"></i> }
) : null )
) case 'error':
return createVNode(createSvgIconVNode(ICON_PATH_WARN, '#fff', 38), {
class: ToastIconClassName,
})
case 'loading':
// @ts-ignore
return <i class={ToastIconClassName} class="uni-loading"></i>
default:
return null
}
})
return { return {
Icon, Icon,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册