fix(env): 移除运行时 dotenvx 显式加载,修复 Next.js 构建期底层崩溃

This commit is contained in:
kennethcheng 2026-05-03 15:38:13 +08:00
parent 917291ad5b
commit 47128a9979
2 changed files with 6 additions and 3 deletions

View File

@ -335,6 +335,12 @@
## Dashboard 流水下鑽明細與行內 CRUD (Task 41b)
- 完成 Dashboard 流水下鑽功能,支持在資產列表中直接查看、修改和刪除歷史交易流水。
## 执行 Task 96从数据库初始化与运行时链路中移除了 dotenvx 的显式调用,依赖 Next.js 原生环境变量解析,解决 Turbopack 遭遇 markAsUncloneable 对象的致命编译错误
- **架构红线**Next.js 原生支持 `.env` 解析。绝对禁止在 Next.js 的运行时链路中手动初始化 dotenv/dotenvx。
- **扫描结果**:在 `src/db/index.ts` 中发现并彻底删除 `import dotenv from 'dotenv'``dotenv.config()` 调用(原第 4-6 行),数据库连接现直接读取 `process.env.DATABASE_URL`
- **API Route 审计**`app/api/cron/fetch-prices/route.ts` 和 `app/api/cron/fetch-rates/route.ts` 均未发现 dotenvx 或自定义 envLoader 调用,无需修改。
- **交付物**:已提交 `git add -A` + `git commit -m "fix(env): 移除运行时 dotenvx 显式加载,修复 Next.js 构建期底层崩溃"`
- 在主行 `TableRow` 下方,根據 `expandedIds[pos.assetId]` 條件渲染第二個子行,使用 `<TableCell colSpan={8} className="p-0">` 確保子行佔滿整行寬度。
- 構建流水明細次級表格:遍歷 `pos.transactions` 數組,表頭為「交易日期 | 類型 | 價格/數量 | 手續費 | 備註 | 操作」,精確渲染每筆交易的歷史數據。
- 實裝 `UpdateTransactionDialog` 組件:「修改」按鈕打開彈窗並回顯該筆流水數據(數量、價格、手續費、幣種、執行時間),提交後調用 `updateTransaction` Action 並刷新頁面。

View File

@ -1,9 +1,6 @@
import { drizzle } from "drizzle-orm/postgres-js";
import postgres from "postgres";
import type { PostgresJsDatabase } from "drizzle-orm/postgres-js";
import dotenv from "dotenv";
dotenv.config();
const connectionString = process.env.DATABASE_URL!;
const driver = postgres(connectionString, { max: 1 });