diff --git a/.env.example b/.env.example index 9c13c3a..eb1d6eb 100644 --- a/.env.example +++ b/.env.example @@ -1 +1 @@ -FEC_API_TOKEN= \ No newline at end of file +PUBLIC_API_URL= \ No newline at end of file diff --git a/.github/workflows/deploy.yaml b/.github/workflows/deploy.yaml index a47a6fe..add6ff2 100644 --- a/.github/workflows/deploy.yaml +++ b/.github/workflows/deploy.yaml @@ -16,13 +16,15 @@ jobs: # Run your project's build step - name: Use Yarn 4 run: corepack enable + - name: Inject Environment Variables + run: | + echo "PUBLIC_API_URL=${{ vars.PUBLIC_API_URL }}" >> .env - name: Build run: yarn install --immutable && yarn build - name: Publish - uses: cloudflare/pages-action@v1 + uses: cloudflare/wrangler-action@v3 with: apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} - projectName: fcc-cms-6b4t # e.g. 'my-project' - directory: dist # e.g. 'dist' + command: pages deploy dist --project-name=fcc-cms-6b4t gitHubToken: ${{ secrets.GITHUB_TOKEN }} diff --git a/package.json b/package.json index 1bb1cc1..927902f 100644 --- a/package.json +++ b/package.json @@ -10,6 +10,7 @@ "preview": "rsbuild preview" }, "dependencies": { + "@hello-pangea/dnd": "^17.0.0", "@mantine/core": "^7.15.1", "@mantine/dates": "^7.15.1", "@mantine/dropzone": "^7.15.1", @@ -41,8 +42,8 @@ "@rsbuild/plugin-svgr": "^1.0.6", "@types/lodash": "^4.17.13", "@types/node": "^22.10.2", - "@types/react": "^18.3.16", - "@types/react-dom": "^18.3.5", + "@types/react": "^19.0.1", + "@types/react-dom": "^19.0.2", "postcss-preset-mantine": "^1.17.0", "postcss-simple-vars": "^7.0.1", "tailwindcss": "^3.4.16", diff --git a/src/api/index.ts b/src/api/index.ts index 550fe4a..a4d8618 100644 --- a/src/api/index.ts +++ b/src/api/index.ts @@ -1,10 +1,7 @@ import axios from "axios"; -// export const BASEURL = "https://api.furryeventchina.com"; -export const BASEURL = "http://localhost:8787"; - const Axios = axios.create({ - baseURL: BASEURL, + baseURL: import.meta.env.PUBLIC_API_URL, }); Axios.interceptors.request.use( diff --git a/src/components/Container/index.tsx b/src/components/Container/index.tsx index 30eb773..b3c5ecd 100644 --- a/src/components/Container/index.tsx +++ b/src/components/Container/index.tsx @@ -1,16 +1,16 @@ -import { twMerge } from "tailwind-merge"; +import { twMerge } from 'tailwind-merge'; export default function DefaultContainer( props: React.DetailedHTMLProps< React.HTMLAttributes, HTMLDivElement - > + >, ) { const { children, className, ...reset } = props; return (
{children}
diff --git a/src/components/Error/index.tsx b/src/components/Error/index.tsx new file mode 100644 index 0000000..75e78c4 --- /dev/null +++ b/src/components/Error/index.tsx @@ -0,0 +1,23 @@ +import DefaultContainer from '@/components/Container'; +import { Container, Title, Text, Group, Button } from '@mantine/core'; +import { useNavigate } from 'react-router-dom'; + +export default function LoadError() { + const navigate = useNavigate(); + + return ( + + + 发生了错误... + + 加载数据时发生了错误,最大的可能是这个数据不存在,如果持续遇到这个问题,请把地址报告给开发者。 + + + + + + + ); +} diff --git a/src/components/OrganizationEditor/index.tsx b/src/components/OrganizationEditor/index.tsx deleted file mode 100644 index ae98010..0000000 --- a/src/components/OrganizationEditor/index.tsx +++ /dev/null @@ -1,479 +0,0 @@ -import { - createOrganization, - updateOrganization, -} from "@/api/dashboard/organization"; -import { uploadStatic } from "@/api/dashboard/upload"; -import { - EditableOrganizationSchema, - OrganizationStatus, - OrganizationType, -} from "@/types/organization"; -import { - Box, - Button, - Card, - Center, - Container, - Divider, - Group, - Image, - Modal, - Select, - SimpleGrid, - Stack, - TextInput, - Textarea, - Title, - rem, -} from "@mantine/core"; -import { DatePickerInput } from "@mantine/dates"; -import { Dropzone, FileWithPath, IMAGE_MIME_TYPE } from "@mantine/dropzone"; -import { useForm } from "@mantine/form"; -import { useDisclosure } from "@mantine/hooks"; -import { notifications } from "@mantine/notifications"; -import { IconPhoto, IconUpload, IconX } from "@tabler/icons-react"; -import { pickBy } from "lodash"; -import { useState } from "react"; -import { z } from "zod"; - -function OrganizationEditor({ - organization, - opened, - onClose, -}: { - organization?: OrganizationType; - opened: boolean; - onClose: () => void; -}) { - return ( - - - - ); -} - -function OrganizationEditorContent({ - organization, - onClose, -}: { - organization?: OrganizationType; - onClose: () => void; -}) { - const form = useForm({ - initialValues: { - name: organization?.name || "", - slug: organization?.slug || "", - description: organization?.description || "", - creationTime: organization?.creationTime - ? new Date(organization.creationTime) - : null, - logoUrl: organization?.logoUrl || "", - website: organization?.website || "", - contactMail: organization?.contactMail || "", - status: organization?.status || "", - twitter: organization?.twitter || "", - weibo: organization?.weibo || "", - bilibili: organization?.bilibili || "", - wikifur: organization?.wikifur || "", - qqGroup: organization?.qqGroup || "", - }, - - validate: { - // email: (value) => (/^\S+@\S+$/.test(value) ? null : "Invalid email"), - }, - }); - - type formType = typeof form.values; - - const handleSubmit = async (formData: formType) => { - const validFormData = Object.fromEntries( - Object.entries(formData).filter( - ([key, value]) => value !== null && value !== "" - ) - ); - const validResult = EditableOrganizationSchema.safeParse({ - ...validFormData, - creationTime: formData.creationTime - ? formData.creationTime.toISOString() - : null, - }); - const validPayload = validResult.data; - - console.log(formData, validResult); - - if (validPayload) { - if (organization?.id) { - const res = await updateOrganization({ - ...validPayload, - id: organization.id, - }); - if (res) { - onClose(); - notifications.show({ - title: "更新成功", - message: "更新展商数据成功", - color: "teal", - }); - } - console.log("update res", res); - } else { - const res = await createOrganization(validPayload); - console.log("create res", res); - if (res) { - onClose(); - notifications.show({ - title: "更新成功", - message: "创建展商数据成功", - color: "teal", - }); - } - } - } else { - notifications.show({ - title: "数据校验不通过", - message: "请检查表单", - color: "teal", - }); - } - }; - - return ( - -
- - - 基础信息 - - - - - - ({ - label: EventStatusLabel[EventStatus[key as EventStatusKeyType]], - value: EventStatus[key as EventStatusKeyType], - }))} - {...form.getInputProps("status")} - /> - -