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,75 @@
"use strict";
var common_vendor = require("../../../../common/vendor.js");
var uni_modules_wotDesignUni_components_common_util = require("../common/util.js");
const messageDefaultOptionKey = "__MESSAGE_OPTION__";
const None = Symbol("None");
const defaultOptions = {
title: "",
showCancelButton: false,
show: false,
closeOnClickModal: true,
msg: "",
type: "alert",
inputType: "text",
inputValue: "",
showErr: false,
zIndex: 99,
lazyRender: true,
inputError: ""
};
function useMessage(selector = "") {
const messageOptionKey = selector ? messageDefaultOptionKey + selector : messageDefaultOptionKey;
const messageOption = common_vendor.inject(messageOptionKey, common_vendor.ref(None));
if (messageOption.value === None) {
messageOption.value = defaultOptions;
common_vendor.provide(messageOptionKey, messageOption);
}
const createMethod = (type) => {
return (options) => {
const messageOptions = uni_modules_wotDesignUni_components_common_util.deepMerge({ type }, typeof options === "string" ? { title: options } : options);
if (messageOptions.type === "confirm" || messageOptions.type === "prompt") {
messageOptions.showCancelButton = true;
} else {
messageOptions.showCancelButton = false;
}
return show(messageOptions);
};
};
const show = (option) => {
return new Promise((resolve, reject) => {
const options = uni_modules_wotDesignUni_components_common_util.deepMerge(defaultOptions, typeof option === "string" ? { title: option } : option);
messageOption.value = uni_modules_wotDesignUni_components_common_util.deepMerge(options, {
show: true,
success: (res) => {
close();
resolve(res);
},
fail: (res) => {
close();
reject(res);
}
});
});
};
const alert = createMethod("alert");
const confirm = createMethod("confirm");
const prompt = createMethod("prompt");
const close = () => {
if (messageOption.value !== None) {
messageOption.value.show = false;
}
};
return {
show,
alert,
confirm,
prompt,
close
};
}
const getMessageDefaultOptionKey = (selector) => {
return selector ? `${messageDefaultOptionKey}${selector}` : messageDefaultOptionKey;
};
exports.defaultOptions = defaultOptions;
exports.getMessageDefaultOptionKey = getMessageDefaultOptionKey;
exports.useMessage = useMessage;
@@ -0,0 +1,8 @@
"use strict";
var uni_modules_wotDesignUni_components_common_props = require("../common/props.js");
const messageBoxProps = {
...uni_modules_wotDesignUni_components_common_props.baseProps,
selector: uni_modules_wotDesignUni_components_common_props.makeStringProp(""),
rootPortal: uni_modules_wotDesignUni_components_common_props.makeBooleanProp(false)
};
exports.messageBoxProps = messageBoxProps;
@@ -0,0 +1,256 @@
"use strict";
var common_vendor = require("../../../../common/vendor.js");
var uni_modules_wotDesignUni_components_wdMessageBox_types = require("./types.js");
var uni_modules_wotDesignUni_components_wdMessageBox_index = require("./index.js");
var uni_modules_wotDesignUni_components_common_util = require("../common/util.js");
var uni_modules_wotDesignUni_components_composables_useTranslate = require("../composables/useTranslate.js");
require("../common/props.js");
require("../common/AbortablePromise.js");
require("../../locale/index.js");
require("../../locale/lang/zh-CN.js");
if (!Math) {
(wdInput + wdButton + wdPopup)();
}
const wdPopup = () => "../wd-popup/wd-popup.js";
const wdButton = () => "../wd-button/wd-button.js";
const wdInput = () => "../wd-input/wd-input.js";
const __default__ = {
name: "wd-message-box",
options: {
virtualHost: true,
addGlobalClass: true,
styleIsolation: "shared"
}
};
const _sfc_main = /* @__PURE__ */ common_vendor.defineComponent({
...__default__,
props: uni_modules_wotDesignUni_components_wdMessageBox_types.messageBoxProps,
setup(__props) {
const props = __props;
const { translate } = uni_modules_wotDesignUni_components_composables_useTranslate.useTranslate("message-box");
const rootClass = common_vendor.computed$1(() => {
return `wd-message-box__container ${props.customClass}`;
});
const bodyClass = common_vendor.computed$1(() => {
return `wd-message-box__body ${!messageState.title ? "is-no-title" : ""} ${messageState.type === "prompt" ? "is-prompt" : ""}`;
});
const messageOptionKey = uni_modules_wotDesignUni_components_wdMessageBox_index.getMessageDefaultOptionKey(props.selector);
const messageOption = common_vendor.inject(messageOptionKey, common_vendor.ref(uni_modules_wotDesignUni_components_wdMessageBox_index.defaultOptions));
const messageState = common_vendor.reactive({
msg: "",
show: false,
title: "",
showCancelButton: false,
closeOnClickModal: true,
confirmButtonText: "",
cancelButtonText: "",
type: "alert",
inputType: "text",
inputValue: "",
inputPlaceholder: "",
inputError: "",
showErr: false,
zIndex: 99,
lazyRender: true
});
const customConfirmProps = common_vendor.computed$1(() => {
const buttonProps = uni_modules_wotDesignUni_components_common_util.deepAssign(
{
block: true
},
uni_modules_wotDesignUni_components_common_util.isDef(messageState.confirmButtonProps) ? uni_modules_wotDesignUni_components_common_util.omitBy(messageState.confirmButtonProps, uni_modules_wotDesignUni_components_common_util.isUndefined) : {}
);
buttonProps.customClass = `${buttonProps.customClass || ""} wd-message-box__actions-btn`;
return buttonProps;
});
const customCancelProps = common_vendor.computed$1(() => {
const buttonProps = uni_modules_wotDesignUni_components_common_util.deepAssign(
{
block: true,
type: "info"
},
uni_modules_wotDesignUni_components_common_util.isDef(messageState.cancelButtonProps) ? uni_modules_wotDesignUni_components_common_util.omitBy(messageState.cancelButtonProps, uni_modules_wotDesignUni_components_common_util.isUndefined) : {}
);
buttonProps.customClass = `${buttonProps.customClass || ""} wd-message-box__actions-btn`;
return buttonProps;
});
common_vendor.watch(
() => messageOption.value,
(newVal) => {
reset(newVal);
},
{
deep: true,
immediate: true
}
);
common_vendor.watch(
() => messageState.show,
(newValue) => {
resetErr(!!newValue);
},
{
deep: true,
immediate: true
}
);
function toggleModal(action) {
if (action === "modal" && !messageState.closeOnClickModal) {
return;
}
if (messageState.type === "prompt" && action === "confirm" && !validate()) {
return;
}
switch (action) {
case "confirm":
if (messageState.beforeConfirm) {
messageState.beforeConfirm({
resolve: (isPass) => {
if (isPass) {
handleConfirm({
action,
value: messageState.inputValue
});
}
}
});
} else {
handleConfirm({
action,
value: messageState.inputValue
});
}
break;
case "cancel":
handleCancel({
action
});
break;
default:
handleCancel({
action: "modal"
});
break;
}
}
function handleConfirm(result) {
messageState.show = false;
if (uni_modules_wotDesignUni_components_common_util.isFunction(messageState.success)) {
messageState.success(result);
}
}
function handleCancel(result) {
messageState.show = false;
if (uni_modules_wotDesignUni_components_common_util.isFunction(messageState.fail)) {
messageState.fail(result);
}
}
function validate() {
if (messageState.inputPattern && !messageState.inputPattern.test(String(messageState.inputValue))) {
messageState.showErr = true;
return false;
}
if (typeof messageState.inputValidate === "function") {
const validateResult = messageState.inputValidate(messageState.inputValue);
if (!validateResult) {
messageState.showErr = true;
return false;
}
}
messageState.showErr = false;
return true;
}
function resetErr(val) {
if (val === false) {
messageState.showErr = false;
}
}
function inputValChange({ value }) {
if (value === "") {
messageState.showErr = false;
return;
}
messageState.inputValue = value;
}
function reset(option) {
if (option) {
messageState.title = uni_modules_wotDesignUni_components_common_util.isDef(option.title) ? option.title : "";
messageState.showCancelButton = uni_modules_wotDesignUni_components_common_util.isDef(option.showCancelButton) ? option.showCancelButton : false;
messageState.show = option.show;
messageState.closeOnClickModal = option.closeOnClickModal;
messageState.confirmButtonText = option.confirmButtonText;
messageState.cancelButtonText = option.cancelButtonText;
messageState.msg = option.msg;
messageState.type = option.type;
messageState.inputType = option.inputType;
messageState.inputSize = option.inputSize;
messageState.inputValue = option.inputValue;
messageState.inputPlaceholder = option.inputPlaceholder;
messageState.inputPattern = option.inputPattern;
messageState.inputValidate = option.inputValidate;
messageState.success = option.success;
messageState.fail = option.fail;
messageState.beforeConfirm = option.beforeConfirm;
messageState.inputError = option.inputError;
messageState.showErr = option.showErr;
messageState.zIndex = option.zIndex;
messageState.lazyRender = option.lazyRender;
messageState.confirmButtonProps = option.confirmButtonProps;
messageState.cancelButtonProps = option.cancelButtonProps;
}
}
return (_ctx, _cache) => {
return common_vendor.e({
a: messageState.title
}, messageState.title ? {
b: common_vendor.t(messageState.title)
} : {}, {
c: messageState.type === "prompt"
}, messageState.type === "prompt" ? common_vendor.e({
d: common_vendor.o(inputValChange),
e: common_vendor.o(($event) => messageState.inputValue = $event),
f: common_vendor.p({
type: messageState.inputType,
size: messageState.inputSize,
placeholder: messageState.inputPlaceholder,
modelValue: messageState.inputValue
}),
g: messageState.showErr
}, messageState.showErr ? {
h: common_vendor.t(messageState.inputError || common_vendor.unref(translate)("inputNoValidate"))
} : {}) : {}, {
i: common_vendor.t(messageState.msg),
j: common_vendor.n(common_vendor.unref(bodyClass)),
k: messageState.showCancelButton
}, messageState.showCancelButton ? {
l: common_vendor.t(messageState.cancelButtonText || common_vendor.unref(translate)("cancel")),
m: common_vendor.o(($event) => toggleModal("cancel")),
n: common_vendor.p({
...common_vendor.unref(customCancelProps)
})
} : {}, {
o: common_vendor.t(messageState.confirmButtonText || common_vendor.unref(translate)("confirm")),
p: common_vendor.o(($event) => toggleModal("confirm")),
q: common_vendor.p({
...common_vendor.unref(customConfirmProps)
}),
r: common_vendor.n(`wd-message-box__actions ${messageState.showCancelButton ? "wd-message-box__flex" : "wd-message-box__block"}`),
s: common_vendor.n(common_vendor.unref(rootClass)),
t: common_vendor.o(($event) => toggleModal("modal")),
v: common_vendor.o(($event) => messageState.show = $event),
w: common_vendor.p({
transition: "zoom-in",
["close-on-click-modal"]: messageState.closeOnClickModal,
["lazy-render"]: messageState.lazyRender,
["custom-class"]: "wd-message-box",
["z-index"]: messageState.zIndex,
duration: 200,
["root-portal"]: _ctx.rootPortal,
modelValue: messageState.show
})
});
};
}
});
var Component = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-12024933"], ["__file", "D:/\u7F51\u6291\u4E91Time/\u79C1\u6D3B/2000\u7B97\u5366/src/uni_modules/wot-design-uni/components/wd-message-box/wd-message-box.vue"]]);
wx.createComponent(Component);
@@ -0,0 +1,8 @@
{
"component": true,
"usingComponents": {
"wd-popup": "../wd-popup/wd-popup",
"wd-button": "../wd-button/wd-button",
"wd-input": "../wd-input/wd-input"
}
}
@@ -0,0 +1 @@
<view class="data-v-12024933"><wd-popup wx:if="{{w}}" class="data-v-12024933" u-s="{{['d']}}" bindclickModal="{{t}}" u-i="12024933-0" bind:__l="__l" bindupdateModelValue="{{v}}" u-p="{{w}}"><view class="{{['data-v-12024933', s]}}"><view class="{{['data-v-12024933', j]}}"><view wx:if="{{a}}" class="wd-message-box__title data-v-12024933">{{b}}</view><view class="wd-message-box__content data-v-12024933"><block wx:if="{{c}}"><wd-input wx:if="{{f}}" class="data-v-12024933" bindinput="{{d}}" u-i="12024933-1,12024933-0" bind:__l="__l" bindupdateModelValue="{{e}}" u-p="{{f}}"/><view wx:if="{{g}}" class="wd-message-box__input-error data-v-12024933">{{h}}</view></block><block wx:if="{{$slots.d}}"><slot></slot></block><block wx:else>{{i}}</block></view></view><view class="{{['data-v-12024933', r]}}"><wd-button wx:if="{{k}}" class="data-v-12024933" u-s="{{['d']}}" bindclick="{{m}}" u-i="12024933-2,12024933-0" bind:__l="__l" u-p="{{n}}">{{l}}</wd-button><wd-button wx:if="{{q}}" class="data-v-12024933" u-s="{{['d']}}" bindclick="{{p}}" u-i="12024933-3,12024933-0" bind:__l="__l" u-p="{{q}}">{{o}}</wd-button></view></view></wd-popup></view>
@@ -0,0 +1,269 @@
/**
* 这里是uni-app内置的常用样式变量
*
* uni-app 官方扩展插件及插件市场(https://ext.dcloud.net.cn)上很多三方插件均使用了这些样式变量
* 如果你是插件开发者,建议你使用scss预处理,并在插件代码中直接使用这些变量(无需 import 这个文件),方便用户通过搭积木的方式开发整体风格一致的App
*
*/
/**
* 如果你是App开发者(插件使用者),你可以通过修改这些变量来定制自己的插件主题,实现自定义主题功能
*
* 如果你的项目同样使用了scss预处理,你也可以直接在你的 scss 代码中使用如下变量,同时无需 import 这个文件
*/
/* 颜色变量 */
/* 行为相关颜色 */
/* 文字基本颜色 */
/* 背景颜色 */
/* 边框颜色 */
/* 尺寸变量 */
/* 文字尺寸 */
/* 图片尺寸 */
/* Border Radius */
/* 水平间距 */
/* 垂直间距 */
/* 透明度 */
/* 文章场景相关 */
/**
* 辅助函数
*/
/**
* 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 */
/**
* 混合宏
*/
/**
* 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 阴影
*/
.wot-theme-dark .wd-message-box__body.data-v-12024933 {
background-color: var(--wot-dark-background2, #1b1b1b);
}
.wot-theme-dark .wd-message-box__title.data-v-12024933 {
color: var(--wot-dark-color, var(--wot-color-white, rgb(255, 255, 255)));
}
.wot-theme-dark .wd-message-box__content.data-v-12024933 {
color: var(--wot-dark-color3, rgba(232, 230, 227, 0.8));
}
.wot-theme-dark .wd-message-box__content.data-v-12024933::-webkit-scrollbar-thumb {
background: var(--wot-dark-border-color, #3a3a3c);
}
.data-v-12024933 .wd-message-box {
border-radius: var(--wot-message-box-radius, 16px);
overflow: hidden;
}
.wd-message-box.data-v-12024933 {
border-radius: var(--wot-message-box-radius, 16px);
overflow: hidden;
}
.wd-message-box__container.data-v-12024933 {
width: var(--wot-message-box-width, 300px);
box-sizing: border-box;
}
.wd-message-box__body.data-v-12024933 {
background-color: var(--wot-message-box-bg, var(--wot-color-white, rgb(255, 255, 255)));
padding: var(--wot-message-box-padding, 25px 24px 0);
}
.wd-message-box__body.is-no-title.data-v-12024933 {
padding: 25px 24px 0px;
}
.wd-message-box__title.data-v-12024933 {
text-align: center;
font-size: var(--wot-message-box-title-fs, 16px);
color: var(--wot-message-box-title-color, rgba(0, 0, 0, 0.85));
line-height: 20px;
font-weight: 500;
padding-top: 5px;
padding-bottom: 10px;
}
.wd-message-box__content.data-v-12024933 {
max-height: var(--wot-message-box-content-max-height, 264px);
color: var(--wot-message-box-content-color, #666666);
font-size: var(--wot-message-box-content-fs, 14px);
text-align: center;
overflow: auto;
line-height: 20px;
}
.wd-message-box__content.data-v-12024933::-webkit-scrollbar {
width: var(--wot-message-box-content-scrollbar-width, 4px);
}
.wd-message-box__content.data-v-12024933::-webkit-scrollbar-thumb {
width: var(--wot-message-box-content-scrollbar-width, 4px);
background: var(--wot-message-box-content-scrollbar-color, rgba(0, 0, 0, 0.1));
border-radius: calc(var(--wot-message-box-content-scrollbar-width, 4px) / 2);
}
.wd-message-box__input-error.data-v-12024933 {
min-height: 18px;
margin-top: 2px;
color: var(--wot-message-box-input-error-color, var(--wot-input-error-color, var(--wot-color-danger, #fa4350)));
text-align: left;
}
.wd-message-box__input-error.is-hidden.data-v-12024933 {
visibility: hidden;
}
.wd-message-box__actions.data-v-12024933 {
padding: 24px;
}
.data-v-12024933 .wd-message-box__actions-btn:not(:last-child) {
margin-right: 16px;
}
.wd-message-box__flex.data-v-12024933 {
display: flex;
}
.wd-message-box__block.data-v-12024933 {
display: block;
}
.wd-message-box__cancel.data-v-12024933 {
margin-right: 16px;
}