diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..3331d70 --- /dev/null +++ b/.editorconfig @@ -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 \ No newline at end of file diff --git a/app/songs/actions.tsx b/app/songs/actions.tsx index d76d9bf..aa54888 100644 --- a/app/songs/actions.tsx +++ b/app/songs/actions.tsx @@ -57,6 +57,20 @@ export async function addSong( return result?.data; } -export async function listSongs() { - -} \ No newline at end of file +export async function listSongs(): Promise { + 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 ?? []; +} diff --git a/app/songs/page.tsx b/app/songs/page.tsx index 839defe..e8e8463 100644 --- a/app/songs/page.tsx +++ b/app/songs/page.tsx @@ -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 (
@@ -8,38 +10,25 @@ export default function Page() {

已收藏

    -
  • - 冬天的秘密 - 周传雄 - -
  • -
  • - 其实都没有 - 张盼盼 - -
  • + + + ))}

搜索

- {/*
-
- Song 3 - -
-
- Song 4 - -
-
*/}