From 20cfaf00bb40913d4eafd7e7e601281c01d28f14 Mon Sep 17 00:00:00 2001 From: wang_yp <357754663@qq.com> Date: Fri, 14 Mar 2025 22:17:16 +0800 Subject: [PATCH] add animation --- src/components/ali_upload.tsx | 27 +++-------- src/components/edittor.tsx | 57 +++++++++++------------- src/components/form/interface.ts | 21 ++++++++- src/components/form/simple_form.tsx | 24 ++++------ src/components/map/mapUtil.ts | 2 +- src/pages/home/home_check.tsx | 4 +- src/pages/home/home_video.tsx | 3 ++ src/pages/polRegulations/regulations.tsx | 14 ++++-- src/pages/politicalStudy/index.tsx | 30 ++++++------- src/pages/system/banner.tsx | 2 +- src/pages/training/task_archives.tsx | 4 +- src/pages/user/user.tsx | 31 ++++++++----- src/pages/user/user_config.tsx | 42 +++++------------ src/store/user.ts | 8 ++++ src/util/config.ts | 4 +- 15 files changed, 137 insertions(+), 136 deletions(-) diff --git a/src/components/ali_upload.tsx b/src/components/ali_upload.tsx index cea1125..7cd68e7 100644 --- a/src/components/ali_upload.tsx +++ b/src/components/ali_upload.tsx @@ -3,21 +3,7 @@ import { PlusOutlined } from "@ant-design/icons"; import Upload, { RcFile, UploadFile, UploadProps } from "antd/lib/upload"; import { useEffect, useState } from "react"; import Config from "@/util/config"; - -interface UploadFileProps { - imgList: Array; - onChnage: Function; - maxCount?: number; -} - -interface UploadFileEx extends UploadFile { - systemImageId?: number; - bannerName?: string; - file_name?: string; - file_url?: string; - redictUrl?: string; - id?: number; -} +import { UploadFileProps } from "./form/interface"; const getBase64 = (file: RcFile): Promise => new Promise((resolve, reject) => { @@ -45,8 +31,8 @@ const AliUpload = (props: UploadFileProps) => { }; useEffect(() => { - setFileList(props.imgList); - }, [props.imgList]); + setFileList(props.value ?? []); + }, [props.value]); const handleChange: UploadProps["onChange"] = ({ fileList: newFileList }) => { newFileList.forEach((i) => { @@ -54,7 +40,7 @@ const AliUpload = (props: UploadFileProps) => { i.fileName = i.name; }); setFileList(newFileList); - props.onChnage(newFileList); + props.onChange!(newFileList); }; const uploadButton = (
@@ -64,8 +50,9 @@ const AliUpload = (props: UploadFileProps) => { ); return ( -
+
{ maxCount={props.maxCount ?? 4} onChange={handleChange} > - {files.length >= (props.maxCount??4) ? null : uploadButton} + {files.length >= (props.maxCount ?? 4) ? null : uploadButton} void; + value?: string; + onChange?: (value: string) => void; + id?: string; } -function MyEditor(props: EditorProps) { +const MyEditor = (props: EditorProps) => { // editor 实例 const [editor, setEditor] = useState(null); // TS 语法 // 编辑器内容 - const [html, setHtml] = useState("

"); + const [html, setHtml] = useState(""); // 模拟 ajax 请求,异步设置 html useEffect(() => { - if (props.value) { - setHtml(props.value); - } - }, [props]); + setHtml(props.value ?? ""); + }, [props.value]); // 工具栏配置 const toolbarConfig: Partial = {}; // TS 语法 @@ -56,28 +55,26 @@ function MyEditor(props: EditorProps) { }, [editor]); return ( - <> -
- - { - setHtml(editor.getHtml()); - props.onChange(editor.getHtml()); - }} - mode="default" - style={{ height: "500px", overflowY: "hidden" }} - /> -
- +
+ + { + setHtml(editor.getHtml()); + props.onChange!(editor.getHtml()); + }} + mode="default" + style={{ height: "500px", overflowY: "hidden" }} + /> +
); -} +}; export default MyEditor; diff --git a/src/components/form/interface.ts b/src/components/form/interface.ts index 3032725..56a48e8 100644 --- a/src/components/form/interface.ts +++ b/src/components/form/interface.ts @@ -1,4 +1,4 @@ -import { FormInstance } from "antd" +import { FormInstance, UploadFile } from "antd" import React from "react" export enum FormType { input = "input", @@ -42,6 +42,7 @@ export interface SimpleFormData { createCallback?: Function children?: React.ReactElement childrenPosi?: boolean + current?:any layout?: "vertical" | "horizontal" | "inline" } @@ -55,4 +56,20 @@ export interface rules { export interface selectItem { name: string, id: number, -} \ No newline at end of file +} + +export interface UploadFileProps { + value?: Array; + onChange?: (value: Array) => void; + maxCount?: number; + id?: string; +} + +export interface UploadFileEx extends UploadFile { + systemImageId?: number; + bannerName?: string; + file_name?: string; + file_url?: string; + redictUrl?: string; + id?: number; +} diff --git a/src/components/form/simple_form.tsx b/src/components/form/simple_form.tsx index 8959f74..26fd0eb 100644 --- a/src/components/form/simple_form.tsx +++ b/src/components/form/simple_form.tsx @@ -10,6 +10,7 @@ const { TextArea } = Input; const SimpleForm = (props: SimpleFormData) => { const [form] = Form.useForm(); const onFinish = (values: any) => { + console.log("Success:", values); props.onFinish(values); }; useEffect(() => { @@ -22,6 +23,7 @@ const SimpleForm = (props: SimpleFormData) => {
{ { if (Array.isArray(e)) { return e; @@ -125,12 +125,7 @@ const SimpleForm = (props: SimpleFormData) => { return e && e.fileList; }} > - { - form.setFieldValue(v.name, res); - }} - /> + ); case FormType.textarea: @@ -142,7 +137,7 @@ const SimpleForm = (props: SimpleFormData) => { rules={v.rules} >