diff --git a/app/space/editSpacePost/[zid]/page.jsx b/app/space/editSpacePost/[zid]/page.jsx index a4f7a77..db7672f 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(2): formData.paidText} + value={formData.paidText.includes("\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/space/setting/[mid]/page.js b/app/space/setting/[mid]/page.js index f200fc2..fb7e4b6 100644 --- a/app/space/setting/[mid]/page.js +++ b/app/space/setting/[mid]/page.js @@ -9,7 +9,7 @@ import { faAngleRight, faCalendar, } from "@fortawesome/free-solid-svg-icons"; -import { getSpaceData,getStreamerInfo } from "@/api/space"; +import { getSpaceData,getStreamerDetailInfo } from "@/api/space"; import requireAPI from "@/utils/requireAPI"; export default function Setting() { const router = useRouter(); @@ -19,9 +19,10 @@ export default function Setting() { (async () => { const {mid} = params; if (mid) { - const info = await getStreamerInfo(Number(mid)); + const info = await getStreamerDetailInfo(Number(mid)); await getSpaceData(Number(mid)).then((res) => { - setStreamerInfo({ ...info, refund_enable: res?.refund_enable }); + setStreamerInfo({ ...info.streamer_ext + , refund_enable: res?.refund_enable }); }); } })(); @@ -133,7 +134,7 @@ export default function Setting() { diff --git a/components/PostItem/index.js b/components/PostItem/index.js index 2a45fe3..8e2bd5a 100644 --- a/components/PostItem/index.js +++ b/components/PostItem/index.js @@ -79,11 +79,15 @@ export default function PostItem({ }, []); const handleDelete = async (type) => { try { - const _data = await requireAPI("POST", `/api/${type=="space"?"zone_moment":"moment"}/delete`, { - body: { - id: data?.id, - }, - }); + const _data = await requireAPI( + "POST", + `/api/${type == "space" ? "zone_moment" : "moment"}/delete`, + { + body: { + id: data?.id, + }, + } + ); if (_data.ret === -1) { Toast.show({ icon: "fail", @@ -172,21 +176,23 @@ export default function PostItem({ )} - {(data?.status === 0 || data?.status === 1) && ( + {(type == "space" + ? data?.status === 0 || data?.status === 1 + : data?.status === 3 || data?.status === 4) && (
审核中
)} - {data?.status === 3 && + {(type == "space" + ? data?.status === 3 + : data?.status === 5 || data?.status === 6) && (type == "space" ? (

{ - router.push( - `/space/editSpacePost/${data.id}` - ); + router.push(`/space/editSpacePost/${data.id}`); }} > @@ -195,9 +201,7 @@ export default function PostItem({

) : (

- - 审核未通过,请删除后重新提交。 - + 审核未通过,请删除后重新提交。

))}
@@ -389,21 +393,25 @@ export default function PostItem({
  • { - router.push( - `/space/editSpacePost/${data.id}` - ); + router.push(`/space/editSpacePost/${data.id}`); }} > 编辑

  • -
  • handleDelete("space")}> +
  • handleDelete("space")} + > 删除
  • ) : type == "post" && account?.mid == data?.mid ? ( <> -
  • handleDelete("post")}> +
  • handleDelete("post")} + > 删除
  • diff --git a/components/UploadImgs/index.js b/components/UploadImgs/index.js index b163435..55c34e4 100644 --- a/components/UploadImgs/index.js +++ b/components/UploadImgs/index.js @@ -15,12 +15,13 @@ export default function UploadImgs({ videoSrc = null, getVideoCover, id = "uploadAvatarBtn", - maxLength=9 + maxLength = 9, }) { const [loading, setLoading] = useState(false); const [filesUrls, setFilesUrls] = useState([]); const [videoUrl, setVideoUrl] = useState(null); const [frameImage, setFrameImage] = useState({ src: null, h: 0, w: 0 }); + const [columns, setColumns] = useState([]); useEffect(() => { if (existImages.length > 0) { setFilesUrls( @@ -41,21 +42,35 @@ export default function UploadImgs({ id: `${index}`, })); 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); } else { setFilesUrls([]); + setColumns([]); } }, [assets]); const handleUploadImage = async (e) => { let file = e.target.files[0]; if (!file) return; - if((e.target.files.length+assets.length)>maxLength){ + if (e.target.files.length + assets.length > maxLength) { Toast.show({ icon: "fail", - content: '最多上传'+maxLength+'张图片', + content: "最多上传" + maxLength + "张图片", position: "top", }); - return + return; } var videoUrl = URL.createObjectURL(file); var videoObj = document.createElement("video"); @@ -99,12 +114,12 @@ export default function UploadImgs({ let newAssets = [...assets]; newArr.splice(index, 1); newAssets.splice(index, 1); - setFilesUrls(newArr); + setFilesUrls(newAssets); getImgs(newAssets); }; const showPhotos = (images, index) => { const file = images[0]; - const urls = type == 2 ? [frameImage.src] : images; + const urls = type == 2 ? [frameImage.src] : images.map((it) => it.url); if (type == 1) { ImageViewer.Multi.show({ images: urls, @@ -143,87 +158,114 @@ export default function UploadImgs({ }; const reorder = (list, startIndex, endIndex) => { const result = Array.from(list); - const [removed] = result.splice(startIndex, 1); - result.splice(endIndex, 0, removed); - + const removing = result[startIndex]; + const removed = result[endIndex]; + result[startIndex] = removed; + result[endIndex] = removing; return result; }; const onDragEnd = (result) => { - if (!result.destination) return; + const { source, destination, draggableId } = result; + + if (!destination) return; + + if ( + source.droppableId === destination.droppableId && + source.index === destination.index + ) { + return; + } const newList = reorder( assets, - result.source.index, - result.destination.index + parseInt(source.droppableId.match(/\d+/)[0], 10) * 4 + source.index, + parseInt(destination.droppableId.match(/\d+/)[0], 10) * 4 + destination.index ); getImgs([...newList]); - // const newArr=newList.map((it,index)=>({...it,url:it.url||URL.createObjectURL(it)})) - const newArr = newList.map((it, index) => { - if (it.url) { - return { url: it.url, id: `${index}` }; - } else { - return { url: URL.createObjectURL(it), id: `${index}` }; + 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 }; + } + + return column; }); - setFilesUrls(newArr); + setColumns(newColumns); }; return ( -
    - - - {(droppableProvided) => ( -
    - {filesUrls.map((item, index) => ( - - {(provided, snapshot) => ( -
    -
    +
    + + {columns.map((column,index) => ( + + {(provided) => ( +
    + {column.items.map((item, ind) => ( + + {(provided) => ( +
    showPhotos(filesUrls, index)} - style={{ height: "calc(25vw - 0.75rem)" }} + key={ind} + className="rounded relative mr-1 mb-1 h-full" > - -
    - -
    handleRemoveItem(index)} - > - -
    - {type == 2 && (
    showPhotos(filesUrls)} + onClick={() => showPhotos(filesUrls, index*4+ind)} + style={{ height: "calc(25vw - 0.75rem)" }} + className="h-full pb-1" > - +
    - )} +
    handleRemoveItem(index*4+ind)} + > + +
    + {type == 2 && ( +
    showPhotos(filesUrls)} + > + +
    + )} +
    -
    - )} - - ))} - {droppableProvided.placeholder} -
    - )} - + )} + + ))} + {provided.placeholder} +
    + )} + + ))} {loading && (
    @@ -260,3 +302,11 @@ export default function UploadImgs({
    ); } + +function ListElement({ item: { id } }) { + return ( +
    +
    {id}
    +
    + ); +}