settings.tsx 42 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399
  1. import { useState, useEffect, useMemo } from "react";
  2. import styles from "./settings.module.scss";
  3. import ResetIcon from "../icons/reload.svg";
  4. import AddIcon from "../icons/add.svg";
  5. import CloseIcon from "../icons/close.svg";
  6. import CopyIcon from "../icons/copy.svg";
  7. import ClearIcon from "../icons/clear.svg";
  8. import LoadingIcon from "../icons/three-dots.svg";
  9. import EditIcon from "../icons/edit.svg";
  10. import EyeIcon from "../icons/eye.svg";
  11. import DownloadIcon from "../icons/download.svg";
  12. import UploadIcon from "../icons/upload.svg";
  13. import ConfigIcon from "../icons/config.svg";
  14. import ConfirmIcon from "../icons/confirm.svg";
  15. import ConnectionIcon from "../icons/connection.svg";
  16. import CloudSuccessIcon from "../icons/cloud-success.svg";
  17. import CloudFailIcon from "../icons/cloud-fail.svg";
  18. import {
  19. Input,
  20. List,
  21. ListItem,
  22. Modal,
  23. PasswordInput,
  24. Popover,
  25. Select,
  26. showConfirm,
  27. showToast,
  28. } from "./ui-lib";
  29. import { ModelConfigList } from "./model-config";
  30. import { IconButton } from "./button";
  31. import {
  32. SubmitKey,
  33. useChatStore,
  34. Theme,
  35. useAccessStore,
  36. useAppConfig,
  37. } from "../store";
  38. import Locale, {
  39. AllLangs,
  40. ALL_LANG_OPTIONS,
  41. changeLang,
  42. getLang,
  43. } from "../locales";
  44. import { copyToClipboard } from "../utils";
  45. import Link from "next/link";
  46. import {
  47. Azure,
  48. Baidu,
  49. Tencent,
  50. ByteDance,
  51. Alibaba,
  52. OPENAI_BASE_URL,
  53. Path,
  54. STORAGE_KEY,
  55. ServiceProvider,
  56. SlotID,
  57. Iflytek,
  58. } from "../constant";
  59. import { Prompt, SearchService, usePromptStore } from "../store/prompt";
  60. import { ErrorBoundary } from "./error";
  61. import { InputRange } from "./input-range";
  62. import { useNavigate } from "react-router-dom";
  63. // Avatar组件替代实现
  64. import BotIcon from "../icons/bot.svg";
  65. import BlackBotIcon from "../icons/black-bot.svg";
  66. function Avatar(props: { model?: string; avatar?: string }) {
  67. if (props.model) {
  68. return (
  69. <div className="no-dark">
  70. {props.model?.startsWith("gpt-4") ? (
  71. <BlackBotIcon className="user-avatar" />
  72. ) : (
  73. <BotIcon className="user-avatar" />
  74. )}
  75. </div>
  76. );
  77. }
  78. return (
  79. <div className="user-avatar">
  80. {/* 移除emoji头像,使用默认bot图标 */}
  81. <BotIcon className="user-avatar" />
  82. </div>
  83. );
  84. }
  85. // 简化的AvatarPicker替代实现
  86. function AvatarPicker(props: { onEmojiClick: (emoji: string) => void }) {
  87. const defaultAvatars = ["🤖", "👤", "💬", "🎯", "⭐", "🔥"];
  88. return (
  89. <div style={{ padding: "10px", display: "grid", gridTemplateColumns: "repeat(3, 1fr)", gap: "10px" }}>
  90. {defaultAvatars.map((emoji, index) => (
  91. <div
  92. key={index}
  93. style={{
  94. padding: "8px",
  95. borderRadius: "4px",
  96. border: "1px solid #ccc",
  97. textAlign: "center",
  98. cursor: "pointer",
  99. fontSize: "20px"
  100. }}
  101. onClick={() => props.onEmojiClick(emoji)}
  102. >
  103. {emoji}
  104. </div>
  105. ))}
  106. </div>
  107. );
  108. }
  109. import { getClientConfig } from "../config/client";
  110. import { useSyncStore } from "../store/sync";
  111. import { nanoid } from "nanoid";
  112. import { useMaskStore } from "../store/mask";
  113. import { ProviderType } from "../utils/cloud";
  114. function EditPromptModal(props: { id: string; onClose: () => void }) {
  115. const promptStore = usePromptStore();
  116. const prompt = promptStore.get(props.id);
  117. return prompt ? (
  118. <div className="modal-mask">
  119. <Modal
  120. title={Locale.Settings.Prompt.EditModal.Title}
  121. onClose={props.onClose}
  122. actions={[
  123. <IconButton
  124. key=""
  125. onClick={props.onClose}
  126. text={Locale.UI.Confirm}
  127. bordered
  128. />,
  129. ]}
  130. >
  131. <div className={styles["edit-prompt-modal"]}>
  132. <input
  133. type="text"
  134. value={prompt.title}
  135. readOnly={!prompt.isUser}
  136. className={styles["edit-prompt-title"]}
  137. onInput={(e) =>
  138. promptStore.updatePrompt(
  139. props.id,
  140. (prompt) => (prompt.title = e.currentTarget.value),
  141. )
  142. }
  143. ></input>
  144. <Input
  145. value={prompt.content}
  146. readOnly={!prompt.isUser}
  147. className={styles["edit-prompt-content"]}
  148. rows={10}
  149. onInput={(e) =>
  150. promptStore.updatePrompt(
  151. props.id,
  152. (prompt) => (prompt.content = e.currentTarget.value),
  153. )
  154. }
  155. ></Input>
  156. </div>
  157. </Modal>
  158. </div>
  159. ) : null;
  160. }
  161. function UserPromptModal(props: { onClose?: () => void }) {
  162. const promptStore = usePromptStore();
  163. const userPrompts = promptStore.getUserPrompts();
  164. // 移除内置提示词,仅使用用户提示词
  165. const allPrompts = userPrompts;
  166. const [searchInput, setSearchInput] = useState("");
  167. const [searchPrompts, setSearchPrompts] = useState<Prompt[]>([]);
  168. const prompts = searchInput.length > 0 ? searchPrompts : allPrompts;
  169. const [editingPromptId, setEditingPromptId] = useState<string>();
  170. useEffect(() => {
  171. if (searchInput.length > 0) {
  172. const searchResult = SearchService.search(searchInput);
  173. setSearchPrompts(searchResult);
  174. } else {
  175. setSearchPrompts([]);
  176. }
  177. }, [searchInput]);
  178. return (
  179. <div className="modal-mask">
  180. <Modal
  181. title={Locale.Settings.Prompt.Modal.Title}
  182. onClose={() => props.onClose?.()}
  183. actions={[
  184. <IconButton
  185. key="add"
  186. onClick={() => {
  187. const promptId = promptStore.add({
  188. id: nanoid(),
  189. createdAt: Date.now(),
  190. title: "Empty Prompt",
  191. content: "Empty Prompt Content",
  192. });
  193. setEditingPromptId(promptId);
  194. }}
  195. icon={<AddIcon />}
  196. bordered
  197. text={Locale.Settings.Prompt.Modal.Add}
  198. />,
  199. ]}
  200. >
  201. <div className={styles["user-prompt-modal"]}>
  202. <input
  203. type="text"
  204. className={styles["user-prompt-search"]}
  205. placeholder={Locale.Settings.Prompt.Modal.Search}
  206. value={searchInput}
  207. onInput={(e) => setSearchInput(e.currentTarget.value)}
  208. ></input>
  209. <div className={styles["user-prompt-list"]}>
  210. {prompts.map((v, _) => (
  211. <div className={styles["user-prompt-item"]} key={v.id ?? v.title}>
  212. <div className={styles["user-prompt-header"]}>
  213. <div className={styles["user-prompt-title"]}>{v.title}</div>
  214. <div className={styles["user-prompt-content"] + " one-line"}>
  215. {v.content}
  216. </div>
  217. </div>
  218. <div className={styles["user-prompt-buttons"]}>
  219. {v.isUser && (
  220. <IconButton
  221. icon={<ClearIcon />}
  222. className={styles["user-prompt-button"]}
  223. onClick={() => promptStore.remove(v.id!)}
  224. />
  225. )}
  226. {v.isUser ? (
  227. <IconButton
  228. icon={<EditIcon />}
  229. className={styles["user-prompt-button"]}
  230. onClick={() => setEditingPromptId(v.id)}
  231. />
  232. ) : (
  233. <IconButton
  234. icon={<EyeIcon />}
  235. className={styles["user-prompt-button"]}
  236. onClick={() => setEditingPromptId(v.id)}
  237. />
  238. )}
  239. <IconButton
  240. icon={<CopyIcon />}
  241. className={styles["user-prompt-button"]}
  242. onClick={() => copyToClipboard(v.content)}
  243. />
  244. </div>
  245. </div>
  246. ))}
  247. </div>
  248. </div>
  249. </Modal>
  250. {editingPromptId !== undefined && (
  251. <EditPromptModal
  252. id={editingPromptId!}
  253. onClose={() => setEditingPromptId(undefined)}
  254. />
  255. )}
  256. </div>
  257. );
  258. }
  259. function DangerItems() {
  260. const chatStore = useChatStore();
  261. const appConfig = useAppConfig();
  262. return (
  263. <List>
  264. <ListItem
  265. title={Locale.Settings.Danger.Reset.Title}
  266. subTitle={Locale.Settings.Danger.Reset.SubTitle}
  267. >
  268. <IconButton
  269. aria={Locale.Settings.Danger.Reset.Title}
  270. text={Locale.Settings.Danger.Reset.Action}
  271. onClick={async () => {
  272. if (await showConfirm(Locale.Settings.Danger.Reset.Confirm)) {
  273. appConfig.reset();
  274. }
  275. }}
  276. type="danger"
  277. />
  278. </ListItem>
  279. <ListItem
  280. title={Locale.Settings.Danger.Clear.Title}
  281. subTitle={Locale.Settings.Danger.Clear.SubTitle}
  282. >
  283. <IconButton
  284. aria={Locale.Settings.Danger.Clear.Title}
  285. text={Locale.Settings.Danger.Clear.Action}
  286. onClick={async () => {
  287. if (await showConfirm(Locale.Settings.Danger.Clear.Confirm)) {
  288. chatStore.clearAllData();
  289. }
  290. }}
  291. type="danger"
  292. />
  293. </ListItem>
  294. </List>
  295. );
  296. }
  297. function CheckButton() {
  298. const syncStore = useSyncStore();
  299. const couldCheck = useMemo(() => {
  300. return syncStore.cloudSync();
  301. }, [syncStore]);
  302. const [checkState, setCheckState] = useState<
  303. "none" | "checking" | "success" | "failed"
  304. >("none");
  305. async function check() {
  306. setCheckState("checking");
  307. const valid = await syncStore.check();
  308. setCheckState(valid ? "success" : "failed");
  309. }
  310. if (!couldCheck) return null;
  311. return (
  312. <IconButton
  313. text={Locale.Settings.Sync.Config.Modal.Check}
  314. bordered
  315. onClick={check}
  316. icon={
  317. checkState === "none" ? (
  318. <ConnectionIcon />
  319. ) : checkState === "checking" ? (
  320. <LoadingIcon />
  321. ) : checkState === "success" ? (
  322. <CloudSuccessIcon />
  323. ) : checkState === "failed" ? (
  324. <CloudFailIcon />
  325. ) : (
  326. <ConnectionIcon />
  327. )
  328. }
  329. ></IconButton>
  330. );
  331. }
  332. function SyncConfigModal(props: { onClose?: () => void }) {
  333. const syncStore = useSyncStore();
  334. return (
  335. <div className="modal-mask">
  336. <Modal
  337. title={Locale.Settings.Sync.Config.Modal.Title}
  338. onClose={() => props.onClose?.()}
  339. actions={[
  340. <CheckButton key="check" />,
  341. <IconButton
  342. key="confirm"
  343. onClick={props.onClose}
  344. icon={<ConfirmIcon />}
  345. bordered
  346. text={Locale.UI.Confirm}
  347. />,
  348. ]}
  349. >
  350. <List>
  351. <ListItem
  352. title={Locale.Settings.Sync.Config.SyncType.Title}
  353. subTitle={Locale.Settings.Sync.Config.SyncType.SubTitle}
  354. >
  355. <select
  356. value={syncStore.provider}
  357. onChange={(e) => {
  358. syncStore.update(
  359. (config) =>
  360. (config.provider = e.target.value as ProviderType),
  361. );
  362. }}
  363. >
  364. {Object.entries(ProviderType).map(([k, v]) => (
  365. <option value={v} key={k}>
  366. {k}
  367. </option>
  368. ))}
  369. </select>
  370. </ListItem>
  371. <ListItem
  372. title={Locale.Settings.Sync.Config.Proxy.Title}
  373. subTitle={Locale.Settings.Sync.Config.Proxy.SubTitle}
  374. >
  375. <input
  376. type="checkbox"
  377. checked={syncStore.useProxy}
  378. onChange={(e) => {
  379. syncStore.update(
  380. (config) => (config.useProxy = e.currentTarget.checked),
  381. );
  382. }}
  383. ></input>
  384. </ListItem>
  385. {syncStore.useProxy ? (
  386. <ListItem
  387. title={Locale.Settings.Sync.Config.ProxyUrl.Title}
  388. subTitle={Locale.Settings.Sync.Config.ProxyUrl.SubTitle}
  389. >
  390. <input
  391. type="text"
  392. value={syncStore.proxyUrl}
  393. onChange={(e) => {
  394. syncStore.update(
  395. (config) => (config.proxyUrl = e.currentTarget.value),
  396. );
  397. }}
  398. ></input>
  399. </ListItem>
  400. ) : null}
  401. </List>
  402. {syncStore.provider === ProviderType.WebDAV && (
  403. <>
  404. <List>
  405. <ListItem title={Locale.Settings.Sync.Config.WebDav.Endpoint}>
  406. <input
  407. type="text"
  408. value={syncStore.webdav.endpoint}
  409. onChange={(e) => {
  410. syncStore.update(
  411. (config) =>
  412. (config.webdav.endpoint = e.currentTarget.value),
  413. );
  414. }}
  415. ></input>
  416. </ListItem>
  417. <ListItem title={Locale.Settings.Sync.Config.WebDav.UserName}>
  418. <input
  419. type="text"
  420. value={syncStore.webdav.username}
  421. onChange={(e) => {
  422. syncStore.update(
  423. (config) =>
  424. (config.webdav.username = e.currentTarget.value),
  425. );
  426. }}
  427. ></input>
  428. </ListItem>
  429. <ListItem title={Locale.Settings.Sync.Config.WebDav.Password}>
  430. <PasswordInput
  431. value={syncStore.webdav.password}
  432. onChange={(e) => {
  433. syncStore.update(
  434. (config) =>
  435. (config.webdav.password = e.currentTarget.value),
  436. );
  437. }}
  438. ></PasswordInput>
  439. </ListItem>
  440. </List>
  441. </>
  442. )}
  443. {syncStore.provider === ProviderType.UpStash && (
  444. <List>
  445. <ListItem title={Locale.Settings.Sync.Config.UpStash.Endpoint}>
  446. <input
  447. type="text"
  448. value={syncStore.upstash.endpoint}
  449. onChange={(e) => {
  450. syncStore.update(
  451. (config) =>
  452. (config.upstash.endpoint = e.currentTarget.value),
  453. );
  454. }}
  455. ></input>
  456. </ListItem>
  457. <ListItem title={Locale.Settings.Sync.Config.UpStash.UserName}>
  458. <input
  459. type="text"
  460. value={syncStore.upstash.username}
  461. placeholder={STORAGE_KEY}
  462. onChange={(e) => {
  463. syncStore.update(
  464. (config) =>
  465. (config.upstash.username = e.currentTarget.value),
  466. );
  467. }}
  468. ></input>
  469. </ListItem>
  470. <ListItem title={Locale.Settings.Sync.Config.UpStash.Password}>
  471. <PasswordInput
  472. value={syncStore.upstash.apiKey}
  473. onChange={(e) => {
  474. syncStore.update(
  475. (config) => (config.upstash.apiKey = e.currentTarget.value),
  476. );
  477. }}
  478. ></PasswordInput>
  479. </ListItem>
  480. </List>
  481. )}
  482. </Modal>
  483. </div>
  484. );
  485. }
  486. function SyncItems() {
  487. const syncStore = useSyncStore();
  488. const chatStore = useChatStore();
  489. const promptStore = usePromptStore();
  490. const maskStore = useMaskStore();
  491. const couldSync = useMemo(() => {
  492. return syncStore.cloudSync();
  493. }, [syncStore]);
  494. const [showSyncConfigModal, setShowSyncConfigModal] = useState(false);
  495. const stateOverview = useMemo(() => {
  496. const sessions = chatStore.sessions;
  497. const messageCount = sessions.reduce((p, c) => p + c.messages.length, 0);
  498. return {
  499. chat: sessions.length,
  500. message: messageCount,
  501. prompt: Object.keys(promptStore.prompts).length,
  502. mask: Object.keys(maskStore.masks).length,
  503. };
  504. }, [chatStore.sessions, maskStore.masks, promptStore.prompts]);
  505. return (
  506. <>
  507. <List>
  508. <ListItem
  509. title={Locale.Settings.Sync.CloudState}
  510. subTitle={
  511. syncStore.lastProvider
  512. ? `${new Date(syncStore.lastSyncTime).toLocaleString()} [${
  513. syncStore.lastProvider
  514. }]`
  515. : Locale.Settings.Sync.NotSyncYet
  516. }
  517. >
  518. <div style={{ display: "flex" }}>
  519. <IconButton
  520. aria={Locale.Settings.Sync.CloudState + Locale.UI.Config}
  521. icon={<ConfigIcon />}
  522. text={Locale.UI.Config}
  523. onClick={() => {
  524. setShowSyncConfigModal(true);
  525. }}
  526. />
  527. {couldSync && (
  528. <IconButton
  529. icon={<ResetIcon />}
  530. text={Locale.UI.Sync}
  531. onClick={async () => {
  532. try {
  533. await syncStore.sync();
  534. showToast(Locale.Settings.Sync.Success);
  535. } catch (e) {
  536. showToast(Locale.Settings.Sync.Fail);
  537. console.error("[Sync]", e);
  538. }
  539. }}
  540. />
  541. )}
  542. </div>
  543. </ListItem>
  544. <ListItem
  545. title={Locale.Settings.Sync.LocalState}
  546. subTitle={Locale.Settings.Sync.Overview(stateOverview)}
  547. >
  548. <div style={{ display: "flex" }}>
  549. <IconButton
  550. aria={Locale.Settings.Sync.LocalState + Locale.UI.Export}
  551. icon={<UploadIcon />}
  552. text={Locale.UI.Export}
  553. onClick={() => {
  554. syncStore.export();
  555. }}
  556. />
  557. <IconButton
  558. aria={Locale.Settings.Sync.LocalState + Locale.UI.Import}
  559. icon={<DownloadIcon />}
  560. text={Locale.UI.Import}
  561. onClick={() => {
  562. syncStore.import();
  563. }}
  564. />
  565. </div>
  566. </ListItem>
  567. </List>
  568. {showSyncConfigModal && (
  569. <SyncConfigModal onClose={() => setShowSyncConfigModal(false)} />
  570. )}
  571. </>
  572. );
  573. }
  574. export function Settings() {
  575. const navigate = useNavigate();
  576. const [showEmojiPicker, setShowEmojiPicker] = useState(false);
  577. const config = useAppConfig();
  578. const updateConfig = config.update;
  579. const accessStore = useAccessStore();
  580. const shouldHideBalanceQuery = useMemo(() => {
  581. const isOpenAiUrl = accessStore.openaiUrl.includes(OPENAI_BASE_URL);
  582. return (
  583. accessStore.hideBalanceQuery ||
  584. isOpenAiUrl ||
  585. accessStore.provider === ServiceProvider.Azure
  586. );
  587. }, [
  588. accessStore.hideBalanceQuery,
  589. accessStore.openaiUrl,
  590. accessStore.provider,
  591. ]);
  592. const enabledAccessControl = useMemo(
  593. () => accessStore.enabledAccessControl(),
  594. // eslint-disable-next-line react-hooks/exhaustive-deps
  595. [],
  596. );
  597. const promptStore = usePromptStore();
  598. // 移除内置提示词,设置count为0
  599. const builtinCount = 0;
  600. const customCount = promptStore.getUserPrompts().length ?? 0;
  601. const [shouldShowPromptModal, setShowPromptModal] = useState(false);
  602. useEffect(() => {
  603. const keydownEvent = (e: KeyboardEvent) => {
  604. if (e.key === "Escape") {
  605. navigate(Path.Home);
  606. }
  607. };
  608. if (clientConfig?.isApp) {
  609. // Force to set custom endpoint to true if it's app
  610. accessStore.update((state) => {
  611. state.useCustomConfig = true;
  612. });
  613. }
  614. document.addEventListener("keydown", keydownEvent);
  615. return () => {
  616. document.removeEventListener("keydown", keydownEvent);
  617. };
  618. // eslint-disable-next-line react-hooks/exhaustive-deps
  619. }, []);
  620. const clientConfig = useMemo(() => getClientConfig(), []);
  621. const showAccessCode = enabledAccessControl && !clientConfig?.isApp;
  622. const accessCodeComponent = showAccessCode && (
  623. <ListItem
  624. title={Locale.Settings.Access.AccessCode.Title}
  625. subTitle={Locale.Settings.Access.AccessCode.SubTitle}
  626. >
  627. <PasswordInput
  628. value={accessStore.accessCode}
  629. type="text"
  630. placeholder={Locale.Settings.Access.AccessCode.Placeholder}
  631. onChange={(e) => {
  632. accessStore.update(
  633. (access) => (access.accessCode = e.currentTarget.value),
  634. );
  635. }}
  636. />
  637. </ListItem>
  638. );
  639. const useCustomConfigComponent = // Conditionally render the following ListItem based on clientConfig.isApp
  640. !clientConfig?.isApp && ( // only show if isApp is false
  641. <ListItem
  642. title={Locale.Settings.Access.CustomEndpoint.Title}
  643. subTitle={Locale.Settings.Access.CustomEndpoint.SubTitle}
  644. >
  645. <input
  646. aria-label={Locale.Settings.Access.CustomEndpoint.Title}
  647. type="checkbox"
  648. checked={accessStore.useCustomConfig}
  649. onChange={(e) =>
  650. accessStore.update(
  651. (access) => (access.useCustomConfig = e.currentTarget.checked),
  652. )
  653. }
  654. ></input>
  655. </ListItem>
  656. );
  657. const openAIConfigComponent = accessStore.provider ===
  658. ServiceProvider.OpenAI && (
  659. <>
  660. <ListItem
  661. title={Locale.Settings.Access.OpenAI.Endpoint.Title}
  662. subTitle={Locale.Settings.Access.OpenAI.Endpoint.SubTitle}
  663. >
  664. <input
  665. aria-label={Locale.Settings.Access.OpenAI.Endpoint.Title}
  666. type="text"
  667. value={accessStore.openaiUrl}
  668. placeholder={OPENAI_BASE_URL}
  669. onChange={(e) =>
  670. accessStore.update(
  671. (access) => (access.openaiUrl = e.currentTarget.value),
  672. )
  673. }
  674. ></input>
  675. </ListItem>
  676. <ListItem
  677. title={Locale.Settings.Access.OpenAI.ApiKey.Title}
  678. subTitle={Locale.Settings.Access.OpenAI.ApiKey.SubTitle}
  679. >
  680. <PasswordInput
  681. aria={Locale.Settings.ShowPassword}
  682. aria-label={Locale.Settings.Access.OpenAI.ApiKey.Title}
  683. value={accessStore.openaiApiKey}
  684. type="text"
  685. placeholder={Locale.Settings.Access.OpenAI.ApiKey.Placeholder}
  686. onChange={(e) => {
  687. accessStore.update(
  688. (access) => (access.openaiApiKey = e.currentTarget.value),
  689. );
  690. }}
  691. />
  692. </ListItem>
  693. </>
  694. );
  695. const azureConfigComponent = accessStore.provider ===
  696. ServiceProvider.Azure && (
  697. <>
  698. <ListItem
  699. title={Locale.Settings.Access.Azure.Endpoint.Title}
  700. subTitle={
  701. Locale.Settings.Access.Azure.Endpoint.SubTitle + Azure.ExampleEndpoint
  702. }
  703. >
  704. <input
  705. aria-label={Locale.Settings.Access.Azure.Endpoint.Title}
  706. type="text"
  707. value={accessStore.azureUrl}
  708. placeholder={Azure.ExampleEndpoint}
  709. onChange={(e) =>
  710. accessStore.update(
  711. (access) => (access.azureUrl = e.currentTarget.value),
  712. )
  713. }
  714. ></input>
  715. </ListItem>
  716. <ListItem
  717. title={Locale.Settings.Access.Azure.ApiKey.Title}
  718. subTitle={Locale.Settings.Access.Azure.ApiKey.SubTitle}
  719. >
  720. <PasswordInput
  721. aria-label={Locale.Settings.Access.Azure.ApiKey.Title}
  722. value={accessStore.azureApiKey}
  723. type="text"
  724. placeholder={Locale.Settings.Access.Azure.ApiKey.Placeholder}
  725. onChange={(e) => {
  726. accessStore.update(
  727. (access) => (access.azureApiKey = e.currentTarget.value),
  728. );
  729. }}
  730. />
  731. </ListItem>
  732. <ListItem
  733. title={Locale.Settings.Access.Azure.ApiVerion.Title}
  734. subTitle={Locale.Settings.Access.Azure.ApiVerion.SubTitle}
  735. >
  736. <input
  737. aria-label={Locale.Settings.Access.Azure.ApiVerion.Title}
  738. type="text"
  739. value={accessStore.azureApiVersion}
  740. placeholder="2023-08-01-preview"
  741. onChange={(e) =>
  742. accessStore.update(
  743. (access) => (access.azureApiVersion = e.currentTarget.value),
  744. )
  745. }
  746. ></input>
  747. </ListItem>
  748. </>
  749. );
  750. const anthropicConfigComponent = null;
  751. const baiduConfigComponent = accessStore.provider ===
  752. ServiceProvider.Baidu && (
  753. <>
  754. <ListItem
  755. title={Locale.Settings.Access.Baidu.Endpoint.Title}
  756. subTitle={Locale.Settings.Access.Baidu.Endpoint.SubTitle}
  757. >
  758. <input
  759. aria-label={Locale.Settings.Access.Baidu.Endpoint.Title}
  760. type="text"
  761. value={accessStore.baiduUrl}
  762. placeholder={Baidu.ExampleEndpoint}
  763. onChange={(e) =>
  764. accessStore.update(
  765. (access) => (access.baiduUrl = e.currentTarget.value),
  766. )
  767. }
  768. ></input>
  769. </ListItem>
  770. <ListItem
  771. title={Locale.Settings.Access.Baidu.ApiKey.Title}
  772. subTitle={Locale.Settings.Access.Baidu.ApiKey.SubTitle}
  773. >
  774. <PasswordInput
  775. aria-label={Locale.Settings.Access.Baidu.ApiKey.Title}
  776. value={accessStore.baiduApiKey}
  777. type="text"
  778. placeholder={Locale.Settings.Access.Baidu.ApiKey.Placeholder}
  779. onChange={(e) => {
  780. accessStore.update(
  781. (access) => (access.baiduApiKey = e.currentTarget.value),
  782. );
  783. }}
  784. />
  785. </ListItem>
  786. <ListItem
  787. title={Locale.Settings.Access.Baidu.SecretKey.Title}
  788. subTitle={Locale.Settings.Access.Baidu.SecretKey.SubTitle}
  789. >
  790. <PasswordInput
  791. aria-label={Locale.Settings.Access.Baidu.SecretKey.Title}
  792. value={accessStore.baiduSecretKey}
  793. type="text"
  794. placeholder={Locale.Settings.Access.Baidu.SecretKey.Placeholder}
  795. onChange={(e) => {
  796. accessStore.update(
  797. (access) => (access.baiduSecretKey = e.currentTarget.value),
  798. );
  799. }}
  800. />
  801. </ListItem>
  802. </>
  803. );
  804. const tencentConfigComponent = accessStore.provider ===
  805. ServiceProvider.Tencent && (
  806. <>
  807. <ListItem
  808. title={Locale.Settings.Access.Tencent.Endpoint.Title}
  809. subTitle={Locale.Settings.Access.Tencent.Endpoint.SubTitle}
  810. >
  811. <input
  812. aria-label={Locale.Settings.Access.Tencent.Endpoint.Title}
  813. type="text"
  814. value={accessStore.tencentUrl}
  815. placeholder={Tencent.ExampleEndpoint}
  816. onChange={(e) =>
  817. accessStore.update(
  818. (access) => (access.tencentUrl = e.currentTarget.value),
  819. )
  820. }
  821. ></input>
  822. </ListItem>
  823. <ListItem
  824. title={Locale.Settings.Access.Tencent.ApiKey.Title}
  825. subTitle={Locale.Settings.Access.Tencent.ApiKey.SubTitle}
  826. >
  827. <PasswordInput
  828. aria-label={Locale.Settings.Access.Tencent.ApiKey.Title}
  829. value={accessStore.tencentSecretId}
  830. type="text"
  831. placeholder={Locale.Settings.Access.Tencent.ApiKey.Placeholder}
  832. onChange={(e) => {
  833. accessStore.update(
  834. (access) => (access.tencentSecretId = e.currentTarget.value),
  835. );
  836. }}
  837. />
  838. </ListItem>
  839. <ListItem
  840. title={Locale.Settings.Access.Tencent.SecretKey.Title}
  841. subTitle={Locale.Settings.Access.Tencent.SecretKey.SubTitle}
  842. >
  843. <PasswordInput
  844. aria-label={Locale.Settings.Access.Tencent.SecretKey.Title}
  845. value={accessStore.tencentSecretKey}
  846. type="text"
  847. placeholder={Locale.Settings.Access.Tencent.SecretKey.Placeholder}
  848. onChange={(e) => {
  849. accessStore.update(
  850. (access) => (access.tencentSecretKey = e.currentTarget.value),
  851. );
  852. }}
  853. />
  854. </ListItem>
  855. </>
  856. );
  857. const byteDanceConfigComponent = accessStore.provider ===
  858. ServiceProvider.ByteDance && (
  859. <>
  860. <ListItem
  861. title={Locale.Settings.Access.ByteDance.Endpoint.Title}
  862. subTitle={
  863. Locale.Settings.Access.ByteDance.Endpoint.SubTitle +
  864. ByteDance.ExampleEndpoint
  865. }
  866. >
  867. <input
  868. aria-label={Locale.Settings.Access.ByteDance.Endpoint.Title}
  869. type="text"
  870. value={accessStore.bytedanceUrl}
  871. placeholder={ByteDance.ExampleEndpoint}
  872. onChange={(e) =>
  873. accessStore.update(
  874. (access) => (access.bytedanceUrl = e.currentTarget.value),
  875. )
  876. }
  877. ></input>
  878. </ListItem>
  879. <ListItem
  880. title={Locale.Settings.Access.ByteDance.ApiKey.Title}
  881. subTitle={Locale.Settings.Access.ByteDance.ApiKey.SubTitle}
  882. >
  883. <PasswordInput
  884. aria-label={Locale.Settings.Access.ByteDance.ApiKey.Title}
  885. value={accessStore.bytedanceApiKey}
  886. type="text"
  887. placeholder={Locale.Settings.Access.ByteDance.ApiKey.Placeholder}
  888. onChange={(e) => {
  889. accessStore.update(
  890. (access) => (access.bytedanceApiKey = e.currentTarget.value),
  891. );
  892. }}
  893. />
  894. </ListItem>
  895. </>
  896. );
  897. const alibabaConfigComponent = accessStore.provider ===
  898. ServiceProvider.Alibaba && (
  899. <>
  900. <ListItem
  901. title={Locale.Settings.Access.Alibaba.Endpoint.Title}
  902. subTitle={
  903. Locale.Settings.Access.Alibaba.Endpoint.SubTitle +
  904. Alibaba.ExampleEndpoint
  905. }
  906. >
  907. <input
  908. aria-label={Locale.Settings.Access.Alibaba.Endpoint.Title}
  909. type="text"
  910. value={accessStore.alibabaUrl}
  911. placeholder={Alibaba.ExampleEndpoint}
  912. onChange={(e) =>
  913. accessStore.update(
  914. (access) => (access.alibabaUrl = e.currentTarget.value),
  915. )
  916. }
  917. ></input>
  918. </ListItem>
  919. <ListItem
  920. title={Locale.Settings.Access.Alibaba.ApiKey.Title}
  921. subTitle={Locale.Settings.Access.Alibaba.ApiKey.SubTitle}
  922. >
  923. <PasswordInput
  924. aria-label={Locale.Settings.Access.Alibaba.ApiKey.Title}
  925. value={accessStore.alibabaApiKey}
  926. type="text"
  927. placeholder={Locale.Settings.Access.Alibaba.ApiKey.Placeholder}
  928. onChange={(e) => {
  929. accessStore.update(
  930. (access) => (access.alibabaApiKey = e.currentTarget.value),
  931. );
  932. }}
  933. />
  934. </ListItem>
  935. </>
  936. );
  937. const moonshotConfigComponent = null;
  938. const stabilityConfigComponent = null;
  939. const lflytekConfigComponent = accessStore.provider ===
  940. ServiceProvider.Iflytek && (
  941. <>
  942. <ListItem
  943. title={Locale.Settings.Access.Iflytek.Endpoint.Title}
  944. subTitle={
  945. Locale.Settings.Access.Iflytek.Endpoint.SubTitle +
  946. Iflytek.ExampleEndpoint
  947. }
  948. >
  949. <input
  950. aria-label={Locale.Settings.Access.Iflytek.Endpoint.Title}
  951. type="text"
  952. value={accessStore.iflytekUrl}
  953. placeholder={Iflytek.ExampleEndpoint}
  954. onChange={(e) =>
  955. accessStore.update(
  956. (access) => (access.iflytekUrl = e.currentTarget.value),
  957. )
  958. }
  959. ></input>
  960. </ListItem>
  961. <ListItem
  962. title={Locale.Settings.Access.Iflytek.ApiKey.Title}
  963. subTitle={Locale.Settings.Access.Iflytek.ApiKey.SubTitle}
  964. >
  965. <PasswordInput
  966. aria-label={Locale.Settings.Access.Iflytek.ApiKey.Title}
  967. value={accessStore.iflytekApiKey}
  968. type="text"
  969. placeholder={Locale.Settings.Access.Iflytek.ApiKey.Placeholder}
  970. onChange={(e) => {
  971. accessStore.update(
  972. (access) => (access.iflytekApiKey = e.currentTarget.value),
  973. );
  974. }}
  975. />
  976. </ListItem>
  977. <ListItem
  978. title={Locale.Settings.Access.Iflytek.ApiSecret.Title}
  979. subTitle={Locale.Settings.Access.Iflytek.ApiSecret.SubTitle}
  980. >
  981. <PasswordInput
  982. aria-label={Locale.Settings.Access.Iflytek.ApiSecret.Title}
  983. value={accessStore.iflytekApiSecret}
  984. type="text"
  985. placeholder={Locale.Settings.Access.Iflytek.ApiSecret.Placeholder}
  986. onChange={(e) => {
  987. accessStore.update(
  988. (access) => (access.iflytekApiSecret = e.currentTarget.value),
  989. );
  990. }}
  991. />
  992. </ListItem>
  993. </>
  994. );
  995. return (
  996. <ErrorBoundary>
  997. <div className="window-header" data-tauri-drag-region>
  998. <div className="window-header-title">
  999. <div className="window-header-main-title">
  1000. {Locale.Settings.Title}
  1001. </div>
  1002. <div className="window-header-sub-title">
  1003. {Locale.Settings.SubTitle}
  1004. </div>
  1005. </div>
  1006. <div className="window-actions">
  1007. <div className="window-action-button"></div>
  1008. <div className="window-action-button"></div>
  1009. <div className="window-action-button">
  1010. <IconButton
  1011. aria={Locale.UI.Close}
  1012. icon={<CloseIcon />}
  1013. onClick={() => navigate(Path.Home)}
  1014. bordered
  1015. />
  1016. </div>
  1017. </div>
  1018. </div>
  1019. <div className={styles["settings"]}>
  1020. <List>
  1021. <ListItem title={Locale.Settings.Avatar}>
  1022. <Popover
  1023. onClose={() => setShowEmojiPicker(false)}
  1024. content={
  1025. <AvatarPicker
  1026. onEmojiClick={(avatar: string) => {
  1027. updateConfig((config) => (config.avatar = avatar));
  1028. setShowEmojiPicker(false);
  1029. }}
  1030. />
  1031. }
  1032. open={showEmojiPicker}
  1033. >
  1034. <div
  1035. aria-label={Locale.Settings.Avatar}
  1036. tabIndex={0}
  1037. className={styles.avatar}
  1038. onClick={() => {
  1039. setShowEmojiPicker(!showEmojiPicker);
  1040. }}
  1041. >
  1042. <Avatar avatar={config.avatar} />
  1043. </div>
  1044. </Popover>
  1045. </ListItem>
  1046. <ListItem title={Locale.Settings.SendKey}>
  1047. <Select
  1048. aria-label={Locale.Settings.SendKey}
  1049. value={config.submitKey}
  1050. onChange={(e) => {
  1051. updateConfig(
  1052. (config) =>
  1053. (config.submitKey = e.target.value as any as SubmitKey),
  1054. );
  1055. }}
  1056. >
  1057. {Object.values(SubmitKey).map((v) => (
  1058. <option value={v} key={v}>
  1059. {v}
  1060. </option>
  1061. ))}
  1062. </Select>
  1063. </ListItem>
  1064. <ListItem title={Locale.Settings.Theme}>
  1065. <Select
  1066. aria-label={Locale.Settings.Theme}
  1067. value={config.theme}
  1068. onChange={(e) => {
  1069. updateConfig(
  1070. (config) => (config.theme = e.target.value as any as Theme),
  1071. );
  1072. }}
  1073. >
  1074. {Object.values(Theme).map((v) => (
  1075. <option value={v} key={v}>
  1076. {v}
  1077. </option>
  1078. ))}
  1079. </Select>
  1080. </ListItem>
  1081. <ListItem title={Locale.Settings.Lang.Name}>
  1082. <Select
  1083. aria-label={Locale.Settings.Lang.Name}
  1084. value={getLang()}
  1085. onChange={(e) => {
  1086. changeLang(e.target.value as any);
  1087. }}
  1088. >
  1089. {AllLangs.map((lang) => (
  1090. <option value={lang} key={lang}>
  1091. {ALL_LANG_OPTIONS[lang]}
  1092. </option>
  1093. ))}
  1094. </Select>
  1095. </ListItem>
  1096. <ListItem
  1097. title={Locale.Settings.FontSize.Title}
  1098. subTitle={Locale.Settings.FontSize.SubTitle}
  1099. >
  1100. <InputRange
  1101. aria={Locale.Settings.FontSize.Title}
  1102. title={`${config.fontSize ?? 14}px`}
  1103. value={config.fontSize}
  1104. min="12"
  1105. max="40"
  1106. step="1"
  1107. onChange={(e) =>
  1108. updateConfig(
  1109. (config) =>
  1110. (config.fontSize = Number.parseInt(e.currentTarget.value)),
  1111. )
  1112. }
  1113. ></InputRange>
  1114. </ListItem>
  1115. <ListItem
  1116. title={Locale.Settings.FontFamily.Title}
  1117. subTitle={Locale.Settings.FontFamily.SubTitle}
  1118. >
  1119. <input
  1120. aria-label={Locale.Settings.FontFamily.Title}
  1121. type="text"
  1122. value={config.fontFamily}
  1123. placeholder={Locale.Settings.FontFamily.Placeholder}
  1124. onChange={(e) =>
  1125. updateConfig(
  1126. (config) => (config.fontFamily = e.currentTarget.value),
  1127. )
  1128. }
  1129. ></input>
  1130. </ListItem>
  1131. <ListItem
  1132. title={Locale.Settings.AutoGenerateTitle.Title}
  1133. subTitle={Locale.Settings.AutoGenerateTitle.SubTitle}
  1134. >
  1135. <input
  1136. aria-label={Locale.Settings.AutoGenerateTitle.Title}
  1137. type="checkbox"
  1138. checked={config.enableAutoGenerateTitle}
  1139. onChange={(e) =>
  1140. updateConfig(
  1141. (config) =>
  1142. (config.enableAutoGenerateTitle = e.currentTarget.checked),
  1143. )
  1144. }
  1145. ></input>
  1146. </ListItem>
  1147. <ListItem
  1148. title={Locale.Settings.SendPreviewBubble.Title}
  1149. subTitle={Locale.Settings.SendPreviewBubble.SubTitle}
  1150. >
  1151. <input
  1152. aria-label={Locale.Settings.SendPreviewBubble.Title}
  1153. type="checkbox"
  1154. checked={config.sendPreviewBubble}
  1155. onChange={(e) =>
  1156. updateConfig(
  1157. (config) =>
  1158. (config.sendPreviewBubble = e.currentTarget.checked),
  1159. )
  1160. }
  1161. ></input>
  1162. </ListItem>
  1163. </List>
  1164. <SyncItems />
  1165. <List>
  1166. <ListItem
  1167. title={Locale.Settings.Mask.Splash.Title}
  1168. subTitle={Locale.Settings.Mask.Splash.SubTitle}
  1169. >
  1170. <input
  1171. aria-label={Locale.Settings.Mask.Splash.Title}
  1172. type="checkbox"
  1173. checked={!config.dontShowMaskSplashScreen}
  1174. onChange={(e) =>
  1175. updateConfig(
  1176. (config) =>
  1177. (config.dontShowMaskSplashScreen =
  1178. !e.currentTarget.checked),
  1179. )
  1180. }
  1181. ></input>
  1182. </ListItem>
  1183. <ListItem
  1184. title={Locale.Settings.Mask.Builtin.Title}
  1185. subTitle={Locale.Settings.Mask.Builtin.SubTitle}
  1186. >
  1187. <input
  1188. aria-label={Locale.Settings.Mask.Builtin.Title}
  1189. type="checkbox"
  1190. checked={config.hideBuiltinMasks}
  1191. onChange={(e) =>
  1192. updateConfig(
  1193. (config) =>
  1194. (config.hideBuiltinMasks = e.currentTarget.checked),
  1195. )
  1196. }
  1197. ></input>
  1198. </ListItem>
  1199. </List>
  1200. <List>
  1201. <ListItem
  1202. title={Locale.Settings.Prompt.Disable.Title}
  1203. subTitle={Locale.Settings.Prompt.Disable.SubTitle}
  1204. >
  1205. <input
  1206. aria-label={Locale.Settings.Prompt.Disable.Title}
  1207. type="checkbox"
  1208. checked={config.disablePromptHint}
  1209. onChange={(e) =>
  1210. updateConfig(
  1211. (config) =>
  1212. (config.disablePromptHint = e.currentTarget.checked),
  1213. )
  1214. }
  1215. ></input>
  1216. </ListItem>
  1217. <ListItem
  1218. title={Locale.Settings.Prompt.List}
  1219. subTitle={Locale.Settings.Prompt.ListCount(
  1220. builtinCount,
  1221. customCount,
  1222. )}
  1223. >
  1224. <IconButton
  1225. aria={Locale.Settings.Prompt.List + Locale.Settings.Prompt.Edit}
  1226. icon={<EditIcon />}
  1227. text={Locale.Settings.Prompt.Edit}
  1228. onClick={() => setShowPromptModal(true)}
  1229. />
  1230. </ListItem>
  1231. </List>
  1232. <List id={SlotID.CustomModel}>
  1233. {accessCodeComponent}
  1234. {!accessStore.hideUserApiKey && (
  1235. <>
  1236. {useCustomConfigComponent}
  1237. {accessStore.useCustomConfig && (
  1238. <>
  1239. <ListItem
  1240. title={Locale.Settings.Access.Provider.Title}
  1241. subTitle={Locale.Settings.Access.Provider.SubTitle}
  1242. >
  1243. <Select
  1244. aria-label={Locale.Settings.Access.Provider.Title}
  1245. value={accessStore.provider}
  1246. onChange={(e) => {
  1247. accessStore.update(
  1248. (access) =>
  1249. (access.provider = e.target
  1250. .value as ServiceProvider),
  1251. );
  1252. }}
  1253. >
  1254. {Object.entries(ServiceProvider).map(([k, v]) => (
  1255. <option value={v} key={k}>
  1256. {k}
  1257. </option>
  1258. ))}
  1259. </Select>
  1260. </ListItem>
  1261. {openAIConfigComponent}
  1262. {azureConfigComponent}
  1263. {baiduConfigComponent}
  1264. {byteDanceConfigComponent}
  1265. {alibabaConfigComponent}
  1266. {tencentConfigComponent}
  1267. {lflytekConfigComponent}
  1268. </>
  1269. )}
  1270. </>
  1271. )}
  1272. <ListItem
  1273. title={Locale.Settings.Access.CustomModel.Title}
  1274. subTitle={Locale.Settings.Access.CustomModel.SubTitle}
  1275. >
  1276. <input
  1277. aria-label={Locale.Settings.Access.CustomModel.Title}
  1278. type="text"
  1279. value={config.customModels}
  1280. placeholder="model1,model2,model3"
  1281. onChange={(e) =>
  1282. config.update(
  1283. (config) => (config.customModels = e.currentTarget.value),
  1284. )
  1285. }
  1286. ></input>
  1287. </ListItem>
  1288. </List>
  1289. <List>
  1290. <ModelConfigList
  1291. modelConfig={config.modelConfig}
  1292. updateConfig={(updater) => {
  1293. const modelConfig = { ...config.modelConfig };
  1294. updater(modelConfig);
  1295. config.update((config) => (config.modelConfig = modelConfig));
  1296. }}
  1297. />
  1298. </List>
  1299. {shouldShowPromptModal && (
  1300. <UserPromptModal onClose={() => setShowPromptModal(false)} />
  1301. )}
  1302. <DangerItems />
  1303. </div>
  1304. </ErrorBoundary>
  1305. );
  1306. }