feat: 更新依赖并添加待办事项功能

- 更新 drizzle-orm、drizzle-zod 和 drizzle-kit 到最新 beta 版本,并将 nitro 更新为最新 nightly 版本,同时升级 iconv-lite 和 tedious 的依赖版本以修复兼容性问题。
- 添加数据库开发脚本并更新 drizzle-orm、drizzle-zod 和 drizzle-kit 为 beta 版本,同时将 nitro 更新为最新 nightly 版本。
- 启用数据库连接的预处理功能并明确配置连接参数。
- 添加待办事项页面路由及服务器函数以获取待办事项数据
- 添加/todo路由配置并更新路由树结构以包含新路由的完整定义和类型声明。
This commit is contained in:
2026-01-17 02:48:10 +08:00
parent d0c203df74
commit 540865eb4c
5 changed files with 67 additions and 17 deletions

View File

@@ -4,7 +4,10 @@ import { env } from '@/env'
export function createDb() {
return drizzle({
connection: env.DATABASE_URL,
connection: {
url: env.DATABASE_URL,
prepare: true,
},
schema,
})
}

View File

@@ -9,8 +9,14 @@
// Additionally, you should also exclude this file from your linter and/or formatter to prevent it from being checked or modified.
import { Route as rootRouteImport } from './routes/__root'
import { Route as TodoRouteImport } from './routes/todo'
import { Route as IndexRouteImport } from './routes/index'
const TodoRoute = TodoRouteImport.update({
id: '/todo',
path: '/todo',
getParentRoute: () => rootRouteImport,
} as any)
const IndexRoute = IndexRouteImport.update({
id: '/',
path: '/',
@@ -19,28 +25,39 @@ const IndexRoute = IndexRouteImport.update({
export interface FileRoutesByFullPath {
'/': typeof IndexRoute
'/todo': typeof TodoRoute
}
export interface FileRoutesByTo {
'/': typeof IndexRoute
'/todo': typeof TodoRoute
}
export interface FileRoutesById {
__root__: typeof rootRouteImport
'/': typeof IndexRoute
'/todo': typeof TodoRoute
}
export interface FileRouteTypes {
fileRoutesByFullPath: FileRoutesByFullPath
fullPaths: '/'
fullPaths: '/' | '/todo'
fileRoutesByTo: FileRoutesByTo
to: '/'
id: '__root__' | '/'
to: '/' | '/todo'
id: '__root__' | '/' | '/todo'
fileRoutesById: FileRoutesById
}
export interface RootRouteChildren {
IndexRoute: typeof IndexRoute
TodoRoute: typeof TodoRoute
}
declare module '@tanstack/react-router' {
interface FileRoutesByPath {
'/todo': {
id: '/todo'
path: '/todo'
fullPath: '/todo'
preLoaderRoute: typeof TodoRouteImport
parentRoute: typeof rootRouteImport
}
'/': {
id: '/'
path: '/'
@@ -53,6 +70,7 @@ declare module '@tanstack/react-router' {
const rootRouteChildren: RootRouteChildren = {
IndexRoute: IndexRoute,
TodoRoute: TodoRoute,
}
export const routeTree = rootRouteImport
._addFileChildren(rootRouteChildren)

17
src/routes/todo.tsx Normal file
View File

@@ -0,0 +1,17 @@
import { createFileRoute } from '@tanstack/react-router'
import { createServerFn } from '@tanstack/react-start'
import { db } from '@/db'
import { todoTable } from '@/db/schema'
const getTodos = createServerFn().handler(async () => {
const todos = await db.select().from(todoTable)
return todos
})
export const Route = createFileRoute('/todo')({
component: Todo,
})
function Todo() {
return <div>Hello "/todo"!</div>
}