From 29bdb3619196c2dd75771663d86b7584cf3604f1 Mon Sep 17 00:00:00 2001 From: josc146 Date: Mon, 15 May 2023 22:51:52 +0800 Subject: [PATCH] update --- frontend/src/pages/Configs.tsx | 23 +++++++++++++++++------ frontend/src/startup.ts | 18 +++++++++++------- frontend/src/stores/commonStore.ts | 2 ++ frontend/src/style.css | 1 + 4 files changed, 31 insertions(+), 13 deletions(-) diff --git a/frontend/src/pages/Configs.tsx b/frontend/src/pages/Configs.tsx index e40b3b7..63c721c 100644 --- a/frontend/src/pages/Configs.tsx +++ b/frontend/src/pages/Configs.tsx @@ -1,4 +1,4 @@ -import {Button, Dropdown, Input, Label, Option, Slider, Switch} from '@fluentui/react-components'; +import {Button, Dropdown, Input, Label, Option, Select, Slider, Switch} from '@fluentui/react-components'; import {AddCircle20Regular, DataUsageSettings20Regular, Delete20Regular, Save20Regular} from '@fluentui/react-icons'; import React, {FC} from 'react'; import {Section} from '../components/Section'; @@ -10,11 +10,14 @@ import {toast} from 'react-toastify'; import {ValuedSlider} from '../components/ValuedSlider'; import {NumberInput} from '../components/NumberInput'; import {Page} from '../components/Page'; +import {useNavigate} from 'react-router'; export const Configs: FC = observer(() => { const [selectedIndex, setSelectedIndex] = React.useState(commonStore.currentModelConfigIndex); const [selectedConfig, setSelectedConfig] = React.useState(commonStore.modelConfigs[selectedIndex]); + const navigate = useNavigate(); + const updateSelectedIndex = (newIndex: number) => { setSelectedIndex(newIndex); setSelectedConfig(commonStore.modelConfigs[newIndex]); @@ -143,19 +146,27 @@ export const Configs: FC = observer(() => {
- + + } onClick={() => { + navigate({pathname: '/models'}); + }}/>
}/> - + }/> { }); cache.models = cache.models.filter((model, index, self) => { - return model.name.endsWith('.pth') && index === self.findIndex(m => m.SHA256 === model.SHA256 && m.size === model.size); + return model.name.endsWith('.pth') + && index === self.findIndex( + m => m.name === model.name || (m.SHA256 === model.SHA256 && m.size === model.size)); }); // remote files commonStore.setModelSourceList(cache.models); diff --git a/frontend/src/stores/commonStore.ts b/frontend/src/stores/commonStore.ts index c6d4787..7ea3a3b 100644 --- a/frontend/src/stores/commonStore.ts +++ b/frontend/src/stores/commonStore.ts @@ -31,6 +31,7 @@ export type ApiParameters = { } export type ModelParameters = { + // different models can not have the same name modelName: string; device: string; precision: string; @@ -39,6 +40,7 @@ export type ModelParameters = { } export type ModelConfig = { + // different configs can have the same name name: string; apiParameters: ApiParameters modelParameters: ModelParameters diff --git a/frontend/src/style.css b/frontend/src/style.css index adbbda1..18cff36 100644 --- a/frontend/src/style.css +++ b/frontend/src/style.css @@ -5,6 +5,7 @@ body { margin: 0; overflow: hidden; + width: 100%; height: 100%; }