From 0e47603d23c9c6bb06baa294c1406d87d6f4ef40 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E5=AF=92=E5=AF=92?= <2596194220@qq.com>
Date: Mon, 15 Dec 2025 11:08:04 +0800
Subject: [PATCH] =?UTF-8?q?fix:=E4=BF=AE=E6=94=B9=E9=A1=B5=E9=9D=A2?=
=?UTF-8?q?=E6=BB=9A=E5=8A=A8=E6=9D=A1=E6=A0=B7=E5=BC=8F?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.idea/growth_report.iml | 3 -
.idea/workspace.xml | 63 ++++++++++++---------
main_nicegui.py | 39 ++++++++++++-
pyproject.toml | 1 +
script/尚城幼儿园幼儿学期发展报告.spec | 45 +++++++++++++++
ui/assets/style.css | 77 +++++++++++++++++++++++++-
ui/views/home_page.py | 2 +-
uv.lock | 29 +++++++++-
8 files changed, 225 insertions(+), 34 deletions(-)
create mode 100644 script/尚城幼儿园幼儿学期发展报告.spec
diff --git a/.idea/growth_report.iml b/.idea/growth_report.iml
index 3aad182..e2e8179 100644
--- a/.idea/growth_report.iml
+++ b/.idea/growth_report.iml
@@ -11,7 +11,4 @@
-
-
-
\ No newline at end of file
diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index 98432dc..ab96c2d 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -4,12 +4,9 @@
-
+
+
-
-
-
-
@@ -35,26 +32,26 @@
- {
+ "keyToString": {
+ "ModuleVcsDetector.initialDetectionPerformed": "true",
+ "Python.flet_ui_main.pyw.executor": "Run",
+ "Python.main.pyw.executor": "Run",
+ "Python.main_nicegui.executor": "Run",
+ "RunOnceActivity.ShowReadmeOnStart": "true",
+ "RunOnceActivity.TerminalTabsStorage.copyFrom.TerminalArrangementManager.252": "true",
+ "RunOnceActivity.git.unshallow": "true",
+ "git-widget-placeholder": "master",
+ "last_opened_file_path": "D:/working/tools/growth_report",
+ "node.js.detected.package.eslint": "true",
+ "node.js.detected.package.tslint": "true",
+ "node.js.selected.package.eslint": "(autodetect)",
+ "node.js.selected.package.tslint": "(autodetect)",
+ "nodejs_package_manager_path": "npm",
+ "settings.editor.selected.configurable": "com.jetbrains.python.configuration.PyActiveSdkModuleConfigurable",
+ "vue.rearranger.settings.migration": "true"
}
-}]]>
+}
@@ -154,7 +151,10 @@
1765613055475
-
+
+
+
+
@@ -172,7 +172,15 @@
1765631607389
-
+
+
+ 1765637863352
+
+
+
+ 1765637863352
+
+
@@ -181,7 +189,8 @@
-
+
+
diff --git a/main_nicegui.py b/main_nicegui.py
index 2c2813b..3f45879 100644
--- a/main_nicegui.py
+++ b/main_nicegui.py
@@ -4,6 +4,8 @@ import sys
from nicegui import ui, app, run, native
from loguru import logger
+from screeninfo import get_monitors
+
# 导入我们的模块
from config.config import load_config
from ui.core.logger import setup_logger
@@ -33,6 +35,40 @@ def get_path(relative_path):
return os.path.join(base_path, relative_path)
+def calculate_window_size():
+ """
+ 获取主屏幕分辨率,并计算一个基于百分比的 NiceGUI 窗口大小。
+ """
+ try:
+ # 尝试获取所有显示器信息
+ monitors = get_monitors()
+ if monitors:
+ # 假设第一个是主显示器
+ m = monitors[0]
+ screen_width = m.width
+ screen_height = m.height
+
+ # 设置窗口宽度为屏幕宽度的 70%
+ target_width = int(screen_width * 0.70)
+ # 设置窗口高度为屏幕高度的 80%
+ target_height = int(screen_height * 0.80)
+
+ # 确保窗口有一个合理的最小值 (例如 800x600)
+ min_width = 800
+ min_height = 700
+
+ target_width = max(target_width, min_width)
+ target_height = max(target_height, min_height)
+
+ logger.info(f"屏幕分辨率: {screen_width}x{screen_height}")
+ logger.info(f"设置窗口大小为: {target_width}x{target_height}")
+
+ return (target_width, target_height)
+
+ except Exception as e:
+ logger.warning(f"无法获取屏幕分辨率 ({e}),使用默认大小 (900, 900)")
+ return (900, 900) # 失败时的默认值
+
# 1. 挂载静态资源 (CSS/图片)
# 注意:这里使用 get_path 确保打包后能找到
static_dir = get_path(os.path.join("ui", "assets"))
@@ -59,10 +95,11 @@ async def startup_check():
app.on_startup(startup_check)
if __name__ in {"__main__", "__mp_main__"}:
+ calculated_size = calculate_window_size()
ui.run(
title="尚城幼儿园成长报告助手",
native=True,
- window_size=(900, 900),
+ window_size=calculated_size,
port=native.find_open_port(), # 自动寻找端口
reload=False
)
diff --git a/pyproject.toml b/pyproject.toml
index 11c5d41..f992a5d 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -19,6 +19,7 @@ dependencies = [
"pywebview>=6.1",
"pywin32>=311",
"rich>=14.2.0",
+ "screeninfo>=0.8.1",
"tomli>=2.3.0",
]
diff --git a/script/尚城幼儿园幼儿学期发展报告.spec b/script/尚城幼儿园幼儿学期发展报告.spec
new file mode 100644
index 0000000..02cfc4a
--- /dev/null
+++ b/script/尚城幼儿园幼儿学期发展报告.spec
@@ -0,0 +1,45 @@
+# -*- mode: python ; coding: utf-8 -*-
+
+
+a = Analysis(
+ ['..\\main_nicegui.py'],
+ pathex=[],
+ binaries=[],
+ datas=[('../config.toml', '.'), ('../fonts', 'fonts'), ('../templates', 'templates'), ('../ui/assets', 'ui/assets')],
+ hiddenimports=['nicegui', 'uvicorn'],
+ hookspath=[],
+ hooksconfig={},
+ runtime_hooks=[],
+ excludes=[],
+ noarchive=False,
+ optimize=0,
+)
+pyz = PYZ(a.pure)
+
+exe = EXE(
+ pyz,
+ a.scripts,
+ [],
+ exclude_binaries=True,
+ name='尚城幼儿园幼儿学期发展报告',
+ debug=False,
+ bootloader_ignore_signals=False,
+ strip=False,
+ upx=True,
+ console=False,
+ disable_windowed_traceback=False,
+ argv_emulation=False,
+ target_arch=None,
+ codesign_identity=None,
+ entitlements_file=None,
+ icon=['..\\public\\icon.ico'],
+)
+coll = COLLECT(
+ exe,
+ a.binaries,
+ a.datas,
+ strip=False,
+ upx=True,
+ upx_exclude=[],
+ name='尚城幼儿园幼儿学期发展报告',
+)
diff --git a/ui/assets/style.css b/ui/assets/style.css
index ede2cb4..8d3055c 100644
--- a/ui/assets/style.css
+++ b/ui/assets/style.css
@@ -52,4 +52,79 @@ body {
/* 蓝色标题 */
.text-blue { color: #1e40af; }
/* 红色标题 */
-.text-red { color: #991b1b; }
\ No newline at end of file
+.text-red { color: #991b1b; }
+
+
+/* assets/style.css */
+
+/* ... (原有的样式) ... */
+
+/* ---------------------------------- */
+/* 滚动条隐藏样式 */
+/* ---------------------------------- */
+
+/*
+* 1. 隐藏 Webkit 内核浏览器 (Chrome, Safari, Edge) 的滚动条
+* 适用于 NiceGUI 默认的 Chromium 浏览器
+*/
+.hide-scrollbar::-webkit-scrollbar {
+ /* 完全隐藏滚动条 */
+ width: 0px;
+ background: transparent; /* 使滚动条轨道透明 */
+}
+
+/* 2. 隐藏 Firefox 浏览器的滚动条 */
+.hide-scrollbar {
+ /* 设置滚动条宽度为 thin (细),比 auto (默认) 要窄 */
+ scrollbar-width: none; /* 'none' 是最新且更彻底的隐藏方式 */
+
+ /* 确保容器内容溢出时可以滚动 */
+ overflow: auto;
+}
+
+/* 示例:如果你只想隐藏日志区的滚动条 */
+.card-logging .q-expansion-item__content .nicegui-log .q-scrollarea__content {
+ /* 如果 nicegui-log 内部使用了 q-scrollarea,可能需要针对其内容应用样式 */
+ scrollbar-width: none;
+}
+
+/* ---------------------------------- */
+/* 滚动条美化(可选 - 不隐藏,但变细变淡) */
+/* 如果完全隐藏不好,可以试试这个更温和的方案 */
+/* ---------------------------------- */
+.thin-scrollbar::-webkit-scrollbar {
+ width: 6px; /* 调整宽度 */
+ height: 6px; /* 调整高度 */
+}
+
+.thin-scrollbar::-webkit-scrollbar-thumb {
+ background-color: #a0a0a0; /* 拇指颜色 */
+ border-radius: 3px;
+ border: 1px solid #f0f4f8; /* 边框颜色 */
+}
+
+.thin-scrollbar::-webkit-scrollbar-track {
+ background: transparent;
+}
+
+.thin-scrollbar {
+ scrollbar-width: thin; /* Firefox 细滚动条 */
+ scrollbar-color: #a0a0a0 transparent; /* Firefox 颜色设置 */
+}
+
+*::-webkit-scrollbar {
+ /* 完全隐藏滚动条 */
+ width: 0px !important;
+ height: 0px !important;
+ background: transparent !important;
+}
+#nicegui-content, #q-app {
+ /* 确保容器内容可以滚动,但滚动条被隐藏 */
+ overflow: auto;
+
+ /* Firefox 隐藏滚动条 */
+ scrollbar-width: none;
+
+ /* IE/Edge 隐藏滚动条 */
+ -ms-overflow-style: none;
+}
\ No newline at end of file
diff --git a/ui/views/home_page.py b/ui/views/home_page.py
index 3f88683..e33abee 100644
--- a/ui/views/home_page.py
+++ b/ui/views/home_page.py
@@ -28,7 +28,7 @@ def create_page():
create_header()
# 主容器
- with ui.column().classes('w-full max-w-4xl mx-auto p-4 gap-4'):
+ with ui.column().classes('w-full max-w-4xl mx-auto p-4 gap-4 thin-scrollbar'):
# === 进度条区域 ===
with ui.card().classes('func-card'):
diff --git a/uv.lock b/uv.lock
index c5bb42b..edc4ee3 100644
--- a/uv.lock
+++ b/uv.lock
@@ -1,5 +1,5 @@
version = 1
-revision = 3
+revision = 2
requires-python = ">=3.13"
[[package]]
@@ -278,6 +278,18 @@ wheels = [
{ url = "https://mirrors.aliyun.com/pypi/packages/66/95/f30c80615fda0d3c0ee6493ac9db61183313b43499b62dec136773b0e870/comtypes-1.4.13-py3-none-any.whl", hash = "sha256:21546210748ba52e839e52112124b16ffab7d7fb68096493165fbc249e9023ad" },
]
+[[package]]
+name = "cython"
+version = "3.2.3"
+source = { registry = "https://mirrors.aliyun.com/pypi/simple/" }
+sdist = { url = "https://mirrors.aliyun.com/pypi/packages/39/e1/c0d92b1258722e1bc62a12e630c33f1f842fdab53fd8cd5de2f75c6449a9/cython-3.2.3.tar.gz", hash = "sha256:f13832412d633376ffc08d751cc18ed0d7d00a398a4065e2871db505258748a6" }
+wheels = [
+ { url = "https://mirrors.aliyun.com/pypi/packages/d5/c2/35cedff7fcbc844e4e872c6719df5ece26551e14f37d76eb41c412d778c6/cython-3.2.3-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:1d097ad4686b58b8c03d760d08eca28f79878d404ef7452c49636170571654e0" },
+ { url = "https://mirrors.aliyun.com/pypi/packages/5c/07/93c65fbee4ab419767b7e54937e91cacae5c71d2d1277cc882ea3b1ce777/cython-3.2.3-cp314-cp314-macosx_11_0_arm64.whl", hash = "sha256:80f20369d7aaf4e76cfef902025256918a5cc6eb0aed6d8783e4b1c563e4f6c4" },
+ { url = "https://mirrors.aliyun.com/pypi/packages/43/49/afe1e3df87a770861cf17ba39f4a91f6d22a2571010fc1890b3708360630/cython-3.2.3-cp39-abi3-macosx_10_9_x86_64.whl", hash = "sha256:74f482da8b605c61b4df6ff716d013f20131949cb2fa59b03e63abd36ef5bac0" },
+ { url = "https://mirrors.aliyun.com/pypi/packages/e5/41/54fd429ff8147475fc24ca43246f85d78fb4e747c27f227e68f1594648f1/cython-3.2.3-py3-none-any.whl", hash = "sha256:06a1317097f540d3bb6c7b81ed58a0d8b9dbfa97abf39dfd4c22ee87a6c7241e" },
+]
+
[[package]]
name = "distro"
version = "1.9.0"
@@ -412,6 +424,7 @@ dependencies = [
{ name = "pywebview" },
{ name = "pywin32" },
{ name = "rich" },
+ { name = "screeninfo" },
{ name = "tomli" },
]
@@ -431,6 +444,7 @@ requires-dist = [
{ name = "pywebview", specifier = ">=6.1" },
{ name = "pywin32", specifier = ">=311" },
{ name = "rich", specifier = ">=14.2.0" },
+ { name = "screeninfo", specifier = ">=0.8.1" },
{ name = "tomli", specifier = ">=2.3.0" },
]
@@ -1869,6 +1883,19 @@ wheels = [
{ url = "https://mirrors.aliyun.com/pypi/packages/25/7a/b0178788f8dc6cafce37a212c99565fa1fe7872c70c6c9c1e1a372d9d88f/rich-14.2.0-py3-none-any.whl", hash = "sha256:76bc51fe2e57d2b1be1f96c524b890b816e334ab4c1e45888799bfaab0021edd" },
]
+[[package]]
+name = "screeninfo"
+version = "0.8.1"
+source = { registry = "https://mirrors.aliyun.com/pypi/simple/" }
+dependencies = [
+ { name = "cython", marker = "sys_platform == 'darwin'" },
+ { name = "pyobjc-framework-cocoa", marker = "sys_platform == 'darwin'" },
+]
+sdist = { url = "https://mirrors.aliyun.com/pypi/packages/ec/bb/e69e5e628d43f118e0af4fc063c20058faa8635c95a1296764acc8167e27/screeninfo-0.8.1.tar.gz", hash = "sha256:9983076bcc7e34402a1a9e4d7dabf3729411fd2abb3f3b4be7eba73519cd2ed1" }
+wheels = [
+ { url = "https://mirrors.aliyun.com/pypi/packages/6e/bf/c5205d480307bef660e56544b9e3d7ff687da776abb30c9cb3f330887570/screeninfo-0.8.1-py3-none-any.whl", hash = "sha256:e97d6b173856edcfa3bd282f81deb528188aff14b11ec3e195584e7641be733c" },
+]
+
[[package]]
name = "setuptools"
version = "80.9.0"