fix:修改页面滚动条样式

This commit is contained in:
2025-12-15 11:08:04 +08:00
parent 6809c6f2c6
commit 0e47603d23
8 changed files with 225 additions and 34 deletions

View File

@@ -11,7 +11,4 @@
</list> </list>
</option> </option>
</component> </component>
<component name="TestRunnerService">
<option name="PROJECT_TEST_RUNNER" value="py.test" />
</component>
</module> </module>

63
.idea/workspace.xml generated
View File

@@ -4,12 +4,9 @@
<option name="autoReloadType" value="SELECTIVE" /> <option name="autoReloadType" value="SELECTIVE" />
</component> </component>
<component name="ChangeListManager"> <component name="ChangeListManager">
<list default="true" id="e258c58a-2a5f-4fad-9d39-8dc186b6b5a7" name="更改" comment="fix:添加niceGui库美化页面"> <list default="true" id="e258c58a-2a5f-4fad-9d39-8dc186b6b5a7" name="更改" comment="fix:更新项目说明文档">
<change beforePath="$PROJECT_DIR$/.idea/growth_report.iml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/growth_report.iml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" /> <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/IFLOW.md" beforeDir="false" afterPath="$PROJECT_DIR$/IFLOW.md" afterDir="false" />
<change beforePath="$PROJECT_DIR$/README.md" beforeDir="false" afterPath="$PROJECT_DIR$/README.md" afterDir="false" />
<change beforePath="$PROJECT_DIR$/main_nicegui.py" beforeDir="false" afterPath="$PROJECT_DIR$/main_nicegui.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/script/setup_nicegui.py" beforeDir="false" afterPath="$PROJECT_DIR$/script/setup_nicegui.py" afterDir="false" />
</list> </list>
<option name="SHOW_DIALOG" value="false" /> <option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" /> <option name="HIGHLIGHT_CONFLICTS" value="true" />
@@ -35,26 +32,26 @@
<option name="hideEmptyMiddlePackages" value="true" /> <option name="hideEmptyMiddlePackages" value="true" />
<option name="showLibraryContents" value="true" /> <option name="showLibraryContents" value="true" />
</component> </component>
<component name="PropertiesComponent"><![CDATA[{ <component name="PropertiesComponent">{
"keyToString": { &quot;keyToString&quot;: {
"ModuleVcsDetector.initialDetectionPerformed": "true", &quot;ModuleVcsDetector.initialDetectionPerformed&quot;: &quot;true&quot;,
"Python.flet_ui_main.pyw.executor": "Run", &quot;Python.flet_ui_main.pyw.executor&quot;: &quot;Run&quot;,
"Python.main.pyw.executor": "Run", &quot;Python.main.pyw.executor&quot;: &quot;Run&quot;,
"Python.main_nicegui.executor": "Run", &quot;Python.main_nicegui.executor&quot;: &quot;Run&quot;,
"RunOnceActivity.ShowReadmeOnStart": "true", &quot;RunOnceActivity.ShowReadmeOnStart&quot;: &quot;true&quot;,
"RunOnceActivity.TerminalTabsStorage.copyFrom.TerminalArrangementManager.252": "true", &quot;RunOnceActivity.TerminalTabsStorage.copyFrom.TerminalArrangementManager.252&quot;: &quot;true&quot;,
"RunOnceActivity.git.unshallow": "true", &quot;RunOnceActivity.git.unshallow&quot;: &quot;true&quot;,
"git-widget-placeholder": "master", &quot;git-widget-placeholder&quot;: &quot;master&quot;,
"last_opened_file_path": "D:/working/tools/growth_report", &quot;last_opened_file_path&quot;: &quot;D:/working/tools/growth_report&quot;,
"node.js.detected.package.eslint": "true", &quot;node.js.detected.package.eslint&quot;: &quot;true&quot;,
"node.js.detected.package.tslint": "true", &quot;node.js.detected.package.tslint&quot;: &quot;true&quot;,
"node.js.selected.package.eslint": "(autodetect)", &quot;node.js.selected.package.eslint&quot;: &quot;(autodetect)&quot;,
"node.js.selected.package.tslint": "(autodetect)", &quot;node.js.selected.package.tslint&quot;: &quot;(autodetect)&quot;,
"nodejs_package_manager_path": "npm", &quot;nodejs_package_manager_path&quot;: &quot;npm&quot;,
"settings.editor.selected.configurable": "com.jetbrains.python.configuration.PyActiveSdkModuleConfigurable", &quot;settings.editor.selected.configurable&quot;: &quot;com.jetbrains.python.configuration.PyActiveSdkModuleConfigurable&quot;,
"vue.rearranger.settings.migration": "true" &quot;vue.rearranger.settings.migration&quot;: &quot;true&quot;
} }
}]]></component> }</component>
<component name="RecentsManager"> <component name="RecentsManager">
<key name="CopyFile.RECENT_KEYS"> <key name="CopyFile.RECENT_KEYS">
<recent name="D:\working\tools\growth_report" /> <recent name="D:\working\tools\growth_report" />
@@ -154,7 +151,10 @@
<updated>1765613055475</updated> <updated>1765613055475</updated>
<workItem from="1765613057798" duration="372000" /> <workItem from="1765613057798" duration="372000" />
<workItem from="1765613448098" duration="48000" /> <workItem from="1765613448098" duration="48000" />
<workItem from="1765613503892" duration="18548000" /> <workItem from="1765613503892" duration="19160000" />
<workItem from="1765638479255" duration="12000" />
<workItem from="1765638935533" duration="5136000" />
<workItem from="1765704332562" duration="272000" />
</task> </task>
<task id="LOCAL-00001" summary="fix:修复一些BUG"> <task id="LOCAL-00001" summary="fix:修复一些BUG">
<option name="closed" value="true" /> <option name="closed" value="true" />
@@ -172,7 +172,15 @@
<option name="project" value="LOCAL" /> <option name="project" value="LOCAL" />
<updated>1765631607389</updated> <updated>1765631607389</updated>
</task> </task>
<option name="localTasksCounter" value="3" /> <task id="LOCAL-00003" summary="fix:更新项目说明文档">
<option name="closed" value="true" />
<created>1765637863352</created>
<option name="number" value="00003" />
<option name="presentableId" value="LOCAL-00003" />
<option name="project" value="LOCAL" />
<updated>1765637863352</updated>
</task>
<option name="localTasksCounter" value="4" />
<servers /> <servers />
</component> </component>
<component name="TypeScriptGeneratedFilesManager"> <component name="TypeScriptGeneratedFilesManager">
@@ -181,7 +189,8 @@
<component name="VcsManagerConfiguration"> <component name="VcsManagerConfiguration">
<MESSAGE value="fix:修复一些BUG" /> <MESSAGE value="fix:修复一些BUG" />
<MESSAGE value="fix:添加niceGui库美化页面" /> <MESSAGE value="fix:添加niceGui库美化页面" />
<option name="LAST_COMMIT_MESSAGE" value="fix:添加niceGui库美化页面" /> <MESSAGE value="fix:更新项目说明文档" />
<option name="LAST_COMMIT_MESSAGE" value="fix:更新项目说明文档" />
</component> </component>
<component name="com.intellij.coverage.CoverageDataManagerImpl"> <component name="com.intellij.coverage.CoverageDataManagerImpl">
<SUITE FILE_PATH="coverage/growth_report$main_pyw.coverage" NAME="main.pyw 覆盖结果" MODIFIED="1765626787983" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="false" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$" /> <SUITE FILE_PATH="coverage/growth_report$main_pyw.coverage" NAME="main.pyw 覆盖结果" MODIFIED="1765626787983" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="false" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$" />

View File

@@ -4,6 +4,8 @@ import sys
from nicegui import ui, app, run, native from nicegui import ui, app, run, native
from loguru import logger from loguru import logger
from screeninfo import get_monitors
# 导入我们的模块 # 导入我们的模块
from config.config import load_config from config.config import load_config
from ui.core.logger import setup_logger from ui.core.logger import setup_logger
@@ -33,6 +35,40 @@ def get_path(relative_path):
return os.path.join(base_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/图片) # 1. 挂载静态资源 (CSS/图片)
# 注意:这里使用 get_path 确保打包后能找到 # 注意:这里使用 get_path 确保打包后能找到
static_dir = get_path(os.path.join("ui", "assets")) static_dir = get_path(os.path.join("ui", "assets"))
@@ -59,10 +95,11 @@ async def startup_check():
app.on_startup(startup_check) app.on_startup(startup_check)
if __name__ in {"__main__", "__mp_main__"}: if __name__ in {"__main__", "__mp_main__"}:
calculated_size = calculate_window_size()
ui.run( ui.run(
title="尚城幼儿园成长报告助手", title="尚城幼儿园成长报告助手",
native=True, native=True,
window_size=(900, 900), window_size=calculated_size,
port=native.find_open_port(), # 自动寻找端口 port=native.find_open_port(), # 自动寻找端口
reload=False reload=False
) )

View File

@@ -19,6 +19,7 @@ dependencies = [
"pywebview>=6.1", "pywebview>=6.1",
"pywin32>=311", "pywin32>=311",
"rich>=14.2.0", "rich>=14.2.0",
"screeninfo>=0.8.1",
"tomli>=2.3.0", "tomli>=2.3.0",
] ]

View File

@@ -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='尚城幼儿园幼儿学期发展报告',
)

View File

@@ -53,3 +53,78 @@ body {
.text-blue { color: #1e40af; } .text-blue { color: #1e40af; }
/* 红色标题 */ /* 红色标题 */
.text-red { color: #991b1b; } .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;
}

View File

@@ -28,7 +28,7 @@ def create_page():
create_header() 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'): with ui.card().classes('func-card'):

29
uv.lock generated
View File

@@ -1,5 +1,5 @@
version = 1 version = 1
revision = 3 revision = 2
requires-python = ">=3.13" requires-python = ">=3.13"
[[package]] [[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" }, { 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]] [[package]]
name = "distro" name = "distro"
version = "1.9.0" version = "1.9.0"
@@ -412,6 +424,7 @@ dependencies = [
{ name = "pywebview" }, { name = "pywebview" },
{ name = "pywin32" }, { name = "pywin32" },
{ name = "rich" }, { name = "rich" },
{ name = "screeninfo" },
{ name = "tomli" }, { name = "tomli" },
] ]
@@ -431,6 +444,7 @@ requires-dist = [
{ name = "pywebview", specifier = ">=6.1" }, { name = "pywebview", specifier = ">=6.1" },
{ name = "pywin32", specifier = ">=311" }, { name = "pywin32", specifier = ">=311" },
{ name = "rich", specifier = ">=14.2.0" }, { name = "rich", specifier = ">=14.2.0" },
{ name = "screeninfo", specifier = ">=0.8.1" },
{ name = "tomli", specifier = ">=2.3.0" }, { 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" }, { 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]] [[package]]
name = "setuptools" name = "setuptools"
version = "80.9.0" version = "80.9.0"