Bläddra i källkod

chore: remove sd new

Dogtiti 1 år sedan
förälder
incheckning
908ee0060f

+ 1 - 5
app/components/home.tsx

@@ -59,10 +59,6 @@ const Sd = dynamic(async () => (await import("./sd")).Sd, {
   loading: () => <Loading noLogo />,
   loading: () => <Loading noLogo />,
 });
 });
 
 
-const SdNew = dynamic(async () => (await import("./sd")).SdNew, {
-  loading: () => <Loading noLogo />,
-});
-
 export function useSwitchTheme() {
 export function useSwitchTheme() {
   const config = useAppConfig();
   const config = useAppConfig();
 
 
@@ -157,7 +153,7 @@ function Screen() {
   const renderContent = () => {
   const renderContent = () => {
     if (isAuth) return <AuthPage />;
     if (isAuth) return <AuthPage />;
     if (isSd) return <Sd />;
     if (isSd) return <Sd />;
-    if (isSdNew) return <SdNew />;
+    if (isSdNew) return <Sd />;
     return (
     return (
       <>
       <>
         <SideBar className={isHome ? styles["sidebar-show"] : ""} />
         <SideBar className={isHome ? styles["sidebar-show"] : ""} />

+ 0 - 1
app/components/sd/index.tsx

@@ -1,3 +1,2 @@
 export * from "./sd";
 export * from "./sd";
 export * from "./sd-panel";
 export * from "./sd-panel";
-export * from "./sd-new";

+ 0 - 127
app/components/sd/sd-new.tsx

@@ -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 (
-    <SideBarContainer
-      onDragStart={onDragStart}
-      shouldNarrow={shouldNarrow}
-      className={homeStyles["sidebar-show"]}
-    >
-      <div
-        className="window-header"
-        data-tauri-drag-region
-        style={{
-          paddingLeft: 0,
-          paddingRight: 0,
-        }}
-      >
-        {
-          <div className="window-actions">
-            <div className="window-action-button">
-              <IconButton
-                icon={<ReturnIcon />}
-                bordered
-                title={Locale.Sd.Actions.ReturnHome}
-                onClick={() => navigate(Path.Home)}
-              />
-            </div>
-          </div>
-        }
-
-        <div className={`window-header-title`}>
-          <div className={`window-header-main-title`}>Stability</div>
-        </div>
-        <div className="window-actions">
-          <div className="window-action-button">
-            <IconButton
-              icon={<HistoryIcon />}
-              bordered
-              title={Locale.Sd.Actions.History}
-              onClick={() => navigate(Path.Sd)}
-            />
-          </div>
-        </div>
-      </div>
-      <SideBarBody>
-        <SdPanel />
-      </SideBarBody>
-      <SideBarTail
-        primaryAction={
-          <a href={REPO_URL} target="_blank" rel="noopener noreferrer">
-            <IconButton icon={<GithubIcon />} shadow />
-          </a>
-        }
-        secondaryAction={
-          <IconButton
-            text={Locale.SdPanel.Submit}
-            type="primary"
-            shadow
-            onClick={handleSubmit}
-          ></IconButton>
-        }
-      />
-    </SideBarContainer>
-  );
-}

+ 47 - 11
app/components/sd/sd-sidebar.tsx

@@ -2,6 +2,7 @@ import { IconButton } from "@/app/components/button";
 import GithubIcon from "@/app/icons/github.svg";
 import GithubIcon from "@/app/icons/github.svg";
 import SDIcon from "@/app/icons/sd.svg";
 import SDIcon from "@/app/icons/sd.svg";
 import ReturnIcon from "@/app/icons/return.svg";
 import ReturnIcon from "@/app/icons/return.svg";
+import HistoryIcon from "@/app/icons/history.svg";
 import Locale from "@/app/locales";
 import Locale from "@/app/locales";
 
 
 import { Path, REPO_URL } from "@/app/constant";
 import { Path, REPO_URL } from "@/app/constant";
@@ -20,6 +21,7 @@ import {
 import { getParams, getModelParamBasicData } from "./sd-panel";
 import { getParams, getModelParamBasicData } from "./sd-panel";
 import { useSdStore } from "@/app/store/sd";
 import { useSdStore } from "@/app/store/sd";
 import { showToast } from "@/app/components/ui-lib";
 import { showToast } from "@/app/components/ui-lib";
+import { useMobileScreen } from "@/app/utils";
 
 
 const SdPanel = dynamic(
 const SdPanel = dynamic(
   async () => (await import("@/app/components/sd")).SdPanel,
   async () => (await import("@/app/components/sd")).SdPanel,
@@ -30,6 +32,7 @@ const SdPanel = dynamic(
 
 
 export function SideBar(props: { className?: string }) {
 export function SideBar(props: { className?: string }) {
   useHotKey();
   useHotKey();
+  const isMobileScreen = useMobileScreen();
   const { onDragStart, shouldNarrow } = useDragSideBar();
   const { onDragStart, shouldNarrow } = useDragSideBar();
   const navigate = useNavigate();
   const navigate = useNavigate();
   const sdStore = useSdStore();
   const sdStore = useSdStore();
@@ -69,17 +72,50 @@ export function SideBar(props: { className?: string }) {
       shouldNarrow={shouldNarrow}
       shouldNarrow={shouldNarrow}
       {...props}
       {...props}
     >
     >
-      <SideBarHeader
-        title={
-          <IconButton
-            icon={<ReturnIcon />}
-            bordered
-            title={Locale.Sd.Actions.ReturnHome}
-            onClick={() => navigate(Path.Home)}
-          />
-        }
-        logo={<SDIcon width={38} height={38} />}
-      ></SideBarHeader>
+      {isMobileScreen ? (
+        <div
+          className="window-header"
+          data-tauri-drag-region
+          style={{
+            paddingLeft: 0,
+            paddingRight: 0,
+          }}
+        >
+          <div className="window-actions">
+            <div className="window-action-button">
+              <IconButton
+                icon={<ReturnIcon />}
+                bordered
+                title={Locale.Sd.Actions.ReturnHome}
+                onClick={() => navigate(Path.Home)}
+              />
+            </div>
+          </div>
+          <SDIcon width={50} height={50} />
+          <div className="window-actions">
+            <div className="window-action-button">
+              <IconButton
+                icon={<HistoryIcon />}
+                bordered
+                title={Locale.Sd.Actions.History}
+                onClick={() => navigate(Path.SdNew)}
+              />
+            </div>
+          </div>
+        </div>
+      ) : (
+        <SideBarHeader
+          title={
+            <IconButton
+              icon={<ReturnIcon />}
+              bordered
+              title={Locale.Sd.Actions.ReturnHome}
+              onClick={() => navigate(Path.Home)}
+            />
+          }
+          logo={<SDIcon width={38} height={38} />}
+        ></SideBarHeader>
+      )}
       <SideBarBody>
       <SideBarBody>
         <SdPanel />
         <SdPanel />
       </SideBarBody>
       </SideBarBody>

+ 9 - 3
app/components/sd/sd.tsx

@@ -1,5 +1,7 @@
 import chatStyles from "@/app/components/chat.module.scss";
 import chatStyles from "@/app/components/chat.module.scss";
 import styles from "@/app/components/sd/sd.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 { IconButton } from "@/app/components/button";
 import ReturnIcon from "@/app/icons/return.svg";
 import ReturnIcon from "@/app/icons/return.svg";
 import Locale from "@/app/locales";
 import Locale from "@/app/locales";
@@ -10,7 +12,7 @@ import {
   getMessageTextContent,
   getMessageTextContent,
   useMobileScreen,
   useMobileScreen,
 } from "@/app/utils";
 } from "@/app/utils";
-import { useNavigate } from "react-router-dom";
+import { useNavigate, useLocation } from "react-router-dom";
 import { useAppConfig } from "@/app/store";
 import { useAppConfig } from "@/app/store";
 import MinIcon from "@/app/icons/min.svg";
 import MinIcon from "@/app/icons/min.svg";
 import MaxIcon from "@/app/icons/max.svg";
 import MaxIcon from "@/app/icons/max.svg";
@@ -24,6 +26,7 @@ import { useSdStore } from "@/app/store/sd";
 import locales from "@/app/locales";
 import locales from "@/app/locales";
 import LoadingIcon from "@/app/icons/three-dots.svg";
 import LoadingIcon from "@/app/icons/three-dots.svg";
 import ErrorIcon from "@/app/icons/delete.svg";
 import ErrorIcon from "@/app/icons/delete.svg";
+import SDIcon from "@/app/icons/sd.svg";
 import { Property } from "csstype";
 import { Property } from "csstype";
 import {
 import {
   showConfirm,
   showConfirm,
@@ -88,12 +91,14 @@ function getSdTaskStatus(item: any) {
 export function Sd() {
 export function Sd() {
   const isMobileScreen = useMobileScreen();
   const isMobileScreen = useMobileScreen();
   const navigate = useNavigate();
   const navigate = useNavigate();
+  const location = useLocation();
   const clientConfig = useMemo(() => getClientConfig(), []);
   const clientConfig = useMemo(() => getClientConfig(), []);
   const showMaxIcon = !isMobileScreen && !clientConfig?.isApp;
   const showMaxIcon = !isMobileScreen && !clientConfig?.isApp;
   const config = useAppConfig();
   const config = useAppConfig();
   const scrollRef = useRef<HTMLDivElement>(null);
   const scrollRef = useRef<HTMLDivElement>(null);
   const sdStore = useSdStore();
   const sdStore = useSdStore();
   const [sdImages, setSdImages] = useState(sdStore.draw);
   const [sdImages, setSdImages] = useState(sdStore.draw);
+  const isSd = location.pathname === Path.Sd;
 
 
   useEffect(() => {
   useEffect(() => {
     setSdImages(sdStore.draw);
     setSdImages(sdStore.draw);
@@ -101,7 +106,7 @@ export function Sd() {
 
 
   return (
   return (
     <>
     <>
-      <SideBar />
+      <SideBar className={isSd ? homeStyles["sidebar-show"] : ""} />
       <WindowContent>
       <WindowContent>
         <div className={chatStyles.chat} key={"1"}>
         <div className={chatStyles.chat} key={"1"}>
           <div className="window-header" data-tauri-drag-region>
           <div className="window-header" data-tauri-drag-region>
@@ -112,7 +117,7 @@ export function Sd() {
                     icon={<ReturnIcon />}
                     icon={<ReturnIcon />}
                     bordered
                     bordered
                     title={Locale.Chat.Actions.ChatList}
                     title={Locale.Chat.Actions.ChatList}
-                    onClick={() => navigate(Path.SdNew)}
+                    onClick={() => navigate(Path.Sd)}
                   />
                   />
                 </div>
                 </div>
               </div>
               </div>
@@ -140,6 +145,7 @@ export function Sd() {
                   />
                   />
                 </div>
                 </div>
               )}
               )}
+              {isMobileScreen && <SDIcon width={50} height={50} />}
             </div>
             </div>
           </div>
           </div>
           <div className={chatStyles["chat-body"]} ref={scrollRef}>
           <div className={chatStyles["chat-body"]} ref={scrollRef}>