16 |

{
23 | setMasonryView(true)
24 | setMasonryViewData(photo)
25 | setMasonryViewDataList(dataList)
26 | }}
27 | onLoad={() => setLoaded(true)}
28 | className={cn(
29 | "duration-700 ease-[cubic-bezier(0.4, 0, 0.2, 1)] group-hover:opacity-75 cursor-pointer transition-all will-change-transform hover:scale-[1.01]",
30 | {
31 | 'opacity-100 scale-100 blur-0': loaded,
32 | 'opacity-0 scale-95 blur-sm': !loaded,
33 | }
34 | )}
35 | />
36 | {
37 | photo.type === 2 &&
38 |
39 |
60 |
61 | }
62 |
63 | )
64 | }
--------------------------------------------------------------------------------
/hono/images.ts:
--------------------------------------------------------------------------------
1 | import 'server-only'
2 | import {
3 | deleteBatchImage,
4 | deleteImage,
5 | insertImage,
6 | updateImage,
7 | updateImageShow,
8 | updateImageAlbum
9 | } from '~/server/db/operate'
10 | import { Hono } from 'hono'
11 |
12 | const app = new Hono()
13 |
14 | app.post('/add', async (c) => {
15 | const image = await c.req.json()
16 | if (!image.url) {
17 | return c.json({
18 | code: 500,
19 | message: '图片链接不能为空!'
20 | })
21 | }
22 | if (!image.height || image.height <= 0) {
23 | return c.json({
24 | code: 500,
25 | message: '图片高度不能为空且必须大于 0!'
26 | })
27 | }
28 | if (!image.width || image.width <= 0) {
29 | return c.json({
30 | code: 500,
31 | message: '图片宽度不能为空且必须大于 0!'
32 | })
33 | }
34 | try {
35 | await insertImage(image);
36 | return c.json({ code: 200, message: '保存成功!' })
37 | } catch (e) {
38 | console.log(e)
39 | return c.json({ code: 500, message: '保存失败!' })
40 | }
41 | })
42 |
43 | app.delete('/batch-delete', async (c) => {
44 | try {
45 | const data = await c.req.json()
46 | await deleteBatchImage(data);
47 | return c.json({ code: 200, message: '删除成功!' })
48 | } catch (e) {
49 | console.log(e)
50 | return c.json({ code: 500, message: '删除失败!' })
51 | }
52 | })
53 |
54 | app.delete('/delete/:id', async (c) => {
55 | try {
56 | const { id } = c.req.param()
57 | await deleteImage(id);
58 | return c.json({ code: 200, message: '删除成功!' })
59 | } catch (e) {
60 | console.log(e)
61 | return c.json({ code: 500, message: '删除失败!' })
62 | }
63 | })
64 |
65 | app.put('/update', async (c) => {
66 | const image = await c.req.json()
67 | if (!image.url) {
68 | return c.json({
69 | code: 500,
70 | message: '图片链接不能为空!'
71 | })
72 | }
73 | if (!image.height || image.height <= 0) {
74 | return c.json({
75 | code: 500,
76 | message: '图片高度不能为空且必须大于 0!'
77 | })
78 | }
79 | if (!image.width || image.width <= 0) {
80 | return c.json({
81 | code: 500,
82 | message: '图片宽度不能为空且必须大于 0!'
83 | })
84 | }
85 | try {
86 | await updateImage(image);
87 | return c.json({ code: 200, message: '更新成功!' })
88 | } catch (e) {
89 | console.log(e)
90 | return c.json({ code: 500, message: '更新失败!' })
91 | }
92 | })
93 |
94 | app.put('/update-show', async (c) => {
95 | const image = await c.req.json()
96 | const data = await updateImageShow(image.id, image.show);
97 | return c.json(data)
98 | })
99 |
100 | app.put('/update-Album', async (c) => {
101 | const image = await c.req.json()
102 | try {
103 | await updateImageAlbum(image.imageId, image.albumId);
104 | return c.json({
105 | code: 200,
106 | message: '更新成功!'
107 | })
108 | } catch (e) {
109 | console.log(e)
110 | return c.json({
111 | code: 500,
112 | message: '更新失败!'
113 | })
114 | }
115 | })
116 |
117 | export default app
--------------------------------------------------------------------------------
/components/admin/settings/storages/S3Tabs.tsx:
--------------------------------------------------------------------------------
1 | 'use client'
2 |
3 | import { Card } from '~/components/ui/card'
4 | import {
5 | Table,
6 | TableBody,
7 | TableCell,
8 | TableHead,
9 | TableHeader,
10 | TableRow,
11 | } from "~/components/ui/table"
12 | import { Button } from '~/components/ui/button'
13 | import { ReloadIcon } from '@radix-ui/react-icons'
14 | import React from 'react'
15 | import useSWR from 'swr'
16 | import { fetcher } from '~/lib/utils/fetcher'
17 | import { toast } from 'sonner'
18 | import { useButtonStore } from '~/app/providers/button-store-Providers'
19 | import S3EditSheet from '~/components/admin/settings/storages/S3EditSheet'
20 |
21 | export default function S3Tabs() {
22 | const { data, error, isValidating, mutate } = useSWR('/api/v1/settings/s3-info', fetcher
23 | , { revalidateOnFocus: false })
24 | const { setS3Edit, setS3EditData } = useButtonStore(
25 | (state) => state,
26 | )
27 |
28 | if (error) {
29 | toast.error('请求失败!')
30 | }
31 |
32 | return (
33 |