first commit

This commit is contained in:
SnhAenIgseAl
2026-03-31 16:44:41 +08:00
parent dd513eda30
commit 7bde226505
219 changed files with 33046 additions and 9 deletions
@@ -0,0 +1,81 @@
"use strict";
var common_vendor = require("../../../../common/vendor.js");
var uni_modules_wotDesignUni_components_common_util = require("../common/util.js");
const toastDefaultOptionKey = "__TOAST_OPTION__";
const defaultOptions = {
duration: 2e3,
show: false
};
const None = Symbol("None");
function useToast(selector = "") {
const toastOptionKey = getToastOptionKey(selector);
const toastOption = common_vendor.inject(toastOptionKey, common_vendor.ref(None));
if (toastOption.value === None) {
toastOption.value = defaultOptions;
common_vendor.provide(toastOptionKey, toastOption);
}
let timer = null;
const createMethod = (toastOptions) => {
return (options) => {
return show(uni_modules_wotDesignUni_components_common_util.deepMerge(toastOptions, typeof options === "string" ? { msg: options } : options));
};
};
const show = (option) => {
const options = uni_modules_wotDesignUni_components_common_util.deepMerge(defaultOptions, typeof option === "string" ? { msg: option } : option);
toastOption.value = uni_modules_wotDesignUni_components_common_util.deepMerge(options, {
show: true
});
timer && clearTimeout(timer);
if (toastOption.value.duration && toastOption.value.duration > 0) {
timer = setTimeout(() => {
timer && clearTimeout(timer);
close();
}, options.duration);
}
};
const loading = createMethod({
iconName: "loading",
duration: 0,
cover: true
});
const success = createMethod({
iconName: "success",
duration: 1500
});
const error = createMethod({ iconName: "error" });
const warning = createMethod({ iconName: "warning" });
const info = createMethod({ iconName: "info" });
const close = () => {
toastOption.value = { show: false };
};
return {
show,
loading,
success,
error,
warning,
info,
close
};
}
const getToastOptionKey = (selector) => {
return selector ? `${toastDefaultOptionKey}${selector}` : toastDefaultOptionKey;
};
const toastIcon = {
success() {
return '<svg xmlns="http://www.w3.org/2000/svg" viewBox="2 2 44 44" width="48" height="48"><circle cx="24" cy="26" r="22" fill="#000" opacity=".1"/><circle cx="24" cy="24" r="20" fill="#34D19D" opacity=".4"/><circle cx="24" cy="24" r="16" fill="#34D19D"/><path d="M19 24l4 4 8-8" stroke="#FFF" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round" fill="none"/></svg>';
},
warning() {
return '<svg xmlns="http://www.w3.org/2000/svg" viewBox="2 2 44 44" width="48" height="48"><circle cx="24" cy="26" r="22" fill="#000" opacity=".1"/><circle cx="24" cy="24" r="20" fill="#F0883A" opacity=".4"/><circle cx="24" cy="24" r="16" fill="#F0883A"/><rect x="22.5" y="14" width="3" height="12" fill="#FFF" rx="1.5"/><circle cx="24" cy="30" r="2" fill="#FFF"/></svg>';
},
info() {
return '<svg xmlns="http://www.w3.org/2000/svg" viewBox="2 2 44 44" width="48" height="48"><circle cx="24" cy="26" r="22" fill="#000" opacity=".1"/><circle cx="24" cy="24" r="20" fill="#909CB7" opacity=".4"/><circle cx="24" cy="24" r="16" fill="#909CB7"/><circle cx="24" cy="18" r="2" fill="#FFF"/><rect x="22.5" y="22" width="3" height="12" fill="#FFF" rx="1.5"/></svg>';
},
error() {
return '<svg xmlns="http://www.w3.org/2000/svg" viewBox="2 2 44 44" width="48" height="48"><circle cx="24" cy="26" r="22" fill="#000" opacity=".1"/><circle cx="24" cy="24" r="20" fill="#fa4350" opacity=".4"/><circle cx="24" cy="24" r="16" fill="#fa4350"/><path d="M18 18l12 12M30 18L18 30" stroke="#FFF" stroke-width="2.5" stroke-linecap="round"/></svg>';
}
};
exports.defaultOptions = defaultOptions;
exports.getToastOptionKey = getToastOptionKey;
exports.toastIcon = toastIcon;
exports.useToast = useToast;
@@ -0,0 +1,43 @@
"use strict";
var uni_modules_wotDesignUni_components_common_props = require("../common/props.js");
const toastProps = {
...uni_modules_wotDesignUni_components_common_props.baseProps,
selector: uni_modules_wotDesignUni_components_common_props.makeStringProp(""),
msg: {
type: String,
default: ""
},
direction: uni_modules_wotDesignUni_components_common_props.makeStringProp("horizontal"),
iconName: {
type: String,
default: ""
},
iconSize: Number,
loadingType: uni_modules_wotDesignUni_components_common_props.makeStringProp("outline"),
loadingColor: {
type: String,
default: "#4D80F0"
},
loadingSize: Number,
iconColor: String,
position: uni_modules_wotDesignUni_components_common_props.makeStringProp("middle-top"),
zIndex: {
type: Number,
default: 100
},
cover: {
type: Boolean,
default: false
},
iconClass: {
type: String,
default: ""
},
classPrefix: {
type: String,
default: "wd-icon"
},
opened: Function,
closed: Function
};
exports.toastProps = toastProps;
@@ -0,0 +1,184 @@
"use strict";
var common_vendor = require("../../../../common/vendor.js");
var uni_modules_wotDesignUni_components_common_base64 = require("../common/base64.js");
var uni_modules_wotDesignUni_components_wdToast_index = require("./index.js");
var uni_modules_wotDesignUni_components_wdToast_types = require("./types.js");
var uni_modules_wotDesignUni_components_common_util = require("../common/util.js");
require("../common/props.js");
require("../common/AbortablePromise.js");
if (!Math) {
(wdOverlay + wdLoading + wdIcon + wdTransition)();
}
const wdIcon = () => "../wd-icon/wd-icon.js";
const wdLoading = () => "../wd-loading/wd-loading.js";
const wdOverlay = () => "../wd-overlay/wd-overlay.js";
const wdTransition = () => "../wd-transition/wd-transition.js";
const __default__ = {
name: "wd-toast",
options: {
addGlobalClass: true,
virtualHost: true,
styleIsolation: "shared"
}
};
const _sfc_main = /* @__PURE__ */ common_vendor.defineComponent({
...__default__,
props: uni_modules_wotDesignUni_components_wdToast_types.toastProps,
setup(__props) {
const props = __props;
const iconName = common_vendor.ref("");
const msg = common_vendor.ref("");
const position = common_vendor.ref("middle");
const show = common_vendor.ref(false);
const zIndex = common_vendor.ref(100);
const loadingType = common_vendor.ref("outline");
const loadingColor = common_vendor.ref("#4D80F0");
const iconSize = common_vendor.ref();
const loadingSize = common_vendor.ref();
const svgStr = common_vendor.ref("");
const cover = common_vendor.ref(false);
const classPrefix = common_vendor.ref("wd-icon");
const iconClass = common_vendor.ref("");
const direction = common_vendor.ref("horizontal");
let opened = null;
let closed = null;
const toastOptionKey = uni_modules_wotDesignUni_components_wdToast_index.getToastOptionKey(props.selector);
const toastOption = common_vendor.inject(toastOptionKey, common_vendor.ref(uni_modules_wotDesignUni_components_wdToast_index.defaultOptions));
common_vendor.watch(
() => toastOption.value,
(newVal) => {
reset(newVal);
},
{
deep: true,
immediate: true
}
);
common_vendor.watch(
() => iconName.value,
() => {
buildSvg();
},
{
deep: true,
immediate: true
}
);
const transitionStyle = common_vendor.computed$1(() => {
const style = {
"z-index": zIndex.value,
position: "fixed",
top: "50%",
left: 0,
width: "100%",
transform: "translate(0, -50%)",
"text-align": "center",
"pointer-events": "none"
};
return uni_modules_wotDesignUni_components_common_util.objToStyle(style);
});
const rootClass = common_vendor.computed$1(() => {
return `wd-toast ${props.customClass} wd-toast--${position.value} ${(iconName.value !== "loading" || msg.value) && (iconName.value || iconClass.value) ? "wd-toast--with-icon" : ""} ${iconName.value === "loading" && !msg.value ? "wd-toast--loading" : ""} ${direction.value === "vertical" ? "is-vertical" : ""}`;
});
const svgStyle = common_vendor.computed$1(() => {
const style = {
backgroundImage: `url(${svgStr.value})`
};
if (uni_modules_wotDesignUni_components_common_util.isDef(iconSize.value)) {
style.width = iconSize.value;
style.height = iconSize.value;
}
return uni_modules_wotDesignUni_components_common_util.objToStyle(style);
});
common_vendor.onBeforeMount(() => {
buildSvg();
});
function handleAfterEnter() {
if (uni_modules_wotDesignUni_components_common_util.isFunction(opened)) {
opened();
}
}
function handleAfterLeave() {
if (uni_modules_wotDesignUni_components_common_util.isFunction(closed)) {
closed();
}
}
function buildSvg() {
if (iconName.value !== "success" && iconName.value !== "warning" && iconName.value !== "info" && iconName.value !== "error")
return;
const iconSvg = uni_modules_wotDesignUni_components_wdToast_index.toastIcon[iconName.value]();
const iconSvgStr = `"data:image/svg+xml;base64,${uni_modules_wotDesignUni_components_common_base64.encode(iconSvg)}"`;
svgStr.value = iconSvgStr;
}
function reset(option) {
show.value = uni_modules_wotDesignUni_components_common_util.isDef(option.show) ? option.show : false;
if (show.value) {
mergeOptionsWithProps(option, props);
}
}
function mergeOptionsWithProps(option, props2) {
iconName.value = uni_modules_wotDesignUni_components_common_util.isDef(option.iconName) ? option.iconName : props2.iconName;
iconClass.value = uni_modules_wotDesignUni_components_common_util.isDef(option.iconClass) ? option.iconClass : props2.iconClass;
msg.value = uni_modules_wotDesignUni_components_common_util.isDef(option.msg) ? option.msg : props2.msg;
position.value = uni_modules_wotDesignUni_components_common_util.isDef(option.position) ? option.position : props2.position;
zIndex.value = uni_modules_wotDesignUni_components_common_util.isDef(option.zIndex) ? option.zIndex : props2.zIndex;
loadingType.value = uni_modules_wotDesignUni_components_common_util.isDef(option.loadingType) ? option.loadingType : props2.loadingType;
loadingColor.value = uni_modules_wotDesignUni_components_common_util.isDef(option.loadingColor) ? option.loadingColor : props2.loadingColor;
iconSize.value = uni_modules_wotDesignUni_components_common_util.isDef(option.iconSize) ? uni_modules_wotDesignUni_components_common_util.addUnit(option.iconSize) : uni_modules_wotDesignUni_components_common_util.isDef(props2.iconSize) ? uni_modules_wotDesignUni_components_common_util.addUnit(props2.iconSize) : void 0;
loadingSize.value = uni_modules_wotDesignUni_components_common_util.isDef(option.loadingSize) ? uni_modules_wotDesignUni_components_common_util.addUnit(option.loadingSize) : uni_modules_wotDesignUni_components_common_util.isDef(props2.loadingSize) ? uni_modules_wotDesignUni_components_common_util.addUnit(props2.loadingSize) : void 0;
cover.value = uni_modules_wotDesignUni_components_common_util.isDef(option.cover) ? option.cover : props2.cover;
classPrefix.value = uni_modules_wotDesignUni_components_common_util.isDef(option.classPrefix) ? option.classPrefix : props2.classPrefix;
direction.value = uni_modules_wotDesignUni_components_common_util.isDef(option.direction) ? option.direction : props2.direction;
closed = uni_modules_wotDesignUni_components_common_util.isFunction(option.closed) ? option.closed : uni_modules_wotDesignUni_components_common_util.isFunction(props2.closed) ? props2.closed : null;
opened = uni_modules_wotDesignUni_components_common_util.isFunction(option.opened) ? option.opened : uni_modules_wotDesignUni_components_common_util.isFunction(props2.opened) ? props2.opened : null;
}
return (_ctx, _cache) => {
return common_vendor.e({
a: cover.value
}, cover.value ? {
b: common_vendor.p({
["z-index"]: zIndex.value,
["lock-scroll"]: true,
show: show.value,
["custom-style"]: "background-color: transparent;pointer-events: auto;"
})
} : {}, {
c: iconName.value === "loading"
}, iconName.value === "loading" ? {
d: common_vendor.p({
type: loadingType.value,
color: loadingColor.value,
size: loadingSize.value,
["custom-class"]: `wd-toast__icon ${direction.value === "vertical" ? "is-vertical" : ""}`
})
} : iconName.value === "success" || iconName.value === "warning" || iconName.value === "info" || iconName.value === "error" ? {
f: common_vendor.s(common_vendor.unref(svgStyle)),
g: common_vendor.n(`wd-toast__iconWrap wd-toast__icon ${direction.value === "vertical" ? "is-vertical" : ""}`)
} : iconClass.value ? {
i: common_vendor.p({
["custom-class"]: `wd-toast__icon ${direction.value === "vertical" ? "is-vertical" : ""}`,
size: iconSize.value,
["class-prefix"]: classPrefix.value,
name: iconClass.value
})
} : {}, {
e: iconName.value === "success" || iconName.value === "warning" || iconName.value === "info" || iconName.value === "error",
h: iconClass.value,
j: msg.value
}, msg.value ? {
k: common_vendor.t(msg.value)
} : {}, {
l: common_vendor.n(common_vendor.unref(rootClass)),
m: common_vendor.o(handleAfterEnter),
n: common_vendor.o(handleAfterLeave),
o: common_vendor.p({
name: "fade",
show: show.value,
["custom-style"]: common_vendor.unref(transitionStyle)
})
});
};
}
});
var Component = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-02663e1a"], ["__file", "D:/\u7F51\u6291\u4E91Time/\u79C1\u6D3B/2000\u7B97\u5366/src/uni_modules/wot-design-uni/components/wd-toast/wd-toast.vue"]]);
wx.createComponent(Component);
@@ -0,0 +1,9 @@
{
"component": true,
"usingComponents": {
"wd-icon": "../wd-icon/wd-icon",
"wd-loading": "../wd-loading/wd-loading",
"wd-overlay": "../wd-overlay/wd-overlay",
"wd-transition": "../wd-transition/wd-transition"
}
}
@@ -0,0 +1 @@
<wd-overlay wx:if="{{a}}" class="data-v-02663e1a" u-i="02663e1a-0" bind:__l="__l" u-p="{{b}}"></wd-overlay><wd-transition wx:if="{{o}}" class="data-v-02663e1a" u-s="{{['d']}}" bindafterEnter="{{m}}" bindafterLeave="{{n}}" u-i="02663e1a-1" bind:__l="__l" u-p="{{o}}"><view class="{{['data-v-02663e1a', l]}}"><wd-loading wx:if="{{c}}" class="data-v-02663e1a" u-i="02663e1a-2,02663e1a-1" bind:__l="__l" u-p="{{d}}"/><view wx:elif="{{e}}" class="{{['data-v-02663e1a', g]}}"><view class="wd-toast__iconBox data-v-02663e1a"><view class="wd-toast__iconSvg data-v-02663e1a" style="{{f}}"></view></view></view><wd-icon wx:elif="{{h}}" class="data-v-02663e1a" u-i="02663e1a-3,02663e1a-1" bind:__l="__l" u-p="{{i}}"></wd-icon><view wx:if="{{j}}" class="wd-toast__msg data-v-02663e1a">{{k}}</view></view></wd-transition>
@@ -0,0 +1,258 @@
/**
* 这里是uni-app内置的常用样式变量
*
* uni-app 官方扩展插件及插件市场(https://ext.dcloud.net.cn)上很多三方插件均使用了这些样式变量
* 如果你是插件开发者,建议你使用scss预处理,并在插件代码中直接使用这些变量(无需 import 这个文件),方便用户通过搭积木的方式开发整体风格一致的App
*
*/
/**
* 如果你是App开发者(插件使用者),你可以通过修改这些变量来定制自己的插件主题,实现自定义主题功能
*
* 如果你的项目同样使用了scss预处理,你也可以直接在你的 scss 代码中使用如下变量,同时无需 import 这个文件
*/
/* 颜色变量 */
/* 行为相关颜色 */
/* 文字基本颜色 */
/* 背景颜色 */
/* 边框颜色 */
/* 尺寸变量 */
/* 文字尺寸 */
/* 图片尺寸 */
/* Border Radius */
/* 水平间距 */
/* 垂直间距 */
/* 透明度 */
/* 文章场景相关 */
/**
* 混合宏
*/
/**
* SCSS 配置项:命名空间以及BEM
*/
/**
* 辅助函数
*/
/**
* SCSS 配置项:命名空间以及BEM
*/
/* 转换成字符串 */
/* 判断是否存在 Modifier */
/* 判断是否存在伪类 */
/**
* 主题色切换
* @params $theme-color 主题色
* @params $type 变暗’dark 变亮 'light'
* @params $mix-color 自己设置的混色
*/
/**
* 颜色结果切换, 如果开启线性渐变色 使用渐变色,如果没有开启,那么使用主题色
* @params $open-linear 是否开启线性渐变色
* @params $deg 渐变色角度
* @params $theme-color 当前配色
* @params [Array] $set 主题色明暗设置,与 $color-list 数量对应
* @params [Array] $color-list 渐变色顺序, $color-list 和 $per-list 数量相同
* @params [Array] $per-list 渐变色比例
*/
/**
* BEM,定义块(b)
*/
/* 定义元素(e),对于伪类,会自动将 e 嵌套在 伪类 底下 */
/* 此方法用于生成穿透样式 */
/* 定义元素(e),对于伪类,会自动将 e 嵌套在 伪类 底下 */
/* 定义状态(m */
/* 定义状态(m */
/* 对于需要需要嵌套在 m 底下的 e,调用这个混合宏,一般在切换整个组件的状态,如切换颜色的时候 */
/* 状态,生成 is-$state 类名 */
/**
* 常用混合宏
*/
/* 单行超出隐藏 */
/* 多行超出隐藏 */
/* 清除浮动 */
/* 0.5px 边框 指定方向*/
/* 0.5px 边框 环绕 */
/**
* 三角形实现尖角样式,适用于背景透明情况
* @param $size 三角形高,底边为 $size * 2
* @param $bg 三角形背景颜色
*/
/**
* 正方形实现尖角样式,适用于背景不透明情况
* @param $size 正方形边长
* @param $bg 正方形背景颜色
* @param $z-index z-index属性值,不得大于外部包裹器
* @param $box-shadow 阴影
*/
/**
* 辅助函数
*/
/**
* SCSS 配置项:命名空间以及BEM
*/
/* 转换成字符串 */
/* 判断是否存在 Modifier */
/* 判断是否存在伪类 */
/**
* 主题色切换
* @params $theme-color 主题色
* @params $type 变暗’dark 变亮 'light'
* @params $mix-color 自己设置的混色
*/
/**
* 颜色结果切换, 如果开启线性渐变色 使用渐变色,如果没有开启,那么使用主题色
* @params $open-linear 是否开启线性渐变色
* @params $deg 渐变色角度
* @params $theme-color 当前配色
* @params [Array] $set 主题色明暗设置,与 $color-list 数量对应
* @params [Array] $color-list 渐变色顺序, $color-list 和 $per-list 数量相同
* @params [Array] $per-list 渐变色比例
*/
/**
* UI规范基础变量
*/
/*----------------------------------------- Theme color. start ----------------------------------------*/
/* 主题颜色 */
/* 辅助色 */
/* 文字颜色(默认浅色背景下 */
/* 暗黑模式 */
/* 图形颜色 */
/*----------------------------------------- Theme color. end -------------------------------------------*/
/*-------------------------------- Theme color application size. start --------------------------------*/
/* 文字字号 */
/* 文字字重 */
/* 尺寸 */
/*-------------------------------- Theme color application size. end --------------------------------*/
/* component var */
/* action-sheet */
/* badge */
/* button */
/* cell */
/* calendar */
/* checkbox */
/* collapse */
/* divider */
/* drop-menu */
/* input-number */
/* input */
/* textarea */
/* loadmore */
/* message-box */
/* notice-bar */
/* pagination */
/* picker */
/* col-picker */
/* overlay */
/* popup */
/* progress */
/* radio */
/* search */
/* slider */
/* sort-button */
/* steps */
/* switch */
/* tabs */
/* tag */
/* toast */
/* loading */
/* tooltip */
/* popover */
/* grid-item */
/* statustip */
/* card */
/* upload */
/* curtain */
/* notify */
/* skeleton */
/* circle */
/* swiper */
/* swiper-nav */
/* segmented */
/* tabbar */
/* tabbar-item */
/* navbar */
/* navbar-capsule */
/* table */
/* sidebar */
/* sidebar-item */
/* fab */
/* count-down */
/* keyboard */
/* number-keyboard */
/* passwod-input */
/* form-item */
/* backtop */
/* index-bar */
/* text */
/* video-preview */
/* img-cropper */
/* floating-panel */
/* signature */
.wd-toast.data-v-02663e1a {
display: inline-block;
max-width: var(--wot-toast-max-width, 300px);
padding: var(--wot-toast-padding, 16px 24px);
background-color: var(--wot-toast-bg, var(--wot-overlay-bg, rgba(0, 0, 0, 0.65)));
border-radius: var(--wot-toast-radius, 8px);
color: var(--wot-toast-color, var(--wot-color-white, rgb(255, 255, 255)));
transition: all 0.2s;
font-size: var(--wot-toast-fs, var(--wot-fs-content, 14px));
box-sizing: border-box;
box-shadow: var(--wot-toast-box-shadow, 0px 6px 16px 0px rgba(0, 0, 0, 0.08));
}
.wd-toast.is-vertical.data-v-02663e1a {
flex-direction: column;
}
.wd-toast__msg.data-v-02663e1a {
font-size: var(--wot-toast-fs, var(--wot-fs-content, 14px));
word-break: break-all;
line-height: var(--wot-toast-line-height, 20px);
text-align: left;
font-family: "San Francisco", Rotobo, arial, "PingFang SC", "Noto SansCJK", "Microsoft Yahei", sans-serif;
}
.data-v-02663e1a .wd-toast__icon {
display: inline-block;
margin-right: var(--wot-toast-icon-margin-right, 12px);
font-size: var(--wot-toast-icon-size, 32px);
}
.data-v-02663e1a .wd-toast__icon.is-vertical {
margin-right: 0;
margin-bottom: var(--wot-toast-icon-margin-bottom, 12px);
}
.wd-toast__iconWrap.data-v-02663e1a {
font-size: 0;
line-height: 0;
vertical-align: middle;
}
.wd-toast__iconBox.data-v-02663e1a {
display: block;
width: 100%;
height: 100%;
}
.wd-toast__iconSvg.data-v-02663e1a {
width: var(--wot-toast-icon-size, 32px);
height: var(--wot-toast-icon-size, 32px);
background-size: cover;
background-repeat: no-repeat;
}
.wd-toast__loading.data-v-02663e1a {
margin-bottom: var(--wot-toast-loading-margin-bottom, 16px);
display: inline-block;
}
.wd-toast--top.data-v-02663e1a {
transform: translate3d(0, -40vh, 0);
}
.wd-toast--middle-top.data-v-02663e1a {
transform: translate3d(0%, -18.8vh, 0);
}
.wd-toast--bottom.data-v-02663e1a {
transform: translate3d(0, 40vh, 0);
}
.wd-toast--with-icon.data-v-02663e1a {
min-width: var(--wot-toast-with-icon-min-width, 150px);
display: inline-flex;
align-items: center;
}
.wd-toast--loading.data-v-02663e1a {
min-width: auto;
padding: var(--wot-toast-loading-padding, 10px);
}