Skip to content

Commit 2c30635

Browse files
committed
style: beautify ui
1 parent 9af00b2 commit 2c30635

File tree

24 files changed

+146
-181
lines changed

24 files changed

+146
-181
lines changed

src/i18n/message/app/dashboard-resource.json

Lines changed: 3 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,7 @@
55
"title1": "近一年上网总时长不足 1 小时"
66
},
77
"topK": {
8-
"title": "近 {day} 天最常访问 TOP {k}",
9-
"filter": {
10-
"chartType": {
11-
"pie": "玫瑰图",
12-
"bar": "条形图",
13-
"halfPie": "半环图"
14-
}
15-
}
8+
"title": "近 {day} 天最常访问 TOP {k}"
169
},
1710
"indicator": {
1811
"installedDays": "已使用 {number} 天",
@@ -30,14 +23,7 @@
3023
"title1": "近一年瀏覽時數少於 1 小時"
3124
},
3225
"topK": {
33-
"title": "近 {day} 天最常造訪 TOP {k}",
34-
"filter": {
35-
"chartType": {
36-
"pie": "玫瑰圖",
37-
"bar": "條形圖",
38-
"halfPie": "半環圖"
39-
}
40-
}
26+
"title": "近 {day} 天最常造訪 TOP {k}"
4127
},
4228
"indicator": {
4329
"installedDays": "已使用 {number} 天",
@@ -55,14 +41,7 @@
5541
"title1": "Browsed less than 1 hour last year"
5642
},
5743
"topK": {
58-
"title": "TOP {k} most visited in the past {day} days",
59-
"filter": {
60-
"chartType": {
61-
"pie": "Nightingale",
62-
"bar": "Bar",
63-
"halfPie": "Half Doughnut"
64-
}
65-
}
44+
"title": "TOP {k} most visited in the past {day} days"
6645
},
6746
"indicator": {
6847
"installedDays": "Installed for {number} days",

src/i18n/message/app/dashboard.ts

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,6 @@ export type DashboardMessage = {
1414
},
1515
topK: {
1616
title: string
17-
filter: {
18-
chartType: {
19-
pie: string
20-
bar: string
21-
halfPie: string
22-
}
23-
}
2417
}
2518
indicator: {
2619
installedDays: string

src/pages/app/components/Dashboard/DashboardCard.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const _default = defineComponent<{ span: number }>(props => {
1313

1414
return () => (
1515
<ElCol span={props.span}>
16-
<ElCard style={{ height: "100%" }} v-slots={slots} />
16+
<ElCard style={{ height: '320px' }} v-slots={slots} />
1717
</ElCol>
1818
)
1919
}, { props: ['span'] })

src/pages/app/components/Dashboard/components/Calendar/index.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import { t } from "@app/locale"
1111
import { REPORT_ROUTE } from "@app/router/constants"
1212
import { useRequest } from "@hooks"
1313
import { useEcharts } from "@hooks/useEcharts"
14+
import Flex from "@pages/components/Flex"
1415
import weekHelper from "@service/components/week-helper"
1516
import statService from "@service/stat-service"
1617
import { groupBy, sum } from "@util/array"
@@ -80,10 +81,10 @@ const _default = defineComponent(() => {
8081
})
8182

8283
return () => (
83-
<div class="calendar-container">
84+
<Flex height="100%" gap={4} column>
8485
<ChartTitle text={titleText(data.value)} />
8586
<div ref={elRef} style={{ flex: 1 }} />
86-
</div>
87+
</Flex>
8788
)
8889
})
8990

src/pages/app/components/Dashboard/components/Indicator/index.tsx renamed to src/pages/app/components/Dashboard/components/Indicator.tsx

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@ import NumberGrow from "@app/components/common/NumberGrow"
99
import { tN, type I18nKey } from "@app/locale"
1010
import PeriodDatabase from "@db/period-database"
1111
import { Sunrise } from "@element-plus/icons-vue"
12-
import { useRequest } from "@hooks"
12+
import { useRequest, useXsState } from "@hooks"
13+
import Flex from "@pages/components/Flex"
1314
import statService from "@service/stat-service"
1415
import { calcMostPeriodOf2Hours } from "@util/period"
1516
import { getStartOfDay, MILL_PER_DAY, MILL_PER_MINUTE } from "@util/time"
1617
import { ElIcon } from "element-plus"
1718
import { computed, defineComponent, toRef, type VNode } from "vue"
18-
import "./style"
1919

2020
const periodDatabase = new PeriodDatabase(chrome.storage.local)
2121

@@ -84,7 +84,7 @@ const IndicatorLabel = defineComponent<Props>(props => {
8484
const i18nParam = computed(() => computeI18nParam(param.value, props.duration))
8585

8686
return () => (
87-
<div class="indicator-label" >
87+
<div style={{ paddingInlineStart: '10px', paddingBottom: '10px', fontSize: '15px' }}>
8888
{param.value && tN(props.path, i18nParam.value)}
8989
</div>
9090
)
@@ -100,15 +100,16 @@ const computeMost2HourParam = (value: _Value | undefined): { start: number, end:
100100

101101
const _default = defineComponent(() => {
102102
const { data } = useRequest(query)
103+
const isXs = useXsState()
103104
const most2HourParam = computed(() => computeMost2HourParam(data.value))
104105

105106
return () => (
106-
<div class="indicator-container">
107-
<div class="indicator-icon-header">
108-
<ElIcon>
107+
<Flex column gap={4} style={{ textAlign: isXs.value ? 'center' : undefined }}>
108+
<Flex align="center" justify="center" marginBlock="0 15px">
109+
<ElIcon size={45}>
109110
<Sunrise />
110111
</ElIcon>
111-
</div>
112+
</Flex>
112113
<IndicatorLabel
113114
v-show={data.value?.installedDays}
114115
path={msg => msg.dashboard.indicator.installedDays}
@@ -130,7 +131,7 @@ const _default = defineComponent(() => {
130131
param={most2HourParam.value}
131132
duration={2.25}
132133
/>
133-
</div>
134+
</Flex>
134135
)
135136
})
136137

src/pages/app/components/Dashboard/components/Indicator/style.sass

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

src/pages/app/components/Dashboard/components/MonthOnMonth/Wrapper.ts

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -75,15 +75,27 @@ function optionOf(lastPeriodItems: Row[], thisPeriodItems: Row[], domWidth: numb
7575
stack: "one",
7676
type: 'bar',
7777
barCategoryGap: `${domWidth < 500 ? 30 : 55}%`,
78-
itemStyle: { color: color1, borderRadius: [10, 10, 0, 0] },
79-
data: thisPeriodItems.map(row => ({ value: row.total, row })),
78+
itemStyle: { color: color1 },
79+
data: thisPeriodItems.map((row, idx) => {
80+
const otherIsEmpty = lastPeriodItems[idx].total === 0
81+
return {
82+
value: row.total, row,
83+
itemStyle: { borderRadius: otherIsEmpty ? 10 : [10, 10, 0, 0] },
84+
}
85+
}),
8086
}, {
8187
name: "Last Month",
8288
stack: "one",
8389
type: 'bar',
84-
itemStyle: { color: color2, borderRadius: [0, 0, 10, 10] },
85-
data: lastPeriodItems.map(row => ({ value: -row.total, row })),
86-
}
90+
itemStyle: { color: color2 },
91+
data: lastPeriodItems.map((row, idx) => {
92+
const otherIsEmpty = thisPeriodItems[idx].total === 0
93+
return {
94+
value: -row.total, row,
95+
itemStyle: { borderRadius: otherIsEmpty ? 10 : [0, 0, 10, 10] },
96+
}
97+
}),
98+
},
8799
],
88100
}
89101
}

src/pages/app/components/Dashboard/components/MonthOnMonth/index.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { t } from "@app/locale"
22
import { useEcharts } from "@hooks/useEcharts"
3+
import Flex from "@pages/components/Flex"
34
import statService from "@service/stat-service"
45
import { groupBy, sum } from "@util/array"
56
import DateIterator from "@util/date-iterator"
@@ -46,10 +47,10 @@ const fetchData = async (): Promise<[thisMonth: Row[], lastMonth: Row[]]> => {
4647
const _default = defineComponent(() => {
4748
const { elRef } = useEcharts(Wrapper, fetchData)
4849
return () => (
49-
<div class="mom-container">
50+
<Flex height="100%" column gap={4}>
5051
<ChartTitle text={t(msg => msg.dashboard.monthOnMonth.title, { k: TOP_NUM })} />
5152
<div ref={elRef} style={{ flex: 1 }} />
52-
</div>
53+
</Flex>
5354
)
5455
})
5556

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,12 @@
11
import { useEcharts } from "@hooks/useEcharts"
2-
import { defineComponent, type StyleValue } from "vue"
2+
import { defineComponent } from "vue"
33
import { useTopKValue } from "../context"
44
import Wrapper from "./Wrapper"
55

6-
const CONTAINER_STYLE: StyleValue = {
7-
width: "100%",
8-
height: "220%",
9-
}
10-
116
const _default = defineComponent(() => {
127
const value = useTopKValue()
138
const { elRef } = useEcharts(Wrapper, value, { manual: true })
14-
return () => <div style={CONTAINER_STYLE} ref={elRef} />
9+
return () => <div style={{ width: '100%' }} ref={elRef} />
1510
})
1611

1712
export default _default

src/pages/app/components/Dashboard/components/TopKVisit/Filter.tsx

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

0 commit comments

Comments
 (0)