chore
This commit is contained in:
parent
0f0281dd63
commit
361d7a5619
@ -102,6 +102,8 @@ func (a *App) AddToDownloadList(path string, url string) {
|
||||
Downloading: true,
|
||||
Done: false,
|
||||
})
|
||||
} else {
|
||||
a.ContinueDownload(url)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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": "查看"
|
||||
}
|
@ -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'});
|
||||
});
|
||||
|
@ -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 (
|
||||
<Page title={t('Downloads')} content={
|
||||
<div className="flex flex-col gap-2 overflow-y-auto overflow-x-hidden p-1">
|
||||
{commonStore.downloadList.map((status, index) => (
|
||||
<div className="flex flex-col gap-1">
|
||||
<div className="flex flex-col gap-1" key={index}>
|
||||
<Field
|
||||
key={index}
|
||||
label={`${status.downloading ? (t('Downloading') + ': ') : ''}${status.name}`}
|
||||
validationMessage={`${status.progress.toFixed(2)}% - ${bytesToGb(status.transferred) + 'GB'}/${bytesToGb(status.size) + 'GB'} - ${status.downloading ? bytesToMb(status.speed) : 0}MB/s - ${status.url}`}
|
||||
validationState={status.done ? 'success' : 'none'}
|
||||
|
@ -19,10 +19,10 @@ import commonStore, {ModelSourceItem} from '../stores/commonStore';
|
||||
import {BrowserOpenURL} from '../../wailsjs/runtime';
|
||||
import {AddToDownloadList, OpenFileFolder} from '../../wailsjs/go/backend_golang/App';
|
||||
import manifest from '../../../manifest.json';
|
||||
import {toast} from 'react-toastify';
|
||||
import {Page} from '../components/Page';
|
||||
import {bytesToGb, refreshModels, saveConfigs} from '../utils';
|
||||
import {bytesToGb, refreshModels, saveConfigs, toastWithButton} from '../utils';
|
||||
import {useTranslation} from 'react-i18next';
|
||||
import {useNavigate} from 'react-router';
|
||||
|
||||
const columns: TableColumnDefinition<ModelSourceItem>[] = [
|
||||
createTableColumn<ModelSourceItem>({
|
||||
@ -113,7 +113,7 @@ const columns: TableColumnDefinition<ModelSourceItem>[] = [
|
||||
createTableColumn<ModelSourceItem>({
|
||||
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<ModelSourceItem>[] = [
|
||||
},
|
||||
renderCell: (item) => {
|
||||
const {t} = useTranslation();
|
||||
const navigate = useNavigate();
|
||||
|
||||
return (
|
||||
<TableCellLayout>
|
||||
@ -134,7 +135,10 @@ const columns: TableColumnDefinition<ModelSourceItem>[] = [
|
||||
}
|
||||
{item.downloadUrl && !item.isLocal &&
|
||||
<ToolTipButton desc={t('Download')} icon={<ArrowDownload20Regular/>} 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 && <ToolTipButton desc={t('Open Url')} icon={<Open20Regular/>} onClick={() => {
|
||||
|
@ -55,5 +55,5 @@ async function initConfig() {
|
||||
}
|
||||
|
||||
async function initCache() {
|
||||
await refreshModels(true);
|
||||
await refreshModels(false);
|
||||
}
|
@ -19,7 +19,6 @@ export type ModelSourceItem = {
|
||||
url?: string;
|
||||
downloadUrl?: string;
|
||||
isLocal?: boolean;
|
||||
isDownloading?: boolean;
|
||||
lastUpdatedMs?: number;
|
||||
};
|
||||
|
||||
|
@ -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 => {
|
||||
|
Loading…
x
Reference in New Issue
Block a user