feat: 新增多插件 UI 支持及运行日志集中回传功能
本次提交包含多项功能更新: 1. 为多个插件(xq0002/0003/0004/0008/0010/0011/0020/0031_xq0032/0033/0035/0037/0045_xq0046/0047/0048)新增 UI 界面及配置支持 2. 新增运行日志集中回传功能,客户端自动上传运行日志到中心机集中存储 3. 新增插件分类字段支持,用于场景库分组管理 4. 优化 xq0034/0037/0048 等插件的功能及描述 5. 修复控制面响应兼容问题,支持新旧版本数据格式 6. 新增 xq0033 插件的状态存储模块,用于历史记录管理 7. 优化 CRM 登录窗口模式,支持全屏置顶
This commit is contained in:
@@ -1,20 +1,40 @@
|
||||
<template>
|
||||
<div class="sched-page">
|
||||
<div class="head">
|
||||
<div class="ident">
|
||||
<span class="avatar"><el-icon><Clock /></el-icon></span>
|
||||
<div class="ident-meta">
|
||||
<h2>定时任务</h2>
|
||||
<p>客户端内置定时:按 cron 到点自动执行插件,配置自动备份到中心机防丢失</p>
|
||||
<PageHead eyebrow="SCHEDULE · 计划" title="定时任务" sub="客户端内置定时:按 cron 到点自动执行插件,配置自动备份到中心机防丢失">
|
||||
<template #actions>
|
||||
<el-button type="primary" :icon="Plus" @click="openCreate">新建任务</el-button>
|
||||
</template>
|
||||
</PageHead>
|
||||
|
||||
<!-- 本周分布:按每周几聚合启用中的任务 -->
|
||||
<section v-if="list.length" class="card week-card">
|
||||
<div class="wc-head">
|
||||
<div class="wc-titles">
|
||||
<span class="sec-eyebrow">WEEK</span>
|
||||
<b class="wc-title">本周分布</b>
|
||||
</div>
|
||||
<span class="wc-note">启用中 {{ enabledCount }} / {{ list.length }} 个任务</span>
|
||||
</div>
|
||||
<div class="wc-bars">
|
||||
<div v-for="(d, i) in weekDist" :key="i" class="wc-col">
|
||||
<span class="wc-n">{{ d.n || '' }}</span>
|
||||
<div class="wc-track"><i class="wc-bar" :style="{ height: barH(d.n) }"></i></div>
|
||||
<span class="wc-label" :class="{ today: i === todayIdx }">{{ d.label }}</span>
|
||||
</div>
|
||||
</div>
|
||||
<el-button type="primary" :icon="Plus" @click="openCreate">新建任务</el-button>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<el-empty v-if="!list.length" description="暂无定时任务,点击右上角「新建任务」创建" />
|
||||
|
||||
<!-- 时间队列:按下次执行时间组织的任务行(替代生硬表格) -->
|
||||
<!-- 时间队列:按下次执行时间组织的任务行 -->
|
||||
<div v-else class="sched-wrap">
|
||||
<div class="sec-head">
|
||||
<div class="wc-titles">
|
||||
<span class="sec-eyebrow">QUEUE</span>
|
||||
<b class="wc-title">时间队列</b>
|
||||
</div>
|
||||
<span class="head-note">共 {{ list.length }} 个任务</span>
|
||||
</div>
|
||||
<div class="sched-list card">
|
||||
<div v-for="row in pagedList" :key="row.id" class="sched-row" :class="{ off: !row.enabled }">
|
||||
<div class="sr-when" :class="{ today: nextWhen(row).today }">
|
||||
@@ -45,7 +65,7 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<el-pagination v-if="list.length > pageSize" class="sched-pager" small background
|
||||
<el-pagination v-if="list.length > pageSize" class="sched-pager" size="small" background
|
||||
layout="total, prev, pager, next" :total="list.length" :page-size="pageSize"
|
||||
:current-page="page" @current-change="(p) => page = p" />
|
||||
</div>
|
||||
@@ -151,9 +171,11 @@
|
||||
<script setup>
|
||||
import { computed, ref, watch } from 'vue'
|
||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
import { Clock, Plus } from '@element-plus/icons-vue'
|
||||
import { Plus } from '@element-plus/icons-vue'
|
||||
import { store } from '../store'
|
||||
import PageHead from './PageHead.vue'
|
||||
import { listSchedules, createSchedule, updateSchedule, deleteSchedule, toggleSchedule, listPluginConfigs } from '../api'
|
||||
import { fmtShort } from '../utils/format'
|
||||
|
||||
const list = ref([])
|
||||
const dlg = ref(false)
|
||||
@@ -171,6 +193,31 @@ watch(() => list.value.length, (n) => {
|
||||
if (page.value > max) page.value = max
|
||||
})
|
||||
|
||||
// ---- 本周分布:按每周几聚合启用中的任务(cron 第5段 dow;dom 固定日的任务不计入周分布) ----
|
||||
const enabledCount = computed(() => list.value.filter((r) => r.enabled).length)
|
||||
const todayIdx = computed(() => (new Date().getDay() + 6) % 7) // 周一=0
|
||||
const weekDist = computed(() => {
|
||||
const labels = ['一', '二', '三', '四', '五', '六', '日']
|
||||
const counts = Array(7).fill(0)
|
||||
for (const r of list.value) {
|
||||
if (!r.enabled) continue
|
||||
const parts = String(r.cron || '').trim().split(/\s+/)
|
||||
if (parts.length !== 5) continue
|
||||
const [dom, , dow] = [parts[2], parts[3], parts[4]]
|
||||
if (dom !== '*') continue // 每月固定日:不落到本周分布
|
||||
if (dow === '*') { for (let i = 0; i < 7; i++) counts[i] += 1; continue } // 每天/每隔N小时
|
||||
for (const seg of dow.split(',')) {
|
||||
const mm = seg.match(/^(\d+)(?:-(\d+))?$/)
|
||||
if (mm) {
|
||||
const a = +mm[1], b = mm[2] ? +mm[2] : a
|
||||
for (let x = a; x <= b; x++) { const i = x === 0 ? 6 : x - 1; if (i >= 0 && i < 7) counts[i] += 1 }
|
||||
}
|
||||
}
|
||||
}
|
||||
return labels.map((label, i) => ({ label, n: counts[i] }))
|
||||
})
|
||||
function barH(n) { return n ? Math.max(14, Math.round((n / Math.max(1, Math.max(...weekDist.value.map((d) => d.n)))) * 46)) + 'px' : '3px' }
|
||||
|
||||
// ---- 闹钟式触发时间选择状态 ----
|
||||
// freq: daily=每天 weekdays=工作日 weekly=每周 monthly=每月 hourly=每隔N小时 advanced=高级cron
|
||||
const freq = ref('daily')
|
||||
@@ -281,14 +328,6 @@ function nextWhen(row) {
|
||||
return { main, sub: md + ' ' + week, today: diffDay === 0 }
|
||||
}
|
||||
|
||||
// 最近执行时间简写(MM-DD HH:mm)
|
||||
function fmtShort(s) {
|
||||
if (!s) return ''
|
||||
const d = new Date(String(s).replace(' ', 'T'))
|
||||
if (isNaN(d.getTime())) return String(s)
|
||||
return pad2(d.getMonth() + 1) + '-' + pad2(d.getDate()) + ' ' + pad2(d.getHours()) + ':' + pad2(d.getMinutes())
|
||||
}
|
||||
|
||||
function onPluginChange(id) {
|
||||
cfgSel.value = ''
|
||||
loadConfigs(id)
|
||||
@@ -418,107 +457,83 @@ load()
|
||||
.sched-page {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 18px;
|
||||
gap: var(--space-3);
|
||||
padding: var(--page-pad);
|
||||
flex-shrink: 0; /* 自然高度,超出由中栏上下文区整体滚动 */
|
||||
}
|
||||
|
||||
.head {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
justify-content: space-between;
|
||||
gap: 16px;
|
||||
/* ---------- 本周分布 ---------- */
|
||||
.week-card {
|
||||
padding-bottom: var(--space-3);
|
||||
background: linear-gradient(160deg, var(--brand-soft-2) 0%, var(--surface) 62%);
|
||||
border-color: var(--brand-track);
|
||||
}
|
||||
.wc-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--space-3); padding: var(--space-3) var(--space-4) 0; }
|
||||
.wc-titles { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
|
||||
.wc-title { font: 600 14px/20px var(--f-cn); color: var(--t1); }
|
||||
.wc-note { font: 400 10.5px/15px var(--f-num); color: var(--t4); }
|
||||
.head-note { font: 400 10.5px/15px var(--f-num); color: var(--t4); }
|
||||
.sec-head { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--space-3); padding: 0 var(--space-1); }
|
||||
.wc-bars { display: flex; gap: var(--space-1-5); padding: var(--space-3) var(--space-4) 0; }
|
||||
.wc-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: var(--space-1); min-width: 0; }
|
||||
.wc-n { font: 500 10px/13px var(--f-num); color: var(--t3); min-height: 13px; }
|
||||
.wc-track { width: 100%; max-width: 44px; height: 56px; display: flex; align-items: flex-end; justify-content: center; background: var(--field); border-radius: var(--r-row); overflow: hidden; }
|
||||
.wc-bar { width: 60%; border-radius: var(--space-1) var(--space-1) 0 0; background: var(--brand); transition: height .3s var(--ease); }
|
||||
.wc-label { font: 400 10px/14px var(--f-cn); color: var(--t4); }
|
||||
.wc-label.today { color: var(--brand-ink); font-weight: 600; }
|
||||
|
||||
.ident {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 14px;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.avatar {
|
||||
width: 44px;
|
||||
height: 44px;
|
||||
border-radius: 13px;
|
||||
flex-shrink: 0;
|
||||
display: grid;
|
||||
place-items: center;
|
||||
color: var(--on-primary);
|
||||
background: var(--primary-grad);
|
||||
box-shadow: var(--shadow-md);
|
||||
font-size: 18px;
|
||||
}
|
||||
|
||||
.ident-meta {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 2px;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.ident-meta h2 {
|
||||
margin: 0;
|
||||
font-size: 17px;
|
||||
}
|
||||
|
||||
.ident-meta p {
|
||||
margin: 0;
|
||||
font-size: 12px;
|
||||
color: var(--text-sub);
|
||||
}
|
||||
|
||||
/* ---------- 时间队列列表(替代表格) ---------- */
|
||||
.sched-wrap { display: flex; flex-direction: column; gap: 10px; }
|
||||
/* ---------- 时间队列列表 ---------- */
|
||||
.sched-wrap { display: flex; flex-direction: column; gap: var(--space-2-5); }
|
||||
.sched-list { display: flex; flex-direction: column; overflow: hidden; }
|
||||
.sched-row {
|
||||
display: flex; align-items: center; gap: 14px;
|
||||
padding: 13px 16px;
|
||||
border-bottom: 1px solid var(--border);
|
||||
transition: background .13s;
|
||||
display: flex; align-items: center; gap: var(--space-3);
|
||||
padding: var(--space-3) var(--space-4);
|
||||
border-bottom: 1px solid var(--line-soft);
|
||||
transition: background var(--dur);
|
||||
}
|
||||
.sched-row:last-child { border-bottom: none; }
|
||||
.sched-row:hover { background: var(--surface-2); }
|
||||
.sched-row:hover { background: var(--field); }
|
||||
.sr-when { width: 112px; flex-shrink: 0; }
|
||||
.sr-when b { display: block; font-size: 14px; font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; line-height: 1.25; }
|
||||
.sr-when.today b { color: var(--primary); }
|
||||
.sr-when span { font-size: 10.5px; color: var(--text-faint); font-variant-numeric: tabular-nums; }
|
||||
.sr-when b { display: block; font: 700 14px/18px var(--f-num); color: var(--t1); }
|
||||
.sr-when.today b { color: var(--brand-ink); }
|
||||
.sr-when span { font: 400 10.5px/15px var(--f-num); color: var(--t4); }
|
||||
.sr-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
|
||||
.sr-main b { display: flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
|
||||
.sr-main span { font-size: 11px; color: var(--text-faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
|
||||
.sr-main b { display: flex; align-items: center; gap: var(--space-1-5); font: 600 12.5px/18px var(--f-cn); color: var(--t1); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
|
||||
.sr-main span { font-size: 11px; color: var(--t4); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
|
||||
.sched-row.off .sr-when, .sched-row.off .sr-main span, .sched-row.off .cron-chip { opacity: .55; }
|
||||
.off-pill {
|
||||
flex-shrink: 0; font-style: normal; font-size: 10px; font-weight: 600;
|
||||
color: var(--text-faint); background: var(--surface-2);
|
||||
border: 1px solid var(--border); border-radius: 999px;
|
||||
padding: 0 7px; line-height: 17px;
|
||||
flex-shrink: 0; font-style: normal; font: 500 10px/17px var(--f-cn);
|
||||
color: var(--t3); background: var(--field);
|
||||
border: 1px solid var(--line); border-radius: var(--r-pill);
|
||||
padding: 0 var(--space-2);
|
||||
}
|
||||
.cron-chip {
|
||||
flex-shrink: 0;
|
||||
font-family: var(--mono); font-size: 11px; color: var(--primary);
|
||||
background: var(--primary-weak); border: 1px solid rgba(var(--primary-rgb), .3);
|
||||
border-radius: 6px; padding: 2px 8px;
|
||||
font-family: var(--f-mono); font-size: 11px; color: var(--brand-ink);
|
||||
background: var(--brand-soft); border: 1px solid var(--brand-track);
|
||||
border-radius: var(--r-row); padding: 2px var(--space-2);
|
||||
}
|
||||
.sr-last { width: 150px; flex-shrink: 0; display: flex; flex-direction: column; gap: 3px; }
|
||||
.sr-last { width: 150px; flex-shrink: 0; display: flex; flex-direction: column; gap: var(--space-1); }
|
||||
.st-pill {
|
||||
display: inline-flex; align-items: center; gap: 5px; width: fit-content;
|
||||
padding: 1px 9px; border-radius: 999px;
|
||||
font-size: 10.5px; font-weight: 600; line-height: 17px;
|
||||
background: var(--surface-2); color: var(--text-faint);
|
||||
border: 1px solid var(--border);
|
||||
display: inline-flex; align-items: center; gap: var(--space-1); width: fit-content;
|
||||
padding: 1px var(--space-2); border-radius: var(--r-pill);
|
||||
font: 600 10.5px/17px var(--f-cn);
|
||||
background: var(--field); color: var(--t3);
|
||||
border: 1px solid var(--line);
|
||||
}
|
||||
.st-pill .dot { width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
|
||||
.st-pill.ok { color: var(--ok); background: var(--ok-weak); border-color: transparent; }
|
||||
.st-pill.err { color: var(--err); background: var(--err-weak); border-color: transparent; }
|
||||
.st-pill.mid { color: var(--primary); background: var(--primary-weak); border-color: transparent; }
|
||||
.st-pill.none { color: var(--text-faint); }
|
||||
.sr-last-time { font-size: 10.5px; color: var(--text-faint); font-variant-numeric: tabular-nums; }
|
||||
.sr-acts { flex-shrink: 0; display: flex; align-items: center; gap: 8px; }
|
||||
.st-pill.ok { color: var(--good-ink); background: var(--good-soft); border-color: transparent; }
|
||||
.st-pill.err { color: var(--danger-ink); background: var(--danger-soft); border-color: transparent; }
|
||||
.st-pill.mid { color: var(--brand-ink); background: var(--brand-soft); border-color: transparent; }
|
||||
.st-pill.none { color: var(--t4); }
|
||||
.sr-last-time { font: 400 10.5px/15px var(--f-num); color: var(--t4); }
|
||||
.sr-acts { flex-shrink: 0; display: flex; align-items: center; gap: var(--space-2); }
|
||||
.sr-acts .el-button + .el-button { margin-left: 0; }
|
||||
.sched-pager { justify-content: center; }
|
||||
|
||||
.cron-row {
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
gap: var(--space-2);
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
@@ -532,8 +547,8 @@ load()
|
||||
|
||||
.cron-tip {
|
||||
font-size: 11px;
|
||||
color: var(--text-faint);
|
||||
margin-top: 6px;
|
||||
color: var(--t4);
|
||||
margin-top: var(--space-1-5);
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
@@ -541,7 +556,7 @@ load()
|
||||
.freq-zone {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 10px;
|
||||
gap: var(--space-2-5);
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
@@ -553,7 +568,7 @@ load()
|
||||
.freq-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
gap: var(--space-2-5);
|
||||
flex-wrap: wrap;
|
||||
width: 100%;
|
||||
}
|
||||
@@ -565,7 +580,7 @@ load()
|
||||
|
||||
.freq-desc {
|
||||
font-size: 13px;
|
||||
color: var(--text-sub);
|
||||
color: var(--t2);
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
@@ -584,31 +599,31 @@ load()
|
||||
.week-days {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 6px;
|
||||
gap: var(--space-1-5);
|
||||
}
|
||||
|
||||
.cron-preview {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
gap: var(--space-2);
|
||||
font-size: 12px;
|
||||
color: var(--text-faint);
|
||||
color: var(--t3);
|
||||
}
|
||||
|
||||
.cron-preview code {
|
||||
padding: 1px 8px;
|
||||
border-radius: 6px;
|
||||
background: var(--surface-2);
|
||||
border: 1px solid var(--border);
|
||||
padding: 1px var(--space-2);
|
||||
border-radius: var(--r-row);
|
||||
background: var(--field);
|
||||
border: 1px solid var(--line);
|
||||
font-size: 12px;
|
||||
color: var(--text);
|
||||
color: var(--t1);
|
||||
}
|
||||
|
||||
.cfg-tip {
|
||||
font-size: 11.5px; color: var(--text-faint); line-height: 1.6;
|
||||
margin-top: 6px;
|
||||
font-size: 11.5px; color: var(--t4); line-height: 1.6;
|
||||
margin-top: var(--space-1-5);
|
||||
}
|
||||
.cfg-tip b { color: var(--primary); font-weight: 600; }
|
||||
.cfg-tip b { color: var(--brand-ink); font-weight: 600; }
|
||||
|
||||
.w-full {
|
||||
width: 100%;
|
||||
|
||||
Reference in New Issue
Block a user