clickgo 3.15.26 → 3.15.28
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -1
- package/dist/app/demo/config.json +4 -0
- package/dist/app/demo/form/control/iconview/iconview.js +2 -1
- package/dist/app/demo/form/control/iconview/iconview.xml +2 -1
- package/dist/app/demo/form/control/palette/palette.js +36 -0
- package/dist/app/demo/form/control/palette/palette.xml +14 -0
- package/dist/app/demo/form/control/uploader/uploader.js +74 -0
- package/dist/app/demo/form/control/uploader/uploader.xml +10 -0
- package/dist/app/demo/form/main.js +10 -0
- package/dist/app/demo/form/main.xml +3 -1
- package/dist/app/demo/form/method/tool/tool.js +6 -0
- package/dist/app/demo/form/method/tool/tool.xml +4 -0
- package/dist/clickgo.js +1 -1
- package/dist/clickgo.ts +1 -1
- package/dist/control/arteditor.cgc +0 -0
- package/dist/control/box.cgc +0 -0
- package/dist/control/common.cgc +0 -0
- package/dist/control/desc.cgc +0 -0
- package/dist/control/drawer.cgc +0 -0
- package/dist/control/echarts.cgc +0 -0
- package/dist/control/form.cgc +0 -0
- package/dist/control/iconview.cgc +0 -0
- package/dist/control/jodit.cgc +0 -0
- package/dist/control/map.cgc +0 -0
- package/dist/control/monaco.cgc +0 -0
- package/dist/control/nav.cgc +0 -0
- package/dist/control/page.cgc +0 -0
- package/dist/control/property.cgc +0 -0
- package/dist/control/table.cgc +0 -0
- package/dist/control/task.cgc +0 -0
- package/dist/control/tuieditor.cgc +0 -0
- package/dist/control/tuiviewer.cgc +0 -0
- package/dist/control/xterm.cgc +0 -0
- package/dist/global.css +1 -1
- package/dist/lib/form.js +18 -4
- package/dist/lib/form.ts +17 -4
- package/dist/lib/fs.js +1 -1
- package/dist/lib/fs.ts +1 -1
- package/dist/lib/task.js +17 -2
- package/dist/lib/task.ts +37 -2
- package/dist/lib/tool.js +172 -32
- package/dist/lib/tool.ts +214 -35
- package/dist/theme/byterun.cgt +0 -0
- package/dist/theme/familiar.cgt +0 -0
- package/dist/theme/light.cgt +0 -0
- package/package.json +1 -1
- package/types/index.d.ts +69 -1
package/dist/lib/tool.ts
CHANGED
|
@@ -104,6 +104,20 @@ export function sizeFormat(size: number, spliter: string = ' '): string {
|
|
|
104
104
|
return (Math.round(size * 100) / 100).toString() + spliter + units[i];
|
|
105
105
|
}
|
|
106
106
|
|
|
107
|
+
/**
|
|
108
|
+
* --- 将毫克重量格式化为带单位的字符串 ---
|
|
109
|
+
* @param weight 毫克重量
|
|
110
|
+
* @param spliter 分隔符
|
|
111
|
+
*/
|
|
112
|
+
export function weightFormat(weight: number, spliter: string = ' '): string {
|
|
113
|
+
const units = ['mg', 'g', 'kg'];
|
|
114
|
+
let i = 0;
|
|
115
|
+
for (; i < 3 && weight >= 1000; ++i) {
|
|
116
|
+
weight /= 1000;
|
|
117
|
+
}
|
|
118
|
+
return (Math.round(weight * 10000) / 10000).toString() + spliter + units[i];
|
|
119
|
+
}
|
|
120
|
+
|
|
107
121
|
/**
|
|
108
122
|
* --- 完整的克隆一份数组/对象 ---
|
|
109
123
|
* @param obj 要克隆的对象
|
|
@@ -674,45 +688,210 @@ export function escapeHTML(html: string): string {
|
|
|
674
688
|
return html.replace(/</g, '<').replace(/>/g, '>');
|
|
675
689
|
}
|
|
676
690
|
|
|
691
|
+
/**
|
|
692
|
+
* --- 将 rgb 或 hsl 等颜色转换为数字数组 ---
|
|
693
|
+
* @param color 颜色字符串
|
|
694
|
+
*/
|
|
695
|
+
export function formatColor(color: string): number[] {
|
|
696
|
+
const match = /[0-9.%, ]+/.exec(color);
|
|
697
|
+
if (!match) {
|
|
698
|
+
return [];
|
|
699
|
+
}
|
|
700
|
+
const arr = match[0].split(',');
|
|
701
|
+
return arr.map((v: string) => {
|
|
702
|
+
return parseFloat(v);
|
|
703
|
+
});
|
|
704
|
+
}
|
|
705
|
+
|
|
706
|
+
/**
|
|
707
|
+
* --- 将 r, g, b 转换为 hex 字符串,不含 # ---
|
|
708
|
+
* @param r r 或 rgb 用 , 分隔的字符串
|
|
709
|
+
* @param g 可留空,g
|
|
710
|
+
* @param b 可留空,b
|
|
711
|
+
*/
|
|
712
|
+
export function rgb2hex(r: string | number, g?: string | number, b?: string | number, a: string | number = 1): string {
|
|
713
|
+
if (g === undefined || b === undefined) {
|
|
714
|
+
if (typeof r !== 'string') {
|
|
715
|
+
return '';
|
|
716
|
+
}
|
|
717
|
+
const rgb = formatColor(r);
|
|
718
|
+
r = Math.round(rgb[0]);
|
|
719
|
+
g = Math.round(rgb[1]);
|
|
720
|
+
b = Math.round(rgb[2]);
|
|
721
|
+
a = rgb[3] ?? 1;
|
|
722
|
+
}
|
|
723
|
+
else {
|
|
724
|
+
if (typeof r === 'string') {
|
|
725
|
+
r = Math.round(parseFloat(r));
|
|
726
|
+
}
|
|
727
|
+
if (typeof g === 'string') {
|
|
728
|
+
g = Math.round(parseFloat(g));
|
|
729
|
+
}
|
|
730
|
+
if (typeof b === 'string') {
|
|
731
|
+
b = Math.round(parseFloat(b));
|
|
732
|
+
}
|
|
733
|
+
if (typeof a === 'string') {
|
|
734
|
+
a = parseFloat(a);
|
|
735
|
+
}
|
|
736
|
+
}
|
|
737
|
+
return ((r << 16) + (g << 8) + b).toString(16).padStart(6, '0') + (a === 1 ? '' : Math.round(a * 255).toString(16).padStart(2, '0'));
|
|
738
|
+
}
|
|
739
|
+
|
|
740
|
+
/**
|
|
741
|
+
* --- hex 转换为 rgba,#27ae60ff, 27ae60 #fff
|
|
742
|
+
* @param hex hex 字符串,无所谓带不带 #
|
|
743
|
+
*/
|
|
744
|
+
export function hex2rgb(hex: string): {
|
|
745
|
+
'r': number;
|
|
746
|
+
'g': number;
|
|
747
|
+
'b': number;
|
|
748
|
+
'a': number;
|
|
749
|
+
'rgb': string;
|
|
750
|
+
} {
|
|
751
|
+
const rgb = {
|
|
752
|
+
'r': 0,
|
|
753
|
+
'g': 0,
|
|
754
|
+
'b': 0,
|
|
755
|
+
'a': 1,
|
|
756
|
+
'rgb': 'rgb'
|
|
757
|
+
};
|
|
758
|
+
let alpha = false,
|
|
759
|
+
h = hex.slice(hex.startsWith('#') ? 1 : 0);
|
|
760
|
+
if (h.length === 3) {
|
|
761
|
+
h = [...h].map(x => x + x).join('');
|
|
762
|
+
}
|
|
763
|
+
else if (h.length === 8) {
|
|
764
|
+
alpha = true;
|
|
765
|
+
}
|
|
766
|
+
const hn = parseInt(h, 16);
|
|
767
|
+
rgb.r = (hn >>> (alpha ? 24 : 16));
|
|
768
|
+
rgb.g = (hn & (alpha ? 0x00ff0000 : 0x00ff00)) >>> (alpha ? 16 : 8);
|
|
769
|
+
rgb.b = (hn & (alpha ? 0x0000ff00 : 0x0000ff)) >>> (alpha ? 8 : 0);
|
|
770
|
+
if (alpha) {
|
|
771
|
+
rgb.a = Math.round((hn & 0x000000ff) / 255 * 100) / 1000;
|
|
772
|
+
}
|
|
773
|
+
rgb.rgb = `${alpha ? 'a' : ''}(${rgb.r},${rgb.g},${rgb.b}${alpha ? ',' + rgb.a : ''})`;
|
|
774
|
+
return rgb;
|
|
775
|
+
}
|
|
776
|
+
|
|
677
777
|
/**
|
|
678
778
|
* --- rgb 字符串转 hsl 数组 ---
|
|
679
779
|
* @param rgb rgb(x, x, x) 或直接 x,x,x
|
|
680
780
|
*/
|
|
681
|
-
export function rgb2hsl(
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
781
|
+
export function rgb2hsl(r: string | number, g?: string | number, b?: string | number, a: string | number = 1): {
|
|
782
|
+
'h': number;
|
|
783
|
+
's': number;
|
|
784
|
+
'l': number;
|
|
785
|
+
'a': number;
|
|
786
|
+
'hsl': string;
|
|
787
|
+
} {
|
|
788
|
+
const hsl = {
|
|
789
|
+
'h': 0,
|
|
790
|
+
's': 0,
|
|
791
|
+
'l': 0,
|
|
792
|
+
'a': 1,
|
|
793
|
+
'hsl': 'hsl'
|
|
794
|
+
};
|
|
795
|
+
if (g === undefined || b === undefined) {
|
|
796
|
+
if (typeof r !== 'string') {
|
|
797
|
+
return hsl;
|
|
798
|
+
}
|
|
799
|
+
const rgb = formatColor(r);
|
|
800
|
+
r = Math.round(rgb[0]);
|
|
801
|
+
g = Math.round(rgb[1]);
|
|
802
|
+
b = Math.round(rgb[2]);
|
|
803
|
+
a = rgb[3] ?? 1;
|
|
804
|
+
}
|
|
805
|
+
else {
|
|
806
|
+
if (typeof r === 'string') {
|
|
807
|
+
r = Math.round(parseFloat(r));
|
|
808
|
+
}
|
|
809
|
+
if (typeof g === 'string') {
|
|
810
|
+
g = Math.round(parseFloat(g));
|
|
811
|
+
}
|
|
812
|
+
if (typeof b === 'string') {
|
|
813
|
+
b = Math.round(parseFloat(b));
|
|
814
|
+
}
|
|
815
|
+
if (typeof a === 'string') {
|
|
816
|
+
a = parseFloat(a);
|
|
817
|
+
}
|
|
818
|
+
}
|
|
819
|
+
|
|
820
|
+
r /= 255;
|
|
821
|
+
g /= 255;
|
|
822
|
+
b /= 255;
|
|
823
|
+
const l = Math.max(r, g, b);
|
|
824
|
+
const s = l - Math.min(r, g, b);
|
|
825
|
+
const h = s
|
|
826
|
+
? l === r
|
|
827
|
+
? (g - b) / s
|
|
828
|
+
: l === g
|
|
829
|
+
? 2 + (b - r) / s
|
|
830
|
+
: 4 + (r - g) / s
|
|
831
|
+
: 0;
|
|
832
|
+
hsl.h = Math.round(60 * h < 0 ? 60 * h + 360 : 60 * h);
|
|
833
|
+
hsl.s = Math.round(100 * (s ? (l <= 0.5 ? s / (2 * l - s) : s / (2 - (2 * l - s))) : 0));
|
|
834
|
+
hsl.l = Math.round((100 * (2 * l - s)) / 2);
|
|
835
|
+
hsl.a = a;
|
|
836
|
+
hsl.hsl += (hsl.a === 1 ? '' : 'a') + `(${hsl.h},${hsl.s}%,${hsl.l}%${hsl.a === 1 ? '' : ',' + hsl.a})`;
|
|
837
|
+
return hsl;
|
|
838
|
+
}
|
|
839
|
+
|
|
840
|
+
/**
|
|
841
|
+
* --- hsl 字符串转 rgb 数组 ---
|
|
842
|
+
* @param rgb rgb(x, x, x) 或直接 x,x,x
|
|
843
|
+
*/
|
|
844
|
+
export function hsl2rgb(h: string | number, s?: string | number, l?: string | number, a: string | number = 1): {
|
|
845
|
+
'r': number;
|
|
846
|
+
'g': number;
|
|
847
|
+
'b': number;
|
|
848
|
+
'a': number;
|
|
849
|
+
'rgb': string;
|
|
850
|
+
} {
|
|
851
|
+
const rgb = {
|
|
852
|
+
'r': 0,
|
|
853
|
+
'g': 0,
|
|
854
|
+
'b': 0,
|
|
855
|
+
'a': 1,
|
|
856
|
+
'rgb': 'rgb'
|
|
857
|
+
};
|
|
858
|
+
if (s === undefined || l === undefined) {
|
|
859
|
+
if (typeof h !== 'string') {
|
|
860
|
+
return rgb;
|
|
861
|
+
}
|
|
862
|
+
const hsl = formatColor(h);
|
|
863
|
+
h = Math.round(hsl[0]);
|
|
864
|
+
s = Math.round(hsl[1]);
|
|
865
|
+
l = Math.round(hsl[2]);
|
|
866
|
+
a = hsl[3] ?? 1;
|
|
867
|
+
}
|
|
868
|
+
else {
|
|
869
|
+
if (typeof h === 'string') {
|
|
870
|
+
h = Math.round(parseFloat(h));
|
|
871
|
+
}
|
|
872
|
+
if (typeof s === 'string') {
|
|
873
|
+
s = Math.round(parseFloat(s));
|
|
874
|
+
}
|
|
875
|
+
if (typeof l === 'string') {
|
|
876
|
+
l = Math.round(parseFloat(l));
|
|
877
|
+
}
|
|
878
|
+
if (typeof a === 'string') {
|
|
879
|
+
a = parseFloat(a);
|
|
880
|
+
}
|
|
881
|
+
}
|
|
882
|
+
|
|
883
|
+
s /= 100;
|
|
884
|
+
l /= 100;
|
|
885
|
+
const k = (n: number): number => (n + h / 30) % 12;
|
|
886
|
+
const aa = s * Math.min(l, 1 - l);
|
|
887
|
+
const f = (n: number): number =>
|
|
888
|
+
l - aa * Math.max(-1, Math.min(k(n) - 3, Math.min(9 - k(n), 1)));
|
|
889
|
+
rgb.r = Math.round(255 * f(0));
|
|
890
|
+
rgb.g = Math.round(255 * f(8));
|
|
891
|
+
rgb.b = Math.round(255 * f(4));
|
|
892
|
+
rgb.a = a;
|
|
893
|
+
rgb.rgb += (rgb.a === 1 ? '' : 'a') + `(${rgb.r},${rgb.g},${rgb.b}${rgb.a === 1 ? '' : ',' + rgb.a})`;
|
|
894
|
+
return rgb;
|
|
716
895
|
}
|
|
717
896
|
|
|
718
897
|
/**
|
package/dist/theme/byterun.cgt
CHANGED
|
Binary file
|
package/dist/theme/familiar.cgt
CHANGED
|
Binary file
|
package/dist/theme/light.cgt
CHANGED
|
Binary file
|
package/package.json
CHANGED
package/types/index.d.ts
CHANGED
|
@@ -605,12 +605,18 @@ export interface IFormDialogOptions {
|
|
|
605
605
|
/** --- 路径基,以 / 结束或文件路径则以文件的基路径为准,可留空 --- */
|
|
606
606
|
'path'?: string;
|
|
607
607
|
|
|
608
|
-
'select'?: (e:
|
|
608
|
+
'select'?: (this: AbstractForm & { 'data': Record<string, any>; }, e: IFormDialogSelectEvent, button: string) => void;
|
|
609
609
|
|
|
610
610
|
/** --- 当前的 taskId,App 模式下无效 --- */
|
|
611
611
|
'taskId'?: number;
|
|
612
612
|
}
|
|
613
613
|
|
|
614
|
+
export interface IFormDialogSelectEvent extends ICustomEvent {
|
|
615
|
+
'detail': {
|
|
616
|
+
'button': string;
|
|
617
|
+
};
|
|
618
|
+
}
|
|
619
|
+
|
|
614
620
|
/** --- Confirm 选项 --- */
|
|
615
621
|
export interface IFormConfirmOptions {
|
|
616
622
|
/** --- 当前的 taskId,App 模式下无效 --- */
|
|
@@ -626,9 +632,16 @@ export interface IFormPromptOptions {
|
|
|
626
632
|
/** --- 当前的 taskId,App 模式下无效 --- */
|
|
627
633
|
'taskId'?: number;
|
|
628
634
|
|
|
635
|
+
/** --- 标题 --- */
|
|
629
636
|
'title'?: string;
|
|
637
|
+
/** --- 内容说明 --- */
|
|
630
638
|
'content': string;
|
|
639
|
+
/** --- 文本默认值 --- */
|
|
631
640
|
'text'?: string;
|
|
641
|
+
/** --- 是否显示取消按钮,默认显示 --- */
|
|
642
|
+
'cancel'?: boolean;
|
|
643
|
+
|
|
644
|
+
'select'?: (this: AbstractForm & { 'data': Record<string, any>; }, e: IFormDialogSelectEvent, button: string) => void;
|
|
632
645
|
}
|
|
633
646
|
|
|
634
647
|
export interface IFormSetTopMostOptions {
|
|
@@ -730,6 +743,17 @@ export interface ITextMinMaxChangeEvent extends ICustomEvent {
|
|
|
730
743
|
};
|
|
731
744
|
}
|
|
732
745
|
|
|
746
|
+
// --- MenulistItem Control ---
|
|
747
|
+
|
|
748
|
+
export interface IMenulistItemCheckEvent extends ICustomEvent {
|
|
749
|
+
'detail': {
|
|
750
|
+
/** --- 当前要选中的项 --- */
|
|
751
|
+
'value': string | boolean;
|
|
752
|
+
/** --- radio 模式下,当前项的 label 内容 --- */
|
|
753
|
+
'label'?: string;
|
|
754
|
+
};
|
|
755
|
+
}
|
|
756
|
+
|
|
733
757
|
// --- Date Control ---
|
|
734
758
|
|
|
735
759
|
export interface IDateChangedEvent {
|
|
@@ -1039,6 +1063,50 @@ export interface IRadioChangeEvent extends ICustomEvent {
|
|
|
1039
1063
|
};
|
|
1040
1064
|
}
|
|
1041
1065
|
|
|
1066
|
+
// --- Palette Control ---
|
|
1067
|
+
|
|
1068
|
+
export interface IPaletteChangedEvent {
|
|
1069
|
+
'detail': {
|
|
1070
|
+
/** --- 颜色值 --- */
|
|
1071
|
+
'value': string;
|
|
1072
|
+
/** --- 对象 --- */
|
|
1073
|
+
'hsl'?: {
|
|
1074
|
+
'h': number;
|
|
1075
|
+
's': number;
|
|
1076
|
+
'l': number;
|
|
1077
|
+
'a': number;
|
|
1078
|
+
};
|
|
1079
|
+
'rgb'?: {
|
|
1080
|
+
'r': number;
|
|
1081
|
+
'g': number;
|
|
1082
|
+
'b': number;
|
|
1083
|
+
'a': number;
|
|
1084
|
+
};
|
|
1085
|
+
};
|
|
1086
|
+
}
|
|
1087
|
+
|
|
1088
|
+
// --- Colorist Control ---
|
|
1089
|
+
|
|
1090
|
+
export interface IColoristChangedEvent {
|
|
1091
|
+
'detail': {
|
|
1092
|
+
/** --- 颜色值 --- */
|
|
1093
|
+
'value': string;
|
|
1094
|
+
/** --- 对象 --- */
|
|
1095
|
+
'hsl'?: {
|
|
1096
|
+
'h': number;
|
|
1097
|
+
's': number;
|
|
1098
|
+
'l': number;
|
|
1099
|
+
'a': number;
|
|
1100
|
+
};
|
|
1101
|
+
'rgb'?: {
|
|
1102
|
+
'r': number;
|
|
1103
|
+
'g': number;
|
|
1104
|
+
'b': number;
|
|
1105
|
+
'a': number;
|
|
1106
|
+
};
|
|
1107
|
+
};
|
|
1108
|
+
}
|
|
1109
|
+
|
|
1042
1110
|
// --- Select Control ---
|
|
1043
1111
|
|
|
1044
1112
|
export interface ISelectAddEvent extends ICustomEvent {
|