feat: 添加eslint 和 桌面歌词(未完成)

This commit is contained in:
alger
2024-05-16 18:54:30 +08:00
parent 5e8676a039
commit a9e5bb33e4
65 changed files with 2724 additions and 2320 deletions
+33 -36
View File
@@ -1,64 +1,61 @@
// 设置歌手背景图片
export const setBackgroundImg = (url: String) => {
return 'background-image:' + 'url(' + url + ')'
}
return `background-image:url(${url})`;
};
// 设置动画类型
export const setAnimationClass = (type: String) => {
return 'animate__animated ' + type
}
return `animate__animated ${type}`;
};
// 设置动画延时
export const setAnimationDelay = (index: number = 6, time: number = 50) => {
return 'animation-delay:' + index * time + 'ms'
}
return `animation-delay:${index * time}ms`;
};
//将秒转换为分钟和秒
// 将秒转换为分钟和秒
export const secondToMinute = (s: number) => {
if (!s) {
return '00:00'
return '00:00';
}
let minute: number = Math.floor(s / 60)
let second: number = Math.floor(s % 60)
let minuteStr: string =
minute > 9 ? minute.toString() : '0' + minute.toString()
let secondStr: string =
second > 9 ? second.toString() : '0' + second.toString()
return minuteStr + ':' + secondStr
}
const minute: number = Math.floor(s / 60);
const second: number = Math.floor(s % 60);
const minuteStr: string = minute > 9 ? minute.toString() : `0${minute.toString()}`;
const secondStr: string = second > 9 ? second.toString() : `0${second.toString()}`;
return `${minuteStr}:${secondStr}`;
};
// 格式化数字 千,万, 百万, 千万,亿
export const formatNumber = (num: any) => {
num = num * 1
num *= 1;
if (num < 10000) {
return num
return num;
}
if (num < 100000000) {
return (num / 10000).toFixed(1) + '万'
return `${(num / 10000).toFixed(1)}`;
}
return (num / 100000000).toFixed(1) + '亿'
}
const windowData = window as any
return `${(num / 100000000).toFixed(1)}亿`;
};
const windowData = window as any;
export const getIsMc = () => {
if (!windowData.electron) {
return false
return false;
}
if (windowData.electron.ipcRenderer.getStoreValue('set').isProxy) {
return true
return true;
}
return false
}
const ProxyUrl =
import.meta.env.VITE_API_PROXY + '' || 'http://110.42.251.190:9856'
return false;
};
const ProxyUrl = import.meta.env.VITE_API_PROXY || 'http://110.42.251.190:9856';
export const getMusicProxyUrl = (url: string) => {
if (!getIsMc()) {
return url
return url;
}
const PUrl = url.split('').join('+')
return `${ProxyUrl}/mc?url=${PUrl}`
}
const PUrl = url.split('').join('+');
return `${ProxyUrl}/mc?url=${PUrl}`;
};
export const getImgUrl = computed(() => (url: string, size: string = '') => {
const bdUrl = 'https://image.baidu.com/search/down?url='
const imgUrl = encodeURIComponent(`${url}?param=${size}`)
return `${bdUrl}${imgUrl}`
})
const bdUrl = 'https://image.baidu.com/search/down?url=';
const imgUrl = encodeURIComponent(`${url}?param=${size}`);
return `${bdUrl}${imgUrl}`;
});