Skip to content

Commit

Permalink
在设置中添加WebView相关的参数;保存窗口尺寸
Browse files Browse the repository at this point in the history
  • Loading branch information
ZhaoZuohong committed Jun 8, 2023
1 parent dbf340c commit c97a8a3
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 10 deletions.
6 changes: 5 additions & 1 deletion arknights_mower/templates/conf.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,8 @@ maa_mall_buy: 招聘许可,龙门币
maa_recruit_only_4: false
maa_recruitment_time: false
maa_rg_sleep_max: 8:30
maa_rg_sleep_min: 9:30
maa_rg_sleep_min: 9:30
webview:
port: 58000
width: 1100
height: 780
3 changes: 1 addition & 2 deletions server.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,8 @@ def load_config():
conf = load_conf()
return conf
else:
conf = request.json
conf.update(request.json)
save_conf(conf)
conf = load_conf()
return f"New config saved!"


Expand Down
43 changes: 36 additions & 7 deletions webview_ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,49 @@
import os
import multiprocessing

from arknights_mower.utils.conf import load_conf, save_conf

def start_server(app):
app.run(host="127.0.0.1", port="8000")

def start_server(app, port):
app.run(host="127.0.0.1", port=port)


def on_resized(w, h):
global width
global height

width = w
height = h


if __name__ == "__main__":
multiprocessing.freeze_support()

webview.create_window(
conf = load_conf()

port = conf["webview"]["port"]

global width
global height

width = conf["webview"]["width"]
height = conf["webview"]["height"]

window = webview.create_window(
"Mower Web UI in WebView (尚不完善,测试用途,谨慎使用)",
"http://127.0.0.1:8000",
width=1200,
height=900,
f"http://127.0.0.1:{port}",
width=width,
height=height,
)
webview.start(start_server, app)

window.events.resized += on_resized

webview.start(start_server, (app, port))


conf = load_conf()
conf["webview"]["width"] = width
conf["webview"]["height"] = height
save_conf(conf)

os._exit(0)

0 comments on commit c97a8a3

Please sign in to comment.