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 @@
.ant-button{position:relative;display:flex;flex-direction:column;justify-content:center;align-items:center;height:auto;line-height:normal;padding:12px;border-radius:4px;border:0 none;box-sizing:border-box;font-size:18px;z-index:2}.ant-button-large{font-size:18px;padding:12px 12px 12px 12px}.ant-button-medium{font-size:17px;padding:8px 12px 8px 12px}.ant-button-small{font-size:15px;padding:4px 12px 4px 12px}.ant-button-primary{color:#fff;background-color:#1677ff;box-shadow:inset 0 0 0 1px #1677ff}.ant-button-default{color:#1677ff;background-color:#fff;box-shadow:inset 0 0 0 1px #1677ff}.ant-button-text{color:#1677ff;background-color:transparent;box-shadow:none}.ant-button-primary-danger{color:#fff;background-color:#ff3141;box-shadow:inset 0 0 0 1px #ff3141}.ant-button-default-danger{color:#ff3141;background-color:#fff;box-shadow:inset 0 0 0 1px #ff3141}.ant-button-text-danger{color:#ff3141;background-color:transparent;box-shadow:none}.ant-button-text-active{background-color:rgba(255,255,255,.92)}.ant-button-active{filter:brightness(.92)}.ant-button-disabled{opacity:.4}.ant-button-wrap{display:flex;flex-direction:row;align-items:center;justify-content:center}.ant-button-content-text-margin{margin-left:8px}.ant-button-content-text:empty{margin-left:0;width:0;opacity:0}.ant-button-content-text:empty::after{content:'\00a0'}.ant-button-content-subtext{font-size:12px;opacity:.6}.ant-button-content-loading-container{display:flex;justify-content:center;align-items:center;width:33px;height:16px;margin-left:8px}.ant-button-content-loading{position:relative}.ant-button-inline{display:inline-block;border-radius:4px}.ant-button-inline .ant-button-content-loading-container{width:16px;height:16px}.ant-button-inline .ant-button-content-loading{transform:scale(.5)}

View File

@ -0,0 +1,46 @@
<import-sjs
from="./index.sjs"
name="utils"
></import-sjs>
<button
formType="{{formType}}"
hoverClass="{{utils.getHoverClass(loading, type, activeClassName)}}"
scope="{{scope}}"
onTap="{{onTap ? 'onTap' : ''}}"
onGetAuthorize="onGetAuthorize"
onFollowLifestyle="onFollowLifestyle"
onError="onError"
onGetUserInfo="onGetUserInfo"
onGetPhoneNumber="onGetPhoneNumber"
catchTap="{{catchTap ? 'catchTap' : ''}}"
publicId="{{publicId}}"
openType="{{openType}}"
class="ant-button {{inline ? 'ant-button-inline ' + utils.getClass(size) : ''}} {{'ant-button-' + type + (danger ? '-danger' : '')}} {{disabled || loading ? 'ant-button-disabled' : ''}} {{className ? className : ''}}"
style="{{style}}"
>
<view class="ant-button-wrap">
<ant-icon
a:if="{{!!icon}}"
type="{{icon}}"
></ant-icon>
<view class="ant-button-content-text {{icon ? 'ant-button-content-text-margin' : ''}}">
<slot></slot>
<view
a:if="{{!inline && subText}}"
class="ant-button-content-subtext"
>
{{subText}}
</view>
</view>
<view
a:if="{{loading}}"
class="ant-button-content-loading-container"
>
<loading
type="mini"
color="currentColor"
className="ant-button-content-loading"
></loading>
</view>
</view>
</button>

View File

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

View File

@ -0,0 +1,55 @@
/* eslint-disable @typescript-eslint/ban-ts-comment */
import { ButtonDefaultProps } from './props';
import fmtEvent from '../_util/fmtEvent';
Component({
props: ButtonDefaultProps,
methods: {
onTap: function (e) {
var _a = this.props, onTap = _a.onTap, disabled = _a.disabled, loading = _a.loading, onDisabledTap = _a.onDisabledTap;
if (disabled && onDisabledTap) {
var event_1 = fmtEvent(this.props, e);
onDisabledTap(event_1);
}
if (onTap && !disabled && !loading) {
var event_2 = fmtEvent(this.props, e);
return onTap(event_2);
}
},
catchTap: function (e) {
var _a = this.props, catchTap = _a.catchTap, disabled = _a.disabled, loading = _a.loading, onDisabledTap = _a.onDisabledTap;
if (disabled && onDisabledTap) {
var event_3 = fmtEvent(this.props, e);
onDisabledTap(event_3);
}
if (catchTap && !disabled && !loading) {
var event_4 = fmtEvent(this.props, e);
return catchTap(event_4);
}
},
onGetAuthorize: function (e) {
if (this.props.onGetAuthorize) {
this.props.onGetAuthorize(fmtEvent(this.props, e));
}
},
onFollowLifestyle: function (e) {
if (this.props.onFollowLifestyle) {
this.props.onFollowLifestyle(fmtEvent(this.props, e));
}
},
onError: function (e) {
if (this.props.onError) {
this.props.onError(fmtEvent(this.props, e));
}
},
onGetUserInfo: function (e) {
if (this.props.onGetUserInfo) {
this.props.onGetUserInfo(fmtEvent(this.props, e));
}
},
onGetPhoneNumber: function (e) {
if (this.props.onGetPhoneNumber) {
this.props.onGetPhoneNumber(fmtEvent(this.props, e));
}
},
},
});

View File

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

View File

@ -0,0 +1,24 @@
function getClass(size) {
var list = ['small', 'medium', 'large'];
if (list.indexOf(size) >= 0) {
return "ant-button-".concat(size);
}
return 'ant-button-medium';
}
function getHoverClass(loading, type, activeClassName) {
if (loading) {
return '';
}
var className = 'ant-button-active';
if (type === 'text') {
className += ' ant-button-text-active';
}
if (activeClassName) {
className += ' ' + activeClassName;
}
return className;
}
export default {
getClass: getClass,
getHoverClass: getHoverClass
};

View File

@ -0,0 +1,85 @@
import { IBaseProps } from '../_util/base';
/**
* @description 按钮,用户只需单击一下即可执行操作并做出选择。
* 常用于表单提交、界面跳转、模块引导点击。具体用法和小程序框架中 button 保持一致,在 button 基础上做了样式的封装。
* 封装后的按钮可改变按钮形态、增加 loading以及内置了几种不同样式的按钮。
*/
export interface IButtonProps extends IBaseProps {
/**
* @description 按钮类型
* @default default
*/
type?: 'default' | 'primary' | 'text';
/**
* @description 是否禁用
* @default false
*/
disabled?: boolean;
/**
* @description 按下时的类名
*/
activeClassName?: string;
/**
* @description 辅助文字,显示在第二行
*/
subText?: string;
/**
* @description 内联,不撑满父级宽度
* @default false
*/
inline?: boolean;
/**
* @description 内联尺寸
* @default medium
*/
size?: 'small' | 'medium' | 'large';
/**
* @description 按钮左侧图标
*/
icon?: string;
/**
* @description 是否加载中,加载中时不可点击
* @default false
*/
loading?: boolean;
/**
* @description 是否为危险按钮,危险按钮的颜色会变成红色
* @default false
*/
danger?: boolean;
/**
* @description 按钮原生类型,在表单提交时有效
* @default button
*/
formType?: 'button' | 'submit' | 'reset';
/**
* @description 点击回调
*/
onTap?: (event: any) => void;
/**
* @description 点击回调
*/
catchTap?: (event: any) => void;
/**
* @description 禁用时点击回调
*/
onDisabledTap?: (event: any) => void;
/**
* @description 生活号 id必须是当前小程序同主体且已关联的生活号open-type="lifestyle" 时有效。
*/
publicId?: string;
/**
* @description 开放能力。
*/
openType?: string;
/**
* @description 当 openType 为 getAuthorize 时有效。
*/
scope?: string;
onGetAuthorize?: (event: any) => void;
onFollowLifestyle?: (event: any) => void;
onError?: (event: any) => void;
onGetUserInfo?: (event: any) => void;
onGetPhoneNumber?: (event: any) => void;
}
export declare const ButtonDefaultProps: Partial<IButtonProps>;

View File

@ -0,0 +1,5 @@
export var ButtonDefaultProps = {
type: 'default',
formType: 'button',
size: 'medium',
};