BuildTimeConstants.ts 772 B

1234567891011121314151617181920212223
  1. /*
  2. * @Author: dgflash
  3. * @Date: 2021-07-03 16:13:17
  4. * @LastEditors: dgflash
  5. * @LastEditTime: 2022-08-02 14:25:27
  6. */
  7. import * as buildTimeConstants from 'cc/env';
  8. const keys = (Object.keys(buildTimeConstants) as (keyof typeof buildTimeConstants)[]).sort();
  9. /* 游戏运行环境 */
  10. export class BuildTimeConstants {
  11. constructor() {
  12. const keyNameMaxLen = keys.reduce((len, key) => Math.max(len, key.length), 0);
  13. var enviroment = `${keys.map((key) => {
  14. const value = buildTimeConstants[key];
  15. const valueRep = typeof value === 'boolean' ? (value ? 'true' : 'false') : value;
  16. return `\n${key.padStart(keyNameMaxLen, ' ')} : ${valueRep}`;
  17. })}`;
  18. console.log(enviroment);
  19. }
  20. }