修复type错误和lint --fix

This commit is contained in:
2025-08-07 14:15:21 +08:00
parent 25470fc7f8
commit 4c8334b7bd
3 changed files with 27 additions and 30 deletions

View File

@@ -8,7 +8,7 @@ const { data: articles } = await useAsyncData('blog-articles', () => {
})
// 格式化日期
const formatDate = (date: any) => {
const formatDate = (date: string | Date | null | undefined) => {
if (!date) return '未知时间'
try {
const d = new Date(date)
@@ -23,16 +23,16 @@ const formatDate = (date: any) => {
}
// 计算阅读时间(基于文章内容长度估算)
const getReadingTime = (content: any) => {
if (!content) return 1
try {
const wordsPerMinute = 200
const wordCount = String(content).split(/\s+/).length
return Math.max(1, Math.ceil(wordCount / wordsPerMinute))
} catch {
return 1
}
}
// const getReadingTime = (content: string | null | undefined) => {
// if (!content) return 1
// try {
// const wordsPerMinute = 200
// const wordCount = String(content).split(/\s+/).length
// return Math.max(1, Math.ceil(wordCount / wordsPerMinute))
// } catch {
// return 1
// }
// }
</script>
<template>