当前项目仅为骨架 后续想要引入tailwindcss完成样式编辑、美化
后端接入Google Books的API,以此完成功能实现,主要专注于前端
interface GBItem { id: string; volumeInfo: any }
interface Book { id: string; title: string; authors: string[]; thumbnail: string }
export async function fetchBooks(type: string, keyword: string): Promise<{ total: number; books: Book[] }> {
const q = `${type}:${encodeURIComponent(keyword)}`
const res = await fetch(`https://www.googleapis.com/books/v1/volumes?q=${q}&maxResults=20`)
if (!res.ok) throw new Error('网络错误')
const data = await res.json() as { totalItems: number; items: GBItem[] }
const books = (data.items || []).map(item => ({
id: item.id,
title: item.volumeInfo.title,
authors: item.volumeInfo.authors || ['未知'],
thumbnail: item.volumeInfo.imageLinks?.thumbnail || ''
}))
return { total: data.totalItems, books }
}开发使用依赖包pnpm
# pnpm
pnpm install开发启动推荐
# pnpm
pnpm dev
pnpm run dev好崩溃啊tailwindcss还是不太适应
整了好久问ai,编辑不明白,还得多花点时间
但是还是挺喜欢这种组件编辑方式的,感觉完全掌握以后写起来肯定很爽
但是发现好像并灭有那么好实现
添加的dark直接就生效了,点击按钮以后暂时也没有切换成原来的颜色
再研究研究吧,今天没法写了
现在终于是有点模样了
说起来刚刚写日期的适合才突然意识到今天是什么日子
把搜索框样式也优化了
在haruki的推荐下稍微学到了新的方式,所以利用上课时间整理了一点东西 VueUse
