add giteeUpdatesSource

This commit is contained in:
josc146 2023-05-22 00:04:18 +08:00
parent b2960052d9
commit c98c32f2f6
4 changed files with 119 additions and 100 deletions

View File

@ -96,5 +96,6 @@
"Install": "安装",
"This is the latest version": "已是最新版",
"Use Tsinghua Pip Mirrors": "使用清华大学Pip镜像源",
"Model Config Exception": "模型配置异常"
"Model Config Exception": "模型配置异常",
"Use Gitee Updates Source": "使用Gitee更新源"
}

View File

@ -18,6 +18,7 @@ export type SettingsType = {
language: Language,
darkMode: boolean
autoUpdatesCheck: boolean
giteeUpdatesSource: boolean
cnMirror: boolean
}
@ -64,6 +65,17 @@ export const Settings: FC = observer(() => {
checkUpdate(true);
}} />
} />
{
commonStore.settings.language === 'zh' &&
<Labeled label={t('Use Gitee Updates Source')} flex spaceBetween content={
<Switch checked={commonStore.settings.giteeUpdatesSource}
onChange={(e, data) => {
commonStore.setSettings({
giteeUpdatesSource: data.checked
});
}} />
} />
}
{
commonStore.settings.language === 'zh' &&
<Labeled label={t('Use Tsinghua Pip Mirrors')} flex spaceBetween content={

View File

@ -50,6 +50,7 @@ class CommonStore {
language: getUserLanguage(),
darkMode: !isSystemLightMode(),
autoUpdatesCheck: true,
giteeUpdatesSource: getUserLanguage() === 'zh',
cnMirror: getUserLanguage() === 'zh'
};

View File

@ -210,13 +210,18 @@ export function bytesToKb(size: number) {
export async function checkUpdate(notifyEvenLatest: boolean = false) {
let updateUrl = '';
await fetch('https://api.github.com/repos/josstorer/RWKV-Runner/releases/latest').then((r) => {
await fetch(!commonStore.settings.giteeUpdatesSource ?
'https://api.github.com/repos/josstorer/RWKV-Runner/releases/latest' :
'https://gitee.com/api/v5/repos/josc146/RWKV-Runner/releases/latest'
).then((r) => {
if (r.ok) {
r.json().then((data) => {
if (data.tag_name) {
const versionTag = data.tag_name;
if (versionTag.replace('v', '') > manifest.version) {
updateUrl = `https://github.com/josStorer/RWKV-Runner/releases/download/${versionTag}/RWKV-Runner_windows_x64.exe`;
updateUrl = !commonStore.settings.giteeUpdatesSource ?
`https://github.com/josStorer/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'), () => {
deletePythonProgramFiles();
setTimeout(() => {