acdr-ui/dist/dev/mp-weixin/node-modules/wot-design-uni/components/wd-toast/wd-toast.js.map

1 line
8.4 KiB
Plaintext
Raw Normal View History

2024-09-19 07:20:14 +08:00
{"version":3,"file":"wd-toast.js","sources":["../../../../../../../node_modules/wot-design-uni/components/wd-toast/wd-toast.vue","../../../../../../../uniComponent:/RDovQXBwL1dvcmsvYWRkci9hY2RyLXVpL25vZGVfbW9kdWxlcy93b3QtZGVzaWduLXVuaS9jb21wb25lbnRzL3dkLXRvYXN0L3dkLXRvYXN0LnZ1ZQ"],"sourcesContent":["<template>\n <wd-overlay v-if=\"cover\" :z-index=\"zIndex\" lock-scroll :show=\"show\" custom-style=\"background-color: transparent;pointer-events: auto;\"></wd-overlay>\n <wd-transition name=\"fade\" :show=\"show\" :custom-style=\"transitionStyle\" @after-enter=\"handleAfterEnter\" @after-leave=\"handleAfterLeave\">\n <view :class=\"rootClass\">\n <!--iconName优先级更高-->\n <wd-loading v-if=\"iconName === 'loading'\" :type=\"loadingType\" :color=\"loadingColor\" custom-class=\"wd-toast__icon\" :customStyle=\"loadingStyle\" />\n <view\n class=\"wd-toast__iconWrap wd-toast__icon\"\n v-else-if=\"iconName === 'success' || iconName === 'warning' || iconName === 'info' || iconName === 'error'\"\n :style=\"`width:${iconSize}px; height:${iconSize}px`\"\n >\n <view class=\"wd-toast__iconBox\">\n <view class=\"wd-toast__iconSvg\" :style=\"`background-image: url(${svgStr}); width:${iconSize}px; height:${iconSize}px`\"></view>\n </view>\n </view>\n <view v-else-if=\"customIcon\" class=\"wd-toast__icon custom-icon-class\" />\n <!--文本-->\n <view v-if=\"msg\" class=\"wd-toast__msg\">{{ msg }}</view>\n </view>\n </wd-transition>\n</template>\n\n<script lang=\"ts\">\nexport default {\n name: 'wd-toast',\n options: {\n addGlobalClass: true,\n virtualHost: true,\n styleIsolation: 'shared'\n }\n}\n</script>\n\n<script lang=\"ts\" setup>\nimport { computed, inject, onBeforeMount, ref, watch, type CSSProperties } from 'vue'\nimport base64 from '../common/base64'\nimport { defaultOptions, toastDefaultOptionKey, toastIcon } from '.'\nimport { toastProps, type ToastLoadingType, type ToastOptions } from './types'\nimport { isDef, isFunction, objToStyle } from '../common/util'\n\nconst props = defineProps(toastProps)\n\nconst iconName = ref<string>('') // 图标类型\nconst customIcon = ref<boolean>(false)\nconst msg = ref<string>('') // 消息内容\nconst position = ref<string>('middle')\nconst show = ref<boolean>(false)\nconst zIndex = ref<number>(100)\nconst loadingType = ref<ToastLoadingType>('outline')\nconst loadingColor = ref<string>('#4D80F0')\nconst iconSize = ref<number>(42)\nconst svgStr = ref<string>('') // 图标\nconst cover = ref<boolean>(false) // 是否存在遮罩层\n\nlet opened: (() => void) | null = null\n\nlet closed: (() => void) | null = null\n\nconst toastOptionKey = props.selector ? toastDefaultOptionKey + props.selector : toastDefaultOptionKey\nconst toastOption = inject(toastOptionKey, ref<ToastOptions>(defaultOptions)) // toast选项\n\n// 监听options变化展示\nwatch(\n () => toastOption.value,\n (newVal: ToastOptions) => {\n reset(newVal)\n },\n {\n deep: true,\n immediate: true\n }\n)\n\n// 监听options变化展示\nwatch(\n () => iconName.value,\n () => {\n buildSvg()\n },\n {\n deep: true,\n immediate: true\n }\n)\n\n/**\n * 动画自定义样式\n */\nconst transitionStyle = computed(() => {\n const style: CSSProperties = {\n 'z-index': zIndex.value,\n position: 'fixed',\n top: '50%',\n left: 0,\n width: '100%',\n transform: 'translate(0, -50%)',\n 'text-align': 'center'\n }\n return objToStyle(style)\n})\n\n/**\n * 加载自定义样式\n */\nconst loadingStyle = computed(() => {\n const style: CSSProperties = {\n display: 'inline-block',\n 'margin-right': '16px'\n }\n return objToStyle(style)\n})\n\nconst rootClass = computed(() => {\n return `wd-toast ${props.customClass} wd-toast--${position.value} ${\n (iconName.value !== 'loading' || msg.value) && (iconName.value || customIcon.value) ? 'wd-toast--with-icon' : ''\n } ${iconName.value === 'loading' && !msg.value ? 'wd-toast--loading' : ''}`\n})\n\nonBeforeMount(() => {\n buil