You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

40 lines
1.2 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

import customtkinter as ctk
class BaseManager:
"""界面管理器基类
所有界面管理器(如日程管理器、待办事项管理器等)的基类,提供通用功能:
1. 在切换界面时自动保存聊天历史记录
2. 提供一致的界面显示方法
子类需要实现具体的界面创建逻辑。
"""
def __init__(self, app, root):
"""初始化基类
Args:
app: 主应用程序实例
root: 根窗口实例
"""
self.app = app
self.root = root
def _save_chat_history(self):
"""保存聊天历史记录
在切换界面之前调用此方法,确保聊天历史记录被保存。
"""
if hasattr(self.app, 'save_chat_history'):
self.app.save_chat_history()
def show(self, parent_frame=None):
"""显示界面的通用方法
子类可以重写此方法但应该调用super().show(parent_frame)来保存聊天历史记录。
Args:
parent_frame: 父框架
"""
# 在切换界面之前保存聊天历史记录
self._save_chat_history()