diff --git a/py/LunaTranslator/gui/showword.py b/py/LunaTranslator/gui/showword.py index d18140e0..c744b6d4 100644 --- a/py/LunaTranslator/gui/showword.py +++ b/py/LunaTranslator/gui/showword.py @@ -768,6 +768,7 @@ class AnkiWindow(QWidget): autoUpdateModel = globalconfig["ankiconnect"]["autoUpdateModel"] allowDuplicate = globalconfig["ankiconnect"]["allowDuplicate"] anki.global_port = globalconfig["ankiconnect"]["port"] + anki.global_host = globalconfig["ankiconnect"]["host"] ModelName = globalconfig["ankiconnect"]["ModelName6"] try: DeckName = globalconfig["ankiconnect"]["DeckNameS"][ diff --git a/py/LunaTranslator/myutils/ankiconnect.py b/py/LunaTranslator/myutils/ankiconnect.py index 1bc67211..d8799807 100644 --- a/py/LunaTranslator/myutils/ankiconnect.py +++ b/py/LunaTranslator/myutils/ankiconnect.py @@ -1,6 +1,7 @@ import requests global_port = 999 +global_host = "127.0.0.1" class AnkiException(Exception): @@ -13,7 +14,7 @@ class AnkiModelExists(AnkiException): def invoke(action, **params): response = requests.get( - "http://127.0.0.1:{}".format(global_port), + "http://{}:{}".format(global_host, global_port), json={"action": action, "params": params, "version": 6}, ).json() if len(response) != 2: diff --git a/py/files/defaultconfig/config.json b/py/files/defaultconfig/config.json index 7d8619e4..04a01d2c 100644 --- a/py/files/defaultconfig/config.json +++ b/py/files/defaultconfig/config.json @@ -465,6 +465,7 @@ "is_tracetime_strict": true, "jiamingcolor": "black", "ankiconnect": { + "host": "127.0.0.1", "port": 8765, "DeckName_i": 0, "DeckNameS": [