From 7a7305e0bf72930617f3820c76ca3f1dae302dc0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Liu=20=E5=AE=87=E9=98=B3?= Date: Mon, 18 Nov 2024 14:03:02 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8A=9F=E8=83=BD=EF=BC=9A=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E9=82=AE=E7=AE=B1=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/Project.ts | 10 +++-- .../Other/components/Email/index.tsx | 40 ++++++++++++++----- src/types/app/project.d.ts | 5 +++ 3 files changed, 43 insertions(+), 12 deletions(-) diff --git a/src/api/Project.ts b/src/api/Project.ts index 333b593..0550c93 100644 --- a/src/api/Project.ts +++ b/src/api/Project.ts @@ -1,5 +1,5 @@ import Request from '@/utils/request' -import { System, Web, Theme } from '@/types/app/project' +import { System, Web, Theme, Other } from '@/types/app/project' // 获取系统配置信息 export const getSystemDataAPI = () => Request("GET", "/project/system") @@ -12,8 +12,12 @@ export const editWebDataAPI = (data: Web) => Request("PATCH", "/project/web // 获取主题配置信息 export const getThemeDataAPI = () => Request("GET", "/project/theme") -// export const getThemeDataAPI = () => Request("GET", "/project/layout") // 修改主题配置信息 export const editThemeDataAPI = (data: Theme) => Request("PATCH", "/project/theme", { data }) -// export const editThemeDataAPI = (data: Theme) => Request("PATCH", "/project/layout", { data }) \ No newline at end of file + +// 获取其他配置信息 +export const getOtherDataAPI = () => Request("GET", "/project/other") + +// 修改其他配置信息 +export const editOtherDataAPI = (data: Other) => Request("PATCH", "/project/other", { data }) \ No newline at end of file diff --git a/src/pages/Setup/components/Other/components/Email/index.tsx b/src/pages/Setup/components/Other/components/Email/index.tsx index ed0578d..b122090 100644 --- a/src/pages/Setup/components/Other/components/Email/index.tsx +++ b/src/pages/Setup/components/Other/components/Email/index.tsx @@ -1,10 +1,34 @@ -import { Button, Form, Input } from "antd" +import { Button, Form, Input, message, Spin } from "antd" +import { editOtherDataAPI, getOtherDataAPI } from "@/api/Project"; +import { useEffect, useState } from "react"; + +interface EmailForm { + host: string, + port: number, + username: string, + password: string +} export default () => { + const [loading, setLoading] = useState(false) const [form] = Form.useForm(); - const handleSubmit = async (values) => { + const getOtherData = async () => { + const { data } = await getOtherDataAPI() + form.setFieldsValue(JSON.parse(data.email)) + } + useEffect(() => { + getOtherData() + }, []) + + const handleSubmit = async (values: EmailForm) => { + setLoading(true) + await editOtherDataAPI({ + email: JSON.stringify(values) + }) + message.success("🎉 修改配置成功"); + setLoading(false) }; return ( @@ -17,26 +41,24 @@ export default () => { onFinish={handleSubmit} className="w-full lg:w-[500px] md:ml-10" > - + - + - + - + - + diff --git a/src/types/app/project.d.ts b/src/types/app/project.d.ts index 5afaf27..7b26001 100644 --- a/src/types/app/project.d.ts +++ b/src/types/app/project.d.ts @@ -41,4 +41,9 @@ export interface Theme { swiperText: string, social: string, covers: string +} + +// 其他配置 +export interface Other { + email: string } \ No newline at end of file