This commit is contained in:
josc146 2023-06-29 20:14:52 +08:00
parent 417389c5f6
commit 87ca694b0b
5 changed files with 10 additions and 6 deletions

View File

@ -12,7 +12,7 @@ import { Button } from '@fluentui/react-components';
import { observer } from 'mobx-react-lite'; import { observer } from 'mobx-react-lite';
import { exit, getStatus, readRoot, switchModel, updateConfig } from '../apis'; import { exit, getStatus, readRoot, switchModel, updateConfig } from '../apis';
import { toast } from 'react-toastify'; import { toast } from 'react-toastify';
import { getStrategy, getSupportedCustomCudaFile, saveCache, toastWithButton } from '../utils'; import { getStrategy, getSupportedCustomCudaFile, toastWithButton } from '../utils';
import { useTranslation } from 'react-i18next'; import { useTranslation } from 'react-i18next';
import { ToolTipButton } from './ToolTipButton'; import { ToolTipButton } from './ToolTipButton';
import { Play16Regular, Stop16Regular } from '@fluentui/react-icons'; import { Play16Regular, Stop16Regular } from '@fluentui/react-icons';
@ -102,7 +102,6 @@ export const RunButton: FC<{ onClickRun?: MouseEventHandler, iconMode?: boolean
commonStore.setDepComplete(true); commonStore.setDepComplete(true);
if (commonStore.platform === 'windows') if (commonStore.platform === 'windows')
CopyFile('./backend-python/wkv_cuda_utils/wkv_cuda_model.py', './py310/Lib/site-packages/rwkv/model.py'); 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); const currentModelSource = commonStore.modelSourceList.find(item => item.name === modelName);

View File

@ -166,6 +166,7 @@ export const Settings: FC = observer(() => {
content={ content={
<Input className="grow" placeholder="./py310/python" value={commonStore.settings.customPythonPath} <Input className="grow" placeholder="./py310/python" value={commonStore.settings.customPythonPath}
onChange={(e, data) => { onChange={(e, data) => {
commonStore.setDepComplete(false);
commonStore.setSettings({ commonStore.setSettings({
customPythonPath: data.value customPythonPath: data.value
}); });

View File

@ -63,8 +63,8 @@ async function initConfig() {
async function initCache(initUnfinishedModels: boolean) { async function initCache(initUnfinishedModels: boolean) {
await ReadJson('cache.json').then((cacheData: Cache) => { await ReadJson('cache.json').then((cacheData: Cache) => {
if (cacheData.depComplete) if (cacheData.version === manifest.version && cacheData.depComplete)
commonStore.setDepComplete(cacheData.depComplete); commonStore.setDepComplete(cacheData.depComplete, false);
}).catch(() => { }).catch(() => {
}); });
await refreshModels(false, initUnfinishedModels); await refreshModels(false, initUnfinishedModels);

View File

@ -1,5 +1,5 @@
import { makeAutoObservable } from 'mobx'; 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 { WindowSetDarkTheme, WindowSetLightTheme } from '../../wailsjs/runtime';
import manifest from '../../../manifest.json'; import manifest from '../../../manifest.json';
import { ModelConfig } from '../pages/Configs'; import { ModelConfig } from '../pages/Configs';
@ -169,8 +169,10 @@ class CommonStore {
this.about = value; this.about = value;
}; };
setDepComplete = (value: boolean) => { setDepComplete = (value: boolean, inSaveCache: boolean = true) => {
this.depComplete = value; this.depComplete = value;
if (inSaveCache)
saveCache();
}; };
setDownloadList = (value: DownloadStatus[]) => { setDownloadList = (value: DownloadStatus[]) => {

View File

@ -19,6 +19,7 @@ import { ModelConfig, ModelParameters } from '../pages/Configs';
import { DownloadStatus } from '../pages/Downloads'; import { DownloadStatus } from '../pages/Downloads';
export type Cache = { export type Cache = {
version: string
models: ModelSourceItem[] models: ModelSourceItem[]
depComplete: boolean depComplete: boolean
} }
@ -200,6 +201,7 @@ export const saveConfigs = async () => {
export const saveCache = async () => { export const saveCache = async () => {
const data: Cache = { const data: Cache = {
version: manifest.version,
models: commonStore.modelSourceList, models: commonStore.modelSourceList,
depComplete: commonStore.depComplete depComplete: commonStore.depComplete
}; };