chore: artifact => artifacts
This commit is contained in:
parent
f2d2622172
commit
6737f016f5
|
@ -1,4 +1,4 @@
|
||||||
.artifact {
|
.artifacts {
|
||||||
display: flex;
|
display: flex;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
|
@ -23,7 +23,7 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.artifact-iframe {
|
.artifacts-iframe {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
border: var(--border-in-light);
|
border: var(--border-in-light);
|
||||||
border-radius: 6px;
|
border-radius: 6px;
|
|
@ -13,7 +13,7 @@ import { Modal, showToast } from "./ui-lib";
|
||||||
import { copyToClipboard, downloadAs } from "../utils";
|
import { copyToClipboard, downloadAs } from "../utils";
|
||||||
import { Path, ApiPath, REPO_URL } from "@/app/constant";
|
import { Path, ApiPath, REPO_URL } from "@/app/constant";
|
||||||
import { Loading } from "./home";
|
import { Loading } from "./home";
|
||||||
import styles from "./artifact.module.scss";
|
import styles from "./artifacts.module.scss";
|
||||||
|
|
||||||
export function HTMLPreview(props: {
|
export function HTMLPreview(props: {
|
||||||
code: string;
|
code: string;
|
||||||
|
@ -72,7 +72,7 @@ export function HTMLPreview(props: {
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<iframe
|
<iframe
|
||||||
className={styles["artifact-iframe"]}
|
className={styles["artifacts-iframe"]}
|
||||||
id={frameId.current}
|
id={frameId.current}
|
||||||
ref={ref}
|
ref={ref}
|
||||||
sandbox="allow-forms allow-modals allow-scripts"
|
sandbox="allow-forms allow-modals allow-scripts"
|
||||||
|
@ -83,7 +83,7 @@ export function HTMLPreview(props: {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function ArtifactShareButton({
|
export function ArtifactsShareButton({
|
||||||
getCode,
|
getCode,
|
||||||
id,
|
id,
|
||||||
style,
|
style,
|
||||||
|
@ -98,13 +98,13 @@ export function ArtifactShareButton({
|
||||||
const [name, setName] = useState(id);
|
const [name, setName] = useState(id);
|
||||||
const [show, setShow] = useState(false);
|
const [show, setShow] = useState(false);
|
||||||
const shareUrl = useMemo(
|
const shareUrl = useMemo(
|
||||||
() => [location.origin, "#", Path.Artifact, "/", name].join(""),
|
() => [location.origin, "#", Path.Artifacts, "/", name].join(""),
|
||||||
[name],
|
[name],
|
||||||
);
|
);
|
||||||
const upload = (code: string) =>
|
const upload = (code: string) =>
|
||||||
id
|
id
|
||||||
? Promise.resolve({ id })
|
? Promise.resolve({ id })
|
||||||
: fetch(ApiPath.Artifact, {
|
: fetch(ApiPath.Artifacts, {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
body: code,
|
body: code,
|
||||||
})
|
})
|
||||||
|
@ -116,7 +116,7 @@ export function ArtifactShareButton({
|
||||||
throw Error();
|
throw Error();
|
||||||
})
|
})
|
||||||
.catch((e) => {
|
.catch((e) => {
|
||||||
showToast(Locale.Export.Artifact.Error);
|
showToast(Locale.Export.Artifacts.Error);
|
||||||
});
|
});
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
|
@ -124,7 +124,7 @@ export function ArtifactShareButton({
|
||||||
<IconButton
|
<IconButton
|
||||||
icon={loading ? <LoadingButtonIcon /> : <ExportIcon />}
|
icon={loading ? <LoadingButtonIcon /> : <ExportIcon />}
|
||||||
bordered
|
bordered
|
||||||
title={Locale.Export.Artifact.Title}
|
title={Locale.Export.Artifacts.Title}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
if (loading) return;
|
if (loading) return;
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
|
@ -142,7 +142,7 @@ export function ArtifactShareButton({
|
||||||
{show && (
|
{show && (
|
||||||
<div className="modal-mask">
|
<div className="modal-mask">
|
||||||
<Modal
|
<Modal
|
||||||
title={Locale.Export.Artifact.Title}
|
title={Locale.Export.Artifacts.Title}
|
||||||
onClose={() => setShow(false)}
|
onClose={() => setShow(false)}
|
||||||
actions={[
|
actions={[
|
||||||
<IconButton
|
<IconButton
|
||||||
|
@ -179,7 +179,7 @@ export function ArtifactShareButton({
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function Artifact() {
|
export function Artifacts() {
|
||||||
const { id } = useParams();
|
const { id } = useParams();
|
||||||
const [code, setCode] = useState("");
|
const [code, setCode] = useState("");
|
||||||
const [loading, setLoading] = useState(true);
|
const [loading, setLoading] = useState(true);
|
||||||
|
@ -187,7 +187,7 @@ export function Artifact() {
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (id) {
|
if (id) {
|
||||||
fetch(`${ApiPath.Artifact}?id=${id}`)
|
fetch(`${ApiPath.Artifacts}?id=${id}`)
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
if (res.status > 300) {
|
if (res.status > 300) {
|
||||||
throw Error("can not get content");
|
throw Error("can not get content");
|
||||||
|
@ -197,21 +197,25 @@ export function Artifact() {
|
||||||
.then((res) => res.text())
|
.then((res) => res.text())
|
||||||
.then(setCode)
|
.then(setCode)
|
||||||
.catch((e) => {
|
.catch((e) => {
|
||||||
showToast(Locale.Export.Artifact.Error);
|
showToast(Locale.Export.Artifacts.Error);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}, [id]);
|
}, [id]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={styles["artifact"]}>
|
<div className={styles["artifacts"]}>
|
||||||
<div className={styles["artifact-header"]}>
|
<div className={styles["artifacts-header"]}>
|
||||||
<a href={REPO_URL} target="_blank" rel="noopener noreferrer">
|
<a href={REPO_URL} target="_blank" rel="noopener noreferrer">
|
||||||
<IconButton bordered icon={<GithubIcon />} shadow />
|
<IconButton bordered icon={<GithubIcon />} shadow />
|
||||||
</a>
|
</a>
|
||||||
<div className={styles["artifact-title"]}>NextChat Artifact</div>
|
<div className={styles["artifacts-title"]}>NextChat Artifacts</div>
|
||||||
<ArtifactShareButton id={id} getCode={() => code} fileName={fileName} />
|
<ArtifactsShareButton
|
||||||
|
id={id}
|
||||||
|
getCode={() => code}
|
||||||
|
fileName={fileName}
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div className={styles["artifact-content"]}>
|
<div className={styles["artifacts-content"]}>
|
||||||
{loading && <Loading />}
|
{loading && <Loading />}
|
||||||
{code && (
|
{code && (
|
||||||
<HTMLPreview
|
<HTMLPreview
|
|
@ -635,8 +635,8 @@ export function ChatActions(props: {
|
||||||
defaultSelectedValue={chatStore.currentSession().mask?.plugin}
|
defaultSelectedValue={chatStore.currentSession().mask?.plugin}
|
||||||
items={[
|
items={[
|
||||||
{
|
{
|
||||||
title: Locale.Plugin.Artifact,
|
title: Locale.Plugin.Artifacts,
|
||||||
value: Plugin.Artifact,
|
value: Plugin.Artifacts,
|
||||||
},
|
},
|
||||||
]}
|
]}
|
||||||
onClose={() => setShowPluginSelector(false)}
|
onClose={() => setShowPluginSelector(false)}
|
||||||
|
|
|
@ -39,7 +39,7 @@ export function Loading(props: { noLogo?: boolean }) {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const Artifact = dynamic(async () => (await import("./artifact")).Artifact, {
|
const Artifacts = dynamic(async () => (await import("./artifacts")).Artifacts, {
|
||||||
loading: () => <Loading noLogo />,
|
loading: () => <Loading noLogo />,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -141,7 +141,7 @@ export function WindowContent(props: { children: React.ReactNode }) {
|
||||||
function Screen() {
|
function Screen() {
|
||||||
const config = useAppConfig();
|
const config = useAppConfig();
|
||||||
const location = useLocation();
|
const location = useLocation();
|
||||||
const isArtifact = location.pathname.includes(Path.Artifact);
|
const isArtifact = location.pathname.includes(Path.Artifacts);
|
||||||
const isHome = location.pathname === Path.Home;
|
const isHome = location.pathname === Path.Home;
|
||||||
const isAuth = location.pathname === Path.Auth;
|
const isAuth = location.pathname === Path.Auth;
|
||||||
const isSd = location.pathname === Path.Sd;
|
const isSd = location.pathname === Path.Sd;
|
||||||
|
@ -158,7 +158,7 @@ function Screen() {
|
||||||
if (isArtifact) {
|
if (isArtifact) {
|
||||||
return (
|
return (
|
||||||
<Routes>
|
<Routes>
|
||||||
<Route path="/artifact/:id" element={<Artifact />} />
|
<Route path="/artifacts/:id" element={<Artifacts />} />
|
||||||
</Routes>
|
</Routes>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,7 +13,7 @@ import LoadingIcon from "../icons/three-dots.svg";
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import { useDebouncedCallback } from "use-debounce";
|
import { useDebouncedCallback } from "use-debounce";
|
||||||
import { showImageModal, FullScreen } from "./ui-lib";
|
import { showImageModal, FullScreen } from "./ui-lib";
|
||||||
import { ArtifactShareButton, HTMLPreview } from "./artifact";
|
import { ArtifactsShareButton, HTMLPreview } from "./artifacts";
|
||||||
import { Plugin } from "../constant";
|
import { Plugin } from "../constant";
|
||||||
import { useChatStore } from "../store";
|
import { useChatStore } from "../store";
|
||||||
export function Mermaid(props: { code: string }) {
|
export function Mermaid(props: { code: string }) {
|
||||||
|
@ -92,7 +92,7 @@ export function PreCode(props: { children: any }) {
|
||||||
}, [refText]);
|
}, [refText]);
|
||||||
|
|
||||||
const enableArtifacts = useMemo(
|
const enableArtifacts = useMemo(
|
||||||
() => plugins?.includes(Plugin.Artifact),
|
() => plugins?.includes(Plugin.Artifacts),
|
||||||
[plugins],
|
[plugins],
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -115,7 +115,7 @@ export function PreCode(props: { children: any }) {
|
||||||
)}
|
)}
|
||||||
{htmlCode.length > 0 && enableArtifacts && (
|
{htmlCode.length > 0 && enableArtifacts && (
|
||||||
<FullScreen className="no-dark html" right={70}>
|
<FullScreen className="no-dark html" right={70}>
|
||||||
<ArtifactShareButton
|
<ArtifactsShareButton
|
||||||
style={{ position: "absolute", right: 20, top: 10 }}
|
style={{ position: "absolute", right: 20, top: 10 }}
|
||||||
getCode={() => htmlCode}
|
getCode={() => htmlCode}
|
||||||
/>
|
/>
|
||||||
|
|
|
@ -35,7 +35,7 @@ export enum Path {
|
||||||
Auth = "/auth",
|
Auth = "/auth",
|
||||||
Sd = "/sd",
|
Sd = "/sd",
|
||||||
SdNew = "/sd-new",
|
SdNew = "/sd-new",
|
||||||
Artifact = "/artifact",
|
Artifacts = "/artifacts",
|
||||||
}
|
}
|
||||||
|
|
||||||
export enum ApiPath {
|
export enum ApiPath {
|
||||||
|
@ -48,7 +48,7 @@ export enum ApiPath {
|
||||||
ByteDance = "/api/bytedance",
|
ByteDance = "/api/bytedance",
|
||||||
Alibaba = "/api/alibaba",
|
Alibaba = "/api/alibaba",
|
||||||
Stability = "/api/stability",
|
Stability = "/api/stability",
|
||||||
Artifact = "/api/artifact",
|
Artifacts = "/api/artifacts",
|
||||||
}
|
}
|
||||||
|
|
||||||
export enum SlotID {
|
export enum SlotID {
|
||||||
|
@ -62,7 +62,7 @@ export enum FileName {
|
||||||
}
|
}
|
||||||
|
|
||||||
export enum Plugin {
|
export enum Plugin {
|
||||||
Artifact = "artifact",
|
Artifacts = "artifacts",
|
||||||
}
|
}
|
||||||
|
|
||||||
export enum StoreKey {
|
export enum StoreKey {
|
||||||
|
|
|
@ -104,7 +104,7 @@ const cn = {
|
||||||
Toast: "正在生成截图",
|
Toast: "正在生成截图",
|
||||||
Modal: "长按或右键保存图片",
|
Modal: "长按或右键保存图片",
|
||||||
},
|
},
|
||||||
Artifact: {
|
Artifacts: {
|
||||||
Title: "分享页面",
|
Title: "分享页面",
|
||||||
Error: "分享失败",
|
Error: "分享失败",
|
||||||
},
|
},
|
||||||
|
@ -461,7 +461,7 @@ const cn = {
|
||||||
},
|
},
|
||||||
Plugin: {
|
Plugin: {
|
||||||
Name: "插件",
|
Name: "插件",
|
||||||
Artifact: "Artifact",
|
Artifacts: "Artifacts",
|
||||||
},
|
},
|
||||||
Discovery: {
|
Discovery: {
|
||||||
Name: "发现",
|
Name: "发现",
|
||||||
|
|
|
@ -106,8 +106,8 @@ const en: LocaleType = {
|
||||||
Toast: "Capturing Image...",
|
Toast: "Capturing Image...",
|
||||||
Modal: "Long press or right click to save image",
|
Modal: "Long press or right click to save image",
|
||||||
},
|
},
|
||||||
Artifact: {
|
Artifacts: {
|
||||||
Title: "Share Artifact",
|
Title: "Share Artifacts",
|
||||||
Error: "Share Error",
|
Error: "Share Error",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -468,7 +468,7 @@ const en: LocaleType = {
|
||||||
},
|
},
|
||||||
Plugin: {
|
Plugin: {
|
||||||
Name: "Plugin",
|
Name: "Plugin",
|
||||||
Artifact: "Artifact",
|
Artifacts: "Artifacts",
|
||||||
},
|
},
|
||||||
Discovery: {
|
Discovery: {
|
||||||
Name: "Discovery",
|
Name: "Discovery",
|
||||||
|
|
Loading…
Reference in New Issue