diff --git a/app/components/chat.tsx b/app/components/chat.tsx index 061192504..9145db04d 100644 --- a/app/components/chat.tsx +++ b/app/components/chat.tsx @@ -337,7 +337,7 @@ function ClearContextDivider() { ); } -function ChatAction(props: { +export function ChatAction(props: { text: string; icon: JSX.Element; onClick: () => void; diff --git a/app/components/home.tsx b/app/components/home.tsx index 99755cc20..21cfbcc42 100644 --- a/app/components/home.tsx +++ b/app/components/home.tsx @@ -1,7 +1,5 @@ "use client"; -import { Sd } from "@/app/components/sd"; - require("../polyfill"); import { useState, useEffect } from "react"; @@ -32,6 +30,7 @@ import { getClientConfig } from "../config/client"; import { ClientApi } from "../client/api"; import { useAccessStore } from "../store"; import { identifyDefaultClaudeModel } from "../utils/checkers"; +import { initDB } from "react-indexed-db-hook"; export function Loading(props: { noLogo?: boolean }) { return ( @@ -58,6 +57,14 @@ const MaskPage = dynamic(async () => (await import("./mask")).MaskPage, { loading: () => , }); +const Sd = dynamic(async () => (await import("./sd")).Sd, { + loading: () => , +}); + +const SdPanel = dynamic(async () => (await import("./sd-panel")).SdPanel, { + loading: () => , +}); + export function useSwitchTheme() { const config = useAppConfig(); @@ -128,7 +135,8 @@ const loadAsyncGoogleFont = () => { function Screen() { const config = useAppConfig(); const location = useLocation(); - const isHome = location.pathname === Path.Home; + const isHome = + location.pathname === Path.Home || location.pathname === Path.SdPanel; const isAuth = location.pathname === Path.Auth; const isMobileScreen = useMobileScreen(); const shouldTightBorder = @@ -137,7 +145,6 @@ function Screen() { useEffect(() => { loadAsyncGoogleFont(); }, []); - return (
-
} /> @@ -162,6 +168,7 @@ function Screen() { } /> } /> } /> + } /> } />
@@ -173,7 +180,6 @@ function Screen() { export function useLoadData() { const config = useAppConfig(); - var api: ClientApi; if (config.modelConfig.model.startsWith("gemini")) { api = new ClientApi(ModelProvider.GeminiPro); diff --git a/app/components/sd-panel.tsx b/app/components/sd-panel.tsx index 71a7a0ce3..8e1159cf9 100644 --- a/app/components/sd-panel.tsx +++ b/app/components/sd-panel.tsx @@ -1,8 +1,14 @@ import styles from "./sd-panel.module.scss"; import React, { useState } from "react"; -import { Select } from "@/app/components/ui-lib"; +import { Select, showToast } from "@/app/components/ui-lib"; import { IconButton } from "@/app/components/button"; import locales from "@/app/locales"; +import { nanoid } from "nanoid"; +import { useIndexedDB } from "react-indexed-db-hook"; +import { StoreKey } from "@/app/constant"; +import { SdDbInit, sendSdTask, useSdStore } from "@/app/store/sd"; + +SdDbInit(); const sdCommonParams = (model: string, data: any) => { return [ @@ -89,7 +95,7 @@ const sdCommonParams = (model: string, data: any) => { name: locales.SdPanel.OutFormat, value: "output_format", type: "select", - default: 0, + default: "png", options: [ { name: "PNG", value: "png" }, { name: "JPEG", value: "jpeg" }, @@ -128,6 +134,7 @@ const models = [ export function ControlParamItem(props: { title: string; subTitle?: string; + required?: boolean; children?: JSX.Element | JSX.Element[]; className?: string; }) { @@ -135,7 +142,10 @@ export function ControlParamItem(props: {
-
{props.title}
+
+ {props.title} + {props.required && *} +
{props.children} @@ -160,7 +170,11 @@ export function ControlParam(props: { switch (item.type) { case "textarea": element = ( - +