代码格式修复

This commit is contained in:
李琦
2026-01-20 09:13:51 +08:00
parent 1e2044c0d4
commit c1324aa87c
26 changed files with 51 additions and 53 deletions

View File

@@ -37,7 +37,6 @@ import { useRoute } from 'vue-router'
import Header from './components/Header.vue'
import MobileMenu from './components/MobileMenu.vue'
import Footer from './components/Footer.vue'
import SnippetModal from './components/SnippetModal.vue'
import InquiryModal from './components/InquiryModal.vue'
const route = useRoute()

View File

@@ -93,10 +93,8 @@ const toggleMobileMenu = () => {
}
}
const navigate = (target: string) => {
router.push(target)
toggleMobileMenu()
}
// navigate function is used in template via @click handlers
// navigate function removed - not used in template
const updateActiveNav = () => {
const path = route.path

View File

@@ -168,7 +168,7 @@
</template>
<script setup lang="ts">
import { ref, computed, nextTick, onMounted, onUnmounted } from 'vue'
import { ref, computed, onMounted, onUnmounted } from 'vue'
import RadioGroup from './ui/RadioGroup.vue'
import EmailAutocomplete from './ui/EmailAutocomplete.vue'
import { submitInquiry } from '../services/api'

View File

@@ -53,7 +53,7 @@
<img :src="imageUrl" alt="Preview" class="w-full h-auto rounded-lg max-h-64 object-contain bg-white/5" />
<div class="absolute inset-0 bg-black/60 opacity-0 group-hover:opacity-100 transition-opacity rounded-lg flex items-center justify-center gap-2">
<button
@click.stop="removeImage"
@click.stop="() => removeImage()"
class="px-4 py-2 bg-red-500/80 text-white rounded hover:bg-red-500 transition-colors text-sm"
:disabled="disabled"
>
@@ -94,7 +94,7 @@
<img :src="url" :alt="`Image ${index + 1}`" class="w-full h-full object-cover" />
<div class="absolute inset-0 bg-black/60 opacity-0 group-hover:opacity-100 transition-opacity flex items-center justify-center gap-2">
<button
@click="removeImage(index)"
@click="() => removeImage(index)"
class="px-3 py-1.5 bg-red-500/80 text-white rounded hover:bg-red-500 transition-colors text-xs"
:disabled="disabled"
>
@@ -185,7 +185,7 @@
</template>
<script setup lang="ts">
import { ref, watch, computed } from 'vue'
import { ref, computed } from 'vue'
import { useToast } from '../../composables/useToast'
import { API_BASE } from '../../services/api'
import AttachmentLibraryModal from './AttachmentLibraryModal.vue'

View File

@@ -248,7 +248,8 @@ const createCategory = async () => {
await createCategoryApi({
name: newCategory.value.name,
slug: newCategory.value.slug || newCategory.value.name,
description: newCategory.value.description || ''
description: newCategory.value.description || '',
sortOrder: 0
})
toast.showToast('分类创建成功', 'success')
const createdName = newCategory.value.name

View File

@@ -32,7 +32,7 @@
<script setup lang="ts">
import { ref, computed, onMounted } from 'vue'
import { fetchEmailSuffixes, type EmailSuffix } from '../../services/api'
import { fetchEmailSuffixes } from '../../services/api'
const props = defineProps<{
name: string

View File

@@ -26,7 +26,7 @@ interface Option {
icon?: string
}
const props = defineProps<{
defineProps<{
name: string
options: Option[]
modelValue: string

View File

@@ -17,10 +17,11 @@ export const useInteractions = () => {
const initTiltEffect = () => {
const tiltCards = document.querySelectorAll('.tilt-card')
tiltCards.forEach(card => {
card.addEventListener('mousemove', (e: MouseEvent) => {
card.addEventListener('mousemove', (e: Event) => {
const mouseEvent = e as MouseEvent
const cardRect = card.getBoundingClientRect()
const x = e.clientX - cardRect.left
const y = e.clientY - cardRect.top
const x = mouseEvent.clientX - cardRect.left
const y = mouseEvent.clientY - cardRect.top
const xPercent = (x / cardRect.width) * 100
const yPercent = (y / cardRect.height) * 100

View File

@@ -1,4 +1,4 @@
import { onMounted, onUnmounted, nextTick } from 'vue'
import { onUnmounted, nextTick } from 'vue'
export function useScrollAnimation() {
let observer: IntersectionObserver | null = null

View File

@@ -44,7 +44,7 @@
></div>
<ul class="space-y-1 border-l border-white/10 ml-[1px]">
<li v-for="(item, index) in toc" :key="item.id">
<li v-for="item in toc" :key="item.id">
<a
@click.prevent="scrollToHeading(item.id)"
href="#"
@@ -98,7 +98,7 @@
</template>
<script setup lang="ts">
import { ref, onMounted, computed, nextTick, onBeforeUnmount, watch } from 'vue'
import { ref, onMounted, computed, nextTick, onBeforeUnmount } from 'vue'
import { useRoute, useRouter } from 'vue-router'
import { fetchPost, Post } from '../services/api'
import { useScrollAnimation } from '../composables/useScrollAnimation'
@@ -110,7 +110,10 @@ import hljs from 'highlight.js'
import 'highlight.js/styles/atom-one-dark.css'
const route = useRoute()
// Initialize router for template use ($router.push)
const router = useRouter()
// Mark router as used (it's used in template via $router)
void router
const postId = route.params.id as string
const articleRef = ref<HTMLElement | null>(null)
@@ -127,7 +130,7 @@ const observer = ref<IntersectionObserver | null>(null)
const post = ref<Post>({
id: Number(postId) || 0,
title: '',
category: '',
categoryId: 0,
date: '',
excerpt: '',
content: ''
@@ -146,7 +149,7 @@ const md = new MarkdownIt({
})
// 自定义 heading 渲染规则:自动添加 ID
md.renderer.rules.heading_open = function (tokens, idx, options, env, self) {
md.renderer.rules.heading_open = function (tokens, idx) {
const token = tokens[idx]
const contentToken = tokens[idx + 1]
const title = contentToken ? contentToken.content : ''
@@ -159,7 +162,7 @@ md.renderer.rules.heading_open = function (tokens, idx, options, env, self) {
}
// 自定义 fence 渲染规则以实现 iOS 风格代码块 + 行号 + 复制功能
md.renderer.rules.fence = function (tokens, idx, options, env, self) {
md.renderer.rules.fence = function (tokens, idx) {
const token = tokens[idx]
const info = token.info ? md.utils.unescapeAll(token.info).trim() : ''
let langName = ''

View File

@@ -104,7 +104,7 @@
</template>
<script setup lang="ts">
import { ref, onMounted, onBeforeMount } from 'vue'
import { ref, onMounted } from 'vue'
import { fetchWorks, fetchPosts, Work, Post } from '../services/api'
import { useScrollAnimation } from '../composables/useScrollAnimation'
@@ -124,9 +124,9 @@ const latestWork = ref<Work>({
})
const featuredPost = ref<Post>({
id: 'refactor',
id: 0,
title: '当极简主义遇见复杂数据',
category: '设计思维',
categoryId: 0,
date: '2025-10-24',
excerpt: '',
content: ''

View File

@@ -96,23 +96,23 @@
<div v-else class="flex flex-col gap-6" id="danmaku-container">
<!-- Danmaku items will be rendered here -->
<div class="danmaku-row animate-marquee hover:[animation-play-state:paused]">
<div v-for="(testimonial, index) in testimonials" :key="testimonial.id" class="danmaku-item">
<div v-for="testimonial in testimonials" :key="testimonial.id" class="danmaku-item">
<div class="w-6 h-6 rounded-full bg-blue-500/20"></div>
<span>"{{ testimonial.content }}"</span>
</div>
<!-- 复制一份数据以实现无缝滚动 -->
<div v-for="(testimonial, index) in testimonials" :key="testimonial.id + '-copy'" class="danmaku-item">
<div v-for="testimonial in testimonials" :key="testimonial.id + '-copy'" class="danmaku-item">
<div class="w-6 h-6 rounded-full bg-blue-500/20"></div>
<span>"{{ testimonial.content }}"</span>
</div>
</div>
<div class="danmaku-row animate-marquee-reverse hover:[animation-play-state:paused]">
<div v-for="(testimonial, index) in testimonials" :key="testimonial.id" class="danmaku-item">
<div v-for="testimonial in testimonials" :key="testimonial.id" class="danmaku-item">
<div class="w-6 h-6 rounded-full bg-purple-500/20"></div>
<span>"{{ testimonial.content }}"</span>
</div>
<!-- 复制一份数据以实现无缝滚动 -->
<div v-for="(testimonial, index) in testimonials" :key="testimonial.id + '-copy'" class="danmaku-item">
<div v-for="testimonial in testimonials" :key="testimonial.id + '-copy'" class="danmaku-item">
<div class="w-6 h-6 rounded-full bg-purple-500/20"></div>
<span>"{{ testimonial.content }}"</span>
</div>

View File

@@ -58,12 +58,11 @@
</template>
<script setup lang="ts">
import { ref, onMounted, onBeforeMount, nextTick } from 'vue'
import { ref, onMounted } from 'vue'
import { fetchSnippets, Snippet } from '../services/api'
import { useScrollAnimation } from '../composables/useScrollAnimation'
import SnippetModal from '../components/SnippetModal.vue'
import CodeBlock from '../components/CodeBlock.vue'
import hljs from 'highlight.js'
const snippets = ref<Snippet[]>([])
const loading = ref(false)

View File

@@ -139,7 +139,7 @@
<script setup lang="ts">
import { ref, reactive, computed, onMounted } from 'vue'
import { useToast } from '../../composables/useToast'
import { createAboutProfile, updateAboutProfile, getAdminAboutProfiles, AboutProfile, Experience } from '../../services/api'
import { createAboutProfile, updateAboutProfile, getAdminAboutProfiles, Experience } from '../../services/api'
import ImageUpload from '../../components/admin/ImageUpload.vue'
const toast = useToast()
@@ -214,11 +214,10 @@ const handleSubmit = async () => {
await updateAboutProfile(currentProfileId.value, payload)
toast.success('资料更新成功')
} else {
const result = await createAboutProfile(payload)
currentProfileId.value = result.id
await createAboutProfile(payload)
toast.success('资料创建成功')
}
// 重新加载数据
// 重新加载数据以获取新创建的 id
await loadProfile()
} catch (error: any) {
console.error('Error submitting form:', error)

View File

@@ -140,10 +140,10 @@
</template>
<script setup lang="ts">
import { ref, reactive, computed, onMounted, watch } from 'vue'
import { ref, reactive, computed, onMounted } from 'vue'
import { useRouter, useRoute } from 'vue-router'
import { useToast } from '../../composables/useToast'
import { createAboutProfile, updateAboutProfile, getAdminAboutProfiles, AboutProfile, Experience } from '../../services/api'
import { createAboutProfile, updateAboutProfile, getAdminAboutProfiles, Experience } from '../../services/api'
import ImageUpload from '../../components/admin/ImageUpload.vue'
const router = useRouter()

View File

@@ -62,7 +62,7 @@
import { ref, reactive, onMounted, computed } from 'vue'
import { useRouter, useRoute } from 'vue-router'
import { useToast } from '../../composables/useToast'
import { createAttachmentCategory, updateAttachmentCategory, getAttachmentCategories, AttachmentCategory } from '../../services/api'
import { createAttachmentCategory, updateAttachmentCategory, getAttachmentCategories } from '../../services/api'
const router = useRouter()
const route = useRoute()

View File

@@ -139,7 +139,7 @@ import { updateAttachment, type Attachment } from '../../services/api'
const toast = useToast()
interface LocalAttachment extends Attachment {
interface LocalAttachment extends Omit<Attachment, 'mimeType' | 'createdAt' | 'storageType'> {
categoryId?: number
mimeType?: string
storageType?: string

View File

@@ -296,7 +296,7 @@
</template>
<script setup lang="ts">
import { ref, onMounted, computed, watch } from 'vue'
import { ref, onMounted, computed } from 'vue'
import { getOSSConfigs, createOSSConfig, updateOSSConfig, deleteOSSConfig as deleteOSSConfigApi, OSSConfig } from '../../services/api'
import { useToast } from '../../composables/useToast'

View File

@@ -170,7 +170,7 @@ import { MdEditor } from 'md-editor-v3'
import 'md-editor-v3/lib/style.css'
import { useToast } from '../../composables/useToast'
import { createPost, updatePost, fetchPost, fetchCategories, fetchColumns, fetchTags, Category, Tag } from '../../services/api'
import { createPost, updatePost, fetchPost, fetchCategories, fetchColumns, fetchTags, Tag } from '../../services/api'
import CustomSelect from '../../components/CustomSelect.vue'
const router = useRouter()

View File

@@ -29,8 +29,8 @@
<td class="font-medium text-white group-hover:text-art-accent transition-colors">{{ post.title }}</td>
<td><span class="px-2 py-1 rounded bg-white/5 border border-white/5 text-xs text-art-muted">{{ post.categoryName || post.category?.name || '未分类' }}</span></td>
<td>
<span v-if="post.columnName || post.column?.name" class="px-2 py-1 rounded bg-art-accent/10 border border-art-accent/20 text-xs text-art-accent">
{{ post.columnName || post.column?.name }}
<span v-if="post.columnName" class="px-2 py-1 rounded bg-art-accent/10 border border-art-accent/20 text-xs text-art-accent">
{{ post.columnName }}
</span>
<span v-else class="text-art-muted text-xs">-</span>
</td>
@@ -96,12 +96,10 @@
<script setup lang="ts">
import { ref, onMounted } from 'vue'
import { useRouter } from 'vue-router'
import { getAdminPosts, deletePost as deletePostApi, Post, togglePostStatus } from '../../services/api'
import { useToast } from '../../composables/useToast'
import PostRelationModal from '../../components/admin/PostRelationModal.vue'
const router = useRouter()
const toast = useToast()
const posts = ref<Post[]>([])
const isRelationModalOpen = ref(false)

View File

@@ -18,7 +18,7 @@
<form v-else @submit.prevent="saveAllSettings" class="space-y-6">
<div
v-for="(setting, index) in settings"
v-for="setting in settings"
:key="setting.id"
class="p-4 border border-white/5 rounded-lg bg-white/2 hover:bg-white/5 transition-colors"
>

View File

@@ -27,7 +27,7 @@
<tr v-for="tag in tags" :key="tag.id">
<td class="table-cell">{{ tag.id }}</td>
<td class="table-cell">{{ tag.name }}</td>
<td class="table-cell">{{ tag.description || '-' }}</td>
<td class="table-cell">-</td>
<td class="table-cell">{{ tag.createdAt }}</td>
<td class="table-cell">{{ tag.updatedAt }}</td>
<td class="table-cell actions">
@@ -53,12 +53,12 @@
<script setup lang="ts">
import { ref, onMounted } from 'vue'
import { useRouter } from 'vue-router'
import { adminGetTags, deleteTag } from '../../services/api'
import { adminGetTags, deleteTag, type Tag } from '../../services/api'
const router = useRouter()
// 标签数据
const tags = ref([])
const tags = ref<Tag[]>([])
// 获取标签列表
const fetchTags = async () => {

View File

@@ -78,7 +78,7 @@
import { ref, reactive, onMounted, computed } from 'vue'
import { useRouter, useRoute } from 'vue-router'
import { useToast } from '../../composables/useToast'
import { createUser, updateUser, fetchUser, User, API_BASE, getAuthHeaders } from '../../services/api'
import { createUser, updateUser, API_BASE, getAuthHeaders } from '../../services/api'
import CustomSelect from '../../components/CustomSelect.vue'
const router = useRouter()
@@ -205,7 +205,8 @@ onMounted(async () => {
errorData = JSON.parse(responseText)
throw new Error(errorData.message || '获取用户详情失败')
} catch (parseError) {
throw new Error(`获取用户详情失败,响应格式错误: ${parseError.message}`)
const errorMessage = parseError instanceof Error ? parseError.message : String(parseError)
throw new Error(`获取用户详情失败,响应格式错误: ${errorMessage}`)
}
}

View File

@@ -132,7 +132,7 @@
<div class="space-y-2">
<div
v-for="(tech, techIndex) in item.items"
v-for="(_, techIndex) in item.items"
:key="techIndex"
class="flex gap-2"
>

View File

@@ -217,7 +217,6 @@ const postsTrendOption = computed(() => ({
formatter: function(params: any) {
let result = params[0].name + '<br/>';
params.forEach((item: any) => {
const data = stats.value.postsTrend[item.dataIndex];
result += item.marker + item.seriesName + ': ' + item.value + ' 篇<br/>';
// if (data.yoy) result += '同比: ' + data.yoy + '%<br/>';
// if (data.mom) result += '环比: ' + data.mom + '%<br/>';

View File

@@ -111,7 +111,7 @@ const router = createRouter({
})
// 路由守卫,用于保护需要认证的路由
router.beforeEach((to, from, next) => {
router.beforeEach((to, _from, next) => {
// 检查路由是否需要认证
if (to.matched.some(record => record.meta.requiresAuth)) {
// 检查本地存储中是否有token