@@ -36,6 +36,10 @@ public partial class SelectCity
3636 [ Parameter ]
3737 public bool AutoClose { get ; set ; } = true ;
3838
39+ [ Inject ]
40+ [ NotNull ]
41+ private IPinyinService ? PinyinService { get ; set ; }
42+
3943 private string ? ClassString => CssBuilder . Default ( "select bb-city" )
4044 . AddClass ( "disabled" , IsDisabled )
4145 . AddClassFromAttributes ( AdditionalAttributes )
@@ -55,7 +59,7 @@ public partial class SelectCity
5559 private string ? GetActiveClass ( string item ) => CssBuilder . Default ( )
5660 . AddClass ( "active" , _values . Contains ( item ) && IsMultiple )
5761 . AddClass ( "active" , CurrentValue == item && ! IsMultiple )
58- . AddClass ( "prev" , ! string . IsNullOrEmpty ( _searchText ) && PinYinService . GetFirstLetters ( item ) . StartsWith ( _searchText ) )
62+ . AddClass ( "prev" , ! string . IsNullOrEmpty ( _searchText ) && PinyinService . GetFirstLetters ( item ) . StartsWith ( _searchText ) )
5963 . Build ( ) ;
6064
6165 /// <summary>
@@ -164,7 +168,7 @@ private HashSet<string> GetProvinces()
164168 return Provinces ;
165169 }
166170
167- if ( IsChinese ( _searchText ) )
171+ if ( PinyinService . IsChinese ( _searchText ) )
168172 {
169173 return [ .. Provinces . Where ( i => i . Contains ( _searchText ) || GetCities ( i ) . Any ( city => city . Contains ( _searchText ) ) ) ] ;
170174 }
@@ -181,7 +185,7 @@ private HashSet<ProvinceItem> GenerateProvincePinYin()
181185 {
182186 _provinceItems ??= [ .. Provinces . Select ( i => new ProvinceItem ( )
183187 {
184- PinYin = PinYinService . GetFirstLetters ( i ) ,
188+ PinYin = PinyinService . GetFirstLetters ( i ) ,
185189 Name = i ,
186190 Cities = GenerateCityPinYin ( i )
187191 } ) ] ;
@@ -197,12 +201,10 @@ private HashSet<ProvinceItem> GenerateProvincePinYin()
197201
198202 private HashSet < CityItem > GenerateCityPinYin ( string provinceName ) => [ .. GetCities ( provinceName ) . Select ( i => new CityItem ( )
199203 {
200- PinYin = PinYinService . GetFirstLetters ( i ) ,
204+ PinYin = PinyinService . GetFirstLetters ( i ) ,
201205 Name = i
202206 } ) ] ;
203207
204- private bool IsChinese ( string text ) => text . Any ( i => i >= 0x4E00 && i <= 0x9FFF ) ;
205-
206208 private static readonly HashSet < string > Provinces = [
207209 "直辖市" ,
208210 "河北省" ,
0 commit comments