update
This commit is contained in:
parent
18db41fd76
commit
de7d6b3417
@ -39,12 +39,9 @@ func (a *App) ReadJson(fileName string) (any, error) {
|
|||||||
return data, nil
|
return data, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *App) FileExists(fileName string) (bool, error) {
|
func (a *App) FileExists(fileName string) bool {
|
||||||
_, err := os.Stat(fileName)
|
_, err := os.Stat(fileName)
|
||||||
if err == nil {
|
return err == nil
|
||||||
return true, nil
|
|
||||||
}
|
|
||||||
return false, err
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type FileInfo struct {
|
type FileInfo struct {
|
||||||
|
@ -59,5 +59,6 @@
|
|||||||
"Failed to switch model": "切换模型失败",
|
"Failed to switch model": "切换模型失败",
|
||||||
"Start Converting": "开始转换",
|
"Start Converting": "开始转换",
|
||||||
"Convert Success": "转换成功",
|
"Convert Success": "转换成功",
|
||||||
"Convert Failed": "转换失败"
|
"Convert Failed": "转换失败",
|
||||||
|
"Model Not Found": "模型不存在"
|
||||||
}
|
}
|
@ -13,7 +13,7 @@ import {Page} from '../components/Page';
|
|||||||
import {useNavigate} from 'react-router';
|
import {useNavigate} from 'react-router';
|
||||||
import {RunButton} from '../components/RunButton';
|
import {RunButton} from '../components/RunButton';
|
||||||
import {updateConfig} from '../apis';
|
import {updateConfig} from '../apis';
|
||||||
import {ConvertModel} from '../../wailsjs/go/backend_golang/App';
|
import {ConvertModel, FileExists} from '../../wailsjs/go/backend_golang/App';
|
||||||
import manifest from '../../../manifest.json';
|
import manifest from '../../../manifest.json';
|
||||||
import {getStrategy, refreshLocalModels} from '../utils';
|
import {getStrategy, refreshLocalModels} from '../utils';
|
||||||
import {useTranslation} from 'react-i18next';
|
import {useTranslation} from 'react-i18next';
|
||||||
@ -178,17 +178,21 @@ export const Configs: FC = observer(() => {
|
|||||||
}}/>
|
}}/>
|
||||||
</div>
|
</div>
|
||||||
}/>
|
}/>
|
||||||
<ToolTipButton text={t('Convert')} desc={t('Convert model with these configs')} onClick={() => {
|
<ToolTipButton text={t('Convert')} desc={t('Convert model with these configs')} onClick={async () => {
|
||||||
const modelPath = `${manifest.localModelDir}/${selectedConfig.modelParameters.modelName}`;
|
const modelPath = `${manifest.localModelDir}/${selectedConfig.modelParameters.modelName}`;
|
||||||
const strategy = getStrategy(selectedConfig);
|
if (await FileExists(modelPath)) {
|
||||||
const newModelPath = modelPath + '-' + strategy.replace(/[> *+]/g, '-');
|
const strategy = getStrategy(selectedConfig);
|
||||||
toast(t('Start Converting'), {autoClose: 1000, type: 'info'});
|
const newModelPath = modelPath + '-' + strategy.replace(/[> *+]/g, '-');
|
||||||
ConvertModel(modelPath, strategy, newModelPath).then(() => {
|
toast(t('Start Converting'), {autoClose: 1000, type: 'info'});
|
||||||
toast(`${t('Convert Success')} - ${newModelPath}`, {type: 'success'});
|
ConvertModel(modelPath, strategy, newModelPath).then(() => {
|
||||||
refreshLocalModels({models: commonStore.modelSourceList});
|
toast(`${t('Convert Success')} - ${newModelPath}`, {type: 'success'});
|
||||||
}).catch(e => {
|
refreshLocalModels({models: commonStore.modelSourceList});
|
||||||
toast(`${t('Convert Failed')} - ${e}`, {type: 'error'});
|
}).catch(e => {
|
||||||
});
|
toast(`${t('Convert Failed')} - ${e}`, {type: 'error'});
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
toast(`${t('Model Not Found')} - ${modelPath}`, {type: 'error'});
|
||||||
|
}
|
||||||
}}/>
|
}}/>
|
||||||
<Labeled label={t('Device')} content={
|
<Labeled label={t('Device')} content={
|
||||||
<Dropdown style={{minWidth: 0}} className="grow" value={selectedConfig.modelParameters.device}
|
<Dropdown style={{minWidth: 0}} className="grow" value={selectedConfig.modelParameters.device}
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
import commonStore, {defaultModelConfigs} from './stores/commonStore';
|
import commonStore, {defaultModelConfigs} from './stores/commonStore';
|
||||||
import {ReadJson} from '../wailsjs/go/backend_golang/App';
|
import {ReadJson} from '../wailsjs/go/backend_golang/App';
|
||||||
import {LocalConfig, refreshModels} from './utils';
|
import {downloadProgramFiles, LocalConfig, refreshModels} from './utils';
|
||||||
|
|
||||||
export async function startup() {
|
export async function startup() {
|
||||||
|
downloadProgramFiles();
|
||||||
initCache();
|
initCache();
|
||||||
await initConfig();
|
await initConfig();
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import {ListDirFiles, ReadJson, SaveJson} from '../../wailsjs/go/backend_golang/App';
|
import {DownloadFile, FileExists, ListDirFiles, ReadJson, SaveJson} from '../../wailsjs/go/backend_golang/App';
|
||||||
import manifest from '../../../manifest.json';
|
import manifest from '../../../manifest.json';
|
||||||
import commonStore, {ModelConfig, ModelParameters, ModelSourceItem} from '../stores/commonStore';
|
import commonStore, {ModelConfig, ModelParameters, ModelSourceItem} from '../stores/commonStore';
|
||||||
|
|
||||||
@ -161,3 +161,18 @@ export function getUserLanguage(): Language {
|
|||||||
export function isSystemLightMode() {
|
export function isSystemLightMode() {
|
||||||
return window.matchMedia && window.matchMedia('(prefers-color-scheme: light)').matches;
|
return window.matchMedia && window.matchMedia('(prefers-color-scheme: light)').matches;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function downloadProgramFiles() {
|
||||||
|
manifest.programFiles.forEach(({url, path}) => {
|
||||||
|
FileExists(path).then(exists => {
|
||||||
|
if (!exists)
|
||||||
|
DownloadFile(path, url);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
export function forceDownloadProgramFiles() {
|
||||||
|
manifest.programFiles.forEach(({url, path}) => {
|
||||||
|
DownloadFile(path, url);
|
||||||
|
});
|
||||||
|
}
|
@ -3,7 +3,7 @@
|
|||||||
"localModelDir": "models",
|
"localModelDir": "models",
|
||||||
"programFiles": [
|
"programFiles": [
|
||||||
{
|
{
|
||||||
"url": "https://cdn.jsdelivr.net/gh/josstorer/RWKV-Runner/cmd-helper.bat",
|
"url": "https://raw.githubusercontent.com/josStorer/RWKV-Runner/master/cmd-helper.bat",
|
||||||
"path": "cmd-helper.bat"
|
"path": "cmd-helper.bat"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user