加入通讯录管理功能
This commit is contained in:
@@ -180,6 +180,90 @@ class DashboardServer:
|
||||
@login_required
|
||||
def robot_management():
|
||||
return render_template('robot_management.html')
|
||||
|
||||
# 添加通讯录管理页面路由
|
||||
@app.route('/contacts')
|
||||
@login_required
|
||||
def contacts_management():
|
||||
"""通讯录管理页面"""
|
||||
return render_template('contacts_management.html')
|
||||
|
||||
# 添加通讯录相关API
|
||||
@app.route('/api/contacts/all', methods=['GET'])
|
||||
@login_required
|
||||
def api_contacts_all():
|
||||
"""获取所有联系人信息API"""
|
||||
try:
|
||||
contacts = self.contact_manager.get_contacts()
|
||||
return jsonify({
|
||||
"success": True,
|
||||
"data": {
|
||||
"contacts": contacts
|
||||
}
|
||||
})
|
||||
except Exception as e:
|
||||
self.logger.error(f"获取所有联系人信息失败: {e}")
|
||||
return jsonify({"success": False, "error": str(e)}), 500
|
||||
|
||||
@app.route('/api/contacts/groups', methods=['GET'])
|
||||
@login_required
|
||||
def api_contacts_groups():
|
||||
"""获取群组联系人信息API"""
|
||||
try:
|
||||
contacts = self.contact_manager.get_contacts()
|
||||
group_contacts = {wxid: name for wxid, name in contacts.items() if '@@' in wxid or '@chatroom' in wxid}
|
||||
|
||||
return jsonify({
|
||||
"success": True,
|
||||
"data": {
|
||||
"groups": group_contacts
|
||||
}
|
||||
})
|
||||
except Exception as e:
|
||||
self.logger.error(f"获取群组联系人信息失败: {e}")
|
||||
return jsonify({"success": False, "error": str(e)}), 500
|
||||
|
||||
@app.route('/api/contacts/personal', methods=['GET'])
|
||||
@login_required
|
||||
def api_contacts_personal():
|
||||
"""获取个人联系人信息API"""
|
||||
try:
|
||||
contacts = self.contact_manager.get_contacts()
|
||||
personal_contacts = {wxid: name for wxid, name in contacts.items()
|
||||
if '@@' not in wxid and '@chatroom' not in wxid}
|
||||
|
||||
return jsonify({
|
||||
"success": True,
|
||||
"data": {
|
||||
"personal": personal_contacts
|
||||
}
|
||||
})
|
||||
except Exception as e:
|
||||
self.logger.error(f"获取个人联系人信息失败: {e}")
|
||||
return jsonify({"success": False, "error": str(e)}), 500
|
||||
|
||||
@app.route('/api/contacts/statistics', methods=['GET'])
|
||||
@login_required
|
||||
def api_contacts_statistics():
|
||||
"""获取联系人统计信息API"""
|
||||
try:
|
||||
contacts = self.contact_manager.get_contacts()
|
||||
group_contacts = {wxid: name for wxid, name in contacts.items()
|
||||
if '@@' in wxid or '@chatroom' in wxid}
|
||||
personal_contacts = {wxid: name for wxid, name in contacts.items()
|
||||
if '@@' not in wxid and '@chatroom' not in wxid}
|
||||
|
||||
return jsonify({
|
||||
"success": True,
|
||||
"data": {
|
||||
"total": len(contacts),
|
||||
"groups": len(group_contacts),
|
||||
"personal": len(personal_contacts)
|
||||
}
|
||||
})
|
||||
except Exception as e:
|
||||
self.logger.error(f"获取联系人统计信息失败: {e}")
|
||||
return jsonify({"success": False, "error": str(e)}), 500
|
||||
|
||||
@app.route('/api/robot/groups')
|
||||
@login_required
|
||||
|
||||
Reference in New Issue
Block a user