自动配置脚本支持显示网页

This commit is contained in:
gfdgd xi 2022-11-11 13:42:21 +08:00
parent c5c0f6ced6
commit 3dc900f2a6
2 changed files with 17 additions and 9 deletions

View File

@ -118,11 +118,13 @@ class InformationWindow():
if i[0] == choose: if i[0] == choose:
fileName = i[1] fileName = i[1]
break break
aboutHtml = ""
try: try:
get = requests.get(f"{urlSources}/information/{fileName}.txt") get = requests.get(f"{urlSources}/information/{fileName}.txt")
if get.status_code / 100 != 2 and get.status_code / 100 != 3: if get.status_code / 100 != 2 and get.status_code / 100 != 3:
int("Bad") int("Bad")
about = get.text about = get.text
aboutHtml = str(about)
if not "<" in about: if not "<" in about:
# 非 Html 标签 # 非 Html 标签
for i in about.splitlines(): for i in about.splitlines():
@ -174,13 +176,19 @@ class InformationWindow():
messageLayout = QtWidgets.QVBoxLayout() messageLayout = QtWidgets.QVBoxLayout()
if webeng: if webeng:
informationText = QtWebEngineWidgets.QWebEngineView() informationText = QtWebEngineWidgets.QWebEngineView()
print(aboutHtml)
if aboutHtml[:7] == "Visit: ":
url = aboutHtml[7:].splitlines()[0]
print(url)
informationText.setUrl(QtCore.QUrl(url.strip()))
else:
#informationText.linkClicked.connect(lambda: print("a")) #informationText.linkClicked.connect(lambda: print("a"))
'''try: try:
with open("/tmp/deepin-wine-runner-information.html", "w") as file: with open("/tmp/deepin-wine-runner-information.html", "w") as file:
file.write(about) file.write(about)
informationText.setUrl(QtCore.QUrl("file:///tmp/deepin-wine-runner-information.html")) informationText.setUrl(QtCore.QUrl("file:///tmp/deepin-wine-runner-information.html"))
except: except:
traceback.print_exc()''' traceback.print_exc()
informationText.setHtml(about) informationText.setHtml(about)
#informationText.urlChanged.connect(lambda: informationText.setUrl(QtCore.QUrl("https://gfdgd-xi.github.io"))) #informationText.urlChanged.connect(lambda: informationText.setUrl(QtCore.QUrl("https://gfdgd-xi.github.io")))
else: else: