config.ts
1.65 KB
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
47
48
49
50
51
52
53
import cloneDeep from 'lodash-es/cloneDeep';
import { InstrumentComponent2Config } from '.';
import {
  ConfigType,
  CreateComponentType,
  PublicComponentOptions,
  PublicPresetOptions,
} from '/@/views/visual/packages/index.type';
import { PublicConfigClass, componentInitConfig } from '/@/views/visual/packages/publicConfig';
import { ComponentConfigFieldEnum } from '/@/views/visual/packages/enum';
export enum Gradient {
  FIRST = 'first',
  SECOND = 'second',
  THIRD = 'third',
}
export enum GradientColor {
  FIRST = '#67e0e3',
  SECOND = '#37a2da',
  THIRD = '#fd666d',
}
export const option: PublicPresetOptions = {
  [ComponentConfigFieldEnum.FONT_COLOR]: GradientColor.THIRD,
  [ComponentConfigFieldEnum.GRADIENT_INFO]: [
    { key: Gradient.FIRST, value: 30, color: GradientColor.FIRST },
    { key: Gradient.SECOND, value: 70, color: GradientColor.SECOND },
    { key: Gradient.THIRD, value: 100, color: GradientColor.THIRD },
  ],
  [ComponentConfigFieldEnum.UNIT]: 'km/h',
  [ComponentConfigFieldEnum.SHOW_DEVICE_NAME]: false,
  [ComponentConfigFieldEnum.SHOW_TIME]: false,
  [ComponentConfigFieldEnum.MAX_NUMBER]: 100,
  [ComponentConfigFieldEnum.FONT_SIZE]: 14,
  [ComponentConfigFieldEnum.VALUE_SIZE]: 14,
};
export default class Config extends PublicConfigClass implements CreateComponentType {
  public key: string = InstrumentComponent2Config.key;
  public attr = { ...componentInitConfig };
  public componentConfig: ConfigType = cloneDeep(InstrumentComponent2Config);
  public persetOption = cloneDeep(option);
  public option: PublicComponentOptions;
  constructor(option: PublicComponentOptions) {
    super();
    this.option = { ...option };
  }
}