feat(console): 添加控制台UI界面及功能组件
实现BLS项目控制台UI界面,包含以下主要功能: - 项目选择器组件,支持项目筛选和选择 - 控制台组件,支持命令输入和日志显示 - 调试区域组件,展示调试信息 - 响应式布局设计,适配PC和移动端 - 日志管理功能,限制最多1000条记录 - 更新路由配置和全局样式
This commit is contained in:
147
.trae/documents/plan_20260110_062839.md
Normal file
147
.trae/documents/plan_20260110_062839.md
Normal file
@@ -0,0 +1,147 @@
|
|||||||
|
# 构建完整的项目界面实施计划
|
||||||
|
|
||||||
|
## 1. 整体布局设计
|
||||||
|
|
||||||
|
### 1.1 修改App.vue布局
|
||||||
|
- 实现左侧选择区域与右侧调试区域的双栏布局
|
||||||
|
- 添加响应式设计,在移动端自动隐藏左侧选择区域
|
||||||
|
- 实现左侧选择区域的折叠/展开功能
|
||||||
|
|
||||||
|
### 1.2 响应式设计实现
|
||||||
|
- 使用CSS Media Queries实现响应式布局
|
||||||
|
- PC端:左侧选择区域固定宽度,右侧调试区域自适应
|
||||||
|
- 移动端:左侧选择区域转为下拉选择器,右侧内容区域占满屏幕宽度
|
||||||
|
|
||||||
|
## 2. 项目选择模块
|
||||||
|
|
||||||
|
### 2.1 创建项目选择组件
|
||||||
|
- 组件位置:`src/frontend/components/ProjectSelector.vue`
|
||||||
|
- 功能:
|
||||||
|
- 项目列表展示
|
||||||
|
- 项目类型筛选(后端项目/前端项目)
|
||||||
|
- 项目搜索功能
|
||||||
|
- 项目选择功能
|
||||||
|
|
||||||
|
### 2.2 项目数据模型
|
||||||
|
```javascript
|
||||||
|
{
|
||||||
|
id: string,
|
||||||
|
name: string,
|
||||||
|
type: string, // 'backend' | 'frontend'
|
||||||
|
description: string,
|
||||||
|
status: string // 'running' | 'stopped' | 'error'
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
## 3. 控制台区域
|
||||||
|
|
||||||
|
### 3.1 创建控制台组件
|
||||||
|
- 组件位置:`src/frontend/components/Console.vue`
|
||||||
|
- 功能:
|
||||||
|
- 命令输入框
|
||||||
|
- 日志显示区域
|
||||||
|
- 日志级别筛选
|
||||||
|
- 日志清理功能
|
||||||
|
- 自动滚动到最新日志
|
||||||
|
|
||||||
|
### 3.2 控制台日志管理
|
||||||
|
- 实现日志记录上限控制,最多保存1000条记录
|
||||||
|
- 达到上限时自动删除最旧的记录
|
||||||
|
- 日志数据模型:
|
||||||
|
```javascript
|
||||||
|
{
|
||||||
|
id: string,
|
||||||
|
timestamp: string,
|
||||||
|
level: string, // 'info' | 'warn' | 'error' | 'debug'
|
||||||
|
message: string
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
## 4. 调试区域管理
|
||||||
|
|
||||||
|
### 4.1 创建调试区域组件
|
||||||
|
- 组件位置:`src/frontend/components/DebugArea.vue`
|
||||||
|
- 功能:
|
||||||
|
- 调试信息展示
|
||||||
|
- 多条件筛选(时间范围、调试类型、项目名称等)
|
||||||
|
- 调试信息导出功能
|
||||||
|
|
||||||
|
### 4.2 调试信息数据模型
|
||||||
|
```javascript
|
||||||
|
{
|
||||||
|
id: string,
|
||||||
|
projectId: string,
|
||||||
|
timestamp: string,
|
||||||
|
type: string,
|
||||||
|
content: string,
|
||||||
|
metadata: object
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
## 5. 主页面整合
|
||||||
|
|
||||||
|
### 5.1 创建主页面组件
|
||||||
|
- 组件位置:`src/frontend/views/MainView.vue`
|
||||||
|
- 功能:
|
||||||
|
- 整合项目选择模块、控制台区域、调试区域
|
||||||
|
- 实现各模块间的通信
|
||||||
|
- 管理全局状态
|
||||||
|
|
||||||
|
### 5.2 更新路由配置
|
||||||
|
- 将主页面设置为默认路由
|
||||||
|
- 保持原有的日志和命令路由,或整合到主页面中
|
||||||
|
|
||||||
|
## 6. 样式设计
|
||||||
|
|
||||||
|
### 6.1 全局样式
|
||||||
|
- 设计统一的颜色方案
|
||||||
|
- 定义统一的字体和间距
|
||||||
|
- 实现主题切换功能(可选)
|
||||||
|
|
||||||
|
### 6.2 组件样式
|
||||||
|
- 为每个组件设计符合样品图的样式
|
||||||
|
- 实现悬停效果和过渡动画
|
||||||
|
- 确保移动端样式适配
|
||||||
|
|
||||||
|
## 7. 交互功能
|
||||||
|
|
||||||
|
### 7.1 项目选择交互
|
||||||
|
- 点击项目列表项选择项目
|
||||||
|
- 选择项目后更新控制台和调试区域的内容
|
||||||
|
- 支持多选项目(可选)
|
||||||
|
|
||||||
|
### 7.2 控制台交互
|
||||||
|
- 输入命令后按Enter键发送
|
||||||
|
- 支持命令历史记录
|
||||||
|
- 支持日志复制功能
|
||||||
|
|
||||||
|
### 7.3 调试区域交互
|
||||||
|
- 点击筛选条件展开/折叠筛选选项
|
||||||
|
- 支持调试信息的排序和分组
|
||||||
|
- 实现调试信息的详情查看
|
||||||
|
|
||||||
|
## 8. 测试与优化
|
||||||
|
|
||||||
|
### 8.1 功能测试
|
||||||
|
- 测试各模块的基本功能
|
||||||
|
- 测试响应式设计
|
||||||
|
- 测试日志管理功能
|
||||||
|
|
||||||
|
### 8.2 性能优化
|
||||||
|
- 优化长列表渲染性能
|
||||||
|
- 优化日志滚动性能
|
||||||
|
- 减少不必要的重新渲染
|
||||||
|
|
||||||
|
## 9. 实施步骤
|
||||||
|
|
||||||
|
1. 修改App.vue,实现基本布局结构
|
||||||
|
2. 创建项目选择组件
|
||||||
|
3. 创建控制台组件
|
||||||
|
4. 创建调试区域组件
|
||||||
|
5. 创建主页面组件,整合所有模块
|
||||||
|
6. 更新路由配置
|
||||||
|
7. 实现样式设计
|
||||||
|
8. 实现交互功能
|
||||||
|
9. 测试和优化
|
||||||
|
|
||||||
|
该计划将确保项目界面按照样品图所示效果构建,同时实现所有核心功能模块。
|
||||||
15
openspec/changes/add-console-ui/proposal.md
Normal file
15
openspec/changes/add-console-ui/proposal.md
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
# Change: Add Console UI
|
||||||
|
|
||||||
|
## Why
|
||||||
|
需要为BLS Project Console添加一个现代化的控制台界面,支持项目选择、命令输入、日志显示和调试信息展示等功能。
|
||||||
|
|
||||||
|
## What Changes
|
||||||
|
- 添加了项目选择组件,支持项目搜索和筛选
|
||||||
|
- 添加了控制台组件,支持命令输入和日志显示
|
||||||
|
- 添加了调试区域组件,支持调试信息的展示和筛选
|
||||||
|
- 实现了响应式设计,适配PC和移动端
|
||||||
|
- 实现了控制台日志管理,限制最多1000条记录
|
||||||
|
|
||||||
|
## Impact
|
||||||
|
- Affected specs: specs/logging/spec.md, specs/command/spec.md
|
||||||
|
- Affected code: src/frontend/components/, src/frontend/views/, src/frontend/router/
|
||||||
17
openspec/changes/add-console-ui/tasks.md
Normal file
17
openspec/changes/add-console-ui/tasks.md
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
## 1. Implementation
|
||||||
|
- [x] 1.1 Create ProjectSelector component for project selection
|
||||||
|
- [x] 1.2 Create Console component for command input and log display
|
||||||
|
- [x] 1.3 Create DebugArea component for debugging information display
|
||||||
|
- [x] 1.4 Create MainView component to integrate all modules
|
||||||
|
- [x] 1.5 Create SidebarView component for sidebar display
|
||||||
|
- [x] 1.6 Update App.vue to implement two-column layout
|
||||||
|
- [x] 1.7 Update router configuration to use named views
|
||||||
|
- [x] 1.8 Implement responsive design for PC and mobile devices
|
||||||
|
- [x] 1.9 Implement console log management with 1000 record limit
|
||||||
|
|
||||||
|
## 2. Urgent Fixes
|
||||||
|
- [x] 2.1 Update openspec documentation with all changes
|
||||||
|
- [x] 2.2 Fix scrolling issues in the page
|
||||||
|
- [x] 2.3 Optimize ProjectSelector by removing filter section
|
||||||
|
- [x] 2.4 Adjust layout: remove debug area and make console height adaptive
|
||||||
|
- [x] 2.5 Ensure PC right area is non-scrollable, mobile area is properly adjusted
|
||||||
@@ -7,6 +7,6 @@
|
|||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div id="app"></div>
|
<div id="app"></div>
|
||||||
<script type="module" src="/src/frontend/main.js"></script>
|
<script type="module" src="/main.js"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
@@ -1,14 +1,57 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="app-container">
|
<div class="app-container">
|
||||||
<header class="app-header">
|
<header class="app-header">
|
||||||
|
<button class="menu-toggle" @click="toggleSidebar" v-if="isMobile">
|
||||||
|
<span class="menu-icon"></span>
|
||||||
|
</button>
|
||||||
<h1>BLS Project Console</h1>
|
<h1>BLS Project Console</h1>
|
||||||
</header>
|
</header>
|
||||||
<main class="app-main">
|
<div class="app-content">
|
||||||
<router-view />
|
<!-- 左侧选择区域 -->
|
||||||
</main>
|
<aside class="sidebar" :class="{ 'sidebar-closed': !sidebarOpen && isMobile }">
|
||||||
|
<router-view name="sidebar" />
|
||||||
|
</aside>
|
||||||
|
|
||||||
|
<!-- 右侧调试区域 -->
|
||||||
|
<main class="main-content">
|
||||||
|
<router-view name="main" />
|
||||||
|
</main>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
<script setup>
|
||||||
|
import { ref, onMounted, onUnmounted } from 'vue';
|
||||||
|
|
||||||
|
const sidebarOpen = ref(true);
|
||||||
|
const isMobile = ref(false);
|
||||||
|
|
||||||
|
// 检测窗口大小变化
|
||||||
|
const checkMobile = () => {
|
||||||
|
isMobile.value = window.innerWidth < 768;
|
||||||
|
if (isMobile.value) {
|
||||||
|
sidebarOpen.value = false;
|
||||||
|
} else {
|
||||||
|
sidebarOpen.value = true;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// 切换侧边栏
|
||||||
|
const toggleSidebar = () => {
|
||||||
|
sidebarOpen.value = !sidebarOpen.value;
|
||||||
|
};
|
||||||
|
|
||||||
|
// 监听窗口大小变化
|
||||||
|
onMounted(() => {
|
||||||
|
checkMobile();
|
||||||
|
window.addEventListener('resize', checkMobile);
|
||||||
|
});
|
||||||
|
|
||||||
|
onUnmounted(() => {
|
||||||
|
window.removeEventListener('resize', checkMobile);
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
* {
|
* {
|
||||||
margin: 0;
|
margin: 0;
|
||||||
@@ -18,26 +61,148 @@
|
|||||||
|
|
||||||
body {
|
body {
|
||||||
font-family: Arial, sans-serif;
|
font-family: Arial, sans-serif;
|
||||||
background-color: #f5f5f5;
|
background-color: #121212;
|
||||||
color: #333;
|
color: #e0e0e0;
|
||||||
|
overflow: hidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
.app-container {
|
.app-container {
|
||||||
min-height: 100vh;
|
min-height: 100vh;
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
|
background-color: #1e1e1e;
|
||||||
}
|
}
|
||||||
|
|
||||||
.app-header {
|
.app-header {
|
||||||
background-color: #4285f4;
|
background-color: #008C8C;
|
||||||
color: white;
|
color: white;
|
||||||
padding: 1rem;
|
padding: 0.6rem 1rem;
|
||||||
text-align: center;
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
|
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
|
||||||
|
z-index: 100;
|
||||||
}
|
}
|
||||||
|
|
||||||
.app-main {
|
.menu-toggle {
|
||||||
|
background: none;
|
||||||
|
border: none;
|
||||||
|
color: white;
|
||||||
|
font-size: 1.2rem;
|
||||||
|
cursor: pointer;
|
||||||
|
margin-right: 1rem;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
width: 32px;
|
||||||
|
height: 32px;
|
||||||
|
border-radius: 4px;
|
||||||
|
transition: background-color 0.2s;
|
||||||
|
}
|
||||||
|
|
||||||
|
.menu-toggle:hover {
|
||||||
|
background-color: rgba(255, 255, 255, 0.1);
|
||||||
|
}
|
||||||
|
|
||||||
|
.menu-icon {
|
||||||
|
display: block;
|
||||||
|
width: 20px;
|
||||||
|
height: 2px;
|
||||||
|
background-color: white;
|
||||||
|
position: relative;
|
||||||
|
transition: background-color 0.2s;
|
||||||
|
}
|
||||||
|
|
||||||
|
.menu-icon::before,
|
||||||
|
.menu-icon::after {
|
||||||
|
content: '';
|
||||||
|
position: absolute;
|
||||||
|
width: 20px;
|
||||||
|
height: 2px;
|
||||||
|
background-color: white;
|
||||||
|
transition: transform 0.2s, top 0.2s;
|
||||||
|
}
|
||||||
|
|
||||||
|
.menu-icon::before {
|
||||||
|
top: -6px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.menu-icon::after {
|
||||||
|
top: 6px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.app-header h1 {
|
||||||
|
font-size: 1.5rem;
|
||||||
|
font-weight: 600;
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.app-content {
|
||||||
flex: 1;
|
flex: 1;
|
||||||
padding: 1rem;
|
display: flex;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 左侧选择区域 */
|
||||||
|
.sidebar {
|
||||||
|
width: 280px;
|
||||||
|
background-color: #252526;
|
||||||
|
border-right: 1px solid #3e3e42;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
transition: all 0.3s ease;
|
||||||
|
overflow-y: auto;
|
||||||
|
z-index: 50;
|
||||||
|
color: #e0e0e0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 移动端侧边栏关闭状态 */
|
||||||
|
.sidebar-closed {
|
||||||
|
width: 0;
|
||||||
|
border-right: none;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 右侧调试区域 */
|
||||||
|
.main-content {
|
||||||
|
flex: 1;
|
||||||
|
padding: 0;
|
||||||
|
overflow: hidden;
|
||||||
|
background-color: #1e1e1e;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 响应式设计 */
|
||||||
|
@media (max-width: 768px) {
|
||||||
|
.menu-toggle {
|
||||||
|
display: flex;
|
||||||
|
}
|
||||||
|
|
||||||
|
.sidebar {
|
||||||
|
position: fixed;
|
||||||
|
left: 0;
|
||||||
|
top: 60px;
|
||||||
|
height: calc(100vh - 60px);
|
||||||
|
width: 280px;
|
||||||
|
box-shadow: 2px 0 8px rgba(0, 0, 0, 0.15);
|
||||||
|
}
|
||||||
|
|
||||||
|
.sidebar-closed {
|
||||||
|
left: -280px;
|
||||||
|
width: 280px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.main-content {
|
||||||
|
padding: 0.5rem;
|
||||||
|
overflow: auto;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (min-width: 769px) {
|
||||||
|
.menu-toggle {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.sidebar {
|
||||||
|
width: 280px;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
604
src/frontend/components/Console.vue
Normal file
604
src/frontend/components/Console.vue
Normal file
@@ -0,0 +1,604 @@
|
|||||||
|
<template>
|
||||||
|
<div class="console">
|
||||||
|
<!-- 控制台控制栏 -->
|
||||||
|
<div class="console-header">
|
||||||
|
<div class="console-controls">
|
||||||
|
<!-- 日志级别筛选 -->
|
||||||
|
<div class="log-level-filter">
|
||||||
|
<label class="filter-label">日志级别:</label>
|
||||||
|
<select v-model="selectedLogLevel" class="filter-select">
|
||||||
|
<option value="all">全部</option>
|
||||||
|
<option value="info">信息</option>
|
||||||
|
<option value="warn">警告</option>
|
||||||
|
<option value="error">错误</option>
|
||||||
|
<option value="debug">调试</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- 自动滚动开关 -->
|
||||||
|
<div class="auto-scroll-toggle">
|
||||||
|
<label class="toggle-label">
|
||||||
|
<input type="checkbox" v-model="autoScroll" class="toggle-checkbox">
|
||||||
|
<span class="toggle-text">自动滚动</span>
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- 日志清理按钮 -->
|
||||||
|
<button class="clear-logs-btn" @click="clearLogs">
|
||||||
|
清空日志
|
||||||
|
</button>
|
||||||
|
|
||||||
|
<!-- 日志数量显示 -->
|
||||||
|
<div class="log-count">
|
||||||
|
{{ filteredLogs.length }} / {{ logs.length }} 条日志
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- 日志显示区域 -->
|
||||||
|
<div class="logs-container" ref="logsContainer">
|
||||||
|
<div class="log-table-wrapper" ref="logTableWrapper" @scroll="handleScroll">
|
||||||
|
<table class="log-table">
|
||||||
|
<tbody>
|
||||||
|
<tr v-for="log in filteredLogs" :key="log.id" :class="`log-item log-level-${log.level}`">
|
||||||
|
<td class="log-meta">
|
||||||
|
<div class="log-timestamp">{{ formatTimestamp(log.timestamp) }}</div>
|
||||||
|
<div class="log-level-badge" :class="`level-${log.level}`">
|
||||||
|
{{ log.level.toUpperCase() }}
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
<td class="log-message">{{ log.message }}</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- 空状态 -->
|
||||||
|
<div class="empty-logs" v-if="filteredLogs.length === 0">
|
||||||
|
<p>暂无日志记录</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- 命令输入区域 -->
|
||||||
|
<div class="command-input-container">
|
||||||
|
<div class="command-prompt">$</div>
|
||||||
|
<input type="text" v-model="commandInput" class="command-input" placeholder="输入命令..." @keydown.enter="sendCommand"
|
||||||
|
ref="commandInputRef" autocomplete="off">
|
||||||
|
<button class="send-command-btn" @click="sendCommand">
|
||||||
|
发送
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup>
|
||||||
|
import { ref, computed, watch, onMounted } from 'vue';
|
||||||
|
|
||||||
|
// 控制台配置
|
||||||
|
const MAX_LOGS = 1000;
|
||||||
|
|
||||||
|
// 响应式状态
|
||||||
|
const logs = ref([]);
|
||||||
|
const commandInput = ref('');
|
||||||
|
const selectedLogLevel = ref('all');
|
||||||
|
const autoScroll = ref(true);
|
||||||
|
const logsContainer = ref(null);
|
||||||
|
const logTableWrapper = ref(null);
|
||||||
|
const commandInputRef = ref(null);
|
||||||
|
const isAtBottom = ref(true);
|
||||||
|
|
||||||
|
// 计算过滤后的日志
|
||||||
|
const filteredLogs = computed(() => {
|
||||||
|
if (selectedLogLevel.value === 'all') {
|
||||||
|
return logs.value;
|
||||||
|
}
|
||||||
|
return logs.value.filter(log => log.level === selectedLogLevel.value);
|
||||||
|
});
|
||||||
|
|
||||||
|
// 模拟发送命令
|
||||||
|
const sendCommand = () => {
|
||||||
|
if (!commandInput.value.trim()) return;
|
||||||
|
|
||||||
|
const content = commandInput.value.trim();
|
||||||
|
|
||||||
|
// 记录命令日志
|
||||||
|
addLog({
|
||||||
|
level: 'info',
|
||||||
|
message: `$ ${content}`
|
||||||
|
});
|
||||||
|
|
||||||
|
// 发送后立即强制滚动到表格底部,确保输入框和最新日志可见
|
||||||
|
if (logTableWrapper.value) {
|
||||||
|
setTimeout(() => {
|
||||||
|
logTableWrapper.value.scrollTop = logTableWrapper.value.scrollHeight;
|
||||||
|
}, 60);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 模拟命令执行结果
|
||||||
|
setTimeout(() => {
|
||||||
|
addLog({
|
||||||
|
level: 'info',
|
||||||
|
message: `执行命令: ${content}`
|
||||||
|
});
|
||||||
|
|
||||||
|
// 模拟不同类型的日志输出
|
||||||
|
const logTypes = ['info', 'warn', 'error', 'debug'];
|
||||||
|
const randomLogType = logTypes[Math.floor(Math.random() * logTypes.length)];
|
||||||
|
addLog({
|
||||||
|
level: randomLogType,
|
||||||
|
message: `命令执行${randomLogType === 'error' ? '失败' : '成功'}: 这是一条${randomLogType}日志`
|
||||||
|
});
|
||||||
|
|
||||||
|
// 响应完成后再次确保滚动到表格底部
|
||||||
|
if (logTableWrapper.value) {
|
||||||
|
setTimeout(() => {
|
||||||
|
logTableWrapper.value.scrollTop = logTableWrapper.value.scrollHeight;
|
||||||
|
}, 60);
|
||||||
|
}
|
||||||
|
}, 500);
|
||||||
|
|
||||||
|
// 清空命令输入
|
||||||
|
commandInput.value = '';
|
||||||
|
|
||||||
|
// 保持输入框焦点
|
||||||
|
if (commandInputRef.value) {
|
||||||
|
commandInputRef.value.focus();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// 添加日志
|
||||||
|
const addLog = (logData) => {
|
||||||
|
const newLog = {
|
||||||
|
id: `log-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`,
|
||||||
|
timestamp: new Date().toISOString(),
|
||||||
|
...logData
|
||||||
|
};
|
||||||
|
|
||||||
|
// 添加新日志
|
||||||
|
logs.value.push(newLog);
|
||||||
|
|
||||||
|
// 检查日志数量是否超过上限
|
||||||
|
if (logs.value.length > MAX_LOGS) {
|
||||||
|
// 删除最旧的日志
|
||||||
|
logs.value.splice(0, logs.value.length - MAX_LOGS);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 自动滚动到底部(如果启用了自动滚动且用户在底部)
|
||||||
|
if (autoScroll.value && isAtBottom.value && logTableWrapper.value) {
|
||||||
|
setTimeout(() => {
|
||||||
|
logTableWrapper.value.scrollTop = logTableWrapper.value.scrollHeight;
|
||||||
|
}, 50);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// 清空日志
|
||||||
|
const clearLogs = () => {
|
||||||
|
logs.value = [];
|
||||||
|
};
|
||||||
|
|
||||||
|
// 格式化时间戳
|
||||||
|
const formatTimestamp = (timestamp) => {
|
||||||
|
const date = new Date(timestamp);
|
||||||
|
return date.toLocaleTimeString('zh-CN', {
|
||||||
|
hour12: false,
|
||||||
|
hour: '2-digit',
|
||||||
|
minute: '2-digit',
|
||||||
|
second: '2-digit',
|
||||||
|
fractionalSecondDigits: 3
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
// 处理滚动事件,检测用户是否在底部
|
||||||
|
const handleScroll = () => {
|
||||||
|
const el = logTableWrapper.value;
|
||||||
|
if (!el) return;
|
||||||
|
|
||||||
|
const { scrollTop, scrollHeight, clientHeight } = el;
|
||||||
|
// 当表格滚动到底部附近(10px以内)时,认为用户在底部
|
||||||
|
isAtBottom.value = scrollTop + clientHeight >= scrollHeight - 10;
|
||||||
|
};
|
||||||
|
|
||||||
|
// 监听过滤后的日志变化,自动滚动(如果启用)
|
||||||
|
watch(filteredLogs, () => {
|
||||||
|
if (autoScroll.value && isAtBottom.value && logsContainer.value) {
|
||||||
|
setTimeout(() => {
|
||||||
|
logsContainer.value.scrollTop = logsContainer.value.scrollHeight;
|
||||||
|
}, 50);
|
||||||
|
}
|
||||||
|
}, { deep: true });
|
||||||
|
|
||||||
|
// 初始化模拟日志
|
||||||
|
onMounted(() => {
|
||||||
|
// 添加一些初始日志
|
||||||
|
for (let i = 0; i < 10; i++) {
|
||||||
|
const logTypes = ['info', 'warn', 'error', 'debug'];
|
||||||
|
const randomLogType = logTypes[Math.floor(Math.random() * logTypes.length)];
|
||||||
|
addLog({
|
||||||
|
level: randomLogType,
|
||||||
|
message: `初始化日志 ${i + 1}: 这是一条${randomLogType}日志,用于测试控制台功能。`
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// 保持命令输入框焦点
|
||||||
|
if (commandInputRef.value) {
|
||||||
|
commandInputRef.value.focus();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.console {
|
||||||
|
background-color: #1e1e1e;
|
||||||
|
border-radius: 0;
|
||||||
|
box-shadow: none;
|
||||||
|
overflow: hidden;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
height: 100%;
|
||||||
|
min-height: 0;
|
||||||
|
color: #d4d4d4;
|
||||||
|
font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
|
||||||
|
font-size: 0.9rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 控制台标题和控制栏 */
|
||||||
|
.console-header {
|
||||||
|
background-color: #252526;
|
||||||
|
padding: 0.8rem 1rem;
|
||||||
|
border-bottom: 1px solid #3e3e42;
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
align-items: center;
|
||||||
|
flex-shrink: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.console-header h2 {
|
||||||
|
font-size: 1.2rem;
|
||||||
|
font-weight: 600;
|
||||||
|
margin: 0;
|
||||||
|
color: #fff;
|
||||||
|
}
|
||||||
|
|
||||||
|
.console-controls {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 1rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 日志级别筛选 */
|
||||||
|
.log-level-filter {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 0.5rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.filter-label {
|
||||||
|
font-size: 0.85rem;
|
||||||
|
color: #969696;
|
||||||
|
}
|
||||||
|
|
||||||
|
.filter-select {
|
||||||
|
background-color: #3c3c3c;
|
||||||
|
color: #d4d4d4;
|
||||||
|
border: 1px solid #555;
|
||||||
|
border-radius: 3px;
|
||||||
|
padding: 0.3rem 0.5rem;
|
||||||
|
font-size: 0.85rem;
|
||||||
|
cursor: pointer;
|
||||||
|
transition: all 0.2s;
|
||||||
|
}
|
||||||
|
|
||||||
|
.filter-select:focus {
|
||||||
|
outline: none;
|
||||||
|
border-color: #0078d4;
|
||||||
|
box-shadow: 0 0 0 2px rgba(0, 120, 212, 0.2);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 自动滚动开关 */
|
||||||
|
.auto-scroll-toggle {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.toggle-label {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 0.5rem;
|
||||||
|
cursor: pointer;
|
||||||
|
font-size: 0.85rem;
|
||||||
|
color: #969696;
|
||||||
|
transition: color 0.2s;
|
||||||
|
}
|
||||||
|
|
||||||
|
.toggle-label:hover {
|
||||||
|
color: #d4d4d4;
|
||||||
|
}
|
||||||
|
|
||||||
|
.toggle-checkbox {
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 日志清理按钮 */
|
||||||
|
.clear-logs-btn {
|
||||||
|
background-color: #3c3c3c;
|
||||||
|
color: #d4d4d4;
|
||||||
|
border: 1px solid #555;
|
||||||
|
border-radius: 3px;
|
||||||
|
padding: 0.3rem 0.8rem;
|
||||||
|
font-size: 0.85rem;
|
||||||
|
cursor: pointer;
|
||||||
|
transition: all 0.2s;
|
||||||
|
}
|
||||||
|
|
||||||
|
.clear-logs-btn:hover {
|
||||||
|
background-color: #4a4a4a;
|
||||||
|
border-color: #666;
|
||||||
|
}
|
||||||
|
|
||||||
|
.clear-logs-btn:active {
|
||||||
|
background-color: #555;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 日志数量显示 */
|
||||||
|
.log-count {
|
||||||
|
font-size: 0.8rem;
|
||||||
|
color: #969696;
|
||||||
|
margin-left: 0.5rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 日志显示区域 */
|
||||||
|
.logs-container {
|
||||||
|
flex: 1;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
overflow: hidden;
|
||||||
|
padding: 1rem;
|
||||||
|
background-color: #000000;
|
||||||
|
line-height: 1.5;
|
||||||
|
scroll-behavior: smooth;
|
||||||
|
min-height: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.log-table-wrapper {
|
||||||
|
flex: 1;
|
||||||
|
min-height: 0;
|
||||||
|
overflow-y: auto;
|
||||||
|
overflow-x: hidden;
|
||||||
|
/* 兜底:当父容器高度不受约束时,限制日志区域最大高度,避免把输入框顶出视口 */
|
||||||
|
max-height: min(80vh, calc(100dvh - 240px));
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 日志表格 */
|
||||||
|
.log-table {
|
||||||
|
width: 100%;
|
||||||
|
border-collapse: collapse;
|
||||||
|
table-layout: fixed;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 日志项 */
|
||||||
|
.log-item {
|
||||||
|
border-bottom: 1px solid rgba(255, 255, 255, 0.12);
|
||||||
|
/* 浅灰色分割线 */
|
||||||
|
}
|
||||||
|
|
||||||
|
.log-item:last-child {
|
||||||
|
border-bottom: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.log-meta {
|
||||||
|
vertical-align: top;
|
||||||
|
padding: 0.1rem 0.2rem 0.1rem 0;
|
||||||
|
white-space: nowrap;
|
||||||
|
width: 120px;
|
||||||
|
min-width: 120px;
|
||||||
|
max-width: 120px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.log-timestamp {
|
||||||
|
color: #608b4e;
|
||||||
|
font-size: 0.8rem;
|
||||||
|
margin-bottom: 0.2rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.log-level-badge {
|
||||||
|
color: #fff;
|
||||||
|
font-size: 0.7rem;
|
||||||
|
font-weight: 600;
|
||||||
|
padding: 0.1rem 0.5rem;
|
||||||
|
border-radius: 10px;
|
||||||
|
text-transform: uppercase;
|
||||||
|
min-width: 60px;
|
||||||
|
text-align: center;
|
||||||
|
display: inline-block;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 日志级别样式 */
|
||||||
|
.log-level-info .log-level-badge.level-info {
|
||||||
|
background-color: #0078d4;
|
||||||
|
}
|
||||||
|
|
||||||
|
.log-level-warn .log-level-badge.level-warn {
|
||||||
|
background-color: #d7ba7d;
|
||||||
|
color: #000;
|
||||||
|
}
|
||||||
|
|
||||||
|
.log-level-error .log-level-badge.level-error {
|
||||||
|
background-color: #f14c4c;
|
||||||
|
}
|
||||||
|
|
||||||
|
.log-level-debug .log-level-badge.level-debug {
|
||||||
|
background-color: #569cd6;
|
||||||
|
}
|
||||||
|
|
||||||
|
.log-message {
|
||||||
|
vertical-align: top;
|
||||||
|
padding: 0.1rem 0;
|
||||||
|
word-break: break-word;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 响应式日志布局 */
|
||||||
|
@media (max-width: 768px) {
|
||||||
|
.log-meta {
|
||||||
|
width: 120px;
|
||||||
|
min-width: 120px;
|
||||||
|
max-width: 120px;
|
||||||
|
padding-right: 0.5rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.log-timestamp {
|
||||||
|
font-size: 0.75rem;
|
||||||
|
margin-bottom: 0.1rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.log-level-badge {
|
||||||
|
min-width: 50px;
|
||||||
|
font-size: 0.65rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 移动端:比默认再小 10px */
|
||||||
|
.log-table-wrapper {
|
||||||
|
max-height: min(70vh, calc(100dvh - 200px));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 空状态 */
|
||||||
|
.empty-logs {
|
||||||
|
text-align: center;
|
||||||
|
padding: 2rem 0;
|
||||||
|
color: #666;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 命令输入区域 */
|
||||||
|
.command-input-container {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
background-color: #2d2d2d;
|
||||||
|
border-top: 1px solid #3e3e42;
|
||||||
|
padding: 0.8rem 1rem;
|
||||||
|
flex-shrink: 0;
|
||||||
|
width: 100%;
|
||||||
|
box-sizing: border-box;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
.command-prompt {
|
||||||
|
color: #34a853;
|
||||||
|
font-weight: 600;
|
||||||
|
margin-right: 0.5rem;
|
||||||
|
flex-shrink: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.command-input {
|
||||||
|
flex: 1;
|
||||||
|
background-color: transparent;
|
||||||
|
color: #d4d4d4;
|
||||||
|
border: none;
|
||||||
|
outline: none;
|
||||||
|
font-family: inherit;
|
||||||
|
font-size: 0.9rem;
|
||||||
|
padding: 0.3rem 0;
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
.command-input::placeholder {
|
||||||
|
color: #666;
|
||||||
|
}
|
||||||
|
|
||||||
|
.send-command-btn {
|
||||||
|
background-color: #0078d4;
|
||||||
|
color: white;
|
||||||
|
border: none;
|
||||||
|
border-radius: 3px;
|
||||||
|
padding: 0.4rem 1rem;
|
||||||
|
font-size: 0.85rem;
|
||||||
|
cursor: pointer;
|
||||||
|
margin-left: 1rem;
|
||||||
|
transition: background-color 0.2s;
|
||||||
|
flex-shrink: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.send-command-btn:hover {
|
||||||
|
background-color: #106ebe;
|
||||||
|
}
|
||||||
|
|
||||||
|
.send-command-btn:active {
|
||||||
|
background-color: #005a9e;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 滚动条样式 */
|
||||||
|
.logs-container::-webkit-scrollbar {
|
||||||
|
width: 8px;
|
||||||
|
height: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.logs-container::-webkit-scrollbar-track {
|
||||||
|
background: #1e1e1e;
|
||||||
|
}
|
||||||
|
|
||||||
|
.logs-container::-webkit-scrollbar-thumb {
|
||||||
|
background: #424242;
|
||||||
|
border-radius: 4px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.logs-container::-webkit-scrollbar-thumb:hover {
|
||||||
|
background: #4e4e4e;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 响应式设计 */
|
||||||
|
@media (max-width: 768px) {
|
||||||
|
.console {
|
||||||
|
min-height: 300px;
|
||||||
|
font-size: 0.8rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.console-header {
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: flex-start;
|
||||||
|
gap: 0.8rem;
|
||||||
|
padding: 0.8rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.console-controls {
|
||||||
|
width: 100%;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
gap: 0.5rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.log-level-filter,
|
||||||
|
.auto-scroll-toggle,
|
||||||
|
.clear-logs-btn,
|
||||||
|
.log-count {
|
||||||
|
font-size: 0.8rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.logs-container {
|
||||||
|
padding: 0.5rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.log-timestamp {
|
||||||
|
min-width: 105px;
|
||||||
|
font-size: 0.75rem;
|
||||||
|
margin-right: 0.5rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.log-level-badge {
|
||||||
|
min-width: 50px;
|
||||||
|
font-size: 0.65rem;
|
||||||
|
margin-right: 0.5rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.command-input-container {
|
||||||
|
padding: 0.6rem 0.8rem;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (min-width: 769px) {
|
||||||
|
|
||||||
|
/* 桌面端:比默认再小 100px */
|
||||||
|
.log-table-wrapper {
|
||||||
|
max-height: min(80vh, calc(100dvh - 200px));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
892
src/frontend/components/DebugArea.vue
Normal file
892
src/frontend/components/DebugArea.vue
Normal file
@@ -0,0 +1,892 @@
|
|||||||
|
<template>
|
||||||
|
<div class="debug-area">
|
||||||
|
<!-- 调试区域标题和控制栏 -->
|
||||||
|
<div class="debug-header">
|
||||||
|
<h2>调试区域</h2>
|
||||||
|
<div class="debug-controls">
|
||||||
|
<button class="export-btn" @click="exportDebugInfo">
|
||||||
|
导出调试信息
|
||||||
|
</button>
|
||||||
|
<button class="refresh-btn" @click="refreshDebugInfo">
|
||||||
|
刷新数据
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- 筛选条件区域 -->
|
||||||
|
<div class="filters-container">
|
||||||
|
<div class="filter-group">
|
||||||
|
<div class="filter-item">
|
||||||
|
<label class="filter-label">项目名称</label>
|
||||||
|
<select v-model="selectedProjectId" class="filter-select">
|
||||||
|
<option value="all">全部项目</option>
|
||||||
|
<option
|
||||||
|
v-for="project in projects"
|
||||||
|
:key="project.id"
|
||||||
|
:value="project.id"
|
||||||
|
>
|
||||||
|
{{ project.name }}
|
||||||
|
</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="filter-item">
|
||||||
|
<label class="filter-label">调试类型</label>
|
||||||
|
<select v-model="selectedDebugType" class="filter-select">
|
||||||
|
<option value="all">全部类型</option>
|
||||||
|
<option value="api">API请求</option>
|
||||||
|
<option value="database">数据库操作</option>
|
||||||
|
<option value="cache">缓存操作</option>
|
||||||
|
<option value="error">错误信息</option>
|
||||||
|
<option value="performance">性能监控</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="filter-group">
|
||||||
|
<div class="filter-item">
|
||||||
|
<label class="filter-label">时间范围</label>
|
||||||
|
<div class="date-range">
|
||||||
|
<input
|
||||||
|
type="datetime-local"
|
||||||
|
v-model="startTime"
|
||||||
|
class="date-input"
|
||||||
|
>
|
||||||
|
<span class="date-separator">至</span>
|
||||||
|
<input
|
||||||
|
type="datetime-local"
|
||||||
|
v-model="endTime"
|
||||||
|
class="date-input"
|
||||||
|
>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="filter-actions">
|
||||||
|
<button class="apply-filters-btn" @click="applyFilters">
|
||||||
|
应用筛选
|
||||||
|
</button>
|
||||||
|
<button class="reset-filters-btn" @click="resetFilters">
|
||||||
|
重置筛选
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- 调试信息展示区域 -->
|
||||||
|
<div class="debug-content">
|
||||||
|
<!-- 调试信息列表 -->
|
||||||
|
<div class="debug-list">
|
||||||
|
<div
|
||||||
|
class="debug-item"
|
||||||
|
v-for="item in filteredDebugInfo"
|
||||||
|
:key="item.id"
|
||||||
|
:class="`debug-type-${item.type}`"
|
||||||
|
>
|
||||||
|
<div class="debug-item-header">
|
||||||
|
<div class="debug-type-badge" :class="`type-${item.type}`">
|
||||||
|
{{ getTypeText(item.type) }}
|
||||||
|
</div>
|
||||||
|
<div class="debug-timestamp">{{ formatTimestamp(item.timestamp) }}</div>
|
||||||
|
<div class="debug-project">
|
||||||
|
{{ getProjectName(item.projectId) }}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="debug-item-content">
|
||||||
|
<div class="debug-content-main">{{ item.content }}</div>
|
||||||
|
|
||||||
|
<!-- 调试元数据 -->
|
||||||
|
<div class="debug-metadata" v-if="Object.keys(item.metadata).length > 0">
|
||||||
|
<h4>元数据</h4>
|
||||||
|
<div class="metadata-list">
|
||||||
|
<div
|
||||||
|
class="metadata-item"
|
||||||
|
v-for="(value, key) in item.metadata"
|
||||||
|
:key="key"
|
||||||
|
>
|
||||||
|
<span class="metadata-key">{{ key }}:</span>
|
||||||
|
<span class="metadata-value">{{ JSON.stringify(value) }}</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- 展开/折叠按钮 -->
|
||||||
|
<div
|
||||||
|
class="expand-btn"
|
||||||
|
@click="toggleExpand(item.id)"
|
||||||
|
:class="{ 'expanded': expandedItems.includes(item.id) }"
|
||||||
|
>
|
||||||
|
<span class="expand-icon">
|
||||||
|
{{ expandedItems.includes(item.id) ? '▼' : '▶' }}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- 空状态 -->
|
||||||
|
<div class="empty-state" v-if="filteredDebugInfo.length === 0">
|
||||||
|
<p>没有找到匹配的调试信息</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- 分页控件 -->
|
||||||
|
<div class="pagination" v-if="totalPages > 1">
|
||||||
|
<button
|
||||||
|
class="page-btn"
|
||||||
|
@click="currentPage = 1"
|
||||||
|
:disabled="currentPage === 1"
|
||||||
|
>
|
||||||
|
首页
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
class="page-btn"
|
||||||
|
@click="currentPage--"
|
||||||
|
:disabled="currentPage === 1"
|
||||||
|
>
|
||||||
|
上一页
|
||||||
|
</button>
|
||||||
|
|
||||||
|
<div class="page-info">
|
||||||
|
第 {{ currentPage }} / {{ totalPages }} 页
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<button
|
||||||
|
class="page-btn"
|
||||||
|
@click="currentPage++"
|
||||||
|
:disabled="currentPage === totalPages"
|
||||||
|
>
|
||||||
|
下一页
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
class="page-btn"
|
||||||
|
@click="currentPage = totalPages"
|
||||||
|
:disabled="currentPage === totalPages"
|
||||||
|
>
|
||||||
|
末页
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup>
|
||||||
|
import { ref, computed, onMounted } from 'vue';
|
||||||
|
|
||||||
|
// 模拟项目数据
|
||||||
|
const projects = ref([
|
||||||
|
{ id: 'proj-1', name: '用户管理系统', type: 'backend' },
|
||||||
|
{ id: 'proj-2', name: '数据可视化平台', type: 'frontend' },
|
||||||
|
{ id: 'proj-3', name: '订单处理系统', type: 'backend' },
|
||||||
|
{ id: 'proj-4', name: '移动端应用', type: 'frontend' },
|
||||||
|
{ id: 'proj-5', name: 'API网关', type: 'backend' },
|
||||||
|
{ id: 'proj-6', name: '管理后台', type: 'frontend' }
|
||||||
|
]);
|
||||||
|
|
||||||
|
// 筛选条件
|
||||||
|
const selectedProjectId = ref('all');
|
||||||
|
const selectedDebugType = ref('all');
|
||||||
|
const startTime = ref('');
|
||||||
|
const endTime = ref('');
|
||||||
|
const expandedItems = ref([]);
|
||||||
|
|
||||||
|
// 分页设置
|
||||||
|
const currentPage = ref(1);
|
||||||
|
const pageSize = ref(10);
|
||||||
|
|
||||||
|
// 模拟调试信息数据
|
||||||
|
const debugInfo = ref([]);
|
||||||
|
|
||||||
|
// 初始化模拟数据
|
||||||
|
const initDebugData = () => {
|
||||||
|
const types = ['api', 'database', 'cache', 'error', 'performance'];
|
||||||
|
const newDebugInfo = [];
|
||||||
|
|
||||||
|
// 生成50条模拟数据
|
||||||
|
for (let i = 0; i < 50; i++) {
|
||||||
|
const type = types[Math.floor(Math.random() * types.length)];
|
||||||
|
const projectId = projects.value[Math.floor(Math.random() * projects.value.length)].id;
|
||||||
|
const timestamp = new Date(Date.now() - Math.random() * 3600000 * 24).toISOString();
|
||||||
|
|
||||||
|
// 根据类型生成不同的内容
|
||||||
|
let content = '';
|
||||||
|
let metadata = {};
|
||||||
|
|
||||||
|
switch (type) {
|
||||||
|
case 'api':
|
||||||
|
content = `API请求: GET /api/users/${i + 1}`;
|
||||||
|
metadata = {
|
||||||
|
status: Math.random() > 0.1 ? 200 : 404,
|
||||||
|
responseTime: Math.floor(Math.random() * 500) + 50,
|
||||||
|
ip: `192.168.1.${Math.floor(Math.random() * 255)}`
|
||||||
|
};
|
||||||
|
break;
|
||||||
|
case 'database':
|
||||||
|
content = `数据库操作: SELECT * FROM users WHERE id = ${i + 1}`;
|
||||||
|
metadata = {
|
||||||
|
queryTime: Math.floor(Math.random() * 100) + 10,
|
||||||
|
rowsAffected: Math.floor(Math.random() * 10) + 1,
|
||||||
|
table: 'users'
|
||||||
|
};
|
||||||
|
break;
|
||||||
|
case 'cache':
|
||||||
|
content = `缓存操作: SET user:${i + 1} = {id: ${i + 1}, name: 'User ${i + 1}'}`;
|
||||||
|
metadata = {
|
||||||
|
cacheKey: `user:${i + 1}`,
|
||||||
|
cacheType: Math.random() > 0.5 ? 'redis' : 'memcached',
|
||||||
|
ttl: 3600
|
||||||
|
};
|
||||||
|
break;
|
||||||
|
case 'error':
|
||||||
|
content = `错误信息: Error: Cannot read property 'name' of undefined`;
|
||||||
|
metadata = {
|
||||||
|
errorType: 'TypeError',
|
||||||
|
stackTrace: [
|
||||||
|
'at Object.<anonymous> (/app/src/index.js:10:20)',
|
||||||
|
'at Module._compile (internal/modules/cjs/loader.js:1085:14)',
|
||||||
|
'at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)'
|
||||||
|
],
|
||||||
|
severity: 'high'
|
||||||
|
};
|
||||||
|
break;
|
||||||
|
case 'performance':
|
||||||
|
content = `性能监控: 页面加载时间: ${Math.floor(Math.random() * 2000) + 500}ms`;
|
||||||
|
metadata = {
|
||||||
|
metric: 'pageLoadTime',
|
||||||
|
value: Math.floor(Math.random() * 2000) + 500,
|
||||||
|
threshold: 1500,
|
||||||
|
status: Math.random() > 0.3 ? 'warning' : 'ok'
|
||||||
|
};
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
newDebugInfo.push({
|
||||||
|
id: `debug-${Date.now()}-${i}`,
|
||||||
|
projectId,
|
||||||
|
timestamp,
|
||||||
|
type,
|
||||||
|
content,
|
||||||
|
metadata
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// 按时间降序排序
|
||||||
|
debugInfo.value = newDebugInfo.sort((a, b) =>
|
||||||
|
new Date(b.timestamp) - new Date(a.timestamp)
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
// 计算过滤后的调试信息
|
||||||
|
const filteredDebugInfo = computed(() => {
|
||||||
|
let result = [...debugInfo.value];
|
||||||
|
|
||||||
|
// 按项目筛选
|
||||||
|
if (selectedProjectId.value !== 'all') {
|
||||||
|
result = result.filter(item => item.projectId === selectedProjectId.value);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 按调试类型筛选
|
||||||
|
if (selectedDebugType.value !== 'all') {
|
||||||
|
result = result.filter(item => item.type === selectedDebugType.value);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 按时间范围筛选
|
||||||
|
if (startTime.value) {
|
||||||
|
const startDate = new Date(startTime.value);
|
||||||
|
result = result.filter(item => new Date(item.timestamp) >= startDate);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (endTime.value) {
|
||||||
|
const endDate = new Date(endTime.value);
|
||||||
|
result = result.filter(item => new Date(item.timestamp) <= endDate);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 分页处理
|
||||||
|
const startIndex = (currentPage.value - 1) * pageSize.value;
|
||||||
|
const endIndex = startIndex + pageSize.value;
|
||||||
|
|
||||||
|
return result.slice(startIndex, endIndex);
|
||||||
|
});
|
||||||
|
|
||||||
|
// 计算总页数
|
||||||
|
const totalPages = computed(() => {
|
||||||
|
let result = [...debugInfo.value];
|
||||||
|
|
||||||
|
// 应用相同的过滤条件来计算总条数
|
||||||
|
if (selectedProjectId.value !== 'all') {
|
||||||
|
result = result.filter(item => item.projectId === selectedProjectId.value);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (selectedDebugType.value !== 'all') {
|
||||||
|
result = result.filter(item => item.type === selectedDebugType.value);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (startTime.value) {
|
||||||
|
const startDate = new Date(startTime.value);
|
||||||
|
result = result.filter(item => new Date(item.timestamp) >= startDate);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (endTime.value) {
|
||||||
|
const endDate = new Date(endTime.value);
|
||||||
|
result = result.filter(item => new Date(item.timestamp) <= endDate);
|
||||||
|
}
|
||||||
|
|
||||||
|
return Math.ceil(result.length / pageSize.value);
|
||||||
|
});
|
||||||
|
|
||||||
|
// 应用筛选
|
||||||
|
const applyFilters = () => {
|
||||||
|
// 重置到第一页
|
||||||
|
currentPage.value = 1;
|
||||||
|
console.log('应用筛选条件');
|
||||||
|
};
|
||||||
|
|
||||||
|
// 重置筛选
|
||||||
|
const resetFilters = () => {
|
||||||
|
selectedProjectId.value = 'all';
|
||||||
|
selectedDebugType.value = 'all';
|
||||||
|
startTime.value = '';
|
||||||
|
endTime.value = '';
|
||||||
|
currentPage.value = 1;
|
||||||
|
console.log('重置筛选条件');
|
||||||
|
};
|
||||||
|
|
||||||
|
// 刷新调试信息
|
||||||
|
const refreshDebugInfo = () => {
|
||||||
|
console.log('刷新调试信息');
|
||||||
|
initDebugData();
|
||||||
|
};
|
||||||
|
|
||||||
|
// 导出调试信息
|
||||||
|
const exportDebugInfo = () => {
|
||||||
|
console.log('导出调试信息');
|
||||||
|
// 这里可以实现导出功能,例如导出为JSON或CSV文件
|
||||||
|
const dataToExport = {
|
||||||
|
exportTime: new Date().toISOString(),
|
||||||
|
filterConditions: {
|
||||||
|
selectedProjectId: selectedProjectId.value,
|
||||||
|
selectedDebugType: selectedDebugType.value,
|
||||||
|
startTime: startTime.value,
|
||||||
|
endTime: endTime.value
|
||||||
|
},
|
||||||
|
debugInfo: filteredDebugInfo.value
|
||||||
|
};
|
||||||
|
|
||||||
|
// 创建下载链接
|
||||||
|
const blob = new Blob([JSON.stringify(dataToExport, null, 2)], { type: 'application/json' });
|
||||||
|
const url = URL.createObjectURL(blob);
|
||||||
|
const a = document.createElement('a');
|
||||||
|
a.href = url;
|
||||||
|
a.download = `debug-info-${new Date().toISOString().slice(0, 10)}.json`;
|
||||||
|
document.body.appendChild(a);
|
||||||
|
a.click();
|
||||||
|
document.body.removeChild(a);
|
||||||
|
URL.revokeObjectURL(url);
|
||||||
|
};
|
||||||
|
|
||||||
|
// 切换展开/折叠状态
|
||||||
|
const toggleExpand = (id) => {
|
||||||
|
const index = expandedItems.value.indexOf(id);
|
||||||
|
if (index === -1) {
|
||||||
|
expandedItems.value.push(id);
|
||||||
|
} else {
|
||||||
|
expandedItems.value.splice(index, 1);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// 获取项目名称
|
||||||
|
const getProjectName = (projectId) => {
|
||||||
|
const project = projects.value.find(p => p.id === projectId);
|
||||||
|
return project ? project.name : '未知项目';
|
||||||
|
};
|
||||||
|
|
||||||
|
// 获取调试类型文本
|
||||||
|
const getTypeText = (type) => {
|
||||||
|
const typeMap = {
|
||||||
|
api: 'API请求',
|
||||||
|
database: '数据库操作',
|
||||||
|
cache: '缓存操作',
|
||||||
|
error: '错误信息',
|
||||||
|
performance: '性能监控'
|
||||||
|
};
|
||||||
|
return typeMap[type] || type;
|
||||||
|
};
|
||||||
|
|
||||||
|
// 格式化时间戳
|
||||||
|
const formatTimestamp = (timestamp) => {
|
||||||
|
const date = new Date(timestamp);
|
||||||
|
return date.toLocaleString('zh-CN', {
|
||||||
|
year: 'numeric',
|
||||||
|
month: '2-digit',
|
||||||
|
day: '2-digit',
|
||||||
|
hour: '2-digit',
|
||||||
|
minute: '2-digit',
|
||||||
|
second: '2-digit'
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
// 组件挂载时初始化数据
|
||||||
|
onMounted(() => {
|
||||||
|
initDebugData();
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.debug-area {
|
||||||
|
background-color: white;
|
||||||
|
border-radius: 8px;
|
||||||
|
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
|
||||||
|
overflow: hidden;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
height: 100%;
|
||||||
|
min-height: 500px;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 调试区域标题和控制栏 */
|
||||||
|
.debug-header {
|
||||||
|
background-color: #f8f9fa;
|
||||||
|
padding: 1rem;
|
||||||
|
border-bottom: 1px solid #e0e0e0;
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
align-items: center;
|
||||||
|
flex-shrink: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.debug-header h2 {
|
||||||
|
font-size: 1.2rem;
|
||||||
|
font-weight: 600;
|
||||||
|
margin: 0;
|
||||||
|
color: #333;
|
||||||
|
}
|
||||||
|
|
||||||
|
.debug-controls {
|
||||||
|
display: flex;
|
||||||
|
gap: 0.8rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.export-btn,
|
||||||
|
.refresh-btn {
|
||||||
|
padding: 0.5rem 1rem;
|
||||||
|
border: 1px solid #e0e0e0;
|
||||||
|
border-radius: 4px;
|
||||||
|
font-size: 0.85rem;
|
||||||
|
cursor: pointer;
|
||||||
|
transition: all 0.2s;
|
||||||
|
}
|
||||||
|
|
||||||
|
.export-btn {
|
||||||
|
background-color: #4285f4;
|
||||||
|
color: white;
|
||||||
|
border-color: #4285f4;
|
||||||
|
}
|
||||||
|
|
||||||
|
.export-btn:hover {
|
||||||
|
background-color: #3367d6;
|
||||||
|
border-color: #3367d6;
|
||||||
|
}
|
||||||
|
|
||||||
|
.refresh-btn {
|
||||||
|
background-color: white;
|
||||||
|
color: #666;
|
||||||
|
}
|
||||||
|
|
||||||
|
.refresh-btn:hover {
|
||||||
|
background-color: #f0f0f0;
|
||||||
|
color: #333;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 筛选条件区域 */
|
||||||
|
.filters-container {
|
||||||
|
padding: 1rem;
|
||||||
|
border-bottom: 1px solid #e0e0e0;
|
||||||
|
background-color: #fafafa;
|
||||||
|
flex-shrink: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.filter-group {
|
||||||
|
display: flex;
|
||||||
|
gap: 1.5rem;
|
||||||
|
margin-bottom: 1rem;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
.filter-group:last-child {
|
||||||
|
margin-bottom: 0;
|
||||||
|
align-items: flex-end;
|
||||||
|
}
|
||||||
|
|
||||||
|
.filter-item {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 0.3rem;
|
||||||
|
min-width: 200px;
|
||||||
|
flex: 1;
|
||||||
|
max-width: 300px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.filter-label {
|
||||||
|
font-size: 0.85rem;
|
||||||
|
font-weight: 600;
|
||||||
|
color: #666;
|
||||||
|
}
|
||||||
|
|
||||||
|
.filter-select,
|
||||||
|
.date-input {
|
||||||
|
padding: 0.5rem;
|
||||||
|
border: 1px solid #e0e0e0;
|
||||||
|
border-radius: 4px;
|
||||||
|
font-size: 0.9rem;
|
||||||
|
transition: border-color 0.2s;
|
||||||
|
}
|
||||||
|
|
||||||
|
.filter-select:focus,
|
||||||
|
.date-input:focus {
|
||||||
|
outline: none;
|
||||||
|
border-color: #4285f4;
|
||||||
|
box-shadow: 0 0 0 2px rgba(66, 133, 244, 0.1);
|
||||||
|
}
|
||||||
|
|
||||||
|
.date-range {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 0.8rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.date-separator {
|
||||||
|
color: #999;
|
||||||
|
font-size: 0.9rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.filter-actions {
|
||||||
|
display: flex;
|
||||||
|
gap: 0.8rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.apply-filters-btn,
|
||||||
|
.reset-filters-btn {
|
||||||
|
padding: 0.5rem 1rem;
|
||||||
|
border: 1px solid #e0e0e0;
|
||||||
|
border-radius: 4px;
|
||||||
|
font-size: 0.85rem;
|
||||||
|
cursor: pointer;
|
||||||
|
transition: all 0.2s;
|
||||||
|
}
|
||||||
|
|
||||||
|
.apply-filters-btn {
|
||||||
|
background-color: #34a853;
|
||||||
|
color: white;
|
||||||
|
border-color: #34a853;
|
||||||
|
}
|
||||||
|
|
||||||
|
.apply-filters-btn:hover {
|
||||||
|
background-color: #2d8f47;
|
||||||
|
border-color: #2d8f47;
|
||||||
|
}
|
||||||
|
|
||||||
|
.reset-filters-btn {
|
||||||
|
background-color: white;
|
||||||
|
color: #666;
|
||||||
|
}
|
||||||
|
|
||||||
|
.reset-filters-btn:hover {
|
||||||
|
background-color: #f0f0f0;
|
||||||
|
color: #333;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 调试信息展示区域 */
|
||||||
|
.debug-content {
|
||||||
|
flex: 1;
|
||||||
|
overflow: hidden;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
}
|
||||||
|
|
||||||
|
.debug-list {
|
||||||
|
flex: 1;
|
||||||
|
overflow-y: auto;
|
||||||
|
padding: 0 1rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.debug-item {
|
||||||
|
background-color: white;
|
||||||
|
border: 1px solid #e0e0e0;
|
||||||
|
border-radius: 4px;
|
||||||
|
margin: 1rem 0;
|
||||||
|
padding: 1rem;
|
||||||
|
position: relative;
|
||||||
|
transition: all 0.2s;
|
||||||
|
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
|
||||||
|
}
|
||||||
|
|
||||||
|
.debug-item:hover {
|
||||||
|
box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
|
||||||
|
border-color: #4285f4;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 调试类型样式 */
|
||||||
|
.debug-type-api {
|
||||||
|
border-left: 4px solid #4285f4;
|
||||||
|
}
|
||||||
|
|
||||||
|
.debug-type-database {
|
||||||
|
border-left: 4px solid #34a853;
|
||||||
|
}
|
||||||
|
|
||||||
|
.debug-type-cache {
|
||||||
|
border-left: 4px solid #fbbc05;
|
||||||
|
}
|
||||||
|
|
||||||
|
.debug-type-error {
|
||||||
|
border-left: 4px solid #ea4335;
|
||||||
|
}
|
||||||
|
|
||||||
|
.debug-type-performance {
|
||||||
|
border-left: 4px solid #673ab7;
|
||||||
|
}
|
||||||
|
|
||||||
|
.debug-item-header {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 1rem;
|
||||||
|
margin-bottom: 0.8rem;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
.debug-type-badge {
|
||||||
|
padding: 0.2rem 0.6rem;
|
||||||
|
border-radius: 12px;
|
||||||
|
font-size: 0.75rem;
|
||||||
|
font-weight: 600;
|
||||||
|
color: white;
|
||||||
|
text-transform: uppercase;
|
||||||
|
}
|
||||||
|
|
||||||
|
.type-api {
|
||||||
|
background-color: #4285f4;
|
||||||
|
}
|
||||||
|
|
||||||
|
.type-database {
|
||||||
|
background-color: #34a853;
|
||||||
|
}
|
||||||
|
|
||||||
|
.type-cache {
|
||||||
|
background-color: #fbbc05;
|
||||||
|
}
|
||||||
|
|
||||||
|
.type-error {
|
||||||
|
background-color: #ea4335;
|
||||||
|
}
|
||||||
|
|
||||||
|
.type-performance {
|
||||||
|
background-color: #673ab7;
|
||||||
|
}
|
||||||
|
|
||||||
|
.debug-timestamp {
|
||||||
|
font-size: 0.8rem;
|
||||||
|
color: #999;
|
||||||
|
flex-shrink: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.debug-project {
|
||||||
|
font-size: 0.85rem;
|
||||||
|
color: #666;
|
||||||
|
font-weight: 500;
|
||||||
|
}
|
||||||
|
|
||||||
|
.debug-item-content {
|
||||||
|
margin-bottom: 0.5rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.debug-content-main {
|
||||||
|
font-size: 0.9rem;
|
||||||
|
color: #333;
|
||||||
|
line-height: 1.5;
|
||||||
|
margin-bottom: 0.8rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 元数据样式 */
|
||||||
|
.debug-metadata {
|
||||||
|
background-color: #f8f9fa;
|
||||||
|
border: 1px solid #e0e0e0;
|
||||||
|
border-radius: 4px;
|
||||||
|
padding: 0.8rem;
|
||||||
|
margin-top: 0.8rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.debug-metadata h4 {
|
||||||
|
font-size: 0.9rem;
|
||||||
|
font-weight: 600;
|
||||||
|
color: #666;
|
||||||
|
margin-bottom: 0.5rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.metadata-list {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 0.3rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.metadata-item {
|
||||||
|
display: flex;
|
||||||
|
gap: 0.5rem;
|
||||||
|
font-size: 0.85rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.metadata-key {
|
||||||
|
font-weight: 600;
|
||||||
|
color: #666;
|
||||||
|
min-width: 100px;
|
||||||
|
flex-shrink: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.metadata-value {
|
||||||
|
color: #333;
|
||||||
|
word-break: break-all;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 展开/折叠按钮 */
|
||||||
|
.expand-btn {
|
||||||
|
position: absolute;
|
||||||
|
right: 1rem;
|
||||||
|
top: 1rem;
|
||||||
|
background: none;
|
||||||
|
border: none;
|
||||||
|
color: #999;
|
||||||
|
font-size: 1rem;
|
||||||
|
cursor: pointer;
|
||||||
|
padding: 0.2rem;
|
||||||
|
border-radius: 3px;
|
||||||
|
transition: all 0.2s;
|
||||||
|
}
|
||||||
|
|
||||||
|
.expand-btn:hover {
|
||||||
|
background-color: #f0f0f0;
|
||||||
|
color: #666;
|
||||||
|
}
|
||||||
|
|
||||||
|
.expand-btn.expanded {
|
||||||
|
color: #4285f4;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 空状态 */
|
||||||
|
.empty-state {
|
||||||
|
text-align: center;
|
||||||
|
padding: 2rem 0;
|
||||||
|
color: #999;
|
||||||
|
font-size: 0.9rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 分页控件 */
|
||||||
|
.pagination {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
gap: 1rem;
|
||||||
|
padding: 1rem;
|
||||||
|
border-top: 1px solid #e0e0e0;
|
||||||
|
background-color: #fafafa;
|
||||||
|
flex-shrink: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.page-btn {
|
||||||
|
padding: 0.5rem 1rem;
|
||||||
|
border: 1px solid #e0e0e0;
|
||||||
|
border-radius: 4px;
|
||||||
|
background-color: white;
|
||||||
|
color: #666;
|
||||||
|
font-size: 0.85rem;
|
||||||
|
cursor: pointer;
|
||||||
|
transition: all 0.2s;
|
||||||
|
}
|
||||||
|
|
||||||
|
.page-btn:hover:not(:disabled) {
|
||||||
|
background-color: #f0f0f0;
|
||||||
|
color: #333;
|
||||||
|
border-color: #ccc;
|
||||||
|
}
|
||||||
|
|
||||||
|
.page-btn:disabled {
|
||||||
|
opacity: 0.5;
|
||||||
|
cursor: not-allowed;
|
||||||
|
}
|
||||||
|
|
||||||
|
.page-info {
|
||||||
|
font-size: 0.85rem;
|
||||||
|
color: #666;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 滚动条样式 */
|
||||||
|
.debug-list::-webkit-scrollbar {
|
||||||
|
width: 6px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.debug-list::-webkit-scrollbar-track {
|
||||||
|
background: #f1f1f1;
|
||||||
|
border-radius: 3px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.debug-list::-webkit-scrollbar-thumb {
|
||||||
|
background: #c1c1c1;
|
||||||
|
border-radius: 3px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.debug-list::-webkit-scrollbar-thumb:hover {
|
||||||
|
background: #a8a8a8;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 响应式设计 */
|
||||||
|
@media (max-width: 768px) {
|
||||||
|
.filter-group {
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 1rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.filter-item {
|
||||||
|
max-width: 100%;
|
||||||
|
min-width: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.filter-group:last-child {
|
||||||
|
align-items: stretch;
|
||||||
|
}
|
||||||
|
|
||||||
|
.filter-actions {
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 0.5rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.debug-controls {
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 0.5rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.export-btn,
|
||||||
|
.refresh-btn {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.debug-item-header {
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: flex-start;
|
||||||
|
gap: 0.5rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.expand-btn {
|
||||||
|
position: static;
|
||||||
|
align-self: flex-end;
|
||||||
|
margin-top: -0.5rem;
|
||||||
|
margin-bottom: 0.5rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.pagination {
|
||||||
|
flex-wrap: wrap;
|
||||||
|
gap: 0.5rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.page-btn {
|
||||||
|
padding: 0.4rem 0.8rem;
|
||||||
|
font-size: 0.8rem;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
278
src/frontend/components/ProjectSelector.vue
Normal file
278
src/frontend/components/ProjectSelector.vue
Normal file
@@ -0,0 +1,278 @@
|
|||||||
|
<template>
|
||||||
|
<div class="project-selector">
|
||||||
|
<!-- 组件标题 -->
|
||||||
|
<div class="selector-header">
|
||||||
|
<h2>项目选择</h2>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- 项目列表 -->
|
||||||
|
<div class="project-list">
|
||||||
|
<div
|
||||||
|
v-for="project in projects"
|
||||||
|
:key="project.id"
|
||||||
|
class="project-item"
|
||||||
|
:class="{ 'project-selected': selectedProjectId === project.id }"
|
||||||
|
@click="selectProject(project)"
|
||||||
|
>
|
||||||
|
<!-- 项目状态指示器 -->
|
||||||
|
<div class="project-status" :class="`status-${project.status}`"></div>
|
||||||
|
|
||||||
|
<!-- 项目信息 -->
|
||||||
|
<div class="project-info">
|
||||||
|
<div class="project-name">{{ project.name }}</div>
|
||||||
|
<div class="project-description">{{ project.description }}</div>
|
||||||
|
<div class="project-meta">
|
||||||
|
<span class="project-type" :class="`type-${project.type}`">
|
||||||
|
{{ project.type === 'backend' ? '后端' : '前端' }}
|
||||||
|
</span>
|
||||||
|
<span class="project-status-text">{{ getStatusText(project.status) }}</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- 选择指示器 -->
|
||||||
|
<div class="project-select-indicator" v-if="selectedProjectId === project.id">
|
||||||
|
<span class="select-icon">✓</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup>
|
||||||
|
import { ref } from 'vue';
|
||||||
|
|
||||||
|
// 定义props和emits
|
||||||
|
const props = defineProps({
|
||||||
|
selectedProjectId: {
|
||||||
|
type: String,
|
||||||
|
default: null
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
const emit = defineEmits(['project-selected']);
|
||||||
|
|
||||||
|
// 模拟项目数据
|
||||||
|
const projects = ref([
|
||||||
|
{
|
||||||
|
id: 'proj-1',
|
||||||
|
name: '用户管理系统',
|
||||||
|
type: 'backend',
|
||||||
|
description: '基于Node.js的用户管理后端服务',
|
||||||
|
status: 'running'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'proj-2',
|
||||||
|
name: '数据可视化平台',
|
||||||
|
type: 'frontend',
|
||||||
|
description: '基于Vue.js的数据可视化前端应用',
|
||||||
|
status: 'running'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'proj-3',
|
||||||
|
name: '订单处理系统',
|
||||||
|
type: 'backend',
|
||||||
|
description: '高性能订单处理后端服务',
|
||||||
|
status: 'stopped'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'proj-4',
|
||||||
|
name: '移动端应用',
|
||||||
|
type: 'frontend',
|
||||||
|
description: '基于React Native的移动端应用',
|
||||||
|
status: 'error'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'proj-5',
|
||||||
|
name: 'API网关',
|
||||||
|
type: 'backend',
|
||||||
|
description: '微服务架构的API网关',
|
||||||
|
status: 'running'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'proj-6',
|
||||||
|
name: '管理后台',
|
||||||
|
type: 'frontend',
|
||||||
|
description: '基于Vue 3的管理后台系统',
|
||||||
|
status: 'running'
|
||||||
|
}
|
||||||
|
]);
|
||||||
|
|
||||||
|
// 选择项目
|
||||||
|
const selectProject = (project) => {
|
||||||
|
emit('project-selected', project);
|
||||||
|
};
|
||||||
|
|
||||||
|
// 获取状态文本
|
||||||
|
const getStatusText = (status) => {
|
||||||
|
const statusMap = {
|
||||||
|
running: '运行中',
|
||||||
|
stopped: '已停止',
|
||||||
|
error: '错误'
|
||||||
|
};
|
||||||
|
return statusMap[status] || status;
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.project-selector {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
height: 100%;
|
||||||
|
padding: 1rem;
|
||||||
|
background-color: #252526;
|
||||||
|
box-sizing: border-box;
|
||||||
|
}
|
||||||
|
|
||||||
|
.selector-header {
|
||||||
|
margin-bottom: 1rem;
|
||||||
|
padding-bottom: 0.5rem;
|
||||||
|
border-bottom: 1px solid #3e3e42;
|
||||||
|
}
|
||||||
|
|
||||||
|
.selector-header h2 {
|
||||||
|
font-size: 1.2rem;
|
||||||
|
font-weight: 600;
|
||||||
|
color: #e0e0e0;
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 项目列表 */
|
||||||
|
.project-list {
|
||||||
|
flex: 1;
|
||||||
|
overflow-y: auto;
|
||||||
|
max-height: calc(100vh - 150px);
|
||||||
|
}
|
||||||
|
|
||||||
|
.project-item {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
padding: 0.8rem;
|
||||||
|
margin-bottom: 0.5rem;
|
||||||
|
background-color: #333333;
|
||||||
|
border: 1px solid #444444;
|
||||||
|
border-radius: 4px;
|
||||||
|
cursor: pointer;
|
||||||
|
transition: all 0.2s;
|
||||||
|
position: relative;
|
||||||
|
}
|
||||||
|
|
||||||
|
.project-item:hover {
|
||||||
|
background-color: #3a3a3a;
|
||||||
|
border-color: #4285f4;
|
||||||
|
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
|
||||||
|
}
|
||||||
|
|
||||||
|
.project-item.project-selected {
|
||||||
|
background-color: #2c3e50;
|
||||||
|
border-color: #4285f4;
|
||||||
|
box-shadow: 0 0 0 2px rgba(66, 133, 244, 0.3);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 项目状态指示器 */
|
||||||
|
.project-status {
|
||||||
|
width: 8px;
|
||||||
|
height: 8px;
|
||||||
|
border-radius: 50%;
|
||||||
|
margin-right: 0.8rem;
|
||||||
|
flex-shrink: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.status-running {
|
||||||
|
background-color: #34a853;
|
||||||
|
}
|
||||||
|
|
||||||
|
.status-stopped {
|
||||||
|
background-color: #fbbc05;
|
||||||
|
}
|
||||||
|
|
||||||
|
.status-error {
|
||||||
|
background-color: #ea4335;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 项目信息 */
|
||||||
|
.project-info {
|
||||||
|
flex: 1;
|
||||||
|
min-width: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.project-name {
|
||||||
|
font-size: 0.95rem;
|
||||||
|
font-weight: 600;
|
||||||
|
color: #e0e0e0;
|
||||||
|
margin-bottom: 0.2rem;
|
||||||
|
white-space: nowrap;
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
}
|
||||||
|
|
||||||
|
.project-description {
|
||||||
|
font-size: 0.8rem;
|
||||||
|
color: #b0b0b0;
|
||||||
|
margin-bottom: 0.3rem;
|
||||||
|
white-space: nowrap;
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
}
|
||||||
|
|
||||||
|
.project-meta {
|
||||||
|
display: flex;
|
||||||
|
gap: 0.8rem;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.project-type {
|
||||||
|
font-size: 0.75rem;
|
||||||
|
padding: 0.15rem 0.5rem;
|
||||||
|
border-radius: 10px;
|
||||||
|
font-weight: 500;
|
||||||
|
}
|
||||||
|
|
||||||
|
.type-backend {
|
||||||
|
background-color: #1e3a2a;
|
||||||
|
color: #4ade80;
|
||||||
|
}
|
||||||
|
|
||||||
|
.type-frontend {
|
||||||
|
background-color: #2d1b4e;
|
||||||
|
color: #c084fc;
|
||||||
|
}
|
||||||
|
|
||||||
|
.project-status-text {
|
||||||
|
font-size: 0.75rem;
|
||||||
|
color: #999;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 选择指示器 */
|
||||||
|
.project-select-indicator {
|
||||||
|
width: 24px;
|
||||||
|
height: 24px;
|
||||||
|
background-color: #4285f4;
|
||||||
|
border-radius: 50%;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
color: white;
|
||||||
|
font-size: 0.8rem;
|
||||||
|
margin-left: 0.5rem;
|
||||||
|
flex-shrink: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 滚动条样式 */
|
||||||
|
.project-list::-webkit-scrollbar {
|
||||||
|
width: 6px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.project-list::-webkit-scrollbar-track {
|
||||||
|
background: #f1f1f1;
|
||||||
|
border-radius: 3px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.project-list::-webkit-scrollbar-thumb {
|
||||||
|
background: #c1c1c1;
|
||||||
|
border-radius: 3px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.project-list::-webkit-scrollbar-thumb:hover {
|
||||||
|
background: #a8a8a8;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
12
src/frontend/index.html
Normal file
12
src/frontend/index.html
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="zh-CN">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>BLS Project Console</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div id="app"></div>
|
||||||
|
<script type="module" src="/main.js"></script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@@ -1,17 +1,15 @@
|
|||||||
import { createRouter, createWebHistory } from 'vue-router'
|
import { createRouter, createWebHistory } from 'vue-router'
|
||||||
import LogView from '../views/LogView.vue'
|
import MainView from '../views/MainView.vue'
|
||||||
import CommandView from '../views/CommandView.vue'
|
import SidebarView from '../views/SidebarView.vue'
|
||||||
|
|
||||||
const routes = [
|
const routes = [
|
||||||
{
|
{
|
||||||
path: '/',
|
path: '/',
|
||||||
name: 'logs',
|
name: 'main',
|
||||||
component: LogView
|
components: {
|
||||||
},
|
sidebar: SidebarView,
|
||||||
{
|
main: MainView
|
||||||
path: '/commands',
|
}
|
||||||
name: 'commands',
|
|
||||||
component: CommandView
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|||||||
69
src/frontend/views/MainView.vue
Normal file
69
src/frontend/views/MainView.vue
Normal file
@@ -0,0 +1,69 @@
|
|||||||
|
<template>
|
||||||
|
<div class="main-view">
|
||||||
|
<!-- 控制台区域 -->
|
||||||
|
<section class="console-section">
|
||||||
|
<Console />
|
||||||
|
</section>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup>
|
||||||
|
import { ref } from 'vue';
|
||||||
|
import Console from '../components/Console.vue';
|
||||||
|
|
||||||
|
// 选中的项目ID,用于在组件间共享状态
|
||||||
|
const selectedProjectId = ref('all');
|
||||||
|
|
||||||
|
// 接收来自项目选择器的项目选择事件
|
||||||
|
const handleProjectSelected = (project) => {
|
||||||
|
selectedProjectId.value = project.id;
|
||||||
|
console.log('选中项目:', project);
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.main-view {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
.console-section {
|
||||||
|
background-color: transparent;
|
||||||
|
border-radius: 0;
|
||||||
|
box-shadow: none;
|
||||||
|
overflow: hidden;
|
||||||
|
flex: 1;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
height: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.console-section .console {
|
||||||
|
flex: 1;
|
||||||
|
min-height: 0;
|
||||||
|
height: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 响应式设计 */
|
||||||
|
@media (max-width: 768px) {
|
||||||
|
.main-view {
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
.console-section {
|
||||||
|
height: 100%;
|
||||||
|
max-height: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.console-section .console {
|
||||||
|
min-height: 0;
|
||||||
|
max-height: none;
|
||||||
|
height: 100%;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
27
src/frontend/views/SidebarView.vue
Normal file
27
src/frontend/views/SidebarView.vue
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
<template>
|
||||||
|
<div class="sidebar-view">
|
||||||
|
<ProjectSelector :selectedProjectId="selectedProjectId" @project-selected="handleProjectSelected" />
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup>
|
||||||
|
import { ref } from 'vue';
|
||||||
|
import ProjectSelector from '../components/ProjectSelector.vue';
|
||||||
|
|
||||||
|
// 选中的项目ID
|
||||||
|
const selectedProjectId = ref('all');
|
||||||
|
|
||||||
|
// 项目选择事件
|
||||||
|
const handleProjectSelected = (project) => {
|
||||||
|
selectedProjectId.value = project.id;
|
||||||
|
console.log('选中项目:', project);
|
||||||
|
// 这里可以通过事件总线或状态管理工具将选中的项目传递给其他组件
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.sidebar-view {
|
||||||
|
height: 100%;
|
||||||
|
overflow-y: auto;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
Reference in New Issue
Block a user