From 64392b307b6951fc17ed9f58938e8da06cb657b9 Mon Sep 17 00:00:00 2001 From: sealday Date: Sat, 6 Apr 2024 23:07:01 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=94=AF=E6=8C=81=E7=BC=96=E8=BE=91?= =?UTF-8?q?=E5=99=A8=E9=85=8D=E7=BD=AE=EF=BC=8C=E6=94=B6=E8=97=8F=E6=AD=8C?= =?UTF-8?q?=E6=9B=B2=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .editorconfig | 16 ++++++++++++++++ app/songs/actions.tsx | 20 +++++++++++++++++--- app/songs/page.tsx | 41 +++++++++++++++-------------------------- 3 files changed, 48 insertions(+), 29 deletions(-) create mode 100644 .editorconfig 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 - -
-
*/}