Spaces:
Running
Running
muxi feng
commited on
Commit
·
bcd32d0
1
Parent(s):
6df0f04
下拉选项增加图标
Browse files- app/components/mask.tsx +5 -5
- app/components/model-config.tsx +3 -3
- app/components/settings.tsx +17 -11
- app/components/ui-lib.module.scss +24 -0
- app/components/ui-lib.tsx +18 -0
- app/icons/down.svg +1 -0
app/components/mask.tsx
CHANGED
@@ -14,7 +14,7 @@ import CopyIcon from "../icons/copy.svg";
|
|
14 |
|
15 |
import { DEFAULT_MASK_AVATAR, Mask, useMaskStore } from "../store/mask";
|
16 |
import { Message, ModelConfig, ROLES, useChatStore } from "../store";
|
17 |
-
import { Input, List, ListItem, Modal, Popover } from "./ui-lib";
|
18 |
import { Avatar, AvatarPicker } from "./emoji";
|
19 |
import Locale, { AllLangs, Lang } from "../locales";
|
20 |
import { useNavigate } from "react-router-dom";
|
@@ -116,7 +116,7 @@ function ContextPromptItem(props: {
|
|
116 |
return (
|
117 |
<div className={chatStyle["context-prompt-row"]}>
|
118 |
{!focusingInput && (
|
119 |
-
<
|
120 |
value={props.prompt.role}
|
121 |
className={chatStyle["context-role"]}
|
122 |
onChange={(e) =>
|
@@ -131,7 +131,7 @@ function ContextPromptItem(props: {
|
|
131 |
{r}
|
132 |
</option>
|
133 |
))}
|
134 |
-
</
|
135 |
)}
|
136 |
<Input
|
137 |
value={props.prompt.content}
|
@@ -307,7 +307,7 @@ export function MaskPage() {
|
|
307 |
autoFocus
|
308 |
onInput={(e) => onSearch(e.currentTarget.value)}
|
309 |
/>
|
310 |
-
<
|
311 |
className={styles["mask-filter-lang"]}
|
312 |
value={filterLang ?? Locale.Settings.Lang.All}
|
313 |
onChange={(e) => {
|
@@ -327,7 +327,7 @@ export function MaskPage() {
|
|
327 |
{Locale.Settings.Lang.Options[lang]}
|
328 |
</option>
|
329 |
))}
|
330 |
-
</
|
331 |
|
332 |
<IconButton
|
333 |
className={styles["mask-create"]}
|
|
|
14 |
|
15 |
import { DEFAULT_MASK_AVATAR, Mask, useMaskStore } from "../store/mask";
|
16 |
import { Message, ModelConfig, ROLES, useChatStore } from "../store";
|
17 |
+
import { Input, List, ListItem, Modal, Popover,Select } from "./ui-lib";
|
18 |
import { Avatar, AvatarPicker } from "./emoji";
|
19 |
import Locale, { AllLangs, Lang } from "../locales";
|
20 |
import { useNavigate } from "react-router-dom";
|
|
|
116 |
return (
|
117 |
<div className={chatStyle["context-prompt-row"]}>
|
118 |
{!focusingInput && (
|
119 |
+
<Select
|
120 |
value={props.prompt.role}
|
121 |
className={chatStyle["context-role"]}
|
122 |
onChange={(e) =>
|
|
|
131 |
{r}
|
132 |
</option>
|
133 |
))}
|
134 |
+
</Select>
|
135 |
)}
|
136 |
<Input
|
137 |
value={props.prompt.content}
|
|
|
307 |
autoFocus
|
308 |
onInput={(e) => onSearch(e.currentTarget.value)}
|
309 |
/>
|
310 |
+
<Select
|
311 |
className={styles["mask-filter-lang"]}
|
312 |
value={filterLang ?? Locale.Settings.Lang.All}
|
313 |
onChange={(e) => {
|
|
|
327 |
{Locale.Settings.Lang.Options[lang]}
|
328 |
</option>
|
329 |
))}
|
330 |
+
</Select>
|
331 |
|
332 |
<IconButton
|
333 |
className={styles["mask-create"]}
|
app/components/model-config.tsx
CHANGED
@@ -2,7 +2,7 @@ import { ALL_MODELS, ModalConfigValidator, ModelConfig } from "../store";
|
|
2 |
|
3 |
import Locale from "../locales";
|
4 |
import { InputRange } from "./input-range";
|
5 |
-
import {
|
6 |
|
7 |
export function ModelConfigList(props: {
|
8 |
modelConfig: ModelConfig;
|
@@ -11,7 +11,7 @@ export function ModelConfigList(props: {
|
|
11 |
return (
|
12 |
<>
|
13 |
<ListItem title={Locale.Settings.Model}>
|
14 |
-
<
|
15 |
value={props.modelConfig.model}
|
16 |
onChange={(e) => {
|
17 |
props.updateConfig(
|
@@ -27,7 +27,7 @@ export function ModelConfigList(props: {
|
|
27 |
{v.name}
|
28 |
</option>
|
29 |
))}
|
30 |
-
</
|
31 |
</ListItem>
|
32 |
<ListItem
|
33 |
title={Locale.Settings.Temperature.Title}
|
|
|
2 |
|
3 |
import Locale from "../locales";
|
4 |
import { InputRange } from "./input-range";
|
5 |
+
import { ListItem,Select} from "./ui-lib";
|
6 |
|
7 |
export function ModelConfigList(props: {
|
8 |
modelConfig: ModelConfig;
|
|
|
11 |
return (
|
12 |
<>
|
13 |
<ListItem title={Locale.Settings.Model}>
|
14 |
+
<Select
|
15 |
value={props.modelConfig.model}
|
16 |
onChange={(e) => {
|
17 |
props.updateConfig(
|
|
|
27 |
{v.name}
|
28 |
</option>
|
29 |
))}
|
30 |
+
</Select>
|
31 |
</ListItem>
|
32 |
<ListItem
|
33 |
title={Locale.Settings.Temperature.Title}
|
app/components/settings.tsx
CHANGED
@@ -1,4 +1,4 @@
|
|
1 |
-
import { useState, useEffect, useMemo
|
2 |
|
3 |
import styles from "./settings.module.scss";
|
4 |
|
@@ -9,8 +9,14 @@ import CopyIcon from "../icons/copy.svg";
|
|
9 |
import ClearIcon from "../icons/clear.svg";
|
10 |
import EditIcon from "../icons/edit.svg";
|
11 |
import EyeIcon from "../icons/eye.svg";
|
12 |
-
import
|
13 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
14 |
import { ModelConfigList } from "./model-config";
|
15 |
|
16 |
import { IconButton } from "./button";
|
@@ -372,7 +378,7 @@ export function Settings() {
|
|
372 |
</ListItem> */}
|
373 |
|
374 |
<ListItem title={Locale.Settings.SendKey}>
|
375 |
-
<
|
376 |
value={config.submitKey}
|
377 |
onChange={(e) => {
|
378 |
updateConfig(
|
@@ -386,11 +392,11 @@ export function Settings() {
|
|
386 |
{v}
|
387 |
</option>
|
388 |
))}
|
389 |
-
</
|
390 |
</ListItem>
|
391 |
|
392 |
<ListItem title={Locale.Settings.Theme}>
|
393 |
-
<
|
394 |
value={config.theme}
|
395 |
onChange={(e) => {
|
396 |
updateConfig(
|
@@ -403,11 +409,11 @@ export function Settings() {
|
|
403 |
{v}
|
404 |
</option>
|
405 |
))}
|
406 |
-
</
|
407 |
</ListItem>
|
408 |
|
409 |
<ListItem title={Locale.Settings.Lang.Name}>
|
410 |
-
<
|
411 |
value={getLang()}
|
412 |
onChange={(e) => {
|
413 |
changeLang(e.target.value as any);
|
@@ -418,7 +424,7 @@ export function Settings() {
|
|
418 |
{Locale.Settings.Lang.Options[lang]}
|
419 |
</option>
|
420 |
))}
|
421 |
-
</
|
422 |
</ListItem>
|
423 |
|
424 |
<ListItem
|
@@ -568,7 +574,7 @@ export function Settings() {
|
|
568 |
|
569 |
<List>
|
570 |
<ListItem title={Locale.Settings.Bot}>
|
571 |
-
<
|
572 |
value={config.bot}
|
573 |
onChange={(e) => {
|
574 |
updateConfig(
|
@@ -585,7 +591,7 @@ export function Settings() {
|
|
585 |
{v.name}
|
586 |
</option>
|
587 |
))}
|
588 |
-
</
|
589 |
</ListItem>
|
590 |
</List>
|
591 |
|
|
|
1 |
+
import { useState, useEffect, useMemo } from "react";
|
2 |
|
3 |
import styles from "./settings.module.scss";
|
4 |
|
|
|
9 |
import ClearIcon from "../icons/clear.svg";
|
10 |
import EditIcon from "../icons/edit.svg";
|
11 |
import EyeIcon from "../icons/eye.svg";
|
12 |
+
import {
|
13 |
+
Input,
|
14 |
+
List,
|
15 |
+
ListItem,
|
16 |
+
Modal,
|
17 |
+
PasswordInput,
|
18 |
+
Select,
|
19 |
+
} from "./ui-lib";
|
20 |
import { ModelConfigList } from "./model-config";
|
21 |
|
22 |
import { IconButton } from "./button";
|
|
|
378 |
</ListItem> */}
|
379 |
|
380 |
<ListItem title={Locale.Settings.SendKey}>
|
381 |
+
<Select
|
382 |
value={config.submitKey}
|
383 |
onChange={(e) => {
|
384 |
updateConfig(
|
|
|
392 |
{v}
|
393 |
</option>
|
394 |
))}
|
395 |
+
</Select>
|
396 |
</ListItem>
|
397 |
|
398 |
<ListItem title={Locale.Settings.Theme}>
|
399 |
+
<Select
|
400 |
value={config.theme}
|
401 |
onChange={(e) => {
|
402 |
updateConfig(
|
|
|
409 |
{v}
|
410 |
</option>
|
411 |
))}
|
412 |
+
</Select>
|
413 |
</ListItem>
|
414 |
|
415 |
<ListItem title={Locale.Settings.Lang.Name}>
|
416 |
+
<Select
|
417 |
value={getLang()}
|
418 |
onChange={(e) => {
|
419 |
changeLang(e.target.value as any);
|
|
|
424 |
{Locale.Settings.Lang.Options[lang]}
|
425 |
</option>
|
426 |
))}
|
427 |
+
</Select>
|
428 |
</ListItem>
|
429 |
|
430 |
<ListItem
|
|
|
574 |
|
575 |
<List>
|
576 |
<ListItem title={Locale.Settings.Bot}>
|
577 |
+
<Select
|
578 |
value={config.bot}
|
579 |
onChange={(e) => {
|
580 |
updateConfig(
|
|
|
591 |
{v.name}
|
592 |
</option>
|
593 |
))}
|
594 |
+
</Select>
|
595 |
</ListItem>
|
596 |
</List>
|
597 |
|
app/components/ui-lib.module.scss
CHANGED
@@ -205,3 +205,27 @@
|
|
205 |
min-width: 50px;
|
206 |
}
|
207 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
205 |
min-width: 50px;
|
206 |
}
|
207 |
|
208 |
+
.select-with-icon {
|
209 |
+
position: relative;
|
210 |
+
max-width: fit-content;
|
211 |
+
|
212 |
+
.select-with-icon-select {
|
213 |
+
height: 100%;
|
214 |
+
border: var(--border-in-light);
|
215 |
+
padding: 10px 25px 10px 10px;
|
216 |
+
border-radius: 10px;
|
217 |
+
appearance: none;
|
218 |
+
cursor: pointer;
|
219 |
+
background-color: var(--white);
|
220 |
+
color: var(--black);
|
221 |
+
text-align: center;
|
222 |
+
}
|
223 |
+
|
224 |
+
.select-with-icon-icon {
|
225 |
+
position: absolute;
|
226 |
+
top: 50%;
|
227 |
+
right: 10px;
|
228 |
+
transform: translateY(-50%);
|
229 |
+
pointer-events: none;
|
230 |
+
}
|
231 |
+
}
|
app/components/ui-lib.tsx
CHANGED
@@ -3,6 +3,7 @@ import LoadingIcon from "../icons/three-dots.svg";
|
|
3 |
import CloseIcon from "../icons/close.svg";
|
4 |
import EyeIcon from "../icons/eye.svg";
|
5 |
import EyeOffIcon from "../icons/eye-off.svg";
|
|
|
6 |
|
7 |
import { createRoot } from "react-dom/client";
|
8 |
import React, { HTMLProps, useEffect, useState} from "react";
|
@@ -244,3 +245,20 @@ export function PasswordInput(props: HTMLProps<HTMLInputElement>) {
|
|
244 |
</div>
|
245 |
);
|
246 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
import CloseIcon from "../icons/close.svg";
|
4 |
import EyeIcon from "../icons/eye.svg";
|
5 |
import EyeOffIcon from "../icons/eye-off.svg";
|
6 |
+
import DownIcon from "../icons/down.svg";
|
7 |
|
8 |
import { createRoot } from "react-dom/client";
|
9 |
import React, { HTMLProps, useEffect, useState} from "react";
|
|
|
245 |
</div>
|
246 |
);
|
247 |
}
|
248 |
+
|
249 |
+
export function Select(
|
250 |
+
props: React.DetailedHTMLProps<
|
251 |
+
React.SelectHTMLAttributes<HTMLSelectElement>,
|
252 |
+
HTMLSelectElement
|
253 |
+
>,
|
254 |
+
) {
|
255 |
+
const { className, children, ...otherProps } = props;
|
256 |
+
return (
|
257 |
+
<div className={`${styles["select-with-icon"]} ${className}`}>
|
258 |
+
<select className={styles["select-with-icon-select"]} {...otherProps}>
|
259 |
+
{children}
|
260 |
+
</select>
|
261 |
+
<DownIcon className={styles["select-with-icon-icon"]} />
|
262 |
+
</div>
|
263 |
+
);
|
264 |
+
}
|
app/icons/down.svg
ADDED