cherry-studio/src/renderer/src/components/Popups/SearchPopup.tsx
2024-11-19 14:17:38 +08:00

66 lines
1.2 KiB
TypeScript

import HistoryPage from '@renderer/pages/history/HistoryPage'
import { Modal } from 'antd'
import { useState } from 'react'
import { TopView } from '../TopView'
interface Props {
resolve: (data: any) => void
}
const PopupContainer: React.FC<Props> = ({ resolve }) => {
const [open, setOpen] = useState(true)
const onOk = () => {
setOpen(false)
}
const onCancel = () => {
setOpen(false)
}
const onClose = () => {
resolve({})
}
SearchPopup.hide = onCancel
return (
<Modal
open={open}
onOk={onOk}
onCancel={onCancel}
afterClose={onClose}
title={null}
width="80vw"
transitionName="ant-move-down"
styles={{
content: { padding: 0, border: '1px solid var(--color-border)' },
body: { height: '80vh' }
}}
footer={null}>
<HistoryPage />
</Modal>
)
}
export default class SearchPopup {
static topviewId = 0
static hide() {
TopView.hide('SearchPopup')
}
static show() {
return new Promise<any>((resolve) => {
TopView.show(
<PopupContainer
resolve={(v) => {
resolve(v)
TopView.hide('SearchPopup')
}}
/>,
'SearchPopup'
)
})
}
}