Skip to content

Commit

Permalink
feat: ✨ 新增函数重载
Browse files Browse the repository at this point in the history
  • Loading branch information
WhiteSevs committed May 22, 2024
1 parent 670fccd commit 95de8cc
Show file tree
Hide file tree
Showing 13 changed files with 495 additions and 91 deletions.
4 changes: 4 additions & 0 deletions 库/Qmsg/dist/CompatibleProcessing.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/**
* 兼容处理
*/
export declare function CompatibleProcessing(): void;
27 changes: 27 additions & 0 deletions 库/Qmsg/dist/QmsgAnimation.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
export type QmsgAnimationState = {
/** 显示中 */
opening: string;
/** 显示完成 */
done: string;
/** 关闭中 */
closing: string;
};
export declare const QmsgAnimation: {
/** 状态 & 动画 */
$state: QmsgAnimationState;
$name: {
startNameList: string[];
endNameList: string[];
};
/**
* 获取元素上的animationName属性
* @param element
*/
getStyleAnimationName(element: HTMLElement): any;
/**
* 设置元素上的animationName属性
* @param element
* @param animationNameValue
*/
setStyleAnimationName(element: HTMLElement, animationNameValue?: string): void;
};
8 changes: 8 additions & 0 deletions 库/Qmsg/dist/QmsgCSS.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export declare const QmsgCSS: {
css: string;
/**
* 获取CSS元素
* @returns
*/
getStyleElement(): HTMLStyleElement;
};
3 changes: 3 additions & 0 deletions 库/Qmsg/dist/QmsgIcon.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { QmsgType } from ".";
export declare const QmsgHeaderCloseIcon = "<svg width=\"16\" height=\"16\" viewBox=\"0 0 48 48\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\"><rect width=\"48\" height=\"48\" fill=\"white\" fill-opacity=\"0.01\"/><path d=\"M14 14L34 34\" stroke=\"#909399\" stroke-width=\"4\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/><path d=\"M14 34L34 14\" stroke=\"#909399\" stroke-width=\"4\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/></svg>";
export declare const QmsgIcon: Record<QmsgType, string>;
10 changes: 10 additions & 0 deletions 库/Qmsg/dist/QmsgInstance.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { QmsgItemInfo } from "./QmsgUtils";
export declare const QmsgObj: {
QmsgList: QmsgItemInfo[];
/**
* 移除实例
* @param uuid
* @returns
*/
remove(uuid: string): void;
};
69 changes: 69 additions & 0 deletions 库/Qmsg/dist/QmsgMsg.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
import { QmsgOption } from ".";
/**
* 每条消息的构造函数
*/
export declare class QmsgMsg {
#private;
option: QmsgOption;
uuid: string;
/**
* 主元素
*/
$Qmsg: HTMLDivElement;
constructor(option: QmsgOption, uuid: string);
/**
* 获取当前配置
* @returns
*/
getSetting(): Required<QmsgOption>;
/**
* 获取当前相同的数量
* @returns
*/
getRepeatNum(): number;
/**
* 设置repeatNum值
*/
setRepeatNum(num: number): void;
/**
* 设置repeatNum自增
*/
setRepeatNumIncreasing(): void;
/**
* 初始化元素
*/
private init;
/**
* 对timeout进行检测并转换
* 当timeout为string时,转换为number
* timeout必须在规定范围内
*/
private detectionType;
/**
* 设置元素动画状态 开启/关闭
* @param QmsgMsg
* @param state
* @returns
*/
private setState;
/**
* 设置消息数量统计
*/
setMsgCount(): void;
/**
* 关闭Qmsg(会触发动画)
*/
close(): void;
/**
* 销毁Qmsg
*/
destroy(): void;
/**
* 设置内容文本
*/
setText(text: string): void;
/**
* 设置内容超文本
*/
setHTML(text: string): void;
}
12 changes: 12 additions & 0 deletions 库/Qmsg/dist/QmsgStore.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { QmsgOption } from ".";
export declare const QmsgStore: {
/** 声明插件名称 */
PLUGIN_NAME: string;
/** 命名空间,用于css和事件 */
NAMESPACE: string;
DEFAULT: Required<QmsgOption>;
/**
* 是否支持动画属性
*/
CAN_ANIMATION: boolean;
};
33 changes: 33 additions & 0 deletions 库/Qmsg/dist/QmsgUtils.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { QmsgOption } from ".";
import { QmsgMsg } from "./QmsgMsg";
export interface QmsgItemInfo {
config: string;
instance: QmsgMsg;
uuid: string;
}
export declare const QmsgUtils: {
/**
* 生成带插件名的名称
* @param args
* @returns
*/
getNameSpacify(...args: string[]): string;
/**
* 获取唯一性的UUID
* @returns
*/
getUUID(): string;
/**
* 合并参数为配置信息,用于创建Msg实例
* @param content 文本内容
* @param config 配置
* @private
*/
mergeArgs(content?: string, config?: object): Required<QmsgOption>;
/**
* 通过配置信息 来判断是否为同一条消息,并返回消息实例
* @param option 配置项
* @private
*/
judgeReMsg(option: QmsgOption): QmsgMsg;
};
210 changes: 210 additions & 0 deletions 库/Qmsg/dist/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,210 @@
import { QmsgStore } from "./QmsgStore";
import { QmsgIcon } from "./QmsgIcon";
import { QmsgObj } from "./QmsgInstance";
import { QmsgMsg } from "./QmsgMsg";
export type QmsgPosition = "topleft" | "top" | "topright" | "left" | "center" | "right" | "bottomleft" | "bottom" | "bottomright";
export type QmsgType = "info" | "warning" | "success" | "error" | "loading";
export interface QmsgOption {
/**
* 是否使用动画
* + 默认:true
*/
animation?: boolean;
/**
* 是否自动关闭,注意在type为loading的时候自动关闭为false
* + 默认:true
*/
autoClose?: boolean;
/**
* 显示的内容
*/
content?: string;
/**
* 内容是否是html
* + 默认:false
* @deprecated 建议使用isHTML
*/
html?: boolean;
/**
* 内容是否是html
* + 默认:false
*/
isHTML?: boolean;
/**
* 弹出的位置
* + 默认:center
*/
position?: QmsgPosition;
/**
* 是否显示关闭图标
* + 默认:false
*/
showClose?: boolean;
/**
* 最大显示的数量
* + 默认:5
*/
maxNums?: number;
/**
* 关闭时的回调函数
*/
onClose?: (<T extends QmsgMsg>(this: T) => void) | null;
/**
* 是否显示左边的icon图标
* + 默认:true
*/
showIcon?: boolean;
/**
* 是否使内容进行换行显示
* + 默认:false
*/
showMoreContent?: boolean;
/**
* 弹出顺序是否逆反
* + 默认:false
*/
showReverse?: boolean;
/**
* 最大显示的时长(ms)
* + 默认:2500
*/
timeout?: number;
/**
* 弹出类型
*/
type: QmsgType;
/**
* 元素层级
* + 默认:50000
*/
zIndex?: number;
/**
* 自定义的style
*/
style?: string;
/**
* 自定义类名
*/
customClass?: string;
/**
* 是否限制宽度
* + 默认:false
*/
isLimitWidth?: boolean;
/**
* 限制宽度的数值
* + 默认:200
*/
limitWidthNum?: number | string;
/**
* 当超出限制宽度时,是否换行还是显示为省略号
* + 默认:"wrap"
*/
limitWidthWrap?: "no-wrap" | "wrap" | "ellipsis";
}
export interface QmsgDetails extends Partial<QmsgOption> {
}
interface Qmsg {
/** 版本号 */
version: string;
$data: typeof QmsgStore;
/** 图标svg */
$icons: typeof QmsgIcon;
$obj: typeof QmsgObj;
/**
* 修改默认配置
* @param option
*/
config(option?: QmsgDetails): void;
/**
* 信息
* @param content 内容
*/
info(content: string): QmsgMsg;
/**
* 信息
* @param config 配置
*/
info(config: QmsgDetails): QmsgMsg;
/**
* 信息
* @param content 内容
* @param config 配置
*/
info(content: string, config: QmsgDetails): QmsgMsg;
/**
* 警告
* @param content 内容
*/
warning(content: string): QmsgMsg;
/**
* 警告
* @param config 配置
*/
warning(config: QmsgDetails): QmsgMsg;
/**
* 警告
* @param content 内容
* @param config 配置
*/
warning(content: string, config: QmsgDetails): QmsgMsg;
/**
* 成功
* @param content 内容
*/
success(content: string): QmsgMsg;
/**
* 成功
* @param config 配置
*/
success(config: QmsgDetails): QmsgMsg;
/**
* 成功
* @param content 内容
* @param config 配置
*/
success(content: string, config: QmsgDetails): QmsgMsg;
/**
* 失败
* @param content 内容
*/
error(content: string): QmsgMsg;
/**
* 失败
* @param config 配置
*/
error(config: QmsgDetails): QmsgMsg;
/**
* 失败
* @param content 内容
* @param config 配置
*/
error(content: string, config: QmsgDetails): QmsgMsg;
/**
* 加载中
* @param content 内容
*/
loading(content: string): QmsgMsg;
/**
* 加载中
* @param config 配置
*/
loading(config: QmsgDetails): QmsgMsg;
/**
* 加载中
* @param content 内容
* @param config 配置
*/
loading(content: string, config: QmsgDetails): QmsgMsg;
/**
* 根据uuid删除Qmsg实例和元素
* @param uuid
*/
remove(uuid: string): void;
/**
* 关闭当前页面中所有的Qmsg
*/
closeAll(): void;
}
declare const Qmsg: Qmsg;
export { Qmsg };
Loading

0 comments on commit 95de8cc

Please sign in to comment.