From 30473ec41e68842bf0eed03f9a308ca8aaa551b5 Mon Sep 17 00:00:00 2001 From: Yidadaa Date: Sun, 16 Jul 2023 16:14:57 +0800 Subject: [PATCH] fix: #2367 do not copy in async callback after sharing to ShareGPT --- app/api/common.ts | 2 +- app/components/exporter.tsx | 26 +++++++++++++++++++++++++- 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/app/api/common.ts b/app/api/common.ts index 5222ee941..3146b6bd9 100644 --- a/app/api/common.ts +++ b/app/api/common.ts @@ -3,7 +3,7 @@ import { NextRequest, NextResponse } from "next/server"; export const OPENAI_URL = "api.openai.com"; const DEFAULT_PROTOCOL = "https"; const PROTOCOL = process.env.PROTOCOL || DEFAULT_PROTOCOL; -const BASE_URL = process.env.BASE_URL || OPENAI_URL; // ?? 仅在 undefined 时候才转向后者,但是环境变量大家都不会去注释掉变量,因此最好用 || +const BASE_URL = process.env.BASE_URL || OPENAI_URL; const DISABLE_GPT4 = !!process.env.DISABLE_GPT4; export async function requestOpenai(req: NextRequest) { diff --git a/app/components/exporter.tsx b/app/components/exporter.tsx index f88965f95..ab6fad29e 100644 --- a/app/components/exporter.tsx +++ b/app/components/exporter.tsx @@ -8,6 +8,7 @@ import { Modal, Select, showImageModal, + showModal, showToast, } from "./ui-lib"; import { IconButton } from "./button"; @@ -287,7 +288,30 @@ export function PreviewActions(props: { .share(msgs) .then((res) => { if (!res) return; - copyToClipboard(res); + showModal({ + title: Locale.Export.Share, + children: [ + e.currentTarget.select()} + >, + ], + actions: [ + } + text={Locale.Chat.Actions.Copy} + key="copy" + onClick={() => copyToClipboard(res)} + />, + ], + }); setTimeout(() => { window.open(res, "_blank"); }, 800);