File tree 2 files changed +12
-6
lines changed
2 files changed +12
-6
lines changed Original file line number Diff line number Diff line change @@ -134,11 +134,17 @@ type GetMultiplePinyin = (
134
134
const getMultiplePinyin : GetMultiplePinyin = ( word , mode = 'normal' ) => {
135
135
const wordCode = word . charCodeAt ( 0 ) ;
136
136
const customMultpileDict = getCustomMultpileDict ( ) ;
137
- const pinyin =
138
- customMultpileDict [ wordCode ] ||
139
- ( mode === 'surname' ? Surnames [ word ] : '' ) ||
140
- DICT1 [ wordCode ] ||
141
- '' ;
137
+ let pinyin = DICT1 [ wordCode ] || '' ;
138
+ if ( customMultpileDict [ wordCode ] ) {
139
+ pinyin = customMultpileDict [ wordCode ] ;
140
+ } else if ( mode === 'surname' ) {
141
+ const surnamePinyin = Surnames [ word ] ;
142
+ pinyin = [
143
+ surnamePinyin ,
144
+ pinyin . split ( ' ' ) . filter ( py => py !== surnamePinyin ) ,
145
+ ] . join ( ' ' ) ;
146
+ }
147
+
142
148
if ( pinyin ) {
143
149
return pinyin . split ( ' ' ) . map ( ( value ) => ( {
144
150
origin : word ,
Original file line number Diff line number Diff line change @@ -34,7 +34,7 @@ describe('multiple', () => {
34
34
35
35
it ( '[multiple]multiple+surname同时使用' , ( ) => {
36
36
const result = pinyin ( '能' , { mode : 'surname' , multiple : true } ) ;
37
- expect ( result ) . to . be . equal ( 'nài' ) ;
37
+ expect ( result ) . to . be . equal ( 'nài néng ' ) ;
38
38
} ) ;
39
39
40
40
it ( '[multiple]base' , ( ) => {
You can’t perform that action at this time.
0 commit comments