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