@@ -25,43 +25,25 @@ function WifiPreviewCard({ ssid, password, hidePassword, qrValue, template, onUp
2525 const [ editedTitle , setEditedTitle ] = useState ( '' ) ;
2626 const [ editedDescription , setEditedDescription ] = useState ( '' ) ;
2727
28- const TEMPLATE_STYLES = useMemo ( ( ) => ( {
29- default : {
30- title : '免费 Wi-Fi' ,
31- description : '无需密码即可连接' ,
32- icon : '📶' ,
33- textColor : 'text-gray-900' ,
34- } ,
35- restaurant : {
36- title : '餐厅 Wi-Fi' ,
37- description : '用餐时享用免费网络' ,
38- icon : '🍽️' ,
39- textColor : 'text-gray-900' ,
40- } ,
41- hotel : {
42- title : '酒店 Wi-Fi' ,
43- description : '客房和公共区域均可连接' ,
44- icon : '🏨' ,
45- textColor : 'text-gray-900' ,
46- } ,
47- hospital : {
48- title : '医院 Wi-Fi' ,
49- description : '患者和访客可免费使用' ,
50- icon : '🏥' ,
51- textColor : 'text-gray-900' ,
52- } ,
53- office : {
54- title : '办公 Wi-Fi' ,
55- description : '安全可靠的商务网络' ,
56- icon : '💼' ,
57- textColor : 'text-gray-900' ,
58- } ,
59- } ) , [ ] ) ;
28+ const TEMPLATE_ICONS = {
29+ default : '📶' ,
30+ restaurant : '🍽️' ,
31+ hotel : '🏨' ,
32+ hospital : '🏥' ,
33+ office : '💼' ,
34+ } ;
35+
36+ const templateStyle = useMemo ( ( ) => ( {
37+ title : isEditing ? editedTitle : t ( `templates.${ template } .title` ) ,
38+ description : isEditing ? editedDescription : t ( `templates.${ template } .description` ) ,
39+ icon : TEMPLATE_ICONS [ template ] ,
40+ textColor : 'text-gray-900' ,
41+ } ) , [ template , isEditing , editedTitle , editedDescription , t ] ) ;
6042
6143 useEffect ( ( ) => {
62- setEditedTitle ( TEMPLATE_STYLES [ template ] . title ) ;
63- setEditedDescription ( TEMPLATE_STYLES [ template ] . description ) ;
64- } , [ template , TEMPLATE_STYLES ] ) ;
44+ setEditedTitle ( t ( `templates. ${ template } .title` ) ) ;
45+ setEditedDescription ( t ( `templates. ${ template } .description` ) ) ;
46+ } , [ template , t ] ) ;
6547
6648 const handleSave = ( ) => {
6749 onUpdate ?.( editedSsid , editedPassword ) ;
@@ -72,17 +54,11 @@ function WifiPreviewCard({ ssid, password, hidePassword, qrValue, template, onUp
7254 const handleEdit = ( ) => {
7355 setEditedSsid ( ssid ) ;
7456 setEditedPassword ( password ) ;
75- setEditedTitle ( TEMPLATE_STYLES [ template ] . title ) ;
76- setEditedDescription ( TEMPLATE_STYLES [ template ] . description ) ;
57+ setEditedTitle ( t ( `templates. ${ template } .title` ) ) ;
58+ setEditedDescription ( t ( `templates. ${ template } .description` ) ) ;
7759 setIsEditing ( true ) ;
7860 } ;
7961
80- const templateStyle = {
81- ...TEMPLATE_STYLES [ template ] ,
82- title : isEditing ? editedTitle : TEMPLATE_STYLES [ template ] . title ,
83- description : isEditing ? editedDescription : TEMPLATE_STYLES [ template ] . description ,
84- } ;
85-
8662 return (
8763 < div className = "inline-block p-4 bg-white rounded-lg shadow-lg border-2 border-gray-200 print:shadow-none print:border-gray-300" >
8864 < div className = "flex items-center justify-center gap-2 mb-4" >
0 commit comments