feat: monorepo

This commit is contained in:
qier222 2022-05-12 02:45:43 +08:00
parent 4d54060a4f
commit 42089d4996
No known key found for this signature in database
GPG key ID: 9C85007ED905F14D
200 changed files with 1530 additions and 1521 deletions

View file

@ -0,0 +1,72 @@
import { FetchArtistAlbumsResponse, FetchArtistResponse } from './api/Artist'
import { FetchAlbumResponse } from './api/Album'
import {
FetchUserAccountResponse,
FetchUserAlbumsResponse,
FetchUserArtistsResponse,
FetchUserLikedTracksIDsResponse,
FetchUserPlaylistsResponse,
} from './api/User'
import {
FetchAudioSourceResponse,
FetchLyricResponse,
FetchTracksResponse,
} from './api/Track'
import {
FetchPlaylistResponse,
FetchRecommendedPlaylistsResponse,
} from './api/Playlists'
export const enum APIs {
Album = 'album',
Artist = 'artists',
ArtistAlbum = 'artist/album',
CoverColor = 'cover_color',
Likelist = 'likelist',
Lyric = 'lyric',
Personalized = 'personalized',
Playlist = 'playlist/detail',
RecommendResource = 'recommend/resource',
SongUrl = 'song/url',
Track = 'song/detail',
UserAccount = 'user/account',
UserAlbums = 'album/sublist',
UserArtists = 'artist/sublist',
UserPlaylist = 'user/playlist',
}
export interface APIsParams {
[APIs.Album]: { id: number }
[APIs.Artist]: { id: number }
[APIs.ArtistAlbum]: { id: number }
[APIs.CoverColor]: { id: number }
[APIs.Likelist]: void
[APIs.Lyric]: { id: number }
[APIs.Personalized]: void
[APIs.Playlist]: { id: number }
[APIs.RecommendResource]: void
[APIs.SongUrl]: { id: string }
[APIs.Track]: { ids: string }
[APIs.UserAccount]: void
[APIs.UserAlbums]: void
[APIs.UserArtists]: void
[APIs.UserPlaylist]: void
}
export interface APIsResponse {
[APIs.Album]: FetchAlbumResponse
[APIs.Artist]: FetchArtistResponse
[APIs.ArtistAlbum]: FetchArtistAlbumsResponse
[APIs.CoverColor]: string | undefined
[APIs.Likelist]: FetchUserLikedTracksIDsResponse
[APIs.Lyric]: FetchLyricResponse
[APIs.Personalized]: FetchRecommendedPlaylistsResponse
[APIs.Playlist]: FetchPlaylistResponse
[APIs.RecommendResource]: FetchRecommendedPlaylistsResponse
[APIs.SongUrl]: FetchAudioSourceResponse
[APIs.Track]: FetchTracksResponse
[APIs.UserAccount]: FetchUserAccountResponse
[APIs.UserAlbums]: FetchUserAlbumsResponse
[APIs.UserArtists]: FetchUserArtistsResponse
[APIs.UserPlaylist]: FetchUserPlaylistsResponse
}

View file

@ -0,0 +1,77 @@
import { APIs } from './CacheAPIs'
import { RepeatMode } from './playerDataTypes'
import { Store } from '@/shared/store'
export const enum IpcChannels {
ClearAPICache = 'clear-api-cache',
Minimize = 'minimize',
MaximizeOrUnmaximize = 'maximize-or-unmaximize',
Close = 'close',
IsMaximized = 'is-maximized',
GetApiCacheSync = 'get-api-cache-sync',
DevDbExportJson = 'dev-db-export-json',
CacheCoverColor = 'cache-cover-color',
SetTrayTooltip = 'set-tray-tooltip',
// 准备三个播放相关channel, 为 mpris 预留接口
Play = 'play',
Pause = 'pause',
PlayOrPause = 'play-or-pause',
Next = 'next',
Previous = 'previous',
Like = 'like',
Repeat = 'repeat',
SyncSettings = 'sync-settings',
}
// ipcMain.on params
export interface IpcChannelsParams {
[IpcChannels.ClearAPICache]: void
[IpcChannels.Minimize]: void
[IpcChannels.MaximizeOrUnmaximize]: void
[IpcChannels.Close]: void
[IpcChannels.IsMaximized]: void
[IpcChannels.GetApiCacheSync]: {
api: APIs
query?: any
}
[IpcChannels.DevDbExportJson]: void
[IpcChannels.CacheCoverColor]: {
id: number
color: string
}
[IpcChannels.SetTrayTooltip]: {
text: string
}
[IpcChannels.Play]: void
[IpcChannels.Pause]: void
[IpcChannels.PlayOrPause]: void
[IpcChannels.Next]: void
[IpcChannels.Previous]: void
[IpcChannels.Like]: {
isLiked: boolean
}
[IpcChannels.Repeat]: {
mode: RepeatMode
}
[IpcChannels.SyncSettings]: Store['settings']
}
// ipcRenderer.on params
export interface IpcChannelsReturns {
[IpcChannels.ClearAPICache]: void
[IpcChannels.Minimize]: void
[IpcChannels.MaximizeOrUnmaximize]: void
[IpcChannels.Close]: void
[IpcChannels.IsMaximized]: boolean
[IpcChannels.GetApiCacheSync]: any
[IpcChannels.DevDbExportJson]: void
[IpcChannels.CacheCoverColor]: void
[IpcChannels.SetTrayTooltip]: void
[IpcChannels.Play]: void
[IpcChannels.Pause]: void
[IpcChannels.PlayOrPause]: void
[IpcChannels.Next]: void
[IpcChannels.Previous]: void
[IpcChannels.Like]: void
[IpcChannels.Repeat]: RepeatMode
}

View file

@ -0,0 +1,23 @@
export enum AlbumApiNames {
FetchAlbum = 'fetchAlbum',
}
// 专辑详情
export interface FetchAlbumParams {
id: number
}
export interface FetchAlbumResponse {
code: number
resourceState: boolean
album: Album
songs: Track[]
description: string
}
export interface LikeAAlbumParams {
t: 1 | 2
id: number
}
export interface LikeAAlbumResponse {
code: number
}

View file

@ -0,0 +1,28 @@
export enum ArtistApiNames {
FetchArtist = 'fetchArtist',
FetchArtistAlbums = 'fetchArtistAlbums',
}
// 歌手详情
export interface FetchArtistParams {
id: number
}
export interface FetchArtistResponse {
code: number
more: boolean
artist: Artist
hotSongs: Track[]
}
// 获取歌手的专辑列表
export interface FetchArtistAlbumsParams {
id: number
limit?: number // default: 50
offset?: number // default: 0
}
export interface FetchArtistAlbumsResponse {
code: number
hotAlbums: Album[]
more: boolean
artist: Artist
}

View file

@ -0,0 +1,48 @@
export enum PlaylistApiNames {
FetchPlaylist = 'fetchPlaylist',
FetchRecommendedPlaylists = 'fetchRecommendedPlaylists',
FetchDailyRecommendPlaylists = 'fetchDailyRecommendPlaylists',
LikeAPlaylist = 'likeAPlaylist',
}
// 歌单详情
export interface FetchPlaylistParams {
id: number
s?: number // 歌单最近的 s 个收藏者
}
export interface FetchPlaylistResponse {
code: number
playlist: Playlist
privileges: unknown // TODO: unknown type
relatedVideos: null
resEntrance: null
sharedPrivilege: null
urls: null
}
// 推荐歌单
export interface FetchRecommendedPlaylistsParams {
limit?: number
}
export interface FetchRecommendedPlaylistsResponse {
code: number
category: number
hasTaste: boolean
result: Playlist[]
}
// 每日推荐歌单(需要登录)
export interface FetchDailyRecommendPlaylistsResponse {
code: number
featureFirst: boolean
haveRcmdSongs: boolean
recommend: Playlist[]
}
export interface LikeAPlaylistParams {
t: 1 | 2
id: number
}
export interface LikeAPlaylistResponse {
code: number
}

View file

@ -0,0 +1,82 @@
export enum SearchApiNames {
Search = 'search',
MultiMatchSearch = 'multiMatchSearch',
}
// 搜索
export enum SearchTypes {
Single = '1',
Album = '10',
Artist = '100',
Playlist = '1000',
User = '1002',
Mv = '1004',
Lyrics = '1006',
Radio = '1009',
Video = '1014',
All = '1018',
}
export interface SearchParams {
keywords: string
limit?: number // 返回数量 , 默认为 30
offset?: number // 偏移数量,用于分页 , 如 : 如 :( 页数 -1)*30, 其中 30 为 limit 的值 , 默认为 0
type: keyof typeof SearchTypes // type: 搜索类型
}
export interface SearchResponse {
code: number
result: {
album: {
albums: Album[]
more: boolean
moreText: string
resourceIds: number[]
}
artist: {
artists: Artist[]
more: boolean
moreText: string
resourceIds: number[]
}
playList: {
playLists: Playlist[]
more: boolean
moreText: string
resourceIds: number[]
}
song: {
songs: Track[]
more: boolean
moreText: string
resourceIds: number[]
}
user: {
users: User[]
more: boolean
moreText: string
resourceIds: number[]
}
circle: unknown
new_mlog: unknown
order: string[]
rec_type: null
rec_query: null[]
sim_query: unknown
voice: unknown
voiceList: unknown
}
}
// 搜索多重匹配
export interface MultiMatchSearchParams {
keywords: string
}
export interface MultiMatchSearchResponse {
code: number
result: {
album: Album[]
artist: Artist[]
playlist: Playlist[]
orpheus: unknown
orders: Array<'artist' | 'album'>
}
}

View file

@ -0,0 +1,104 @@
export enum TrackApiNames {
FetchTracks = 'fetchTracks',
FetchAudioSource = 'fetchAudioSource',
FetchLyric = 'fetchLyric',
}
// 获取歌曲详情
export interface FetchTracksParams {
ids: number[]
}
export interface FetchTracksResponse {
code: number
songs: Track[]
privileges: {
[key: string]: unknown
}
}
// 获取音源URL
export interface FetchAudioSourceParams {
id: number
br?: number // bitrate, default 999000320000 = 320kbps
}
export interface FetchAudioSourceResponse {
code: number
data: {
br: number
canExtend: boolean
code: number
encodeType: 'mp3' | null
expi: number
fee: number
flag: number
freeTimeTrialPrivilege: {
[key: string]: unknown
}
freeTrialPrivilege: {
[key: string]: unknown
}
freeTrialInfo: null
gain: number
id: number
level: 'standard' | 'null'
md5: string | null
payed: number
size: number
type: 'mp3' | null
uf: null
url: string | null
urlSource: number
}[]
}
// 获取歌词
export interface FetchLyricParams {
id: number
}
export interface FetchLyricResponse {
code: number
sgc: boolean
sfy: boolean
qfy: boolean
lyricUser?: {
id: number
status: number
demand: number
userid: number
nickname: string
uptime: number
}
transUser?: {
id: number
status: number
demand: number
userid: number
nickname: string
uptime: number
}
lrc: {
version: number
lyric: string
}
klyric?: {
version: number
lyric: string
}
tlyric?: {
version: number
lyric: string
}
}
// 收藏歌曲
export interface LikeATrackParams {
id: number
like: boolean
}
export interface LikeATrackResponse {
code: number
playlistId: number
songs: Track[]
}

108
packages/shared/api/User.ts Normal file
View file

@ -0,0 +1,108 @@
export enum UserApiNames {
FetchUserAccount = 'fetchUserAccount',
FetchUserLikedTracksIds = 'fetchUserLikedTracksIDs',
FetchUserPlaylists = 'fetchUserPlaylists',
FetchUserAlbums = 'fetchUserAlbums',
FetchUserArtist = 'fetchUserArtists',
}
// 获取账号详情
export interface FetchUserAccountResponse {
code: number
account: {
anonimousUser: boolean
ban: number
baoyueVersion: number
createTime: number
donateVersion: number
id: number
paidFee: boolean
status: number
tokenVersion: number
type: number
userName: string
vipType: number
whitelistAuthority: number
} | null
profile: {
userId: number
userType: number
nickname: string
avatarImgId: number
avatarUrl: string
backgroundImgId: number
backgroundUrl: string
signature: string
createTime: number
userName: string
accountType: number
shortUserName: string
birthday: number
authority: number
gender: number
accountStatus: number
province: number
city: number
authStatus: number
description: string | null
detailDescription: string | null
defaultAvatar: boolean
expertTags: [] | null
experts: [] | null
djStatus: number
locationStatus: number
vipType: number
followed: boolean
mutual: boolean
authenticated: boolean
lastLoginTime: number
lastLoginIP: string
remarkName: string | null
viptypeVersion: number
authenticationTypes: number
avatarDetail: string | null
anchor: boolean
} | null
}
// 获取用户歌单
export interface FetchUserPlaylistsParams {
uid: number
offset: number
limit?: number // default 30
}
export interface FetchUserPlaylistsResponse {
code: number
more: boolean
version: string
playlist: Playlist[]
}
export interface FetchUserLikedTracksIDsParams {
uid: number
}
export interface FetchUserLikedTracksIDsResponse {
code: number
checkPoint: number
ids: number[]
}
export interface FetchUserAlbumsParams {
offset?: number // default 0
limit?: number // default 25
}
export interface FetchUserAlbumsResponse {
code: number
hasMore: boolean
paidCount: number
count: number
data: Album[]
}
// 获取收藏的歌手
export interface FetchUserArtistsResponse {
code: number
hasMore: boolean
count: number
data: Artist[]
}

207
packages/shared/interface.d.ts vendored Normal file
View file

@ -0,0 +1,207 @@
declare interface Playlist {
id: number
name: string
highQuality: boolean
playCount: number
trackCount: number
trackNumberUpdateTime: number
// 非必有
adType?: number
alg?: string
anonimous?: boolean
artists?: Artist[]
backgroundCoverId?: number
backgroundCoverUrl?: string | null
creator: User
canDislike?: boolean
cloudTrackCount?: number
commentThreadId?: string
copywriter?: string
coverImgId_str?: string
coverImgId?: number
coverImgUrl?: string
createTime?: number
description?: string | null
englishTitle?: string | null
historySharedUsers: null
newImported?: boolean
officialPlaylistType: null
opRecommend?: boolean
ordered?: boolean
picUrl?: string
privacy?: number
recommendInfo?: null
remixVideo?: null
sharedUsers?: null
shareStatus?: null
shareCount?: number
specialType?: number
status?: number
subscribed?: boolean
subscribedCount?: number
subscribers?: []
tags?: []
titleImage?: number
titleImageUrl?: string | null
totalDuration?: number
trackIds?: {
alg: null
at: number
id: number
rcmdReason: string
t: number
uid: number
v: number
}[]
trackUpdateTime?: number
tracks?: Track[]
type?: number
updateFrequency?: null
updateTime?: number
userId?: number
videoIds: null // TODO: unknown type
videos?: null
}
declare interface Track {
id: number
a: null
al: Album
alia: string[]
ar: Artist[]
cd: string
cf?: string
copyright: number
cp: number
crbt: null
djId: number
dt: number
fee: number
ftype: number
[key in ('h' | 'm' | 'l')]: {
br: number
fid: number
size: number
vd: number
}
mark: number
mst: number
mv: number
name: string
no: number
noCopyrightRcmd: null
originCoverType: number
originSongSimpleData: null
pop: number
pst: number
publishTime: number
resourceState: boolean
rt: string
rtUrl: string | null
rtUrls: (string | null)[]
rtType: number
rurl: null
s_id: number
single: number
songJumpInfo: null
st: number
t: number
tagPicList: null
v: number
version: number
tns: (string | null)[]
}
declare interface Artist {
alias: unknown[]
id: number
name: string
tns: string[]
picUrl: string
albumSize: number
picId: string
img1v1Url: string
accountId: number
img1v1: number
identityIconUrl: string
mvSize: number
followed: boolean
alg: string
trans: unknown
cover?: string
musicSize?: number
img1v1Id?: number
topicPerson?: number
briefDesc?: string
publishTime?: number
picId_str?: string
img1v1Id_str?: string
occupation?: string
}
declare interface Album {
alias: unknown[]
artist: Artist
artists: Artist[]
blurPicUrl: string
briefDesc: string
commentThreadId: string
company: string
companyId: string
copyrightId: number
description: string
id: number
info: {
commentThread: unknown
}
mark: number
name: string
onSale: boolean
paid: boolean
pic_str: string
pic: number
picId_str: string
picId: number
picUrl: string
publishTime: number
size: number
songs: Track[]
status: number
subType: string
tags: string
tns: unknown[]
type: '专辑' | 'Single' | 'EP/Single' | 'EP' | '精选集'
}
declare interface User {
defaultAvatar: boolean
province: number
authStatus: number
followed: boolean
avatarUrl: string
accountStatus: number
gender: number
city: number
birthday: number
userId: number
userType: number
nickname: string
signature: string
description: string
detailDescription: string
avatarImgId: number
backgroundImgId: number
backgroundUrl: string
authority: number
mutual: boolean
expertTags: null
experts: null
djStatus: number
vipType: number
remarkName: null
authenticationTypes: number
avatarDetail: null
avatarImgIdStr: string
backgroundImgIdStr: string
anchor: boolean
avatarImgId_str: string
}

View file

@ -0,0 +1,5 @@
export enum RepeatMode {
Off = 'off',
On = 'on',
One = 'one',
}

46
packages/shared/store.ts Normal file
View file

@ -0,0 +1,46 @@
export interface Store {
uiStates: {
loginPhoneCountryCode: string
showLyricPanel: boolean
}
settings: {
showSidebar: boolean
accentColor: string
unm: {
enabled: boolean
sources: Array<
'migu' | 'kuwo' | 'kugou' | 'ytdl' | 'qq' | 'bilibili' | 'joox'
>
searchMode: 'order-first' | 'fast-first'
proxy: null | {
protocol: 'http' | 'https' | 'socks5'
host: string
port: number
username?: string
password?: string
}
cookies: {
qq?: string
joox?: string
}
}
}
}
export const initialState: Store = {
uiStates: {
loginPhoneCountryCode: '+86',
showLyricPanel: false,
},
settings: {
showSidebar: true,
accentColor: 'blue',
unm: {
enabled: true,
sources: ['migu'],
searchMode: 'order-first',
proxy: null,
cookies: {},
},
},
}

View file

@ -0,0 +1,19 @@
{
"compilerOptions": {
"target": "ESNext",
"module": "ESNext",
"allowJs": true,
"skipLibCheck": true,
"skipDefaultLibCheck": true,
"esModuleInterop": true,
"moduleResolution": "Node",
"resolveJsonModule": true,
"strict": true,
"jsx": "react-jsx",
"baseUrl": "./",
"paths": {
"@/*": ["../*"]
}
},
"include": ["./**/*.ts"]
}