Skip to content

Commit e0e4021

Browse files
author
sheepzh
committed
Deprecate total time (#166)
1 parent 4ba86ae commit e0e4021

File tree

11 files changed

+42
-66
lines changed

11 files changed

+42
-66
lines changed

global.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,7 @@ declare namespace timer {
184184
*/
185185
type Dimension =
186186
// Running time
187+
// @deprecated v1.3.4
187188
| 'total'
188189
// Focus time
189190
| 'focus'

src/app/components/option/components/popup.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,11 @@ const _default = defineComponent({
103103
name: "PopupOptionContainer",
104104
setup(_props, ctx) {
105105
const option: UnwrapRef<timer.option.PopupOption> = reactive(defaultPopup())
106-
optionService.getAllOption().then(currentVal => copy(option, currentVal))
106+
optionService.getAllOption().then(currentVal => {
107+
// Remove total @since v1.3.4
108+
currentVal.defaultType === 'total' && (currentVal.defaultType = 'focus')
109+
copy(option, currentVal)
110+
})
107111
ctx.expose({
108112
async reset() {
109113
copy(option, defaultPopup())

src/app/components/report/table/columns/total.ts

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,22 @@
88
import type { PropType } from "vue"
99

1010
import { t } from "@app/locale"
11-
import { ElTableColumn } from "element-plus"
11+
import { ElIcon, ElTableColumn, ElTooltip } from "element-plus"
1212
import { defineComponent, h } from "vue"
1313
import { periodFormatter } from "../../formatter"
14+
import { QuestionFilled } from "@element-plus/icons-vue"
1415

15-
const columnLabel = t(msg => msg.item.total)
16+
function renderHeader() {
17+
return [
18+
t(msg => msg.item.total),
19+
h(ElTooltip, {
20+
content: t(msg => msg.item.totalTip),
21+
placement: 'top',
22+
}, () => h(ElIcon, {
23+
style: { paddingLeft: '3px' },
24+
}, () => h(QuestionFilled)))
25+
]
26+
}
1627

1728
const _default = defineComponent({
1829
name: "TotalColumn",
@@ -24,11 +35,10 @@ const _default = defineComponent({
2435
setup(props) {
2536
return () => h(ElTableColumn, {
2637
prop: "total",
27-
label: columnLabel,
2838
minWidth: 130,
2939
align: "center",
30-
sortable: "custom"
3140
}, {
41+
header: renderHeader,
3242
default: ({ row }: { row: timer.stat.Row }) => periodFormatter(row.total, props.timeFormat)
3343
})
3444
}

src/app/components/report/table/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,8 @@ const _default = defineComponent({
6767
onAliasChange: (host: string, newAlias: string) => ctx.emit("aliasChange", host, newAlias)
6868
}))
6969
result.push(h(FocusColumn, { timeFormat: props.timeFormat }))
70-
result.push(h(TotalColumn, { timeFormat: props.timeFormat }))
7170
result.push(h(TimeColumn))
71+
result.push(h(TotalColumn, { timeFormat: props.timeFormat }))
7272
result.push(h(OperationColumn, {
7373
mergeDate: props.mergeDate,
7474
mergeHost: props.mergeHost,

src/app/components/trend/components/chart/wrapper.ts

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ function optionOf(
8585
xAxisData: string[],
8686
subtext: string,
8787
timeFormat: timer.app.TimeFormat,
88-
[focusData, totalData, timeData]: number[][]
88+
[focusData, timeData]: [number[], number[]]
8989
) {
9090
const textColor = getPrimaryTextColor()
9191
const secondaryTextColor = getSecondaryTextColor()
@@ -139,14 +139,6 @@ function optionOf(
139139
textStyle: { color: textColor },
140140
}],
141141
series: [{
142-
// run time
143-
name: t(msg => msg.item.total),
144-
data: totalData,
145-
yAxisIndex: 0,
146-
type: 'line',
147-
smooth: true,
148-
tooltip: { formatter: (params: any) => formatTimeOfEchart(params, timeFormat) }
149-
}, {
150142
name: t(msg => msg.item.focus),
151143
data: focusData,
152144
yAxisIndex: 0,
@@ -208,23 +200,21 @@ async function processSubtitle(host: timer.app.trend.HostInfo) {
208200
return subtitle
209201
}
210202

211-
function processDataItems(allDates: string[], timeFormat: timer.app.TimeFormat, rows: timer.stat.Row[]): number[][] {
203+
function processDataItems(allDates: string[], timeFormat: timer.app.TimeFormat, rows: timer.stat.Row[]): [number[], number[]] {
212204
timeFormat = timeFormat || 'default'
213205
const millConverter = MILL_CONVERTERS[timeFormat]
214206
const focusData: number[] = []
215-
const totalData: number[] = []
216207
const timeData: number[] = []
217208

218-
const dateInfoMap = {}
209+
const dateInfoMap: Record<string, timer.stat.Row> = {}
219210
rows.forEach(row => dateInfoMap[row.date] = row)
220211

221212
allDates.forEach(date => {
222-
const row = dateInfoMap[date] || {}
223-
focusData.push(millConverter(row.focus || 0))
224-
totalData.push(millConverter(row.total || 0))
225-
timeData.push(row.time || 0)
213+
const row = dateInfoMap[date]
214+
focusData.push(millConverter(row?.focus || 0))
215+
timeData.push(row?.time || 0)
226216
})
227-
return [focusData, totalData, timeData]
217+
return [focusData, timeData]
228218
}
229219

230220
class ChartWrapper {

src/database/router-database.ts

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

src/database/timer-database.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ export type TimerCondition = {
2525
* Total range, milliseconds
2626
*
2727
* @since 0.0.9
28+
* @deprecated 1.3.4
2829
*/
2930
totalRange?: number[]
3031
/**

src/popup/components/footer/index.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,9 @@ class FooterWrapper {
8282

8383
const option = await optionService.getAllOption()
8484
this.timeSelectWrapper.init(option.defaultDuration)
85-
this.typeSelectWrapper.init(option.defaultType)
85+
// Remove total @since v1.3.4
86+
const defaultType = option.defaultType === 'total' ? 'focus' : option.defaultType
87+
this.typeSelectWrapper.init(defaultType)
8688
this.mergeHostWrapper.init(option.defaultMergeDomain)
8789
this.query()
8890
}

src/popup/style/index.sass

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ $optionPadding: 10px
6363
#type-select-popup
6464
z-index: 2004
6565
left: 619px
66-
top: 380px
66+
top: 410px
6767
margin: 0px
6868
#time-select-popup
6969
z-index: 2004

src/util/i18n/components/item.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,11 @@ import type { Messages } from ".."
1010
export type ItemMessage = {
1111
date: string
1212
host: string
13+
// @deprecated v1.3.4
1314
total: string
15+
// @since v1.3.4
16+
// @deprecated v1.3.4
17+
totalTip: string
1418
focus: string
1519
time: string
1620
operation: {
@@ -33,6 +37,7 @@ const _default: Messages<ItemMessage> = {
3337
date: '日期',
3438
host: '域名',
3539
total: '运行时长',
40+
totalTip: '许多用户反应该数据实际作用不大。作者深思熟虑,打算于不久的将来下线它。如果您有疑问,欢迎提交反馈。',
3641
focus: '浏览时长',
3742
time: '打开次数',
3843
operation: {
@@ -53,6 +58,7 @@ const _default: Messages<ItemMessage> = {
5358
date: '日期',
5459
host: '域名',
5560
total: '運行時長',
61+
totalTip: '許多用戶反應該數據實際作用不大。作者深思熟慮,打算於不久的將來下線它。如果您有疑問,歡迎提交反饋。',
5662
focus: '瀏覽時長',
5763
time: '訪問次數',
5864
operation: {
@@ -73,6 +79,7 @@ const _default: Messages<ItemMessage> = {
7379
date: 'Date',
7480
host: 'Site URL',
7581
total: 'Running Time',
82+
totalTip: 'The author plans to take this column offline in the near future. If you have questions, feel free to submit feedback.',
7683
focus: 'Browsing Time',
7784
time: 'Site Visits',
7885
operation: {
@@ -93,6 +100,7 @@ const _default: Messages<ItemMessage> = {
93100
date: '日期',
94101
host: 'URL',
95102
total: '実行時間',
103+
totalTip: '著者は、近い将来にオフラインにする予定です。 ご不明な点がございましたら、お気軽にフィードバックを送信してください。',
96104
focus: '閲覧時間',
97105
time: '拜訪回数',
98106
operation: {

0 commit comments

Comments
 (0)