-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9 from Vsion/main
feat: setting data-control
- Loading branch information
Showing
9 changed files
with
230 additions
and
41 deletions.
There are no files selected for viewing
File renamed without changes.
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
104 changes: 104 additions & 0 deletions
104
src/app/setting/data-control/DataControlClient/index.tsx
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,104 @@ | ||
'use client'; | ||
|
||
import { Button, Card, Flex, Switch, Table } from 'antd'; | ||
import classNames from 'classnames'; | ||
import React from 'react'; | ||
|
||
import BtnsBlock, { Btn } from '@/components/BtnsBlock'; | ||
import ReturnBtn from '@/components/ReturnBtn'; | ||
|
||
import { useStyles } from './styles'; | ||
|
||
interface Props { | ||
user: { | ||
name: string; | ||
}; | ||
} | ||
|
||
const DataControlClient: React.FC<Props> = () => { | ||
const { styles } = useStyles(); | ||
const [checked, setChecked] = React.useState(false); | ||
|
||
const btns1: Btn[] = React.useMemo( | ||
() => [ | ||
{ | ||
title: '聊天记录应用', | ||
action: ( | ||
<Switch | ||
checked={checked} | ||
onChange={_checked => { | ||
setChecked(_checked); | ||
}} | ||
/> | ||
), | ||
}, | ||
], | ||
[checked] | ||
); | ||
const btns_del_all: Btn[] = React.useMemo( | ||
() => [ | ||
{ | ||
title: '删除所有聊天记录', | ||
danger: true, | ||
onClick: () => { | ||
console.warn('handel del all'); | ||
}, | ||
}, | ||
], | ||
[checked] | ||
); | ||
return ( | ||
<div className={classNames(styles.dataControl)}> | ||
<div> | ||
<ReturnBtn title="数据控制" to="/setting" /> | ||
<Flex className={'scrollBar'} justify={'center'}> | ||
<div className={classNames(styles.content)}> | ||
<BtnsBlock | ||
btns={btns1} | ||
extra="将此浏览器上的新聊天记录保存到您的历史记录中,并允许我们应用您的聊天记录,改进我们的模型。关闭开关,将不会保留您的聊天记录。此设置不在浏览器或设备之间同步。" | ||
/> | ||
<BtnsBlock btns={btns_del_all} /> | ||
<Card bordered={false} title="分享链接"> | ||
<Table | ||
className={styles.table} | ||
columns={[ | ||
{ | ||
dataIndex: 'name', | ||
title: '对话名称', | ||
width: '50%', | ||
}, | ||
{ | ||
dataIndex: 'time', | ||
title: '分享时间', | ||
width: '50%', | ||
}, | ||
{ | ||
dataIndex: 'opera', | ||
title: '操作', | ||
width: 120, | ||
render: () => { | ||
return ( | ||
<Button danger type="primary"> | ||
删除 | ||
</Button> | ||
); | ||
}, | ||
}, | ||
]} | ||
dataSource={[ | ||
{ | ||
name: '对话1', | ||
time: '2024-01-01 08:08:08', | ||
}, | ||
]} | ||
pagination={false} | ||
/> | ||
</Card> | ||
</div> | ||
</Flex> | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
export default DataControlClient; |
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,30 @@ | ||
import { createStyles } from 'antd-style'; | ||
|
||
export const useStyles = createStyles(({ token }) => ({ | ||
dataControl: { | ||
'height': '100%', | ||
'width': '100%', | ||
'background': token.colorBgLayout, | ||
'position': 'relative', | ||
'& > div': { | ||
position: 'relative', | ||
overflow: 'hidden', | ||
height: '100%', | ||
paddingBottom: '40px', | ||
paddingTop: '64px', | ||
}, | ||
}, | ||
sub: { | ||
width: '100%', | ||
}, | ||
content: { | ||
paddingTop: 16, | ||
paddingBottom: 42, | ||
width: 600, | ||
}, | ||
table: { | ||
'.ant-table-tbody > tr:last-child > td': { | ||
borderBottom: 'unset', | ||
}, | ||
}, | ||
})); |
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 { PropsWithChildren, memo } from 'react'; | ||
|
||
const Layout = memo<PropsWithChildren>(({ children }) => { | ||
return <>{children}</>; | ||
}); | ||
|
||
export default Layout; |
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,17 @@ | ||
import React from 'react'; | ||
|
||
import { getUserData } from '../../actions/user'; | ||
import DataControlClient from './DataControlClient'; | ||
|
||
export default async function DesktopPage() { | ||
const user = await getUserData(); | ||
const props = { | ||
user, | ||
}; | ||
// todo fetch server data | ||
return ( | ||
<> | ||
<DataControlClient {...props} /> | ||
</> | ||
); | ||
} |
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