管理后台 server 使用蓝图模式,降低维护成本,降低修改功能时对其他模块的影响
This commit is contained in:
@@ -32,7 +32,6 @@ def api_contacts_all():
|
|||||||
return jsonify({"success": False, "error": str(e)}), 500
|
return jsonify({"success": False, "error": str(e)}), 500
|
||||||
|
|
||||||
@contacts_bp.route('/api/statistics', methods=['GET'])
|
@contacts_bp.route('/api/statistics', methods=['GET'])
|
||||||
@login_required
|
|
||||||
def api_contacts_statistics():
|
def api_contacts_statistics():
|
||||||
"""获取联系人统计信息API"""
|
"""获取联系人统计信息API"""
|
||||||
try:
|
try:
|
||||||
|
|||||||
@@ -5,11 +5,11 @@ from robot_cmd.robot_command import GroupBotManager, Feature, PermissionStatus
|
|||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
|
||||||
# 创建机器人管理蓝图
|
# 创建机器人管理蓝图
|
||||||
robot_bp = Blueprint('robot', __name__)
|
robot_bp = Blueprint('robot', __name__, url_prefix='/robot')
|
||||||
logger = logging.getLogger("RobotBlueprint")
|
logger = logging.getLogger("RobotBlueprint")
|
||||||
|
|
||||||
# 机器人管理页面
|
# 机器人管理页面
|
||||||
@robot_bp.route('/robot_management')
|
@robot_bp.route('/')
|
||||||
@login_required
|
@login_required
|
||||||
def robot_management():
|
def robot_management():
|
||||||
return render_template('robot_management.html')
|
return render_template('robot_management.html')
|
||||||
|
|||||||
@@ -342,8 +342,10 @@
|
|||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
loadContactsData() {
|
loadContactsData() {
|
||||||
|
// 修改API请求路径,从 /api/contacts/ 改为 /contacts/api/
|
||||||
|
|
||||||
// 加载统计数据
|
// 加载统计数据
|
||||||
axios.get('/api/contacts/statistics')
|
axios.get('/contacts/api/statistics')
|
||||||
.then(response => {
|
.then(response => {
|
||||||
if (response.data.success) {
|
if (response.data.success) {
|
||||||
this.statistics = response.data.data;
|
this.statistics = response.data.data;
|
||||||
@@ -355,7 +357,7 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
// 加载群组数据
|
// 加载群组数据
|
||||||
axios.get('/api/contacts/groups')
|
axios.get('/contacts/api/groups')
|
||||||
.then(response => {
|
.then(response => {
|
||||||
if (response.data.success) {
|
if (response.data.success) {
|
||||||
const groups = response.data.data.groups;
|
const groups = response.data.data.groups;
|
||||||
@@ -371,7 +373,7 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
// 加载个人联系人数据
|
// 加载个人联系人数据
|
||||||
axios.get('/api/contacts/personal')
|
axios.get('/contacts/api/personal')
|
||||||
.then(response => {
|
.then(response => {
|
||||||
if (response.data.success) {
|
if (response.data.success) {
|
||||||
const personal = response.data.data.personal;
|
const personal = response.data.data.personal;
|
||||||
@@ -387,7 +389,7 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
// 加载公众号数据
|
// 加载公众号数据
|
||||||
axios.get('/api/contacts/official')
|
axios.get('/contacts/api/official')
|
||||||
.then(response => {
|
.then(response => {
|
||||||
if (response.data.success) {
|
if (response.data.success) {
|
||||||
const official = response.data.data.official;
|
const official = response.data.data.official;
|
||||||
@@ -403,7 +405,7 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
// 加载公共好友数据
|
// 加载公共好友数据
|
||||||
axios.get('/api/contacts/public')
|
axios.get('/contacts/api/public')
|
||||||
.then(response => {
|
.then(response => {
|
||||||
if (response.data.success) {
|
if (response.data.success) {
|
||||||
const publicFriends = response.data.data.public;
|
const publicFriends = response.data.data.public;
|
||||||
|
|||||||
@@ -199,7 +199,7 @@
|
|||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
loadGroups() {
|
loadGroups() {
|
||||||
axios.get('/api/robot/groups')
|
axios.get('/robot/api/groups')
|
||||||
.then(response => {
|
.then(response => {
|
||||||
if (response.data.success) {
|
if (response.data.success) {
|
||||||
this.groups = response.data.data || [];
|
this.groups = response.data.data || [];
|
||||||
@@ -219,7 +219,7 @@
|
|||||||
this.currentGroupId = group.group_id;
|
this.currentGroupId = group.group_id;
|
||||||
this.currentGroupName = group.group_name || group.group_id;
|
this.currentGroupName = group.group_name || group.group_id;
|
||||||
|
|
||||||
axios.get(`/api/robot/group/${group.group_id}/permissions`)
|
axios.get(`/robot/api/group/${group.group_id}/permissions`)
|
||||||
.then(response => {
|
.then(response => {
|
||||||
if (response.data.success) {
|
if (response.data.success) {
|
||||||
// 添加布尔值属性用于switch组件
|
// 添加布尔值属性用于switch组件
|
||||||
@@ -241,7 +241,7 @@
|
|||||||
togglePermission(permission) {
|
togglePermission(permission) {
|
||||||
const newStatus = permission.statusBool ? 'enabled' : 'disabled';
|
const newStatus = permission.statusBool ? 'enabled' : 'disabled';
|
||||||
|
|
||||||
axios.post(`/api/robot/group/${this.currentGroupId}/permissions`, {
|
axios.post(`/robot/api/group/${this.currentGroupId}/permissions`, {
|
||||||
feature_id: permission.feature_id,
|
feature_id: permission.feature_id,
|
||||||
status: newStatus
|
status: newStatus
|
||||||
})
|
})
|
||||||
@@ -269,7 +269,7 @@
|
|||||||
this.updateAllPermissions('disabled');
|
this.updateAllPermissions('disabled');
|
||||||
},
|
},
|
||||||
updateAllPermissions(status) {
|
updateAllPermissions(status) {
|
||||||
axios.post(`/api/robot/group/${this.currentGroupId}/permissions`, {
|
axios.post(`/robot/api/group/${this.currentGroupId}/permissions`, {
|
||||||
status: status
|
status: status
|
||||||
})
|
})
|
||||||
.then(response => {
|
.then(response => {
|
||||||
@@ -292,7 +292,7 @@
|
|||||||
toggleRobotStatus(group) {
|
toggleRobotStatus(group) {
|
||||||
const newStatus = group.robot_status === 'enabled' ? 'disabled' : 'enabled';
|
const newStatus = group.robot_status === 'enabled' ? 'disabled' : 'enabled';
|
||||||
|
|
||||||
axios.post(`/api/robot/group/${group.group_id}/status`, {
|
axios.post(`/robot/api/group/${group.group_id}/status`, {
|
||||||
status: newStatus
|
status: newStatus
|
||||||
})
|
})
|
||||||
.then(response => {
|
.then(response => {
|
||||||
@@ -315,7 +315,7 @@
|
|||||||
submitAddGroup() {
|
submitAddGroup() {
|
||||||
this.$refs.addGroupForm.validate(valid => {
|
this.$refs.addGroupForm.validate(valid => {
|
||||||
if (valid) {
|
if (valid) {
|
||||||
axios.post('/api/robot/group', {
|
axios.post('/robot/api/group', {
|
||||||
group_id: this.addGroupForm.groupId
|
group_id: this.addGroupForm.groupId
|
||||||
})
|
})
|
||||||
.then(response => {
|
.then(response => {
|
||||||
@@ -347,7 +347,7 @@
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
axios.post('/api/robot/batch_operation', {
|
axios.post('/robot/api/batch_operation', {
|
||||||
operation: 'update_status',
|
operation: 'update_status',
|
||||||
group_ids: this.selectedGroups,
|
group_ids: this.selectedGroups,
|
||||||
status: status
|
status: status
|
||||||
@@ -381,7 +381,7 @@
|
|||||||
cancelButtonText: '取消',
|
cancelButtonText: '取消',
|
||||||
type: 'danger'
|
type: 'danger'
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
axios.post('/api/robot/batch_operation', {
|
axios.post('/robot/api/batch_operation', {
|
||||||
operation: 'remove_groups',
|
operation: 'remove_groups',
|
||||||
group_ids: this.selectedGroups
|
group_ids: this.selectedGroups
|
||||||
})
|
})
|
||||||
@@ -408,7 +408,7 @@
|
|||||||
|
|
||||||
// 获取消息趋势数据
|
// 获取消息趋势数据
|
||||||
const days = parseInt(this.timeRange || 7);
|
const days = parseInt(this.timeRange || 7);
|
||||||
axios.get(`/api/robot/group/${group.group_id}/message_trend?days=${days}`)
|
axios.get(`/robot/api/group/${group.group_id}/message_trend?days=${days}`)
|
||||||
.then(response => {
|
.then(response => {
|
||||||
if (response.data.success) {
|
if (response.data.success) {
|
||||||
this.messageTrendData = response.data.data || { dates: [], counts: [] };
|
this.messageTrendData = response.data.data || { dates: [], counts: [] };
|
||||||
|
|||||||
Reference in New Issue
Block a user