feat(electron-shell): 启动链路修复与执行/配置收口插件侧
- 启动链路 P1-P7 修复:预算对齐、完成事件推送、端口占用提示、前端阶段文案接管 - 静态缓存按 IS_FROZEN 区分开发/打包态,bootPhaseOwned 竞态修复 - 一键执行与参数配置统一收口到插件界面,定时任务引用 config_id - 环境包迁移到 %LOCALAPPDATA%\37duAutomation\python-env,重装零解压 - shell-updater:缓存包 sha256 校验、静默升级后自动拉起新版、自动清理旧安装包 - after-pack 钩子生成 shell.version 修复打包态版本识别 - 插件 xq0031/xq0045 迁移至 plugins/XQ0001-0100/ 号段分桶中文目录
This commit is contained in:
@@ -5,7 +5,7 @@
|
||||
<span class="avatar"><el-icon><Clock /></el-icon></span>
|
||||
<div class="ident-meta">
|
||||
<h2>定时任务</h2>
|
||||
<p>壳子内置定时:按 cron 到点自动执行插件,配置自动备份到中心机防丢失</p>
|
||||
<p>客户端内置定时:按 cron 到点自动执行插件,配置自动备份到中心机防丢失</p>
|
||||
</div>
|
||||
</div>
|
||||
<el-button type="primary" :icon="Plus" @click="openCreate">新建任务</el-button>
|
||||
@@ -60,9 +60,9 @@
|
||||
:label="`${p.name}(${p.id})`" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item v-if="form.plugin_id" label="使用配置">
|
||||
<el-select v-model="cfgSel" class="w-full" placeholder="默认配置">
|
||||
<el-option label="默认配置" value="" />
|
||||
<el-form-item v-if="form.plugin_id" label="执行配置">
|
||||
<el-select v-model="cfgSel" class="w-full" placeholder="插件当前配置">
|
||||
<el-option label="插件当前配置" value="" />
|
||||
<el-option v-for="c in configs" :key="c.id" :value="c.id" :label="c.name" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
@@ -130,9 +130,9 @@
|
||||
</div>
|
||||
</div>
|
||||
</el-form-item>
|
||||
<!-- 定时执行引用运行台保存的配置方案:不在此复刻参数字段表单(各场景字段千差万别) -->
|
||||
<!-- 参数引用插件界面维护的多配置方案:到点自动取所选方案的最新参数(方案更新自动跟随) -->
|
||||
<el-form-item label="执行配置">
|
||||
<span class="params-tip">到点自动执行该场景,使用上方<b>所选配置</b>(默认 = 插件默认参数);自定义参数请在运行台「存为配置」后引用</span>
|
||||
<span class="params-tip">到点自动执行该场景,使用上方<b>所选方案</b>的最新参数;方案在插件界面内保存维护(同名覆盖);不选 = 使用插件当前保存的配置</span>
|
||||
</el-form-item>
|
||||
<el-form-item label="启用">
|
||||
<el-switch v-model="form.enabled" />
|
||||
@@ -252,7 +252,7 @@ const presets = [
|
||||
{ label: '每月 1 日 09:00', cron: '0 9 1 * *' },
|
||||
]
|
||||
|
||||
const form = ref({ name: '', plugin_id: '', cron: '', enabled: true, fields: {} })
|
||||
const form = ref({ name: '', plugin_id: '', cron: '', enabled: true })
|
||||
|
||||
function pluginName(id) {
|
||||
return store.plugins.find((p) => p.id === id)?.name || id
|
||||
@@ -287,19 +287,12 @@ function fmtShort(s) {
|
||||
return pad2(d.getMonth() + 1) + '-' + pad2(d.getDate()) + ' ' + pad2(d.getHours()) + ':' + pad2(d.getMinutes())
|
||||
}
|
||||
|
||||
function buildFields(p) {
|
||||
const f = {}
|
||||
if (p) p.fields.forEach((x) => (f[x.key] = x.default ?? (x.type === 'int' ? 0 : '')))
|
||||
return f
|
||||
}
|
||||
|
||||
function onPluginChange(id) {
|
||||
form.value.fields = buildFields(store.plugins.find((x) => x.id === id))
|
||||
cfgSel.value = ''
|
||||
loadConfigs(id)
|
||||
}
|
||||
|
||||
// ===== 配置方案引用:运行台「存为配置」的方案可在此选用 =====
|
||||
// ===== 配置方案引用:方案由插件界面内保存维护(同名覆盖),定时任务到点取方案最新参数 =====
|
||||
const configs = ref([])
|
||||
const cfgSel = ref('')
|
||||
|
||||
@@ -310,22 +303,10 @@ async function loadConfigs(pluginId) {
|
||||
const r = await listPluginConfigs(pluginId)
|
||||
configs.value = r.configs || []
|
||||
} catch (e) {
|
||||
// 方案加载失败不阻塞任务编辑,静默降级为「默认配置」
|
||||
// 方案加载失败不阻塞任务编辑,静默降级为「插件当前配置」
|
||||
}
|
||||
}
|
||||
|
||||
// 把选中的配置方案字段应用到任务(未选 = 插件默认参数)
|
||||
function applySelectedConfig() {
|
||||
if (cfgSel.value) {
|
||||
const c = configs.value.find((x) => x.id === cfgSel.value)
|
||||
if (c) {
|
||||
form.value.fields = { ...c.fields }
|
||||
return
|
||||
}
|
||||
}
|
||||
form.value.fields = buildFields(store.plugins.find((x) => x.id === form.value.plugin_id))
|
||||
}
|
||||
|
||||
function onPreset(cron) {
|
||||
advancedCron.value = cron
|
||||
preset.value = ''
|
||||
@@ -342,7 +323,7 @@ async function load() {
|
||||
|
||||
function openCreate() {
|
||||
editing.value = null
|
||||
form.value = { name: '', plugin_id: '', cron: '', enabled: true, fields: {} }
|
||||
form.value = { name: '', plugin_id: '', cron: '', enabled: true }
|
||||
cfgSel.value = ''
|
||||
configs.value = []
|
||||
// 默认:每天 08:00
|
||||
@@ -358,15 +339,13 @@ function openCreate() {
|
||||
|
||||
function openEdit(row) {
|
||||
editing.value = row
|
||||
// 执行参数引用配置方案:编辑时先按「默认配置」展示,可自行改选
|
||||
form.value = {
|
||||
name: row.name || '',
|
||||
plugin_id: row.plugin_id || '',
|
||||
cron: row.cron || '',
|
||||
enabled: !!row.enabled,
|
||||
fields: buildFields(store.plugins.find((x) => x.id === row.plugin_id)),
|
||||
}
|
||||
cfgSel.value = ''
|
||||
cfgSel.value = row.config_id || ''
|
||||
loadConfigs(row.plugin_id)
|
||||
// 把已有 cron 解析回可视化选择状态
|
||||
const st = cronToState(row.cron || '')
|
||||
@@ -383,14 +362,15 @@ function openEdit(row) {
|
||||
async function onSave() {
|
||||
if (!form.value.plugin_id) { ElMessage.warning('请选择执行插件'); return }
|
||||
if (!form.value.cron.trim()) { ElMessage.warning('请填写 cron 表达式'); return }
|
||||
applySelectedConfig()
|
||||
saving.value = true
|
||||
try {
|
||||
// 引用插件界面维护的多配置方案(config_id),到点取方案最新参数;不选 = 插件当前配置
|
||||
const payload = { ...form.value, config_id: cfgSel.value }
|
||||
if (editing.value) {
|
||||
await updateSchedule(editing.value.id, { ...form.value })
|
||||
await updateSchedule(editing.value.id, payload)
|
||||
ElMessage.success('已保存')
|
||||
} else {
|
||||
await createSchedule({ ...form.value })
|
||||
await createSchedule(payload)
|
||||
ElMessage.success('已创建,配置已备份到中心机')
|
||||
}
|
||||
dlg.value = false
|
||||
|
||||
Reference in New Issue
Block a user