This commit is contained in:
雷欧(林平凡)
2025-09-09 11:19:54 +08:00
parent 4a30efaa56
commit 3d258dc6aa
2 changed files with 17 additions and 7 deletions

View File

@@ -37,6 +37,7 @@
"js-cookie": "3.0.1",
"jsencrypt": "3.0.0-rc.1",
"nprogress": "0.2.0",
"pinyin-pro": "^3.27.0",
"quill": "2.0.2",
"screenfull": "5.0.2",
"sortablejs": "1.10.2",

View File

@@ -11,12 +11,12 @@
<div class="form-label">型号/类型</div>
<div class="letter-nav">
<el-button-group>
<el-button size="mini" :type="activeLetter === 'ALL' ? 'primary' : 'default'" @click="activeLetter = 'ALL'">全部</el-button>
<el-button v-for="ltr in letters" :key="ltr" size="mini" :type="activeLetter === ltr ? 'primary' : 'default'" @click="activeLetter = ltr">{{ ltr }}</el-button>
<el-button size="small" :type="activeLetter === 'ALL' ? 'primary' : 'default'" @click="activeLetter = 'ALL'">全部</el-button>
<el-button v-for="ltr in letters" :key="ltr" size="small" :type="activeLetter === ltr ? 'primary' : 'default'" @click="activeLetter = ltr">{{ ltr }}</el-button>
</el-button-group>
<el-button
type="primary"
size="mini"
size="small"
class="refresh-btn"
@click="loadTypes"
icon="el-icon-refresh"
@@ -174,6 +174,7 @@
</template>
<script>
import { pinyin } from 'pinyin-pro'
export default {
name: 'CommentGeneratorPublic',
data() {
@@ -277,10 +278,18 @@ export default {
getInitial(it) {
const source = (it && (it.name || it.value) || '').toString().trim()
if (!source) return '#'
const ch = source[0]
const upper = ch.toUpperCase()
if (upper >= 'A' && upper <= 'Z') return upper
const firstChar = source[0]
const upperAscii = firstChar.toUpperCase()
if (upperAscii >= 'A' && upperAscii <= 'Z') return upperAscii
// 中文等非 ASCII 字符,取拼音首字母
try {
const letter = pinyin(firstChar, { toneType: 'none', type: 'array' })[0]
if (!letter || !letter.length) return '#'
const initial = letter[0].toUpperCase()
return (initial >= 'A' && initial <= 'Z') ? initial : '#'
} catch(e) {
return '#'
}
},
selectType(it) {
if (!it) return