Constants.ets 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. import { pinyin4js } from "@ohos/pinyin4js"
  2. export const APP_ID = "wx263d1c80d204c3c0"
  3. export const APP_SECRET = "a29d0d08885334589698837e46d4573a"
  4. // WebDAV相关常量
  5. export class Constants {
  6. // WebDAV Preferences名称
  7. public static readonly WEBDAV_PREFERENCE_NAME: string = 'WebdavPreferences'
  8. // 分块加载大小
  9. public static readonly CHUNK_SIZE: number = 100
  10. // 音频文件扩展名
  11. public static readonly AUDIO_EXTENSIONS = ['.mp3','.wav','.wma','.mp2','.mov','.flac',
  12. '.midi','.ra','.aac','.ape','.cda','.alac','.m4a','.mp4','.wmv','.mkv',
  13. '.3gv','.m4v','.avi','.rmvb','.flv','.3g2','.rmvb','.mpg','.webm','.ogv','.f4v','.swf'
  14. ,'.dsf','.vob','.3gp','.mpeg','.ts','.ogg','.opus','.wv','.aiff','.amr','.aif','.dff'
  15. ,'.aif','.au','.eac3','.mlp','.tak','.thd','.tta','.wv','.ac3','.amr','.mka','.mpc','.ra','.dts'
  16. , '.asf','.m2ts','.m4b','.mts','.rm','.wtv','.av3a','.dsd']
  17. // 图片扩展名
  18. public static readonly IMAGE_EXTENSIONS = ['.jpg', '.jpeg', '.png', '.webp', '.bmp']
  19. // 歌词扩展名
  20. public static readonly LYRIC_EXTENSIONS = ['.lrc']
  21. // 默认值
  22. public static readonly UNKNOWN_NAME: string = '未命名'
  23. public static readonly UNKNOWN_TITLE: string = '未知标题'
  24. public static readonly UNKNOWN_ARTIST: string = '未知艺术家'
  25. public static readonly UNKNOWN_SAMPLE_RATE: string = '未知采样率'
  26. public static readonly UNKNOWN_TRACK_COUNT: string = '未知轨道'
  27. public static readonly UNKNOWN_MIME_TYPE: string = 'audio/mpeg'
  28. // 默认封面
  29. public static readonly COMMON_SONG_DEFAULT_IMAGE: ResourceStr = $r('app.media.music_red')
  30. public static readonly COMMON_BORDER_RADIUS: number = 8
  31. public static readonly COMMON_HIGHLIGHT_COLOR: string = '#e45050'
  32. public static readonly COMMON_HIGHLIGHT_LIGHT_COLOR: string = '#f9d7d7'
  33. }
  34. // 本地化语言
  35. export function getFirstLetter(text: string){
  36. if (!text) return '#';
  37. const pinyin = pinyin4js.getShortPinyin(text).toUpperCase() as string
  38. const firstLetter = pinyin[0];
  39. return /^[A-Z]$/.test(firstLetter) ? firstLetter : '#';
  40. }