add cnMirror
This commit is contained in:
parent
8d730d71ba
commit
825cbd15f8
@ -34,12 +34,16 @@ func (a *App) DepCheck() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (a *App) InstallPyDep() (string, error) {
|
||||
func (a *App) InstallPyDep(cnMirror bool) (string, error) {
|
||||
python, err := GetPython()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
_, err = Cmd(python, "./backend-python/get-pip.py")
|
||||
if cnMirror {
|
||||
_, err = Cmd(python, "./backend-python/get-pip.py", "-i", "https://pypi.tuna.tsinghua.edu.cn/simple")
|
||||
} else {
|
||||
_, err = Cmd(python, "./backend-python/get-pip.py")
|
||||
}
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
@ -48,5 +52,9 @@ func (a *App) InstallPyDep() (string, error) {
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
return Cmd(python, "-m", "pip", "install", "-r", "./backend-python/requirements_versions.txt")
|
||||
if cnMirror {
|
||||
return Cmd(python, "-m", "pip", "install", "-r", "./backend-python/requirements_versions.txt", "-i", "https://pypi.tuna.tsinghua.edu.cn/simple")
|
||||
} else {
|
||||
return Cmd(python, "-m", "pip", "install", "-r", "./backend-python/requirements_versions.txt")
|
||||
}
|
||||
}
|
||||
|
@ -94,5 +94,6 @@
|
||||
"Python target not found, would you like to download it?": "没有找到目标Python, 是否下载?",
|
||||
"Python dependencies are incomplete, would you like to install them?": "Python依赖缺失, 是否安装?",
|
||||
"Install": "安装",
|
||||
"This is the latest version": "已是最新版"
|
||||
"This is the latest version": "已是最新版",
|
||||
"Use Tsinghua Pip Mirrors": "使用清华大学Pip镜像源"
|
||||
}
|
@ -52,7 +52,7 @@ export const RunButton: FC<{ onClickRun?: MouseEventHandler, iconMode?: boolean
|
||||
});
|
||||
} else if (depErrorMsg.includes('DepCheck Error')) {
|
||||
toastWithButton(t('Python dependencies are incomplete, would you like to install them?'), t('Install'), () => {
|
||||
InstallPyDep();
|
||||
InstallPyDep(commonStore.settings.cnMirror);
|
||||
});
|
||||
} else {
|
||||
toast(depErrorMsg, {type: 'error'});
|
||||
|
@ -18,6 +18,7 @@ export type SettingsType = {
|
||||
language: Language,
|
||||
darkMode: boolean
|
||||
autoUpdatesCheck: boolean
|
||||
cnMirror: boolean
|
||||
}
|
||||
|
||||
export const Settings: FC = observer(() => {
|
||||
@ -63,6 +64,17 @@ export const Settings: FC = observer(() => {
|
||||
checkUpdate(true);
|
||||
}}/>
|
||||
}/>
|
||||
{
|
||||
commonStore.settings.language === 'zh' &&
|
||||
<Labeled label={t('Use Tsinghua Pip Mirrors')} flex spaceBetween content={
|
||||
<Switch checked={commonStore.settings.cnMirror}
|
||||
onChange={(e, data) => {
|
||||
commonStore.setSettings({
|
||||
cnMirror: data.checked
|
||||
});
|
||||
}}/>
|
||||
}/>
|
||||
}
|
||||
</div>
|
||||
}/>
|
||||
);
|
||||
|
@ -48,7 +48,8 @@ class CommonStore {
|
||||
settings: SettingsType = {
|
||||
language: getUserLanguage(),
|
||||
darkMode: !isSystemLightMode(),
|
||||
autoUpdatesCheck: true
|
||||
autoUpdatesCheck: true,
|
||||
cnMirror: getUserLanguage() === 'zh'
|
||||
};
|
||||
|
||||
// about
|
||||
|
2
frontend/wailsjs/go/backend_golang/App.d.ts
vendored
2
frontend/wailsjs/go/backend_golang/App.d.ts
vendored
@ -18,7 +18,7 @@ export function FileExists(arg1:string):Promise<boolean>;
|
||||
|
||||
export function GetPlatform():Promise<string>;
|
||||
|
||||
export function InstallPyDep():Promise<string>;
|
||||
export function InstallPyDep(arg1:boolean):Promise<string>;
|
||||
|
||||
export function ListDirFiles(arg1:string):Promise<Array<backend_golang.FileInfo>>;
|
||||
|
||||
|
@ -34,8 +34,8 @@ export function GetPlatform() {
|
||||
return window['go']['backend_golang']['App']['GetPlatform']();
|
||||
}
|
||||
|
||||
export function InstallPyDep() {
|
||||
return window['go']['backend_golang']['App']['InstallPyDep']();
|
||||
export function InstallPyDep(arg1) {
|
||||
return window['go']['backend_golang']['App']['InstallPyDep'](arg1);
|
||||
}
|
||||
|
||||
export function ListDirFiles(arg1) {
|
||||
|
Loading…
Reference in New Issue
Block a user