feat: add plugin entry selection

This commit is contained in:
licoy
2024-06-27 15:35:16 +08:00
parent a51fb24f36
commit fa6ebadc7b
3 changed files with 37 additions and 10 deletions

View File

@@ -1,4 +1,4 @@
import { useEffect, useRef, useMemo } from "react";
import React, { useEffect, useRef, useMemo, useState } from "react";
import styles from "./home.module.scss";
@@ -15,7 +15,7 @@ import DragIcon from "../icons/drag.svg";
import Locale from "../locales";
import { useAppConfig, useChatStore } from "../store";
import { ModelType, useAppConfig, useChatStore } from "../store";
import {
DEFAULT_SIDEBAR_WIDTH,
@@ -29,7 +29,7 @@ import {
import { Link, useNavigate } from "react-router-dom";
import { isIOS, useMobileScreen } from "../utils";
import dynamic from "next/dynamic";
import { showConfirm, showToast } from "./ui-lib";
import { Selector, showConfirm, showToast } from "./ui-lib";
const ChatList = dynamic(async () => (await import("./chat-list")).ChatList, {
loading: () => null,
@@ -140,6 +140,7 @@ export function SideBar(props: { className?: string }) {
() => isIOS() && isMobileScreen,
[isMobileScreen],
);
const [showPluginSelector, setShowPluginSelector] = useState(false);
useHotKey();
@@ -183,7 +184,7 @@ export function SideBar(props: { className?: string }) {
icon={<PluginIcon />}
text={shouldNarrow ? undefined : Locale.Plugin.Name}
className={styles["sidebar-bar-button"]}
onClick={() => showToast(Locale.WIP)}
onClick={() => setShowPluginSelector(true)}
shadow
/>
</div>
@@ -245,6 +246,22 @@ export function SideBar(props: { className?: string }) {
>
<DragIcon />
</div>
{showPluginSelector && (
<Selector
items={[
{
title: "👇 Please select the plugin you need to use",
value: "-",
disable: true,
},
{ title: "Stable Diffusion", value: "sd" },
]}
onClose={() => setShowPluginSelector(false)}
onSelection={(s) => {
console.log("go to page: ", s);
}}
/>
)}
</div>
);
}