mirror of
https://github.com/GiriNeko/YesPlayMusic.git
synced 2025-12-18 06:07:48 +00:00
feat: updates
This commit is contained in:
parent
884f3df41a
commit
c6c59b2cd9
84 changed files with 3531 additions and 2616 deletions
26
packages/web/api/r3play.ts
Normal file
26
packages/web/api/r3play.ts
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
import axios, { AxiosInstance } from 'axios'
|
||||
import { appName } from '../utils/const'
|
||||
|
||||
const request: AxiosInstance = axios.create({
|
||||
baseURL: `/${appName.toLowerCase()}`,
|
||||
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