From b54b1738d4242f7204cf9857317d32757ec2a051 Mon Sep 17 00:00:00 2001 From: anln Date: Wed, 13 Nov 2024 18:51:55 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=AD=98=E5=9C=A8=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/space/editSpacePost/[zid]/page.jsx | 2 +- app/streamerPosts/[id]/page.jsx | 2 +- components/PostItem/index.js | 3 +- components/UploadImgs/index.js | 91 ++++++++++++++++---------- 4 files changed, 61 insertions(+), 37 deletions(-) diff --git a/app/space/editSpacePost/[zid]/page.jsx b/app/space/editSpacePost/[zid]/page.jsx index db7672f..8ef15c6 100644 --- a/app/space/editSpacePost/[zid]/page.jsx +++ b/app/space/editSpacePost/[zid]/page.jsx @@ -316,7 +316,7 @@ export default function EditSpacePost() { })) } autoSize={{ minRows: 6, maxRows: 15 }} - value={formData.paidText.includes("\n") ? formData.paidText.slice(1): formData.paidText} + value={formData.paidText.startsWith("\n") ? formData.paidText.slice(1): formData.paidText} style={{ "--font-size": "14px" }} className="bg-[#FFFFFF1A] rounded-2xl mt-2 mb-4 p-2 h-full" /> diff --git a/app/streamerPosts/[id]/page.jsx b/app/streamerPosts/[id]/page.jsx index bd9ccb9..d2b6f1f 100644 --- a/app/streamerPosts/[id]/page.jsx +++ b/app/streamerPosts/[id]/page.jsx @@ -91,7 +91,7 @@ export default function StreamerPosts({ id }) { {data?.map((item, index) => ( {/* */} - + ))} diff --git a/components/PostItem/index.js b/components/PostItem/index.js index 8e2bd5a..c769585 100644 --- a/components/PostItem/index.js +++ b/components/PostItem/index.js @@ -17,6 +17,7 @@ export default function PostItem({ follow, date = new Date(), data = {}, + showFollow = true, }) { const router = useRouter(); const [isOpenText, setIsOpenText] = useState(false); @@ -167,7 +168,7 @@ export default function PostItem({
{data.streamer_ext?.name} - {type == "post" && ( + {type == "post" && showFollow && ( handleFollow(isFollow, data?.mid, setIsFollow)} className="rounded-full bg-[#FFFFFF1A] px-2 py-1 text-xs text-white font-medium" diff --git a/components/UploadImgs/index.js b/components/UploadImgs/index.js index 55c34e4..fd7cb6c 100644 --- a/components/UploadImgs/index.js +++ b/components/UploadImgs/index.js @@ -43,18 +43,7 @@ export default function UploadImgs({ })); setFilesUrls(list); // 将filesUrls转变为每组四个的二维数组 - const newList = []; - for (let i = 0; i < list.length; i += 4) { - newList.push(list.slice(i, i + 4)); - } - const newColumns = newList.map((it, index) => { - return { - id: "column-" + index, - title: "Column " + index, - items: it, - }; - }); - setColumns(newColumns); + handleMakeColumns(list); } else { setFilesUrls([]); setColumns([]); @@ -133,7 +122,7 @@ export default function UploadImgs({ playsInline controls muted={true} - controlslist="nodownload" + controlsList="nodownload" > @@ -153,9 +142,25 @@ export default function UploadImgs({ // videoD.src = url; getVideoBase64(url).then((src) => { setFrameImage((old) => ({ ...old, src })); - setFilesUrls([{ url: src, id: "0" }]); + const list = [{ url: src, id: "0" }] + setFilesUrls(list); + handleMakeColumns(list); }); }; + const handleMakeColumns = (list) => { + const newList = []; + for (let i = 0; i < list.length; i += 4) { + newList.push(list.slice(i, i + 4)); + } + const newColumns = newList.map((it, index) => { + return { + id: "column-" + index, + title: "Column " + index, + items: it, + }; + }); + setColumns(newColumns); + } const reorder = (list, startIndex, endIndex) => { const result = Array.from(list); const removing = result[startIndex]; @@ -178,33 +183,49 @@ export default function UploadImgs({ const newList = reorder( assets, parseInt(source.droppableId.match(/\d+/)[0], 10) * 4 + source.index, - parseInt(destination.droppableId.match(/\d+/)[0], 10) * 4 + destination.index + parseInt(destination.droppableId.match(/\d+/)[0], 10) * 4 + + destination.index ); - getImgs([...newList]); const start = columns.find((column) => column.id === source.droppableId); const end = columns.find((column) => column.id === destination.droppableId); const startItems = Array.from(start.items); let endItems = Array.from(end.items); - const newColumns = columns.map((column) => { - if (column.id === start.id) { - startItems.splice(source.index, 1, end.items[destination.index]); - return { ...column, items: startItems }; - } - if (column.id === end.id) { - endItems.splice(destination.index, 1, start.items[source.index]); - return { ...column, items: endItems }; - } + if (destination.droppableId === source.droppableId) { + const itemToMove = startItems[source.index]; + startItems.splice(source.index, 1); + startItems.splice(destination.index, 0, itemToMove); + const newColumns = columns.map((column) => { + if (column.id === start.id) { + return { ...column, items: startItems }; + } + if (column.id === end.id) { + return { ...column, items: endItems }; + } + return column; + }); + setColumns(newColumns); + getImgs([...newList]); + } else { + const newColumns = columns.map((column) => { + if (column.id === start.id) { + startItems.splice(source.index, 1, end.items[destination.index]); + return { ...column, items: startItems }; + } + if (column.id === end.id) { + endItems.splice(destination.index, 1, start.items[source.index]); + return { ...column, items: endItems }; + } - return column; - }); - setColumns(newColumns); + return column; + }); + setColumns(newColumns); + getImgs([...newList]); + } }; return (
- - {columns.map((column,index) => ( + + {columns.map((column, index) => (
showPhotos(filesUrls, index*4+ind)} + onClick={() => + showPhotos(filesUrls, index * 4 + ind) + } style={{ height: "calc(25vw - 0.75rem)" }} className="h-full pb-1" > @@ -244,7 +267,7 @@ export default function UploadImgs({
handleRemoveItem(index*4+ind)} + onClick={() => handleRemoveItem(index * 4 + ind)} >