From d019d0d22372a6693fd37508067512da76e93bfe Mon Sep 17 00:00:00 2001 From: gfdgd_xi <3025613752@qq.com> Date: Sun, 26 Nov 2023 08:58:34 +0800 Subject: [PATCH] =?UTF-8?q?=E5=9B=BD=E5=A4=96IP=E5=88=A4=E6=96=AD=E4=BB=A5?= =?UTF-8?q?=E5=AE=9E=E7=8E=B0=E8=87=AA=E5=8A=A8=E9=80=89=E6=8B=A9=E5=90=88?= =?UTF-8?q?=E9=80=82=E6=BA=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- wine/installwine | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/wine/installwine b/wine/installwine index bbcc43c..341923f 100755 --- a/wine/installwine +++ b/wine/installwine @@ -364,12 +364,12 @@ if __name__ == "__main__": internetJsonList = [] internetWineSourceList = [ "http://wine.wine-runner.gfdgdxi.top/", - "https://github.com/gfdgd-xi/wine-mirrors-websize/raw/master/sourceforge", + "http://wine.wine-runner.gfdgdxi.top/sourceforge", "https://gitee.com/gfdgd-xi/wine-mirrors-websize/raw/master/", "https://github.com/gfdgd-xi/wine-mirrors-websize/raw/master/", "http://127.0.0.1/wine-mirrors/" # 本地测试源 ] - internetWineSource = internetWineSourceList[0] + app = QtWidgets.QApplication(sys.argv) # 读取翻译 if not get_now_lang() == "zh_CN.UTF-8": @@ -382,6 +382,22 @@ if __name__ == "__main__": window.setWindowIcon(QtGui.QIcon(f"{programPath}/../deepin-wine-runner.svg")) ui.setupUi(window) window.show() + # 判断机器所在国家并自动分配源 + try: + isChina = requests.get("https://ip.useragentinfo.com/json").json()["country"] == "中国" + print("IsChina", isChina) + if isChina: + internetWineSource = internetWineSourceList[0] + ui.ipv6Action.setChecked(True) + else: + internetWineSource = internetWineSourceList[1] + ui.kgithubAction.setChecked(True) + except: + traceback.print_exc() + print("IsChina", False) + # 请求失败,默认使用国际源 + internetWineSource = internetWineSourceList[1] + ui.kgithubAction.setChecked(True) # 连接信号 ui.addButton.clicked.connect(on_addButton_clicked) ui.delButton.clicked.connect(on_delButton_clicked)