Skip to content

Commit

Permalink
feat: update model market
Browse files Browse the repository at this point in the history
  • Loading branch information
zmh-program committed Mar 18, 2024
1 parent 9151fdf commit 5c42d33
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 14 deletions.
28 changes: 22 additions & 6 deletions app/src/assets/pages/home.less
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,26 @@
display: flex;
flex-direction: column;
width: 100%;
padding: 1rem 3.5rem;
height: max-content;
max-height: calc(100% - 56px);
padding: 0 3.5rem;
height: 100%;
overflow: auto;
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 {
width: 100%;
height: 100%;
Expand All @@ -25,7 +39,7 @@
}

@media (max-width: 768px) {
padding: 1rem;
padding: 0 1rem;
}

.title {
Expand Down Expand Up @@ -241,7 +255,8 @@
flex-shrink: 0;
margin-right: 0.25rem;
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;
font-size: 12px;
margin-bottom: 0.25rem;
Expand All @@ -261,6 +276,7 @@
position: relative;
width: 100%;
height: max-content;
margin-top: 1.5rem;

.close-action {
position: absolute;
Expand All @@ -269,7 +285,7 @@

.market-footer {
margin-top: 3rem;
margin-bottom: .5rem;
margin-bottom: 2.5rem;
user-select: none;
padding: 0 1rem;

Expand Down
13 changes: 8 additions & 5 deletions app/src/components/home/ModelMarket.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import {
selectModelList,
selectSupportModels,
setModel,
setSupportModels,
} from "@/store/chat.ts";
import { Button } from "@/components/ui/button.tsx";
import { levelSelector } from "@/store/subscription.ts";
Expand Down Expand Up @@ -59,6 +60,7 @@ import {
timesBilling,
tokenBilling,
} from "@/admin/charge.ts";
import { ScrollArea } from "@/components/ui/scroll-area.tsx";

type SearchBarProps = {
value: string;
Expand Down Expand Up @@ -290,6 +292,7 @@ function MarketPlace({ search }: MarketPlaceProps) {
const { t } = useTranslation();
const select = useSelector(selectModel);
const supportModels = useSelector(selectSupportModels);
const dispatch = useDispatch();

const models = useMemo(() => {
if (search.length === 0) return supportModels;
Expand Down Expand Up @@ -340,13 +343,13 @@ function MarketPlace({ search }: MarketPlaceProps) {
const [removed] = list.splice(from, 1);
list.splice(to, 0, removed);

supportModels.splice(0, supportModels.length, ...list);
savePreferenceModels(supportModels);
dispatch(setSupportModels(list));
savePreferenceModels(list);
};

return (
<DragDropContext onDragEnd={onDragEnd}>
<Droppable droppableId={`model-market`}>
<Droppable droppableId={`model-market-droppable`}>
{(provided) => (
<div
className={`model-list`}
Expand Down Expand Up @@ -414,14 +417,14 @@ function ModelMarket() {
const [search, setSearch] = useState<string>("");

return (
<div className={`model-market`}>
<ScrollArea className={`model-market`}>
<div className={`market-wrapper`}>
<MarketHeader />
<SearchBar value={search} onChange={setSearch} />
<MarketPlace search={search} />
<MarketFooter />
</div>
</div>
</ScrollArea>
);
}

Expand Down
6 changes: 3 additions & 3 deletions app/src/utils/dom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ export function useDraggableInput(
const dragOver = (e: DragEvent) => {
e.preventDefault();
e.stopPropagation();
}
};

const drop = (e: DragEvent) => {
e.preventDefault();
Expand All @@ -132,15 +132,15 @@ export function useDraggableInput(
const files = e.dataTransfer?.files || ([] as File[]);
if (!files.length) return;
handleChange(Array.from(files));
}
};

target.addEventListener("dragover", dragOver);
target.addEventListener("drop", drop);

return () => {
target.removeEventListener("dragover", dragOver);
target.removeEventListener("drop", drop);
}
};
}

export function testNumberInputEvent(e: any): boolean {
Expand Down

0 comments on commit 5c42d33

Please sign in to comment.