55 * https://opensource.org/licenses/MIT
66 */
77import { t } from "@app/locale"
8- import { type I18nKey , t as t_ } from "@i18n"
9- import DurationSelect , { rangeLabel } from "@popup/components/Footer/DurationSelect"
108import { IS_ANDROID } from "@util/constant/environment"
119import { defaultPopup } from "@util/constant/option"
12- import { ALL_DIMENSIONS } from "@util/stat"
13- import { ElInputNumber , ElOption , ElSelect , ElSwitch } from "element-plus"
10+ import { ElInputNumber , ElSwitch } from "element-plus"
1411import { defineComponent } from "vue"
1512import { type OptionInstance } from "../common"
1613import { useOption } from "../useOption"
1714import OptionItem from "./OptionItem"
1815import OptionTag from "./OptionTag"
1916
20- type LocaleStyle = {
21- /**
22- * Width of duration select
23- */
24- duration : number
25- /**
26- * Width and type select
27- */
28- type : number
29- }
30-
31- const STYLES : Messages < LocaleStyle > = {
32- zh_CN : { type : 85 , duration : 100 } ,
33- en : { type : 115 , duration : 110 } ,
34- ja : { type : 85 , duration : 110 } ,
35- pt_PT : { type : 155 , duration : 120 } ,
36- zh_TW : { type : 85 , duration : 100 } ,
37- uk : { type : 145 , duration : 120 } ,
38- es : { type : 160 , duration : 125 } ,
39- de : { duration : 120 } ,
40- fr : { type : 150 , duration : 130 } ,
41- ru : { type : 170 , duration : 150 } ,
42- }
43-
44- const tStyle = ( key : I18nKey < LocaleStyle > ) => t_ ( STYLES , { key } )
45-
4617const defaultPopOptions = defaultPopup ( )
47- const defaultTypeLabel = t ( msg => msg . item [ defaultPopOptions . defaultType ] )
48- const defaultDurationLabel = rangeLabel ( defaultPopOptions . defaultDuration , defaultPopOptions . defaultDurationNum )
49- const displayDefaultLabel = `${ defaultDurationLabel } /${ defaultTypeLabel } `
5018
5119function copy ( target : timer . option . PopupOption , source : timer . option . PopupOption ) {
52- target . defaultMergeMethod = source . defaultMergeMethod
53- target . defaultDuration = source . defaultDuration
54- target . defaultDurationNum = source . defaultDurationNum
55- target . defaultType = source . defaultType
5620 target . displaySiteName = source . displaySiteName
5721 target . popupMax = source . popupMax
5822}
@@ -66,51 +30,7 @@ const _default = defineComponent((_props, ctx) => {
6630
6731 return ( ) => < >
6832 < OptionItem
69- label = { msg => msg . option . popup . defaultMergeMethod }
70- defaultValue = { t ( msg => msg . shared . merge . mergeMethod . notMerge ) }
7133 hideDivider
72- >
73- < ElSelect
74- size = "small"
75- modelValue = { option . defaultMergeMethod }
76- placeholder = { t ( msg => msg . shared . merge . mergeMethod . notMerge ) }
77- onChange = { ( val : timer . stat . MergeMethod ) => option . defaultMergeMethod = val || undefined }
78- >
79- < ElOption value = { '' } label = { t ( msg => msg . shared . merge . mergeMethod . notMerge ) } />
80- { ( [ 'domain' , 'cate' ] satisfies timer . stat . MergeMethod [ ] ) . map ( m => (
81- < ElOption value = { m } label = { t ( msg => msg . shared . merge . mergeMethod [ m ] ) } />
82- ) ) }
83- </ ElSelect >
84- </ OptionItem >
85- < OptionItem
86- label = { msg => msg . option . popup . defaultDisplay }
87- defaultValue = { displayDefaultLabel }
88- v-slots = { {
89- duration : ( ) => (
90- < DurationSelect
91- size = "small"
92- expandTrigger = "hover"
93- modelValue = { [ option . defaultDuration , option . defaultDurationNum ] }
94- onChange = { ( [ duration , num ] ) => {
95- option . defaultDuration = duration
96- option . defaultDurationNum = num
97- } }
98- style = { { width : `${ tStyle ( m => m . duration ) } px` } }
99- />
100- ) ,
101- type : ( ) => (
102- < ElSelect
103- modelValue = { option . defaultType }
104- size = "small"
105- style = { { width : `${ tStyle ( m => m . type ) } px` } }
106- onChange = { ( val : timer . core . Dimension ) => option . defaultType = val }
107- >
108- { ALL_DIMENSIONS . map ( item => < ElOption value = { item } label = { t ( msg => msg . item [ item ] ) } /> ) }
109- </ ElSelect >
110- )
111- } }
112- />
113- < OptionItem
11434 label = { msg => msg . option . popup . max }
11535 defaultValue = { defaultPopOptions . popupMax }
11636 >
0 commit comments