util.ts
890 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
export interface RadioRecord {
width: number;
height: number;
isLess: boolean;
radio: number;
}
export const DEFAULT_ANIMATION_INTERVAL = 2000;
export const DEFAULT_RADIO_RECORD: RadioRecord = {
width: 300,
height: 300,
isLess: false,
radio: 1,
};
export const DEFAULT_DATE_FORMAT = 'YYYY-MM-DD HH:mm:ss';
export const calcScale = (
width: number,
height: number,
widthRadio: number,
heightRadio: number
): RadioRecord => {
width = width * (widthRadio / 100);
height = height * (heightRadio / 100);
const temp = width * height;
const isLess = temp < 300 * 300;
const radio = temp / (300 * 300);
return {
width,
height,
isLess,
radio,
};
};
export const fontSize = ({ radio, basic, max }: { radio: number; basic: number; max?: number }) => {
let res = basic * radio;
if (max && res > max) res = max;
return res + 'px';
};