-
Notifications
You must be signed in to change notification settings - Fork 121
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
224 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import 'server-only' | ||
import { fetchAListInfo } from '~/server/lib/query' | ||
|
||
export async function GET() { | ||
const data = await fetchAListInfo(); | ||
return Response.json(data) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import 'server-only' | ||
import { fetchS3Info } from '~/server/lib/query' | ||
|
||
export async function GET() { | ||
const data = await fetchS3Info(); | ||
return Response.json(data) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
'use client' | ||
|
||
import { Table, TableHeader, TableColumn, TableBody, TableRow, TableCell, Skeleton, Card, CardHeader, Button } from '@nextui-org/react' | ||
import useSWR from 'swr' | ||
import { fetcher } from '~/utils/fetcher' | ||
import { toast } from 'sonner' | ||
|
||
export default function AListTabs() { | ||
const { data, error, isLoading } = useSWR('/api/alist-info', fetcher) | ||
|
||
if (error) { | ||
toast.error('请求失败!') | ||
} | ||
|
||
return ( | ||
<div className="space-y-2"> | ||
<Card> | ||
<CardHeader className="justify-between"> | ||
<div className="flex gap-5"> | ||
<div className="flex flex-col gap-1 items-start justify-center"> | ||
<h4 className="text-small font-semibold leading-none text-default-600">AList 配置信息</h4> | ||
</div> | ||
</div> | ||
<Button | ||
color="primary" | ||
variant="light" | ||
radius="full" | ||
onClick={() => toast.info('还没写')} | ||
> | ||
编辑 | ||
</Button> | ||
</CardHeader> | ||
</ Card> | ||
{ | ||
!isLoading && data ? | ||
<Table aria-label="S3 设置"> | ||
<TableHeader> | ||
<TableColumn>Key</TableColumn> | ||
<TableColumn>Value</TableColumn> | ||
</TableHeader> | ||
<TableBody emptyContent={"No rows to display."}> | ||
{ | ||
data.map((item: any) => ( | ||
<TableRow key={item.id}> | ||
<TableCell>{item.config_key}</TableCell> | ||
<TableCell>{item.config_value || 'N&A'}</TableCell> | ||
</TableRow> | ||
)) | ||
} | ||
</TableBody> | ||
</Table> | ||
: | ||
<div className="w-full p-2 space-y-4"> | ||
<Skeleton className="w-full rounded-md"> | ||
<div className="h-4 w-full rounded-md bg-white"></div> | ||
</Skeleton> | ||
<Skeleton className="w-full rounded-md"> | ||
<div className="h-4 w-full rounded-md bg-white"></div> | ||
</Skeleton> | ||
<Skeleton className="w-full rounded-md"> | ||
<div className="h-4 w-full rounded-md bg-white"></div> | ||
</Skeleton> | ||
</div> | ||
} | ||
</div> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
'use client' | ||
|
||
import { Table, TableHeader, TableColumn, TableBody, TableRow, TableCell, Skeleton, Card, CardHeader, Button } from '@nextui-org/react' | ||
import useSWR from 'swr' | ||
import { fetcher } from '~/utils/fetcher' | ||
import { toast } from 'sonner' | ||
|
||
export default function S3Tabs() { | ||
const { data, error, isLoading } = useSWR('/api/s3-info', fetcher) | ||
|
||
if (error) { | ||
toast.error('请求失败!') | ||
} | ||
|
||
return ( | ||
<div className="space-y-2"> | ||
<Card> | ||
<CardHeader className="justify-between"> | ||
<div className="flex gap-5"> | ||
<div className="flex flex-col gap-1 items-start justify-center"> | ||
<h4 className="text-small font-semibold leading-none text-default-600">S3 配置信息</h4> | ||
</div> | ||
</div> | ||
<Button | ||
color="primary" | ||
variant="light" | ||
radius="full" | ||
onClick={() => toast.info('还没写')} | ||
> | ||
编辑 | ||
</Button> | ||
</CardHeader> | ||
</ Card> | ||
{ | ||
!isLoading && data ? | ||
<Table aria-label="S3 设置"> | ||
<TableHeader> | ||
<TableColumn>Key</TableColumn> | ||
<TableColumn>Value</TableColumn> | ||
</TableHeader> | ||
<TableBody emptyContent={"No rows to display."}> | ||
{ | ||
data.map((item: any) => ( | ||
<TableRow key={item.id}> | ||
<TableCell>{item.config_key}</TableCell> | ||
<TableCell>{item.config_value || 'N&A'}</TableCell> | ||
</TableRow> | ||
)) | ||
} | ||
</TableBody> | ||
</Table> | ||
: | ||
<div className="w-full p-2 space-y-4"> | ||
<Skeleton className="w-full rounded-md"> | ||
<div className="h-4 w-full rounded-md bg-white"></div> | ||
</Skeleton> | ||
<Skeleton className="w-full rounded-md"> | ||
<div className="h-4 w-full rounded-md bg-white"></div> | ||
</Skeleton> | ||
<Skeleton className="w-full rounded-md"> | ||
<div className="h-4 w-full rounded-md bg-white"></div> | ||
</Skeleton> | ||
</div> | ||
} | ||
</div> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
'use client' | ||
|
||
import { Card, CardHeader, Button } from '@nextui-org/react' | ||
import { toast } from 'sonner' | ||
|
||
export default function SettingsTab() { | ||
return ( | ||
<div className="space-y-2"> | ||
<Card> | ||
<CardHeader className="justify-between"> | ||
<div className="flex gap-5"> | ||
<div className="flex flex-col gap-1 items-start justify-center"> | ||
<h4 className="text-small font-semibold leading-none text-default-600">系统设置</h4> | ||
</div> | ||
</div> | ||
</CardHeader> | ||
</ Card> | ||
</div> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
'use server' | ||
|
||
import { db } from '~/server/lib/db' | ||
|
||
export async function fetchS3Info() { | ||
const findConfig = await db.configs.findMany({ | ||
where: { | ||
config_key: { | ||
in: [ | ||
'accesskey_id', | ||
'accesskey_secret', | ||
'region', | ||
'endpoint', | ||
'bucket', | ||
'storage_folder', | ||
'cdn_url' | ||
] | ||
} | ||
}, | ||
select: { | ||
id: true, | ||
config_key: true, | ||
config_value: true | ||
} | ||
}) | ||
|
||
return findConfig; | ||
} | ||
|
||
export async function fetchAListInfo() { | ||
const findConfig = await db.configs.findMany({ | ||
where: { | ||
config_key: { | ||
in: [ | ||
'alist_url', | ||
'alist_token' | ||
] | ||
} | ||
}, | ||
select: { | ||
id: true, | ||
config_key: true, | ||
config_value: true | ||
} | ||
}) | ||
|
||
return findConfig; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export const fetcher = (url: string) => fetch(url).then((res) => res.json()); |