1+ import { ElCard , ElSwitch , ElTooltip } from "element-plus"
2+ import optionService from "../../../../service/option-service"
3+ import { defaultStatistics } from "../../../../util/constant/option"
4+ import { defineComponent , h , Ref , ref } from "vue"
5+ import { t } from "../../../locale"
6+ import { renderHeader , renderOptionItem , tagText } from "../common"
7+
8+ const optionRef : Ref < Timer . StatisticsOption > = ref ( defaultStatistics ( ) )
9+
10+ function updateOptionVal ( key : keyof Timer . StatisticsOption , newVal : boolean ) {
11+ const value = optionRef . value
12+ value [ key ] = newVal
13+ optionService . setStatisticsOption ( value )
14+ }
15+
16+ const countWhenIdle = ( ) => h ( ElSwitch , {
17+ modelValue : optionRef . value . countWhenIdle ,
18+ onChange : ( newVal : boolean ) => updateOptionVal ( 'countWhenIdle' , newVal )
19+ } )
20+
21+ const options = ( ) => [
22+ renderOptionItem ( {
23+ input : countWhenIdle ( ) ,
24+ idleTime : tagText ( msg => msg . option . statistics . idleTime ) ,
25+ info : h ( ElTooltip , { content : t ( msg => msg . option . statistics . idleTimeInfo ) } , { default : ( ) => h ( 'i' , { class : 'el-icon-info' } ) } )
26+ } , msg => msg . statistics . countWhenIdle , t ( msg => msg . option . no ) )
27+ ]
28+
29+ const _default = defineComponent ( ( ) => {
30+ return ( ) => h ( ElCard , { } , {
31+ header : ( ) => renderHeader (
32+ msg => msg . statistics . title ,
33+ ( ) => optionService . setStatisticsOption ( optionRef . value = defaultStatistics ( ) ) ) ,
34+ default : options
35+ } )
36+ } )
37+
38+ export default _default
0 commit comments