Improved cross-platform interaction

This commit is contained in:
josc146 2023-06-05 23:11:22 +08:00
parent 9bd9b9ecbd
commit e62fcd152a
4 changed files with 30 additions and 20 deletions

View File

@ -88,6 +88,7 @@
"Downloads": "下载", "Downloads": "下载",
"Pause": "暂停", "Pause": "暂停",
"Continue": "继续", "Continue": "继续",
"Resume": "继续",
"Check": "查看", "Check": "查看",
"Model file not found": "模型文件不存在", "Model file not found": "模型文件不存在",
"Can not find download url": "找不到下载地址", "Can not find download url": "找不到下载地址",
@ -134,9 +135,10 @@
"Advanced": "高级", "Advanced": "高级",
"Custom Python Path": "自定义Python路径", "Custom Python Path": "自定义Python路径",
"Custom Models Path": "自定义模型路径", "Custom Models Path": "自定义模型路径",
"MacOS is not supported yet, please convert manually.": "暂不支持MacOS, 请手动转换",
"Microsoft Visual C++ Redistributable is not installed, would you like to download it?": "微软VC++组件未安装, 是否下载?", "Microsoft Visual C++ Redistributable is not installed, would you like to download it?": "微软VC++组件未安装, 是否下载?",
"Path Cannot Contain Space": "路径不能包含空格", "Path Cannot Contain Space": "路径不能包含空格",
"Failed to switch model, please try starting the program with administrator privileges.": "切换模型失败, 请尝试以管理员权限启动程序", "Failed to switch model, please try starting the program with administrator privileges.": "切换模型失败, 请尝试以管理员权限启动程序",
"Current Strategy": "当前Strategy" "Current Strategy": "当前Strategy",
"MacOS is not yet supported for performing this operation, please do it manually.": "MacOS尚未支持此操作, 请手动执行",
"Linux is not yet supported for performing this operation, please do it manually.": "Linux尚未支持此操作, 请手动执行"
} }

View File

@ -142,23 +142,28 @@ export const RunButton: FC<{ onClickRun?: MouseEventHandler, iconMode?: boolean
}); });
let customCudaFile = ''; let customCudaFile = '';
if (modelConfig.modelParameters.device != 'CPU' && modelConfig.modelParameters.useCustomCuda) { if ((modelConfig.modelParameters.device === 'CUDA' || modelConfig.modelParameters.device === 'Custom')
customCudaFile = getSupportedCustomCudaFile(); && modelConfig.modelParameters.useCustomCuda) {
if (customCudaFile && commonStore.platform === 'windows') { if (commonStore.platform === 'windows') {
FileExists('./py310/Lib/site-packages/rwkv/model.py').then((exist) => { customCudaFile = getSupportedCustomCudaFile();
// defensive measure. As Python has already been launched, will only take effect the next time it runs. if (customCudaFile) {
if (!exist) CopyFile('./backend-python/wkv_cuda_utils/wkv_cuda_model.py', './py310/Lib/site-packages/rwkv/model.py'); FileExists('./py310/Lib/site-packages/rwkv/model.py').then((exist) => {
}); // defensive measure. As Python has already been launched, will only take effect the next time it runs.
await CopyFile(customCudaFile, './py310/Lib/site-packages/rwkv/wkv_cuda.pyd').catch(() => { if (!exist) CopyFile('./backend-python/wkv_cuda_utils/wkv_cuda_model.py', './py310/Lib/site-packages/rwkv/model.py');
FileExists('./py310/Lib/site-packages/rwkv/wkv_cuda.pyd').then((exist) => {
if (!exist) {
customCudaFile = '';
toast(t('Failed to copy custom cuda file'), { type: 'error' });
}
}); });
}); await CopyFile(customCudaFile, './py310/Lib/site-packages/rwkv/wkv_cuda.pyd').catch(() => {
} else FileExists('./py310/Lib/site-packages/rwkv/wkv_cuda.pyd').then((exist) => {
toast(t('Supported custom cuda file not found'), { type: 'warning' }); if (!exist) {
customCudaFile = '';
toast(t('Failed to copy custom cuda file'), { type: 'error' });
}
});
});
} else
toast(t('Supported custom cuda file not found'), { type: 'warning' });
} else {
customCudaFile = 'any';
}
} }
switchModel({ switchModel({

View File

@ -840,7 +840,10 @@ export const Configs: FC = observer(() => {
} /> } />
<ToolTipButton text={t('Convert')} desc={t('Convert model with these configs')} onClick={async () => { <ToolTipButton text={t('Convert')} desc={t('Convert model with these configs')} onClick={async () => {
if (commonStore.platform == 'darwin') { if (commonStore.platform == 'darwin') {
toast(t('MacOS is not supported yet, please convert manually.'), { type: 'info' }); toast(t('MacOS is not yet supported for performing this operation, please do it manually.'), { type: 'info' });
return;
} else if (commonStore.platform == 'linux') {
toast(t('Linux is not yet supported for performing this operation, please do it manually.'), { type: 'info' });
return; return;
} }

View File

@ -53,7 +53,7 @@ export const Downloads: FC = observer(() => {
<div className="flex items-center gap-2"> <div className="flex items-center gap-2">
<ProgressBar className="grow" value={status.progress} max={100} /> <ProgressBar className="grow" value={status.progress} max={100} />
{!status.done && {!status.done &&
<ToolTipButton desc={status.downloading ? t('Pause') : t('Continue')} <ToolTipButton desc={status.downloading ? t('Pause') : t('Resume')}
icon={status.downloading ? <Pause20Regular /> : <Play20Regular />} icon={status.downloading ? <Pause20Regular /> : <Play20Regular />}
onClick={() => { onClick={() => {
if (status.downloading) if (status.downloading)