修复type错误和lint --fix
This commit is contained in:
@@ -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>
|
||||
|
Reference in New Issue
Block a user