first commit
This commit is contained in:
17
frontend/src/config/neteasePlayer.ts
Normal file
17
frontend/src/config/neteasePlayer.ts
Normal file
@@ -0,0 +1,17 @@
|
||||
/**
|
||||
* 网易云外链播放器:在前端配置,不经过 Django。
|
||||
*
|
||||
* 在 `frontend/.env` / `.env.development` 中设置:
|
||||
* VITE_NETEASE_PLAYER_SRC=https://music.163.com/outchain/player?type=2&id=…&auto=1&height=66
|
||||
* 也可粘贴整段 `<iframe … src="…">`,会自动取出 src。
|
||||
*/
|
||||
function extractIframeSrc(raw: string): string {
|
||||
const t = raw.trim()
|
||||
if (!t) return ''
|
||||
const m = /\bsrc\s*=\s*["']([^"']+)["']/i.exec(t)
|
||||
return (m ? m[1] : t).trim()
|
||||
}
|
||||
|
||||
const fromEnv = (import.meta.env.VITE_NETEASE_PLAYER_SRC as string | undefined)?.trim() ?? ''
|
||||
|
||||
export const NETEASE_PLAYER_SRC = extractIframeSrc(fromEnv)
|
||||
Reference in New Issue
Block a user