toastWithButton

This commit is contained in:
josc146 2023-05-20 10:31:20 +08:00
parent c5b3246154
commit c03e16415f
2 changed files with 32 additions and 3 deletions

View File

@ -71,5 +71,7 @@
"Copy": "复制", "Copy": "复制",
"Read Aloud": "朗读", "Read Aloud": "朗读",
"Hello! I'm RWKV, an open-source and commercially available large language model.": "你好! 我是RWKV, 一个开源可商用的大语言模型.", "Hello! I'm RWKV, an open-source and commercially available large language model.": "你好! 我是RWKV, 一个开源可商用的大语言模型.",
"This tools API is compatible with OpenAI API. It can be used with any ChatGPT tool you like. Go to the settings of some ChatGPT tool, replace the 'https://api.openai.com' part in the API address with '": "本工具的API与OpenAI API兼容. 因此可以配合任意你喜欢的ChatGPT工具使用. 打开某个ChatGPT工具的设置, 将API地址中的'https://api.openai.com'部分替换为'" "This tools API is compatible with OpenAI API. It can be used with any ChatGPT tool you like. Go to the settings of some ChatGPT tool, replace the 'https://api.openai.com' part in the API address with '": "本工具的API与OpenAI API兼容. 因此可以配合任意你喜欢的ChatGPT工具使用. 打开某个ChatGPT工具的设置, 将API地址中的'https://api.openai.com'部分替换为'",
"New Version Available": "新版本可用",
"Update": "更新"
} }

View File

@ -1,8 +1,17 @@
import {DownloadFile, FileExists, ListDirFiles, ReadJson, SaveJson} from '../../wailsjs/go/backend_golang/App'; import {
DownloadFile,
FileExists,
ListDirFiles,
ReadJson,
SaveJson,
UpdateApp
} 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';
import {toast} from 'react-toastify'; import {toast} from 'react-toastify';
import {t} from 'i18next'; import {t} from 'i18next';
import {ToastOptions} from 'react-toastify/dist/types';
import {Button} from '@fluentui/react-components';
export const Languages = { export const Languages = {
dev: 'English', // i18n default dev: 'English', // i18n default
@ -186,8 +195,12 @@ export async function checkUpdate() {
r.json().then((data) => { r.json().then((data) => {
if (data.tag_name) { if (data.tag_name) {
const versionTag = data.tag_name; const versionTag = data.tag_name;
if (versionTag.replace('v', '') > manifest.version) if (versionTag.replace('v', '') > manifest.version) {
updateUrl = `https://github.com/josStorer/RWKV-Runner/releases/download/${versionTag}/RWKV-Runner_windows_x64.exe`; updateUrl = `https://github.com/josStorer/RWKV-Runner/releases/download/${versionTag}/RWKV-Runner_windows_x64.exe`;
toastWithButton(t('New Version Available') + ': ' + versionTag, t('Update'), () => {
UpdateApp(updateUrl);
});
}
} else { } else {
throw new Error('Invalid response.'); throw new Error('Invalid response.');
} }
@ -200,4 +213,18 @@ export async function checkUpdate() {
toast(t('Updates Check Error') + ' - ' + e.message, {type: 'error', position: 'bottom-left'}); toast(t('Updates Check Error') + ' - ' + e.message, {type: 'error', position: 'bottom-left'});
}); });
return updateUrl; return updateUrl;
}
export function toastWithButton(text: string, buttonText: string, onClickButton: () => void, options?: ToastOptions) {
return toast(
<div className="flex flex-row items-center justify-between">
<div>{text}</div>
<Button appearance="primary" onClick={onClickButton}>{buttonText}</Button>
</div>,
{
autoClose: false,
position: 'bottom-left',
type: 'info',
...options
});
} }