You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Global-sales/src/views/accounts/ShorturlConversion.jsx

57 lines
1.6 KiB
JavaScript

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

import { Input, Button, Space, Typography } from 'antd'
import { LinkOutlined } from '@ant-design/icons'
import useShortUrlChange from '@/components/Shorturlchange'
import { useState } from 'react'
const { Title, Text, Paragraph } = Typography
function ShorturlConversion() {
const [longUrl, setLongUrl] = useState('')
const [shortUrl, setShortUrl] = useState('')
const { convertUrl } = useShortUrlChange()
const handleConvert = async () => {
const result = await convertUrl(longUrl);
if (result) {
setShortUrl(result);
}
};
return (
<Space direction='vertical' size='large' className='w-full'>
<div>
<Text strong style={{ fontSize: '18px' }}>长链接</Text>
<Input
placeholder="输入需要转换的长链接"
value={longUrl}
onChange={(e) => setLongUrl(e.target.value)}
prefix={<LinkOutlined />}
size="large"
/>
</div>
<Button
type='primary'
size='medium'
onClick={handleConvert}
icon={<LinkOutlined />}
>
转换
</Button>
{shortUrl && (
<div>
<Text strong style={{ fontSize: '18px' }}>转换后的短链接</Text>
<Paragraph
copyable={shortUrl ? {
text: shortUrl,
tooltips: ['点击复制', '已复制!'],
} : false}
style={{ fontSize: '17px' }}
>
{shortUrl}
</Paragraph>
</div>)}
</Space>
);
}
export default ShorturlConversion