Skip to content

Commit

Permalink
feat: 后台完善分析卡片&增加提示'
Browse files Browse the repository at this point in the history
  • Loading branch information
Mereithhh committed Jul 31, 2022
1 parent cbc5627 commit 11485cf
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 24 deletions.
13 changes: 13 additions & 0 deletions packages/admin/src/components/TipTitle/index.tsx
@@ -0,0 +1,13 @@
import { QuestionCircleOutlined } from '@ant-design/icons';
import { Tooltip } from 'antd';

export default function (props: { tip: string; title: string }) {
return (
<span>
<span style={{ marginRight: 2 }}>{props.title}</span>
<Tooltip title={props.tip}>
<QuestionCircleOutlined />
</Tooltip>
</span>
);
}
15 changes: 13 additions & 2 deletions packages/admin/src/pages/Welcome/tabs/overview.jsx
Expand Up @@ -3,6 +3,7 @@ import { Spin } from 'antd';
import { Area } from '@ant-design/plots';
import { useCallback, useEffect, useMemo, useState } from 'react';
import { getWelcomeData } from '@/services/van-blog/api';
import TipTitle from '@/components/TipTitle';
const { Statistic } = StatisticCard;

const OverView = () => {
Expand Down Expand Up @@ -54,7 +55,12 @@ const OverView = () => {
/>
<StatisticCard
statistic={{
title: '总访客数',
title: (
<TipTitle
title="总访客数"
tip="以浏览器内缓存的唯一标识符为衡量标准计算全站独立访客的数量"
/>
),
value: data?.viewer?.now?.visited || 0,
description: (
<Statistic title="今日新增" value={data?.viewer?.add?.visited || 0} trend="up" />
Expand All @@ -63,7 +69,12 @@ const OverView = () => {
/>
<StatisticCard
statistic={{
title: '总访问量',
title: (
<TipTitle
title="总访问数"
tip="以每一次页面的访问及跳转为衡量标准计算全站的访问数量"
/>
),
value: data?.viewer?.now?.viewer || 0,
description: (
<Statistic title="今日新增" value={data?.viewer?.add?.viewer || 0} trend="up" />
Expand Down
47 changes: 25 additions & 22 deletions packages/admin/src/pages/Welcome/tabs/viewer.jsx
Expand Up @@ -8,7 +8,7 @@ import moment from 'moment';
import ArticleList from '@/components/ArticleList';
import { getRecentTimeDes } from '@/services/van-blog/tool';
import { Link, history } from 'umi';
const { Statistic } = StatisticCard;
import TipTitle from '@/components/TipTitle';

const Viewer = () => {
const [data, setData] = useState();
Expand All @@ -24,23 +24,6 @@ const Viewer = () => {
});
}, [fetchData, setLoading]);

const lineData = useMemo(() => {
const res = [];
for (const each of data?.viewer?.grid || []) {
res.push({
date: each.date,
访客数: each.visited,
访问量: each.viewer,
});
}
return res;
}, [data]);
const lineConfig = {
data: lineData,
padding: 'auto',
xField: 'date',
autoFix: false,
};
const recentHref = useMemo(() => {
if (!data) {
return undefined;
Expand Down Expand Up @@ -129,25 +112,45 @@ const Viewer = () => {
<StatisticCard.Group style={{ marginTop: -16 }}>
<StatisticCard
statistic={{
title: '总访客数',
title: (
<TipTitle
title="总访客数"
tip="以浏览器内缓存的唯一标识符为衡量标准计算全站独立访客的数量"
/>
),
value: data?.totalVisited || 0,
}}
/>
<StatisticCard
statistic={{
title: '总访问量',
title: (
<TipTitle
title="总访问数"
tip="以每一次页面的访问及跳转为衡量标准计算全站的访问数量"
/>
),
value: data?.totalViewer || 0,
}}
/>
<StatisticCard
statistic={{
title: '单篇最高访客数',
title: (
<TipTitle
title="单篇最高访客数"
tip="以浏览器内缓存的唯一标识符为衡量标准计算出单篇文章最高的独立访客数"
/>
),
value: data?.maxArticleVisited || 0,
}}
/>
<StatisticCard
statistic={{
title: '单篇最高访问量',
title: (
<TipTitle
title="单篇最高访问量"
tip="以每一次页面的访问及跳转为衡量标准计算出单篇文章最高的访问量"
/>
),
value: data?.maxArticleViewer || 0,
}}
/>
Expand Down

0 comments on commit 11485cf

Please sign in to comment.