Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 0 additions & 16 deletions app/components/photos/PhotoDetail.vue

This file was deleted.

2 changes: 1 addition & 1 deletion app/composables/photos.ts → app/composables/usePhotos.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export function usePhotos() {

try {
// 使用 useFetch 来确保在服务端和客户端都能正确工作
const response = await $fetch('/api/photos', {
const response = await $fetch('/api/imgs', {
method: 'GET',
query: {
page,
Expand Down
94 changes: 0 additions & 94 deletions app/pages/posts.vue

This file was deleted.

69 changes: 0 additions & 69 deletions app/pages/posts/[...slug].vue

This file was deleted.

5 changes: 4 additions & 1 deletion nuxt.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,8 @@ export default defineNuxtConfig({
future: {
compatibilityVersion: 4,
},
compatibilityDate: '2024-09-05',
compatibilityDate: '2025-07-01',
nitro: {
preset: 'netlify',
},
})
56 changes: 56 additions & 0 deletions server/api/cwd.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import { readdir, stat } from 'node:fs/promises'
import { join } from 'node:path'

export default defineEventHandler(async () => {
const path = process.cwd()

try {
// 读取当前工作目录下的文件和文件夹
const files = await readdir(path)

// 获取每个文件的详细信息
const fileStats = await Promise.all(
files.map(async (file) => {
const filePath = join(path, file)
const stats = await stat(filePath)

return {
name: file,
path: filePath,
isDirectory: stats.isDirectory(),
isFile: stats.isFile(),
size: stats.size,
createdAt: stats.birthtime,
modifiedAt: stats.mtime,
}
}),
)

// 按类型和名称排序(文件夹在前,然后按名称排序)
const sortedFiles = fileStats.sort((a, b) => {
if (a.isDirectory && !b.isDirectory) {
return -1
}
if (!a.isDirectory && b.isDirectory) {
return 1
}
return a.name.localeCompare(b.name)
})

return {
path,
publicPath: join(path, 'public'),
files: sortedFiles,
totalFiles: files.length,
directories: sortedFiles.filter(f => f.isDirectory).length,
regularFiles: sortedFiles.filter(f => f.isFile).length,
}
}
catch (error) {
throw createError({
statusCode: 500,
statusMessage: 'Failed to read directory',
data: error,
})
}
})
File renamed without changes.