Skip to content

Commit bf8f0e8

Browse files
committed
fix(hanzi): 笔画多时调小显示笔顺
1 parent dbb8ac9 commit bf8f0e8

File tree

2 files changed

+13
-12
lines changed

2 files changed

+13
-12
lines changed

docs/.vuepress/theme/components/hanzi/Hanzi2.vue

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,11 @@ const aniRef = ref(null)
5555
const strokesRef = ref(null)
5656
const pinyinRet = ref(props.pinyin)
5757
const bushouRet = shallowRef([{}])
58-
const bihuaCountRet = shallowRef([props.bihuashu])
5958
const bihuaNameRet = shallowRef([props.bihua])
6059
const zuciRet = shallowRef(props.zuci)
6160
61+
const bihuaCount = ref(props.bihuashu)
62+
6263
const chengyuRef = computed(() => {
6364
if (props.chengyu.length > 0) {
6465
return props.chengyu.slice(0, 4)
@@ -103,12 +104,15 @@ onMounted(() => {
103104
},
104105
})
105106
107+
if (!bihuaCount.value) {
108+
bihuaCount.value = cnchar.stroke(props.zi)
109+
}
106110
// 笔顺
107111
cnchar.draw(props.zi, {
108112
el: strokesRef.value,
109113
type: cnchar.draw.TYPE.STROKE,
110114
style: {
111-
length: 45,
115+
length: bihuaCount.value <= 18 ? 45 : 35,
112116
showOutline: false,
113117
},
114118
line: {
@@ -127,12 +131,7 @@ onMounted(() => {
127131
bushouRet.value = cnchar.radical(props.zi)
128132
speehTxt.value.push(props.jiegou || bushouRet.value[0].struct)
129133
speehTxt.value.push('笔画数')
130-
if (!props.bihuashu) {
131-
bihuaCountRet.value = cnchar.stroke(props.zi, 'order', 'count')
132-
speehTxt.value.push(bihuaCountRet.value)
133-
} else {
134-
speehTxt.value.push(props.bihuashu)
135-
}
134+
speehTxt.value.push(bihuaCount.value)
136135
speehTxt.value.push('笔顺')
137136
if (props.bihua === null || props.bihua.length === 0) {
138137
bihuaNameRet.value = cnchar.stroke(props.zi, 'order', 'name')
@@ -202,7 +201,7 @@ function handleRead() {
202201
:height="32"
203202
/>
204203
<div class="hanzi-container">
205-
<div ref="printRef" class="print hanzi-card" />
204+
<div ref="printRef" class="hanzi-card print" />
206205
<div ref="aniRef" class="hanzi-card animation" />
207206
<div class="hanzi-controls">
208207
<button class="btn-voice btn" title="发音" @click="handleVoice" />
@@ -242,9 +241,7 @@ function handleRead() {
242241
<span class="label">
243242
<span class="tag">笔画数</span>
244243
</span>
245-
<span class="content">{{
246-
props.bihuashu || bihuaCountRet[0]
247-
}}</span>
244+
<span class="content">{{ bihuaCount }}</span>
248245
</div>
249246
<div class="info bihua">
250247
<span class="label">

docs/notes/other/demo/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,3 +199,7 @@ import {
199199
<HanziCard zi="" />
200200

201201
<HanziCard zi="" hide-pinyin />
202+
203+
<HanziCard zi="" />
204+
205+
<HanziCard zi="" />

0 commit comments

Comments
 (0)