From 908ee0060f4e3a84afb63a182eee49b774b7e812 Mon Sep 17 00:00:00 2001
From: Dogtiti <499960698@qq.com>
Date: Tue, 23 Jul 2024 22:23:34 +0800
Subject: [PATCH] chore: remove sd new
---
app/components/home.tsx | 6 +-
app/components/sd/index.tsx | 1 -
app/components/sd/sd-new.tsx | 127 -------------------------------
app/components/sd/sd-sidebar.tsx | 58 +++++++++++---
app/components/sd/sd.tsx | 12 ++-
5 files changed, 57 insertions(+), 147 deletions(-)
delete mode 100644 app/components/sd/sd-new.tsx
diff --git a/app/components/home.tsx b/app/components/home.tsx
index 19ecb730f..40929b240 100644
--- a/app/components/home.tsx
+++ b/app/components/home.tsx
@@ -59,10 +59,6 @@ const Sd = dynamic(async () => (await import("./sd")).Sd, {
loading: () => ,
});
-const SdNew = dynamic(async () => (await import("./sd")).SdNew, {
- loading: () => ,
-});
-
export function useSwitchTheme() {
const config = useAppConfig();
@@ -157,7 +153,7 @@ function Screen() {
const renderContent = () => {
if (isAuth) return ;
if (isSd) return ;
- if (isSdNew) return ;
+ if (isSdNew) return ;
return (
<>
diff --git a/app/components/sd/index.tsx b/app/components/sd/index.tsx
index f2808bd3e..d442c22bc 100644
--- a/app/components/sd/index.tsx
+++ b/app/components/sd/index.tsx
@@ -1,3 +1,2 @@
export * from "./sd";
export * from "./sd-panel";
-export * from "./sd-new";
diff --git a/app/components/sd/sd-new.tsx b/app/components/sd/sd-new.tsx
deleted file mode 100644
index 682cbfb2f..000000000
--- a/app/components/sd/sd-new.tsx
+++ /dev/null
@@ -1,127 +0,0 @@
-import homeStyles from "@/app/components/home.module.scss";
-
-import { IconButton } from "@/app/components/button";
-import GithubIcon from "@/app/icons/github.svg";
-import ReturnIcon from "@/app/icons/return.svg";
-import Locale from "@/app/locales";
-import HistoryIcon from "@/app/icons/history.svg";
-
-import { Path, REPO_URL } from "@/app/constant";
-
-import { useNavigate } from "react-router-dom";
-import dynamic from "next/dynamic";
-import {
- SideBarContainer,
- SideBarBody,
- SideBarTail,
- useDragSideBar,
- useHotKey,
-} from "@/app/components/sidebar";
-import { getParams, getModelParamBasicData } from "./sd-panel";
-import { useSdStore } from "@/app/store/sd";
-import { showToast } from "@/app/components/ui-lib";
-
-const SdPanel = dynamic(
- async () => (await import("@/app/components/sd")).SdPanel,
- {
- loading: () => null,
- },
-);
-
-export function SdNew() {
- useHotKey();
- const { onDragStart, shouldNarrow } = useDragSideBar();
- const navigate = useNavigate();
- const sdStore = useSdStore();
- const currentModel = sdStore.currentModel;
- const params = sdStore.currentParams;
- const setParams = sdStore.setCurrentParams;
-
- const handleSubmit = () => {
- const columns = getParams?.(currentModel, params);
- const reqParams: any = {};
- for (let i = 0; i < columns.length; i++) {
- const item = columns[i];
- reqParams[item.value] = params[item.value] ?? null;
- if (item.required) {
- if (!reqParams[item.value]) {
- showToast(Locale.SdPanel.ParamIsRequired(item.name));
- return;
- }
- }
- }
- let data: any = {
- model: currentModel.value,
- model_name: currentModel.name,
- status: "wait",
- params: reqParams,
- created_at: new Date().toLocaleString(),
- img_data: "",
- };
- sdStore.sendTask(data, () => {
- setParams(getModelParamBasicData(columns, params, true));
- navigate(Path.Sd);
- });
- };
- return (
-
-
- {
-
-
- }
- bordered
- title={Locale.Sd.Actions.ReturnHome}
- onClick={() => navigate(Path.Home)}
- />
-
-
- }
-
-
-
-
- }
- bordered
- title={Locale.Sd.Actions.History}
- onClick={() => navigate(Path.Sd)}
- />
-
-
-
-
-
-
-
- } shadow />
-
- }
- secondaryAction={
-
- }
- />
-
- );
-}
diff --git a/app/components/sd/sd-sidebar.tsx b/app/components/sd/sd-sidebar.tsx
index fcb97d300..4510a7c46 100644
--- a/app/components/sd/sd-sidebar.tsx
+++ b/app/components/sd/sd-sidebar.tsx
@@ -2,6 +2,7 @@ import { IconButton } from "@/app/components/button";
import GithubIcon from "@/app/icons/github.svg";
import SDIcon from "@/app/icons/sd.svg";
import ReturnIcon from "@/app/icons/return.svg";
+import HistoryIcon from "@/app/icons/history.svg";
import Locale from "@/app/locales";
import { Path, REPO_URL } from "@/app/constant";
@@ -20,6 +21,7 @@ import {
import { getParams, getModelParamBasicData } from "./sd-panel";
import { useSdStore } from "@/app/store/sd";
import { showToast } from "@/app/components/ui-lib";
+import { useMobileScreen } from "@/app/utils";
const SdPanel = dynamic(
async () => (await import("@/app/components/sd")).SdPanel,
@@ -30,6 +32,7 @@ const SdPanel = dynamic(
export function SideBar(props: { className?: string }) {
useHotKey();
+ const isMobileScreen = useMobileScreen();
const { onDragStart, shouldNarrow } = useDragSideBar();
const navigate = useNavigate();
const sdStore = useSdStore();
@@ -69,17 +72,50 @@ export function SideBar(props: { className?: string }) {
shouldNarrow={shouldNarrow}
{...props}
>
- }
- bordered
- title={Locale.Sd.Actions.ReturnHome}
- onClick={() => navigate(Path.Home)}
- />
- }
- logo={}
- >
+ {isMobileScreen ? (
+
+
+
+ }
+ bordered
+ title={Locale.Sd.Actions.ReturnHome}
+ onClick={() => navigate(Path.Home)}
+ />
+
+
+
+
+
+ }
+ bordered
+ title={Locale.Sd.Actions.History}
+ onClick={() => navigate(Path.SdNew)}
+ />
+
+
+
+ ) : (
+ }
+ bordered
+ title={Locale.Sd.Actions.ReturnHome}
+ onClick={() => navigate(Path.Home)}
+ />
+ }
+ logo={}
+ >
+ )}
diff --git a/app/components/sd/sd.tsx b/app/components/sd/sd.tsx
index 9a1453046..c4ed6fa32 100644
--- a/app/components/sd/sd.tsx
+++ b/app/components/sd/sd.tsx
@@ -1,5 +1,7 @@
import chatStyles from "@/app/components/chat.module.scss";
import styles from "@/app/components/sd/sd.module.scss";
+import homeStyles from "@/app/components/home.module.scss";
+
import { IconButton } from "@/app/components/button";
import ReturnIcon from "@/app/icons/return.svg";
import Locale from "@/app/locales";
@@ -10,7 +12,7 @@ import {
getMessageTextContent,
useMobileScreen,
} from "@/app/utils";
-import { useNavigate } from "react-router-dom";
+import { useNavigate, useLocation } from "react-router-dom";
import { useAppConfig } from "@/app/store";
import MinIcon from "@/app/icons/min.svg";
import MaxIcon from "@/app/icons/max.svg";
@@ -24,6 +26,7 @@ import { useSdStore } from "@/app/store/sd";
import locales from "@/app/locales";
import LoadingIcon from "@/app/icons/three-dots.svg";
import ErrorIcon from "@/app/icons/delete.svg";
+import SDIcon from "@/app/icons/sd.svg";
import { Property } from "csstype";
import {
showConfirm,
@@ -88,12 +91,14 @@ function getSdTaskStatus(item: any) {
export function Sd() {
const isMobileScreen = useMobileScreen();
const navigate = useNavigate();
+ const location = useLocation();
const clientConfig = useMemo(() => getClientConfig(), []);
const showMaxIcon = !isMobileScreen && !clientConfig?.isApp;
const config = useAppConfig();
const scrollRef = useRef(null);
const sdStore = useSdStore();
const [sdImages, setSdImages] = useState(sdStore.draw);
+ const isSd = location.pathname === Path.Sd;
useEffect(() => {
setSdImages(sdStore.draw);
@@ -101,7 +106,7 @@ export function Sd() {
return (
<>
-
+
@@ -112,7 +117,7 @@ export function Sd() {
icon={}
bordered
title={Locale.Chat.Actions.ChatList}
- onClick={() => navigate(Path.SdNew)}
+ onClick={() => navigate(Path.Sd)}
/>
@@ -140,6 +145,7 @@ export function Sd() {
/>
)}
+ {isMobileScreen && }