@@ -13,17 +13,12 @@ import { defaultStatistics } from "@util/constant/option"
1313import { defineComponent , h , reactive , unref } from "vue"
1414import { t } from "@app/locale"
1515import { renderOptionItem , tagText , tooltip } from "../common"
16- import { IS_SAFARI } from "@util/constant/environment"
1716
1817function updateOptionVal ( key : keyof timer . option . StatisticsOption , newVal : boolean , option : UnwrapRef < timer . option . StatisticsOption > ) {
1918 option [ key ] = newVal
2019 optionService . setStatisticsOption ( unref ( option ) )
2120}
2221
23- const countWhenIdle = ( option : UnwrapRef < timer . option . StatisticsOption > ) => h ( ElSwitch , {
24- modelValue : option . countWhenIdle ,
25- onChange : ( newVal : boolean ) => updateOptionVal ( 'countWhenIdle' , newVal , option )
26- } )
2722
2823const countLocalFiles = ( option : UnwrapRef < timer . option . StatisticsOption > ) => h ( ElSwitch , {
2924 modelValue : option . countLocalFiles ,
@@ -36,40 +31,10 @@ const collectSiteName = (option: UnwrapRef<timer.option.StatisticsOption>) => h(
3631} )
3732
3833function copy ( target : timer . option . StatisticsOption , source : timer . option . StatisticsOption ) {
39- target . countWhenIdle = source . countWhenIdle
4034 target . collectSiteName = source . collectSiteName
4135 target . countLocalFiles = source . countLocalFiles
4236}
4337
44- function renderOptionItems ( option : timer . option . StatisticsOption ) {
45- const result = [ ]
46- if ( ! IS_SAFARI ) {
47- // chrome.idle does not work in Safari, so not to display this option
48- result . push (
49- renderOptionItem ( {
50- input : countWhenIdle ( option ) ,
51- idleTime : tagText ( msg => msg . option . statistics . idleTime ) ,
52- info : tooltip ( msg => msg . option . statistics . idleTimeInfo )
53- } , msg => msg . statistics . countWhenIdle , t ( msg => msg . option . yes ) ) ,
54- h ( ElDivider )
55- )
56- }
57- result . push (
58- renderOptionItem ( {
59- input : countLocalFiles ( option ) ,
60- localFileTime : tagText ( msg => msg . option . statistics . localFileTime ) ,
61- info : tooltip ( msg => msg . option . statistics . localFilesInfo )
62- } , msg => msg . statistics . countLocalFiles , t ( msg => msg . option . no ) ) ,
63- h ( ElDivider ) ,
64- renderOptionItem ( {
65- input : collectSiteName ( option ) ,
66- siteName : tagText ( msg => msg . option . statistics . siteName ) ,
67- siteNameUsage : tooltip ( msg => msg . option . statistics . siteNameUsage )
68- } , msg => msg . statistics . collectSiteName , t ( msg => msg . option . yes ) )
69- )
70- return result
71- }
72-
7338const _default = defineComponent ( {
7439 name : "StatisticsOptionContainer" ,
7540 setup ( _props , ctx ) {
@@ -81,7 +46,19 @@ const _default = defineComponent({
8146 await optionService . setStatisticsOption ( unref ( option ) )
8247 }
8348 } )
84- return ( ) => h ( 'div' , renderOptionItems ( option ) )
49+ return ( ) => h ( 'div' , [
50+ renderOptionItem ( {
51+ input : countLocalFiles ( option ) ,
52+ localFileTime : tagText ( msg => msg . option . statistics . localFileTime ) ,
53+ info : tooltip ( msg => msg . option . statistics . localFilesInfo )
54+ } , msg => msg . statistics . countLocalFiles , t ( msg => msg . option . no ) ) ,
55+ h ( ElDivider ) ,
56+ renderOptionItem ( {
57+ input : collectSiteName ( option ) ,
58+ siteName : tagText ( msg => msg . option . statistics . siteName ) ,
59+ siteNameUsage : tooltip ( msg => msg . option . statistics . siteNameUsage )
60+ } , msg => msg . statistics . collectSiteName , t ( msg => msg . option . yes ) )
61+ ] )
8562 }
8663} )
8764
0 commit comments