feat: 支持编辑器配置,收藏歌曲显示
This commit is contained in:
parent
35695714ac
commit
64392b307b
16
.editorconfig
Normal file
16
.editorconfig
Normal 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
|
@ -57,6 +57,20 @@ export async function addSong(
|
||||
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 ?? [];
|
||||
}
|
@ -1,6 +1,8 @@
|
||||
import { listSongs } from "./actions";
|
||||
import SearchForm from "./search-form";
|
||||
|
||||
export default function Page() {
|
||||
export default async function Page() {
|
||||
const songs = await listSongs();
|
||||
return (
|
||||
<section className="bg-gray-100">
|
||||
<div className="container mx-auto px-4 py-8">
|
||||
@ -8,38 +10,25 @@ export default function Page() {
|
||||
<div>
|
||||
<h2 className="text-xl font-bold mb-4">已收藏</h2>
|
||||
<ul className="bg-white rounded shadow-md p-4">
|
||||
<li className="flex justify-between items-center py-2 border-b">
|
||||
<span>冬天的秘密 - 周传雄</span>
|
||||
<button className="text-red-500 hover:text-red-700">
|
||||
删除
|
||||
</button>
|
||||
</li>
|
||||
<li className="flex justify-between items-center py-2 border-b">
|
||||
<span>其实都没有 - 张盼盼</span>
|
||||
{songs.map((song, i) => (
|
||||
<li
|
||||
className="flex justify-between items-center py-2 border-b"
|
||||
key={i}
|
||||
>
|
||||
<span>
|
||||
{song.name} - {song.artist}
|
||||
</span>
|
||||
<button className="text-red-500 hover:text-red-700">
|
||||
删除
|
||||
</button>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<h2 className="text-xl font-bold mb-4">搜索</h2>
|
||||
<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>
|
||||
|
Loading…
Reference in New Issue
Block a user