mirror of
https://github.com/Megghy/vtsuru.live.git
synced 2025-12-07 02:46:55 +08:00
更新项目配置,删除不必要的文件,优化依赖项,修复类型定义,添加新歌单样式
This commit is contained in:
79
src/Utils.ts
79
src/Utils.ts
@@ -1,6 +1,9 @@
|
||||
import { useStorage } from '@vueuse/core'
|
||||
import {
|
||||
ConfigProviderProps,
|
||||
NButton,
|
||||
NIcon,
|
||||
NTooltip,
|
||||
UploadFileInfo,
|
||||
createDiscreteApi,
|
||||
darkTheme,
|
||||
@@ -8,10 +11,13 @@ import {
|
||||
useOsTheme,
|
||||
zhCN
|
||||
} from 'naive-ui'
|
||||
import { ThemeType } from './api/api-models'
|
||||
import { SongFrom, SongsInfo, ThemeType } from './api/api-models'
|
||||
import { computed } from 'vue'
|
||||
import { VTSURU_API_URL } from './data/constants'
|
||||
import { DiscreteApiType } from 'naive-ui/es/discrete/src/interface'
|
||||
import { SquareArrowForward24Filled } from '@vicons/fluent';
|
||||
import FiveSingIcon from '@/svgs/fivesing.svg'
|
||||
import NeteaseIcon from '@/svgs/netease.svg'
|
||||
|
||||
const { message } = createDiscreteApi(['message'])
|
||||
|
||||
@@ -29,7 +35,7 @@ export const configProviderPropsRef = computed<ConfigProviderProps>(() => ({
|
||||
theme: theme.value,
|
||||
locale: zhCN,
|
||||
dateLocale: dateZhCN,
|
||||
|
||||
|
||||
}))
|
||||
export function createNaiveUIApi(types: DiscreteApiType[]) {
|
||||
return createDiscreteApi(types, {
|
||||
@@ -139,7 +145,8 @@ export async function getImageUploadModel(
|
||||
}
|
||||
return result
|
||||
}
|
||||
export function getUserAvatarUrl(userId: number) {
|
||||
export function getUserAvatarUrl(userId: number | undefined | null) {
|
||||
if (!userId) return ''
|
||||
return VTSURU_API_URL + 'user-face/' + userId
|
||||
}
|
||||
export function getOUIdAvatarUrl(ouid: string) {
|
||||
@@ -198,3 +205,69 @@ export class GuidUtils {
|
||||
return buffer
|
||||
}
|
||||
}
|
||||
export function GetPlayButton(song: SongsInfo) {
|
||||
switch (song.from) {
|
||||
case SongFrom.FiveSing: {
|
||||
return h(NTooltip, null, {
|
||||
trigger: () =>
|
||||
h(
|
||||
h(
|
||||
NButton,
|
||||
{
|
||||
size: 'small',
|
||||
color: '#00BBB3',
|
||||
ghost: true,
|
||||
onClick: () => {
|
||||
window.open(`http://5sing.kugou.com/bz/${song.id}.html`)
|
||||
},
|
||||
},
|
||||
{
|
||||
icon: () => h(FiveSingIcon, { class: 'svg-icon fivesing' }),
|
||||
},
|
||||
),
|
||||
),
|
||||
default: () => '在5sing打开',
|
||||
})
|
||||
}
|
||||
case SongFrom.Netease:
|
||||
return h(NTooltip, null, {
|
||||
trigger: () =>
|
||||
h(
|
||||
NButton,
|
||||
{
|
||||
size: 'small',
|
||||
color: '#C20C0C',
|
||||
ghost: true,
|
||||
onClick: () => {
|
||||
window.open(`https://music.163.com/#/song?id=${song.id}`)
|
||||
},
|
||||
},
|
||||
{
|
||||
icon: () => h(NeteaseIcon, { class: 'svg-icon netease' }),
|
||||
},
|
||||
),
|
||||
default: () => '在网易云打开',
|
||||
})
|
||||
case SongFrom.Custom:
|
||||
return song.url
|
||||
? h(NTooltip, null, {
|
||||
trigger: () =>
|
||||
h(
|
||||
NButton,
|
||||
{
|
||||
size: 'small',
|
||||
color: '#6b95bd',
|
||||
ghost: true,
|
||||
onClick: () => {
|
||||
window.open(song.url)
|
||||
},
|
||||
},
|
||||
{
|
||||
icon: () => h(NIcon, { component: SquareArrowForward24Filled }),
|
||||
},
|
||||
),
|
||||
default: () => '打开链接',
|
||||
})
|
||||
: null
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user