@ -21,7 +21,7 @@ Vue.createApp({
showModalDelete : false ,
showModalShare : false ,
// eslint-disable-next-line no-undef
shareLink : ` ${ protocol } // ${ host } /collection/ ${ userId } ` ,
shareLink : ` /collection/ ${ userId } ` ,
// eslint-disable-next-line no-undef
isPublicCollection ,
// eslint-disable-next-line no-undef
@ -32,6 +32,9 @@ Vue.createApp({
this . fetch ( ) ;
} ,
methods : {
formatParams ( param ) {
return param . replace ( "&" , "%26" ) . replace ( "+" , "%2B" ) ;
} ,
fetch ( ) {
this . loading = true ;
this . total = 0 ;
@ -64,19 +67,19 @@ Vue.createApp({
let url = ` /api/v1/albums?page= ${ this . page } &limit= ${ this . limit } &sort= ${ this . sort } &order= ${ this . order } ` ;
if ( this . artist ) {
url += ` &artist s_sort=${ this . artist . replace ( "&" , "%26" ) } ` ;
url += ` &artist =${ this . formatParams ( this . artist ) } ` ;
}
if ( this . format ) {
url += ` &format= ${ this . format . replace ( "&" , "%26" ) } ` ;
url += ` &format= ${ this . format Params( this . format ) } ` ;
}
if ( this . year ) {
url += ` &year= ${ this . year } ` ;
}
if ( this . genre ) {
url += ` &genre= ${ this . genre. replace ( "&" , "%26" ) } ` ;
url += ` &genre= ${ this . formatParams( this . genre ) } ` ;
}
if ( this . style ) {
url += ` &style= ${ this . style. replace ( "&" , "%26" ) } ` ;
url += ` &style= ${ this . formatParams( this . style ) } ` ;
}
axios
@ -101,19 +104,19 @@ Vue.createApp({
changeUrl ( ) {
let url = ` ?page= ${ this . page } &limit= ${ this . limit } &sort= ${ this . sort } &order= ${ this . order } ` ;
if ( this . artist ) {
url += ` &artists_sort= ${ this . artist. replace ( "&" , "%26" ) } ` ;
url += ` &artists_sort= ${ this . formatParams( this . artist ) } ` ;
}
if ( this . format ) {
url += ` &format= ${ this . format . replace ( "&" , "%26" ) } ` ;
url += ` &format= ${ this . format Params( this . format ) } ` ;
}
if ( this . year ) {
url += ` &year= ${ this . year } ` ;
}
if ( this . genre ) {
url += ` &genre= ${ this . genre. replace ( "&" , "%26" ) } ` ;
url += ` &genre= ${ this . formatParams( this . genre ) } ` ;
}
if ( this . style ) {
url += ` &style= ${ this . style. replace ( "&" , "%26" ) } ` ;
url += ` &style= ${ this . formatParams( this . style ) } ` ;
}
window . location . href = url ;
@ -215,5 +218,20 @@ Vue.createApp({
this . toggleModalShare ( ) ;
} ) ;
} ,
renderAlbumTitle ( item ) {
let render = '' ;
for ( let i = 0 ; i < item . artists . length ; i += 1 ) {
const {
name ,
join ,
} = item . artists [ i ] ;
render += ` ${ name } ${ join ? ` ${ join } ` : '' } ` ;
}
render += ` - ${ item . title } ` ;
return render ;
}
} ,
} ) . mount ( "#collection" ) ;