refactor: 重构项目模块结构与代码细节优化

1.  调整后端模块路由与插件文件结构,迁移部分模块代码至api/v1目录
2.  优化代码注释格式与文档字符串,简化冗余代码
3.  添加监控仪表盘、工单评论等新模块功能
4.  修复前端部分组件交互逻辑与类型定义
5.  清理冗余的初始化数据与废弃配置文件
6.  新增租户注册表单字段与国际化支持
7.  优化HTTP请求拦截器与快捷键功能
This commit is contained in:
zhangtao
2026-07-10 00:18:11 +08:00
parent 349ab7b525
commit 5ff72b086f
323 changed files with 7633 additions and 15306 deletions
+8
View File
@@ -277,6 +277,8 @@ defineOptions({ name: "CacheMonitor" });
const { width: winWidth } = useWindowSize();
const descColumns = computed(() => (winWidth.value < 768 ? 2 : 6));
let refreshTimer: ReturnType<typeof setInterval> | undefined;
const cacheNames = ref<CacheInfo[]>([]);
const cacheKeys = ref<string[]>([]);
const loading = ref(true);
@@ -452,9 +454,15 @@ const initCharts = () => {
onMounted(() => {
getCacheNameList();
getInfo();
// Redis 监控信息自动刷新(30 秒轮询)
refreshTimer = setInterval(() => {
getInfo();
getCacheNameList();
}, 30000);
});
onUnmounted(() => {
if (refreshTimer) clearInterval(refreshTimer);
commandstatsInstance?.dispose();
usedmemoryInstance?.dispose();
});
@@ -280,6 +280,15 @@ function handleClearAll() {
}
})();
}
// 在线用户列表自动刷新(30 秒轮询)
let refreshTimer: ReturnType<typeof setInterval> | undefined;
onMounted(() => {
refreshTimer = setInterval(() => refreshData(), 30000);
});
onUnmounted(() => {
if (refreshTimer) clearInterval(refreshTimer);
});
</script>
<style lang="scss" scoped></style>
@@ -3,7 +3,7 @@
<ElRow :gutter="16">
<!-- CPU 使用情况 -->
<ElCol :xs="24" :sm="12" class="mb-5">
<ElCard :loading="loading" shadow="hover">
<ElCard shadow="hover">
<template #header>
<div class="flex items-center gap-2">
<FaSvgIcon icon="ri:cpu-line" class="text-lg" />
@@ -46,7 +46,7 @@
<!-- 内存使用情况 -->
<ElCol :xs="24" :sm="12" class="mb-5">
<ElCard :loading="loading" shadow="hover">
<ElCard shadow="hover">
<template #header>
<div class="flex items-center gap-2">
<FaSvgIcon icon="ri:ram-line" class="text-lg" />
@@ -91,7 +91,7 @@
<ElRow :gutter="16">
<!-- 服务器基本信息 -->
<ElCol :xs="24" :sm="12" class="mb-5">
<ElCard :loading="loading" shadow="hover">
<ElCard shadow="hover">
<template #header>
<div class="flex items-center gap-2">
<FaSvgIcon icon="ri:server-line" class="text-lg" />
@@ -117,7 +117,7 @@
<!-- Python运行环境 -->
<ElCol :xs="24" :sm="12" class="mb-5">
<ElCard :loading="loading" shadow="hover">
<ElCard shadow="hover">
<template #header>
<div class="flex items-center gap-2">
<FaSvgIcon icon="ri:code-s-slash-line" class="text-lg" />
@@ -151,7 +151,7 @@
<!-- 磁盘使用情况 -->
<ElRow :gutter="16">
<ElCol :span="24" class="mb-5">
<ElCard :loading="loading" shadow="hover">
<ElCard shadow="hover">
<template #header>
<div class="flex items-center gap-2">
<FaSvgIcon icon="ri:hard-drive-2-line" class="text-lg" />
@@ -187,10 +187,10 @@
<script lang="ts" setup>
import ServerAPI, { type ServerInfo } from "@/api/module_monitor/server";
import { Auth } from "@utils";
defineOptions({ name: "ServerMonitor" });
const loading = ref(false);
const server = ref<ServerInfo>({
cpu: { cpu_num: 0, used: 0, sys: 0, free: 0 },
mem: { total: "", used: "", free: "", usage: 0 },
@@ -209,20 +209,38 @@ const server = ref<ServerInfo>({
disks: [],
});
async function getList() {
loading.value = true;
try {
const response = await ServerAPI.getServer();
server.value = response.data.data;
} catch (error) {
console.error("获取服务器信息失败:", error);
} finally {
loading.value = false;
}
let eventSource: EventSource | null = null;
function connectSSE() {
const token = Auth.getAccessToken();
const baseURL = import.meta.env.VITE_APP_BASE_API || "";
const url = `${baseURL}/monitor/server/stream?token=${encodeURIComponent(token)}`;
const es = new EventSource(url);
es.addEventListener("server_status", (event: MessageEvent) => {
try {
const data = JSON.parse(event.data);
server.value = data;
} catch {
/* 静默忽略解析错误 */
}
});
es.onerror = () => {
es.close();
};
eventSource = es;
}
onMounted(() => {
getList();
// 先获取一次静态数据,再开启 SSE
ServerAPI.getServer().then((res) => {
server.value = res.data.data;
});
connectSSE();
});
onUnmounted(() => {
eventSource?.close();
});
</script>