优化类型问题
This commit is contained in:
@@ -9,8 +9,7 @@ import { getTagListAPI } from '@/api/Tag'
|
||||
import { delArticleDataAPI, getArticleListAPI } from '@/api/Article';
|
||||
import type { Tag as ArticleTag } from '@/types/app/tag';
|
||||
import type { Cate } from '@/types/app/cate';
|
||||
import type { Article } from '@/types/app/article';
|
||||
import { FilterArticle, FilterForm } from './type'
|
||||
import type { Article, FilterArticle, FilterForm } from '@/types/app/article';
|
||||
|
||||
import dayjs from 'dayjs';
|
||||
|
||||
@@ -127,10 +126,10 @@ const ArticlePage = () => {
|
||||
const onSubmit = async (values: FilterForm) => {
|
||||
const query: FilterArticle = {
|
||||
key: values.title,
|
||||
startDate: values.createTime ? values.createTime[0].valueOf() + '' : undefined,
|
||||
endDate: values.createTime ? values.createTime[1].valueOf() + '' : undefined,
|
||||
cateIds: values.cateIds,
|
||||
tagId: values.tagId,
|
||||
startDate: values?.createTime[0].valueOf() + '',
|
||||
endDate: values?.createTime[1].valueOf() + '',
|
||||
}
|
||||
|
||||
const { data } = await getArticleListAPI({ query });
|
||||
@@ -142,7 +141,7 @@ const ArticlePage = () => {
|
||||
|
||||
const getCateList = async () => {
|
||||
const { data } = await getCateListAPI()
|
||||
setCateList(data as Cate[])
|
||||
setCateList(data.filter(item => item.type === "cate") as Cate[])
|
||||
}
|
||||
|
||||
const getTagList = async () => {
|
||||
|
||||
11
src/pages/Article/type.d.ts
vendored
11
src/pages/Article/type.d.ts
vendored
@@ -1,11 +0,0 @@
|
||||
export interface FilterForm {
|
||||
title: string,
|
||||
cateIds?: number[],
|
||||
tagId?: number,
|
||||
createTime: Date[]
|
||||
}
|
||||
|
||||
export interface FilterArticle extends FilterData {
|
||||
cateIds?: number[],
|
||||
tagId?: number,
|
||||
}
|
||||
@@ -1,11 +1,11 @@
|
||||
import { useState, useEffect } from 'react';
|
||||
import { Card, message, Table, Popconfirm, Button, Tag, Modal, Form, Input, DatePicker } from 'antd';
|
||||
import { Card, message, Table, Popconfirm, Button, Modal, Form, Input, DatePicker } from 'antd';
|
||||
import { getCommentListAPI } from '@/api/Comment';
|
||||
import { delCommentDataAPI } from '@/api/Comment';
|
||||
import { ColumnsType } from 'antd/es/table';
|
||||
import { titleSty } from '@/styles/sty';
|
||||
import Title from '@/components/Title';
|
||||
import { Comment } from '@/types/app/comment'
|
||||
import { Comment, FilterForm } from '@/types/app/comment'
|
||||
import dayjs from 'dayjs';
|
||||
|
||||
const CommentPage = () => {
|
||||
@@ -18,8 +18,6 @@ const CommentPage = () => {
|
||||
const getCommentList = async () => {
|
||||
const { data } = await getCommentListAPI();
|
||||
|
||||
// 根据时间排序:最新时间在前
|
||||
// const sortedData = (data as Comment[]).sort((a, b) => +b.createTime - +a.createTime);
|
||||
setList(data)
|
||||
setLoading(false)
|
||||
}
|
||||
@@ -43,15 +41,6 @@ const CommentPage = () => {
|
||||
key: 'id',
|
||||
align: "center"
|
||||
},
|
||||
// {
|
||||
// title: '状态',
|
||||
// dataIndex: 'auditStatus',
|
||||
// key: 'auditStatus',
|
||||
// fixed: 'left',
|
||||
// render: (status: number) => status ?
|
||||
// <Tag bordered={false} color="processing">通过</Tag>
|
||||
// : <Tag bordered={false} color="error">待审核</Tag>
|
||||
// },
|
||||
{
|
||||
title: '名称',
|
||||
dataIndex: 'name',
|
||||
@@ -116,14 +105,13 @@ const CommentPage = () => {
|
||||
|
||||
const onSubmit = async (values: FilterForm) => {
|
||||
const query: FilterData = {
|
||||
key: values.title ? values.title : undefined,
|
||||
content: values.content ? values.content : undefined,
|
||||
startDate: values.createTime ? values.createTime[0].valueOf() + '' : undefined,
|
||||
endDate: values.createTime ? values.createTime[1].valueOf() + '' : undefined,
|
||||
key: values?.title,
|
||||
content: values?.content,
|
||||
startDate: values?.createTime[0].valueOf() + '',
|
||||
endDate: values?.createTime[1].valueOf() + '',
|
||||
}
|
||||
|
||||
const { data } = await getCommentListAPI({ query });
|
||||
console.log(data);
|
||||
setList(data)
|
||||
}
|
||||
|
||||
|
||||
@@ -79,9 +79,6 @@ const PublishForm = ({ data, closeModel }: { data: Article, closeModel: () => vo
|
||||
};
|
||||
|
||||
const onSubmit: FormProps<FieldType>['onFinish'] = async (values) => {
|
||||
console.log(values, 777);
|
||||
|
||||
|
||||
values.createTime = values.createTime.valueOf()
|
||||
values.cateIds = [...new Set(values.cateIds?.flat())]
|
||||
|
||||
@@ -135,7 +132,6 @@ const PublishForm = ({ data, closeModel }: { data: Article, closeModel: () => vo
|
||||
multiple
|
||||
fieldNames={{ label: "name", value: "id" }}
|
||||
placeholder="请选择文章分类"
|
||||
onChange={(value) => { console.log(value) }}
|
||||
className="w-full"
|
||||
/>
|
||||
</Form.Item>
|
||||
|
||||
@@ -3,7 +3,7 @@ import { Table, Button, Tag, notification, Card, Popconfirm, Form, Input, DatePi
|
||||
import { titleSty } from '@/styles/sty';
|
||||
import Title from '@/components/Title';
|
||||
import { delFootprintDataAPI, getFootprintListAPI, addFootprintDataAPI, editFootprintDataAPI, getFootprintDataAPI } from '@/api/Footprint';
|
||||
import type { Footprint, FilterFootprint, FilterForm } from '@/types/app/footprint';
|
||||
import type { Footprint, FilterForm } from '@/types/app/footprint';
|
||||
import dayjs from 'dayjs';
|
||||
|
||||
const FootprintPage = () => {
|
||||
@@ -129,7 +129,7 @@ const FootprintPage = () => {
|
||||
const onSubmit = async () => {
|
||||
form.validateFields().then(async (values: Footprint) => {
|
||||
values.createTime = values.createTime.valueOf()
|
||||
values.images = values.images?(values.images as string).split("\n"):[]
|
||||
values.images = values.images ? (values.images as string).split("\n") : []
|
||||
|
||||
if (isMethod === "edit") {
|
||||
await editFootprintDataAPI({ ...footprint, ...values });
|
||||
@@ -147,10 +147,10 @@ const FootprintPage = () => {
|
||||
const closeModel = () => reset();
|
||||
|
||||
const onFilterSubmit = async (values: FilterForm) => {
|
||||
const query: FilterFootprint = {
|
||||
key: values.address ? values.address : null,
|
||||
startDate: values.createTime ? values.createTime[0].valueOf() + '' : null,
|
||||
endDate: values.createTime ? values.createTime[1].valueOf() + '' : null,
|
||||
const query: FilterData = {
|
||||
key: values.address,
|
||||
startDate: values?.createTime[0].valueOf() + '',
|
||||
endDate: values?.createTime[1].valueOf() + '',
|
||||
}
|
||||
|
||||
const { data } = await getFootprintListAPI({ query });
|
||||
|
||||
5
src/pages/Footprint/type.d.ts
vendored
5
src/pages/Footprint/type.d.ts
vendored
@@ -1,5 +0,0 @@
|
||||
export interface FilterForm {
|
||||
content?: string;
|
||||
cateId?: number;
|
||||
createTime?: [moment.Moment, moment.Moment];
|
||||
}
|
||||
12
src/types/app/article.d.ts
vendored
12
src/types/app/article.d.ts
vendored
@@ -14,4 +14,16 @@ export interface Article {
|
||||
view?: number
|
||||
count?: number,
|
||||
createTime?: string,
|
||||
}
|
||||
|
||||
export interface FilterForm {
|
||||
title?: string,
|
||||
cateIds?: number[],
|
||||
tagId?: number,
|
||||
createTime: Date[]
|
||||
}
|
||||
|
||||
export interface FilterArticle extends FilterData {
|
||||
cateIds?: number[],
|
||||
tagId?: number,
|
||||
}
|
||||
6
src/types/app/comment.d.ts
vendored
6
src/types/app/comment.d.ts
vendored
@@ -17,4 +17,10 @@ export interface Info {
|
||||
loading: boolean,
|
||||
list: Comment[],
|
||||
paginate: Page
|
||||
}
|
||||
|
||||
export interface FilterForm {
|
||||
title?: string,
|
||||
content?: string,
|
||||
createTime: Date[]
|
||||
}
|
||||
8
src/types/app/footprint.d.ts
vendored
8
src/types/app/footprint.d.ts
vendored
@@ -8,13 +8,7 @@ export interface Footprint {
|
||||
createTime?: string | Dayjs;
|
||||
}
|
||||
|
||||
export interface FilterFootprint {
|
||||
key?: string | null;
|
||||
startDate?: string | null;
|
||||
endDate?: string | null;
|
||||
}
|
||||
|
||||
export interface FilterForm {
|
||||
address?: string;
|
||||
createTime?: [moment.Moment, moment.Moment];
|
||||
createTime: Date[]
|
||||
}
|
||||
Reference in New Issue
Block a user