Skip to content

Commit

Permalink
fix: 修复简繁转换清空的时没有清除时间和字数统计
Browse files Browse the repository at this point in the history
  • Loading branch information
dxhuii committed Apr 24, 2024
1 parent 73120f1 commit 175e4c0
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions pages/simple2traditional.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ useHead({
const type = ref('s2t')
const isEnhance = ref(false)
const meta = ref('共 0 字,耗时 0ms')
const output = ref('')
const time = ref(0)
function toggleType() {
type.value = type.value === 's2t' ? 't2s' : 's2t'
Expand All @@ -29,11 +29,10 @@ function convert() {
const text = input.value
const begin = performance.now()
const result = type.value === 's2t' ? toTraditional(text, isEnhance.value) : toSimplified(text, isEnhance.value)
const time = performance.now() - begin
output.value = result.replace(/\n/g, '<br>')
meta.value = `${text.length} 字,耗时 ${time.toFixed(2)}ms`
time.value = Number.parseFloat((performance.now() - begin).toFixed(2))
}
async function paste() {
Expand Down Expand Up @@ -70,7 +69,7 @@ async function paste() {
<button type="button" @click="paste">
粘贴
</button>
<button type="button" @click="input = ''">
<button type="button" @click="input = '';output = ''; time = 0">
清空
</button>
</header>
Expand All @@ -79,7 +78,7 @@ async function paste() {
<p id="output" dark:text-black v-html="output" />
</div>
<p text-sm pt4 pl3 pb16>
{{ meta }}
{{ input?.length || 0 }} 字,耗时 {{ time }}ms
</p>
</main>
</template>
Expand Down

0 comments on commit 175e4c0

Please sign in to comment.