-
Notifications
You must be signed in to change notification settings - Fork 123
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
4 changed files
with
133 additions
and
200 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
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,23 @@ | ||
'use client' | ||
|
||
import { Button } from '@nextui-org/react' | ||
import React from 'react' | ||
import { useSWRConfig } from 'swr' | ||
|
||
export default function RefreshButton() { | ||
const { mutate } = useSWRConfig() | ||
|
||
return ( | ||
<Button | ||
color="primary" | ||
radius="full" | ||
size="sm" | ||
// isLoading={loading} | ||
onClick={() => { | ||
mutate('getTags') | ||
}} | ||
> | ||
刷新 | ||
</Button> | ||
) | ||
} |
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,89 @@ | ||
'use client' | ||
|
||
import React from 'react' | ||
import { Table, type TableProps } from 'antd' | ||
import { Button, Dropdown, DropdownItem, DropdownMenu, DropdownTrigger } from '@nextui-org/react' | ||
import { DeleteDocumentBulkIcon, EditDocumentBulkIcon, SendFilledIcon } from '@nextui-org/shared-icons' | ||
import { toast } from 'sonner' | ||
import useSWR from 'swr' | ||
|
||
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' | ||
|
||
export default function TagList({handleClick: onClick}: any) { | ||
const { data, error, isLoading, isValidating } = useSWR('getTags', | ||
() => { | ||
return onClick() | ||
}) | ||
|
||
console.log(data) | ||
|
||
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> | ||
), | ||
}, | ||
]; | ||
|
||
return ( | ||
<Table | ||
bordered | ||
columns={columns} | ||
loading={isValidating} | ||
dataSource={data} | ||
/> | ||
) | ||
} |