1
This commit is contained in:
@@ -0,0 +1,59 @@
|
||||
|
||||
import {RGBA} from "../interface.uts"
|
||||
export function hexToRgb(sColors : string) : RGBA | null {
|
||||
if (sColors == "") {
|
||||
return null
|
||||
}
|
||||
let reg = /^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3}|[A-Fa-f0-9]{8})$/;
|
||||
let sColor : string = sColors.toLowerCase();
|
||||
|
||||
if (sColor != '' && reg.test(sColor)) {
|
||||
if (sColor.length == 4) {
|
||||
let sColorNew = "#";
|
||||
for (let i = 1; i < 4; i += 1) {
|
||||
sColorNew += sColor.slice(i, i + 1).concat(sColor.slice(i, i + 1));
|
||||
}
|
||||
sColor = sColorNew;
|
||||
}
|
||||
|
||||
//处理六位的颜色值
|
||||
let sColorChange : number[] = [];
|
||||
sColorChange.push(parseInt(sColor.substring(1, 3), 16));
|
||||
sColorChange.push(parseInt(sColor.substring(3, 5), 16));
|
||||
sColorChange.push(parseInt(sColor.substring(5, 7), 16));
|
||||
if (sColor.length == 9) {
|
||||
sColorChange.push(parseInt(sColor.substring(7, 9), 16) / 255);
|
||||
}
|
||||
return {
|
||||
r: sColorChange[0],
|
||||
g: sColorChange[1],
|
||||
b: sColorChange[2],
|
||||
a: sColorChange.length == 4 ? sColorChange[3] : 1
|
||||
} as RGBA
|
||||
} else if (/^(rgb|RGB|rgba|RGBA)/.test(sColor)) {
|
||||
let arr : string[] = sColor.replace(/(?:\(|\)|rgba|rgb|RGB|RGBA)*/g, "").split(",")
|
||||
let p : number[] = arr.map((val : string) : number => parseInt(val));
|
||||
|
||||
if (p.length < 3) {
|
||||
return {
|
||||
r: 0,
|
||||
g: 0,
|
||||
b: 0,
|
||||
a: 1
|
||||
} as RGBA
|
||||
}
|
||||
if (p.length == 3) {
|
||||
p.add(1)
|
||||
|
||||
}
|
||||
|
||||
return {
|
||||
r: p[0],
|
||||
g: p[1],
|
||||
b: p[2],
|
||||
a: arr.length==3?p[3]:parseFloat(arr[3])
|
||||
} as RGBA
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
@@ -0,0 +1,109 @@
|
||||
import {X_MODAL_TYPE,X_MODAL_TYPE_PRIVATE} from "../interface.uts"
|
||||
export const defaultConfig = {
|
||||
title:"提醒",
|
||||
content:"",
|
||||
contentAlign:'center',
|
||||
cancelText:"取消",
|
||||
cancelColor:"#333",
|
||||
cancelBgColor:"#f5f5f5",
|
||||
confirmText:"确认",
|
||||
confirmBgColor:"#0579FF",
|
||||
confirmColor:"#FFF",
|
||||
titleColor:'#000000',
|
||||
contentColor:"#333333",
|
||||
lineColor:"transparent",
|
||||
linkFontColor:"rgb(5, 121, 255)",
|
||||
radius:16,
|
||||
confirmIcon:"",
|
||||
cancelIcon:"",
|
||||
isSplitBtn:true,
|
||||
contentBgColor:"#fff",
|
||||
maskBgColor:"rgba(0,0,0,0.6)",
|
||||
confirm:()=>{},
|
||||
cancel:()=>{},
|
||||
close:()=>{},
|
||||
clickLink:(href:string)=>{},
|
||||
isBlurMask:true,
|
||||
height:80,
|
||||
width:320,
|
||||
clickMaskClose:true,
|
||||
showCancel:true
|
||||
} as X_MODAL_TYPE_PRIVATE
|
||||
|
||||
|
||||
export const configCover = (opts : X_MODAL_TYPE) : X_MODAL_TYPE_PRIVATE => {
|
||||
let title = opts.title==null?defaultConfig.title:(opts.title!);
|
||||
let content = opts.content==null?defaultConfig.content:(opts.content!);
|
||||
let cancelText = opts.cancelText==null?defaultConfig.cancelText:(opts.cancelText!);
|
||||
let cancelBgColor = opts.cancelBgColor==null?defaultConfig.cancelBgColor:(opts.cancelBgColor!);
|
||||
let cancelColor = opts.cancelColor==null?defaultConfig.cancelColor:(opts.cancelColor!);
|
||||
let confirmText = opts.confirmText==null?defaultConfig.confirmText:(opts.confirmText!);
|
||||
let confirmBgColor = opts.confirmBgColor==null?defaultConfig.confirmBgColor:(opts.confirmBgColor!);
|
||||
let confirmColor = opts.confirmColor==null?defaultConfig.confirmColor:(opts.confirmColor!);
|
||||
let radius = opts.radius==null?defaultConfig.radius:(opts.radius!);
|
||||
let confirmIcon = opts.confirmIcon==null?defaultConfig.confirmIcon:(opts.confirmIcon!);
|
||||
let cancelIcon = opts.cancelIcon==null?defaultConfig.cancelIcon:(opts.cancelIcon!);
|
||||
let contentBgColor = opts.contentBgColor==null?defaultConfig.contentBgColor:(opts.contentBgColor!);
|
||||
let maskBgColor = opts.maskBgColor==null?defaultConfig.maskBgColor:(opts.maskBgColor!);
|
||||
let confirm = opts.confirm==null?defaultConfig.confirm:(opts.confirm!);
|
||||
let cancel = opts.cancel==null?defaultConfig.cancel:(opts.cancel!);
|
||||
let close = opts.close==null?defaultConfig.close:(opts.close!);
|
||||
let height = opts.height==null?defaultConfig.height:(opts.height!);
|
||||
let width = opts.width==null?defaultConfig.width:(opts.width!);
|
||||
let titleColor = opts.titleColor==null?defaultConfig.titleColor:(opts.titleColor!);
|
||||
let contentColor = opts.contentColor==null?defaultConfig.contentColor:(opts.contentColor!);
|
||||
let contentAlign = opts.contentAlign==null?defaultConfig.contentAlign:(opts.contentAlign!);
|
||||
let clickLink = opts.clickLink==null?defaultConfig.clickLink:(opts.clickLink!);
|
||||
let linkFontColor = opts.linkFontColor==null?defaultConfig.linkFontColor:(opts.linkFontColor!);
|
||||
let lineColor = opts.lineColor==null?defaultConfig.lineColor:(opts.lineColor!);
|
||||
|
||||
|
||||
// #ifdef APP-ANDROID || APP-HARMONY
|
||||
|
||||
let clickMaskClose = opts.clickMaskClose==null?defaultConfig.clickMaskClose:(opts.clickMaskClose!);
|
||||
let showCancel = opts.showCancel==null?defaultConfig.showCancel:(opts.showCancel!);
|
||||
let isBlurMask = opts.isBlurMask==null?defaultConfig.isBlurMask:(opts.isBlurMask!);
|
||||
let isSplitBtn = opts.isSplitBtn==null?defaultConfig.isSplitBtn:(opts.isSplitBtn!);
|
||||
// #endif
|
||||
|
||||
// #ifdef WEB || APP-IOS || MP
|
||||
|
||||
let clickMaskClose = opts.clickMaskClose==null?defaultConfig.clickMaskClose:(opts.clickMaskClose);
|
||||
let showCancel = opts.showCancel==null?defaultConfig.showCancel:(opts.showCancel);
|
||||
let isBlurMask = opts.isBlurMask==null?defaultConfig.isBlurMask:(opts.isBlurMask);
|
||||
let isSplitBtn = opts.isSplitBtn==null?defaultConfig.isSplitBtn:(opts.isSplitBtn);
|
||||
// #endif
|
||||
|
||||
return {
|
||||
title,
|
||||
content,
|
||||
cancelText,
|
||||
cancelBgColor,
|
||||
cancelColor,
|
||||
confirmText,
|
||||
confirmBgColor,
|
||||
confirmColor,
|
||||
linkFontColor,
|
||||
lineColor,
|
||||
radius,
|
||||
confirmIcon,
|
||||
cancelIcon,
|
||||
isSplitBtn,
|
||||
// 框体内容背景
|
||||
contentBgColor,
|
||||
// 遮罩背景
|
||||
maskBgColor,
|
||||
confirm,
|
||||
cancel,
|
||||
close,
|
||||
clickLink,
|
||||
isBlurMask,
|
||||
height,
|
||||
width,
|
||||
clickMaskClose,
|
||||
showCancel,
|
||||
titleColor,
|
||||
contentColor,
|
||||
contentAlign
|
||||
} as X_MODAL_TYPE_PRIVATE
|
||||
}
|
||||
Reference in New Issue
Block a user