improve interaction and avoid user mistakes

This commit is contained in:
josc146 2023-05-24 09:17:49 +08:00
parent cc06669b3e
commit cf55c4578b
2 changed files with 17 additions and 3 deletions

View File

@ -101,5 +101,6 @@
"Use Custom CUDA kernel to Accelerate": "使用自定义CUDA算子加速", "Use Custom CUDA kernel to Accelerate": "使用自定义CUDA算子加速",
"Enabling this option can greatly improve inference speed, but there may be compatibility issues. If it fails to start, please turn off this option.": "开启这个选项能大大提升推理速度,但可能存在兼容性问题,如果启动失败,请关闭此选项", "Enabling this option can greatly improve inference speed, but there may be compatibility issues. If it fails to start, please turn off this option.": "开启这个选项能大大提升推理速度,但可能存在兼容性问题,如果启动失败,请关闭此选项",
"Supported custom cuda file not found": "没有找到支持的自定义cuda文件", "Supported custom cuda file not found": "没有找到支持的自定义cuda文件",
"Failed to copy custom cuda file": "自定义cuda文件复制失败" "Failed to copy custom cuda file": "自定义cuda文件复制失败",
"Downloading update, please wait. If it is not completed, please manually download the program from GitHub and replace the original program.": "正在下载更新请等待。如果一直未完成请从Github手动下载并覆盖原程序"
} }

View File

@ -225,6 +225,11 @@ export async function checkUpdate(notifyEvenLatest: boolean = false) {
`https://gitee.com/josc146/RWKV-Runner/releases/download/${versionTag}/RWKV-Runner_windows_x64.exe`; `https://gitee.com/josc146/RWKV-Runner/releases/download/${versionTag}/RWKV-Runner_windows_x64.exe`;
toastWithButton(t('New Version Available') + ': ' + versionTag, t('Update'), () => { toastWithButton(t('New Version Available') + ': ' + versionTag, t('Update'), () => {
deleteDynamicProgramFiles(); deleteDynamicProgramFiles();
toast(t('Downloading update, please wait. If it is not completed, please manually download the program from GitHub and replace the original program.'), {
type: 'info',
position: 'bottom-left',
autoClose: 6000
});
setTimeout(() => { setTimeout(() => {
UpdateApp(updateUrl).catch((e) => { UpdateApp(updateUrl).catch((e) => {
toast(t('Update Error, Please restart this program') + ' - ' + e.message || e, { toast(t('Update Error, Please restart this program') + ' - ' + e.message || e, {
@ -258,15 +263,23 @@ export async function checkUpdate(notifyEvenLatest: boolean = false) {
} }
export function toastWithButton(text: string, buttonText: string, onClickButton: () => void, options?: ToastOptions) { export function toastWithButton(text: string, buttonText: string, onClickButton: () => void, options?: ToastOptions) {
return toast( let triggered = false;
const id = toast(
<div className="flex flex-row items-center justify-between"> <div className="flex flex-row items-center justify-between">
<div>{text}</div> <div>{text}</div>
<Button appearance="primary" onClick={onClickButton}>{buttonText}</Button> <Button appearance="primary" onClick={() => {
if (!triggered) {
triggered = true;
toast.dismiss(id);
onClickButton();
}
}}>{buttonText}</Button>
</div>, </div>,
{ {
type: 'info', type: 'info',
...options ...options
}); });
return id;
} }
export function getSupportedCustomCudaFile() { export function getSupportedCustomCudaFile() {