diff --git a/app/components/auth.tsx b/app/components/auth.tsx
index de0df4542..1ca83dcd3 100644
--- a/app/components/auth.tsx
+++ b/app/components/auth.tsx
@@ -7,6 +7,8 @@ import { useAccessStore } from "../store";
import Locale from "../locales";
import BotIcon from "../icons/bot.svg";
+import { useEffect } from "react";
+import { getClientConfig } from "../config/client";
export function AuthPage() {
const navigate = useNavigate();
@@ -14,6 +16,13 @@ export function AuthPage() {
const goHome = () => navigate(Path.Home);
+ useEffect(() => {
+ if (getClientConfig()?.isApp) {
+ navigate(Path.Settings);
+ }
+ // eslint-disable-next-line react-hooks/exhaustive-deps
+ }, []);
+
return (
diff --git a/app/components/chat.tsx b/app/components/chat.tsx
index f661d0a47..656208585 100644
--- a/app/components/chat.tsx
+++ b/app/components/chat.tsx
@@ -1123,9 +1123,9 @@ function _Chat() {
10,
);
chatStore.updateCurrentSession((session) => {
- const m = session.messages.find(
- (m) => m.id === message.id,
- );
+ const m = session.mask.context
+ .concat(session.messages)
+ .find((m) => m.id === message.id);
if (m) {
m.content = newMessage;
}
diff --git a/app/components/exporter.tsx b/app/components/exporter.tsx
index ab6fad29e..604b8823d 100644
--- a/app/components/exporter.tsx
+++ b/app/components/exporter.tsx
@@ -127,7 +127,7 @@ export function MessageExporter() {
];
const { currentStep, setCurrentStepIndex, currentStepIndex } =
useSteps(steps);
- const formats = ["text", "image"] as const;
+ const formats = ["text", "image", "json"] as const;
type ExportFormat = (typeof formats)[number];
const [exportConfig, setExportConfig] = useState({
@@ -157,7 +157,21 @@ export function MessageExporter() {
session.mask.context,
selection,
]);
-
+ function preview() {
+ if (exportConfig.format === "text") {
+ return (
+
+ );
+ } else if (exportConfig.format === "json") {
+ return (
+
+ );
+ } else {
+ return (
+
+ );
+ }
+ }
return (
<>
{currentStep.value === "preview" && (
-
- {exportConfig.format === "text" ? (
-
- ) : (
-
- )}
-
+
{preview()}
)}
>
);
@@ -545,12 +550,44 @@ export function MarkdownPreviewer(props: {
const download = () => {
downloadAs(mdText, `${props.topic}.md`);
};
-
return (
<>
+
+ >
+ );
+}
+
+export function JsonPreviewer(props: {
+ messages: ChatMessage[];
+ topic: string;
+}) {
+ const msgs = props.messages.map((m) => ({
+ role: m.role,
+ content: m.content,
+ }));
+ const mdText = "\n" + JSON.stringify(msgs, null, 2) + "\n";
+
+ const copy = () => {
+ copyToClipboard(JSON.stringify(msgs, null, 2));
+ };
+ const download = () => {
+ downloadAs(JSON.stringify(msgs, null, 2), `${props.topic}.json`);
+ };
+
+ return (
+ <>
+
diff --git a/app/locales/cn.ts b/app/locales/cn.ts
index 3929e09e7..19e804b3a 100644
--- a/app/locales/cn.ts
+++ b/app/locales/cn.ts
@@ -1,10 +1,14 @@
+import { getClientConfig } from "../config/client";
import { SubmitKey } from "../store/config";
+const isApp = !!getClientConfig()?.isApp;
+
const cn = {
WIP: "该功能仍在开发中……",
Error: {
- Unauthorized:
- "访问密码不正确或为空,请前往[登录](/#/auth)页输入正确的访问密码,或者在[设置](/#/settings)页填入你自己的 OpenAI API Key。",
+ Unauthorized: isApp
+ ? "检测到无效 API Key,请前往[设置](/#/settings)页检查 API Key 是否配置正确。"
+ : "访问密码不正确或为空,请前往[登录](/#/auth)页输入正确的访问密码,或者在[设置](/#/settings)页填入你自己的 OpenAI API Key。",
},
Auth: {
Title: "需要密码",
diff --git a/app/locales/en.ts b/app/locales/en.ts
index d37149c92..64cdc38bb 100644
--- a/app/locales/en.ts
+++ b/app/locales/en.ts
@@ -1,12 +1,16 @@
+import { getClientConfig } from "../config/client";
import { SubmitKey } from "../store/config";
import { LocaleType } from "./index";
// if you are adding a new translation, please use PartialLocaleType instead of LocaleType
+
+const isApp = !!getClientConfig()?.isApp;
const en: LocaleType = {
WIP: "Coming Soon...",
Error: {
- Unauthorized:
- "Unauthorized access, please enter access code in [auth](/#/auth) page.",
+ Unauthorized: isApp
+ ? "Invalid API Key, please check it in [Settings](/#/settings) page."
+ : "Unauthorized access, please enter access code in [auth](/#/auth) page, or enter your OpenAI API Key.",
},
Auth: {
Title: "Need Access Code",