+
{showSidebarTrigger && (
<>
>
)}
-
+
{breadcrumbs?.map((item, index) => (
@@ -52,6 +58,20 @@ export function AppHeader({
))}
+
+
+
+
+
+
+
+ AI Provider Settings
+
+
+
+
)
diff --git a/lib/db/codegen/mutaitons.ts b/lib/db/codegen/mutaitons.ts
index f2998175..63ac9596 100644
--- a/lib/db/codegen/mutaitons.ts
+++ b/lib/db/codegen/mutaitons.ts
@@ -6,12 +6,21 @@ export async function createCodegen(codegen: Codegen | Codegen[]) {
}
export async function upsertCodegen(codegen: Codegen) {
- const result = await CodegenModel.findOneAndUpdate(
- { title: codegen.title },
- codegen,
- { upsert: true, new: true },
- )
- return result
+ if (codegen._id) {
+ const result = await CodegenModel.findByIdAndUpdate(
+ codegen._id,
+ codegen,
+ { new: true },
+ )
+ return result
+ } else {
+ const result = await CodegenModel.findOneAndUpdate(
+ { title: codegen.title },
+ codegen,
+ { upsert: true, new: true },
+ )
+ return result
+ }
}
export async function upsertCodegens(codegens: Codegen[]) {
diff --git a/lib/db/codegen/selectors.ts b/lib/db/codegen/selectors.ts
index 881ea36d..b2c5850f 100644
--- a/lib/db/codegen/selectors.ts
+++ b/lib/db/codegen/selectors.ts
@@ -37,7 +37,7 @@ export async function findCodegens(params: CodegenApi.ListRequest) {
export async function findCodegenById(id: string) {
const codegen = await CodegenModel.findById(id)
- .select("_id title description fullStack guides codeRendererUrl rules")
+ .select("_id title description fullStack guides codeRendererUrl rules model")
.lean<
Pick<
Codegen,
@@ -47,6 +47,7 @@ export async function findCodegenById(id: string) {
| "guides"
| "codeRendererUrl"
| "rules"
+ | "model"
> & {
_id: string
}
diff --git a/lib/db/codegen/types.ts b/lib/db/codegen/types.ts
index 40f96d61..53dc1390 100644
--- a/lib/db/codegen/types.ts
+++ b/lib/db/codegen/types.ts
@@ -20,6 +20,7 @@ export interface CodegenRule {
}
export interface Codegen {
+ _id?: string // MongoDB 文档ID,编辑时必需
title: string
description: string
fullStack: "React" | "Vue"