mirror of
https://github.com/GiriNeko/YesPlayMusic.git
synced 2025-12-17 05:38:04 +00:00
feat: monorepo
This commit is contained in:
parent
4d54060a4f
commit
42089d4996
200 changed files with 1530 additions and 1521 deletions
29
packages/web/api/yesplaymusic.ts
Normal file
29
packages/web/api/yesplaymusic.ts
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
import axios, { AxiosInstance } from 'axios'
|
||||
|
||||
const baseURL = String(
|
||||
import.meta.env.DEV ? '/yesplaymusic' : `http://127.0.0.1:42710/yesplaymusic`
|
||||
)
|
||||
|
||||
const request: AxiosInstance = axios.create({
|
||||
baseURL,
|
||||
withCredentials: true,
|
||||
timeout: 15000,
|
||||
})
|
||||
|
||||
export async function cacheAudio(id: number, audio: string) {
|
||||
const file = await axios.get(audio, { responseType: 'arraybuffer' })
|
||||
if (file.status !== 200 && file.status !== 206) return
|
||||
|
||||
const formData = new FormData()
|
||||
const blob = new Blob([file.data], { type: 'multipart/form-data' })
|
||||
formData.append('file', blob)
|
||||
|
||||
request.post(`/audio/${id}`, formData, {
|
||||
headers: {
|
||||
'Content-Type': 'multipart/form-data',
|
||||
},
|
||||
params: {
|
||||
url: audio,
|
||||
},
|
||||
})
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue