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 { 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);

View File

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

View File

@ -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);

View File

@ -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[]) => {

View File

@ -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
};