From 87ca694b0bf67d01c2f7fd2eb0521cf91495c770 Mon Sep 17 00:00:00 2001 From: josc146 Date: Thu, 29 Jun 2023 20:14:52 +0800 Subject: [PATCH] chore --- frontend/src/components/RunButton.tsx | 3 +-- frontend/src/pages/Settings.tsx | 1 + frontend/src/startup.ts | 4 ++-- frontend/src/stores/commonStore.ts | 6 ++++-- frontend/src/utils/index.tsx | 2 ++ 5 files changed, 10 insertions(+), 6 deletions(-) diff --git a/frontend/src/components/RunButton.tsx b/frontend/src/components/RunButton.tsx index 0adb57a..ed8fc84 100644 --- a/frontend/src/components/RunButton.tsx +++ b/frontend/src/components/RunButton.tsx @@ -12,7 +12,7 @@ import { Button } from '@fluentui/react-components'; import { observer } from 'mobx-react-lite'; import { exit, getStatus, readRoot, switchModel, updateConfig } from '../apis'; import { toast } from 'react-toastify'; -import { getStrategy, getSupportedCustomCudaFile, saveCache, toastWithButton } from '../utils'; +import { getStrategy, getSupportedCustomCudaFile, toastWithButton } from '../utils'; import { useTranslation } from 'react-i18next'; import { ToolTipButton } from './ToolTipButton'; import { Play16Regular, Stop16Regular } from '@fluentui/react-icons'; @@ -102,7 +102,6 @@ export const RunButton: FC<{ onClickRun?: MouseEventHandler, iconMode?: boolean commonStore.setDepComplete(true); if (commonStore.platform === 'windows') CopyFile('./backend-python/wkv_cuda_utils/wkv_cuda_model.py', './py310/Lib/site-packages/rwkv/model.py'); - saveCache(); } const currentModelSource = commonStore.modelSourceList.find(item => item.name === modelName); diff --git a/frontend/src/pages/Settings.tsx b/frontend/src/pages/Settings.tsx index b6ad520..3a4f196 100644 --- a/frontend/src/pages/Settings.tsx +++ b/frontend/src/pages/Settings.tsx @@ -166,6 +166,7 @@ export const Settings: FC = observer(() => { content={ { + commonStore.setDepComplete(false); commonStore.setSettings({ customPythonPath: data.value }); diff --git a/frontend/src/startup.ts b/frontend/src/startup.ts index cee3e26..9fe7ead 100644 --- a/frontend/src/startup.ts +++ b/frontend/src/startup.ts @@ -63,8 +63,8 @@ async function initConfig() { async function initCache(initUnfinishedModels: boolean) { await ReadJson('cache.json').then((cacheData: Cache) => { - if (cacheData.depComplete) - commonStore.setDepComplete(cacheData.depComplete); + if (cacheData.version === manifest.version && cacheData.depComplete) + commonStore.setDepComplete(cacheData.depComplete, false); }).catch(() => { }); await refreshModels(false, initUnfinishedModels); diff --git a/frontend/src/stores/commonStore.ts b/frontend/src/stores/commonStore.ts index a474e5d..30b17fc 100644 --- a/frontend/src/stores/commonStore.ts +++ b/frontend/src/stores/commonStore.ts @@ -1,5 +1,5 @@ import { makeAutoObservable } from 'mobx'; -import { getUserLanguage, isSystemLightMode, saveConfigs, savePresets } from '../utils'; +import { getUserLanguage, isSystemLightMode, saveCache, saveConfigs, savePresets } from '../utils'; import { WindowSetDarkTheme, WindowSetLightTheme } from '../../wailsjs/runtime'; import manifest from '../../../manifest.json'; import { ModelConfig } from '../pages/Configs'; @@ -169,8 +169,10 @@ class CommonStore { this.about = value; }; - setDepComplete = (value: boolean) => { + setDepComplete = (value: boolean, inSaveCache: boolean = true) => { this.depComplete = value; + if (inSaveCache) + saveCache(); }; setDownloadList = (value: DownloadStatus[]) => { diff --git a/frontend/src/utils/index.tsx b/frontend/src/utils/index.tsx index 6f45bdd..700d4fc 100644 --- a/frontend/src/utils/index.tsx +++ b/frontend/src/utils/index.tsx @@ -19,6 +19,7 @@ import { ModelConfig, ModelParameters } from '../pages/Configs'; import { DownloadStatus } from '../pages/Downloads'; export type Cache = { + version: string models: ModelSourceItem[] depComplete: boolean } @@ -200,6 +201,7 @@ export const saveConfigs = async () => { export const saveCache = async () => { const data: Cache = { + version: manifest.version, models: commonStore.modelSourceList, depComplete: commonStore.depComplete };