diff --git a/backend-golang/download.go b/backend-golang/download.go index 501d9b6..f7f94a0 100644 --- a/backend-golang/download.go +++ b/backend-golang/download.go @@ -102,6 +102,8 @@ func (a *App) AddToDownloadList(path string, url string) { Downloading: true, Done: false, }) + } else { + a.ContinueDownload(url) } } diff --git a/frontend/src/_locales/zh-hans/main.json b/frontend/src/_locales/zh-hans/main.json index 94c6f93..18ba264 100644 --- a/frontend/src/_locales/zh-hans/main.json +++ b/frontend/src/_locales/zh-hans/main.json @@ -87,5 +87,6 @@ "Whether to use CPU to calculate the last output layer of the neural network with FP32 precision to obtain better quality.": "是否使用cpu以fp32精度计算神经网络的最后一层输出层, 以获得更好的质量", "Downloads": "下载", "Pause": "暂停", - "Continue": "继续" + "Continue": "继续", + "Check": "查看" } \ No newline at end of file diff --git a/frontend/src/pages/Configs.tsx b/frontend/src/pages/Configs.tsx index d02e96f..bd1e59e 100644 --- a/frontend/src/pages/Configs.tsx +++ b/frontend/src/pages/Configs.tsx @@ -203,7 +203,7 @@ export const Configs: FC = observer(() => { toast(t('Start Converting'), {autoClose: 1000, type: 'info'}); ConvertModel(modelPath, strategy, newModelPath).then(() => { toast(`${t('Convert Success')} - ${newModelPath}`, {type: 'success'}); - refreshLocalModels({models: commonStore.modelSourceList}); + refreshLocalModels({models: commonStore.modelSourceList}, false); }).catch(e => { toast(`${t('Convert Failed')} - ${e}`, {type: 'error'}); }); diff --git a/frontend/src/pages/Downloads.tsx b/frontend/src/pages/Downloads.tsx index d9d7bd7..2cd9449 100644 --- a/frontend/src/pages/Downloads.tsx +++ b/frontend/src/pages/Downloads.tsx @@ -1,24 +1,28 @@ -import React, {FC} from 'react'; +import React, {FC, useEffect} from 'react'; import {useTranslation} from 'react-i18next'; import {Page} from '../components/Page'; import {observer} from 'mobx-react-lite'; import commonStore from '../stores/commonStore'; import {Divider, Field, ProgressBar} from '@fluentui/react-components'; -import {bytesToGb, bytesToMb} from '../utils'; +import {bytesToGb, bytesToMb, refreshLocalModels} from '../utils'; import {ToolTipButton} from '../components/ToolTipButton'; import {Folder20Regular, Pause20Regular, Play20Regular} from '@fluentui/react-icons'; import {ContinueDownload, OpenFileFolder, PauseDownload} from '../../wailsjs/go/backend_golang/App'; export const Downloads: FC = observer(() => { const {t} = useTranslation(); + const finishedDownloads = commonStore.downloadList.filter((status) => status.done).length; + useEffect(() => { + refreshLocalModels({models: commonStore.modelSourceList}, false); + console.log('finishedDownloads:', finishedDownloads); + }, [finishedDownloads]); return ( {commonStore.downloadList.map((status, index) => ( -
+
[] = [ createTableColumn({ @@ -113,7 +113,7 @@ const columns: TableColumnDefinition[] = [ createTableColumn({ columnId: 'actions', compare: (a, b) => { - return a.isDownloading ? 0 : a.isLocal ? -1 : 1; + return a.isLocal ? -1 : 1; }, renderHeaderCell: () => { const {t} = useTranslation(); @@ -122,6 +122,7 @@ const columns: TableColumnDefinition[] = [ }, renderCell: (item) => { const {t} = useTranslation(); + const navigate = useNavigate(); return ( @@ -134,7 +135,10 @@ const columns: TableColumnDefinition[] = [ } {item.downloadUrl && !item.isLocal && } onClick={() => { - toast(`${t('Downloading')} ${item.name}`, {type: 'info'}); + toastWithButton(`${t('Downloading')} ${item.name}`, t('Check'), () => { + navigate({pathname: '/downloads'}); + }, + {autoClose: 3000, position: 'top-center'}); AddToDownloadList(`./${manifest.localModelDir}/${item.name}`, item.downloadUrl!); }}/>} {item.url && } onClick={() => { diff --git a/frontend/src/startup.ts b/frontend/src/startup.ts index 7b79434..5c57368 100644 --- a/frontend/src/startup.ts +++ b/frontend/src/startup.ts @@ -55,5 +55,5 @@ async function initConfig() { } async function initCache() { - await refreshModels(true); + await refreshModels(false); } \ No newline at end of file diff --git a/frontend/src/stores/commonStore.ts b/frontend/src/stores/commonStore.ts index 12b8180..55016c2 100644 --- a/frontend/src/stores/commonStore.ts +++ b/frontend/src/stores/commonStore.ts @@ -19,7 +19,6 @@ export type ModelSourceItem = { url?: string; downloadUrl?: string; isLocal?: boolean; - isDownloading?: boolean; lastUpdatedMs?: number; }; diff --git a/frontend/src/utils/index.tsx b/frontend/src/utils/index.tsx index 8dc159c..fe550cf 100644 --- a/frontend/src/utils/index.tsx +++ b/frontend/src/utils/index.tsx @@ -56,8 +56,9 @@ export async function refreshBuiltInModels(readCache: boolean = false) { return cache; } -export async function refreshLocalModels(cache: Cache) { - cache.models = cache.models.filter(m => !m.isLocal); +export async function refreshLocalModels(cache: Cache, filter: boolean = true) { + if (filter) + cache.models = cache.models.filter(m => !m.isLocal); //TODO BUG cause local but in manifest files to be removed, so currently cache is disabled await ListDirFiles(manifest.localModelDir).then((data) => { cache.models.push(...data.flatMap(d => {