docs: 完善项目文档和使用说明

- 更新README.md,补充GUI特性说明和参数配置文档
- 新增使用说明目录,包含完整的操作手册和界面截图
- 优化generate_template.py,支持自定义模板输出路径
- 改进GUI界面布局,优化文件上传和模板导出功能
- 添加系统参数配置说明(电压、功率因数等)
This commit is contained in:
dmy
2026-01-05 23:30:29 +08:00
parent c6168afd1d
commit b924f75add
10 changed files with 208 additions and 36 deletions

53
gui.py
View File

@@ -230,6 +230,7 @@ def index():
# 更新文件显示区域
if refs["current_file_container"]:
# refs["current_file_container"].set_visibility(True)
refs["current_file_container"].clear()
with refs["current_file_container"]:
with ui.row().classes(
@@ -846,16 +847,23 @@ def index():
with ui.row().classes("w-full p-4 gap-4"):
with ui.card().classes("w-full p-4 shadow-md"):
ui.label("配置面板").classes("text-xl font-semibold mb-4 border-b pb-2")
with ui.row(align_items='center').classes('w-full'):
# 使用 items-stretch 确保所有子元素高度一致
with ui.row().classes('w-full items-stretch gap-4'):
# 1. 导出模板按钮
async def export_template():
from generate_template import create_template
import shutil
async def save_template(path):
# 生成模板到当前目录
create_template()
source = "coordinates.xlsx"
if os.path.exists(source):
shutil.copy2(source, path)
# 生成模板到系统临时目录
temp_template = os.path.join(state["temp_dir"], "coordinates_template.xlsx")
create_template(temp_template)
if os.path.exists(temp_template):
shutil.copy2(temp_template, path)
try:
os.remove(temp_template)
except:
pass
else:
raise FileNotFoundError("无法生成模板文件")
@@ -866,40 +874,29 @@ def index():
)
ui.button("导出 Excel 模板", on_click=export_template).classes(
" w-1/4"
"flex-1 py-4"
).props("icon=file_download outline color=primary")
# async def test_save_dialog():
# async def dummy_callback(path):
# # 仅作为测试,实际不写入文件,只弹出通知
# ui.notify(f"测试成功!选定路径: {path}", type="info")
# await save_file_with_dialog(
# "test_save_dialog.txt", dummy_callback, "Text Files (*.txt)"
# )
# ui.button("测试对话框", on_click=test_save_dialog).classes(
# "w-full mb-4"
# ).props("icon=bug_report outline color=orange")
with ui.column().classes('w-1/4'):
ui.label("1. 上传坐标文件 (.xlsx)").classes("font-medium")
# 2. 上传文件区域 (垂直堆叠 Label 和 Upload 组件)
with ui.column().classes('flex-1 gap-0 justify-between'):
# 使用 .no-list CSS 隐藏 Quasar 默认列表,完全自定义文件显示
refs["upload_widget"] = ui.upload(
label="选择Excel文件", on_upload=handle_upload, auto_upload=True
).classes("w-full mb-2 no-list")
).classes("w-full no-list h-full").props('flat bordered color=primary')
# 自定义文件显示容器
refs["current_file_container"] = ui.column().classes("w-full mb-4")
with refs["current_file_container"]:
ui.label("未选择文件").classes("text-xs text-gray-500 italic ml-1")
refs["current_file_container"] = ui.column().classes("w-full")
# 初始状态不显示任何内容,直到选择文件后才显示
# with refs["current_file_container"]:
# ui.label("未选择文件").classes("text-xs text-gray-500 italic ml-1")
# 3. 运行按钮
refs["run_btn"] = (
ui.button(
"运行方案对比",
on_click=run_analysis,
)
.classes("w-1/4 py-4")
.classes("flex-1 py-4")
.props("icon=play_arrow color=secondary")
)