index.ts 843 B

1234567891011121314151617181920212223242526272829303132333435
  1. export const inDebug = true
  2. export function downloadFile(file: string, name?: string) {
  3. window.open(file)
  4. // const a = document.createElement('a')
  5. // a.href = file
  6. // a.download = name ?? file
  7. // a.click()
  8. }
  9. export function getFileType(ext: string) {
  10. if (['doc', 'docx'].includes(ext)) {
  11. return 'doc'
  12. }
  13. if (['xls', 'xlsx'].includes(ext)) {
  14. return 'xls'
  15. }
  16. if (['ppt', 'pptx'].includes(ext)) {
  17. return 'ppt'
  18. }
  19. if (['pdf'].includes(ext)) {
  20. return 'pdf'
  21. }
  22. if (['jpg', 'jpeg', 'png', 'gif', 'bmp'].includes(ext)) {
  23. return 'image'
  24. }
  25. if (['mp4', 'avi', 'rmvb', 'rm', 'asf', 'divx', 'mpg', 'mpeg', 'mpe', 'wmv', 'mkv', 'vob'].includes(ext)) {
  26. return 'video'
  27. }
  28. if (['mp3', 'wma', 'wav', 'midi', 'ape', 'flac', 'aac', 'ogg', 'm4a'].includes(ext)) {
  29. return 'music'
  30. }
  31. return 'unknow'
  32. }