File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ import { songDetail } from "@/api/song" ;
2+ import { formatSongsList } from "@/utils/format" ;
3+ import { usePlayer } from "@/utils/player" ;
4+
15class OrpheusData {
2- constructor ( type : string , id : string , cmd : string ) {
6+ constructor ( type : string , id : number , cmd : string ) {
37 this . type = type ;
48 this . id = id ;
59 this . cmd = cmd ;
610 }
711
8- type : string = "" ;
9- id : string = "" ;
10- cmd : string = "" ;
12+ type : string ;
13+ id : number ;
14+ cmd : string ;
1115}
1216
1317export const handleProtocolUrl = ( url : string ) => {
@@ -22,12 +26,19 @@ export const handleProtocolUrl = (url: string) => {
2226
2327
2428
25- export const handleOpenOrpheus = ( url : string ) => {
29+ export const handleOpenOrpheus = async ( url : string ) => {
2630 const data = parseOrpheus ( url ) ;
2731 if ( ! data ) return ;
2832 console . log ( "🚀 Open Orpheus:" , data ) ;
2933
30- // TODO 处理
34+ if ( data . cmd === "play" && data . type === "song" ) {
35+ const player = usePlayer ( ) ;
36+ const result = await songDetail ( data . id ) ;
37+ const song = formatSongsList ( result . songs ) [ 0 ] ;
38+ player . addNextSong ( song , true ) ;
39+ } else {
40+ console . log ( "❌ Unsupported Command or Type:" , data ) ;
41+ }
3142} ;
3243
3344const parseOrpheus = ( url : string ) : OrpheusData | undefined => {
You can’t perform that action at this time.
0 commit comments