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

@@ -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`;
toastWithButton(t('New Version Available') + ': ' + versionTag, t('Update'), () => {
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(() => {
UpdateApp(updateUrl).catch((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) {
return toast(
let triggered = false;
const id = toast(
<div className="flex flex-row items-center justify-between">
<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>,
{
type: 'info',
...options
});
return id;
}
export function getSupportedCustomCudaFile() {