更加首页背景图,增加点击弹出联系方式

This commit is contained in:
2025-06-25 17:43:30 +08:00
parent 18001dcc30
commit 971c789f70
2 changed files with 96 additions and 53 deletions

1
.gitignore vendored
View File

@@ -22,3 +22,4 @@ dist-ssr
*.njsproj *.njsproj
*.sln *.sln
*.sw? *.sw?
dist.zip

View File

@@ -1,9 +1,22 @@
import { useEffect, useState } from 'react'; import { useEffect, useState } from 'react';
import { useTheme } from './theme-provider'; import { useTheme } from './theme-provider';
import { Button } from "@/components/ui/button";
import {
Dialog,
DialogContent,
DialogHeader,
DialogTitle,
DialogFooter,
DialogClose,
} from "@/components/ui/dialog";
import { toast } from "@/components/ui/use-toast";
const WECHAT_ID = "JIWEI-Tech";
export const Hero = () => { export const Hero = () => {
const { theme } = useTheme(); const { theme } = useTheme();
const [isDark, setIsDark] = useState(false); const [isDark, setIsDark] = useState(false);
const [isContactModalOpen, setIsContactModalOpen] = useState(false);
useEffect(() => { useEffect(() => {
if (theme === 'system') { if (theme === 'system') {
@@ -17,68 +30,97 @@ export const Hero = () => {
} }
}, [theme]); }, [theme]);
const handleBackgroundClick = () => {
setIsContactModalOpen(true);
};
const handleCopy = () => {
navigator.clipboard.writeText(WECHAT_ID).then(
() => {
setIsContactModalOpen(false);
toast({
title: "复制成功",
description: "微信号已复制到剪贴板",
});
},
(err) => {
console.error("Async: Could not copy text: ", err);
toast({
title: "复制失败",
description: "请手动复制微信号。",
variant: "destructive",
});
}
);
};
const bgUrl = isDark const bgUrl = isDark
? 'url(https://lijue-me.oss-cn-chengdu.aliyuncs.com/20250619153149236.png)' ? 'url(https://lijue-me.oss-cn-chengdu.aliyuncs.com/20250619153149236.png)'
: 'url(https://lijue-me.oss-cn-chengdu.aliyuncs.com/20250619153149236.png)'; : 'url(https://lijue-me.oss-cn-chengdu.aliyuncs.com/20250619153149236.png)';
return ( return (
<section <>
id="index" <section
className="container grid lg:grid-cols-2 place-items-center py-10 md:py-20 gap-6 id="index"
h-[200px] md:h-[400px] lg:h-[500px] xl:h-[600px] max-w-[1920px] mx-auto" className="container grid lg:grid-cols-2 place-items-center py-10 md:py-20 gap-6
style={{ h-[200px] md:h-[400px] lg:h-[500px] xl:h-[600px] max-w-[1920px] mx-auto relative cursor-pointer"
backgroundImage: bgUrl, style={{
backgroundSize: 'cover', backgroundImage: bgUrl,
backgroundPosition: 'center', backgroundSize: 'cover',
backgroundRepeat: 'no-repeat', backgroundPosition: 'center',
}} backgroundRepeat: 'no-repeat',
> }}
{/* <div className="text-center lg:text-start space-y-6"> onClick={handleBackgroundClick}
<main className="text-5xl md:text-6xl font-bold"> >
<h1 className="inline">
<span className="inline bg-gradient-to-r from-[#F596D3] to-[#D247BF] text-transparent bg-clip-text">
Shadcn
</span>{" "}
landing page
</h1>{" "}
for{" "}
<h2 className="inline">
<span className="inline bg-gradient-to-r from-[#61DAFB] via-[#1fc0f1] to-[#03a3d7] text-transparent bg-clip-text">
React
</span>{" "}
developers
</h2>
</main>
<p className="text-xl text-muted-foreground md:w-10/12 mx-auto lg:mx-0">
Build your React landing page effortlessly with the required sections
to your project.
</p>
<div className="space-y-4 md:space-y-0 md:space-x-4"> {/* Shadow effect */}
<Button className="w-full md:w-1/3">Get Started</Button> <div className="shadow"></div>
</section>
<a {/* Contact Modal */}
rel="noreferrer noopener" <Dialog open={isContactModalOpen} onOpenChange={setIsContactModalOpen}>
href="https://github.com/leoMirandaa/shadcn-landing-page.git" <DialogContent className="bg-white dark:bg-[#232c3b] rounded-2xl p-6 max-w-md w-full mx-22 shadow-2xl">
target="_blank" <DialogHeader className="flex justify-between items-center mb-6 text-left">
className={`w-full md:w-1/3 ${buttonVariants({ <DialogTitle className="text-xl font-bold text-[#181f2a] dark:text-white">
variant: "outline",
})}`} </DialogTitle>
> </DialogHeader>
Github Repository
<GitHubLogoIcon className="ml-2 w-5 h-5" />
</a>
</div>
</div> */}
{/* Hero cards sections */} <div className="text-center">
{/* <div className="z-10"> <div className="bg-[#f3f4f6] dark:bg-[#1e293b] p-4 rounded-xl mb-4">
<HeroCards /> <img
</div> */} src="https://lijue-me.oss-cn-chengdu.aliyuncs.com/20250617153505991.png"
alt="联系二维码"
className="max-w-48 max-h-60 mx-auto rounded-lg object-contain"
/>
</div>
<p className="text-[#4b5563] dark:text-[#cbd5e1] mb-2">
</p>
<p className="text-sm text-[#6b7280] dark:text-[#94a3b8]">
</p>
</div>
{/* Shadow effect */} <DialogFooter className="mt-6 flex gap-3">
<div className="shadow"></div> <DialogClose asChild>
</section> <Button
type="button"
className="flex-1 px-4 py-2 border border-[#d1d5db] dark:border-[#374151] text-[#374151] dark:text-[#cbd5e1] rounded-lg hover:bg-[#f9fafb] dark:hover:bg-[#374151] transition-colors bg-white dark:bg-[#232c3b]"
>
</Button>
</DialogClose>
<Button
onClick={handleCopy}
className="flex-1 px-4 py-2 bg-[#2563eb] text-white rounded-lg hover:bg-[#1d4ed8] transition-colors"
>
</Button>
</DialogFooter>
</DialogContent>
</Dialog>
</>
); );
}; };