@@ -18,9 +18,11 @@ import {
18
18
} from '@/components/ui/dialog'
19
19
import { Input } from '@/components/ui/input'
20
20
import { Logo } from '@/components/logo'
21
- import type { Content , ContentWithId , PreviewRef } from '@/types'
21
+ import type { Content , ContentWithId , PreviewRef , Size } from '@/types'
22
22
import type { ExportContent , ExportJSON } from '@/components/header/types'
23
23
import {
24
+ CACHE_KEY_SIZE ,
25
+ CACHE_KEY_SIZE_NAME ,
24
26
CACHE_KEY_TEMPLATE , CACHE_KEY_THEME ,
25
27
addAllContents ,
26
28
cn ,
@@ -49,6 +51,8 @@ import {
49
51
SelectValue ,
50
52
} from '@/components/ui/select'
51
53
import {
54
+ DEFAULT_SIZE_MAP ,
55
+ DEFAULT_SIZE_NAMES ,
52
56
DEFAULT_TEMPLATE ,
53
57
DEFAULT_TEMPLATES ,
54
58
DEFAULT_THEME ,
@@ -58,10 +62,14 @@ import { usePlatform } from '@/hooks/use-platform'
58
62
59
63
interface HeaderProps {
60
64
contents : Content [ ] ;
61
- setContents : ( contents : ContentWithId [ ] ) => void ;
62
65
previewRef : React . RefObject < PreviewRef > ;
63
66
templateName : string ;
64
67
theme : string ;
68
+ size ?: Size ;
69
+ sizeName : string ;
70
+ setSize : ( size : Size ) => void ;
71
+ setSizeName : ( sizeName : string ) => void ;
72
+ setContents : ( contents : ContentWithId [ ] ) => void ;
65
73
setTemplateName : ( template : string ) => void ;
66
74
setTheme : ( color : string ) => void
67
75
setTableValue ?: ( tab : string ) => void
@@ -76,7 +84,7 @@ export function Header(props: HeaderProps) {
76
84
const [ isExporting , setIsExporting ] = useState ( true )
77
85
const [ scale , setScale ] = useState ( '3' )
78
86
const platform = usePlatform ( )
79
- const { contents, setContents, previewRef, templateName, theme, setTemplateName, setTheme, setTableValue } = props
87
+ const { contents, setContents, previewRef, templateName, theme, setTemplateName, setTheme, setTableValue, sizeName , setSizeName , setSize } = props
80
88
const { toast } = useToast ( )
81
89
const fileRef = useRef < HTMLInputElement > ( null )
82
90
@@ -390,7 +398,7 @@ export function Header(props: HeaderProps) {
390
398
</ SelectGroup >
391
399
</ SelectContent >
392
400
</ Select >
393
- </ div >
401
+ </ div >
394
402
< div className = "px-1.5 py-2 text-sm" >
395
403
< div className = "mb-2" > 模版色</ div >
396
404
< div >
@@ -412,6 +420,29 @@ export function Header(props: HeaderProps) {
412
420
</ MenubarContent >
413
421
</ MenubarMenu >
414
422
</ Menubar >
423
+ < Select defaultValue = "default" value = { sizeName } onValueChange = { ( value : string ) => {
424
+ const size = DEFAULT_SIZE_MAP [ value ]
425
+ setSizeName ( value )
426
+ setSize ( size )
427
+ localStorage . setItem ( CACHE_KEY_SIZE , JSON . stringify ( size ) )
428
+ localStorage . setItem ( CACHE_KEY_SIZE_NAME , sizeName )
429
+ } } >
430
+ < SelectTrigger className = "h-8 w-[146px]" >
431
+ < SelectValue className = "text-muted-foreground" placeholder = "调整尺寸" />
432
+ </ SelectTrigger >
433
+ < SelectContent >
434
+ < SelectGroup >
435
+ {
436
+ DEFAULT_SIZE_NAMES . map ( size => (
437
+ < SelectItem key = { size . value } value = { size . value } disabled = { size . disabled } >
438
+ { size . label }
439
+ { /* <p className="text-xs">{size.description}</p> */ }
440
+ </ SelectItem >
441
+ ) )
442
+ }
443
+ </ SelectGroup >
444
+ </ SelectContent >
445
+ </ Select >
415
446
< div className = "flex flex-wrap gap-2 ml-auto" >
416
447
< Button size = "sm" asChild variant = "ghost" className = "py-2 px-2 hidden md:flex gap-2" >
417
448
< a href = "https://github.com/byodian/oneimg" target = "_blank" rel = "noreferrer" >
0 commit comments