This commit is contained in:
sijinhui
2023-12-16 23:05:14 +08:00
parent efdd61595e
commit b43c0b0109
91 changed files with 3399 additions and 12096 deletions

View File

@@ -34,7 +34,7 @@
}
&:hover {
--delay: 0.5s;
--delay: 0.3s;
width: var(--full-width);
transition-delay: var(--delay);
@@ -52,6 +52,17 @@
justify-content: center;
}
}
.chat-input-action-long-weight {
width: var(--full-width);
.text {
white-space: nowrap;
padding-left: 5px;
opacity: 1;
transform: translate(0);
pointer-events: none;
}
}
}
.prompt-toast {
@@ -381,6 +392,39 @@
transition: all ease 0.3s;
}
.chat-model-mj{
img{
width: 280px;
}
}
.chat-message-action-btn{
font-size: 12px;
background-color: var(--white);
color: var(--black);
border: var(--border-in-light);
box-shadow: var(--card-shadow);
padding: 8px 16px;
border-radius: 16px;
animation: slide-in-from-top ease 0.3s;
transition: all .3s;
cursor: pointer;
margin: 2px 2px;
}
.chat-select-images{
margin-bottom: 10px;
img{
width:80px;
height: 80px;
margin: 0 5px;
border-radius: 10px;
border:1px dashed var(--color-border-muted);
}
}
.chat-message-action-date {
font-size: 12px;
opacity: 0.2;

View File

@@ -34,6 +34,7 @@ import AutoIcon from "../icons/auto.svg";
import BottomIcon from "../icons/bottom.svg";
import StopIcon from "../icons/pause.svg";
import RobotIcon from "../icons/robot.svg";
import UploadIcon from "../icons/upload.svg";
import {
ChatMessage,
@@ -50,6 +51,7 @@ import {
import {
copyToClipboard,
downloadAs,
selectOrCopy,
autoGrowTextArea,
useMobileScreen,
@@ -88,6 +90,8 @@ import { ChatCommandPrefix, useChatCommand, useCommand } from "../command";
import { prettyObject } from "../utils/format";
import { ExportMessageModal } from "./exporter";
import { getClientConfig } from "../config/client";
import { Button } from "emoji-picker-react/src/components/atoms/Button";
import Image from "next/image";
import { useAllModels } from "../utils/hooks";
const Markdown = dynamic(async () => (await import("./markdown")).Markdown, {
@@ -337,6 +341,10 @@ function ChatAction(props: {
full: 16,
icon: 16,
});
const allModels = useAllModels().map((item) => item.displayName);
const customModelClassName = allModels.includes(props.text)
? "chat-input-action-long-weight"
: "";
function updateWidth() {
if (!iconRef.current || !textRef.current) return;
@@ -349,9 +357,15 @@ function ChatAction(props: {
});
}
useEffect(() => {
if (customModelClassName !== "") {
updateWidth();
}
}, [props.text, customModelClassName]);
return (
<div
className={`${styles["chat-input-action"]} clickable`}
className={`${styles["chat-input-action"]} ${styles[customModelClassName]} clickable`}
onClick={() => {
props.onClick();
setTimeout(updateWidth, 1);
@@ -409,6 +423,7 @@ export function ChatActions(props: {
showPromptModal: () => void;
scrollToBottom: () => void;
showPromptHints: () => void;
imageSelected: (img: any) => void;
hitBottom: boolean;
}) {
const config = useAppConfig();
@@ -429,6 +444,25 @@ export function ChatActions(props: {
const couldStop = ChatControllerPool.hasPending();
const stopAll = () => ChatControllerPool.stopAll();
function selectImage() {
document.getElementById("chat-image-file-select-upload")?.click();
}
const onImageSelected = (e: any) => {
const file = e.target.files[0];
const filename = file.name;
const reader = new FileReader();
reader.readAsDataURL(file);
reader.onload = () => {
const base64 = reader.result;
props.imageSelected({
filename,
base64,
});
};
e.target.value = null;
};
// switch model
const currentModel = chatStore.currentSession().mask.modelConfig.model;
const allModels = useAllModels();
@@ -467,13 +501,13 @@ export function ChatActions(props: {
icon={<BottomIcon />}
/>
)}
{props.hitBottom && (
<ChatAction
onClick={props.showPromptModal}
text={Locale.Chat.InputActions.Settings}
icon={<SettingsIcon />}
/>
)}
{/*{props.hitBottom && (*/}
{/* <ChatAction*/}
{/* onClick={props.showPromptModal}*/}
{/* text={Locale.Chat.InputActions.Settings}*/}
{/* icon={<SettingsIcon />}*/}
{/* />*/}
{/*)}*/}
<ChatAction
onClick={nextTheme}
@@ -491,19 +525,19 @@ export function ChatActions(props: {
}
/>
<ChatAction
onClick={props.showPromptHints}
text={Locale.Chat.InputActions.Prompt}
icon={<PromptIcon />}
/>
{/*<ChatAction*/}
{/* onClick={props.showPromptHints}*/}
{/* text={Locale.Chat.InputActions.Prompt}*/}
{/* icon={<PromptIcon />}*/}
{/*/>*/}
<ChatAction
onClick={() => {
navigate(Path.Masks);
}}
text={Locale.Chat.InputActions.Masks}
icon={<MaskIcon />}
/>
{/*<ChatAction*/}
{/* onClick={() => {*/}
{/* navigate(Path.Masks);*/}
{/* }}*/}
{/* text={Locale.Chat.InputActions.Masks}*/}
{/* icon={<MaskIcon />}*/}
{/*/>*/}
<ChatAction
text={Locale.Chat.InputActions.Clear}
@@ -526,11 +560,25 @@ export function ChatActions(props: {
icon={<RobotIcon />}
/>
<ChatAction
onClick={selectImage}
text={Locale.Chat.InputActions.UploadImage}
icon={<UploadIcon />}
/>
<input
type="file"
accept=".png,.jpg,.webp,.jpeg"
id="chat-image-file-select-upload"
style={{ display: "none" }}
onChange={onImageSelected}
/>
{showModelSelector && (
<Selector
defaultSelectedValue={currentModel}
items={models.map((m) => ({
title: m.displayName,
subTitle: m.describe,
value: m.name,
}))}
onClose={() => setShowModelSelector(false)}
@@ -622,6 +670,8 @@ function _Chat() {
const inputRef = useRef<HTMLTextAreaElement>(null);
const [userInput, setUserInput] = useState("");
const [useImages, setUseImages] = useState<any[]>([]);
const [mjImageMode, setMjImageMode] = useState<string>("IMAGINE");
const [isLoading, setIsLoading] = useState(false);
const { submitKey, shouldSubmit } = useSubmitHandler();
const { scrollRef, setAutoScroll, scrollDomToBottom } = useScrollToBottom();
@@ -697,17 +747,33 @@ function _Chat() {
const doSubmit = (userInput: string) => {
if (userInput.trim() === "") return;
const matchCommand = chatCommands.match(userInput);
if (matchCommand.matched) {
setUserInput("");
setPromptHints([]);
matchCommand.invoke();
return;
if (useImages.length > 0) {
if (mjImageMode === "IMAGINE" && userInput == "") {
alert(Locale.Midjourney.NeedInputUseImgPrompt);
return;
}
} else {
const matchCommand = chatCommands.match(userInput);
if (matchCommand.matched) {
setUserInput("");
setPromptHints([]);
matchCommand.invoke();
return;
}
}
setIsLoading(true);
chatStore.onUserInput(userInput).then(() => setIsLoading(false));
chatStore
.onUserInput(userInput, {
useImages,
mjImageMode,
setAutoScroll,
})
.then(() => setIsLoading(false));
localStorage.setItem(LAST_INPUT_KEY, userInput);
setUserInput("");
setUseImages([]);
setMjImageMode("IMAGINE");
setPromptHints([]);
if (!isMobileScreen) inputRef.current?.focus();
setAutoScroll(true);
@@ -1031,6 +1097,12 @@ function _Chat() {
// edit / insert message modal
const [isEditingMessage, setIsEditingMessage] = useState(false);
messages?.forEach((msg) => {
if (msg.model === "midjourney" && msg.attr.taskId) {
chatStore.fetchMidjourneyStatus(msg);
}
});
// remember unfinished input
useEffect(() => {
// try to load from local storage
@@ -1238,17 +1310,109 @@ function _Chat() {
message.content.length === 0 &&
!isUser
}
onContextMenu={(e) => onRightClick(e, message)}
onDoubleClickCapture={() => {
if (!isMobileScreen) return;
setUserInput(message.content);
}}
// onContextMenu={(e) => onRightClick(e, message)}
// onDoubleClickCapture={() => {
// if (!isMobileScreen) return;
// setUserInput(message.content);
// }}
fontSize={fontSize}
parentRef={scrollRef}
defaultShow={i >= messages.length - 6}
/>
</div>
{!isUser &&
message.model == "midjourney" &&
message.attr?.finished &&
["VARIATION", "IMAGINE", "BLEND"].includes(
message.attr?.action,
) && (
<div
className={[
styles["chat-message-actions"],
styles["column-flex"],
].join(" ")}
>
<div>
<button
onClick={() =>
doSubmit(`/mj UPSCALE::1::${message.attr.taskId}`)
}
className={`${styles["chat-message-action-btn"]} clickable`}
>
U1
</button>
<button
onClick={() =>
doSubmit(`/mj UPSCALE::2::${message.attr.taskId}`)
}
className={`${styles["chat-message-action-btn"]} clickable`}
>
U2
</button>
<button
onClick={() =>
doSubmit(`/mj UPSCALE::3::${message.attr.taskId}`)
}
className={`${styles["chat-message-action-btn"]} clickable`}
>
U3
</button>
<button
onClick={() =>
doSubmit(`/mj UPSCALE::4::${message.attr.taskId}`)
}
className={`${styles["chat-message-action-btn"]} clickable`}
>
U4
</button>
{/*<button onClick={() => doSubmit(`/mj REROLL::0::${message.attr.taskId}`)} className={`${styles["chat-message-action-btn"]} clickable`}>RESET</button>*/}
</div>
<div>
<button
onClick={() =>
doSubmit(
`/mj VARIATION::1::${message.attr.taskId}`,
)
}
className={`${styles["chat-message-action-btn"]} clickable`}
>
V1
</button>
<button
onClick={() =>
doSubmit(
`/mj VARIATION::2::${message.attr.taskId}`,
)
}
className={`${styles["chat-message-action-btn"]} clickable`}
>
V2
</button>
<button
onClick={() =>
doSubmit(
`/mj VARIATION::3::${message.attr.taskId}`,
)
}
className={`${styles["chat-message-action-btn"]} clickable`}
>
V3
</button>
<button
onClick={() =>
doSubmit(
`/mj VARIATION::4::${message.attr.taskId}`,
)
}
className={`${styles["chat-message-action-btn"]} clickable`}
>
V4
</button>
</div>
</div>
)}
<div className={styles["chat-message-action-date"]}>
{isContext
? Locale.Chat.IsContext
@@ -1280,12 +1444,65 @@ function _Chat() {
setUserInput("/");
onSearch("");
}}
imageSelected={(img: any) => {
if (useImages.length >= 5) {
alert(Locale.Midjourney.SelectImgMax(5));
return;
}
setUseImages([...useImages, img]);
}}
/>
{useImages.length > 0 && (
<div className={styles["chat-select-images"]}>
{useImages.map((img: any, i) => (
<Image
src={img.base64}
key={i}
onClick={() => {
setUseImages(useImages.filter((_, ii) => ii != i));
}}
title={img.filename}
alt={img.filename}
width={20}
height={20}
/>
))}
<div style={{ fontSize: "12px", marginBottom: "5px" }}>
{[
{ name: Locale.Midjourney.ModeImagineUseImg, value: "IMAGINE" },
// { name: Locale.Midjourney.ModeBlend, value: "BLEND" },
// { name: Locale.Midjourney.ModeDescribe, value: "DESCRIBE" },
].map((item, i) => (
<label key={i}>
<input
type="radio"
name="mj-img-mode"
checked={mjImageMode == item.value}
value={item.value}
onChange={(e) => {
setMjImageMode(e.target.value);
}}
/>
<span>{item.name}</span>
</label>
))}
</div>
<div style={{ fontSize: "12px" }}>
<small>{Locale.Midjourney.HasImgTip}</small>
</div>
</div>
)}
<div className={styles["chat-input-panel-inner"]}>
<textarea
ref={inputRef}
className={styles["chat-input"]}
placeholder={Locale.Chat.Input(submitKey)}
// placeholder={Locale.Chat.Input(submitKey)}
placeholder={
useImages.length > 0 && mjImageMode != "IMAGINE"
? Locale.Midjourney.InputDisabled
: Locale.Chat.Input(submitKey)
}
onInput={(e) => onInput(e.currentTarget.value)}
value={userInput}
onKeyDown={onInputKeyDown}

View File

@@ -10,7 +10,7 @@ import BotIcon from "../icons/bot.svg";
import BlackBotIcon from "../icons/black-bot.svg";
export function getEmojiUrl(unified: string, style: EmojiStyle) {
return `https://cdn.staticfile.org/emoji-datasource-apple/15.0.1/img/${style}/64/${unified}.png`;
return `https://cdn.staticfile.org/emoji-datasource-apple/14.0.0/img/${style}/64/${unified}.png`;
}
export function AvatarPicker(props: {

View File

@@ -1,3 +1,5 @@
"use client";
import React from "react";
import { IconButton } from "./button";
import GithubIcon from "../icons/github.svg";

View File

@@ -24,7 +24,7 @@ import {
useLocation,
} from "react-router-dom";
import { SideBar } from "./sidebar";
import { useAppConfig } from "../store/config";
import { useAppConfig } from "@/app/store";
import { AuthPage } from "./auth";
import { getClientConfig } from "../config/client";
import { api } from "../client/api";
@@ -55,6 +55,10 @@ const MaskPage = dynamic(async () => (await import("./mask")).MaskPage, {
loading: () => <Loading noLogo />,
});
const Reward = dynamic(async () => (await import("./reward")).RewardPage, {
loading: () => <Loading noLogo />,
});
export function useSwitchTheme() {
const config = useAppConfig();
@@ -108,18 +112,18 @@ const useHasHydrated = () => {
};
const loadAsyncGoogleFont = () => {
const linkEl = document.createElement("link");
const proxyFontUrl = "/google-fonts";
const remoteFontUrl = "https://fonts.googleapis.com";
const googleFontUrl =
getClientConfig()?.buildMode === "export" ? remoteFontUrl : proxyFontUrl;
linkEl.rel = "stylesheet";
linkEl.href =
googleFontUrl +
"/css2?family=" +
encodeURIComponent("Noto Sans:wght@300;400;700;900") +
"&display=swap";
document.head.appendChild(linkEl);
// const linkEl = document.createElement("link");
// const proxyFontUrl = "/google-fonts";
// const remoteFontUrl = "https://fonts.googleapis.com";
// const googleFontUrl =
// getClientConfig()?.buildMode === "export" ? remoteFontUrl : proxyFontUrl;
// linkEl.rel = "stylesheet";
// linkEl.href =
// googleFontUrl +
// "/css2?family=" +
// encodeURIComponent("Noto Sans:wght@300;400;700;900") +
// "&display=swap";
// document.head.appendChild(linkEl);
};
function Screen() {
@@ -128,7 +132,8 @@ function Screen() {
const isHome = location.pathname === Path.Home;
const isAuth = location.pathname === Path.Auth;
const isMobileScreen = useMobileScreen();
const shouldTightBorder = getClientConfig()?.isApp || (config.tightBorder && !isMobileScreen);
const shouldTightBorder =
getClientConfig()?.isApp || (config.tightBorder && !isMobileScreen);
useEffect(() => {
loadAsyncGoogleFont();
@@ -138,9 +143,7 @@ function Screen() {
<div
className={
styles.container +
` ${shouldTightBorder ? styles["tight-container"] : styles.container} ${
getLang() === "ar" ? styles["rtl-screen"] : ""
}`
` ${shouldTightBorder ? styles["tight-container"] : styles.container} `
}
>
{isAuth ? (
@@ -158,6 +161,7 @@ function Screen() {
<Route path={Path.Masks} element={<MaskPage />} />
<Route path={Path.Chat} element={<Chat />} />
<Route path={Path.Settings} element={<Settings />} />
<Route path={Path.Reward} element={<Reward />} />
</Routes>
</div>
</>

View File

@@ -0,0 +1,22 @@
export default function LoadingCircle({ dimensions }: { dimensions?: string }) {
return (
<svg
aria-hidden="true"
className={`${
dimensions || "h-4 w-4"
} animate-spin fill-stone-600 text-stone-200`}
viewBox="0 0 100 101"
fill="none"
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M100 50.5908C100 78.2051 77.6142 100.591 50 100.591C22.3858 100.591 0 78.2051 0 50.5908C0 22.9766 22.3858 0.59082 50 0.59082C77.6142 0.59082 100 22.9766 100 50.5908ZM9.08144 50.5908C9.08144 73.1895 27.4013 91.5094 50 91.5094C72.5987 91.5094 90.9186 73.1895 90.9186 50.5908C90.9186 27.9921 72.5987 9.67226 50 9.67226C27.4013 9.67226 9.08144 27.9921 9.08144 50.5908Z"
fill="currentColor"
/>
<path
d="M93.9676 39.0409C96.393 38.4038 97.8624 35.9116 97.0079 33.5539C95.2932 28.8227 92.871 24.3692 89.8167 20.348C85.8452 15.1192 80.8826 10.7238 75.2124 7.41289C69.5422 4.10194 63.2754 1.94025 56.7698 1.05124C51.7666 0.367541 46.6976 0.446843 41.7345 1.27873C39.2613 1.69328 37.813 4.19778 38.4501 6.62326C39.0873 9.04874 41.5694 10.4717 44.0505 10.1071C47.8511 9.54855 51.7191 9.52689 55.5402 10.0491C60.8642 10.7766 65.9928 12.5457 70.6331 15.2552C75.2735 17.9648 79.3347 21.5619 82.5849 25.841C84.9175 28.9121 86.7997 32.2913 88.1811 35.8758C89.083 38.2158 91.5421 39.6781 93.9676 39.0409Z"
fill="currentFill"
/>
</svg>
);
}

View File

@@ -0,0 +1,40 @@
.loading {
display: inline-flex;
align-items: center;
}
.loading .spacer {
margin-right: 2px;
}
.loading span {
animation-name: blink;
animation-duration: 1.4s;
animation-iteration-count: infinite;
animation-fill-mode: both;
width: 5px;
height: 5px;
border-radius: 50%;
display: inline-block;
margin: 0 1px;
}
.loading span:nth-of-type(2) {
animation-delay: 0.2s;
}
.loading span:nth-of-type(3) {
animation-delay: 0.4s;
}
@keyframes blink {
0% {
opacity: 0.2;
}
20% {
opacity: 1;
}
100% {
opacity: 0.2;
}
}

View File

@@ -0,0 +1,17 @@
import styles from "./loading-dots.module.scss";
interface LoadingDotsProps {
color?: string;
}
const LoadingDots = ({ color = "#000" }: LoadingDotsProps) => {
return (
<span className={styles.loading}>
<span style={{ backgroundColor: color }} />
<span style={{ backgroundColor: color }} />
<span style={{ backgroundColor: color }} />
</span>
);
};
export default LoadingDots;

View File

@@ -0,0 +1,30 @@
export default function Magic({ className }: { className: string }) {
return (
<svg
width="469"
height="469"
viewBox="0 0 469 469"
fill="none"
xmlns="http://www.w3.org/2000/svg"
shapeRendering="geometricPrecision"
stroke="currentColor"
strokeLinecap="round"
strokeLinejoin="round"
strokeWidth="1.5"
className={className}
>
<path
d="M237.092 62.3004L266.754 71.4198C267.156 71.5285 267.51 71.765 267.765 72.0934C268.02 72.4218 268.161 72.8243 268.166 73.2399C268.172 73.6555 268.042 74.0616 267.796 74.3967C267.55 74.7318 267.201 74.9777 266.803 75.097L237.141 84.3145C236.84 84.4058 236.566 84.5699 236.344 84.7922C236.121 85.0146 235.957 85.2883 235.866 85.5893L226.747 115.252C226.638 115.653 226.401 116.008 226.073 116.263C225.745 116.517 225.342 116.658 224.926 116.664C224.511 116.669 224.105 116.539 223.77 116.293C223.435 116.047 223.189 115.699 223.069 115.301L213.852 85.6383C213.761 85.3374 213.597 85.0636 213.374 84.8412C213.152 84.6189 212.878 84.4548 212.577 84.3635L182.914 75.2441C182.513 75.1354 182.158 74.8989 181.904 74.5705C181.649 74.2421 181.508 73.8396 181.503 73.424C181.497 73.0084 181.627 72.6023 181.873 72.2672C182.119 71.9321 182.467 71.6863 182.865 71.5669L212.528 62.3494C212.829 62.2582 213.103 62.0941 213.325 61.8717C213.547 61.6494 213.712 61.3756 213.803 61.0747L222.922 31.4121C223.031 31.0109 223.267 30.656 223.596 30.4013C223.924 30.1465 224.327 30.0057 224.742 30.0002C225.158 29.9946 225.564 30.1247 225.899 30.3706C226.234 30.6165 226.48 30.9649 226.599 31.363L235.817 61.0257C235.908 61.3266 236.072 61.6003 236.295 61.8227C236.517 62.0451 236.791 62.2091 237.092 62.3004Z"
fill="currentColor"
/>
<path
d="M155.948 155.848L202.771 168.939C203.449 169.131 204.045 169.539 204.47 170.101C204.895 170.663 205.125 171.348 205.125 172.052C205.125 172.757 204.895 173.442 204.47 174.004C204.045 174.566 203.449 174.974 202.771 175.166L155.899 188.06C155.361 188.209 154.87 188.496 154.475 188.891C154.079 189.286 153.793 189.777 153.644 190.316L140.553 237.138C140.361 237.816 139.953 238.413 139.391 238.838C138.829 239.262 138.144 239.492 137.44 239.492C136.735 239.492 136.05 239.262 135.488 238.838C134.927 238.413 134.519 237.816 134.327 237.138L121.432 190.267C121.283 189.728 120.997 189.237 120.601 188.842C120.206 188.446 119.715 188.16 119.177 188.011L72.3537 174.92C71.676 174.728 71.0795 174.32 70.6547 173.759C70.2299 173.197 70 172.512 70 171.807C70 171.103 70.2299 170.418 70.6547 169.856C71.0795 169.294 71.676 168.886 72.3537 168.694L119.226 155.799C119.764 155.65 120.255 155.364 120.65 154.969C121.046 154.573 121.332 154.082 121.481 153.544L134.572 106.721C134.764 106.043 135.172 105.447 135.734 105.022C136.295 104.597 136.981 104.367 137.685 104.367C138.389 104.367 139.075 104.597 139.637 105.022C140.198 105.447 140.606 106.043 140.798 106.721L153.693 153.593C153.842 154.131 154.128 154.622 154.524 155.018C154.919 155.413 155.41 155.699 155.948 155.848Z"
fill="currentColor"
/>
<path
d="M386.827 289.992C404.33 292.149 403.84 305.828 386.876 307.299C346.623 310.829 298.869 316.271 282.199 360.005C274.844 379.192 269.942 403.2 267.49 432.029C267.427 432.846 267.211 433.626 266.856 434.319C266.501 435.012 266.015 435.602 265.431 436.05C254.988 444.041 251.212 434.186 250.183 425.606C239.2 332.353 214.588 316.909 124.668 306.122C123.892 306.031 123.151 305.767 122.504 305.35C121.857 304.933 121.322 304.375 120.942 303.72C116.399 295.679 119.324 291.038 129.718 289.796C224.688 278.47 236.062 262.83 250.183 169.331C252.177 156.355 257.259 154.083 265.431 162.516C266.51 163.593 267.202 165.099 267.392 166.782C279.257 258.564 293.328 278.617 386.827 289.992Z"
fill="currentColor"
/>
</svg>
);
}

View File

@@ -136,7 +136,7 @@ function _MarkDownContent(props: { content: string }) {
],
]}
components={{
pre: PreCode,
pre: PreCode as any,
p: (pProps) => <p {...pProps} dir="auto" />,
a: (aProps) => {
const href = aProps.href || "";

39
app/components/reward.tsx Normal file
View File

@@ -0,0 +1,39 @@
import Image from "next/image";
import React from "react";
import { useLocation, useNavigate } from "react-router-dom";
import styles from "@/app/components/mask.module.scss";
import Locale from "@/app/locales";
import { IconButton } from "@/app/components/button";
import LeftIcon from "@/app/icons/left.svg";
import { Path } from "@/app/constant";
export function RewardPage() {
const navigate = useNavigate();
return (
<div style={{ height: "100%" }}>
<div className={styles["new-chat"]}>
<div className={styles["mask-header"]} style={{ padding: "10px" }}>
<IconButton
icon={<LeftIcon />}
text={Locale.NewChat.Return}
onClick={() => navigate(Path.Home)}
></IconButton>
</div>
</div>
<div
style={{ position: "relative", width: "100%", paddingBottom: "100%" }}
>
<div
style={{ position: "absolute", top: 0, left: 0, right: 0, bottom: 0 }}
>
<Image
src="https://cos.xiaosi.cc/img/zanshang.jpeg"
alt="打赏"
layout="fill"
objectFit="cover" // Optional: you can use this if you want the image to cover the entire area without stretching
/>
</div>
</div>
</div>
);
}

View File

@@ -62,7 +62,7 @@ import {
} from "../constant";
import { Prompt, SearchService, usePromptStore } from "../store/prompt";
import { ErrorBoundary } from "./error";
import { InputRange } from "./input-range";
// import { InputRange } from "./input-range";
import { useNavigate } from "react-router-dom";
import { Avatar, AvatarPicker } from "./emoji";
import { getClientConfig } from "../config/client";
@@ -491,41 +491,41 @@ function SyncItems() {
return (
<>
<List>
<ListItem
title={Locale.Settings.Sync.CloudState}
subTitle={
syncStore.lastProvider
? `${new Date(syncStore.lastSyncTime).toLocaleString()} [${
syncStore.lastProvider
}]`
: Locale.Settings.Sync.NotSyncYet
}
>
<div style={{ display: "flex" }}>
<IconButton
icon={<ConfigIcon />}
text={Locale.UI.Config}
onClick={() => {
setShowSyncConfigModal(true);
}}
/>
{couldSync && (
<IconButton
icon={<ResetIcon />}
text={Locale.UI.Sync}
onClick={async () => {
try {
await syncStore.sync();
showToast(Locale.Settings.Sync.Success);
} catch (e) {
showToast(Locale.Settings.Sync.Fail);
console.error("[Sync]", e);
}
}}
/>
)}
</div>
</ListItem>
{/*<ListItem*/}
{/* title={Locale.Settings.Sync.CloudState}*/}
{/* subTitle={*/}
{/* syncStore.lastProvider*/}
{/* ? `${new Date(syncStore.lastSyncTime).toLocaleString()} [${*/}
{/* syncStore.lastProvider*/}
{/* }]`*/}
{/* : Locale.Settings.Sync.NotSyncYet*/}
{/* }*/}
{/*>*/}
{/* <div style={{ display: "flex" }}>*/}
{/* <IconButton*/}
{/* icon={<ConfigIcon />}*/}
{/* text={Locale.UI.Config}*/}
{/* onClick={() => {*/}
{/* setShowSyncConfigModal(true);*/}
{/* }}*/}
{/* />*/}
{/* {couldSync && (*/}
{/* <IconButton*/}
{/* icon={<ResetIcon />}*/}
{/* text={Locale.UI.Sync}*/}
{/* onClick={async () => {*/}
{/* try {*/}
{/* await syncStore.sync();*/}
{/* showToast(Locale.Settings.Sync.Success);*/}
{/* } catch (e) {*/}
{/* showToast(Locale.Settings.Sync.Fail);*/}
{/* console.error("[Sync]", e);*/}
{/* }*/}
{/* }}*/}
{/* />*/}
{/* )}*/}
{/* </div>*/}
{/*</ListItem>*/}
<ListItem
title={Locale.Settings.Sync.LocalState}
@@ -624,7 +624,7 @@ export function Settings() {
const showUsage = accessStore.isAuthorized();
useEffect(() => {
// checks per minutes
checkUpdate();
// checkUpdate();
showUsage && checkUsage();
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);
@@ -635,7 +635,8 @@ export function Settings() {
navigate(Path.Home);
}
};
if (clientConfig?.isApp) { // Force to set custom endpoint to true if it's app
if (clientConfig?.isApp) {
// Force to set custom endpoint to true if it's app
accessStore.update((state) => {
state.useCustomConfig = true;
});
@@ -697,48 +698,48 @@ export function Settings() {
</Popover>
</ListItem>
<ListItem
title={Locale.Settings.Update.Version(currentVersion ?? "unknown")}
subTitle={
checkingUpdate
? Locale.Settings.Update.IsChecking
: hasNewVersion
? Locale.Settings.Update.FoundUpdate(remoteId ?? "ERROR")
: Locale.Settings.Update.IsLatest
}
>
{checkingUpdate ? (
<LoadingIcon />
) : hasNewVersion ? (
<Link href={updateUrl} target="_blank" className="link">
{Locale.Settings.Update.GoToUpdate}
</Link>
) : (
<IconButton
icon={<ResetIcon></ResetIcon>}
text={Locale.Settings.Update.CheckUpdate}
onClick={() => checkUpdate(true)}
/>
)}
</ListItem>
{/*<ListItem*/}
{/* title={Locale.Settings.Update.Version(currentVersion ?? "unknown")}*/}
{/* subTitle={*/}
{/* checkingUpdate*/}
{/* ? Locale.Settings.Update.IsChecking*/}
{/* : hasNewVersion*/}
{/* ? Locale.Settings.Update.FoundUpdate(remoteId ?? "ERROR")*/}
{/* : Locale.Settings.Update.IsLatest*/}
{/* }*/}
{/*>*/}
{/* {checkingUpdate ? (*/}
{/* <LoadingIcon />*/}
{/* ) : hasNewVersion ? (*/}
{/* <Link href={updateUrl} target="_blank" className="link">*/}
{/* {Locale.Settings.Update.GoToUpdate}*/}
{/* </Link>*/}
{/* ) : (*/}
{/* <IconButton*/}
{/* icon={<ResetIcon></ResetIcon>}*/}
{/* text={Locale.Settings.Update.CheckUpdate}*/}
{/* onClick={() => checkUpdate(true)}*/}
{/* />*/}
{/* )}*/}
{/*</ListItem>*/}
<ListItem title={Locale.Settings.SendKey}>
<Select
value={config.submitKey}
onChange={(e) => {
updateConfig(
(config) =>
(config.submitKey = e.target.value as any as SubmitKey),
);
}}
>
{Object.values(SubmitKey).map((v) => (
<option value={v} key={v}>
{v}
</option>
))}
</Select>
</ListItem>
{/*<ListItem title={Locale.Settings.SendKey}>*/}
{/* <Select*/}
{/* value={config.submitKey}*/}
{/* onChange={(e) => {*/}
{/* updateConfig(*/}
{/* (config) =>*/}
{/* (config.submitKey = e.target.value as any as SubmitKey),*/}
{/* );*/}
{/* }}*/}
{/* >*/}
{/* {Object.values(SubmitKey).map((v) => (*/}
{/* <option value={v} key={v}>*/}
{/* {v}*/}
{/* </option>*/}
{/* ))}*/}
{/* </Select>*/}
{/*</ListItem>*/}
<ListItem title={Locale.Settings.Theme}>
<Select
@@ -757,353 +758,353 @@ export function Settings() {
</Select>
</ListItem>
<ListItem title={Locale.Settings.Lang.Name}>
<Select
value={getLang()}
onChange={(e) => {
changeLang(e.target.value as any);
}}
>
{AllLangs.map((lang) => (
<option value={lang} key={lang}>
{ALL_LANG_OPTIONS[lang]}
</option>
))}
</Select>
</ListItem>
{/*<ListItem title={Locale.Settings.Lang.Name}>*/}
{/* <Select*/}
{/* value={getLang()}*/}
{/* onChange={(e) => {*/}
{/* changeLang(e.target.value as any);*/}
{/* }}*/}
{/* >*/}
{/* {AllLangs.map((lang) => (*/}
{/* <option value={lang} key={lang}>*/}
{/* {ALL_LANG_OPTIONS[lang]}*/}
{/* </option>*/}
{/* ))}*/}
{/* </Select>*/}
{/*</ListItem>*/}
<ListItem
title={Locale.Settings.FontSize.Title}
subTitle={Locale.Settings.FontSize.SubTitle}
>
<InputRange
title={`${config.fontSize ?? 14}px`}
value={config.fontSize}
min="12"
max="40"
step="1"
onChange={(e) =>
updateConfig(
(config) =>
(config.fontSize = Number.parseInt(e.currentTarget.value)),
)
}
></InputRange>
</ListItem>
{/*<ListItem*/}
{/* title={Locale.Settings.FontSize.Title}*/}
{/* subTitle={Locale.Settings.FontSize.SubTitle}*/}
{/*>*/}
{/* <InputRange*/}
{/* title={`${config.fontSize ?? 14}px`}*/}
{/* value={config.fontSize}*/}
{/* min="12"*/}
{/* max="40"*/}
{/* step="1"*/}
{/* onChange={(e) =>*/}
{/* updateConfig(*/}
{/* (config) =>*/}
{/* (config.fontSize = Number.parseInt(e.currentTarget.value)),*/}
{/* )*/}
{/* }*/}
{/* ></InputRange>*/}
{/*</ListItem>*/}
<ListItem
title={Locale.Settings.AutoGenerateTitle.Title}
subTitle={Locale.Settings.AutoGenerateTitle.SubTitle}
>
<input
type="checkbox"
checked={config.enableAutoGenerateTitle}
onChange={(e) =>
updateConfig(
(config) =>
(config.enableAutoGenerateTitle = e.currentTarget.checked),
)
}
></input>
</ListItem>
{/*<ListItem*/}
{/* title={Locale.Settings.AutoGenerateTitle.Title}*/}
{/* subTitle={Locale.Settings.AutoGenerateTitle.SubTitle}*/}
{/*>*/}
{/* <input*/}
{/* type="checkbox"*/}
{/* checked={config.enableAutoGenerateTitle}*/}
{/* onChange={(e) =>*/}
{/* updateConfig(*/}
{/* (config) =>*/}
{/* (config.enableAutoGenerateTitle = e.currentTarget.checked),*/}
{/* )*/}
{/* }*/}
{/* ></input>*/}
{/*</ListItem>*/}
<ListItem
title={Locale.Settings.SendPreviewBubble.Title}
subTitle={Locale.Settings.SendPreviewBubble.SubTitle}
>
<input
type="checkbox"
checked={config.sendPreviewBubble}
onChange={(e) =>
updateConfig(
(config) =>
(config.sendPreviewBubble = e.currentTarget.checked),
)
}
></input>
</ListItem>
{/*<ListItem*/}
{/* title={Locale.Settings.SendPreviewBubble.Title}*/}
{/* subTitle={Locale.Settings.SendPreviewBubble.SubTitle}*/}
{/*>*/}
{/* <input*/}
{/* type="checkbox"*/}
{/* checked={config.sendPreviewBubble}*/}
{/* onChange={(e) =>*/}
{/* updateConfig(*/}
{/* (config) =>*/}
{/* (config.sendPreviewBubble = e.currentTarget.checked),*/}
{/* )*/}
{/* }*/}
{/* ></input>*/}
{/*</ListItem>*/}
</List>
<SyncItems />
<List>
<ListItem
title={Locale.Settings.Mask.Splash.Title}
subTitle={Locale.Settings.Mask.Splash.SubTitle}
>
<input
type="checkbox"
checked={!config.dontShowMaskSplashScreen}
onChange={(e) =>
updateConfig(
(config) =>
(config.dontShowMaskSplashScreen =
!e.currentTarget.checked),
)
}
></input>
</ListItem>
{/*<List>*/}
{/* <ListItem*/}
{/* title={Locale.Settings.Mask.Splash.Title}*/}
{/* subTitle={Locale.Settings.Mask.Splash.SubTitle}*/}
{/* >*/}
{/* <input*/}
{/* type="checkbox"*/}
{/* checked={!config.dontShowMaskSplashScreen}*/}
{/* onChange={(e) =>*/}
{/* updateConfig(*/}
{/* (config) =>*/}
{/* (config.dontShowMaskSplashScreen =*/}
{/* !e.currentTarget.checked),*/}
{/* )*/}
{/* }*/}
{/* ></input>*/}
{/* </ListItem>*/}
<ListItem
title={Locale.Settings.Mask.Builtin.Title}
subTitle={Locale.Settings.Mask.Builtin.SubTitle}
>
<input
type="checkbox"
checked={config.hideBuiltinMasks}
onChange={(e) =>
updateConfig(
(config) =>
(config.hideBuiltinMasks = e.currentTarget.checked),
)
}
></input>
</ListItem>
</List>
{/* <ListItem*/}
{/* title={Locale.Settings.Mask.Builtin.Title}*/}
{/* subTitle={Locale.Settings.Mask.Builtin.SubTitle}*/}
{/* >*/}
{/* <input*/}
{/* type="checkbox"*/}
{/* checked={config.hideBuiltinMasks}*/}
{/* onChange={(e) =>*/}
{/* updateConfig(*/}
{/* (config) =>*/}
{/* (config.hideBuiltinMasks = e.currentTarget.checked),*/}
{/* )*/}
{/* }*/}
{/* ></input>*/}
{/* </ListItem>*/}
{/*</List>*/}
<List>
<ListItem
title={Locale.Settings.Prompt.Disable.Title}
subTitle={Locale.Settings.Prompt.Disable.SubTitle}
>
<input
type="checkbox"
checked={config.disablePromptHint}
onChange={(e) =>
updateConfig(
(config) =>
(config.disablePromptHint = e.currentTarget.checked),
)
}
></input>
</ListItem>
{/*<List>*/}
{/*<ListItem*/}
{/* title={Locale.Settings.Prompt.Disable.Title}*/}
{/* subTitle={Locale.Settings.Prompt.Disable.SubTitle}*/}
{/*>*/}
{/* <input*/}
{/* type="checkbox"*/}
{/* checked={config.disablePromptHint}*/}
{/* onChange={(e) =>*/}
{/* updateConfig(*/}
{/* (config) =>*/}
{/* (config.disablePromptHint = e.currentTarget.checked),*/}
{/* )*/}
{/* }*/}
{/* ></input>*/}
{/*</ListItem>*/}
<ListItem
title={Locale.Settings.Prompt.List}
subTitle={Locale.Settings.Prompt.ListCount(
builtinCount,
customCount,
)}
>
<IconButton
icon={<EditIcon />}
text={Locale.Settings.Prompt.Edit}
onClick={() => setShowPromptModal(true)}
/>
</ListItem>
</List>
{/* <ListItem*/}
{/* title={Locale.Settings.Prompt.List}*/}
{/* subTitle={Locale.Settings.Prompt.ListCount(*/}
{/* builtinCount,*/}
{/* customCount,*/}
{/* )}*/}
{/* >*/}
{/* <IconButton*/}
{/* icon={<EditIcon />}*/}
{/* text={Locale.Settings.Prompt.Edit}*/}
{/* onClick={() => setShowPromptModal(true)}*/}
{/* />*/}
{/* </ListItem>*/}
{/*</List>*/}
<List id={SlotID.CustomModel}>
{showAccessCode && (
<ListItem
title={Locale.Settings.Access.AccessCode.Title}
subTitle={Locale.Settings.Access.AccessCode.SubTitle}
>
<PasswordInput
value={accessStore.accessCode}
type="text"
placeholder={Locale.Settings.Access.AccessCode.Placeholder}
onChange={(e) => {
accessStore.update(
(access) => (access.accessCode = e.currentTarget.value),
);
}}
/>
</ListItem>
)}
{/*<List id={SlotID.CustomModel}>*/}
{/* {showAccessCode && (*/}
{/* <ListItem*/}
{/* title={Locale.Settings.Access.AccessCode.Title}*/}
{/* subTitle={Locale.Settings.Access.AccessCode.SubTitle}*/}
{/* >*/}
{/* <PasswordInput*/}
{/* value={accessStore.accessCode}*/}
{/* type="text"*/}
{/* placeholder={Locale.Settings.Access.AccessCode.Placeholder}*/}
{/* onChange={(e) => {*/}
{/* accessStore.update(*/}
{/* (access) => (access.accessCode = e.currentTarget.value),*/}
{/* );*/}
{/* }}*/}
{/* />*/}
{/* </ListItem>*/}
{/* )}*/}
{!accessStore.hideUserApiKey && (
<>
{
// Conditionally render the following ListItem based on clientConfig.isApp
!clientConfig?.isApp && ( // only show if isApp is false
<ListItem
title={Locale.Settings.Access.CustomEndpoint.Title}
subTitle={Locale.Settings.Access.CustomEndpoint.SubTitle}
>
<input
type="checkbox"
checked={accessStore.useCustomConfig}
onChange={(e) =>
accessStore.update(
(access) =>
(access.useCustomConfig = e.currentTarget.checked),
)
}
></input>
</ListItem>
)
}
{accessStore.useCustomConfig && (
<>
<ListItem
title={Locale.Settings.Access.Provider.Title}
subTitle={Locale.Settings.Access.Provider.SubTitle}
>
<Select
value={accessStore.provider}
onChange={(e) => {
accessStore.update(
(access) =>
(access.provider = e.target
.value as ServiceProvider),
);
}}
>
{Object.entries(ServiceProvider).map(([k, v]) => (
<option value={v} key={k}>
{k}
</option>
))}
</Select>
</ListItem>
{/*{!accessStore.hideUserApiKey && (*/}
{/* <>*/}
{/* {*/}
{/* // Conditionally render the following ListItem based on clientConfig.isApp*/}
{/* !clientConfig?.isApp && ( // only show if isApp is false*/}
{/* <ListItem*/}
{/* title={Locale.Settings.Access.CustomEndpoint.Title}*/}
{/* subTitle={Locale.Settings.Access.CustomEndpoint.SubTitle}*/}
{/* >*/}
{/* <input*/}
{/* type="checkbox"*/}
{/* checked={accessStore.useCustomConfig}*/}
{/* onChange={(e) =>*/}
{/* accessStore.update(*/}
{/* (access) =>*/}
{/* (access.useCustomConfig = e.currentTarget.checked),*/}
{/* )*/}
{/* }*/}
{/* ></input>*/}
{/* </ListItem>*/}
{/* )*/}
{/* }*/}
{/* {accessStore.useCustomConfig && (*/}
{/* <>*/}
{/* <ListItem*/}
{/* title={Locale.Settings.Access.Provider.Title}*/}
{/* subTitle={Locale.Settings.Access.Provider.SubTitle}*/}
{/* >*/}
{/* <Select*/}
{/* value={accessStore.provider}*/}
{/* onChange={(e) => {*/}
{/* accessStore.update(*/}
{/* (access) =>*/}
{/* (access.provider = e.target*/}
{/* .value as ServiceProvider),*/}
{/* );*/}
{/* }}*/}
{/* >*/}
{/* {Object.entries(ServiceProvider).map(([k, v]) => (*/}
{/* <option value={v} key={k}>*/}
{/* {k}*/}
{/* </option>*/}
{/* ))}*/}
{/* </Select>*/}
{/* </ListItem>*/}
{accessStore.provider === "OpenAI" ? (
<>
<ListItem
title={Locale.Settings.Access.OpenAI.Endpoint.Title}
subTitle={
Locale.Settings.Access.OpenAI.Endpoint.SubTitle
}
>
<input
type="text"
value={accessStore.openaiUrl}
placeholder={OPENAI_BASE_URL}
onChange={(e) =>
accessStore.update(
(access) =>
(access.openaiUrl = e.currentTarget.value),
)
}
></input>
</ListItem>
<ListItem
title={Locale.Settings.Access.OpenAI.ApiKey.Title}
subTitle={Locale.Settings.Access.OpenAI.ApiKey.SubTitle}
>
<PasswordInput
value={accessStore.openaiApiKey}
type="text"
placeholder={
Locale.Settings.Access.OpenAI.ApiKey.Placeholder
}
onChange={(e) => {
accessStore.update(
(access) =>
(access.openaiApiKey = e.currentTarget.value),
);
}}
/>
</ListItem>
</>
) : (
<>
<ListItem
title={Locale.Settings.Access.Azure.Endpoint.Title}
subTitle={
Locale.Settings.Access.Azure.Endpoint.SubTitle +
Azure.ExampleEndpoint
}
>
<input
type="text"
value={accessStore.azureUrl}
placeholder={Azure.ExampleEndpoint}
onChange={(e) =>
accessStore.update(
(access) =>
(access.azureUrl = e.currentTarget.value),
)
}
></input>
</ListItem>
<ListItem
title={Locale.Settings.Access.Azure.ApiKey.Title}
subTitle={Locale.Settings.Access.Azure.ApiKey.SubTitle}
>
<PasswordInput
value={accessStore.azureApiKey}
type="text"
placeholder={
Locale.Settings.Access.Azure.ApiKey.Placeholder
}
onChange={(e) => {
accessStore.update(
(access) =>
(access.azureApiKey = e.currentTarget.value),
);
}}
/>
</ListItem>
<ListItem
title={Locale.Settings.Access.Azure.ApiVerion.Title}
subTitle={
Locale.Settings.Access.Azure.ApiVerion.SubTitle
}
>
<input
type="text"
value={accessStore.azureApiVersion}
placeholder="2023-08-01-preview"
onChange={(e) =>
accessStore.update(
(access) =>
(access.azureApiVersion =
e.currentTarget.value),
)
}
></input>
</ListItem>
</>
)}
</>
)}
</>
)}
{/* {accessStore.provider === "OpenAI" ? (*/}
{/* <>*/}
{/* <ListItem*/}
{/* title={Locale.Settings.Access.OpenAI.Endpoint.Title}*/}
{/* subTitle={*/}
{/* Locale.Settings.Access.OpenAI.Endpoint.SubTitle*/}
{/* }*/}
{/* >*/}
{/* <input*/}
{/* type="text"*/}
{/* value={accessStore.openaiUrl}*/}
{/* placeholder={OPENAI_BASE_URL}*/}
{/* onChange={(e) =>*/}
{/* accessStore.update(*/}
{/* (access) =>*/}
{/* (access.openaiUrl = e.currentTarget.value),*/}
{/* )*/}
{/* }*/}
{/* ></input>*/}
{/* </ListItem>*/}
{/* <ListItem*/}
{/* title={Locale.Settings.Access.OpenAI.ApiKey.Title}*/}
{/* subTitle={Locale.Settings.Access.OpenAI.ApiKey.SubTitle}*/}
{/* >*/}
{/* <PasswordInput*/}
{/* value={accessStore.openaiApiKey}*/}
{/* type="text"*/}
{/* placeholder={*/}
{/* Locale.Settings.Access.OpenAI.ApiKey.Placeholder*/}
{/* }*/}
{/* onChange={(e) => {*/}
{/* accessStore.update(*/}
{/* (access) =>*/}
{/* (access.openaiApiKey = e.currentTarget.value),*/}
{/* );*/}
{/* }}*/}
{/* />*/}
{/* </ListItem>*/}
{/* </>*/}
{/* ) : (*/}
{/* <>*/}
{/* <ListItem*/}
{/* title={Locale.Settings.Access.Azure.Endpoint.Title}*/}
{/* subTitle={*/}
{/* Locale.Settings.Access.Azure.Endpoint.SubTitle +*/}
{/* Azure.ExampleEndpoint*/}
{/* }*/}
{/* >*/}
{/* <input*/}
{/* type="text"*/}
{/* value={accessStore.azureUrl}*/}
{/* placeholder={Azure.ExampleEndpoint}*/}
{/* onChange={(e) =>*/}
{/* accessStore.update(*/}
{/* (access) =>*/}
{/* (access.azureUrl = e.currentTarget.value),*/}
{/* )*/}
{/* }*/}
{/* ></input>*/}
{/* </ListItem>*/}
{/* <ListItem*/}
{/* title={Locale.Settings.Access.Azure.ApiKey.Title}*/}
{/* subTitle={Locale.Settings.Access.Azure.ApiKey.SubTitle}*/}
{/* >*/}
{/* <PasswordInput*/}
{/* value={accessStore.azureApiKey}*/}
{/* type="text"*/}
{/* placeholder={*/}
{/* Locale.Settings.Access.Azure.ApiKey.Placeholder*/}
{/* }*/}
{/* onChange={(e) => {*/}
{/* accessStore.update(*/}
{/* (access) =>*/}
{/* (access.azureApiKey = e.currentTarget.value),*/}
{/* );*/}
{/* }}*/}
{/* />*/}
{/* </ListItem>*/}
{/* <ListItem*/}
{/* title={Locale.Settings.Access.Azure.ApiVerion.Title}*/}
{/* subTitle={*/}
{/* Locale.Settings.Access.Azure.ApiVerion.SubTitle*/}
{/* }*/}
{/* >*/}
{/* <input*/}
{/* type="text"*/}
{/* value={accessStore.azureApiVersion}*/}
{/* placeholder="2023-08-01-preview"*/}
{/* onChange={(e) =>*/}
{/* accessStore.update(*/}
{/* (access) =>*/}
{/* (access.azureApiVersion =*/}
{/* e.currentTarget.value),*/}
{/* )*/}
{/* }*/}
{/* ></input>*/}
{/* </ListItem>*/}
{/* </>*/}
{/* )}*/}
{/* </>*/}
{/* )}*/}
{/* </>*/}
{/* )}*/}
{!shouldHideBalanceQuery && !clientConfig?.isApp ? (
<ListItem
title={Locale.Settings.Usage.Title}
subTitle={
showUsage
? loadingUsage
? Locale.Settings.Usage.IsChecking
: Locale.Settings.Usage.SubTitle(
usage?.used ?? "[?]",
usage?.subscription ?? "[?]",
)
: Locale.Settings.Usage.NoAccess
}
>
{!showUsage || loadingUsage ? (
<div />
) : (
<IconButton
icon={<ResetIcon></ResetIcon>}
text={Locale.Settings.Usage.Check}
onClick={() => checkUsage(true)}
/>
)}
</ListItem>
) : null}
{/*{!shouldHideBalanceQuery && !clientConfig?.isApp ? (*/}
{/* <ListItem*/}
{/* title={Locale.Settings.Usage.Title}*/}
{/* subTitle={*/}
{/* showUsage*/}
{/* ? loadingUsage*/}
{/* ? Locale.Settings.Usage.IsChecking*/}
{/* : Locale.Settings.Usage.SubTitle(*/}
{/* usage?.used ?? "[?]",*/}
{/* usage?.subscription ?? "[?]",*/}
{/* )*/}
{/* : Locale.Settings.Usage.NoAccess*/}
{/* }*/}
{/* >*/}
{/* {!showUsage || loadingUsage ? (*/}
{/* <div />*/}
{/* ) : (*/}
{/* <IconButton*/}
{/* icon={<ResetIcon></ResetIcon>}*/}
{/* text={Locale.Settings.Usage.Check}*/}
{/* onClick={() => checkUsage(true)}*/}
{/* />*/}
{/* )}*/}
{/* </ListItem>*/}
{/*) : null}*/}
<ListItem
title={Locale.Settings.Access.CustomModel.Title}
subTitle={Locale.Settings.Access.CustomModel.SubTitle}
>
<input
type="text"
value={config.customModels}
placeholder="model1,model2,model3"
onChange={(e) =>
config.update(
(config) => (config.customModels = e.currentTarget.value),
)
}
></input>
</ListItem>
</List>
{/* /!*<ListItem*!/*/}
{/* /!* title={Locale.Settings.Access.CustomModel.Title}*!/*/}
{/* /!* subTitle={Locale.Settings.Access.CustomModel.SubTitle}*!/*/}
{/* /!*>*!/*/}
{/* /!* <input*!/*/}
{/* /!* type="text"*!/*/}
{/* /!* value={config.customModels}*!/*/}
{/* /!* placeholder="model1,model2,model3"*!/*/}
{/* /!* onChange={(e) =>*!/*/}
{/* /!* config.update(*!/*/}
{/* /!* (config) => (config.customModels = e.currentTarget.value),*!/*/}
{/* /!* )*!/*/}
{/* /!* }*!/*/}
{/* /!* ></input>*!/*/}
{/* /!*</ListItem>*!/*/}
{/*</List>*/}
<List>
<ModelConfigList

View File

@@ -4,13 +4,12 @@ import styles from "./home.module.scss";
import { IconButton } from "./button";
import SettingsIcon from "../icons/settings.svg";
import GithubIcon from "../icons/github.svg";
import ChatGptIcon from "../icons/chatgpt.svg";
import AddIcon from "../icons/add.svg";
import CloseIcon from "../icons/close.svg";
import DeleteIcon from "../icons/delete.svg";
import MaskIcon from "../icons/mask.svg";
import PluginIcon from "../icons/plugin.svg";
import CoffeeIcon from "../icons/coffee.svg";
import DragIcon from "../icons/drag.svg";
import Locale from "../locales";
@@ -155,10 +154,17 @@ export function SideBar(props: { className?: string }) {
>
<div className={styles["sidebar-header"]} data-tauri-drag-region>
<div className={styles["sidebar-title"]} data-tauri-drag-region>
ChatGPT Next
</div>
<div className={styles["sidebar-sub-title"]}>
Build your own AI assistant.
<br />
<br />
1. <b></b><b></b>
<br />
2. /mj
<br />
3.
</div>
<div className={styles["sidebar-logo"] + " no-dark"}>
<ChatGptIcon />
@@ -180,12 +186,19 @@ export function SideBar(props: { className?: string }) {
shadow
/>
<IconButton
icon={<PluginIcon />}
text={shouldNarrow ? undefined : Locale.Plugin.Name}
icon={<CoffeeIcon />}
text={shouldNarrow ? undefined : "赏杯咖啡️"}
className={styles["sidebar-bar-button"]}
onClick={() => showToast(Locale.WIP)}
onClick={() => navigate(Path.Reward)}
shadow
/>
{/*<IconButton*/}
{/* icon={<PluginIcon />}*/}
{/* text={shouldNarrow ? undefined : Locale.Plugin.Name}*/}
{/* className={styles["sidebar-bar-button"]}*/}
{/* onClick={() => showToast(Locale.WIP)}*/}
{/* shadow*/}
{/*/>*/}
</div>
<div
@@ -216,11 +229,6 @@ export function SideBar(props: { className?: string }) {
<IconButton icon={<SettingsIcon />} shadow />
</Link>
</div>
<div className={styles["sidebar-action"]}>
<a href={REPO_URL} target="_blank" rel="noopener noreferrer">
<IconButton icon={<GithubIcon />} shadow />
</a>
</div>
</div>
<div>
<IconButton