chore
This commit is contained in:
@@ -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={() => {
|
||||
|
||||
Reference in New Issue
Block a user