大改动
This commit is contained in:
@@ -27,11 +27,12 @@ export default () => {
|
|||||||
const { RangePicker } = DatePicker;
|
const { RangePicker } = DatePicker;
|
||||||
|
|
||||||
const getArticleList = async () => {
|
const getArticleList = async () => {
|
||||||
setLoading(true);
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
setLoading(true);
|
||||||
|
|
||||||
const { data } = await getArticleListAPI();
|
const { data } = await getArticleListAPI();
|
||||||
setArticleList(data);
|
setArticleList(data);
|
||||||
|
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
@@ -39,9 +40,9 @@ export default () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const delArticleData = async (id: number) => {
|
const delArticleData = async (id: number) => {
|
||||||
setLoading(true);
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
setLoading(true);
|
||||||
|
|
||||||
// 普通删除:可从回收站恢复
|
// 普通删除:可从回收站恢复
|
||||||
await delArticleDataAPI(id, true);
|
await delArticleDataAPI(id, true);
|
||||||
await getArticleList();
|
await getArticleList();
|
||||||
@@ -151,9 +152,9 @@ export default () => {
|
|||||||
];
|
];
|
||||||
|
|
||||||
const onFilterSubmit = async (values: FilterForm) => {
|
const onFilterSubmit = async (values: FilterForm) => {
|
||||||
setLoading(true)
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
setLoading(true)
|
||||||
|
|
||||||
const query: FilterArticle = {
|
const query: FilterArticle = {
|
||||||
key: values.title,
|
key: values.title,
|
||||||
cateIds: values.cateIds,
|
cateIds: values.cateIds,
|
||||||
@@ -166,6 +167,7 @@ export default () => {
|
|||||||
|
|
||||||
const { data } = await getArticleListAPI({ query });
|
const { data } = await getArticleListAPI({ query });
|
||||||
setArticleList(data);
|
setArticleList(data);
|
||||||
|
|
||||||
setLoading(false)
|
setLoading(false)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
setLoading(false)
|
setLoading(false)
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ const CatePage = () => {
|
|||||||
const { data } = await getCateListAPI();
|
const { data } = await getCateListAPI();
|
||||||
data.sort((a, b) => a.order - b.order)
|
data.sort((a, b) => a.order - b.order)
|
||||||
setList(data);
|
setList(data);
|
||||||
|
|
||||||
setLoading(false)
|
setLoading(false)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
setLoading(false)
|
setLoading(false)
|
||||||
@@ -46,14 +47,16 @@ const CatePage = () => {
|
|||||||
|
|
||||||
const editCateData = async (id: number) => {
|
const editCateData = async (id: number) => {
|
||||||
try {
|
try {
|
||||||
|
setEditLoading(true)
|
||||||
|
|
||||||
setIsMethod("edit");
|
setIsMethod("edit");
|
||||||
setIsModelOpen(true);
|
setIsModelOpen(true);
|
||||||
setEditLoading(true)
|
|
||||||
|
|
||||||
const { data } = await getCateDataAPI(id);
|
const { data } = await getCateDataAPI(id);
|
||||||
setIsCateShow(data.type === "cate" ? false : true);
|
setIsCateShow(data.type === "cate" ? false : true);
|
||||||
setCate(data);
|
setCate(data);
|
||||||
form.setFieldsValue(data);
|
form.setFieldsValue(data);
|
||||||
|
|
||||||
setEditLoading(false)
|
setEditLoading(false)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
setEditLoading(false)
|
setEditLoading(false)
|
||||||
@@ -61,9 +64,9 @@ const CatePage = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const delCateData = async (id: number) => {
|
const delCateData = async (id: number) => {
|
||||||
setLoading(true)
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
setLoading(true)
|
||||||
|
|
||||||
await delCateDataAPI(id);
|
await delCateDataAPI(id);
|
||||||
await getCateList();
|
await getCateList();
|
||||||
message.success('🎉 删除分类成功');
|
message.success('🎉 删除分类成功');
|
||||||
|
|||||||
@@ -150,9 +150,9 @@ export default () => {
|
|||||||
const [replyInfo, setReplyInfo] = useState("")
|
const [replyInfo, setReplyInfo] = useState("")
|
||||||
const [isReplyModalOpen, setIsReplyModalOpen] = useState(false);
|
const [isReplyModalOpen, setIsReplyModalOpen] = useState(false);
|
||||||
const handleReply = async () => {
|
const handleReply = async () => {
|
||||||
setBtnLoading(true)
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
setBtnLoading(true)
|
||||||
|
|
||||||
await addCommentDataAPI({
|
await addCommentDataAPI({
|
||||||
avatar: user.avatar,
|
avatar: user.avatar,
|
||||||
url: web.url,
|
url: web.url,
|
||||||
@@ -169,6 +169,8 @@ export default () => {
|
|||||||
message.success('🎉 回复评论成功');
|
message.success('🎉 回复评论成功');
|
||||||
setIsReplyModalOpen(false)
|
setIsReplyModalOpen(false)
|
||||||
setReplyInfo("")
|
setReplyInfo("")
|
||||||
|
|
||||||
|
setBtnLoading(true)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
setBtnLoading(false)
|
setBtnLoading(false)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,19 +32,20 @@ export default () => {
|
|||||||
// 获取文章数据
|
// 获取文章数据
|
||||||
const getArticleData = async () => {
|
const getArticleData = async () => {
|
||||||
try {
|
try {
|
||||||
|
setLoading(true)
|
||||||
|
|
||||||
const { data } = await getArticleDataAPI(id)
|
const { data } = await getArticleDataAPI(id)
|
||||||
setData(data)
|
setData(data)
|
||||||
setContent(data.content)
|
setContent(data.content)
|
||||||
|
|
||||||
|
setLoading(false)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
setLoading(false)
|
setLoading(false)
|
||||||
}
|
}
|
||||||
|
|
||||||
setLoading(false)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 回显数据
|
// 回显数据
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setLoading(true)
|
|
||||||
setPublishOpen(false)
|
setPublishOpen(false)
|
||||||
|
|
||||||
// 有Id就回显指定的数据
|
// 有Id就回显指定的数据
|
||||||
@@ -93,9 +94,9 @@ export default () => {
|
|||||||
|
|
||||||
// 解析接口数据
|
// 解析接口数据
|
||||||
const parsingData = async (command: string) => {
|
const parsingData = async (command: string) => {
|
||||||
setLoading(true)
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
setLoading(true)
|
||||||
|
|
||||||
const res = await fetch(`/ai/v1/chat/completions`, {
|
const res = await fetch(`/ai/v1/chat/completions`, {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
headers: {
|
headers: {
|
||||||
@@ -142,12 +143,12 @@ export default () => {
|
|||||||
|
|
||||||
// 保留最后一行未处理的数据
|
// 保留最后一行未处理的数据
|
||||||
receivedText = lines[lines.length - 1];
|
receivedText = lines[lines.length - 1];
|
||||||
|
|
||||||
|
setLoading(false)
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
setLoading(false)
|
setLoading(false)
|
||||||
}
|
}
|
||||||
|
|
||||||
setLoading(false)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// AI功能
|
// AI功能
|
||||||
|
|||||||
@@ -32,9 +32,9 @@ export default () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const onSubmit = async () => {
|
const onSubmit = async () => {
|
||||||
setLoading(true)
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
setLoading(true)
|
||||||
|
|
||||||
const data = {
|
const data = {
|
||||||
content,
|
content,
|
||||||
images: JSON.stringify(imageList),
|
images: JSON.stringify(imageList),
|
||||||
@@ -52,29 +52,29 @@ export default () => {
|
|||||||
await addRecordDataAPI(data)
|
await addRecordDataAPI(data)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setLoading(false)
|
||||||
navigate("/record")
|
navigate("/record")
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
setLoading(false)
|
setLoading(false)
|
||||||
}
|
}
|
||||||
|
|
||||||
setLoading(false)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const getRecordData = async () => {
|
const getRecordData = async () => {
|
||||||
try {
|
try {
|
||||||
|
setLoading(true)
|
||||||
|
|
||||||
const { data } = await getRecordDataAPI(id)
|
const { data } = await getRecordDataAPI(id)
|
||||||
setContent(data.content)
|
setContent(data.content)
|
||||||
setImageList(JSON.parse(data.images as string))
|
setImageList(JSON.parse(data.images as string))
|
||||||
|
|
||||||
|
setLoading(false)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
setLoading(false)
|
setLoading(false)
|
||||||
}
|
}
|
||||||
|
|
||||||
setLoading(false)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 回显数据
|
// 回显数据
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setLoading(true)
|
|
||||||
// 有Id就回显指定的数据
|
// 有Id就回显指定的数据
|
||||||
if (id) getRecordData()
|
if (id) getRecordData()
|
||||||
}, [id])
|
}, [id])
|
||||||
|
|||||||
@@ -1,24 +0,0 @@
|
|||||||
export interface Result {
|
|
||||||
timeSpan: string[];
|
|
||||||
fields: string[];
|
|
||||||
items: [
|
|
||||||
string[][],
|
|
||||||
number[][],
|
|
||||||
any[],
|
|
||||||
any[]
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface MonthlySums {
|
|
||||||
[key: string]: {
|
|
||||||
pv: number;
|
|
||||||
ip: number;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface ChartOneState {
|
|
||||||
series: {
|
|
||||||
name: string;
|
|
||||||
data: number[];
|
|
||||||
}[];
|
|
||||||
}
|
|
||||||
@@ -2,9 +2,32 @@ import { useEffect, useState, useCallback, useMemo } from 'react';
|
|||||||
import { Spin } from 'antd';
|
import { Spin } from 'antd';
|
||||||
import { ApexOptions } from 'apexcharts';
|
import { ApexOptions } from 'apexcharts';
|
||||||
import ReactApexChart from 'react-apexcharts';
|
import ReactApexChart from 'react-apexcharts';
|
||||||
import { MonthlySums, ChartOneState } from './type';
|
|
||||||
import dayjs from 'dayjs';
|
import dayjs from 'dayjs';
|
||||||
import { Result } from '../../type';
|
|
||||||
|
interface Result {
|
||||||
|
timeSpan: string[];
|
||||||
|
fields: string[];
|
||||||
|
items: [
|
||||||
|
string[][],
|
||||||
|
number[][],
|
||||||
|
any[],
|
||||||
|
any[]
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
interface MonthlySums {
|
||||||
|
[key: string]: {
|
||||||
|
pv: number;
|
||||||
|
ip: number;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
interface ChartOneState {
|
||||||
|
series: {
|
||||||
|
name: string;
|
||||||
|
data: number[];
|
||||||
|
}[];
|
||||||
|
}
|
||||||
|
|
||||||
export default () => {
|
export default () => {
|
||||||
const [loading, setLoading] = useState<boolean>(false);
|
const [loading, setLoading] = useState<boolean>(false);
|
||||||
@@ -124,9 +147,9 @@ export default () => {
|
|||||||
|
|
||||||
// 获取统计数据
|
// 获取统计数据
|
||||||
const getDataList = useCallback(async () => {
|
const getDataList = useCallback(async () => {
|
||||||
setLoading(true)
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
setLoading(true)
|
||||||
|
|
||||||
const siteId = import.meta.env.VITE_BAIDU_TONGJI_SITE_ID;
|
const siteId = import.meta.env.VITE_BAIDU_TONGJI_SITE_ID;
|
||||||
const token = import.meta.env.VITE_BAIDU_TONGJI_ACCESS_TOKEN;
|
const token = import.meta.env.VITE_BAIDU_TONGJI_ACCESS_TOKEN;
|
||||||
|
|
||||||
@@ -134,16 +157,16 @@ export default () => {
|
|||||||
const data = await response.json();
|
const data = await response.json();
|
||||||
const { result } = data;
|
const { result } = data;
|
||||||
setResult(result);
|
setResult(result);
|
||||||
|
|
||||||
|
setLoading(false);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
setLoading(false)
|
setLoading(false)
|
||||||
}
|
}
|
||||||
|
|
||||||
setLoading(false);
|
|
||||||
}, [startDate, endDate]);
|
}, [startDate, endDate]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
getDataList();
|
getDataList();
|
||||||
}, [getDataList]);
|
}, []);
|
||||||
|
|
||||||
// 切换不同范围的数据
|
// 切换不同范围的数据
|
||||||
const scopeData = useMemo(() => {
|
const scopeData = useMemo(() => {
|
||||||
@@ -239,6 +262,7 @@ export default () => {
|
|||||||
// 当数据发生变化时,更新图表选项和状态
|
// 当数据发生变化时,更新图表选项和状态
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setLoading(true)
|
setLoading(true)
|
||||||
|
|
||||||
setOptions((data) => ({
|
setOptions((data) => ({
|
||||||
...data,
|
...data,
|
||||||
xaxis: { ...options.xaxis, categories: scopeData.categories || [] }
|
xaxis: { ...options.xaxis, categories: scopeData.categories || [] }
|
||||||
|
|||||||
@@ -1,13 +0,0 @@
|
|||||||
export interface MonthlySums {
|
|
||||||
[key: string]: {
|
|
||||||
pv: number;
|
|
||||||
ip: number;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface ChartOneState {
|
|
||||||
series: {
|
|
||||||
name: string;
|
|
||||||
data: number[];
|
|
||||||
}[];
|
|
||||||
}
|
|
||||||
@@ -31,9 +31,9 @@ export default () => {
|
|||||||
|
|
||||||
// 获取统计数据
|
// 获取统计数据
|
||||||
const getDataList = async () => {
|
const getDataList = async () => {
|
||||||
setLoading(true)
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
setLoading(true)
|
||||||
|
|
||||||
const siteId = import.meta.env.VITE_BAIDU_TONGJI_SITE_ID;
|
const siteId = import.meta.env.VITE_BAIDU_TONGJI_SITE_ID;
|
||||||
const token = import.meta.env.VITE_BAIDU_TONGJI_ACCESS_TOKEN;
|
const token = import.meta.env.VITE_BAIDU_TONGJI_ACCESS_TOKEN;
|
||||||
|
|
||||||
@@ -78,11 +78,10 @@ export default () => {
|
|||||||
|
|
||||||
setStats({ pv, ip, bounce: (bounce / count) || 0, avgTime: formatTime(avgTime / count) || "00:00:00" })
|
setStats({ pv, ip, bounce: (bounce / count) || 0, avgTime: formatTime(avgTime / count) || "00:00:00" })
|
||||||
|
|
||||||
|
setLoading(false)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
setLoading(false)
|
setLoading(false)
|
||||||
}
|
}
|
||||||
|
|
||||||
setLoading(false)
|
|
||||||
};
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
|||||||
10
src/pages/Dashboard/components/Stats/type.d.ts
vendored
10
src/pages/Dashboard/components/Stats/type.d.ts
vendored
@@ -1,10 +0,0 @@
|
|||||||
export interface Result {
|
|
||||||
timeSpan: string[];
|
|
||||||
fields: string[];
|
|
||||||
items: [
|
|
||||||
string[][],
|
|
||||||
number[][],
|
|
||||||
any[],
|
|
||||||
any[]
|
|
||||||
];
|
|
||||||
}
|
|
||||||
@@ -25,24 +25,25 @@ export default () => {
|
|||||||
|
|
||||||
const getArticleList = async () => {
|
const getArticleList = async () => {
|
||||||
try {
|
try {
|
||||||
|
setLoading(true);
|
||||||
|
|
||||||
const { data } = await getArticleListAPI({ query: { isDel: 1 } });
|
const { data } = await getArticleListAPI({ query: { isDel: 1 } });
|
||||||
setArticleList(data as Article[]);
|
setArticleList(data);
|
||||||
|
|
||||||
|
setLoading(false);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
setLoading(false);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setLoading(true);
|
|
||||||
getArticleList()
|
getArticleList()
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const delArticleData = async (id: number) => {
|
const delArticleData = async (id: number) => {
|
||||||
setLoading(true);
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
setLoading(true);
|
||||||
|
|
||||||
// 严格删除:彻底从数据库删除,无法恢复
|
// 严格删除:彻底从数据库删除,无法恢复
|
||||||
await delArticleDataAPI(id);
|
await delArticleDataAPI(id);
|
||||||
await getArticleList();
|
await getArticleList();
|
||||||
@@ -55,12 +56,14 @@ export default () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const reductionArticleData = async (id: number) => {
|
const reductionArticleData = async (id: number) => {
|
||||||
setLoading(true);
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
setLoading(true);
|
||||||
|
|
||||||
await reductionArticleDataAPI(id)
|
await reductionArticleDataAPI(id)
|
||||||
navigate("/article")
|
|
||||||
notification.success({ message: '🎉 还原文章成功' })
|
notification.success({ message: '🎉 还原文章成功' })
|
||||||
|
navigate("/article")
|
||||||
|
|
||||||
|
setLoading(false)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,23 +23,25 @@ export default () => {
|
|||||||
|
|
||||||
const getArticleList = async () => {
|
const getArticleList = async () => {
|
||||||
try {
|
try {
|
||||||
|
setLoading(true)
|
||||||
|
|
||||||
const { data } = await getArticleListAPI({ query: { isDraft: 1 } });
|
const { data } = await getArticleListAPI({ query: { isDraft: 1 } });
|
||||||
setArticleList(data as Article[]);
|
setArticleList(data as Article[]);
|
||||||
|
|
||||||
|
setLoading(false)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
}
|
}
|
||||||
setLoading(false)
|
|
||||||
};
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setLoading(true)
|
|
||||||
getArticleList()
|
getArticleList()
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const delArticleData = async (id: number) => {
|
const delArticleData = async (id: number) => {
|
||||||
setLoading(true);
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
setLoading(true);
|
||||||
|
|
||||||
await delArticleDataAPI(id);
|
await delArticleDataAPI(id);
|
||||||
await getArticleList();
|
await getArticleList();
|
||||||
form.resetFields()
|
form.resetFields()
|
||||||
|
|||||||
@@ -36,56 +36,56 @@ export default () => {
|
|||||||
|
|
||||||
// 获取目录列表
|
// 获取目录列表
|
||||||
const getDirList = async () => {
|
const getDirList = async () => {
|
||||||
setLoading(true)
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
setLoading(true)
|
||||||
|
|
||||||
const { data } = await getDirListAPI()
|
const { data } = await getDirListAPI()
|
||||||
setDirList(data)
|
setDirList(data)
|
||||||
|
|
||||||
|
setLoading(false)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
setLoading(false)
|
setLoading(false)
|
||||||
}
|
}
|
||||||
|
|
||||||
setLoading(false)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取指定目录的文件列表
|
// 获取指定目录的文件列表
|
||||||
const getFileList = async (dir: string) => {
|
const getFileList = async (dir: string) => {
|
||||||
setLoading(true)
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
setLoading(true)
|
||||||
|
|
||||||
const { data } = await getFileListAPI(dir)
|
const { data } = await getFileListAPI(dir)
|
||||||
if (!fileList.length && !data.length) message.error("该目录中没有文件")
|
if (!fileList.length && !data.length) message.error("该目录中没有文件")
|
||||||
setFileList(data)
|
setFileList(data)
|
||||||
|
|
||||||
|
setLoading(false)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
setLoading(false)
|
setLoading(false)
|
||||||
}
|
}
|
||||||
|
|
||||||
setLoading(false)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 删除图片
|
// 删除图片
|
||||||
const onDeleteImage = async (data: File) => {
|
const onDeleteImage = async (data: File) => {
|
||||||
setBtnLoading(true)
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
setBtnLoading(true)
|
||||||
|
|
||||||
await delFileDataAPI(data.url)
|
await delFileDataAPI(data.url)
|
||||||
await getFileList(dirName)
|
await getFileList(dirName)
|
||||||
message.success("🎉 删除图片成功")
|
message.success("🎉 删除图片成功")
|
||||||
setFile({} as File)
|
setFile({} as File)
|
||||||
setOpenFileInfoDrawer(false)
|
setOpenFileInfoDrawer(false)
|
||||||
setOpenFilePreviewDrawer(false)
|
setOpenFilePreviewDrawer(false)
|
||||||
|
|
||||||
|
setBtnLoading(false)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
setBtnLoading(false)
|
setBtnLoading(false)
|
||||||
}
|
}
|
||||||
|
|
||||||
setBtnLoading(false)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 下载图片
|
// 下载图片
|
||||||
const onDownloadImage = (data: File) => {
|
const onDownloadImage = (data: File) => {
|
||||||
setDownloadLoading(true)
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
setDownloadLoading(true)
|
||||||
|
|
||||||
fetch(data.url)
|
fetch(data.url)
|
||||||
.then((response) => response.blob())
|
.then((response) => response.blob())
|
||||||
.then((blob) => {
|
.then((blob) => {
|
||||||
@@ -98,11 +98,11 @@ export default () => {
|
|||||||
URL.revokeObjectURL(url);
|
URL.revokeObjectURL(url);
|
||||||
link.remove();
|
link.remove();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
setDownloadLoading(false)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
setDownloadLoading(false)
|
setDownloadLoading(false)
|
||||||
}
|
}
|
||||||
|
|
||||||
setDownloadLoading(false)
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// 打开目录
|
// 打开目录
|
||||||
|
|||||||
@@ -129,9 +129,9 @@ export default () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const editFootprintData = async (id: number) => {
|
const editFootprintData = async (id: number) => {
|
||||||
setEditLoading(true);
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
setEditLoading(true);
|
||||||
|
|
||||||
setIsMethod("edit");
|
setIsMethod("edit");
|
||||||
setIsModelOpen(true);
|
setIsModelOpen(true);
|
||||||
|
|
||||||
@@ -142,17 +142,17 @@ export default () => {
|
|||||||
|
|
||||||
setFootprint(data);
|
setFootprint(data);
|
||||||
form.setFieldsValue(data);
|
form.setFieldsValue(data);
|
||||||
|
|
||||||
|
setEditLoading(false);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
setEditLoading(false);
|
setEditLoading(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
setEditLoading(false);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const onSubmit = async () => {
|
const onSubmit = async () => {
|
||||||
setBtnLoading(true)
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
setBtnLoading(true)
|
||||||
|
|
||||||
form.validateFields().then(async (values: Footprint) => {
|
form.validateFields().then(async (values: Footprint) => {
|
||||||
values.createTime = values.createTime.valueOf()
|
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") : []
|
||||||
@@ -166,6 +166,7 @@ export default () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
await getFootprintList();
|
await getFootprintList();
|
||||||
|
setBtnLoading(false)
|
||||||
reset()
|
reset()
|
||||||
});
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@@ -176,9 +177,9 @@ export default () => {
|
|||||||
const closeModel = () => reset();
|
const closeModel = () => reset();
|
||||||
|
|
||||||
const onFilterSubmit = async (values: FilterForm) => {
|
const onFilterSubmit = async (values: FilterForm) => {
|
||||||
setLoading(true)
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
setLoading(true)
|
||||||
|
|
||||||
const query: FilterData = {
|
const query: FilterData = {
|
||||||
key: values.address,
|
key: values.address,
|
||||||
startDate: values.createTime && values.createTime[0].valueOf() + '',
|
startDate: values.createTime && values.createTime[0].valueOf() + '',
|
||||||
@@ -187,18 +188,18 @@ export default () => {
|
|||||||
|
|
||||||
const { data } = await getFootprintListAPI({ query });
|
const { data } = await getFootprintListAPI({ query });
|
||||||
setFootprintList(data);
|
setFootprintList(data);
|
||||||
|
|
||||||
|
setLoading(false)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
setLoading(false)
|
setLoading(false)
|
||||||
}
|
}
|
||||||
|
|
||||||
setLoading(false)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 通过详细地址获取纬度
|
// 通过详细地址获取纬度
|
||||||
const getGeocode = async () => {
|
const getGeocode = async () => {
|
||||||
setEditLoading(true)
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
setEditLoading(true)
|
||||||
|
|
||||||
const address = form.getFieldValue("address")
|
const address = form.getFieldValue("address")
|
||||||
|
|
||||||
const { data } = await axios.get('https://restapi.amap.com/v3/geocode/geo', {
|
const { data } = await axios.get('https://restapi.amap.com/v3/geocode/geo', {
|
||||||
@@ -215,17 +216,15 @@ export default () => {
|
|||||||
// 立即触发校验
|
// 立即触发校验
|
||||||
form.validateFields(['position']);
|
form.validateFields(['position']);
|
||||||
|
|
||||||
setEditLoading(false)
|
|
||||||
|
|
||||||
return data.geocodes[0].location;
|
return data.geocodes[0].location;
|
||||||
} else {
|
} else {
|
||||||
message.warning('未找到该地址的经纬度');
|
message.warning('未找到该地址的经纬度');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setEditLoading(false)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
setEditLoading(false)
|
setEditLoading(false)
|
||||||
}
|
}
|
||||||
|
|
||||||
setEditLoading(false)
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -24,6 +24,8 @@ export default () => {
|
|||||||
// 从github获取最近10次迭代记录
|
// 从github获取最近10次迭代记录
|
||||||
const getCommitData = async (project: string) => {
|
const getCommitData = async (project: string) => {
|
||||||
try {
|
try {
|
||||||
|
setLoading(true)
|
||||||
|
|
||||||
const res = await fetch(`https://api.github.com/repos/LiuYuYang01/${project}/commits?per_page=10`)
|
const res = await fetch(`https://api.github.com/repos/LiuYuYang01/${project}/commits?per_page=10`)
|
||||||
const data = await res.json()
|
const data = await res.json()
|
||||||
const result = data?.map((item: Commit) => (
|
const result = data?.map((item: Commit) => (
|
||||||
@@ -47,11 +49,11 @@ export default () => {
|
|||||||
setServer_IterativeRecording(result)
|
setServer_IterativeRecording(result)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setLoading(false)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
setLoading(false)
|
setLoading(false)
|
||||||
}
|
}
|
||||||
|
|
||||||
setLoading(false)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
|||||||
@@ -7,19 +7,21 @@ import { loginDataAPI } from '@/api/User';
|
|||||||
import { useUserStore } from '@/stores';
|
import { useUserStore } from '@/stores';
|
||||||
|
|
||||||
export default () => {
|
export default () => {
|
||||||
|
const navigate = useNavigate();
|
||||||
|
const location = useLocation();
|
||||||
|
const store = useUserStore();
|
||||||
|
|
||||||
const [loading, setLoading] = useState(false)
|
const [loading, setLoading] = useState(false)
|
||||||
|
|
||||||
const [form] = useForm();
|
const [form] = useForm();
|
||||||
|
|
||||||
const [isPassVisible, setIsPassVisible] = useState(false);
|
const [isPassVisible, setIsPassVisible] = useState(false);
|
||||||
const store = useUserStore();
|
|
||||||
const navigate = useNavigate();
|
|
||||||
const location = useLocation();
|
|
||||||
const returnUrl = new URLSearchParams(location.search).get('returnUrl') || '/';
|
const returnUrl = new URLSearchParams(location.search).get('returnUrl') || '/';
|
||||||
|
|
||||||
const onSubmit = async () => {
|
const onSubmit = async () => {
|
||||||
setLoading(true)
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
setLoading(true)
|
||||||
|
|
||||||
const values = await form.validateFields();
|
const values = await form.validateFields();
|
||||||
const { data } = await loginDataAPI(values);
|
const { data } = await loginDataAPI(values);
|
||||||
|
|
||||||
@@ -33,12 +35,11 @@ export default () => {
|
|||||||
description: `Hello ${data.user.name} 欢迎回来`,
|
description: `Hello ${data.user.name} 欢迎回来`,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
setLoading(false)
|
||||||
navigate(returnUrl);
|
navigate(returnUrl);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
setLoading(false)
|
setLoading(false)
|
||||||
}
|
}
|
||||||
|
|
||||||
setLoading(false)
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -86,25 +86,26 @@ export default () => {
|
|||||||
|
|
||||||
const getOssList = async () => {
|
const getOssList = async () => {
|
||||||
try {
|
try {
|
||||||
|
setLoading(true);
|
||||||
|
|
||||||
const { data } = await getOssListAPI();
|
const { data } = await getOssListAPI();
|
||||||
setOssList(data);
|
setOssList(data);
|
||||||
|
|
||||||
|
setLoading(false);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
setLoading(false)
|
setLoading(false)
|
||||||
}
|
}
|
||||||
|
|
||||||
setLoading(false);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setLoading(true);
|
|
||||||
getOssList();
|
getOssList();
|
||||||
getOssPlatformList()
|
getOssPlatformList()
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const enableOssData = async (id: number) => {
|
const enableOssData = async (id: number) => {
|
||||||
setLoading(true)
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
setLoading(true)
|
||||||
|
|
||||||
await enableOssDataAPI(id);
|
await enableOssDataAPI(id);
|
||||||
await getOssList();
|
await getOssList();
|
||||||
message.success('启用成功');
|
message.success('启用成功');
|
||||||
@@ -114,9 +115,9 @@ export default () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const disableOssData = async (id: number) => {
|
const disableOssData = async (id: number) => {
|
||||||
setLoading(true)
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
setLoading(true)
|
||||||
|
|
||||||
await disableOssDataAPI(id);
|
await disableOssDataAPI(id);
|
||||||
await getOssList();
|
await getOssList();
|
||||||
message.success('禁用成功');
|
message.success('禁用成功');
|
||||||
@@ -126,25 +127,25 @@ export default () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const editOssData = async (record: Oss) => {
|
const editOssData = async (record: Oss) => {
|
||||||
setEditLoading(true)
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
setEditLoading(true)
|
||||||
|
|
||||||
setIsModalOpen(true);
|
setIsModalOpen(true);
|
||||||
|
|
||||||
const { data } = await getOssDataAPI(record.id)
|
const { data } = await getOssDataAPI(record.id)
|
||||||
setOss(data);
|
setOss(data);
|
||||||
form.setFieldsValue(data);
|
form.setFieldsValue(data);
|
||||||
|
|
||||||
|
setEditLoading(false)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
setEditLoading(false)
|
setEditLoading(false)
|
||||||
}
|
}
|
||||||
|
|
||||||
setEditLoading(false)
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const delOssData = async (id: number) => {
|
const delOssData = async (id: number) => {
|
||||||
setLoading(true);
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
setLoading(true);
|
||||||
|
|
||||||
await delOssDataAPI(id);
|
await delOssDataAPI(id);
|
||||||
await getOssList();
|
await getOssList();
|
||||||
message.success('🎉 删除存储配置成功');
|
message.success('🎉 删除存储配置成功');
|
||||||
@@ -166,9 +167,9 @@ export default () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const onSubmit = async () => {
|
const onSubmit = async () => {
|
||||||
setBtnLoading(true);
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
setBtnLoading(true);
|
||||||
|
|
||||||
const values = await form.validateFields();
|
const values = await form.validateFields();
|
||||||
|
|
||||||
if (oss.id) {
|
if (oss.id) {
|
||||||
@@ -179,15 +180,14 @@ export default () => {
|
|||||||
message.success('🎉 新增存储配置成功');
|
message.success('🎉 新增存储配置成功');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
await getOssList();
|
||||||
setIsModalOpen(false);
|
setIsModalOpen(false);
|
||||||
getOssList();
|
|
||||||
form.resetFields();
|
form.resetFields();
|
||||||
|
|
||||||
setBtnLoading(false);
|
setBtnLoading(false);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
setBtnLoading(false);
|
setBtnLoading(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
setBtnLoading(false)
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
Reference in New Issue
Block a user