mirror of
https://github.com/coaidev/coai.git
synced 2025-05-23 06:50:14 +09:00
feat: update model market
This commit is contained in:
parent
9151fdf8ee
commit
5c42d33f30
@ -11,12 +11,26 @@
|
|||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
padding: 1rem 3.5rem;
|
padding: 0 3.5rem;
|
||||||
height: max-content;
|
height: 100%;
|
||||||
max-height: calc(100% - 56px);
|
|
||||||
overflow: auto;
|
overflow: auto;
|
||||||
scrollbar-width: thin;
|
scrollbar-width: thin;
|
||||||
|
|
||||||
|
&:before {
|
||||||
|
--line: hsl(var(--text-secondary) / 0.25);
|
||||||
|
content: "";
|
||||||
|
height: 100vh;
|
||||||
|
width: 100vw;
|
||||||
|
position: fixed;
|
||||||
|
background:
|
||||||
|
linear-gradient(90deg, var(--line) 1px, transparent 1px 10vmin) 0 -5vmin / 10vmin 10vmin,
|
||||||
|
linear-gradient(var(--line) 1px, transparent 1px 10vmin) 0 -5vmin / 10vmin 10vmin;
|
||||||
|
mask: linear-gradient(-15deg, transparent 50%, white);
|
||||||
|
top: 0;
|
||||||
|
z-index: -1;
|
||||||
|
transform: rotate(180deg);
|
||||||
|
}
|
||||||
|
|
||||||
.market-wrapper {
|
.market-wrapper {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
@ -25,7 +39,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
@media (max-width: 768px) {
|
@media (max-width: 768px) {
|
||||||
padding: 1rem;
|
padding: 0 1rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
.title {
|
.title {
|
||||||
@ -241,7 +255,8 @@
|
|||||||
flex-shrink: 0;
|
flex-shrink: 0;
|
||||||
margin-right: 0.25rem;
|
margin-right: 0.25rem;
|
||||||
padding: 0.125rem 0.45rem;
|
padding: 0.125rem 0.45rem;
|
||||||
background: hsl(var(--input));
|
border: 1px solid hsl(var(--text-secondary) / 0.25);
|
||||||
|
background: hsl(var(--background));
|
||||||
border-radius: 4px;
|
border-radius: 4px;
|
||||||
font-size: 12px;
|
font-size: 12px;
|
||||||
margin-bottom: 0.25rem;
|
margin-bottom: 0.25rem;
|
||||||
@ -261,6 +276,7 @@
|
|||||||
position: relative;
|
position: relative;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: max-content;
|
height: max-content;
|
||||||
|
margin-top: 1.5rem;
|
||||||
|
|
||||||
.close-action {
|
.close-action {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
@ -269,7 +285,7 @@
|
|||||||
|
|
||||||
.market-footer {
|
.market-footer {
|
||||||
margin-top: 3rem;
|
margin-top: 3rem;
|
||||||
margin-bottom: .5rem;
|
margin-bottom: 2.5rem;
|
||||||
user-select: none;
|
user-select: none;
|
||||||
padding: 0 1rem;
|
padding: 0 1rem;
|
||||||
|
|
||||||
|
@ -25,6 +25,7 @@ import {
|
|||||||
selectModelList,
|
selectModelList,
|
||||||
selectSupportModels,
|
selectSupportModels,
|
||||||
setModel,
|
setModel,
|
||||||
|
setSupportModels,
|
||||||
} from "@/store/chat.ts";
|
} from "@/store/chat.ts";
|
||||||
import { Button } from "@/components/ui/button.tsx";
|
import { Button } from "@/components/ui/button.tsx";
|
||||||
import { levelSelector } from "@/store/subscription.ts";
|
import { levelSelector } from "@/store/subscription.ts";
|
||||||
@ -59,6 +60,7 @@ import {
|
|||||||
timesBilling,
|
timesBilling,
|
||||||
tokenBilling,
|
tokenBilling,
|
||||||
} from "@/admin/charge.ts";
|
} from "@/admin/charge.ts";
|
||||||
|
import { ScrollArea } from "@/components/ui/scroll-area.tsx";
|
||||||
|
|
||||||
type SearchBarProps = {
|
type SearchBarProps = {
|
||||||
value: string;
|
value: string;
|
||||||
@ -290,6 +292,7 @@ function MarketPlace({ search }: MarketPlaceProps) {
|
|||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const select = useSelector(selectModel);
|
const select = useSelector(selectModel);
|
||||||
const supportModels = useSelector(selectSupportModels);
|
const supportModels = useSelector(selectSupportModels);
|
||||||
|
const dispatch = useDispatch();
|
||||||
|
|
||||||
const models = useMemo(() => {
|
const models = useMemo(() => {
|
||||||
if (search.length === 0) return supportModels;
|
if (search.length === 0) return supportModels;
|
||||||
@ -340,13 +343,13 @@ function MarketPlace({ search }: MarketPlaceProps) {
|
|||||||
const [removed] = list.splice(from, 1);
|
const [removed] = list.splice(from, 1);
|
||||||
list.splice(to, 0, removed);
|
list.splice(to, 0, removed);
|
||||||
|
|
||||||
supportModels.splice(0, supportModels.length, ...list);
|
dispatch(setSupportModels(list));
|
||||||
savePreferenceModels(supportModels);
|
savePreferenceModels(list);
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<DragDropContext onDragEnd={onDragEnd}>
|
<DragDropContext onDragEnd={onDragEnd}>
|
||||||
<Droppable droppableId={`model-market`}>
|
<Droppable droppableId={`model-market-droppable`}>
|
||||||
{(provided) => (
|
{(provided) => (
|
||||||
<div
|
<div
|
||||||
className={`model-list`}
|
className={`model-list`}
|
||||||
@ -414,14 +417,14 @@ function ModelMarket() {
|
|||||||
const [search, setSearch] = useState<string>("");
|
const [search, setSearch] = useState<string>("");
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={`model-market`}>
|
<ScrollArea className={`model-market`}>
|
||||||
<div className={`market-wrapper`}>
|
<div className={`market-wrapper`}>
|
||||||
<MarketHeader />
|
<MarketHeader />
|
||||||
<SearchBar value={search} onChange={setSearch} />
|
<SearchBar value={search} onChange={setSearch} />
|
||||||
<MarketPlace search={search} />
|
<MarketPlace search={search} />
|
||||||
<MarketFooter />
|
<MarketFooter />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</ScrollArea>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -123,7 +123,7 @@ export function useDraggableInput(
|
|||||||
const dragOver = (e: DragEvent) => {
|
const dragOver = (e: DragEvent) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
}
|
};
|
||||||
|
|
||||||
const drop = (e: DragEvent) => {
|
const drop = (e: DragEvent) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
@ -132,7 +132,7 @@ export function useDraggableInput(
|
|||||||
const files = e.dataTransfer?.files || ([] as File[]);
|
const files = e.dataTransfer?.files || ([] as File[]);
|
||||||
if (!files.length) return;
|
if (!files.length) return;
|
||||||
handleChange(Array.from(files));
|
handleChange(Array.from(files));
|
||||||
}
|
};
|
||||||
|
|
||||||
target.addEventListener("dragover", dragOver);
|
target.addEventListener("dragover", dragOver);
|
||||||
target.addEventListener("drop", drop);
|
target.addEventListener("drop", drop);
|
||||||
@ -140,7 +140,7 @@ export function useDraggableInput(
|
|||||||
return () => {
|
return () => {
|
||||||
target.removeEventListener("dragover", dragOver);
|
target.removeEventListener("dragover", dragOver);
|
||||||
target.removeEventListener("drop", drop);
|
target.removeEventListener("drop", drop);
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export function testNumberInputEvent(e: any): boolean {
|
export function testNumberInputEvent(e: any): boolean {
|
||||||
|
Loading…
Reference in New Issue
Block a user