agentscope-ai / agentscope-ai/QwenPaw
[Feature Request] 窗口大小和位置记忆:重启后保留上次窗口尺寸
- Dominant language
- Python
- Stars
- 34.9k
- Forks
- 3.1k
- Avg merge
- 1d 15h
- Merged PRs (30d)
- 225
Description
## 🔍 问题描述
当前 QwenPaw Desktop 每次启动时窗口都会重置为默认的 1280×800 尺寸,无法保留用户上次关闭时的窗口大小和位置。用户每次都需要手动调整窗口,体验不佳。
## 💡 功能建议
### 期望行为
用户在关闭 QwenPaw Desktop 时,应用自动保存当前窗口的 width、height、x、y 到配置文件。下次启动时自动恢复这些值。
### 建议实现方案
**1. 新增配置文件字段**
在 config.json 中增加 window 配置节:
```json
{
"window": {
"width": 1200,
"height": 800,
"x": null,
"y": null
}
}
```
**2. 修改启动入口 (desktop_cmd.py)**
从配置文件中读取 window 对象,传入 webview.create_window():
```python
window_config = load_window_config()
webview.create_window(
title="QwenPaw Desktop",
url=url,
js_api=api,
width=window_config.get("width", 1280),
height=window_config.get("height", 800),
x=window_config.get("x"),
y=window_config.get("y"),
)
```
**3. 监听窗口关闭事件,保存状态**
在窗口关闭前,读取并保存当前窗口几何信息:
```python
def save_window_geometry(window):
x, y = window.x, window.y
width, height = window.width, window.height
config_path = os.path.expanduser("~/.qwenpaw/config.json")
with open(config_path, "r+") as f:
config = json.load(f)
config["window"] = {
"width": width,
"height": height,
"x": x,
"y": y
}
f.seek(0)
json.dump(config, f, indent=2)
window.events.closing += save_window_geometry
```
## 🎯 使用场景
- 多显示器用户:窗口总是在特定屏幕的特定位置
- - 大屏用户:需要更大的窗口而非默认的 1280×800
- - - 固定窗口大小:减少每次启动后的调整操作
## 📎 附加信息
- 相关源码文件:qwenpaw/cli/desktop_cmd.py
- - pywebview create_window 参数:width、height、x、y
- - - pywebview 窗口对象属性:.x、.y、.width、.height
- - - - 当前默认值:width=1280, height=800
Contributor guide
Assessment
This issue has not been assessed yet.