Skip to content

Commit 7863484

Browse files
committed
Add lodash.clonedeep for deep cloning config object
1 parent ab00b80 commit 7863484

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

src/views/pages/Config.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import MessageUtil from "@/util/MessageUtil";
2020
import { useMst } from "@/views/stores/RootStore";
2121
import getModelShowName from "@/util/getModelShowName";
2222
import isEqual from "lodash.isequal";
23+
import cloneDeep from "lodash.clonedeep";
2324
import { useTranslation } from "react-i18next";
2425
import { useDisclosure } from "@mantine/hooks";
2526
import { observer } from "mobx-react-lite";
@@ -70,7 +71,7 @@ const Config = function () {
7071
initialValues: {
7172
providers: {},
7273
models: {},
73-
...config.config,
74+
...cloneDeep(config.config),
7475
},
7576
validate: {
7677
providers: {
@@ -105,7 +106,8 @@ const Config = function () {
105106

106107
useEffect(() => {
107108
if (router.currentRoute !== "config") return;
108-
form.setValues(config.config);
109+
const cloneConfig = cloneDeep(config.config);
110+
form.setValues(cloneConfig);
109111
if (config.settle && loading) {
110112
setTimeout(() => {
111113
router.updateRoute("chat");
@@ -224,6 +226,7 @@ const Config = function () {
224226
description={t("the base URL for the API")}
225227
{...form.getInputProps("providers.devchat.api_base")}
226228
/>
229+
227230
<PasswordInput
228231
styles={commonInputStyle}
229232
sx={{

0 commit comments

Comments
 (0)