kevisual-center/src/pages/home/module/SuccessModal.tsx
2025-04-03 19:29:57 +08:00

56 lines
2.2 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { Dialog, DialogContent, DialogTitle } from '@mui/material';
import { useShallow } from 'zustand/shallow';
import { useHomeStore } from '../store';
import { useMemo } from 'react';
import { useLayoutStore } from '@/modules/layout/store';
export const Label = ({ label, children }: { label: string; children: React.ReactNode }) => {
return (
<div className='text-sm text-gray-500 w-full flex gap-2'>
<div className='min-w-[60px]'>{label}</div>
<div className=''>{children}</div>
</div>
);
};
export const SuccessModal = () => {
const { openSuccessModal, setOpenSuccessModal, appKey, version, filename } = useHomeStore(
useShallow((state) => ({
openSuccessModal: state.openSuccessModal,
setOpenSuccessModal: state.setOpenSuccessModal,
appKey: state.appKey, //
version: state.version, //
filename: state.filename, //
})),
);
const { me } = useLayoutStore(useShallow((state) => ({ me: state.me })));
const link = useMemo(() => {
const _currentHref = new URL(window.location.href);
const username = me?.username;
const newHref = new URL(`/${username}/${appKey}/`, _currentHref.origin);
return newHref.toString();
}, [me, appKey]);
return (
<Dialog open={openSuccessModal} onClose={() => setOpenSuccessModal(false)}>
<DialogTitle className='text-black'></DialogTitle>
<DialogContent>
<div className='flex flex-col gap-2 w-[400px] min-h-[100px] text-black'>
<Label label='应用 Key: '>{appKey}</Label>
<Label label='版本:'>{version}</Label>
<Label label='访问地址:'>
<a href={link} className='text-blue-500' target='_blank' rel='noreferrer'>
{link}
</a>
</Label>
<Label label='配置地址:'>
<a href={`/app/edit/list`} className='text-blue-500' target='_self' rel='noreferrer'>
{`/app/edit/list`}
</a>
</Label>
<div className='mt-1 text-gray-500 italic' style={{ fontSize: 10 }}>
: 如果需要其他人访问
</div>
</div>
</DialogContent>
</Dialog>
);
};