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

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,15 +176,21 @@ class InformationWindow():
messageLayout = QtWidgets.QVBoxLayout() messageLayout = QtWidgets.QVBoxLayout()
if webeng: if webeng:
informationText = QtWebEngineWidgets.QWebEngineView() informationText = QtWebEngineWidgets.QWebEngineView()
#informationText.linkClicked.connect(lambda: print("a")) print(aboutHtml)
'''try: if aboutHtml[:7] == "Visit: ":
with open("/tmp/deepin-wine-runner-information.html", "w") as file: url = aboutHtml[7:].splitlines()[0]
file.write(about) print(url)
informationText.setUrl(QtCore.QUrl("file:///tmp/deepin-wine-runner-information.html")) informationText.setUrl(QtCore.QUrl(url.strip()))
except: else:
traceback.print_exc()''' #informationText.linkClicked.connect(lambda: print("a"))
informationText.setHtml(about) try:
#informationText.urlChanged.connect(lambda: informationText.setUrl(QtCore.QUrl("https://gfdgd-xi.github.io"))) with open("/tmp/deepin-wine-runner-information.html", "w") as file:
file.write(about)
informationText.setUrl(QtCore.QUrl("file:///tmp/deepin-wine-runner-information.html"))
except:
traceback.print_exc()
informationText.setHtml(about)
#informationText.urlChanged.connect(lambda: informationText.setUrl(QtCore.QUrl("https://gfdgd-xi.github.io")))
else: else:
informationText = QtWidgets.QTextBrowser() informationText = QtWidgets.QTextBrowser()
informationText.setHtml(about) informationText.setHtml(about)