CompUtils.ets 1.08 KB
import { LabelDTO } from 'wdBean';
import { Logger } from 'wdKit';

const TAG: string = 'CompCornerUtil';

/**
 * 与组件布局(边距/间距/圆角半径)相关的数字
 */
export class CompUtils {
  // 高/宽比
  public static readonly ASPECT_RATIO_1_1: number = 1;
  public static readonly ASPECT_RATIO_2_1: number = 2;
  public static readonly ASPECT_RATIO_3_4: number = 3 / 4;
  public static readonly ASPECT_RATIO_16_9: number = 16 / 9;
  public static readonly ASPECT_RATIO_75_45: number = 75 / 45; // 角标宽高比
  /**
   * The max lines.
   */
  public static readonly MAX_LINES_1: number = 1;
  public static readonly MAX_LINES_2: number = 2;
  public static readonly MAX_LINES_3: number = 3;

  /**
   * 获取Label标题
   *
   * @param component 组件bean
   * @return Label标题
   */
  static getLabelTitle(extraData?: string): string {
    if (!extraData) {
      return ""
    }
    let labelDTO = JSON.parse(extraData) as LabelDTO
    if (!labelDTO) {
      Logger.info(TAG, 'getLabelTitle, labels is null');
      return ""
    }


    return labelDTO.title ?? "";
  }
}