From dcccf6675f2e466cb8e920465a4a8497fa01c7f7 Mon Sep 17 00:00:00 2001 From: imbytecat Date: Tue, 31 Mar 2026 22:46:47 +0800 Subject: [PATCH] =?UTF-8?q?style:=20=E7=BB=9F=E4=B8=80=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E9=A3=8E=E6=A0=BC=20=E2=80=94=20=E6=A0=BC=E5=BC=8F=E5=8C=96=20?= =?UTF-8?q?auth=20schema=E3=80=81=E4=BF=AE=E5=A4=8D=20setup=20=E9=A1=B5?= =?UTF-8?q?=E9=9D=A2=20return=20=E8=AF=AD=E5=8F=A5=E3=80=81=E8=A7=84?= =?UTF-8?q?=E8=8C=83=20drizzle=20snapshot?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/server/drizzle/meta/0000_snapshot.json | 50 ++---- apps/server/drizzle/meta/_journal.json | 2 +- apps/server/src/routes/setup.tsx | 167 ++++++++++---------- apps/server/src/server/auth/schema.ts | 104 ++++++------ 4 files changed, 151 insertions(+), 172 deletions(-) diff --git a/apps/server/drizzle/meta/0000_snapshot.json b/apps/server/drizzle/meta/0000_snapshot.json index 5e93168..1eb35fc 100644 --- a/apps/server/drizzle/meta/0000_snapshot.json +++ b/apps/server/drizzle/meta/0000_snapshot.json @@ -110,12 +110,8 @@ "name": "account_user_id_user_id_fk", "tableFrom": "account", "tableTo": "user", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], + "columnsFrom": ["user_id"], + "columnsTo": ["id"], "onDelete": "cascade", "onUpdate": "no action" } @@ -202,12 +198,8 @@ "name": "session_user_id_user_id_fk", "tableFrom": "session", "tableTo": "user", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], + "columnsFrom": ["user_id"], + "columnsTo": ["id"], "onDelete": "cascade", "onUpdate": "no action" } @@ -217,9 +209,7 @@ "session_token_unique": { "name": "session_token_unique", "nullsNotDistinct": false, - "columns": [ - "token" - ] + "columns": ["token"] } }, "policies": {}, @@ -283,9 +273,7 @@ "user_email_unique": { "name": "user_email_unique", "nullsNotDistinct": false, - "columns": [ - "email" - ] + "columns": ["email"] } }, "policies": {}, @@ -434,12 +422,8 @@ "name": "bookmark_category_id_category_id_fk", "tableFrom": "bookmark", "tableTo": "category", - "columnsFrom": [ - "category_id" - ], - "columnsTo": [ - "id" - ], + "columnsFrom": ["category_id"], + "columnsTo": ["id"], "onDelete": "cascade", "onUpdate": "no action" }, @@ -447,12 +431,8 @@ "name": "bookmark_user_id_user_id_fk", "tableFrom": "bookmark", "tableTo": "user", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], + "columnsFrom": ["user_id"], + "columnsTo": ["id"], "onDelete": "cascade", "onUpdate": "no action" } @@ -527,12 +507,8 @@ "name": "category_user_id_user_id_fk", "tableFrom": "category", "tableTo": "user", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], + "columnsFrom": ["user_id"], + "columnsTo": ["id"], "onDelete": "cascade", "onUpdate": "no action" } @@ -555,4 +531,4 @@ "schemas": {}, "tables": {} } -} \ No newline at end of file +} diff --git a/apps/server/drizzle/meta/_journal.json b/apps/server/drizzle/meta/_journal.json index 37c3a60..9fc1e9e 100644 --- a/apps/server/drizzle/meta/_journal.json +++ b/apps/server/drizzle/meta/_journal.json @@ -10,4 +10,4 @@ "breakpoints": true } ] -} \ No newline at end of file +} diff --git a/apps/server/src/routes/setup.tsx b/apps/server/src/routes/setup.tsx index 62a59d9..af18255 100644 --- a/apps/server/src/routes/setup.tsx +++ b/apps/server/src/routes/setup.tsx @@ -52,90 +52,93 @@ function SetupPage() { router.navigate({ to: '/' as never }) } - ;
-
-
-

Kairos

-

初始化你的人生操作系统

-
-
-
-
- - setName(e.target.value)} - className="w-full px-4 py-3 rounded-xl bg-slate-50 border-0 ring-1 ring-slate-200 focus:ring-2 focus:ring-indigo-500 outline-none transition-all text-slate-700 placeholder:text-slate-400" - placeholder="你的名字" + return ( +
+
+
+

Kairos

+

初始化你的人生操作系统

+
+ +
+ +
+ + setName(e.target.value)} + className="w-full px-4 py-3 rounded-xl bg-slate-50 border-0 ring-1 ring-slate-200 focus:ring-2 focus:ring-indigo-500 outline-none transition-all text-slate-700 placeholder:text-slate-400" + placeholder="你的名字" + disabled={loading} + /> +
+ +
+ + setEmail(e.target.value)} + className="w-full px-4 py-3 rounded-xl bg-slate-50 border-0 ring-1 ring-slate-200 focus:ring-2 focus:ring-indigo-500 outline-none transition-all text-slate-700 placeholder:text-slate-400" + placeholder="your@email.com" + disabled={loading} + /> +
+ +
+ + setPassword(e.target.value)} + className="w-full px-4 py-3 rounded-xl bg-slate-50 border-0 ring-1 ring-slate-200 focus:ring-2 focus:ring-indigo-500 outline-none transition-all text-slate-700 placeholder:text-slate-400" + placeholder="至少 8 个字符" + disabled={loading} + /> +
+ +
+ + setConfirmPassword(e.target.value)} + className="w-full px-4 py-3 rounded-xl bg-slate-50 border-0 ring-1 ring-slate-200 focus:ring-2 focus:ring-indigo-500 outline-none transition-all text-slate-700 placeholder:text-slate-400" + placeholder="再次输入密码" + disabled={loading} + /> +
+ + {error &&

{error}

} + +
- -
- - setEmail(e.target.value)} - className="w-full px-4 py-3 rounded-xl bg-slate-50 border-0 ring-1 ring-slate-200 focus:ring-2 focus:ring-indigo-500 outline-none transition-all text-slate-700 placeholder:text-slate-400" - placeholder="your@email.com" - disabled={loading} - /> -
- -
- - setPassword(e.target.value)} - className="w-full px-4 py-3 rounded-xl bg-slate-50 border-0 ring-1 ring-slate-200 focus:ring-2 focus:ring-indigo-500 outline-none transition-all text-slate-700 placeholder:text-slate-400" - placeholder="至少 8 个字符" - disabled={loading} - /> -
- -
- - setConfirmPassword(e.target.value)} - className="w-full px-4 py-3 rounded-xl bg-slate-50 border-0 ring-1 ring-slate-200 focus:ring-2 focus:ring-indigo-500 outline-none transition-all text-slate-700 placeholder:text-slate-400" - placeholder="再次输入密码" - disabled={loading} - /> -
- - {error &&

{error}

} - - - + className="w-full py-3 bg-indigo-600 hover:bg-indigo-700 text-white rounded-xl font-medium transition-all shadow-md shadow-indigo-200 disabled:opacity-50 disabled:shadow-none hover:shadow-lg hover:shadow-indigo-300 active:scale-[0.98]" + > + {loading ? '初始化中...' : '开始使用 Kairos'} + + +
-
+ ) } diff --git a/apps/server/src/server/auth/schema.ts b/apps/server/src/server/auth/schema.ts index 413a524..2d7a881 100644 --- a/apps/server/src/server/auth/schema.ts +++ b/apps/server/src/server/auth/schema.ts @@ -1,93 +1,93 @@ -import { relations } from "drizzle-orm"; -import { pgTable, text, timestamp, boolean, index } from "drizzle-orm/pg-core"; +import { relations } from 'drizzle-orm' +import { boolean, index, pgTable, text, timestamp } from 'drizzle-orm/pg-core' -export const user = pgTable("user", { - id: text("id").primaryKey(), - name: text("name").notNull(), - email: text("email").notNull().unique(), - emailVerified: boolean("email_verified").default(false).notNull(), - image: text("image"), - createdAt: timestamp("created_at").defaultNow().notNull(), - updatedAt: timestamp("updated_at") +export const user = pgTable('user', { + id: text('id').primaryKey(), + name: text('name').notNull(), + email: text('email').notNull().unique(), + emailVerified: boolean('email_verified').default(false).notNull(), + image: text('image'), + createdAt: timestamp('created_at').defaultNow().notNull(), + updatedAt: timestamp('updated_at') .defaultNow() .$onUpdate(() => /* @__PURE__ */ new Date()) .notNull(), -}); +}) export const session = pgTable( - "session", + 'session', { - id: text("id").primaryKey(), - expiresAt: timestamp("expires_at").notNull(), - token: text("token").notNull().unique(), - createdAt: timestamp("created_at").defaultNow().notNull(), - updatedAt: timestamp("updated_at") + id: text('id').primaryKey(), + expiresAt: timestamp('expires_at').notNull(), + token: text('token').notNull().unique(), + createdAt: timestamp('created_at').defaultNow().notNull(), + updatedAt: timestamp('updated_at') .$onUpdate(() => /* @__PURE__ */ new Date()) .notNull(), - ipAddress: text("ip_address"), - userAgent: text("user_agent"), - userId: text("user_id") + ipAddress: text('ip_address'), + userAgent: text('user_agent'), + userId: text('user_id') .notNull() - .references(() => user.id, { onDelete: "cascade" }), + .references(() => user.id, { onDelete: 'cascade' }), }, - (table) => [index("session_userId_idx").on(table.userId)], -); + (table) => [index('session_userId_idx').on(table.userId)], +) export const account = pgTable( - "account", + 'account', { - id: text("id").primaryKey(), - accountId: text("account_id").notNull(), - providerId: text("provider_id").notNull(), - userId: text("user_id") + id: text('id').primaryKey(), + accountId: text('account_id').notNull(), + providerId: text('provider_id').notNull(), + userId: text('user_id') .notNull() - .references(() => user.id, { onDelete: "cascade" }), - accessToken: text("access_token"), - refreshToken: text("refresh_token"), - idToken: text("id_token"), - accessTokenExpiresAt: timestamp("access_token_expires_at"), - refreshTokenExpiresAt: timestamp("refresh_token_expires_at"), - scope: text("scope"), - password: text("password"), - createdAt: timestamp("created_at").defaultNow().notNull(), - updatedAt: timestamp("updated_at") + .references(() => user.id, { onDelete: 'cascade' }), + accessToken: text('access_token'), + refreshToken: text('refresh_token'), + idToken: text('id_token'), + accessTokenExpiresAt: timestamp('access_token_expires_at'), + refreshTokenExpiresAt: timestamp('refresh_token_expires_at'), + scope: text('scope'), + password: text('password'), + createdAt: timestamp('created_at').defaultNow().notNull(), + updatedAt: timestamp('updated_at') .$onUpdate(() => /* @__PURE__ */ new Date()) .notNull(), }, - (table) => [index("account_userId_idx").on(table.userId)], -); + (table) => [index('account_userId_idx').on(table.userId)], +) export const verification = pgTable( - "verification", + 'verification', { - id: text("id").primaryKey(), - identifier: text("identifier").notNull(), - value: text("value").notNull(), - expiresAt: timestamp("expires_at").notNull(), - createdAt: timestamp("created_at").defaultNow().notNull(), - updatedAt: timestamp("updated_at") + id: text('id').primaryKey(), + identifier: text('identifier').notNull(), + value: text('value').notNull(), + expiresAt: timestamp('expires_at').notNull(), + createdAt: timestamp('created_at').defaultNow().notNull(), + updatedAt: timestamp('updated_at') .defaultNow() .$onUpdate(() => /* @__PURE__ */ new Date()) .notNull(), }, - (table) => [index("verification_identifier_idx").on(table.identifier)], -); + (table) => [index('verification_identifier_idx').on(table.identifier)], +) export const userRelations = relations(user, ({ many }) => ({ sessions: many(session), accounts: many(account), -})); +})) export const sessionRelations = relations(session, ({ one }) => ({ user: one(user, { fields: [session.userId], references: [user.id], }), -})); +})) export const accountRelations = relations(account, ({ one }) => ({ user: one(user, { fields: [account.userId], references: [user.id], }), -})); +}))