mirror of
https://gitee.com/g1879/DrissionPage.git
synced 2024-12-10 04:00:23 +08:00
运行浏览器时自动加上--remote-allow-origins参数
This commit is contained in:
parent
518b261365
commit
62d41900e1
@ -63,13 +63,17 @@ def get_launch_args(opt):
|
|||||||
# ----------处理arguments-----------
|
# ----------处理arguments-----------
|
||||||
result = set()
|
result = set()
|
||||||
has_user_path = False
|
has_user_path = False
|
||||||
|
remote_allow = False
|
||||||
for i in opt.arguments:
|
for i in opt.arguments:
|
||||||
if i.startswith(('--load-extension=', '--remote-debugging-port=')):
|
if i.startswith(('--load-extension=', '--remote-debugging-port=')):
|
||||||
continue
|
continue
|
||||||
elif i.startswith('--user-data-dir') and not opt.system_user_path:
|
elif i.startswith('--user-data-dir') and not opt.system_user_path:
|
||||||
p = Path(i[16:]).absolute()
|
result.add(f'--user-data-dir={Path(i[16:]).absolute()}')
|
||||||
result.add(f'--user-data-dir={p}')
|
|
||||||
has_user_path = True
|
has_user_path = True
|
||||||
|
continue
|
||||||
|
elif i.startswith('--remote-allow-origins='):
|
||||||
|
remote_allow = True
|
||||||
|
|
||||||
result.add(i)
|
result.add(i)
|
||||||
|
|
||||||
if not has_user_path and not opt.system_user_path:
|
if not has_user_path and not opt.system_user_path:
|
||||||
@ -78,6 +82,9 @@ def get_launch_args(opt):
|
|||||||
path.mkdir(parents=True, exist_ok=True)
|
path.mkdir(parents=True, exist_ok=True)
|
||||||
result.add(f'--user-data-dir={path}')
|
result.add(f'--user-data-dir={path}')
|
||||||
|
|
||||||
|
if not remote_allow:
|
||||||
|
result.add('--remote-allow-origins=*')
|
||||||
|
|
||||||
result = list(result)
|
result = list(result)
|
||||||
|
|
||||||
# ----------处理插件extensions-------------
|
# ----------处理插件extensions-------------
|
||||||
@ -164,6 +171,7 @@ def _run_browser(port, path: str, args) -> Popen:
|
|||||||
:param args: 启动参数
|
:param args: 启动参数
|
||||||
:return: 进程对象
|
:return: 进程对象
|
||||||
"""
|
"""
|
||||||
|
print(port)
|
||||||
arguments = [path, f'--remote-debugging-port={port}']
|
arguments = [path, f'--remote-debugging-port={port}']
|
||||||
arguments.extend(args)
|
arguments.extend(args)
|
||||||
return Popen(arguments, shell=False)
|
return Popen(arguments, shell=False)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user