This commit is contained in:
2025-05-28 19:39:50 +08:00
parent 22cb48b9f3
commit 26be3b85e8
24 changed files with 356 additions and 301 deletions

View File

@@ -115,3 +115,18 @@ export const useComputedHeight = () => {
}, []);
return computedHeight;
};
export const useDragSize = (width = 600, heigth = 400) => {
const computedHeight = getComputedHeight();
const isMin = computedHeight.width < width;
return {
defaultSize: {
width: isMin ? computedHeight.width : 600,
height: 400,
},
style: {
left: isMin ? 0 : computedHeight.width / 2 - width / 2,
top: computedHeight.height / 2 - heigth / 2,
},
};
};

View File

@@ -0,0 +1,24 @@
import { Dialog, DialogContent, DialogHeader, DialogTitle } from '../ui/dialog';
import React, { Dispatch, SetStateAction } from 'react';
type ModalProps = {
open?: boolean;
setOpen?: (open: boolean) => any;
title?: string;
children?: React.ReactNode;
};
export const Modal = (props: ModalProps) => {
const { open = false, setOpen, title, children } = props;
return (
<Dialog open={open} onOpenChange={setOpen}>
<DialogContent>
<DialogHeader>
<DialogTitle>{title}</DialogTitle>
</DialogHeader>
{children}
</DialogContent>
</Dialog>
);
};

View File

@@ -5,6 +5,7 @@
<html lang='zh-CN'>
<head>
<meta charset='UTF-8' />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>AI Pages</title>
<style>
html,