11'use client' ;
22
3- import { memo , useState , useEffect } from 'react' ;
3+ import { memo , useState , useEffect , useMemo } from 'react' ;
44import { QRCodeSVG } from 'qrcode.react' ;
55import { PencilIcon , CheckIcon } from '@heroicons/react/24/outline' ;
66import { useTranslations } from 'next-intl' ;
@@ -25,44 +25,38 @@ function WifiPreviewCard({ ssid, password, hidePassword, qrValue, template, onUp
2525 const [ editedTitle , setEditedTitle ] = useState ( '' ) ;
2626 const [ editedDescription , setEditedDescription ] = useState ( '' ) ;
2727
28- // 使用翻译的模板样式
29- const TEMPLATE_STYLES : Record < TemplateType , {
30- title : string ;
31- description : string ;
32- icon : string ;
33- textColor : string ;
34- } > = {
28+ const TEMPLATE_STYLES = useMemo ( ( ) => ( {
3529 default : {
36- title : t ( 'templates.default.title' ) ,
37- description : t ( 'templates.default.description' ) ,
30+ title : '免费 Wi-Fi' ,
31+ description : '无需密码即可连接' ,
3832 icon : '📶' ,
3933 textColor : 'text-gray-900' ,
4034 } ,
4135 restaurant : {
42- title : t ( 'templates.restaurant.title' ) ,
43- description : t ( 'templates.restaurant.description' ) ,
36+ title : '餐厅 Wi-Fi' ,
37+ description : '用餐时享用免费网络' ,
4438 icon : '🍽️' ,
4539 textColor : 'text-gray-900' ,
4640 } ,
4741 hotel : {
48- title : t ( 'templates.hotel.title' ) ,
49- description : t ( 'templates.hotel.description' ) ,
42+ title : '酒店 Wi-Fi' ,
43+ description : '客房和公共区域均可连接' ,
5044 icon : '🏨' ,
5145 textColor : 'text-gray-900' ,
5246 } ,
5347 hospital : {
54- title : t ( 'templates.hospital.title' ) ,
55- description : t ( 'templates.hospital.description' ) ,
48+ title : '医院 Wi-Fi' ,
49+ description : '患者和访客可免费使用' ,
5650 icon : '🏥' ,
5751 textColor : 'text-gray-900' ,
5852 } ,
5953 office : {
60- title : t ( 'templates.office.title' ) ,
61- description : t ( 'templates.office.description' ) ,
54+ title : '办公 Wi-Fi' ,
55+ description : '安全可靠的商务网络' ,
6256 icon : '💼' ,
6357 textColor : 'text-gray-900' ,
6458 } ,
65- } ;
59+ } ) , [ ] ) ;
6660
6761 useEffect ( ( ) => {
6862 setEditedTitle ( TEMPLATE_STYLES [ template ] . title ) ;
0 commit comments