Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

兼容Mac和Linux #4

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions evue/evueapplication.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
from loguru import logger
from .router import Router
from pyee import EventEmitter
import platform

os.environ["FLET_WS_MAX_MESSAGE_SIZE"] = "8000000"
def main(page: Page):
Expand Down Expand Up @@ -171,12 +172,19 @@ def startApp(path: str, closeCallback=None, threaded=False):
kwargs['host'] = host
globalThis.server_ip = host if host not in [None, "", "*"] else "127.0.0.1"

system_type_local = platform.system()
if 'port' in kwargs and kwargs['port']:
port = kwargs['port']
globalThis.port = port
if system_type_local == "Linux":
globalThis.port = port - 1
else:
globalThis.port = port
else:
port = get_free_tcp_port()
globalThis.port = port
if system_type_local == "Linux":
globalThis.port = port + 1
else:
globalThis.port = port
kwargs['port'] = port


Expand Down
13 changes: 11 additions & 2 deletions evue/imagebrowser.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,12 @@
from flet.padding import Padding
from flet.control_event import ControlEvent
import shutil
from os import startfile
import platform
system_type = platform.system()
if system_type == "Darwin" or system_type == "Linux":
import subprocess
else:
from os import startfile


class debounce: # noqa
Expand Down Expand Up @@ -241,7 +246,11 @@ def on_explore(self, e):
else:
d = "%s%s" % (self.assets_dir, self.currentDirName)
d = os.path.abspath(d)
startfile(d)
system_type_local = platform.system()
if system_type_local == "Darwin" or system_type_local == "Linux":
subprocess.call(["open", d])
else:
startfile(d)

def updateSideBar(self):
self.sidebar.controls.clear()
Expand Down