#feature: add ip operation log & sql generator
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
<template>
|
||||
<admin-layout
|
||||
:page-title="pageTitle"
|
||||
:is-admin="isAdmin"
|
||||
@menu-change="handleMenuChange"
|
||||
>
|
||||
<!-- 环境管理页面 -->
|
||||
@@ -15,6 +16,12 @@
|
||||
ref="weeklyReport"
|
||||
/>
|
||||
|
||||
<!-- SQL 生成页面 -->
|
||||
<sql-generator
|
||||
v-else-if="currentPage === 'sql-generator'"
|
||||
ref="sqlGenerator"
|
||||
/>
|
||||
|
||||
<!-- JIRA 工时查询页面 -->
|
||||
<jira-worklog
|
||||
v-else-if="currentPage === 'worklog'"
|
||||
@@ -43,15 +50,10 @@
|
||||
<system-settings v-else-if="currentPage === 'settings'" />
|
||||
|
||||
<!-- 操作日志页面 -->
|
||||
<div v-else-if="currentPage === 'logs'" class="bg-white rounded-xl shadow-sm border border-gray-200 p-8">
|
||||
<div class="text-center py-12">
|
||||
<svg class="w-16 h-16 text-gray-300 mx-auto mb-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 17v-2m3 2v-4m3 4v-6m2 10H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"/>
|
||||
</svg>
|
||||
<h3 class="text-lg font-medium text-gray-900 mb-2">操作日志</h3>
|
||||
<p class="text-gray-500">此功能正在开发中...</p>
|
||||
</div>
|
||||
</div>
|
||||
<operation-logs v-else-if="currentPage === 'logs'" :is-admin="isAdmin" :current-ip="currentIp" />
|
||||
|
||||
<!-- IP 用户映射页面 -->
|
||||
<ip-user-mappings v-else-if="currentPage === 'ip-mappings'" />
|
||||
</admin-layout>
|
||||
</template>
|
||||
|
||||
@@ -59,11 +61,14 @@
|
||||
import AdminLayout from './AdminLayout.vue';
|
||||
import EnvManagement from '../env/EnvManagement.vue';
|
||||
import WeeklyReport from '../jira/WeeklyReport.vue';
|
||||
import SqlGenerator from '../tools/SqlGenerator.vue';
|
||||
import JiraWorklog from '../jira/JiraWorklog.vue';
|
||||
import MessageSync from '../message-sync/MessageSync.vue';
|
||||
import EventConsumerSync from '../message-sync/EventConsumerSync.vue';
|
||||
import MessageDispatch from '../message-sync/MessageDispatch.vue';
|
||||
import SystemSettings from './SystemSettings.vue';
|
||||
import OperationLogs from './OperationLogs.vue';
|
||||
import IpUserMappings from './IpUserMappings.vue';
|
||||
|
||||
export default {
|
||||
name: 'AdminDashboard',
|
||||
@@ -71,38 +76,62 @@ export default {
|
||||
AdminLayout,
|
||||
EnvManagement,
|
||||
WeeklyReport,
|
||||
SqlGenerator,
|
||||
JiraWorklog,
|
||||
MessageSync,
|
||||
EventConsumerSync,
|
||||
MessageDispatch,
|
||||
SystemSettings
|
||||
SystemSettings,
|
||||
OperationLogs,
|
||||
IpUserMappings
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
currentPage: 'env',
|
||||
pageTitle: '环境配置管理'
|
||||
pageTitle: '环境配置管理',
|
||||
isAdmin: false,
|
||||
currentIp: ''
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
console.log('AdminDashboard mounted');
|
||||
|
||||
// 根据 URL 路径设置初始页面
|
||||
async mounted() {
|
||||
await this.loadAdminMeta();
|
||||
this.setCurrentPageFromPath();
|
||||
},
|
||||
methods: {
|
||||
async loadAdminMeta() {
|
||||
try {
|
||||
const response = await fetch('/api/admin/meta');
|
||||
const data = await response.json();
|
||||
|
||||
if (data.success) {
|
||||
this.isAdmin = Boolean(data.data.is_admin);
|
||||
this.currentIp = data.data.ip || '';
|
||||
}
|
||||
} catch (error) {
|
||||
this.isAdmin = false;
|
||||
this.currentIp = '';
|
||||
}
|
||||
},
|
||||
handleMenuChange(menu) {
|
||||
if (menu === 'ip-mappings' && !this.isAdmin) {
|
||||
this.redirectToDefault();
|
||||
return;
|
||||
}
|
||||
|
||||
this.currentPage = menu;
|
||||
|
||||
// 更新页面标题
|
||||
const titles = {
|
||||
'env': '环境配置管理',
|
||||
'weekly-report': '生成周报',
|
||||
'sql-generator': '生成SQL',
|
||||
'worklog': 'JIRA 工时查询',
|
||||
'message-sync': '消息同步',
|
||||
'event-consumer-sync': '事件消费者同步对比',
|
||||
'message-dispatch': '消息分发异常查询',
|
||||
'settings': '系统设置',
|
||||
'logs': '操作日志'
|
||||
'logs': '操作日志',
|
||||
'ip-mappings': 'IP 用户映射'
|
||||
};
|
||||
|
||||
this.pageTitle = titles[menu] || '环境配置管理';
|
||||
@@ -114,6 +143,8 @@ export default {
|
||||
|
||||
if (path === '/') {
|
||||
page = 'env';
|
||||
} else if (path === '/sql-generator') {
|
||||
page = 'sql-generator';
|
||||
} else if (path === '/weekly-report') {
|
||||
page = 'weekly-report';
|
||||
} else if (path === '/worklog') {
|
||||
@@ -128,10 +159,25 @@ export default {
|
||||
page = 'settings';
|
||||
} else if (path === '/logs') {
|
||||
page = 'logs';
|
||||
} else if (path === '/ip-mappings') {
|
||||
page = 'ip-mappings';
|
||||
}
|
||||
|
||||
if (page === 'ip-mappings' && !this.isAdmin) {
|
||||
this.redirectToDefault();
|
||||
return;
|
||||
}
|
||||
|
||||
this.currentPage = page;
|
||||
this.handleMenuChange(page);
|
||||
},
|
||||
|
||||
redirectToDefault() {
|
||||
this.currentPage = 'env';
|
||||
this.pageTitle = '环境配置管理';
|
||||
if (window.location.pathname !== '/') {
|
||||
window.history.replaceState({}, '', '/');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user