-
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
5 changed files
with
296 additions
and
34 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,126 @@ | ||
import { Card, CardBody } from '@nextui-org/card' | ||
'use client' | ||
|
||
import React from 'react' | ||
import { Card, CardHeader } from '@nextui-org/card' | ||
import { Button, Dropdown, DropdownItem, DropdownMenu, DropdownTrigger } from '@nextui-org/react' | ||
import { Table } from 'antd' | ||
import type { TableProps } from 'antd' | ||
import useSWR from 'swr' | ||
import { fetcher } from '~/utils/fetcher' | ||
import { toast } from 'sonner' | ||
import { DeleteDocumentBulkIcon, EditDocumentBulkIcon, SendFilledIcon, LinkIcon } from '@nextui-org/shared-icons' | ||
|
||
interface DataType { | ||
id: number; | ||
tag: string; | ||
url: string; | ||
exif: any; | ||
rating: number; | ||
detail: string; | ||
show: number; | ||
sort: number; | ||
} | ||
|
||
const iconClasses = 'text-xl text-default-500 pointer-events-none flex-shrink-0' | ||
|
||
const columns: TableProps<DataType>['columns'] = [ | ||
{ | ||
title: '标签', | ||
dataIndex: 'tag', | ||
}, | ||
{ | ||
title: '评分', | ||
dataIndex: 'rating', | ||
}, | ||
{ | ||
title: '说明', | ||
dataIndex: 'detail', | ||
}, | ||
{ | ||
title: '显示', | ||
dataIndex: 'show', | ||
}, | ||
{ | ||
title: '排序', | ||
dataIndex: 'sort', | ||
}, | ||
{ | ||
title: '操作', | ||
key: 'action', | ||
render: (_, record) => ( | ||
<Dropdown> | ||
<DropdownTrigger> | ||
<Button | ||
isIconOnly | ||
variant="bordered" | ||
> | ||
<SendFilledIcon /> | ||
</Button> | ||
</DropdownTrigger> | ||
<DropdownMenu variant="faded" aria-label="图片操作选项卡"> | ||
<DropdownItem | ||
key="edit" | ||
description="编辑图片信息" | ||
startContent={<EditDocumentBulkIcon className={iconClasses} />} | ||
onClick={() => toast.warning('还没写!')} | ||
> | ||
编辑 | ||
</DropdownItem> | ||
<DropdownItem | ||
key="edit" | ||
description="同步图片地址" | ||
startContent={<LinkIcon className={iconClasses} />} | ||
onClick={() => toast.warning('还没写!')} | ||
> | ||
同步 | ||
</DropdownItem> | ||
<DropdownItem | ||
key="delete" | ||
description="删除图片" | ||
startContent={<DeleteDocumentBulkIcon className={iconClasses + ' text-red-500'} />} | ||
onClick={() => toast.warning('还没写!')} | ||
> | ||
删除 | ||
</DropdownItem> | ||
</DropdownMenu> | ||
</Dropdown> | ||
), | ||
}, | ||
]; | ||
|
||
export default async function List() { | ||
const { data, error, isLoading, isValidating, mutate } = useSWR('/api/get-images', fetcher) | ||
|
||
if (error) { | ||
toast.error('数据获取失败!') | ||
} | ||
|
||
return ( | ||
<div className="flex flex-col space-y-2 h-full flex-1"> | ||
<Card> | ||
<CardBody> | ||
<p> | ||
图片维护 | ||
</p> | ||
</CardBody> | ||
</Card> | ||
<Card className="flex-1"> | ||
<CardBody> | ||
<p> | ||
图片维护页面 | ||
</p> | ||
</CardBody> | ||
<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 select-none">标签管理</h4> | ||
</div> | ||
</div> | ||
<Button | ||
color="primary" | ||
radius="full" | ||
size="sm" | ||
isLoading={isValidating} | ||
onClick={() => mutate()} | ||
> | ||
刷新 | ||
</Button> | ||
</CardHeader> | ||
</Card> | ||
<Table | ||
bordered | ||
columns={columns} | ||
dataSource={data} | ||
loading={isValidating} | ||
/> | ||
</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 |
---|---|---|
@@ -1,22 +1,111 @@ | ||
import { Card, CardBody } from '@nextui-org/card' | ||
'use client' | ||
|
||
import React from 'react' | ||
import { Card, CardHeader } from '@nextui-org/card' | ||
import { Button, Dropdown, DropdownItem, DropdownMenu, DropdownTrigger } from '@nextui-org/react' | ||
import { Table } from 'antd' | ||
import type { TableProps } from 'antd' | ||
import useSWR from 'swr' | ||
import { fetcher } from '~/utils/fetcher' | ||
import { toast } from 'sonner' | ||
import { DeleteDocumentBulkIcon, EditDocumentBulkIcon, SendFilledIcon } from '@nextui-org/shared-icons' | ||
|
||
interface DataType { | ||
id: number; | ||
name: string; | ||
tag_value: string; | ||
detail: string; | ||
show: number; | ||
} | ||
|
||
const iconClasses = 'text-xl text-default-500 pointer-events-none flex-shrink-0' | ||
|
||
const columns: TableProps<DataType>['columns'] = [ | ||
{ | ||
title: '标签名称', | ||
dataIndex: 'name', | ||
}, | ||
{ | ||
title: '标签值', | ||
dataIndex: 'tag_value', | ||
}, | ||
{ | ||
title: '说明', | ||
dataIndex: 'detail', | ||
}, | ||
{ | ||
title: '显示', | ||
dataIndex: 'show', | ||
}, | ||
{ | ||
title: '操作', | ||
key: 'action', | ||
render: (_, record) => ( | ||
<Dropdown> | ||
<DropdownTrigger> | ||
<Button | ||
isIconOnly | ||
variant="bordered" | ||
> | ||
<SendFilledIcon /> | ||
</Button> | ||
</DropdownTrigger> | ||
<DropdownMenu variant="faded" aria-label="标签操作选项卡"> | ||
<DropdownItem | ||
key="edit" | ||
description="编辑标签信息" | ||
startContent={<EditDocumentBulkIcon className={iconClasses} />} | ||
onClick={() => toast.warning('还没写!')} | ||
> | ||
编辑 | ||
</DropdownItem> | ||
<DropdownItem | ||
key="delete" | ||
description="删除标签" | ||
startContent={<DeleteDocumentBulkIcon className={iconClasses + ' text-red-500'} />} | ||
onClick={() => toast.warning('还没写!')} | ||
> | ||
删除 | ||
</DropdownItem> | ||
</DropdownMenu> | ||
</Dropdown> | ||
), | ||
}, | ||
]; | ||
|
||
export default function List(callback: any, deps: React.DependencyList) { | ||
const { data, error, isLoading, isValidating, mutate } = useSWR('/api/get-tags', fetcher) | ||
|
||
if (error) { | ||
toast.error('数据获取失败!') | ||
} | ||
|
||
export default async function List() { | ||
return ( | ||
<div className="flex flex-col space-y-2 h-full flex-1"> | ||
<Card> | ||
<CardBody> | ||
<p> | ||
标签管理 | ||
</p> | ||
</CardBody> | ||
</Card> | ||
<Card className="flex-1"> | ||
<CardBody> | ||
<p> | ||
标签管理页面 | ||
</p> | ||
</CardBody> | ||
<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 select-none">标签管理</h4> | ||
</div> | ||
</div> | ||
<Button | ||
color="primary" | ||
radius="full" | ||
size="sm" | ||
isLoading={isValidating} | ||
onClick={() => mutate()} | ||
> | ||
刷新 | ||
</Button> | ||
</CardHeader> | ||
</Card> | ||
<Table | ||
bordered | ||
columns={columns} | ||
dataSource={data} | ||
loading={isValidating} | ||
/> | ||
</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
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,56 @@ | ||
'use client' | ||
|
||
import { Button, Select, SelectItem } from '@nextui-org/react' | ||
import {CardHeader} from "@nextui-org/card"; | ||
|
||
export default async function UploadSelect() { | ||
const animals = [ | ||
{label: "Cat", value: "cat", description: "The second most popular pet in the world"}, | ||
{label: "Dog", value: "dog", description: "The most popular pet in the world"}, | ||
{label: "Elephant", value: "elephant", description: "The largest land animal"}, | ||
]; | ||
|
||
const storages = [ | ||
{ | ||
label: 'S3', | ||
value: 's3', | ||
}, | ||
{ | ||
label: 'AList', | ||
value: 'alist', | ||
} | ||
] | ||
|
||
return ( | ||
<CardHeader className="justify-between space-x-1"> | ||
<Select | ||
isRequired | ||
color="primary" | ||
variant="bordered" | ||
label="存储" | ||
placeholder="请选择存储" | ||
defaultSelectedKeys={["cat"]} | ||
> | ||
{storages.map((storage) => ( | ||
<SelectItem key={storage.value} value={storage.value}> | ||
{storage.label} | ||
</SelectItem> | ||
))} | ||
</Select> | ||
<Select | ||
isRequired | ||
color="secondary" | ||
variant="bordered" | ||
label="标签" | ||
placeholder="请选择标签" | ||
defaultSelectedKeys={["cat"]} | ||
> | ||
{animals.map((animal) => ( | ||
<SelectItem key={animal.value} value={animal.value}> | ||
{animal.label} | ||
</SelectItem> | ||
))} | ||
</Select> | ||
</CardHeader> | ||
) | ||
} |