mirror of
https://github.com/JuLi0n21/pwa-player.git
synced 2026-04-19 23:40:05 +00:00
update api routing me -> /me
This commit is contained in:
@@ -19,8 +19,8 @@ onMounted(async () => {
|
|||||||
console.log(data)
|
console.log(data)
|
||||||
|
|
||||||
data.songs.forEach(song => {
|
data.songs.forEach(song => {
|
||||||
song.previewimage = `${userStore.baseUrl}api/v1/images/${song.previewimage}`;
|
song.previewimage = `${userStore.baseUrl}/api/v1/images/${song.previewimage}`;
|
||||||
song.url = `${userStore.baseUrl}api/v1/audio/${song.url}`;
|
song.url = `${userStore.baseUrl}/api/v1/audio/${song.url}`;
|
||||||
});
|
});
|
||||||
|
|
||||||
name.value = data.name;
|
name.value = data.name;
|
||||||
|
|||||||
@@ -4,8 +4,8 @@ import type { Song, CollectionPreview, Me } from '@/script/types';
|
|||||||
|
|
||||||
export const useUserStore = defineStore('userStore', () => {
|
export const useUserStore = defineStore('userStore', () => {
|
||||||
const userId = ref(null)
|
const userId = ref(null)
|
||||||
const baseUrl = ref('https://service.illegalesachen.download/')
|
const baseUrl = ref('https://service.illegalesachen.download')
|
||||||
const proxyUrl = ref('https://proxy.illegalesachen.download/')
|
const proxyUrl = ref('https://proxy.illegalesachen.download')
|
||||||
|
|
||||||
const User = ref<Me | null>(null)
|
const User = ref<Me | null>(null)
|
||||||
|
|
||||||
@@ -26,7 +26,7 @@ export const useUserStore = defineStore('userStore', () => {
|
|||||||
async function fetchSong(hash: string): Promise<Song> {
|
async function fetchSong(hash: string): Promise<Song> {
|
||||||
try {
|
try {
|
||||||
|
|
||||||
const response = await fetch(`${baseUrl}api/v1/songs/${hash}`);
|
const response = await fetch(`${baseUrl}/api/v1/songs/${hash}`);
|
||||||
if (!response.ok) {
|
if (!response.ok) {
|
||||||
throw new Error(`HTTP error! status: ${response.status}`);
|
throw new Error(`HTTP error! status: ${response.status}`);
|
||||||
}
|
}
|
||||||
@@ -79,42 +79,42 @@ export const useUserStore = defineStore('userStore', () => {
|
|||||||
|
|
||||||
async function fetchCollections(offset: number, limit: number): Promise<CollectionPreview[]> {
|
async function fetchCollections(offset: number, limit: number): Promise<CollectionPreview[]> {
|
||||||
const cacheKey = `collections_cache_${offset}_${limit}`;
|
const cacheKey = `collections_cache_${offset}_${limit}`;
|
||||||
const url = `${baseUrl.value}api/v1/collections/?offset=${offset}&limit=${limit}`;
|
const url = `${baseUrl.value}/api/v1/collections/?offset=${offset}&limit=${limit}`;
|
||||||
return fetchWithCache<CollectionPreview[]>(cacheKey, url);
|
return fetchWithCache<CollectionPreview[]>(cacheKey, url);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function fetchCollection(index: number): Promise<Song[]> {
|
async function fetchCollection(index: number): Promise<Song[]> {
|
||||||
const cacheKey = `collection_${index}_cache`;
|
const cacheKey = `collection_${index}_cache`;
|
||||||
const url = `${baseUrl.value}api/v1/collection/${index}`;
|
const url = `${baseUrl.value}/api/v1/collection/${index}`;
|
||||||
return fetchWithCache<Song[]>(cacheKey, url);
|
return fetchWithCache<Song[]>(cacheKey, url);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function fetchFavorites(limit: number, offset: number): Promise<Song[]> {
|
async function fetchFavorites(limit: number, offset: number): Promise<Song[]> {
|
||||||
const cacheKey = `favorites_${limit}_${offset}_cache`;
|
const cacheKey = `favorites_${limit}_${offset}_cache`;
|
||||||
const url = `${baseUrl.value}api/v1/recent?limit=${limit}&offset=${offset}`;
|
const url = `${baseUrl.value}/api/v1/recent?limit=${limit}&offset=${offset}`;
|
||||||
return fetchWithCache<Song[]>(cacheKey, url);
|
return fetchWithCache<Song[]>(cacheKey, url);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function fetchRecent(limit: number, offset: number): Promise<Song[]> {
|
async function fetchRecent(limit: number, offset: number): Promise<Song[]> {
|
||||||
const cacheKey = `recent_${limit}_${offset}_cache`;
|
const cacheKey = `recent_${limit}_${offset}_cache`;
|
||||||
const url = `${baseUrl.value}api/v1/songs/recent?limit=${limit}&offset=${offset}`;
|
const url = `${baseUrl.value}/api/v1/songs/recent?limit=${limit}&offset=${offset}`;
|
||||||
return fetchWithCache<Song[]>(cacheKey, url);
|
return fetchWithCache<Song[]>(cacheKey, url);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function fetchActiveSearch(query: string): Promise<{}> {
|
async function fetchActiveSearch(query: string): Promise<{}> {
|
||||||
const cacheKey = `collections_activeSearch_${query}`;
|
const cacheKey = `collections_activeSearch_${query}`;
|
||||||
const url = `${baseUrl.value}api/v1/search/active?q=${query}`;
|
const url = `${baseUrl.value}/api/v1/search/active?q=${query}`;
|
||||||
return fetchWithCache(cacheKey, url);
|
return fetchWithCache(cacheKey, url);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function fetchSearchArtist(query: string): Promise<Song[]> {
|
async function fetchSearchArtist(query: string): Promise<Song[]> {
|
||||||
const cacheKey = `collections_artist_${query}`;
|
const cacheKey = `collections_artist_${query}`;
|
||||||
const url = `${baseUrl.value}api/v1/search/artist?q=${query}`;
|
const url = `${baseUrl.value}/api/v1/search/artist?q=${query}`;
|
||||||
return fetchWithCache<Song[]>(cacheKey, url);
|
return fetchWithCache<Song[]>(cacheKey, url);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function fetchMe(): Promise<Me | {}> {
|
async function fetchMe(): Promise<Me | {}> {
|
||||||
const url = `${proxyUrl.value}me`;
|
const url = `${proxyUrl.value}/me`;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const response = await fetch(url, {
|
const response = await fetch(url, {
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ const fetchCollections = async () => {
|
|||||||
|
|
||||||
const data = await userStore.fetchCollections(offset.value, limit.value);
|
const data = await userStore.fetchCollections(offset.value, limit.value);
|
||||||
data.forEach(song => {
|
data.forEach(song => {
|
||||||
song.previewimage = `${userStore.baseUrl}api/v1/images/${song.previewimage}?h=80&w=80`;
|
song.previewimage = `${userStore.baseUrl}/api/v1/images/${song.previewimage}?h=80&w=80`;
|
||||||
});
|
});
|
||||||
|
|
||||||
collections.value = [...collections.value, ...data];
|
collections.value = [...collections.value, ...data];
|
||||||
|
|||||||
@@ -87,7 +87,7 @@ function reset() {
|
|||||||
|
|
||||||
<main class="flex-1 flex flex-col overflow-scroll">
|
<main class="flex-1 flex flex-col overflow-scroll">
|
||||||
<h1> Meeeeee </h1>
|
<h1> Meeeeee </h1>
|
||||||
<input @change="update" type="text" id="url-input" :value="userStore.baseUrl" />
|
<input @change="update" type="text" id="url-input" :value="userStore.baseUrl" disabled />
|
||||||
<br>
|
<br>
|
||||||
<button v-if="!userStore.User" @click="getMe" class="border bordercolor rounded-lg p-0.5">{{ loginStatus }}</button>
|
<button v-if="!userStore.User" @click="getMe" class="border bordercolor rounded-lg p-0.5">{{ loginStatus }}</button>
|
||||||
<div v-if="userStore.User" class="flex p-5 justify-between">
|
<div v-if="userStore.User" class="flex p-5 justify-between">
|
||||||
|
|||||||
@@ -26,8 +26,8 @@ const fetchRecent = async () => {
|
|||||||
const data = await userStore.fetchRecent(limit.value, offset.value);
|
const data = await userStore.fetchRecent(limit.value, offset.value);
|
||||||
|
|
||||||
data.forEach(song => {
|
data.forEach(song => {
|
||||||
song.previewimage = `${userStore.baseUrl}api/v1/images/${song.previewimage}`;
|
song.previewimage = `${userStore.baseUrl}/api/v1/images/${song.previewimage}`;
|
||||||
song.url = `${userStore.baseUrl}api/v1/audio/${song.url}`;
|
song.url = `${userStore.baseUrl}/api/v1/audio/${song.url}`;
|
||||||
});
|
});
|
||||||
|
|
||||||
offset.value += limit.value;
|
offset.value += limit.value;
|
||||||
|
|||||||
@@ -34,8 +34,8 @@ onMounted(async () => {
|
|||||||
searchTerm.value = target.value
|
searchTerm.value = target.value
|
||||||
|
|
||||||
data.songs.forEach(song => {
|
data.songs.forEach(song => {
|
||||||
song.previewimage = `${userStore.baseUrl}api/v1/images/${song.previewimage}`;
|
song.previewimage = `${userStore.baseUrl}/api/v1/images/${song.previewimage}`;
|
||||||
song.url = `${userStore.baseUrl}api/v1/audio/${song.url}`;
|
song.url = `${userStore.baseUrl}/api/v1/audio/${song.url}`;
|
||||||
});
|
});
|
||||||
|
|
||||||
activesongs.value = data.songs;
|
activesongs.value = data.songs;
|
||||||
@@ -73,8 +73,8 @@ async function loadartistifexist() {
|
|||||||
console.log(data);
|
console.log(data);
|
||||||
|
|
||||||
data.forEach(song => {
|
data.forEach(song => {
|
||||||
song.previewimage = `${userStore.baseUrl}api/v1/images/${song.previewimage}`;
|
song.previewimage = `${userStore.baseUrl}/api/v1/images/${song.previewimage}`;
|
||||||
song.url = `${userStore.baseUrl}api/v1/audio/${song.url}`;
|
song.url = `${userStore.baseUrl}/api/v1/audio/${song.url}`;
|
||||||
});
|
});
|
||||||
|
|
||||||
songs.value = data;
|
songs.value = data;
|
||||||
|
|||||||
Reference in New Issue
Block a user