This commit is contained in:
Ling53666
2025-08-18 09:11:51 +08:00
commit 02554225da
2516 changed files with 133155 additions and 0 deletions

View File

@ -0,0 +1 @@
@keyframes loading-rotate{100%{transform:rotate(1turn)}}.ant-switch{display:inline-block;vertical-align:middle;box-sizing:border-box;position:relative;align-self:center;min-width:51px;height:31px;border:2px solid #eee;border-radius:15.5px;background:#fff;overflow:hidden;line-height:31px}.ant-switch-checked{background:#1677ff;border-color:#1677ff}.ant-switch-checked .ant-switch-handle{left:calc(100% - (31px - 2 * 2px))}.ant-switch-checked .ant-switch-inner{color:#fff;justify-content:flex-start}.ant-switch-disabled{opacity:.4;pointer-events:none}.ant-switch-loading{pointer-events:none}.ant-switch-loading-icon{font-size:10px;animation:loading-rotate 1s linear infinite;color:#1677ff}.ant-switch-handle{display:flex;justify-content:center;align-items:center;width:27px;height:27px;border-radius:50%;background:#fff;position:absolute;top:0;left:0;transition:all .2s;box-shadow:0 0 2px 0 rgba(0,0,0,.2),0 2px 11.5px 0 rgba(0,0,0,.08),-1px 2px 2px 0 rgba(0,0,0,.1)}.ant-switch-inner{position:relative;display:flex;justify-content:flex-end;align-items:center;height:100%;color:#999;transition:margin .2s;font-size:15px;padding:0 7px;min-width:54px;box-sizing:border-box}.ant-switch-inner:empty{display:none}.ant-switch-small{min-width:36px;height:21px;border-radius:10.5px}.ant-switch-small .ant-switch-handle{width:17px;height:17px}.ant-switch-small .ant-switch-inner{font-size:8px;padding:0 5px;min-width:36px}.ant-switch-small.ant-switch-checked .ant-switch-handle{left:calc(100% - (21px - 2 * 2px))}.ant-switch-x-small{min-width:26px;height:16px;border-radius:8px}.ant-switch-x-small .ant-switch-handle{width:12px;height:12px}.ant-switch-x-small .ant-switch-inner{font-size:5px;padding:0 3px;min-width:28px}.ant-switch-x-small.ant-switch-checked .ant-switch-handle{left:calc(100% - (16px - 2 * 2px))}

View File

@ -0,0 +1,21 @@
<view
class="ant-switch {{className ? className : ''}} ant-switch-{{size}} {{mixin.value ? 'ant-switch-checked' : ''}} {{disabled ? 'ant-switch-disabled' : ''}} {{loading ? 'ant-switch-loading' : ''}}"
style="{{mixin.value && color ? 'background:' + color + '; border-color:' + color : ''}};{{style || ''}}"
onTap="onChange"
>
<view class="ant-switch-handle">
<ant-icon
a:if="{{loading}}"
type="UndoOutline"
className="ant-switch-loading-icon"
></ant-icon>
</view>
<view class="ant-switch-inner">
<block a:if="{{mixin.value}}">
<slot name="checkedText">{{checkedText}}</slot>
</block>
<block a:else>
<slot name="uncheckedText">{{uncheckedText}}</slot>
</block>
</view>
</view>

View File

@ -0,0 +1 @@
export {};

View File

@ -0,0 +1,17 @@
import { Component, triggerEvent } from '../_util/simply';
import { SwitchDefaultProps } from './props';
import mixinValue from '../mixins/value';
Component(SwitchDefaultProps, {
onChange: function (e) {
var value = !this.getValue();
if (!this.isControlled()) {
this.update(value);
}
triggerEvent(this, 'change', value, e);
},
}, null, [
mixinValue({
valueKey: 'checked',
defaultValueKey: 'defaultChecked',
}),
]);

View File

@ -0,0 +1,6 @@
{
"component": true,
"usingComponents": {
"ant-icon": "../Icon/index"
}
}

View File

@ -0,0 +1,44 @@
import { IBaseProps } from '../_util/base';
/**
* @description 开关。
*/
export interface ISwitchProps extends IBaseProps {
/**
* @description 是否勾选
*/
checked?: boolean;
/**
* @description 是否加载状态
*/
loading?: boolean;
/**
* @description 选中时的颜色
*/
color?: string;
/**
* @description 选中时的内容
*/
checkedText?: string;
/**
* @description 非选中时的内容
*/
uncheckedText?: string;
/**
* @default medium
* @description 尺寸
*/
size?: 'medium' | 'small' | 'x-small';
/**
* 是否禁用
*/
disabled?: boolean;
/**
* 初始值
*/
defaultChecked?: boolean;
/**
* @description 修改回调方法
*/
onChange?: (checked: boolean, e: Record<string, any>) => void;
}
export declare const SwitchDefaultProps: Partial<ISwitchProps>;

View File

@ -0,0 +1,10 @@
export var SwitchDefaultProps = {
checked: null,
loading: false,
color: '',
checkedText: '',
uncheckedText: '',
size: 'medium',
disabled: false,
defaultChecked: false,
};