feat(monitor): 新增暂停1小时监测功能

This commit is contained in:
tsl 2026-07-06 10:43:48 +08:00
parent 305fcfae06
commit aa01a63fcd
2 changed files with 54 additions and 1 deletions

View File

@ -32,7 +32,12 @@ export function useTray() {
const { addLog } = useLogStore();
const monitorStore = useMonitorStore();
const { isMonitoring, isPostponed, ticketCounts } = storeToRefs(monitorStore);
const { startMonitoring, stopMonitoring } = monitorStore;
const {
startMonitoring,
stopMonitoring,
postponeMonitoring,
resumeMonitoring,
} = monitorStore;
const appName = import.meta.env.VITE_APP_NAME;
// 当前托盘图标实例null 表示尚未初始化
let trayIconInstance: TrayIcon | null = null;
@ -201,6 +206,22 @@ export function useTray() {
}
},
}),
await MenuItem.new({
id: "pause_1h",
text: "暂停1小时",
enabled: isMonitoring.value && !isPostponed.value,
action: () => {
postponeMonitoring();
},
}),
await MenuItem.new({
id: "resume_monitor",
text: "恢复监测",
enabled: isMonitoring.value && isPostponed.value,
action: () => {
resumeMonitoring();
},
}),
await MenuItem.new({
id: "open_website",
text: "打开工单网站",

View File

@ -5,11 +5,16 @@ import {
BellOutlined,
WifiOutlined,
ClockCircleOutlined,
PauseCircleOutlined,
PlayCircleOutlined,
LinkOutlined,
} from "@ant-design/icons-vue";
import { openUrl } from "@tauri-apps/plugin-opener";
import dayjs from "dayjs";
import duration from "dayjs/plugin/duration";
import { ref, onMounted, onUnmounted } from "vue";
import { useTray } from "@/composables/useTray";
import { CRM_URL } from "@/constants/app";
import { useMonitorStore } from "@/stores/monitor";
import { useNetworkStore } from "@/stores/network";
@ -31,6 +36,10 @@ async function handleMinimizeToTray() {
await minimizeToTray();
}
async function handleOpenCrmWebsite() {
await openUrl(CRM_URL);
}
const countdown = ref("");
let countdownTimer: ReturnType<typeof setInterval> | null = null;
@ -107,12 +116,35 @@ onUnmounted(() => {
</template>
手动检查
</a-button>
<a-button :disabled="!store.isMonitoring || store.isPostponed" @click="store.postponeMonitoring()">
<template #icon>
<PauseCircleOutlined />
</template>
暂停1小时
</a-button>
<a-button
:disabled="!store.isMonitoring || !store.isPostponed"
type="primary"
ghost
@click="store.resumeMonitoring()"
>
<template #icon>
<PlayCircleOutlined />
</template>
恢复监测
</a-button>
<a-button @click="networkStore.checkNetworkStatus()">
<template #icon>
<WifiOutlined />
</template>
网络检测
</a-button>
<a-button @click="handleOpenCrmWebsite()">
<template #icon>
<LinkOutlined />
</template>
打开工单网站
</a-button>
<a-button @click="store.testNotification()">
<template #icon>
<BellOutlined />