处理这个python打开紫鸟
This commit is contained in:
18
app/main.py
18
app/main.py
@@ -16,6 +16,7 @@ import webview
|
||||
import threading
|
||||
import time
|
||||
import requests
|
||||
import subprocess
|
||||
|
||||
|
||||
with open("version.txt","w",encoding="utf-8") as file:
|
||||
@@ -234,6 +235,21 @@ class WindowAPI:
|
||||
except Exception as e:
|
||||
return {'success': False, 'error': str(e)}
|
||||
|
||||
def open_external_url(self, url):
|
||||
if not url or not str(url).strip():
|
||||
return {'success': False, 'error': '链接为空'}
|
||||
target = str(url).strip()
|
||||
try:
|
||||
if sys.platform.startswith('win'):
|
||||
os.startfile(target)
|
||||
elif sys.platform == 'darwin':
|
||||
subprocess.Popen(['open', target])
|
||||
else:
|
||||
subprocess.Popen(['xdg-open', target])
|
||||
return {'success': True}
|
||||
except Exception as e:
|
||||
return {'success': False, 'error': str(e)}
|
||||
|
||||
def enqueue_json(self, data):
|
||||
"""保存任务到队列"""
|
||||
try:
|
||||
@@ -350,7 +366,7 @@ def main():
|
||||
)
|
||||
api = WindowAPI(window)
|
||||
window.expose(api.close, api.minimize, api.maximize, api.toggle_maximize, generate_images, api.save_image, api.save_image_to_folder, api.select_folder, api.select_brand_xlsx_files, api.select_brand_folder,
|
||||
api.save_file_from_url, api.save_template_xlsx,api.save_template_zip,api.upload_file_to_java,api.enqueue_json)
|
||||
api.save_file_from_url, api.save_template_xlsx,api.save_template_zip,api.upload_file_to_java,api.open_external_url,api.enqueue_json)
|
||||
webview.start(
|
||||
debug=True,
|
||||
storage_path=cache_path,
|
||||
|
||||
Reference in New Issue
Block a user