From 2ed15c9b6b0721bbf7a2e384ca508fccd2cc9900 Mon Sep 17 00:00:00 2001 From: Rao <1227431568@qq.com> Date: Mon, 3 Mar 2025 11:09:04 +0800 Subject: [PATCH] rht --- apps/web/src/app/admin/base-setting/page.tsx | 5 +- .../app/main/home/components/HeroSection.tsx | 11 ++-- .../common/input/CarouselUrlInput.tsx | 53 +++++++++++++++++++ 3 files changed, 63 insertions(+), 6 deletions(-) create mode 100644 apps/web/src/components/common/input/CarouselUrlInput.tsx diff --git a/apps/web/src/app/admin/base-setting/page.tsx b/apps/web/src/app/admin/base-setting/page.tsx index 5d610cf..b5dcc83 100755 --- a/apps/web/src/app/admin/base-setting/page.tsx +++ b/apps/web/src/app/admin/base-setting/page.tsx @@ -9,6 +9,7 @@ import FixedHeader from "@web/src/components/layout/fix-header"; import { useForm } from "antd/es/form/Form"; import { api } from "@nice/client"; import { MainLayoutContext } from "../layout"; +import CarouselUrlInput from "@web/src/components/common/input/CarouselUrlInput"; export default function BaseSettingPage() { const { update, baseSetting } = useAppConfig(); @@ -134,11 +135,11 @@ export default function BaseSettingPage() { -
+
- +
{/*
{ const carouselRef = useRef(null); const { statistics, slides, slideLinks = [] } = useAppConfig(); const [countStatistics, setCountStatistics] = useState(4); + const navigator = useNavigate() const platformStats: PlatformStat[] = useMemo(() => { return [ { @@ -91,11 +93,12 @@ const HeroSection = () => { }}> {Array.isArray(slides) ? ( slides.map((item, index) => ( -
+
{ + if(slideLinks?.[index])window.open(slideLinks?.[index],"_blank") + }} + >
{ - // slideLinks?.[index]; - }} className="absolute inset-0 bg-cover bg-center transform transition-[transform,filter] duration-[2000ms] group-hover:scale-105 group-hover:brightness-110 will-change-[transform,filter]" style={{ //backgroundImage: `url(https://s.cn.bing.net/th?id=OHR.GiantCuttlefish_ZH-CN0670915878_1920x1080.webp&qlt=50)`, diff --git a/apps/web/src/components/common/input/CarouselUrlInput.tsx b/apps/web/src/components/common/input/CarouselUrlInput.tsx new file mode 100644 index 0000000..81cc57b --- /dev/null +++ b/apps/web/src/components/common/input/CarouselUrlInput.tsx @@ -0,0 +1,53 @@ +import { Button, Input } from "antd"; +import { useEffect, useState } from "react"; + +export default function CarouselUrlInput( + { value, onChange } + : { + value?: string[]; + onChange?: (value: string[]) => void; + }) { + const [url, setUrl] = useState(""); + const [urls, setUrls] = useState(value || []); + const handleChange = (e) => { + if (e.target.value !== "") setUrl(e.target.value); + }; + const handleDelete = (index) => { + setUrls((prevList) => { + // 创建一个新数组并移除指定索引的元素 + const newList = [...prevList]; + newList.splice(index, 1); + return newList; + }); + }; + useEffect(() => { + if (value) { + setUrls(value) + } + }, [value]) + useEffect(() => { + onChange?.(urls); + }, [urls]); + return ( + <> +
+ + +
+
+
    + {urls.map((item, index) => ( +
  • + + {/* {item} */} + +
  • + ))} +
+
+ + + ); +} \ No newline at end of file