feat: 支持编辑器配置,收藏歌曲显示

This commit is contained in:
sealday 2024-04-06 23:07:01 +08:00
parent 35695714ac
commit 64392b307b
3 changed files with 48 additions and 29 deletions

16
.editorconfig Normal file
View File

@ -0,0 +1,16 @@
# http://editorconfig.org
root = true
[*]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
[*.md]
trim_trailing_whitespace = false
[Makefile]
indent_style = tab

View File

@ -57,6 +57,20 @@ export async function addSong(
return result?.data; return result?.data;
} }
export async function listSongs() { export async function listSongs(): Promise<any[]> {
const token = cookies().get("token");
const params = new URLSearchParams();
params.append('pageSize', '99999');
params.append('filter', JSON.stringify({"$and":[{"createdBy":{"id":{"$eq":"{{$user.id}}"}}}]}))
const songs = await fetch("https://tachy.daoyoucloud.com/api/songs:list?" + params.toString(), {
method: "GET",
headers: {
"X-App": "danmu-sim",
"X-Authenticator": "basic",
authorization: "Bearer " + token?.value,
"content-type": "application/json",
},
});
const result = await songs.json();
return result?.data ?? [];
} }

View File

@ -1,6 +1,8 @@
import { listSongs } from "./actions";
import SearchForm from "./search-form"; import SearchForm from "./search-form";
export default function Page() { export default async function Page() {
const songs = await listSongs();
return ( return (
<section className="bg-gray-100"> <section className="bg-gray-100">
<div className="container mx-auto px-4 py-8"> <div className="container mx-auto px-4 py-8">
@ -8,38 +10,25 @@ export default function Page() {
<div> <div>
<h2 className="text-xl font-bold mb-4"></h2> <h2 className="text-xl font-bold mb-4"></h2>
<ul className="bg-white rounded shadow-md p-4"> <ul className="bg-white rounded shadow-md p-4">
<li className="flex justify-between items-center py-2 border-b"> {songs.map((song, i) => (
<span> - </span> <li
<button className="text-red-500 hover:text-red-700"> className="flex justify-between items-center py-2 border-b"
key={i}
</button> >
</li> <span>
<li className="flex justify-between items-center py-2 border-b"> {song.name} - {song.artist}
<span> - </span> </span>
<button className="text-red-500 hover:text-red-700"> <button className="text-red-500 hover:text-red-700">
</button> </button>
</li> </li>
))}
</ul> </ul>
</div> </div>
<div> <div>
<h2 className="text-xl font-bold mb-4"></h2> <h2 className="text-xl font-bold mb-4"></h2>
<SearchForm className="mb-4" /> <SearchForm className="mb-4" />
{/* <div className="bg-white rounded shadow-md p-4">
<div className="flex justify-between items-center py-2 border-b">
<span>Song 3</span>
<button className="text-green-500 hover:text-green-700">
Add
</button>
</div>
<div className="flex justify-between items-center py-2 border-b">
<span>Song 4</span>
<button className="text-green-500 hover:text-green-700">
Add
</button>
</div>
</div> */}
</div> </div>
</div> </div>
</div> </div>