Skip to content

Commit dacfc3b

Browse files
author
sheepzh
committed
Optimized analysis (#268)
1 parent 966fa58 commit dacfc3b

File tree

7 files changed

+89
-70
lines changed

7 files changed

+89
-70
lines changed

src/app/components/Analysis/components/Summary/CalendarChart.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,6 @@ function optionOf(data: _Value[], weekDays: string[], timeFormat: timer.app.Time
116116
axisLabel: {
117117
formatter: (x: string) => xAxisLabelMap[x] || '',
118118
interval: 0,
119-
margin: 0,
120119
color: textColor,
121120
},
122121
},

src/app/components/Analysis/index.tsx

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import './style.sass'
1818
import { judgeVirtualFast } from "@util/pattern"
1919
import { initProvider } from "./context"
2020
import { useRequest } from "@app/hooks/useRequest"
21+
import { ElLoadingService } from "element-plus"
2122

2223
type _Queries = {
2324
host: string
@@ -52,13 +53,23 @@ const _default = defineComponent(() => {
5253
const siteFromQuery = getSiteFromQuery()
5354
const site: Ref<timer.site.SiteKey> = ref(siteFromQuery)
5455
const timeFormat: Ref<timer.app.TimeFormat> = ref('default')
56+
const contentId = `analysis-content-` + Date.now()
5557

56-
const { data: rows, refresh } = useRequest(async () => {
58+
const { data: rows, refresh, loading } = useRequest(async () => {
5759
const siteKey = site.value
5860
if (!siteKey) return []
5961
return await query(siteKey)
6062
})
6163

64+
let loadingService: { close: () => void }
65+
watch(loading, () => {
66+
if (loading.value) {
67+
loadingService = ElLoadingService({ target: `#${contentId}`, text: "Loading data..." })
68+
} else {
69+
loadingService?.close?.()
70+
}
71+
})
72+
6273
initProvider(site, timeFormat, rows)
6374

6475
watch(site, refresh)
@@ -72,8 +83,10 @@ const _default = defineComponent(() => {
7283
onTimeFormatChange={val => timeFormat.value = val}
7384
/>
7485
}}>
75-
<Summary />
76-
<Trend />
86+
<div id={contentId}>
87+
<Summary />
88+
<Trend />
89+
</div>
7790
</ContentContainer>
7891
)
7992
})
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
/**
2+
* Copyright (c) 2023 Hengyang Zhang
3+
*
4+
* This software is released under the MIT License.
5+
* https://opensource.org/licenses/MIT
6+
*/
7+
8+
import type { I18nKey } from "@app/locale"
9+
import type { PropType, VNode } from "vue"
10+
11+
import { tN } from "@app/locale"
12+
import { defineComponent } from "vue"
13+
import "./indicator-cell.sass"
14+
import { ElIcon, ElTooltip } from "element-plus"
15+
import { InfoFilled } from "@element-plus/icons-vue"
16+
17+
export type IndicatorProps = {
18+
mainName: string
19+
mainValue: string
20+
subTips?: I18nKey
21+
subValue?: string
22+
subInfo?: string
23+
}
24+
25+
function renderSub(props: IndicatorProps): VNode {
26+
const { subTips, subValue, subInfo } = props
27+
if (!subTips && !subValue) {
28+
return null
29+
}
30+
31+
const subTipsLine = []
32+
const subValueSpan = <span class="kanban-indicator-cell-sub-val">{subValue ?? '-'}</span>
33+
if (subTips) {
34+
subTipsLine.push(...tN(subTips, { value: subValueSpan }))
35+
} else {
36+
subTipsLine.push(subValueSpan)
37+
}
38+
subInfo && subTipsLine.push(
39+
<span class="kanban-indicator-cell-sub-info">
40+
<ElTooltip content={subInfo} placement="bottom">
41+
<ElIcon><InfoFilled /></ElIcon>
42+
</ElTooltip>
43+
</span>
44+
)
45+
return <div class="kanban-indicator-cell-sub-tip">{subTipsLine}</div>
46+
}
47+
48+
const _default = defineComponent({
49+
props: {
50+
mainName: String,
51+
mainValue: String,
52+
subTips: Function as PropType<I18nKey>,
53+
subValue: String,
54+
subInfo: String,
55+
},
56+
setup(props) {
57+
const { mainName, mainValue } = props
58+
return () => (
59+
<div class="kanban-indicator-cell-container">
60+
<div class="kanban-indicator-cell-name">{mainName}</div>
61+
<div class="kanban-indicator-cell-val">{mainValue ?? '-'}</div>
62+
{renderSub(props)}
63+
</div>
64+
)
65+
}
66+
})
67+
68+
export default _default
File renamed without changes.

src/app/components/common/kanban/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
* https://opensource.org/licenses/MIT
66
*/
77

8-
import IndicatorCell from "./indicator-cell"
9-
import IndicatorRow from "./indicator-row"
8+
import IndicatorCell from "./IndicatorCell"
9+
import IndicatorRow from "./IndicatorRow"
1010
import Card from "./card"
1111

1212
export const KanbanIndicatorCell = IndicatorCell

src/app/components/common/kanban/indicator-cell.sass

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,10 @@
1818
font-size: 12px
1919
word-break: break-word
2020
color: var(--el-text-color-secondary)
21+
display: flex
22+
align-items: center
2123
.kanban-indicator-cell-sub-val,.indicator-ring-growth-value
2224
color: var(--el-text-color-primary)
2325
.kanban-indicator-cell-sub-info
24-
vertical-align: sub
26+
margin-top: 1px
2527
margin-left: 2px

src/app/components/common/kanban/indicator-cell.ts

Lines changed: 0 additions & 63 deletions
This file was deleted.

0 commit comments

Comments
 (0)