|
|
@@ -40,7 +40,7 @@
|
|
40
|
40
|
|
|
41
|
41
|
</template>
|
|
42
|
42
|
<script>
|
|
43
|
|
- import pinyin from 'pinyin'
|
|
|
43
|
+import { chineseToPinYin } from '@/utils/pinyin.js'
|
|
44
|
44
|
export default {
|
|
45
|
45
|
components: {
|
|
46
|
46
|
},
|
|
|
@@ -115,11 +115,9 @@ export default {
|
|
115
|
115
|
} else {
|
|
116
|
116
|
// 中文字符,使用拼音首字母
|
|
117
|
117
|
try {
|
|
118
|
|
- const pinyinArray = pinyin(label, {
|
|
119
|
|
- style: pinyin.STYLE_FIRST_LETTER,
|
|
120
|
|
- })
|
|
121
|
|
- if (pinyinArray.length > 0 && /[a-zA-Z]/.test(pinyinArray[0][0].toUpperCase())) {
|
|
122
|
|
- firstLetter = pinyinArray[0][0].toUpperCase()
|
|
|
118
|
+ const pinyin = chineseToPinYin(label)
|
|
|
119
|
+ if (pinyin && pinyin.length > 0 && /[a-zA-Z]/.test(pinyin.charAt(0).toUpperCase())) {
|
|
|
120
|
+ firstLetter = pinyin.charAt(0).toUpperCase()
|
|
123
|
121
|
} else {
|
|
124
|
122
|
firstLetter = '#'
|
|
125
|
123
|
}
|