From 523af797931c24d8672ede396675e8bef782a1da Mon Sep 17 00:00:00 2001 From: besscroft Date: Wed, 22 May 2024 21:07:24 +0800 Subject: [PATCH 1/4] =?UTF-8?q?feat:=20=E6=96=B0=E5=A2=9E=E5=9B=BE?= =?UTF-8?q?=E7=89=87=E6=A0=87=E7=AD=BE=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/(default)/label/[...tag]/page.tsx | 26 ++ app/admin/settings/backup/page.tsx | 50 ++-- components/Masonry.tsx | 2 +- components/MasonryItem.tsx | 19 +- components/admin/list/ImageEditSheet.tsx | 8 + components/admin/list/ImageView.tsx | 9 +- components/admin/upload/FileUpload.tsx | 14 + package.json | 1 + pnpm-lock.yaml | 247 ++++++++++++++++-- .../20240522123550_v5/migration.sql | 2 + prisma/schema.prisma | 1 + server/lib/operate.ts | 2 + server/lib/query.ts | 60 +++++ style/globals.css | 4 + types/index.ts | 1 + 15 files changed, 401 insertions(+), 45 deletions(-) create mode 100644 app/(default)/label/[...tag]/page.tsx create mode 100644 prisma/migrations/20240522123550_v5/migration.sql diff --git a/app/(default)/label/[...tag]/page.tsx b/app/(default)/label/[...tag]/page.tsx new file mode 100644 index 0000000..4deda5f --- /dev/null +++ b/app/(default)/label/[...tag]/page.tsx @@ -0,0 +1,26 @@ +import Masonry from '~/components/Masonry' +import { fetchClientImagesListByLabel, fetchClientImagesPageTotalByLabel } from '~/server/lib/query' +import { ImageHandleProps } from '~/types' + +export default function Label({ params }: { params: { tag: string } }) { + const getData = async (pageNum: number, tag: string) => { + 'use server' + return await fetchClientImagesListByLabel(pageNum, tag) + } + + const getPageTotal = async (tag: string) => { + 'use server' + return await fetchClientImagesPageTotalByLabel(tag) + } + + const props: ImageHandleProps = { + handle: getData, + args: `getImages-client-label`, + tag: `${decodeURIComponent(params.tag)}`, + totalHandle: getPageTotal + } + + return ( + + ) +} \ No newline at end of file diff --git a/app/admin/settings/backup/page.tsx b/app/admin/settings/backup/page.tsx index e238e8b..7c8f9d1 100644 --- a/app/admin/settings/backup/page.tsx +++ b/app/admin/settings/backup/page.tsx @@ -3,8 +3,8 @@ import { Card, CardBody } from '@nextui-org/react' import React, { useState } from 'react' import { CloudUploadOutlined, CloudDownloadOutlined } from '@ant-design/icons' -import type { UploadProps } from 'antd' -import { Button, Upload } from 'antd' +// import type { UploadProps } from 'antd' +// import { Button, Upload } from 'antd' import { toast } from 'sonner' import dayjs from 'dayjs' @@ -92,33 +92,33 @@ export default function Backup() { option.onSuccess(option.file) } - const picimpactProps: UploadProps = { - className: '!w-full sm:!w-64', - name: 'file', - maxCount: 1, - multiple: false, - showUploadList: false, - customRequest: async (file) => await onPicImpactRequestUpload(file), - }; + // const picimpactProps: UploadProps = { + // className: '!w-full sm:!w-64', + // name: 'file', + // maxCount: 1, + // multiple: false, + // showUploadList: false, + // customRequest: async (file) => await onPicImpactRequestUpload(file), + // }; return ( - - - - + {/*}*/} + {/* loading={backupLoading}*/} + {/* onClick={() => backup()}*/} + {/* aria-label="备份"*/} + {/*>备份*/} + {/**/} + {/* }*/} + {/* loading={restorePicImpactLoading}*/} + {/* aria-label="选择备份文件(本机迁移)"*/} + {/* >选择备份文件(本机迁移)*/} + {/**/}

如果您在线上环境,请确保您的数据库单次会话时长以及事务的支持,否则会还原数据失败!

diff --git a/components/Masonry.tsx b/components/Masonry.tsx index dcb1cad..b2a84f3 100644 --- a/components/Masonry.tsx +++ b/components/Masonry.tsx @@ -12,7 +12,7 @@ import MasonryItem from '~/components/MasonryItem' export default function Masonry(props : Readonly) { const { data: pageTotal } = useSWRPageTotalHook(props) const { data, error, isLoading, isValidating, size, setSize } = useSWRInfinite((index) => { - return [`client--${index}-${props.tag}`, index] + return [`client-${props.args}-${index}-${props.tag}`, index] }, ([_, index]) => { return props.handle(index + 1, props.tag) diff --git a/components/MasonryItem.tsx b/components/MasonryItem.tsx index d1b8c9f..909fcda 100644 --- a/components/MasonryItem.tsx +++ b/components/MasonryItem.tsx @@ -6,12 +6,14 @@ import { } from '~/components/ui/Dialog' import { useButtonStore } from '~/app/providers/button-store-Providers' import { ImageType } from '~/types' -import { Image, Tabs, Tab, Card, CardHeader, Table, TableHeader, TableColumn, TableBody, TableRow, TableCell, Button } from '@nextui-org/react' +import { Image, Tabs, Tab, Card, CardHeader, Table, TableHeader, TableColumn, TableBody, TableRow, TableCell, Button, Chip } from '@nextui-org/react' import { Aperture, Camera, Image as ImageIcon, Languages, CalendarDays, X, SunMedium, MoonStar } from 'lucide-react' import * as React from 'react' import { useTheme } from 'next-themes' +import { useRouter } from 'next-nprogress-bar' export default function MasonryItem() { + const router = useRouter() const { MasonryView, MasonryViewData, setMasonryView, setMasonryViewData } = useButtonStore( (state) => state, ) @@ -109,6 +111,21 @@ export default function MasonryItem() {

{MasonryViewData?.exif?.data_time || 'N&A'}

+ {MasonryViewData?.labels && +
+ {MasonryViewData?.labels.map((tag: string) => ( + { + setMasonryView(false) + router.push(`/label/${tag}`) + }} + >{tag} + ))} +
+ } ) { const { pageNum, tag, ...restProps } = props @@ -140,6 +141,13 @@ export default function ImageEditSheet(props : Readonly + setImageEditData({ ...image, labels: value })} + /> + {imageViewData?.labels && +
+ {imageViewData?.labels.map((tag: string) => ( + {tag} + ))} +
+ }