修复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>
|
||||
|
@@ -1,9 +1,9 @@
|
||||
<script setup lang="ts">
|
||||
import type { NuxtError } from '#app'
|
||||
|
||||
definePageMeta({
|
||||
layout: 'default'
|
||||
})
|
||||
// definePageMeta({
|
||||
// layout: ''
|
||||
// })
|
||||
|
||||
defineProps<{
|
||||
error: NuxtError
|
||||
|
@@ -1,19 +1,18 @@
|
||||
<script setup lang="ts">
|
||||
import type { ContentNavigationItem } from '@nuxt/content'
|
||||
import { findPageHeadline } from '#ui-pro/utils/content'
|
||||
|
||||
// import type { ContentNavigationItem } from '@nuxt/content'
|
||||
// import { findPageHeadline } from '#ui-pro/utils/content'
|
||||
|
||||
const route = useRoute()
|
||||
const appConfig = useAppConfig()
|
||||
const navigation = inject<Ref<ContentNavigationItem[]>>('navigation')
|
||||
// const appConfig = useAppConfig()
|
||||
// const navigation = inject<Ref<ContentNavigationItem[]>>('navigation')
|
||||
|
||||
// 获取主题系统的字号设置
|
||||
const { selectedFontSize } = useTheme()
|
||||
// const { selectedFontSize } = useTheme()
|
||||
|
||||
// 计算页面内容的字号类
|
||||
const pageFontSizeClass = computed(() => {
|
||||
return `text-${selectedFontSize.value}`
|
||||
})
|
||||
// const pageFontSizeClass = computed(() => {
|
||||
// return `text-${selectedFontSize.value}`
|
||||
// })
|
||||
|
||||
// 根据路由参数构建内容路径
|
||||
const path = computed(() => {
|
||||
@@ -49,7 +48,6 @@ const collection = computed(() => {
|
||||
return queryPath.value.startsWith('/blog') ? 'blog' : 'docs'
|
||||
})
|
||||
|
||||
|
||||
const { data: page } = await useAsyncData(
|
||||
`page-${route.path}`, // 使用更具体的 key
|
||||
() => queryCollection(collection.value).path(queryPath.value).first(),
|
||||
@@ -67,7 +65,6 @@ if (!page.value) {
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
// 复制状态
|
||||
const isCopied = ref(false)
|
||||
|
||||
@@ -76,7 +73,7 @@ const copyFullText = async () => {
|
||||
if (!page.value?.rawbody) {
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
try {
|
||||
await navigator.clipboard.writeText(page.value.rawbody)
|
||||
// 设置复制成功状态
|
||||
@@ -96,21 +93,21 @@ const copyFullText = async () => {
|
||||
<!-- 复制按钮 -->
|
||||
<div class="mb-4 flex justify-start">
|
||||
<UButton
|
||||
@click="copyFullText"
|
||||
:icon="isCopied ? 'lucide-check' : 'lucide-copy'"
|
||||
variant="solid"
|
||||
size="sm"
|
||||
@click="copyFullText"
|
||||
>
|
||||
{{ isCopied ? '已复制' : '复制全文' }}
|
||||
</UButton>
|
||||
</div>
|
||||
|
||||
|
||||
<!-- 原始内容显示区域 -->
|
||||
<div
|
||||
<div
|
||||
class="bg-gray-50 dark:bg-gray-900 rounded-lg p-4 overflow-auto"
|
||||
style="user-select: text; -webkit-user-select: text; -moz-user-select: text; -ms-user-select: text;"
|
||||
>
|
||||
<pre
|
||||
<pre
|
||||
class="whitespace-pre-wrap break-words text-sm"
|
||||
style="user-select: text; -webkit-user-select: text; -moz-user-select: text; -ms-user-select: text;"
|
||||
>
|
||||
|
Reference in New Issue
Block a user