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:
@@ -1,6 +1,6 @@
|
||||
<template>
|
||||
<div v-if="plugin" class="plugin-page">
|
||||
<!-- Hero:场景身份 + 大执行按钮 -->
|
||||
<!-- Hero:场景身份 + 运行状态(执行入口收口在插件界面内,壳子不再提供一键执行) -->
|
||||
<section class="hero card">
|
||||
<div class="hero-main">
|
||||
<span class="avatar" :style="{ background: avatarBg }">{{ plugin.name.slice(0, 1) }}</span>
|
||||
@@ -13,35 +13,24 @@
|
||||
<span v-if="plugin.platform" class="badge" :class="platformOnline ? 'on' : 'off'">
|
||||
<i class="bdot"></i>{{ platformLabel }} {{ platformOnline ? '已登录' : '未登录' }}
|
||||
</span>
|
||||
<span v-if="plugin.uses_month" class="badge">
|
||||
<el-select v-model="month" size="small" class="month-sel" :disabled="store.running">
|
||||
<el-option v-for="m in months" :key="m" :value="m" :label="m" />
|
||||
</el-select>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="hero-actions">
|
||||
<button class="run-btn" :class="{ running: store.running }" :disabled="store.running" @click="run">
|
||||
<template v-if="store.running">
|
||||
<span class="ring">
|
||||
<svg viewBox="0 0 36 36" width="26" height="26">
|
||||
<circle class="ring-bg" cx="18" cy="18" r="15.5" fill="none" stroke-width="3.5" />
|
||||
<circle class="ring-fg" cx="18" cy="18" r="15.5" fill="none" stroke-width="3.5"
|
||||
stroke-linecap="round" :stroke-dasharray="ringDash" transform="rotate(-90 18 18)" />
|
||||
</svg>
|
||||
</span>
|
||||
<span>执行中 {{ store.progress }}%</span>
|
||||
</template>
|
||||
<template v-else>
|
||||
<span class="play-ic">▶</span>
|
||||
<span>一键执行</span>
|
||||
</template>
|
||||
</button>
|
||||
<div v-if="store.running" class="run-chip">
|
||||
<span class="ring">
|
||||
<svg viewBox="0 0 36 36" width="22" height="22">
|
||||
<circle class="ring-bg" cx="18" cy="18" r="15.5" fill="none" stroke-width="3.5" />
|
||||
<circle class="ring-fg" cx="18" cy="18" r="15.5" fill="none" stroke-width="3.5"
|
||||
stroke-linecap="round" :stroke-dasharray="ringDash" transform="rotate(-90 18 18)" />
|
||||
</svg>
|
||||
</span>
|
||||
<span>执行中 {{ store.progress }}%</span>
|
||||
</div>
|
||||
<el-button v-if="rollbackVer" size="small" text type="warning" class="rollback-btn"
|
||||
:disabled="store.running" @click="doRollback">回滚 v{{ rollbackVer }}</el-button>
|
||||
<span class="hero-tip">配置与运行日志都在下方运行台</span>
|
||||
<span class="hero-tip">在插件界面内配置并执行,运行日志与历史见下方</span>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
@@ -55,8 +44,8 @@
|
||||
<button class="b-close" @click="closeBanner" title="关闭">✕</button>
|
||||
</section>
|
||||
|
||||
<!-- 运行台:参数 / 插件界面 / 运行日志
|
||||
日志归属"本次运行"(不再是全局面板);带专属界面的插件用界面本身配置,故不并列参数表单 -->
|
||||
<!-- 运行台:插件界面 / 运行日志 / 历史运行
|
||||
执行与参数配置收口在插件界面内(插件自包含前端+执行);日志归属"本次运行" -->
|
||||
<div class="run-tabs card">
|
||||
<div class="rt-head">
|
||||
<div class="rt-tabs">
|
||||
@@ -66,56 +55,9 @@
|
||||
<i v-if="t.k === 'log' && store.running" class="rt-live"></i>
|
||||
</button>
|
||||
</div>
|
||||
<el-button v-if="tab === 'params' && fieldCount" size="small" text :disabled="store.running" :icon="RefreshLeft"
|
||||
@click="resetForm">恢复默认</el-button>
|
||||
</div>
|
||||
|
||||
<div class="rt-body">
|
||||
<!-- 参数配置 -->
|
||||
<section v-show="tab === 'params'" class="params">
|
||||
<div class="cfg-bar">
|
||||
<el-select v-model="curCfg" size="small" class="cfg-sel" placeholder="默认配置" @change="onCfgChange">
|
||||
<el-option label="默认配置" value="" />
|
||||
<el-option v-for="c in configs" :key="c.id" :value="c.id" :label="c.name" />
|
||||
</el-select>
|
||||
<el-button size="small" text :icon="FolderAdd" :disabled="store.running" @click="saveAsCfg">存为配置</el-button>
|
||||
<el-button v-if="curCfg" size="small" text type="danger" :icon="Delete" :disabled="store.running" @click="delCfg">删除</el-button>
|
||||
<span v-if="curCfgLabel" class="cfg-note">已套用「{{ curCfgLabel }}」,定时任务可引用</span>
|
||||
</div>
|
||||
<el-form label-width="auto" class="form-card">
|
||||
<div class="fields">
|
||||
<el-form-item v-for="f in plugin.fields" :key="f.key" :label="f.label">
|
||||
<template v-if="f.type === 'int'">
|
||||
<el-input-number v-model="form[f.key]" :controls="false" placeholder="0" :disabled="store.running" />
|
||||
</template>
|
||||
<el-input v-else-if="f.type === 'password'" v-model="form[f.key]" type="password" show-password
|
||||
:placeholder="String(f.default ?? '')" :disabled="store.running">
|
||||
<template v-if="f.help || f.description" #suffix>
|
||||
<el-tooltip :content="f.help || f.description" placement="bottom"><el-icon class="help-ic">
|
||||
<QuestionFilled />
|
||||
</el-icon></el-tooltip>
|
||||
</template>
|
||||
</el-input>
|
||||
<el-input v-else-if="f.type === 'text'" v-model="form[f.key]" :placeholder="String(f.default ?? '')"
|
||||
:disabled="store.running">
|
||||
<template v-if="f.help || f.description" #suffix>
|
||||
<el-tooltip :content="f.help || f.description" placement="bottom"><el-icon class="help-ic">
|
||||
<QuestionFilled />
|
||||
</el-icon></el-tooltip>
|
||||
</template>
|
||||
</el-input>
|
||||
<el-select v-else-if="f.type === 'multiselect'" v-model="form[f.key]" multiple filterable allow-create
|
||||
default-first-option placeholder="选择或输入后回车" :disabled="store.running">
|
||||
<el-option v-for="opt in (f.options || [])" :key="opt" :value="opt" :label="opt" />
|
||||
</el-select>
|
||||
<el-select v-else v-model="form[f.key]" :disabled="store.running">
|
||||
<el-option v-for="opt in f.options" :key="opt" :value="opt" :label="opt" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</div>
|
||||
</el-form>
|
||||
</section>
|
||||
|
||||
<!-- 插件专属界面(同源 iframe,自动携带会话 cookie)
|
||||
sandbox 白名单加固:允许脚本/同源/表单,禁用 top 跳转与弹窗
|
||||
仅一层容器承载尺寸,不再叠提示条/卡片 -->
|
||||
@@ -176,10 +118,10 @@
|
||||
|
||||
<script setup>
|
||||
import { computed, ref, watch } from 'vue'
|
||||
import { QuestionFilled, Refresh, RefreshLeft, ArrowLeft, ArrowRight, FolderAdd, Delete } from '@element-plus/icons-vue'
|
||||
import { Refresh, ArrowLeft, ArrowRight } from '@element-plus/icons-vue'
|
||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
import { store, log } from '../store'
|
||||
import { startRun, getRun, fetchRuns, fetchMeta, listRollbacks, rollbackPlugin, listPluginConfigs, savePluginConfig, deletePluginConfig } from '../api'
|
||||
import { store } from '../store'
|
||||
import { getRun, fetchRuns, fetchMeta, listRollbacks, rollbackPlugin } from '../api'
|
||||
import LogPanel from './LogPanel.vue'
|
||||
|
||||
const GRADS = [
|
||||
@@ -187,136 +129,26 @@ const GRADS = [
|
||||
'var(--grad-lilac)', 'var(--grad-honey)', 'var(--grad-blush)',
|
||||
]
|
||||
|
||||
const months = computed(() => {
|
||||
const now = new Date()
|
||||
const list = []
|
||||
for (let off = 1; off <= 6; off++) {
|
||||
const d = new Date(now.getFullYear(), now.getMonth() - off, 1)
|
||||
list.push(`${d.getFullYear()}-${String(d.getMonth() + 1).padStart(2, '0')}`)
|
||||
}
|
||||
return list
|
||||
})
|
||||
const month = ref(months.value[0])
|
||||
|
||||
const idx = computed(() => Math.max(0, store.plugins.findIndex((p) => p.id === store.selectedId)))
|
||||
const avatarBg = computed(() => GRADS[idx.value % GRADS.length])
|
||||
|
||||
const plugin = computed(() => store.plugins.find((p) => p.id === store.selectedId) || null)
|
||||
|
||||
const form = ref({})
|
||||
|
||||
function buildFormDefaults(p) {
|
||||
const f = {}
|
||||
if (p) p.fields.forEach((x) => (f[x.key] = x.default ?? (x.type === 'int' ? 0 : '')))
|
||||
return f
|
||||
}
|
||||
|
||||
watch(
|
||||
() => plugin.value?.id,
|
||||
(id) => {
|
||||
form.value = buildFormDefaults(store.plugins.find((x) => x.id === id))
|
||||
loadConfigs()
|
||||
},
|
||||
{ immediate: true }
|
||||
)
|
||||
|
||||
function resetForm() {
|
||||
form.value = buildFormDefaults(plugin.value)
|
||||
curCfg.value = ''
|
||||
}
|
||||
|
||||
// ===== 配置方案(多配置):把当前参数存成命名方案,运行台可一键套用、定时任务可引用 =====
|
||||
const configs = ref([])
|
||||
const curCfg = ref('')
|
||||
const curCfgLabel = computed(() => {
|
||||
if (!curCfg.value) return ''
|
||||
const c = configs.value.find((x) => x.id === curCfg.value)
|
||||
return c ? c.name : ''
|
||||
})
|
||||
|
||||
async function loadConfigs() {
|
||||
if (!plugin.value?.id) {
|
||||
configs.value = []
|
||||
curCfg.value = ''
|
||||
return
|
||||
}
|
||||
try {
|
||||
const r = await listPluginConfigs(plugin.value.id)
|
||||
configs.value = r.configs || []
|
||||
if (curCfg.value && !configs.value.some((c) => c.id === curCfg.value)) curCfg.value = ''
|
||||
} catch (e) {
|
||||
ElMessage.error('配置方案加载失败:' + (e.message || e))
|
||||
}
|
||||
}
|
||||
|
||||
function onCfgChange(id) {
|
||||
const c = configs.value.find((x) => x.id === id)
|
||||
if (!c) return
|
||||
Object.assign(form.value, c.fields)
|
||||
ElMessage.success(`已套用配置「${c.name}」`)
|
||||
}
|
||||
|
||||
async function saveAsCfg() {
|
||||
let name
|
||||
try {
|
||||
const r = await ElMessageBox.prompt('给这套参数起个名字(同名会覆盖旧配置)', '保存为配置', {
|
||||
confirmButtonText: '保存',
|
||||
cancelButtonText: '取消',
|
||||
inputPattern: /\S+/,
|
||||
inputErrorMessage: '名称不能为空',
|
||||
inputValue: curCfgLabel.value || '',
|
||||
})
|
||||
name = r.value
|
||||
} catch (e) {
|
||||
if (e === 'cancel') return
|
||||
throw e
|
||||
}
|
||||
try {
|
||||
const r = await savePluginConfig(plugin.value.id, name, { ...form.value })
|
||||
await loadConfigs()
|
||||
curCfg.value = r.config.id
|
||||
ElMessage.success(`配置「${r.config.name}」已保存`)
|
||||
} catch (e) {
|
||||
ElMessage.error(e.message || String(e))
|
||||
}
|
||||
}
|
||||
|
||||
async function delCfg() {
|
||||
try {
|
||||
await ElMessageBox.confirm(`确定删除配置「${curCfgLabel.value}」?`, '删除配置', {
|
||||
type: 'warning',
|
||||
confirmButtonText: '删除',
|
||||
cancelButtonText: '取消',
|
||||
})
|
||||
} catch (_) { return }
|
||||
try {
|
||||
await deletePluginConfig(plugin.value.id, curCfg.value)
|
||||
curCfg.value = ''
|
||||
await loadConfigs()
|
||||
ElMessage.success('已删除')
|
||||
} catch (e) {
|
||||
ElMessage.error('删除失败:' + (e.message || e))
|
||||
}
|
||||
}
|
||||
|
||||
// 专属界面插件:插件 UI 直接内嵌在页面主体(同源自动携带会话 cookie,不再弹窗/外跳)。
|
||||
const uiSrc = computed(() => (plugin.value?.ui ? `/pui/${plugin.value.id}/` : ''))
|
||||
|
||||
// ===== 运行台标签页 =====
|
||||
// 带专属界面的插件由界面自己配置参数,故不并列参数表单(与改造前语义一致)
|
||||
// ===== 运行台标签页:插件界面(如有)/ 运行日志 / 历史运行 =====
|
||||
// 执行与参数配置收口在插件界面内(插件自包含前端+执行按钮),壳子不再提供参数表单与一键执行
|
||||
const tabs = computed(() => {
|
||||
const base = plugin.value?.ui
|
||||
? [{ k: 'ui', label: '插件界面' }]
|
||||
: [{ k: 'params', label: '参数配置' }]
|
||||
return [...base, { k: 'log', label: '运行日志' }, { k: 'history', label: '历史运行' }]
|
||||
const t = plugin.value?.ui ? [{ k: 'ui', label: '插件界面' }] : []
|
||||
return [...t, { k: 'log', label: '运行日志' }, { k: 'history', label: '历史运行' }]
|
||||
})
|
||||
const tab = ref('params')
|
||||
const fieldCount = computed(() => (plugin.value?.fields || []).length)
|
||||
const tab = ref('log')
|
||||
|
||||
watch(
|
||||
() => plugin.value?.id,
|
||||
(id) => {
|
||||
tab.value = plugin.value?.ui ? 'ui' : 'params'
|
||||
() => {
|
||||
tab.value = plugin.value?.ui ? 'ui' : 'log'
|
||||
resetHistory()
|
||||
consumePendingReplay()
|
||||
},
|
||||
@@ -446,29 +278,7 @@ async function doRollback() {
|
||||
}
|
||||
}
|
||||
|
||||
async function run() {
|
||||
if (!plugin.value || store.running) return
|
||||
if (plugin.value.platform && !platformOnline.value) {
|
||||
log('WARN', `插件「${plugin.value.name}」需要先登录平台「${platformLabel.value}」才能正确执行`)
|
||||
}
|
||||
store.running = true
|
||||
store.progress = 0
|
||||
store.currentRun = ''
|
||||
store.lastResult = null
|
||||
store.lastSummary = ''
|
||||
const payload = { ...form.value }
|
||||
if (plugin.value.uses_month) payload.ref_month = month.value // 仅月度插件注入月份
|
||||
try {
|
||||
const r = await startRun(plugin.value.id, payload)
|
||||
store.lastRunId = r.run_id
|
||||
} catch (e) {
|
||||
store.running = false
|
||||
store.lastResult = { ok: false, error: e.message || String(e) }
|
||||
log('ERROR', `启动执行失败:${e.message || e}`)
|
||||
}
|
||||
}
|
||||
|
||||
// 完成时拉取后端摘要填充横幅
|
||||
// 完成时拉取后端摘要填充横幅(触发源无关:插件界面/定时任务触发的运行同样回填)
|
||||
watch(
|
||||
() => store.lastResult,
|
||||
async (res) => {
|
||||
@@ -537,27 +347,18 @@ function closeBanner() {
|
||||
.badge.off { color: var(--badge-off-text); }
|
||||
.bdot { width: 6px; height: 6px; border-radius: 50%; background: var(--badge-dot); }
|
||||
.badge.on .bdot { background: var(--ok); }
|
||||
.month-sel { width: 108px; --el-component-size: 24px; }
|
||||
|
||||
.hero-actions { display: flex; flex-direction: column; align-items: flex-end; gap: 7px; flex-shrink: 0; }
|
||||
.run-btn {
|
||||
display: inline-flex; align-items: center; gap: 9px;
|
||||
padding: 0 26px; height: 50px;
|
||||
border: none; border-radius: 16px;
|
||||
background: var(--primary-grad-2);
|
||||
color: var(--on-primary); font-size: 15px; font-weight: 600; letter-spacing: .06em;
|
||||
cursor: pointer; font-family: inherit;
|
||||
box-shadow: 0 12px 26px -12px rgba(var(--primary-rgb), .85);
|
||||
transition: all .16s ease;
|
||||
/* 运行状态 chip:仅展示进度,不可点击(执行入口在插件界面内) */
|
||||
.run-chip {
|
||||
display: inline-flex; align-items: center; gap: 8px;
|
||||
padding: 6px 15px; border-radius: 999px;
|
||||
background: var(--primary-grad-3); color: var(--on-primary);
|
||||
font-size: 12.5px; font-weight: 600; font-variant-numeric: tabular-nums;
|
||||
box-shadow: 0 8px 18px -10px rgba(var(--primary-rgb), .8);
|
||||
}
|
||||
.run-btn:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 16px 30px -12px rgba(var(--primary-rgb), .95); }
|
||||
.run-btn:active:not(:disabled) { transform: translateY(0) scale(.98); }
|
||||
.run-btn.running { background: var(--primary-grad-3); cursor: default; min-width: 168px; font-variant-numeric: tabular-nums; }
|
||||
/* 进度环用 CSS 上色(SVG 表现属性不支持 var(),故不写在 stroke="" 上) */
|
||||
.ring-bg { stroke: rgba(var(--on-primary-rgb), .35); }
|
||||
.ring-fg { stroke: var(--on-primary); }
|
||||
.run-btn:disabled { opacity: 1; }
|
||||
.play-ic { font-size: 13px; transform: translateY(-1px); }
|
||||
.ring { display: inline-flex; }
|
||||
.ring-fg { transition: stroke-dasharray .25s ease; }
|
||||
.hero-tip { font-size: 10.5px; color: var(--text-faint); letter-spacing: .02em; }
|
||||
@@ -623,15 +424,6 @@ function closeBanner() {
|
||||
border: 1px solid var(--border); border-radius: 12px; background: var(--surface);
|
||||
}
|
||||
|
||||
/* ---------- 参数 ---------- */
|
||||
.params { flex: 1 1 auto; min-height: 0; overflow: auto; padding: 18px 22px 6px; }
|
||||
.cfg-bar { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
|
||||
.cfg-sel { width: 200px; }
|
||||
.cfg-note { font-size: 11.5px; color: var(--text-faint); }
|
||||
.fields { display: flex; gap: 24px; flex-wrap: wrap; }
|
||||
.form-card .el-form-item { margin-bottom: 18px; }
|
||||
.help-ic { color: var(--text-faint); cursor: help; }
|
||||
|
||||
/* ---------- 历史运行 ---------- */
|
||||
.history { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; overflow: hidden; }
|
||||
.hist-view { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }
|
||||
|
||||
Reference in New Issue
Block a user