Files
AlgerMusicPlayer/src/utils/index.ts
T

39 lines
1.1 KiB
TypeScript
Raw Normal View History

import { computed } from 'vue'
2021-07-21 15:01:39 +08:00
// 设置歌手背景图片
export const setBackgroundImg = (url: String) => {
return 'background-image:' + 'url(' + url + ')'
2021-11-09 11:34:09 +08:00
}
2021-07-21 15:01:39 +08:00
// 设置动画类型
export const setAnimationClass = (type: String) => {
return 'animate__animated ' + type
2021-11-09 11:34:09 +08:00
}
2021-07-21 15:01:39 +08:00
// 设置动画延时
export const setAnimationDelay = (index: number = 6, time: number = 50) => {
return 'animation-delay:' + index * time + 'ms'
2021-11-09 11:34:09 +08:00
}
2021-07-21 22:30:55 +08:00
//将秒转换为分钟和秒
export const secondToMinute = (s: number) => {
2021-11-09 11:34:09 +08:00
if (!s) {
return '00:00'
2021-11-09 11:34:09 +08:00
}
let minute: number = Math.floor(s / 60)
let second: number = Math.floor(s % 60)
2021-07-21 22:30:55 +08:00
let minuteStr: string =
minute > 9 ? minute.toString() : '0' + minute.toString()
2021-07-21 22:30:55 +08:00
let secondStr: string =
second > 9 ? second.toString() : '0' + second.toString()
return minuteStr + ':' + secondStr
}
export const getIsMc = () => {
2023-12-18 19:39:36 +08:00
return true
2021-11-09 11:34:09 +08:00
}
2023-12-19 14:42:53 +08:00
export const getImgUrl = computed(() => (url: string, size: string = '') => {
const bdUrl = 'https://image.baidu.com/search/down?url='
2023-12-18 15:24:57 +08:00
const imgUrl = encodeURIComponent(`${url}?param=${size}`)
2023-12-18 19:39:36 +08:00
return `${bdUrl}${imgUrl}`
})