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:
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,51 @@
|
||||
<template>
|
||||
<el-dialog v-model="visible" :title="title" width="420px"
|
||||
:close-on-click-modal="false" align-center class="upd-dl-dialog">
|
||||
<template v-if="dl.status === 'downloading'">
|
||||
<div class="dl-dlg-body">
|
||||
<el-progress :percentage="dl.pct || 0" :stroke-width="10" />
|
||||
<span class="dl-dlg-bytes">{{ fmtBytes(dl.received) }}{{ dl.total ? ' / ' + fmtBytes(dl.total) : '' }}</span>
|
||||
</div>
|
||||
</template>
|
||||
<template v-else-if="dl.status === 'extracting'">
|
||||
<div class="dl-dlg-body">
|
||||
<el-progress :percentage="100" :stroke-width="10" status="warning" :indeterminate="true" :duration="2" />
|
||||
<span class="dl-dlg-bytes">下载完成,正在解压安装(约需几十秒)…</span>
|
||||
</div>
|
||||
</template>
|
||||
<template v-else-if="dl.status === 'failed'">
|
||||
<div class="dl-dlg-body">
|
||||
<span class="dl-dlg-err">{{ failLabel }}:{{ dl.error || '未知错误' }}</span>
|
||||
</div>
|
||||
</template>
|
||||
<div v-else class="dl-dlg-body"><span>{{ bodyText }}</span></div>
|
||||
<template #footer><slot name="footer" /></template>
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { computed } from 'vue'
|
||||
import { fmtBytes } from '../utils/format'
|
||||
|
||||
const props = defineProps({
|
||||
modelValue: { type: Boolean, default: false },
|
||||
title: { type: String, default: '' },
|
||||
dl: { type: Object, default: () => ({}) },
|
||||
// 非下载/解压/失败状态的正文(准备中、已就绪、已安装等由调用方给文案)
|
||||
bodyText: { type: String, default: '' },
|
||||
failLabel: { type: String, default: '下载失败' },
|
||||
})
|
||||
const emit = defineEmits(['update:modelValue'])
|
||||
|
||||
const visible = computed({
|
||||
get: () => props.modelValue,
|
||||
set: (v) => emit('update:modelValue', v),
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
/* el-dialog 就地渲染(未 append-to-body),scoped 样式仍作用于弹窗内部 */
|
||||
.dl-dlg-body { display: flex; flex-direction: column; gap: var(--space-2); padding: var(--space-1) 2px; font-size: 12.5px; color: var(--t2); }
|
||||
.dl-dlg-bytes { font-family: var(--f-num); font-size: 11px; color: var(--t3); text-align: right; }
|
||||
.dl-dlg-err { color: var(--danger-ink); font-size: 12px; line-height: 1.6; }
|
||||
</style>
|
||||
@@ -1,89 +1,208 @@
|
||||
<template>
|
||||
<div class="home">
|
||||
<!-- 指标行:压缩首屏信息密度(替代问候区与统计卡) -->
|
||||
<!-- 头部 hero:英文小标 + 中文大标 + 副文案 + 右侧日期信息 -->
|
||||
<section class="hero card">
|
||||
<div class="hero-main">
|
||||
<span class="hero-eyebrow"><i></i>TODAY · 今日简报</span>
|
||||
<h1 class="hero-title">今日运行简报</h1>
|
||||
<p class="hero-sub">场景运行状态与成功率一屏掌握,数据来自本机执行记录</p>
|
||||
</div>
|
||||
<div class="hero-side">
|
||||
<span class="hs-date">{{ dateShort }}</span>
|
||||
<span class="hs-week">{{ weekLabel }}</span>
|
||||
<div class="hs-meta">
|
||||
<i class="hs-dot" :class="{ on: onlineCount }"></i>
|
||||
{{ onlineCount }} 个平台在线 · {{ scheduleCount }} 个任务
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<!-- 指标四宫格 -->
|
||||
<section class="kpis">
|
||||
<div class="kpi">
|
||||
<b>{{ store.plugins.length }}<em> 场景</em></b>
|
||||
<span>可用场景</span>
|
||||
<div class="kpi card k-brand">
|
||||
<span class="k-label">SCENES</span>
|
||||
<b class="k-num">{{ store.plugins.length }}<em>个</em></b>
|
||||
<span class="k-sub">已授权可用场景</span>
|
||||
</div>
|
||||
<div class="kpi">
|
||||
<b>{{ scheduleCount }}<em> 任务</em></b>
|
||||
<span>定时任务</span>
|
||||
<div class="kpi card k-good">
|
||||
<span class="k-label">SCHEDULES</span>
|
||||
<b class="k-num">{{ scheduleCount }}<em>个</em></b>
|
||||
<span class="k-sub">按计划自动执行</span>
|
||||
</div>
|
||||
<div class="kpi" :class="onlineCount ? 'ok' : ''">
|
||||
<b>{{ onlineCount }}<em>/{{ store.platforms.length }}</em></b>
|
||||
<span>平台在线</span>
|
||||
<div class="kpi card k-warn">
|
||||
<span class="k-label">PLATFORMS</span>
|
||||
<b class="k-num">{{ onlineCount }}<em>/{{ store.platforms.length }}</em></b>
|
||||
<span class="k-sub">平台账号在线</span>
|
||||
</div>
|
||||
<div class="kpi" :class="lastOk === null ? '' : (lastOk ? 'ok' : 'err')">
|
||||
<b>{{ lastOk === null ? '—' : (lastOk ? '成功' : '失败') }}</b>
|
||||
<span>{{ lastRunTime || '暂无运行' }}</span>
|
||||
<div class="kpi card k-plain">
|
||||
<span class="k-label">LAST RUN</span>
|
||||
<b class="k-num last" :class="lastOk === null ? '' : (lastOk ? 'good' : 'bad')">
|
||||
{{ lastOk === null ? '—' : (lastOk ? '成功' : '失败') }}
|
||||
</b>
|
||||
<span class="k-sub">{{ lastRunTime || '暂无运行' }}</span>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<!-- 平台账号(当前登录人的 HR/OA 账号与登录状态,登录后场景按本人身份执行) -->
|
||||
<section class="block">
|
||||
<div class="block-head">
|
||||
<span class="sec-title">平台账号</span>
|
||||
<span class="rec-note">配置你自己的 HR/OA 账号</span>
|
||||
</div>
|
||||
<PlatformAccounts />
|
||||
<!-- 运行中卡 -->
|
||||
<section v-if="store.running" class="card running-card">
|
||||
<RunIndicator :name="runningName" :progress="store.progress">
|
||||
<template #tail>
|
||||
<span class="run-tail">{{ runningTail || '执行中…' }}</span>
|
||||
</template>
|
||||
</RunIndicator>
|
||||
</section>
|
||||
|
||||
<!-- 常用场景(只放前 6 个快捷入口,全部走「场景」视图) -->
|
||||
<div class="grid-2">
|
||||
<!-- 运行脉冲 -->
|
||||
<section class="card signal-card">
|
||||
<div class="card-top">
|
||||
<div class="card-titles">
|
||||
<span class="sec-eyebrow">SIGNAL</span>
|
||||
<b class="card-title">运行脉冲</b>
|
||||
<span class="card-sub">近 7 日运行分布</span>
|
||||
</div>
|
||||
<div class="legend">
|
||||
<span><i class="lg-dot ok"></i>成功</span>
|
||||
<span><i class="lg-dot bad"></i>失败</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<template v-if="trendTotal && chart">
|
||||
<div class="chart">
|
||||
<svg :viewBox="`0 0 ${chart.w} ${chart.h}`" preserveAspectRatio="none" aria-hidden="true">
|
||||
<defs>
|
||||
<linearGradient id="pulseOk" x1="0" y1="0" x2="0" y2="1">
|
||||
<stop offset="0%" class="g-top" />
|
||||
<stop offset="100%" class="g-bot" />
|
||||
</linearGradient>
|
||||
</defs>
|
||||
<path :d="chart.okArea" fill="url(#pulseOk)" />
|
||||
<path :d="chart.okLine" class="line-ok" vector-effect="non-scaling-stroke" />
|
||||
<path :d="chart.failLine" class="line-fail" vector-effect="non-scaling-stroke" />
|
||||
</svg>
|
||||
<div class="axis">
|
||||
<span v-for="(d, i) in trendDays" :key="i">{{ d.label }}</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="period">
|
||||
<div class="p-cell">
|
||||
<span class="p-k">运行总数</span>
|
||||
<b>{{ trendTotal }}</b>
|
||||
</div>
|
||||
<div class="p-cell">
|
||||
<span class="p-k">成功</span>
|
||||
<b class="good">{{ trendOk }}</b>
|
||||
</div>
|
||||
<div class="p-cell">
|
||||
<span class="p-k">失败</span>
|
||||
<b :class="trendFail ? 'bad' : ''">{{ trendFail }}</b>
|
||||
</div>
|
||||
<div class="p-cell">
|
||||
<span class="p-k">单日峰值</span>
|
||||
<b>{{ trendPeak }}</b>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<div v-else class="empty-note">暂无运行记录</div>
|
||||
</section>
|
||||
|
||||
<!-- 执行成功率(平台账号已在右侧栏常驻,这里不重复展示) -->
|
||||
<section class="card rate-card">
|
||||
<div class="card-top">
|
||||
<div class="card-titles">
|
||||
<span class="sec-eyebrow">RATE</span>
|
||||
<b class="card-title">执行成功率</b>
|
||||
<span class="card-sub">近 7 日成功占比</span>
|
||||
</div>
|
||||
<span v-if="trendTotal" class="rate-pill" :class="rateTone">{{ rateLabel }}</span>
|
||||
</div>
|
||||
<div v-if="trendTotal" class="rate-main">
|
||||
<div class="rate-ring">
|
||||
<svg viewBox="0 0 120 120" aria-hidden="true">
|
||||
<circle class="ring-track" cx="60" cy="60" r="50" />
|
||||
<circle
|
||||
class="ring-val"
|
||||
:class="rateTone"
|
||||
cx="60" cy="60" r="50"
|
||||
:style="{ strokeDasharray: `${ringDash} ${ringC}` }"
|
||||
/>
|
||||
</svg>
|
||||
<div class="ring-center">
|
||||
<span class="rate-num"><b>{{ ratePct }}</b><em>%</em></span>
|
||||
<span class="ring-cap">成功率</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="rate-stats">
|
||||
<div class="rs-row">
|
||||
<span class="rs-k"><i class="rs-dot ok"></i>成功</span>
|
||||
<b class="good">{{ trendOk }}<em>{{ ratePct }}%</em></b>
|
||||
</div>
|
||||
<div class="rs-row">
|
||||
<span class="rs-k"><i class="rs-dot bad"></i>失败</span>
|
||||
<b :class="trendFail ? 'bad' : ''">{{ trendFail }}<em>{{ 100 - ratePct }}%</em></b>
|
||||
</div>
|
||||
<div class="rs-row">
|
||||
<span class="rs-k"><i class="rs-dot neutral"></i>7 日合计</span>
|
||||
<b>{{ trendTotal }}<em>次</em></b>
|
||||
</div>
|
||||
<div class="rs-row">
|
||||
<span class="rs-k"><i class="rs-dot neutral"></i>日均运行</span>
|
||||
<b>{{ avgPerDay }}<em>次</em></b>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div v-else class="empty-note">暂无运行记录</div>
|
||||
</section>
|
||||
</div>
|
||||
|
||||
<!-- 常用场景 -->
|
||||
<section class="block">
|
||||
<div class="block-head">
|
||||
<span class="sec-title">常用场景</span>
|
||||
<el-button v-if="store.plugins.length > 6" text size="small" class="more" @click="goScenes">
|
||||
全部场景 {{ store.plugins.length }} <el-icon><ArrowRight /></el-icon>
|
||||
</el-button>
|
||||
</div>
|
||||
<div v-if="store.plugins.length" class="scenes" :style="{ '--n': Math.min(4, store.plugins.length) }">
|
||||
<button
|
||||
v-for="(p, i) in store.plugins.slice(0, 6)" :key="p.id" class="sc card"
|
||||
:class="{ running: store.running && store.selectedId === p.id }"
|
||||
@click="openPlugin(p.id)"
|
||||
>
|
||||
<span class="sc-ic" :style="{ background: grad(i) }">{{ p.name.slice(0, 1) }}</span>
|
||||
<span class="sc-body">
|
||||
<b>{{ p.name }}</b>
|
||||
<span class="sc-meta">
|
||||
v{{ p.version }}
|
||||
<template v-if="p.platform">
|
||||
<i class="sep-dot"></i>{{ platformLabel(p.platform) }}
|
||||
<em class="plat-state" :class="{ on: platformOnline(p.platform) }">
|
||||
{{ platformOnline(p.platform) ? '已登录' : '未登录' }}
|
||||
</em>
|
||||
</template>
|
||||
</span>
|
||||
</span>
|
||||
<span class="sc-go">
|
||||
<template v-if="store.running && store.selectedId === p.id">{{ store.progress }}%</template>
|
||||
<template v-else>执行</template>
|
||||
</span>
|
||||
<div class="block-titles">
|
||||
<span class="sec-eyebrow">SCENES</span>
|
||||
<b class="sec-name">常用场景</b>
|
||||
</div>
|
||||
<button v-if="store.plugins.length > 6" class="link-btn" @click="goScenes">
|
||||
全部场景 {{ store.plugins.length }} <i class="arr">→</i>
|
||||
</button>
|
||||
</div>
|
||||
<div v-else class="empty card">
|
||||
<span class="empty-emoji">🤍</span>
|
||||
<div v-if="store.plugins.length" class="scenes" :style="{ '--n': Math.min(4, store.plugins.length) }">
|
||||
<SceneCard v-for="p in store.plugins.slice(0, 6)" :key="p.id" :plugin="p" compact @open="openPlugin" />
|
||||
</div>
|
||||
<div v-else class="card empty">
|
||||
<div>
|
||||
<b>当前账号暂无可用场景</b>
|
||||
<span>请联系管理员在控制面进行授权,授权后点击右上角刷新</span>
|
||||
<span>请联系管理员在控制面进行授权,授权后在左侧「场景库」点击插件同步</span>
|
||||
</div>
|
||||
<el-button size="small" round type="primary" plain @click="goScenes">去同步</el-button>
|
||||
<button class="btn primary" @click="goScenes">去场景库</button>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<!-- 最近动态 -->
|
||||
<!-- 最近运行 -->
|
||||
<section class="block" v-if="store.recents.length">
|
||||
<div class="block-head">
|
||||
<span class="sec-title">最近动态</span>
|
||||
<span class="rec-note">最近 {{ store.recents.length }} 次执行</span>
|
||||
<div class="block-titles">
|
||||
<span class="sec-eyebrow">RECENT</span>
|
||||
<b class="sec-name">最近运行</b>
|
||||
</div>
|
||||
<span class="head-note">最近 {{ store.recents.length }} 次</span>
|
||||
</div>
|
||||
<div class="recent card">
|
||||
<button v-for="(r, i) in store.recents" :key="i" class="rec" @click="openPlugin(r.pluginId, r.runId)">
|
||||
<span class="rec-ic" :class="r.ok ? 'ok' : 'err'">{{ r.ok ? '✓' : '✕' }}</span>
|
||||
<span class="rec-name">{{ r.name }}</span>
|
||||
<span class="rec-msg" :class="r.ok ? 'ok' : 'err'">{{ r.ok ? '执行完成' : (r.error || '执行失败') }}</span>
|
||||
<span class="rec-time">{{ r.time }}</span>
|
||||
<div class="card table">
|
||||
<div class="thead">
|
||||
<span class="c-idx">#</span>
|
||||
<span class="c-name">场景</span>
|
||||
<span class="c-msg">结果</span>
|
||||
<span class="c-time">时间</span>
|
||||
</div>
|
||||
<button v-for="(r, i) in store.recents" :key="i" class="trow" @click="openPlugin(r.pluginId, r.runId)">
|
||||
<span class="c-idx num">{{ String(i + 1).padStart(2, '0') }}</span>
|
||||
<span class="c-name">
|
||||
<i class="tag" :class="r.ok ? 'ok' : 'bad'">{{ r.ok ? '成功' : '失败' }}</i>
|
||||
<b>{{ r.name }}</b>
|
||||
</span>
|
||||
<span class="c-msg" :class="r.ok ? '' : 'bad-text'">{{ r.ok ? '执行完成' : (r.error || '执行失败') }}</span>
|
||||
<span class="c-time num">{{ r.time }}</span>
|
||||
</button>
|
||||
</div>
|
||||
</section>
|
||||
@@ -92,17 +211,10 @@
|
||||
|
||||
<script setup>
|
||||
import { computed, onMounted, ref } from 'vue'
|
||||
import { ArrowRight } from '@element-plus/icons-vue'
|
||||
import { store } from '../store'
|
||||
import { listSchedules } from '../api'
|
||||
import PlatformAccounts from './PlatformAccounts.vue'
|
||||
|
||||
const GRADS = [
|
||||
'var(--grad-sky)', 'var(--grad-peach)', 'var(--grad-mint)',
|
||||
'var(--grad-lilac)', 'var(--grad-honey)', 'var(--grad-blush)',
|
||||
]
|
||||
|
||||
function grad(i) { return GRADS[i % GRADS.length] }
|
||||
import { listSchedules, fetchRuns } from '../api'
|
||||
import SceneCard from './SceneCard.vue'
|
||||
import RunIndicator from './RunIndicator.vue'
|
||||
|
||||
const scheduleCount = ref(0)
|
||||
onMounted(async () => {
|
||||
@@ -114,22 +226,118 @@ onMounted(async () => {
|
||||
|
||||
const onlineCount = computed(() => (store.platforms || []).filter((p) => p.online).length)
|
||||
|
||||
const WEEK = ['周日', '周一', '周二', '周三', '周四', '周五', '周六']
|
||||
const now = new Date()
|
||||
const pad2 = (n) => String(n).padStart(2, '0')
|
||||
const dateShort = `${pad2(now.getMonth() + 1)}.${pad2(now.getDate())}`
|
||||
const weekLabel = `${now.getFullYear()} 年 · ${WEEK[now.getDay()]}`
|
||||
|
||||
const lastOk = computed(() => (store.lastResult ? !!store.lastResult.ok : null))
|
||||
const lastRunTime = computed(() => {
|
||||
const r = store.recents[0]
|
||||
return r ? r.time : ''
|
||||
})
|
||||
|
||||
function platformLabel(id) {
|
||||
return (store.platforms.find((p) => p.id === id) || {}).label || id
|
||||
}
|
||||
function platformOnline(id) {
|
||||
return !!(store.platforms.find((p) => p.id === id) || {}).online
|
||||
const runningName = computed(() => {
|
||||
const p = (store.plugins || []).find((x) => x.id === store.selectedId)
|
||||
return p ? p.name : (store.selectedId || '')
|
||||
})
|
||||
const runningTail = computed(() => {
|
||||
const list = store.logs || []
|
||||
const l = list[list.length - 1]
|
||||
if (!l) return ''
|
||||
return String(l.msg ?? '').slice(0, 80)
|
||||
})
|
||||
|
||||
/* 近 7 日趋势:从后端运行历史(fetchRuns)按 started 时间戳归日聚合。
|
||||
不用 store.recents——它是内存态且 time 只有时分秒,重启即空、无法按日归桶 */
|
||||
const trendDays = ref([])
|
||||
onMounted(async () => {
|
||||
const now = new Date()
|
||||
const buckets = []
|
||||
for (let i = 6; i >= 0; i--) {
|
||||
const d = new Date(now); d.setDate(d.getDate() - i)
|
||||
const key = `${d.getFullYear()}-${d.getMonth()}-${d.getDate()}`
|
||||
buckets.push({ key, label: i === 0 ? '今天' : `${d.getMonth() + 1}-${d.getDate()}`, ok: 0, fail: 0 })
|
||||
}
|
||||
const keyOf = (sec) => { const d = new Date(sec * 1000); return `${d.getFullYear()}-${d.getMonth()}-${d.getDate()}` }
|
||||
try {
|
||||
const r = await fetchRuns(200)
|
||||
for (const run of r.runs || []) {
|
||||
if (!run.started) continue
|
||||
const b = buckets.find((x) => x.key === keyOf(run.started))
|
||||
if (b) { run.ok ? b.ok++ : b.fail++ }
|
||||
}
|
||||
} catch (_) { /* 拉取失败保持空态 */ }
|
||||
trendDays.value = buckets
|
||||
})
|
||||
const trendTotal = computed(() => trendDays.value.reduce((s, d) => s + d.ok + d.fail, 0))
|
||||
const trendOk = computed(() => trendDays.value.reduce((s, d) => s + d.ok, 0))
|
||||
const trendFail = computed(() => trendDays.value.reduce((s, d) => s + d.fail, 0))
|
||||
const trendPeak = computed(() => trendDays.value.reduce((m, d) => Math.max(m, d.ok + d.fail), 0))
|
||||
const ratePct = computed(() => (trendTotal.value ? Math.round((trendOk.value / trendTotal.value) * 100) : 0))
|
||||
const avgPerDay = computed(() => (trendTotal.value / 7).toFixed(1).replace(/\.0$/, ''))
|
||||
/* 成功率环:r=50 的周长作为 dasharray 基准,按占比取可见弧长 */
|
||||
const ringC = 2 * Math.PI * 50
|
||||
const ringDash = computed(() => (ringC * ratePct.value) / 100)
|
||||
const rateTone = computed(() => (ratePct.value >= 95 ? 'good' : ratePct.value >= 80 ? 'warn' : 'bad'))
|
||||
const rateLabel = computed(() => ({ good: '运行稳定', warn: '偶有失败', bad: '需重点关注' }[rateTone.value]))
|
||||
|
||||
/* 脉冲曲线:成功=平滑曲线+面积,失败=虚线;用单调三次插值(Fritsch-Carlson),
|
||||
普通 Catmull-Rom 在 0 值附近的节点会过冲下凹,单调插值保证不越过相邻点数值。
|
||||
preserveAspectRatio=none 横向拉伸,描边用 non-scaling-stroke 保持 2px 不变形 */
|
||||
const chart = computed(() => {
|
||||
const days = trendDays.value
|
||||
if (days.length < 2) return null
|
||||
const W = 640, H = 120, PAD = 14
|
||||
const max = Math.max(1, ...days.map((d) => d.ok + d.fail))
|
||||
const stepX = W / (days.length - 1)
|
||||
const yOf = (v) => H - PAD - (v / max) * (H - PAD * 2)
|
||||
const okPts = days.map((d, i) => [i * stepX, yOf(d.ok)])
|
||||
const failPts = days.map((d, i) => [i * stepX, yOf(d.fail)])
|
||||
const okLine = smoothPath(okPts)
|
||||
return {
|
||||
w: W,
|
||||
h: H,
|
||||
okLine,
|
||||
okArea: `${okLine} L ${W},${H} L 0,${H} Z`,
|
||||
failLine: smoothPath(failPts),
|
||||
}
|
||||
})
|
||||
|
||||
/* 点位 → 三次贝塞尔平滑路径(单调三次插值,避免峰谷过冲出负数) */
|
||||
function smoothPath(pts) {
|
||||
const n = pts.length
|
||||
if (n < 2) return ''
|
||||
const dx = [], slope = []
|
||||
for (let i = 0; i < n - 1; i++) {
|
||||
dx[i] = pts[i + 1][0] - pts[i][0]
|
||||
slope[i] = (pts[i + 1][1] - pts[i][1]) / dx[i]
|
||||
}
|
||||
const m = [slope[0]]
|
||||
for (let i = 1; i < n - 1; i++) {
|
||||
if (slope[i - 1] * slope[i] <= 0) m[i] = 0
|
||||
else {
|
||||
const w1 = 2 * dx[i] + dx[i - 1]
|
||||
const w2 = dx[i] + 2 * dx[i - 1]
|
||||
m[i] = (w1 + w2) / (w1 / slope[i - 1] + w2 / slope[i])
|
||||
}
|
||||
}
|
||||
m[n - 1] = slope[n - 2]
|
||||
let d = `M ${pts[0][0].toFixed(1)},${pts[0][1].toFixed(1)}`
|
||||
for (let i = 0; i < n - 1; i++) {
|
||||
const h = dx[i] / 3
|
||||
d += ` C ${(pts[i][0] + h).toFixed(1)},${(pts[i][1] + m[i] * h).toFixed(1)}`
|
||||
+ ` ${(pts[i + 1][0] - h).toFixed(1)},${(pts[i + 1][1] - m[i + 1] * h).toFixed(1)}`
|
||||
+ ` ${pts[i + 1][0].toFixed(1)},${pts[i + 1][1].toFixed(1)}`
|
||||
}
|
||||
return d
|
||||
}
|
||||
|
||||
function openPlugin(id, runId) {
|
||||
store.selectedId = id
|
||||
store.view = 'run'
|
||||
// 最近动态点击:直达该次运行的回看(运行台消费后清空);普通场景点击清掉残留意图
|
||||
// 最近运行点击:直达该次运行的回看(运行台消费后清空);普通场景点击清掉残留意图
|
||||
store.pendingReplay = runId ? { pluginId: id, runId } : null
|
||||
}
|
||||
function goScenes() {
|
||||
@@ -138,105 +346,199 @@ function goScenes() {
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.home { display: flex; flex-direction: column; gap: 20px; padding: 4px 2px 10px; flex-shrink: 0; }
|
||||
.home { display: flex; flex-direction: column; gap: var(--space-3); padding: var(--page-pad); flex-shrink: 0; container-type: inline-size; }
|
||||
.num { font-family: var(--f-num); font-variant-numeric: tabular-nums; }
|
||||
|
||||
/* ---------- 指标行(紧凑,替代问候区/统计卡) ---------- */
|
||||
.kpis { display: flex; gap: 10px; flex-wrap: wrap; }
|
||||
.kpi {
|
||||
flex: 1; min-width: 150px;
|
||||
display: flex; align-items: baseline; gap: 8px;
|
||||
padding: 10px 14px;
|
||||
background: var(--surface);
|
||||
border: 1px solid var(--border);
|
||||
border-radius: var(--radius-sm);
|
||||
/* ---------- 通用小标 / 卡头 ---------- */
|
||||
.k-label,
|
||||
.sec-eyebrow {
|
||||
display: inline-flex; align-items: center; gap: var(--space-1-5);
|
||||
font: 600 9.5px/14px var(--f-num);
|
||||
letter-spacing: .14em; text-transform: uppercase; color: var(--t4);
|
||||
}
|
||||
.kpi b { font-size: 17px; font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; line-height: 1.1; }
|
||||
.kpi b em { font-style: normal; font-size: 11px; color: var(--text-faint); font-weight: 500; }
|
||||
.kpi span { margin-left: auto; font-size: 11px; color: var(--text-faint); white-space: nowrap; }
|
||||
.kpi.ok b { color: var(--ok); }
|
||||
.kpi.err b { color: var(--err); }
|
||||
.k-label::before,
|
||||
.sec-eyebrow::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: var(--t5); }
|
||||
.k-brand .k-label::before { background: var(--brand); opacity: .8; }
|
||||
.k-good .k-label::before { background: var(--good); opacity: .8; }
|
||||
.k-warn .k-label::before { background: var(--warn); opacity: .8; }
|
||||
|
||||
.card-top { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--space-3); }
|
||||
.card-titles { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
|
||||
.card-title { font: 600 14px/20px var(--f-cn); color: var(--t1); }
|
||||
.card-sub { font: 400 10.5px/15px var(--f-cn); color: var(--t4); }
|
||||
|
||||
/* ---------- 头部 hero ---------- */
|
||||
.hero {
|
||||
display: flex; align-items: flex-end; justify-content: space-between; gap: var(--space-4);
|
||||
padding: var(--space-4) var(--space-5);
|
||||
background: linear-gradient(118deg, var(--brand-soft-2) 0%, var(--surface) 52%, var(--subtle) 100%);
|
||||
border-color: var(--brand-track);
|
||||
}
|
||||
.hero-main { min-width: 0; display: flex; flex-direction: column; }
|
||||
.hero-eyebrow {
|
||||
display: inline-flex; align-items: center; gap: var(--space-1-5);
|
||||
font: 600 9.5px/14px var(--f-num); letter-spacing: .14em;
|
||||
text-transform: uppercase; color: var(--brand);
|
||||
}
|
||||
.hero-eyebrow i { width: 6px; height: 6px; border-radius: 50%; background: var(--brand); }
|
||||
.hero-title { margin: var(--space-1) 0 var(--space-1); font: 600 24px/32px var(--f-cn); color: var(--t1); letter-spacing: -.2px; }
|
||||
.hero-sub { margin: 0; font: 400 11.5px/17px var(--f-cn); color: var(--t3); }
|
||||
.hero-side { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; flex-shrink: 0; }
|
||||
.hs-date { font: 600 20px/24px var(--f-num); color: var(--t2); letter-spacing: -.3px; }
|
||||
.hs-week { font: 400 10.5px/15px var(--f-cn); color: var(--t4); }
|
||||
.hs-meta {
|
||||
display: inline-flex; align-items: center; gap: var(--space-1-5);
|
||||
margin-top: var(--space-1-5); font: 400 10.5px/15px var(--f-cn); color: var(--t3);
|
||||
}
|
||||
.hs-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--t5); }
|
||||
.hs-dot.on { background: var(--good); }
|
||||
|
||||
/* ---------- 指标四宫格 ---------- */
|
||||
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--space-2); }
|
||||
.kpi { padding: var(--space-3) var(--space-4) var(--space-4); display: flex; flex-direction: column; gap: var(--space-1); }
|
||||
.k-brand { background: linear-gradient(160deg, var(--brand-soft) 0%, var(--surface) 64%); }
|
||||
.k-good { background: linear-gradient(160deg, var(--good-soft) 0%, var(--surface) 64%); }
|
||||
.k-warn { background: linear-gradient(160deg, var(--warn-soft) 0%, var(--surface) 64%); }
|
||||
.k-plain { background: linear-gradient(160deg, var(--subtle) 0%, var(--surface) 64%); }
|
||||
.k-num { font: 700 24px/1.15 var(--f-num); color: var(--t1); letter-spacing: -.4px; }
|
||||
.k-num em { font-style: normal; font-size: 12px; font-weight: 500; color: var(--t4); }
|
||||
.k-num.good { color: var(--good-ink); }
|
||||
.k-num.bad { color: var(--danger-ink); }
|
||||
.k-num.last { font-family: var(--f-cn); font-size: 20px; line-height: 1.35; }
|
||||
.k-sub { font: 400 10.5px/15px var(--f-cn); color: var(--t4); }
|
||||
|
||||
/* ---------- 运行中卡 ---------- */
|
||||
.running-card { padding: var(--space-3) var(--space-4); border-color: var(--brand-track); }
|
||||
.run-tail { font: 400 10.5px/15px var(--f-mono); color: var(--t4); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
|
||||
|
||||
/* ---------- 双列区 ---------- */
|
||||
.grid-2 { display: grid; grid-template-columns: 1.6fr 1fr; gap: var(--space-3); }
|
||||
.signal-card { padding: var(--space-4); }
|
||||
.legend { display: flex; align-items: center; gap: var(--space-3); font: 400 10.5px/15px var(--f-cn); color: var(--t3); flex-shrink: 0; }
|
||||
.legend span { display: inline-flex; align-items: center; gap: var(--space-1-5); }
|
||||
.lg-dot { width: 6px; height: 6px; border-radius: 50%; }
|
||||
.lg-dot.ok { background: var(--brand); }
|
||||
.lg-dot.bad { background: var(--danger); }
|
||||
|
||||
.chart { margin-top: var(--space-3); }
|
||||
.chart svg { display: block; width: 100%; height: 116px; }
|
||||
.g-top { stop-color: var(--brand); stop-opacity: .2; }
|
||||
.g-bot { stop-color: var(--brand); stop-opacity: 0; }
|
||||
.line-ok { fill: none; stroke: var(--brand); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
|
||||
.line-fail { fill: none; stroke: var(--danger); stroke-width: 1.5; stroke-dasharray: 4 4; opacity: .8; }
|
||||
.axis { display: flex; justify-content: space-between; margin-top: var(--space-1); }
|
||||
.axis span { font: 400 9.5px/13px var(--f-num); color: var(--t4); white-space: nowrap; }
|
||||
|
||||
.period {
|
||||
display: grid; grid-template-columns: repeat(4, 1fr);
|
||||
margin-top: var(--space-3); padding-top: var(--space-3);
|
||||
border-top: 1px solid var(--line-soft);
|
||||
}
|
||||
.p-cell { display: flex; flex-direction: column; gap: 2px; padding-left: var(--space-3); border-left: 1px solid var(--line-soft); }
|
||||
.p-cell:first-child { padding-left: 0; border-left: 0; }
|
||||
.p-k { font: 400 10px/14px var(--f-cn); color: var(--t4); }
|
||||
.p-cell b { font: 600 16px/1.2 var(--f-num); color: var(--t1); }
|
||||
.p-cell b.good { color: var(--good-ink); }
|
||||
.p-cell b.bad { color: var(--danger-ink); }
|
||||
|
||||
/* 执行成功率:成功率环 + 明细 */
|
||||
.rate-card { padding: var(--space-4); display: flex; flex-direction: column; gap: var(--space-3); }
|
||||
.rate-pill {
|
||||
flex-shrink: 0; padding: 0 var(--space-2); border-radius: var(--r-pill);
|
||||
font: 500 10px/18px var(--f-cn);
|
||||
}
|
||||
.rate-pill.good { color: var(--good-ink); background: var(--good-soft); }
|
||||
.rate-pill.warn { color: var(--warn-ink); background: var(--warn-soft); }
|
||||
.rate-pill.bad { color: var(--danger-ink); background: var(--danger-soft); }
|
||||
.rate-main { display: flex; align-items: center; gap: var(--space-4); }
|
||||
.rate-ring { position: relative; width: 106px; height: 106px; flex-shrink: 0; }
|
||||
.rate-ring svg { display: block; width: 100%; height: 100%; transform: rotate(-90deg); }
|
||||
.ring-track { fill: none; stroke: var(--line-soft); stroke-width: 8; }
|
||||
.ring-val { fill: none; stroke-width: 8; stroke-linecap: round; transition: stroke-dasharray var(--dur); }
|
||||
.ring-val.good { stroke: var(--good); }
|
||||
.ring-val.warn { stroke: var(--warn); }
|
||||
.ring-val.bad { stroke: var(--danger); }
|
||||
.ring-center {
|
||||
position: absolute; inset: 0; display: flex; flex-direction: column;
|
||||
align-items: center; justify-content: center; gap: 1px;
|
||||
}
|
||||
.rate-num { display: flex; align-items: baseline; gap: 1px; }
|
||||
.rate-num b { font: 700 24px/1 var(--f-num); color: var(--t1); letter-spacing: -.6px; }
|
||||
.rate-num em { font-style: normal; font-size: 11px; color: var(--t4); }
|
||||
.ring-cap { font: 400 9.5px/13px var(--f-cn); color: var(--t4); }
|
||||
.rate-stats { flex: 1; min-width: 0; display: flex; flex-direction: column; }
|
||||
.rs-row {
|
||||
display: flex; align-items: center; justify-content: space-between; gap: var(--space-2);
|
||||
padding: var(--space-1-5) 0; border-bottom: 1px dashed var(--line-soft);
|
||||
}
|
||||
.rs-row:first-child { padding-top: 0; }
|
||||
.rs-row:last-child { padding-bottom: 0; border-bottom: 0; }
|
||||
.rs-k { display: inline-flex; align-items: center; gap: var(--space-1-5); font: 400 11px/16px var(--f-cn); color: var(--t3); }
|
||||
.rs-dot { width: 6px; height: 6px; border-radius: 50%; }
|
||||
.rs-dot.ok { background: var(--good); }
|
||||
.rs-dot.bad { background: var(--danger); }
|
||||
.rs-dot.neutral { background: var(--t5); }
|
||||
.rs-row b { font: 600 13px/1.2 var(--f-num); color: var(--t1); }
|
||||
.rs-row b em { font-style: normal; margin-left: 3px; font-size: 9.5px; font-weight: 400; color: var(--t4); }
|
||||
.rs-row b.good { color: var(--good-ink); }
|
||||
.rs-row b.bad { color: var(--danger-ink); }
|
||||
|
||||
/* ---------- 分节 ---------- */
|
||||
.block { display: flex; flex-direction: column; gap: 10px; container-type: inline-size; }
|
||||
.block-head { display: flex; align-items: center; justify-content: space-between; padding: 0 2px; }
|
||||
.more { color: var(--text-faint); }
|
||||
.more:hover { color: var(--primary); }
|
||||
.rec-note { font-size: 11px; color: var(--text-faint); }
|
||||
|
||||
/* ---------- 场景卡:列数 = min(4, 场景数),按实际数量均分并占满整行;
|
||||
间隔数随列数变化,2 个场景即 2 列(与上方 2 列平台账号完全对齐);
|
||||
容器变窄时先降为 2 列、再降 1 列,避免卡片过窄 ---------- */
|
||||
.scenes {
|
||||
--max: 4;
|
||||
display: grid;
|
||||
grid-template-columns: repeat(min(var(--max), var(--n, 1)), 1fr);
|
||||
gap: 10px;
|
||||
.block { display: flex; flex-direction: column; gap: var(--space-2); container-type: inline-size; }
|
||||
.block-head { display: flex; align-items: flex-end; justify-content: space-between; padding: 0 2px; }
|
||||
.block-titles { display: flex; flex-direction: column; gap: 2px; }
|
||||
.sec-name { font: 600 15px/21px var(--f-cn); color: var(--t1); }
|
||||
.head-note { font: 400 10.5px/15px var(--f-num); color: var(--t4); }
|
||||
.link-btn {
|
||||
border: 0; background: transparent; padding: 0; cursor: pointer;
|
||||
font: 500 11px/16px var(--f-cn); color: var(--brand);
|
||||
}
|
||||
@container (max-width: 620px) { .scenes { --max: 2; } }
|
||||
@container (max-width: 380px) { .scenes { --max: 1; } }
|
||||
.sc {
|
||||
display: flex; align-items: center; gap: 10px;
|
||||
padding: 11px 13px; text-align: left;
|
||||
.link-btn:hover { color: var(--brand-ink); }
|
||||
.arr { font-style: normal; font-family: var(--f-num); }
|
||||
|
||||
/* 场景卡(SceneCard 共享);--n 由模板取 min(4, 插件数) */
|
||||
.scenes { display: grid; grid-template-columns: repeat(var(--n, 1), 1fr); gap: var(--space-2); }
|
||||
@container (max-width: 620px) { .scenes { grid-template-columns: repeat(2, 1fr); } }
|
||||
@container (max-width: 380px) { .scenes { grid-template-columns: 1fr; } }
|
||||
|
||||
.empty { display: flex; align-items: center; gap: var(--space-4); padding: var(--space-5); }
|
||||
.empty b { display: block; font-size: 13px; color: var(--t1); margin-bottom: 3px; font-weight: 600; }
|
||||
.empty span { font-size: 11.5px; color: var(--t3); }
|
||||
.empty .btn { margin-left: auto; }
|
||||
|
||||
/* ---------- 最近运行表格 ---------- */
|
||||
.table { padding: var(--space-1-5) var(--space-2) var(--space-2); }
|
||||
.thead, .trow { display: grid; grid-template-columns: 34px 1.1fr 1.6fr 96px; align-items: center; gap: var(--space-2-5); }
|
||||
.thead { padding: var(--space-2) var(--space-2-5) var(--space-1-5); border-bottom: 1px solid var(--line-soft); }
|
||||
.thead span { font: 500 10px/14px var(--f-cn); color: var(--t4); }
|
||||
.trow {
|
||||
width: 100%; padding: 0 var(--space-2-5); height: 38px; text-align: left;
|
||||
background: transparent; border: 0; border-radius: var(--r-row);
|
||||
cursor: pointer; font-family: inherit;
|
||||
transition: border-color .15s ease, box-shadow .15s ease;
|
||||
transition: background var(--dur);
|
||||
}
|
||||
.sc:hover { border-color: var(--border-strong); box-shadow: var(--shadow-sm); }
|
||||
.sc:active { transform: scale(.99); }
|
||||
.sc.running { border-color: rgba(var(--primary-rgb), .55); background: var(--surface-glow); }
|
||||
.sc-ic {
|
||||
width: 32px; height: 32px; border-radius: 9px; flex-shrink: 0;
|
||||
display: grid; place-items: center; color: var(--tile-fg);
|
||||
font-size: 13px; font-weight: 700;
|
||||
.trow:hover { background: var(--field); }
|
||||
.c-idx { font-size: 10.5px; color: var(--t4); }
|
||||
.c-name { display: flex; align-items: center; gap: var(--space-2); min-width: 0; }
|
||||
.c-name b { font: 500 12px/17px var(--f-cn); color: var(--t1); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
|
||||
.tag {
|
||||
font-style: normal; flex: 0 0 auto;
|
||||
font: 500 10px/16px var(--f-cn); padding: 0 var(--space-2); border-radius: var(--r-pill);
|
||||
}
|
||||
.sc-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
|
||||
.sc-body b { font-size: 13px; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
|
||||
.sc-meta { font-size: 10.5px; color: var(--text-faint); display: flex; align-items: center; gap: 5px; font-style: normal; white-space: nowrap; }
|
||||
.sep-dot { width: 3px; height: 3px; border-radius: 50%; background: var(--dot-muted); }
|
||||
.plat-state { font-style: normal; color: var(--text-muted-warm); }
|
||||
.plat-state.on { color: var(--ok); }
|
||||
.sc-go {
|
||||
flex-shrink: 0;
|
||||
font-size: 11px; font-weight: 600;
|
||||
color: var(--primary); background: var(--primary-weak);
|
||||
border: 1px solid rgba(var(--primary-rgb), .35);
|
||||
padding: 4px 10px; border-radius: 999px;
|
||||
transition: all .15s ease;
|
||||
}
|
||||
.sc:hover .sc-go { background: var(--primary); color: var(--on-primary); border-color: transparent; }
|
||||
.sc.running .sc-go { color: var(--on-primary); background: var(--primary); border-color: transparent; font-variant-numeric: tabular-nums; }
|
||||
.tag.ok { color: var(--good-ink); background: var(--good-soft); }
|
||||
.tag.bad { color: var(--danger-ink); background: var(--danger-soft); }
|
||||
.c-msg { font-size: 11.5px; color: var(--t3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
|
||||
.c-msg.bad-text { color: var(--danger-ink); }
|
||||
.c-time { font: 400 10.5px/15px var(--f-num); color: var(--t4); text-align: right; }
|
||||
|
||||
.empty {
|
||||
display: flex; align-items: center; gap: 14px;
|
||||
padding: 22px 20px; color: var(--text-sub);
|
||||
/* 容器查询:按首页自身宽度(而非窗口宽度)收敛,右轨显隐不再影响断点 */
|
||||
@container (max-width: 860px) {
|
||||
.kpis { grid-template-columns: repeat(2, 1fr); }
|
||||
.grid-2 { grid-template-columns: 1fr; }
|
||||
.hero { align-items: flex-start; }
|
||||
}
|
||||
.empty-emoji { font-size: 26px; }
|
||||
.empty b { display: block; font-size: 13.5px; color: var(--text); margin-bottom: 3px; font-weight: 600; }
|
||||
.empty span { font-size: 12px; color: var(--text-faint); }
|
||||
.empty .el-button { margin-left: auto; }
|
||||
|
||||
/* ---------- 最近动态 ---------- */
|
||||
.recent { padding: 4px 8px; }
|
||||
.rec {
|
||||
display: flex; align-items: center; gap: 11px;
|
||||
width: 100%; padding: 8px; text-align: left;
|
||||
background: transparent; border: none; border-radius: 8px;
|
||||
cursor: pointer; font-family: inherit;
|
||||
transition: background .13s;
|
||||
}
|
||||
.rec:hover { background: var(--surface-2); }
|
||||
.rec-ic {
|
||||
width: 20px; height: 20px; border-radius: 50%; flex-shrink: 0;
|
||||
display: grid; place-items: center; font-size: 10px; font-weight: 700;
|
||||
}
|
||||
.rec-ic.ok { background: var(--ok-weak); color: var(--ok); }
|
||||
.rec-ic.err { background: var(--err-weak); color: var(--err); }
|
||||
.rec-name { font-size: 12.5px; font-weight: 600; color: var(--text); min-width: 110px; }
|
||||
.rec-msg { flex: 1; font-size: 12px; color: var(--text-sub); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
|
||||
.rec-msg.ok { color: var(--ok); }
|
||||
.rec-msg.err { color: var(--err); }
|
||||
.rec-time { font-size: 11px; color: var(--text-faint); font-variant-numeric: tabular-nums; }
|
||||
|
||||
@media (max-width: 1100px) {
|
||||
.kpis { flex-direction: column; }
|
||||
@container (max-width: 480px) {
|
||||
.period { grid-template-columns: repeat(2, 1fr); row-gap: var(--space-3); }
|
||||
.p-cell:nth-child(3) { padding-left: 0; border-left: 0; }
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<div class="log-title">
|
||||
<i v-if="!isStatic" class="status" :class="store.wsOn ? 'on' : 'off'" :title="store.wsOn ? '实时连接正常' : '连接已中断'"></i>
|
||||
<span>{{ isStatic ? '历史回看' : '运行日志' }}</span>
|
||||
<span v-if="store.running && !isStatic" class="live">● LIVE</span>
|
||||
<RunIndicator v-if="store.running && !isStatic" variant="tag" label="LIVE" />
|
||||
<span v-else-if="visibleLogs.length" class="count">{{ visibleLogs.length }} 条</span>
|
||||
</div>
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
<div v-if="!visibleLogs.length" class="log-empty">
|
||||
<template v-if="isStatic">该次运行没有日志记录</template>
|
||||
<template v-else-if="store.logs.length">当前级别无日志</template>
|
||||
<template v-else>暂无日志,点击「一键执行」开始</template>
|
||||
<template v-else>暂无日志,点击「执行」开始</template>
|
||||
</div>
|
||||
<div v-for="(l, i) in visibleLogs" :key="i" class="log-line">
|
||||
<span class="t">{{ l.time || l.t || '' }}</span>
|
||||
@@ -39,6 +39,7 @@ import { nextTick, ref, watch, computed } from 'vue'
|
||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
import { CopyDocument, VideoPause, VideoPlay } from '@element-plus/icons-vue'
|
||||
import { store, clearLogs } from '../store'
|
||||
import RunIndicator from './RunIndicator.vue'
|
||||
|
||||
const props = defineProps({
|
||||
// 历史回看模式:传入后显示该次运行的静态日志(替代 store.logs),并隐藏清空/LIVE
|
||||
@@ -104,25 +105,25 @@ async function copy() {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
padding: 10px 14px 10px 18px;
|
||||
border-bottom: 1px solid var(--border);
|
||||
gap: 10px;
|
||||
padding: var(--space-2-5) var(--space-3) var(--space-2-5) var(--space-4);
|
||||
border-bottom: 1px solid var(--line);
|
||||
gap: var(--space-2-5);
|
||||
}
|
||||
|
||||
.log-title {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 9px;
|
||||
gap: var(--space-2);
|
||||
font-size: 13.5px;
|
||||
font-weight: 600;
|
||||
color: var(--text);
|
||||
color: var(--t1);
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.log-tools {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
gap: var(--space-1-5);
|
||||
}
|
||||
|
||||
.log-tools .el-button+.el-button {
|
||||
@@ -137,37 +138,24 @@ async function copy() {
|
||||
}
|
||||
|
||||
.status.on {
|
||||
background: var(--ok);
|
||||
box-shadow: 0 0 0 3px var(--ok-weak);
|
||||
background: var(--good);
|
||||
box-shadow: 0 0 0 3px var(--good-soft);
|
||||
}
|
||||
|
||||
.status.off {
|
||||
background: var(--dot-off);
|
||||
}
|
||||
|
||||
.live {
|
||||
color: var(--ok);
|
||||
font-size: 10px;
|
||||
animation: blink 1s infinite;
|
||||
letter-spacing: .04em;
|
||||
background: var(--idle-bar);
|
||||
}
|
||||
|
||||
.count {
|
||||
font-size: 11px;
|
||||
color: var(--text-faint);
|
||||
color: var(--t3);
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
@keyframes blink {
|
||||
50% {
|
||||
opacity: .2;
|
||||
}
|
||||
}
|
||||
|
||||
.log-empty {
|
||||
color: var(--text-faint);
|
||||
padding: 14px;
|
||||
font-family: var(--mono);
|
||||
color: var(--t3);
|
||||
padding: var(--space-3);
|
||||
font-family: var(--f-mono);
|
||||
font-size: 12px;
|
||||
}
|
||||
</style>
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,22 @@
|
||||
<template>
|
||||
<div class="page-head">
|
||||
<div class="page-title-group">
|
||||
<span v-if="eyebrow" class="eyebrow">{{ eyebrow }}</span>
|
||||
<h1 class="page-title"><slot name="title">{{ title }}</slot></h1>
|
||||
<p v-if="$slots.sub || sub" class="page-sub"><slot name="sub">{{ sub }}</slot></p>
|
||||
</div>
|
||||
<div v-if="$slots.actions" class="actions">
|
||||
<slot name="actions" />
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
// 统一页头:所有一级视图共用(样式在 style.css 的「页头」段,对齐 design-app)
|
||||
// title/sub 可传字符串,也可用 #title/#sub 插槽承载带标记的内容(如版本号、状态徽标)。
|
||||
defineProps({
|
||||
eyebrow: { type: String, default: '' },
|
||||
title: { type: String, default: '' },
|
||||
sub: { type: String, default: '' },
|
||||
})
|
||||
</script>
|
||||
@@ -1,27 +1,40 @@
|
||||
<template>
|
||||
<div class="paccs">
|
||||
<div v-for="p in platStatus" :key="p.id" class="pacc card">
|
||||
<div class="p-top">
|
||||
<span class="p-dot" :class="{ on: p.online }"></span>
|
||||
<span class="p-name">{{ p.label }}</span>
|
||||
<span class="p-state" :class="{ on: p.online }">{{ p.online ? '已登录' : '未登录' }}</span>
|
||||
<div class="plat-page">
|
||||
<PageHead eyebrow="PLATFORMS · 平台账号" title="平台账号" sub="账号密码仅保存在本机;登录后场景按当前账号身份执行" />
|
||||
<div class="paccs">
|
||||
<div v-if="!platStatus.length" class="pacc pacc-loading card">
|
||||
<span class="spin"></span>
|
||||
<b>{{ loading ? '正在读取平台清单…' : '暂无可用平台' }}</b>
|
||||
<span>{{ loading ? '首次启动需校验平台登录态,请稍候' : '请稍后重试或联系管理员' }}</span>
|
||||
</div>
|
||||
<div class="p-user" :class="{ none: !p.has_creds }">{{ p.has_creds ? p.user : '未配置个人账号' }}</div>
|
||||
<div class="p-acts">
|
||||
<el-button v-if="!p.online" size="small" :loading="busy === p.id" @click="login(p.id)">
|
||||
{{ busy === p.id ? '登录中…' : '登录' }}
|
||||
</el-button>
|
||||
<el-button v-else size="small" plain type="danger" :disabled="!!busy" @click="logout(p.id)">
|
||||
登出
|
||||
</el-button>
|
||||
<el-button size="small" text @click="openEdit(p)">配置账号</el-button>
|
||||
<div v-for="p in platStatus" :key="p.id" class="pacc card" :class="{ on: p.online }">
|
||||
<div class="p-top">
|
||||
<span class="p-dot" :class="{ on: p.online }"></span>
|
||||
<span class="p-name">{{ p.label }}</span>
|
||||
<span class="p-state" :class="{ on: p.online, waiting: p.has_creds === null }">
|
||||
{{ p.has_creds === null ? (failed ? '校验失败' : '校验中') : p.online ? '已登录' : '未登录' }}
|
||||
</span>
|
||||
</div>
|
||||
<div class="p-user" :class="{ none: p.has_creds === false, waiting: p.has_creds === null }">
|
||||
{{ p.has_creds === null ? (failed ? '登录态校验失败' : '正在校验登录态…') : p.has_creds ? p.user : '未配置个人账号' }}
|
||||
</div>
|
||||
<div class="p-acts">
|
||||
<el-button v-if="!p.online" size="small" :loading="busy === p.id" @click="login(p.id)">
|
||||
{{ busy === p.id ? '登录中…' : '登录' }}
|
||||
</el-button>
|
||||
<el-button v-else size="small" plain type="danger" :disabled="!!busy" @click="logout(p.id)">
|
||||
登出
|
||||
</el-button>
|
||||
<el-button size="small" text :disabled="p.has_creds === null" @click="openEdit(p)">配置账号</el-button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<p class="p-hint">账号密码仅本机加密保存;登录后场景按<b>你的身份</b>执行。</p>
|
||||
<p v-if="failed" class="pacc-note">
|
||||
登录态校验未完成(平台无响应或网络异常)
|
||||
<button type="button" class="pacc-retry" :disabled="loading" @click="refresh">重新校验</button>
|
||||
</p>
|
||||
|
||||
<!-- 账号配置弹窗(必须 append-to-body:本组件位于 HomePage 的 .block 内,其
|
||||
container-type: inline-size 隐含 contain: layout,会把 position:fixed 的遮罩
|
||||
劫持为卡片包含块,导致弹窗"钉"在平台账号区域而不是全屏居中) -->
|
||||
<!-- 账号配置弹窗(必须 append-to-body:避免被容器包含块劫持 fixed 定位) -->
|
||||
<el-dialog v-model="dlg" :title="`配置 ${editLabel} 账号`" width="380px" align-center
|
||||
append-to-body class="pacc-dlg">
|
||||
<el-form label-width="72px" @submit.prevent>
|
||||
@@ -46,9 +59,16 @@ import { reactive, ref, onMounted, computed } from 'vue'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import { store, log } from '../store'
|
||||
import { loginPlatform, logoutPlatform, getPlatformStatus, savePlatformCreds } from '../api'
|
||||
import PageHead from './PageHead.vue'
|
||||
|
||||
// 当前账号的平台状态(按账号隔离:各自 HR/OA 账号密码 + 各自会话)
|
||||
const platStatus = ref([]) // [{id, label, online, has_creds, user}]
|
||||
// 先用 meta 下发的平台清单即时铺出卡片(has_creds=null 表示"校验中"),
|
||||
// 状态接口返回后再补齐登录态与已存账号,避免等待外网校验时整页空白。
|
||||
const platStatus = ref(
|
||||
store.platforms.map((p) => ({ id: p.id, label: p.label, online: !!p.online, has_creds: null, user: '' }))
|
||||
)
|
||||
const loading = ref(true) // 状态接口是否仍在进行
|
||||
const failed = ref(false) // 状态接口失败(网络/平台无响应)
|
||||
const dlg = ref(false) // 配置弹窗开关
|
||||
const editing = ref(null) // 正在配置的平台对象
|
||||
const form = reactive({ user: '', pass: '' })
|
||||
@@ -59,15 +79,23 @@ const editLabel = computed(() => (editing.value ? editing.value.label : ''))
|
||||
const hasCreds = computed(() => !!(editing.value && editing.value.has_creds))
|
||||
|
||||
async function refresh() {
|
||||
loading.value = true
|
||||
failed.value = false
|
||||
try {
|
||||
const r = await getPlatformStatus()
|
||||
platStatus.value = (r && r.platforms) || []
|
||||
const list = (r && r.platforms) || []
|
||||
if (list.length) platStatus.value = list
|
||||
// 同步全局平台在线态(首页统计/场景徽章按当前账号展示)
|
||||
for (const ps of platStatus.value) {
|
||||
const p = store.platforms.find((x) => x.id === ps.id)
|
||||
if (p) p.online = ps.online
|
||||
}
|
||||
} catch (_) { /* 静默 */ }
|
||||
} catch (e) {
|
||||
failed.value = true
|
||||
log('ERROR', `平台状态校验失败:${e.message || e}`)
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(refresh)
|
||||
@@ -134,33 +162,57 @@ async function logout(id) {
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.paccs { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
|
||||
.pacc { padding: 13px 14px; display: flex; flex-direction: column; gap: 8px; }
|
||||
.p-top { display: flex; align-items: center; gap: 8px; }
|
||||
.plat-page { display: flex; flex-direction: column; gap: var(--space-3); padding: var(--page-pad); flex-shrink: 0; }
|
||||
.paccs { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: var(--space-2-5); }
|
||||
.pacc {
|
||||
padding: var(--space-3) var(--space-4); display: flex; flex-direction: column; gap: var(--space-2);
|
||||
background: linear-gradient(160deg, var(--subtle) 0%, var(--surface) 64%);
|
||||
}
|
||||
.pacc.on { background: linear-gradient(160deg, var(--good-soft) 0%, var(--surface) 64%); }
|
||||
.p-top { display: flex; align-items: center; gap: var(--space-2); }
|
||||
.p-dot {
|
||||
flex: none; width: 8px; height: 8px; border-radius: 50%;
|
||||
background: var(--sep-warm);
|
||||
background: var(--t5);
|
||||
}
|
||||
.p-dot.on { background: var(--ok); box-shadow: 0 0 0 3px rgba(var(--ok-rgb), .16); }
|
||||
.p-name { font-size: 13.5px; font-weight: 600; color: var(--text); }
|
||||
.p-dot.on { background: var(--good); box-shadow: 0 0 0 3px var(--good-soft); }
|
||||
.p-name { font: 600 13px/18px var(--f-cn); color: var(--t1); }
|
||||
.p-state {
|
||||
margin-left: auto; font-size: 11px; color: var(--text-faint);
|
||||
padding: 2px 9px; border-radius: 999px; background: var(--surface-2);
|
||||
margin-left: auto; font: 500 10.5px/16px var(--f-cn); color: var(--t3);
|
||||
padding: 1px var(--space-2); border-radius: var(--r-pill); background: var(--field);
|
||||
}
|
||||
.p-state.on { color: var(--ok); background: var(--ok-weak); }
|
||||
.p-state.on { color: var(--good-ink); background: var(--good-soft); }
|
||||
.p-user {
|
||||
font-size: 11.5px; color: var(--text); font-variant-numeric: tabular-nums;
|
||||
font: 400 11.5px/16px var(--f-num); color: var(--t2);
|
||||
white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
|
||||
}
|
||||
.p-user.none { color: var(--text-faint); }
|
||||
.p-acts { display: flex; align-items: center; gap: 6px; margin-top: 2px; }
|
||||
.p-user.none { color: var(--t4); }
|
||||
.p-user.waiting { color: var(--t4); }
|
||||
.p-acts { display: flex; align-items: center; gap: var(--space-1-5); margin-top: 2px; }
|
||||
.p-acts .el-button + .el-button { margin-left: 0; }
|
||||
.p-hint {
|
||||
grid-column: 1 / -1;
|
||||
margin: 2px 0 0; font-size: 11px; color: var(--text-faint); line-height: 1.7;
|
||||
}
|
||||
.p-hint b { color: var(--text-sub); }
|
||||
|
||||
/* 与首页常用场景共用同一容器查询断点:窄容器时同步降为 1 列,保证上下卡片始终对齐 */
|
||||
@container (max-width: 380px) { .paccs { grid-template-columns: 1fr; } }
|
||||
/* 校验中:避免空白页,给出明确的进度反馈 */
|
||||
.pacc-loading {
|
||||
grid-column: 1 / -1; min-height: 132px;
|
||||
align-items: center; justify-content: center; text-align: center;
|
||||
color: var(--t3); font-size: 12px;
|
||||
}
|
||||
.pacc-loading b { font: 600 13px/18px var(--f-cn); color: var(--t2); }
|
||||
.pacc-loading span { font-size: 11.5px; color: var(--t4); }
|
||||
.spin {
|
||||
width: 14px; height: 14px; border-radius: 50%;
|
||||
border: 2px solid var(--brand-track); border-top-color: var(--brand);
|
||||
animation: pacc-spin .8s linear infinite;
|
||||
}
|
||||
@keyframes pacc-spin { to { transform: rotate(360deg); } }
|
||||
|
||||
/* 校验失败提示(可手动重试) */
|
||||
.pacc-note {
|
||||
display: flex; align-items: center; gap: var(--space-2);
|
||||
margin: 0; font: 400 11.5px/16px var(--f-cn); color: var(--t4);
|
||||
}
|
||||
.pacc-retry {
|
||||
border: 0; background: none; padding: 0; cursor: pointer;
|
||||
font: 500 11.5px/16px var(--f-cn); color: var(--brand);
|
||||
}
|
||||
.pacc-retry:disabled { color: var(--t4); cursor: default; }
|
||||
</style>
|
||||
|
||||
@@ -1,38 +1,21 @@
|
||||
<template>
|
||||
<div v-if="plugin" class="plugin-page">
|
||||
<!-- Hero:场景身份 + 运行状态(执行入口收口在插件界面内,壳子不再提供一键执行) -->
|
||||
<section class="hero card">
|
||||
<div class="hero-main">
|
||||
<span class="avatar" :style="{ background: avatarBg }">{{ plugin.name.slice(0, 1) }}</span>
|
||||
<div class="hero-meta">
|
||||
<h2 class="p-name">{{ plugin.name }}
|
||||
<span class="ver-tag">v{{ plugin.version }}</span>
|
||||
</h2>
|
||||
<p class="p-desc">{{ plugin.description || '暂无描述' }}</p>
|
||||
<div class="p-badges">
|
||||
<span v-if="plugin.platform" class="badge" :class="platformOnline ? 'on' : 'off'">
|
||||
<i class="bdot"></i>{{ platformLabel }} {{ platformOnline ? '已登录' : '未登录' }}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="hero-actions">
|
||||
<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>
|
||||
</div>
|
||||
</section>
|
||||
<!-- 页头:场景身份 + 平台状态 + 运行中/回滚入口(与其它一级视图共用 PageHead) -->
|
||||
<PageHead eyebrow="CONSOLE · 运行台">
|
||||
<template #title>
|
||||
<span class="p-name">{{ plugin.name }}<span class="ver-tag">v{{ plugin.version }}</span></span>
|
||||
</template>
|
||||
<template #sub>{{ plugin.description || '暂无描述' }}</template>
|
||||
<template #actions>
|
||||
<span v-if="plugin.platform" class="badge" :class="platformOnline ? 'on' : 'off'">
|
||||
<i class="bdot"></i>{{ platformLabel }} {{ platformOnline ? '已登录' : '未登录' }}
|
||||
</span>
|
||||
<RunIndicator v-if="store.running" variant="chip" :progress="store.progress" />
|
||||
<button v-if="rollbackVer" class="btn rollback-btn" :disabled="store.running" @click="doRollback">
|
||||
回滚 v{{ rollbackVer }}
|
||||
</button>
|
||||
</template>
|
||||
</PageHead>
|
||||
|
||||
<!-- 结果横幅 -->
|
||||
<section v-if="store.lastResult" class="banner" :class="store.lastResult.ok ? 'ok' : 'err'">
|
||||
@@ -52,7 +35,7 @@
|
||||
<button v-for="t in tabs" :key="t.k" class="rt-tab" :class="{ on: tab === t.k }" @click="tab = t.k">
|
||||
{{ t.label }}
|
||||
<span v-if="t.k === 'log' && store.logs.length" class="rt-n">{{ store.logs.length }}</span>
|
||||
<i v-if="t.k === 'log' && store.running" class="rt-live"></i>
|
||||
<RunIndicator v-if="t.k === 'log' && store.running" variant="dot" />
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
@@ -73,7 +56,10 @@
|
||||
<section v-show="tab === 'history'" class="history">
|
||||
<div v-if="!replay" class="hist-view">
|
||||
<div class="hist-head">
|
||||
<span class="hist-title">本场景最近运行</span>
|
||||
<div class="hist-titles">
|
||||
<span class="sec-eyebrow">HISTORY</span>
|
||||
<span class="hist-title">本场景最近运行</span>
|
||||
</div>
|
||||
<el-button size="small" text :icon="Refresh" :loading="loadingRuns" @click="loadRuns">刷新</el-button>
|
||||
</div>
|
||||
<div v-if="!runs.length" class="hist-empty">
|
||||
@@ -111,7 +97,7 @@
|
||||
</div>
|
||||
|
||||
<div v-else-if="!store.plugins.length" class="empty-note">
|
||||
<b>当前账号暂无可用场景</b><br>请联系管理员在控制面进行授权,授权后点击右上角刷新
|
||||
<b>当前账号暂无可用场景</b><br>请联系管理员在控制面进行授权,授权后点左栏「插件同步」刷新
|
||||
</div>
|
||||
<div v-else class="empty-note"><b>未选择场景</b></div>
|
||||
</template>
|
||||
@@ -123,14 +109,9 @@ import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
import { store } from '../store'
|
||||
import { getRun, fetchRuns, fetchMeta, listRollbacks, rollbackPlugin } from '../api'
|
||||
import LogPanel from './LogPanel.vue'
|
||||
|
||||
const GRADS = [
|
||||
'var(--grad-sky)', 'var(--grad-peach)', 'var(--grad-mint)',
|
||||
'var(--grad-lilac)', 'var(--grad-honey)', 'var(--grad-blush)',
|
||||
]
|
||||
|
||||
const idx = computed(() => Math.max(0, store.plugins.findIndex((p) => p.id === store.selectedId)))
|
||||
const avatarBg = computed(() => GRADS[idx.value % GRADS.length])
|
||||
import RunIndicator from './RunIndicator.vue'
|
||||
import PageHead from './PageHead.vue'
|
||||
import { durText, fmtTime } from '../utils/format'
|
||||
|
||||
const plugin = computed(() => store.plugins.find((p) => p.id === store.selectedId) || null)
|
||||
|
||||
@@ -217,23 +198,6 @@ watch(
|
||||
function triggerLabel(t) {
|
||||
return ({ manual: '手动执行', schedule: '定时任务' })[t] || t || '手动执行'
|
||||
}
|
||||
function durText(s) {
|
||||
const n = parseInt(s, 10) || 0
|
||||
if (n < 60) return n + 's'
|
||||
const m = Math.floor(n / 60)
|
||||
return m + '分' + (n % 60 ? (n % 60) + 's' : '')
|
||||
}
|
||||
function fmtTime(ts) {
|
||||
if (!ts) return '—'
|
||||
const d = new Date(ts * 1000)
|
||||
if (isNaN(d.getTime())) return '—'
|
||||
const p = (n) => String(n).padStart(2, '0')
|
||||
return `${d.getMonth() + 1}-${p(d.getDate())} ${p(d.getHours())}:${p(d.getMinutes())}`
|
||||
}
|
||||
|
||||
// 执行进度环(SVG stroke-dasharray)
|
||||
const RING_C = 2 * Math.PI * 15.5
|
||||
const ringDash = computed(() => `${(store.progress / 100) * RING_C} ${RING_C}`)
|
||||
|
||||
const platformLabel = computed(() => {
|
||||
const p = store.platforms.find((x) => x.id === plugin.value?.platform)
|
||||
@@ -261,7 +225,7 @@ async function doRollback() {
|
||||
try {
|
||||
await ElMessageBox.confirm(
|
||||
`将「${plugin.value.name}」回滚到 v${rollbackVer.value}(当前 v${plugin.value.version})。` +
|
||||
'回滚后如需最新版,再次点击右上角同步即可。确定回滚?',
|
||||
'回滚后如需最新版,再次点左栏「插件同步」即可。确定回滚?',
|
||||
'插件回滚',
|
||||
{ type: 'warning', confirmButtonText: '回滚', cancelButtonText: '取消' }
|
||||
)
|
||||
@@ -300,92 +264,53 @@ function closeBanner() {
|
||||
.plugin-page {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 14px;
|
||||
gap: var(--space-3);
|
||||
padding: var(--page-pad);
|
||||
flex: 1 1 auto; /* 填满中栏上下文区,运行台内部自己滚 */
|
||||
min-height: 0;
|
||||
}
|
||||
|
||||
.card {
|
||||
background: var(--surface);
|
||||
border: 1px solid var(--border);
|
||||
border-radius: var(--radius-lg);
|
||||
box-shadow: var(--shadow-sm);
|
||||
}
|
||||
|
||||
/* ---------- Hero ---------- */
|
||||
.hero {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 20px;
|
||||
padding: 22px 24px;
|
||||
background: var(--hero-grad);
|
||||
}
|
||||
.hero-main { display: flex; align-items: center; gap: 16px; min-width: 0; }
|
||||
.avatar {
|
||||
width: 54px; height: 54px; border-radius: 16px; flex-shrink: 0;
|
||||
display: grid; place-items: center; color: var(--tile-fg);
|
||||
font-size: 22px; font-weight: 700;
|
||||
box-shadow: 0 10px 22px -10px rgba(var(--text-rgb), .35);
|
||||
}
|
||||
.hero-meta { min-width: 0; display: flex; flex-direction: column; gap: 5px; }
|
||||
.p-name { margin: 0; font-size: 19px; font-weight: 700; color: var(--text); display: flex; align-items: center; gap: 9px; }
|
||||
/* ---------- 页头内的场景身份 ---------- */
|
||||
.p-name { display: inline-flex; align-items: center; gap: var(--space-2); }
|
||||
.ver-tag {
|
||||
font-size: 10.5px; font-weight: 500; color: var(--text-faint);
|
||||
background: var(--surface-2); border: 1px solid var(--border);
|
||||
padding: 1px 8px; border-radius: 999px;
|
||||
font: 500 10.5px/16px var(--f-num); color: var(--t3);
|
||||
background: var(--field); border: 1px solid var(--line);
|
||||
padding: 0 var(--space-2); border-radius: var(--r-pill);
|
||||
}
|
||||
.p-desc { margin: 0; font-size: 12.5px; color: var(--text-sub); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 560px; }
|
||||
.p-badges { display: flex; align-items: center; gap: 8px; margin-top: 2px; }
|
||||
.badge {
|
||||
display: inline-flex; align-items: center; gap: 6px;
|
||||
font-size: 11px; color: var(--badge-warm-text);
|
||||
background: var(--badge-warm-bg); border: 1px solid var(--badge-warm-border);
|
||||
padding: 2px 10px; border-radius: 999px;
|
||||
display: inline-flex; align-items: center; gap: var(--space-1-5);
|
||||
font: 500 10.5px/16px var(--f-cn);
|
||||
padding: 1px var(--space-2-5); border-radius: var(--r-pill);
|
||||
}
|
||||
.badge.on { color: var(--ok-text); background: var(--ok-weak); border-color: rgba(var(--ok-rgb), .3); }
|
||||
.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); }
|
||||
.hero-actions { display: flex; flex-direction: column; align-items: flex-end; gap: 7px; flex-shrink: 0; }
|
||||
/* 运行状态 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);
|
||||
}
|
||||
/* 进度环用 CSS 上色(SVG 表现属性不支持 var(),故不写在 stroke="" 上) */
|
||||
.ring-bg { stroke: rgba(var(--on-primary-rgb), .35); }
|
||||
.ring-fg { stroke: var(--on-primary); }
|
||||
.ring { display: inline-flex; }
|
||||
.ring-fg { transition: stroke-dasharray .25s ease; }
|
||||
.hero-tip { font-size: 10.5px; color: var(--text-faint); letter-spacing: .02em; }
|
||||
.rollback-btn { margin-top: -3px; }
|
||||
.badge.on { color: var(--good-ink); background: var(--good-soft); }
|
||||
.badge.off { color: var(--t3); background: var(--field); }
|
||||
.bdot { width: 6px; height: 6px; border-radius: 50%; background: var(--t5); }
|
||||
.badge.on .bdot { background: var(--good); }
|
||||
.rollback-btn { height: 28px; padding: 0 var(--space-3); font-size: 11.5px; }
|
||||
|
||||
/* ---------- 结果横幅 ---------- */
|
||||
.banner {
|
||||
display: flex; align-items: center; gap: 11px;
|
||||
padding: 12px 16px; border-radius: 14px;
|
||||
display: flex; align-items: center; gap: var(--space-3);
|
||||
padding: var(--space-3) var(--space-4); border-radius: var(--r-card);
|
||||
flex-shrink: 0;
|
||||
animation: riseIn .3s var(--ease) both;
|
||||
}
|
||||
.banner.ok { background: var(--ok-weak); border: 1px solid rgba(var(--ok-rgb), .35); }
|
||||
.banner.err { background: var(--err-weak); border: 1px solid rgba(var(--err-rgb), .4); }
|
||||
.banner.ok { background: var(--good-soft); border: 1px solid var(--good-line); }
|
||||
.banner.err { background: var(--danger-soft); border: 1px solid var(--danger-line); }
|
||||
.b-ic {
|
||||
width: 26px; height: 26px; border-radius: 50%; flex-shrink: 0;
|
||||
display: grid; place-items: center; font-size: 13px; font-weight: 700; color: var(--on-primary);
|
||||
width: 24px; height: 24px; border-radius: 50%; flex-shrink: 0;
|
||||
display: grid; place-items: center; font-size: 12px; font-weight: 700; color: var(--on-primary);
|
||||
}
|
||||
.banner.ok .b-ic { background: var(--ok); }
|
||||
.banner.err .b-ic { background: var(--err); }
|
||||
.banner.ok .b-ic { background: var(--good); }
|
||||
.banner.err .b-ic { background: var(--danger); }
|
||||
.b-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
|
||||
.b-body b { font-size: 13px; color: var(--text); font-weight: 600; }
|
||||
.b-body span { font-size: 12px; color: var(--text-sub); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
|
||||
.b-body b { font-size: 12.5px; color: var(--t1); font-weight: 600; }
|
||||
.b-body span { font-size: 11.5px; color: var(--t2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
|
||||
.b-close {
|
||||
border: none; background: transparent; color: rgba(var(--text-rgb), .4);
|
||||
border: none; background: transparent; color: var(--t4);
|
||||
cursor: pointer; font-size: 12px; padding: 4px; border-radius: 50%;
|
||||
}
|
||||
.b-close:hover { color: var(--text); background: rgba(var(--on-primary-rgb), .6); }
|
||||
.b-close:hover { color: var(--t1); background: var(--field); }
|
||||
|
||||
/* ---------- 运行台(标签页容器) ---------- */
|
||||
.run-tabs {
|
||||
@@ -393,80 +318,79 @@ function closeBanner() {
|
||||
display: flex; flex-direction: column; overflow: hidden;
|
||||
}
|
||||
.rt-head {
|
||||
display: flex; align-items: center; justify-content: space-between; gap: 10px;
|
||||
padding: 0 14px; border-bottom: 1px solid var(--border); flex-shrink: 0;
|
||||
display: flex; align-items: center; justify-content: space-between; gap: var(--space-2-5);
|
||||
padding: 0 var(--space-3); border-bottom: 1px solid var(--line-soft); flex-shrink: 0;
|
||||
}
|
||||
.rt-tabs { display: flex; align-items: center; gap: 2px; }
|
||||
.rt-tab {
|
||||
display: inline-flex; align-items: center; gap: 6px;
|
||||
display: inline-flex; align-items: center; gap: var(--space-1-5);
|
||||
border: none; background: transparent; cursor: pointer; font-family: inherit;
|
||||
padding: 11px 14px; font-size: 13px; color: var(--text-sub);
|
||||
padding: var(--space-3) var(--space-3); font: 500 12.5px/18px var(--f-cn); color: var(--t3);
|
||||
border-bottom: 2px solid transparent; margin-bottom: -1px;
|
||||
transition: color .13s, border-color .13s;
|
||||
transition: color var(--dur), border-color var(--dur);
|
||||
}
|
||||
.rt-tab:hover { color: var(--text); }
|
||||
.rt-tab.on { color: var(--primary); font-weight: 600; border-bottom-color: var(--primary); }
|
||||
.rt-tab:hover { color: var(--t1); }
|
||||
.rt-tab.on { color: var(--brand-ink); font-weight: 600; border-bottom-color: var(--brand); }
|
||||
.rt-n {
|
||||
font-size: 10.5px; color: var(--text-faint); background: var(--surface-2);
|
||||
border: 1px solid var(--border); border-radius: 999px; padding: 0 6px;
|
||||
font: 500 10px/16px var(--f-num); color: var(--t3);
|
||||
background: var(--field); border-radius: var(--r-pill); padding: 0 var(--space-2);
|
||||
}
|
||||
.rt-tab.on .rt-n { color: var(--primary); background: var(--primary-weak); border-color: var(--primary-line); }
|
||||
.rt-live { width: 6px; height: 6px; border-radius: 50%; background: var(--ok); animation: rtBlink 1s infinite; }
|
||||
@keyframes rtBlink { 50% { opacity: .2; } }
|
||||
.rt-tab.on .rt-n { color: var(--brand-ink); background: var(--brand-soft); }
|
||||
|
||||
.rt-body { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; overflow: hidden; }
|
||||
.rt-log { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }
|
||||
|
||||
/* ---------- 专属界面插件 ---------- */
|
||||
.ui-pane { display: flex; flex-direction: column; flex: 1 1 auto; min-height: 0; padding: 14px 16px 16px; }
|
||||
.ui-pane { display: flex; flex-direction: column; flex: 1 1 auto; min-height: 0; padding: var(--space-3) var(--space-4) var(--space-4); }
|
||||
.pui-frame {
|
||||
display: block; width: 100%; flex: 1 1 auto; min-height: 340px;
|
||||
border: 1px solid var(--border); border-radius: 12px; background: var(--surface);
|
||||
border: 1px solid var(--line); border-radius: var(--r-sub); background: var(--surface);
|
||||
}
|
||||
|
||||
/* ---------- 历史运行 ---------- */
|
||||
.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; }
|
||||
.hist-head {
|
||||
display: flex; align-items: center; justify-content: space-between; gap: 10px;
|
||||
padding: 10px 16px 6px; flex-shrink: 0;
|
||||
display: flex; align-items: flex-start; justify-content: space-between; gap: var(--space-2-5);
|
||||
padding: var(--space-2-5) var(--space-4) var(--space-1-5); flex-shrink: 0;
|
||||
}
|
||||
.hist-title { font-size: 12.5px; font-weight: 600; color: var(--text-sub); }
|
||||
.hist-titles { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
|
||||
.hist-title { font: 600 12px/17px var(--f-cn); color: var(--t2); }
|
||||
.hist-empty {
|
||||
flex: 1 1 auto; display: grid; place-items: center;
|
||||
color: var(--text-faint); font-size: 12.5px; padding: 30px 20px; text-align: center;
|
||||
color: var(--t4); font-size: 12px; padding: var(--space-6) var(--space-5); text-align: center;
|
||||
}
|
||||
.hist-list { flex: 1 1 auto; min-height: 0; overflow: auto; list-style: none; margin: 4px 8px 10px; padding: 0; }
|
||||
.hist-list { flex: 1 1 auto; min-height: 0; overflow: auto; list-style: none; margin: var(--space-1) var(--space-2) var(--space-2-5); padding: 0; }
|
||||
.hist-item {
|
||||
display: flex; align-items: center; gap: 11px;
|
||||
padding: 10px 12px; border-radius: 12px; cursor: pointer;
|
||||
transition: background .13s ease;
|
||||
display: flex; align-items: center; gap: var(--space-3);
|
||||
padding: var(--space-2) var(--space-3); border-radius: var(--r-row); cursor: pointer;
|
||||
transition: background var(--dur);
|
||||
}
|
||||
.hist-item:hover { background: var(--surface-2); }
|
||||
.hist-item:hover { background: var(--field); }
|
||||
.hist-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
|
||||
.hist-dot.ok { background: var(--ok); box-shadow: 0 0 0 3px var(--ok-weak); }
|
||||
.hist-dot.err { background: var(--err); box-shadow: 0 0 0 3px var(--err-weak); }
|
||||
.hist-dot.ok { background: var(--good); box-shadow: 0 0 0 3px var(--good-soft); }
|
||||
.hist-dot.err { background: var(--danger); box-shadow: 0 0 0 3px var(--danger-soft); }
|
||||
.hist-meta { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
|
||||
.hist-meta b { font-size: 13px; color: var(--text); font-weight: 600; }
|
||||
.hist-time { font-size: 11.5px; color: var(--text-faint); font-variant-numeric: tabular-nums; }
|
||||
.hist-state { font-size: 12px; font-weight: 600; flex-shrink: 0; }
|
||||
.hist-state.ok { color: var(--ok); }
|
||||
.hist-state.err { color: var(--err); }
|
||||
.hist-arrow { color: var(--text-faint); font-size: 13px; flex-shrink: 0; }
|
||||
.hist-meta b { font: 600 12.5px/18px var(--f-cn); color: var(--t1); }
|
||||
.hist-time { font: 400 10.5px/15px var(--f-num); color: var(--t4); }
|
||||
.hist-state { font: 600 11.5px/16px var(--f-cn); flex-shrink: 0; }
|
||||
.hist-state.ok { color: var(--good-ink); }
|
||||
.hist-state.err { color: var(--danger-ink); }
|
||||
.hist-arrow { color: var(--t5); font-size: 13px; flex-shrink: 0; }
|
||||
|
||||
.hist-replay { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }
|
||||
.replay-head {
|
||||
display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
|
||||
padding: 8px 12px; border-bottom: 1px solid var(--border); flex-shrink: 0;
|
||||
display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap;
|
||||
padding: var(--space-2) var(--space-3); border-bottom: 1px solid var(--line-soft); flex-shrink: 0;
|
||||
}
|
||||
.replay-tags { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; min-width: 0; }
|
||||
.replay-tags { display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; min-width: 0; }
|
||||
.replay-tag {
|
||||
font-size: 11px; color: var(--text-faint); font-variant-numeric: tabular-nums;
|
||||
background: var(--surface-2); border: 1px solid var(--border);
|
||||
padding: 1px 9px; border-radius: 999px;
|
||||
font: 400 10.5px/16px var(--f-num); color: var(--t3);
|
||||
background: var(--field); border: 1px solid var(--line);
|
||||
padding: 0 var(--space-2); border-radius: var(--r-pill);
|
||||
}
|
||||
.replay-sum {
|
||||
font-size: 11.5px; color: var(--text-sub); white-space: nowrap;
|
||||
font-size: 11px; color: var(--t2); white-space: nowrap;
|
||||
overflow: hidden; text-overflow: ellipsis; max-width: 340px;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,84 @@
|
||||
<template>
|
||||
<span v-if="variant === 'dot'" class="run-ind dot" :title="label"><i class="ri-dot"></i></span>
|
||||
<span v-else-if="variant === 'tag'" class="run-ind tag"><i class="ri-dot"></i><span class="ri-label">{{ label }}</span></span>
|
||||
<div v-else class="run-ind" :class="variant">
|
||||
<div class="ri-row">
|
||||
<i class="ri-dot"></i>
|
||||
<span v-if="showLabel" class="ri-label">{{ label }}</span>
|
||||
<span v-if="variant !== 'chip' && name" class="ri-name">{{ name }}</span>
|
||||
<span class="ri-pct">{{ progress }}%</span>
|
||||
<span v-if="variant === 'chip' && showBar" class="ri-track mini"><i :style="barStyle"></i></span>
|
||||
</div>
|
||||
<template v-if="variant !== 'chip'">
|
||||
<div v-if="showBar" class="ri-track"><i :style="barStyle"></i></div>
|
||||
<div v-if="$slots.tail" class="ri-tail"><slot name="tail" /></div>
|
||||
</template>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { computed } from 'vue'
|
||||
|
||||
// 「运行中」唯一出处:颜色、脉冲与文案集中在这里,调用方只传进度/名称。
|
||||
// inline:首页运行卡、右轨当前运行(可带日志 tail 插槽);
|
||||
// chip:插件详情页头部胶囊;tag:小胶囊(右轨「进行中」/日志 LIVE);dot:仅脉冲点(标签页)。
|
||||
const props = defineProps({
|
||||
variant: { type: String, default: 'inline' }, // inline | chip | tag | dot
|
||||
name: { type: String, default: '' },
|
||||
progress: { type: Number, default: 0 },
|
||||
label: { type: String, default: '运行中' },
|
||||
showLabel: { type: Boolean, default: true },
|
||||
showBar: { type: Boolean, default: true },
|
||||
})
|
||||
|
||||
const barStyle = computed(() => ({ width: `${Math.max(0, Math.min(100, props.progress))}%` }))
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.run-ind { --ri-ink: var(--brand); --ri-track: var(--brand-track); --ri-soft: var(--brand-soft); }
|
||||
|
||||
.ri-dot {
|
||||
width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0;
|
||||
background: var(--ri-ink); animation: riPulse 1.4s infinite;
|
||||
}
|
||||
@keyframes riPulse {
|
||||
0%, 100% { box-shadow: 0 0 0 0 var(--ri-soft); }
|
||||
50% { box-shadow: 0 0 0 4px var(--ri-soft); }
|
||||
}
|
||||
|
||||
.ri-row { display: flex; align-items: center; gap: var(--space-2); min-width: 0; }
|
||||
.ri-label { font: 600 12px/17px var(--f-cn); color: var(--t1); flex-shrink: 0; }
|
||||
.ri-name {
|
||||
flex: 1; min-width: 0; font-size: 12px; font-weight: 600; color: var(--t1);
|
||||
white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
|
||||
}
|
||||
.ri-pct { font: 600 12px/1 var(--f-num); color: var(--ri-ink); flex-shrink: 0; }
|
||||
|
||||
.ri-track { height: 5px; border-radius: 3px; background: var(--ri-track); overflow: hidden; }
|
||||
.ri-track i { display: block; height: 100%; border-radius: 3px; background: var(--ri-ink); transition: width .5s var(--ease); }
|
||||
|
||||
.run-ind.inline { display: flex; flex-direction: column; gap: var(--space-2); }
|
||||
.ri-tail { display: flex; flex-direction: column; gap: 3px; max-height: 72px; overflow: hidden; }
|
||||
|
||||
/* 插件详情页胶囊:仅回显进度,执行入口在插件界面内 */
|
||||
.run-ind.chip { display: inline-flex; align-items: center; padding: var(--space-1-5) var(--space-3); border-radius: var(--r-pill); background: var(--ri-soft); }
|
||||
.run-ind.chip .ri-row { gap: var(--space-1-5); }
|
||||
.run-ind.chip .ri-dot { width: 5px; height: 5px; animation: riBlink 1s infinite; }
|
||||
.run-ind.chip .ri-label { font-size: 12px; color: var(--brand-ink); }
|
||||
.run-ind.chip .ri-pct { font-size: 12px; }
|
||||
.run-ind.chip .ri-track.mini { width: 56px; height: 4px; border-radius: 2px; }
|
||||
@keyframes riBlink { 50% { opacity: .25; } }
|
||||
|
||||
/* 小胶囊:右轨「进行中」、日志 LIVE(替代各页面自定义的脉动态样式) */
|
||||
.run-ind.tag {
|
||||
display: inline-flex; align-items: center; gap: var(--space-1);
|
||||
height: 20px; padding: 0 var(--space-2);
|
||||
border-radius: var(--r-pill); background: var(--ri-soft);
|
||||
}
|
||||
.run-ind.tag .ri-dot { width: 5px; height: 5px; }
|
||||
.run-ind.tag .ri-label { font: 500 10px/1 var(--f-cn); color: var(--brand-ink); }
|
||||
|
||||
/* 仅脉冲点:运行台标签页等只需状态提示的位置 */
|
||||
.run-ind.dot { display: inline-flex; align-items: center; }
|
||||
.run-ind.dot .ri-dot { width: 6px; height: 6px; }
|
||||
</style>
|
||||
@@ -0,0 +1,116 @@
|
||||
<template>
|
||||
<button class="scene-card card" :class="{ running, compact }" @click="$emit('open', plugin.id)">
|
||||
<span v-if="compact" class="sc-dot" :style="{ background: dotColor }"></span>
|
||||
<span v-else class="sc-ic" :style="{ color: dotColor, background: tileBg }">{{ initial }}</span>
|
||||
<span class="sc-body">
|
||||
<span class="sc-head">
|
||||
<b class="sc-name">{{ plugin.name }}</b>
|
||||
<em v-if="!compact && plugin.category" class="sc-cat">{{ plugin.category }}</em>
|
||||
</span>
|
||||
<span v-if="!compact" class="sc-desc">{{ plugin.description || '暂无描述' }}</span>
|
||||
<span class="sc-meta">
|
||||
<em class="ver">v{{ plugin.version }}</em>
|
||||
<span v-if="plugin.platform" class="plat" :class="platformOnline ? 'on' : 'off'"
|
||||
:title="`${platformLabel} ${platformOnline ? '已登录' : '未登录,请先在运行台登录'}`">
|
||||
<i class="dot"></i>{{ platformLabel }} · {{ platformOnline ? '已登录' : '未登录' }}
|
||||
</span>
|
||||
</span>
|
||||
</span>
|
||||
<span class="sc-go" :class="{ busy: running }">
|
||||
<template v-if="running">{{ store.progress }}%</template>
|
||||
<svg v-else width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor"
|
||||
stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
|
||||
<path d="M4 12h16" /><path d="m13 5 7 7-7 7" />
|
||||
</svg>
|
||||
</span>
|
||||
</button>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { computed } from 'vue'
|
||||
import { store } from '../store'
|
||||
import { sceneDotColor } from '../utils/theme'
|
||||
|
||||
// 场景卡:首页「常用场景」(compact,无描述)与场景库共用。
|
||||
// 色点按插件在总清单中的位置取色,搜索/筛选/分组后颜色仍稳定。
|
||||
const props = defineProps({
|
||||
plugin: { type: Object, required: true },
|
||||
compact: { type: Boolean, default: false },
|
||||
})
|
||||
defineEmits(['open'])
|
||||
|
||||
const dotColor = computed(() => sceneDotColor(store.plugins.findIndex((p) => p.id === props.plugin.id)))
|
||||
const tileBg = computed(() => `color-mix(in srgb, ${dotColor.value} 13%, var(--surface))`)
|
||||
const initial = computed(() => (props.plugin.name || '·').trim().slice(0, 1))
|
||||
const platform = computed(() => store.platforms.find((p) => p.id === props.plugin.platform) || null)
|
||||
const platformLabel = computed(() => platform.value?.label || props.plugin.platform || '')
|
||||
const platformOnline = computed(() => !!platform.value?.online)
|
||||
const running = computed(() => store.running && store.selectedId === props.plugin.id)
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.scene-card {
|
||||
position: relative;
|
||||
display: flex; align-items: center; gap: var(--space-3);
|
||||
padding: var(--space-3) var(--space-4); text-align: left;
|
||||
cursor: pointer; font-family: inherit;
|
||||
background: linear-gradient(160deg, var(--subtle) 0%, var(--surface) 58%);
|
||||
transition: border-color var(--dur), box-shadow var(--dur), transform var(--dur);
|
||||
}
|
||||
.scene-card:hover { border-color: var(--brand-track); box-shadow: var(--sh-float); transform: translateY(-2px); }
|
||||
.scene-card:active { transform: translateY(0) scale(.995); }
|
||||
.scene-card.running {
|
||||
border-color: var(--brand-track);
|
||||
background: linear-gradient(160deg, var(--brand-soft) 0%, var(--surface) 70%);
|
||||
}
|
||||
.scene-card.compact {
|
||||
background: var(--surface);
|
||||
padding: var(--space-2-5) var(--space-3); gap: var(--space-2);
|
||||
}
|
||||
.scene-card.compact:hover { transform: none; box-shadow: var(--sh-card); }
|
||||
|
||||
.sc-dot { width: 6px; height: 6px; border-radius: 3px; flex-shrink: 0; }
|
||||
.sc-ic {
|
||||
width: 36px; height: 36px; border-radius: var(--r-sub); flex-shrink: 0;
|
||||
display: grid; place-items: center; background: var(--brand-soft);
|
||||
font: 600 14px/1 var(--f-cn);
|
||||
}
|
||||
.sc-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
|
||||
.sc-head { display: flex; align-items: center; gap: var(--space-2); min-width: 0; }
|
||||
.sc-name {
|
||||
min-width: 0; font: 600 13px/18px var(--f-cn); color: var(--t1);
|
||||
white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
|
||||
}
|
||||
.sc-cat {
|
||||
flex-shrink: 0; font-style: normal; font: 500 9.5px/15px var(--f-cn);
|
||||
color: var(--brand-ink); background: var(--brand-soft);
|
||||
border: 1px solid var(--brand-track); border-radius: var(--r-pill);
|
||||
padding: 0 var(--space-2);
|
||||
}
|
||||
.sc-desc { font-size: 11.5px; color: var(--t4); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
|
||||
.sc-meta { display: flex; align-items: center; gap: var(--space-2); margin-top: 1px; }
|
||||
.ver { font-style: normal; font: 400 10.5px/15px var(--f-num); color: var(--t4); flex-shrink: 0; }
|
||||
.plat {
|
||||
display: inline-flex; align-items: center; gap: 5px;
|
||||
font-size: 10.5px; color: var(--t3);
|
||||
white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
|
||||
}
|
||||
.plat .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--t5); flex-shrink: 0; }
|
||||
.plat.on { color: var(--good-ink); }
|
||||
.plat.on .dot { background: var(--good); }
|
||||
.plat.off { color: var(--warn-ink); }
|
||||
.plat.off .dot { background: var(--warn); }
|
||||
|
||||
.sc-go {
|
||||
flex-shrink: 0; width: 26px; height: 26px; display: grid; place-items: center;
|
||||
font: 600 12px/1 var(--f-num); color: var(--t3);
|
||||
background: var(--field); border: 1px solid var(--line-btn);
|
||||
border-radius: 50%; transition: all var(--dur);
|
||||
}
|
||||
.sc-go svg { display: block; }
|
||||
.sc-go.busy { font-size: 9.5px; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
|
||||
.scene-card.compact .sc-go { width: 22px; height: 22px; font-size: 11px; }
|
||||
.scene-card.compact .sc-go.busy { font-size: 8.5px; }
|
||||
.scene-card:hover .sc-go { background: var(--brand); color: var(--on-primary); border-color: transparent; box-shadow: var(--sh-brand-sm); }
|
||||
.scene-card.running .sc-go { background: var(--brand); color: var(--on-primary); border-color: transparent; }
|
||||
</style>
|
||||
@@ -1,80 +1,98 @@
|
||||
<template>
|
||||
<div class="scenes-page">
|
||||
<div class="head">
|
||||
<div class="ident">
|
||||
<span class="avatar"><el-icon><Collection /></el-icon></span>
|
||||
<div class="ident-meta">
|
||||
<h2>全部场景</h2>
|
||||
<p>当前账号可用的 {{ store.plugins.length }} 个场景,点击行进入运行台</p>
|
||||
<!-- 页头:标题 + 搜索/计数同排 -->
|
||||
<PageHead eyebrow="LIBRARY · 场景库" title="全部场景" sub="按账号授权自动同步 · 点击卡片进入场景">
|
||||
<template #actions>
|
||||
<div class="search tool-search">
|
||||
<svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"><circle cx="11" cy="11" r="6.6"/><path d="M16.2 16.2 21 21"/></svg>
|
||||
<input v-model="q" placeholder="搜索场景" @input="onFilter" />
|
||||
</div>
|
||||
</div>
|
||||
<span class="dim num">共 {{ filtered.length }} / {{ store.plugins.length }}</span>
|
||||
</template>
|
||||
</PageHead>
|
||||
|
||||
<!-- 分类筛选:横向 chips,一眼看到各分类规模 -->
|
||||
<div class="cat-bar">
|
||||
<button v-for="c in catTabs" :key="c.key" type="button" class="chip"
|
||||
:class="{ on: cat === c.key }" @click="pickCat(c.key)">
|
||||
<span class="chip-name">{{ c.label }}</span>
|
||||
<span class="chip-n">{{ c.n }}</span>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div class="sc-list card">
|
||||
<button
|
||||
v-for="(p, i) in pagedList" :key="p.id" class="sc-row"
|
||||
:class="{ running: store.running && store.selectedId === p.id }"
|
||||
@click="open(p.id)"
|
||||
>
|
||||
<span class="sc-ic" :style="{ background: grad((page - 1) * pageSize + i) }">{{ p.name.slice(0, 1) }}</span>
|
||||
<span class="sc-body">
|
||||
<span class="sc-title">
|
||||
<b>{{ p.name }}</b>
|
||||
<em>v{{ p.version }}</em>
|
||||
</span>
|
||||
<span class="sc-desc">{{ p.description || '暂无描述' }}</span>
|
||||
<span v-if="p.platform" class="sc-meta">
|
||||
{{ platformLabel(p.platform) }}
|
||||
<i class="sep-dot"></i>
|
||||
<em class="plat-state" :class="{ on: platformOnline(p.platform) }">
|
||||
{{ platformOnline(p.platform) ? '已登录' : '未登录' }}
|
||||
</em>
|
||||
</span>
|
||||
</span>
|
||||
<span class="sc-go">
|
||||
<template v-if="store.running && store.selectedId === p.id">{{ store.progress }}%</template>
|
||||
<template v-else>执行</template>
|
||||
</span>
|
||||
</button>
|
||||
<!-- 卡片网格:自适应列数,留白取代密排 -->
|
||||
<div class="sc-grid">
|
||||
<SceneCard v-for="p in pagedList" :key="p.id" :plugin="p" @open="open" />
|
||||
<div v-if="!store.plugins.length" class="sc-empty">
|
||||
<span class="empty-emoji">🤍</span>
|
||||
<b>当前账号暂无可用场景</b>
|
||||
<span>请联系管理员在控制面进行授权,授权后点左栏「同步」刷新</span>
|
||||
</div>
|
||||
<div v-else-if="!filtered.length" class="sc-empty">
|
||||
<b>未找到匹配的场景</b>
|
||||
<span>换个关键词或分类试试</span>
|
||||
</div>
|
||||
</div>
|
||||
<el-pagination v-if="store.plugins.length > pageSize" class="sc-pager" small background
|
||||
layout="total, prev, pager, next" :total="store.plugins.length" :page-size="pageSize"
|
||||
<el-pagination v-if="filtered.length > pageSize" class="sc-pager" size="small" background
|
||||
layout="total, prev, pager, next" :total="filtered.length" :page-size="pageSize"
|
||||
:current-page="page" @current-change="(p) => page = p" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { computed, ref, watch } from 'vue'
|
||||
import { Collection } from '@element-plus/icons-vue'
|
||||
import { store } from '../store'
|
||||
import PageHead from './PageHead.vue'
|
||||
import SceneCard from './SceneCard.vue'
|
||||
|
||||
// ---- 分页:每页 10 个场景,避免长列表刷屏 ----
|
||||
const CAT_FALLBACK = '其他'
|
||||
|
||||
// ---- 搜索 + 分类筛选:在分页之上再提供定位能力(插件多时的全览入口) ----
|
||||
const q = ref('')
|
||||
const cat = ref('')
|
||||
const page = ref(1)
|
||||
const pageSize = 10
|
||||
const pagedList = computed(() => store.plugins.slice((page.value - 1) * pageSize, page.value * pageSize))
|
||||
const pageSize = 12
|
||||
|
||||
const filtered = computed(() => {
|
||||
const kw = q.value.trim().toLowerCase()
|
||||
return store.plugins.filter((p) => {
|
||||
if (cat.value && ((p.category || '').trim() || CAT_FALLBACK) !== cat.value) return false
|
||||
if (!kw) return true
|
||||
return (p.name || '').toLowerCase().includes(kw) ||
|
||||
(p.description || '').toLowerCase().includes(kw) ||
|
||||
(p.id || '').toLowerCase().includes(kw)
|
||||
})
|
||||
})
|
||||
const pagedList = computed(() => filtered.value.slice((page.value - 1) * pageSize, page.value * pageSize))
|
||||
|
||||
// 分类 chips(含数量):按数量降序,未分类归「其他」;首项「全部」
|
||||
const cats = computed(() => {
|
||||
const m = new Map()
|
||||
for (const p of store.plugins) {
|
||||
const k = (p.category || '').trim() || CAT_FALLBACK
|
||||
m.set(k, (m.get(k) || 0) + 1)
|
||||
}
|
||||
return [...m.entries()]
|
||||
.map(([key, n]) => ({ key, n }))
|
||||
.sort((a, b) => b.n - a.n || a.key.localeCompare(b.key, 'zh'))
|
||||
})
|
||||
const catTabs = computed(() => [
|
||||
{ key: '', label: '全部', n: store.plugins.length },
|
||||
...cats.value.map((c) => ({ key: c.key, label: c.key, n: c.n })),
|
||||
])
|
||||
|
||||
function pickCat(key) {
|
||||
if (cat.value === key) return
|
||||
cat.value = key
|
||||
onFilter()
|
||||
}
|
||||
|
||||
function onFilter() { page.value = 1 }
|
||||
// 同步/撤销授权后当前页可能超界,自动回退
|
||||
watch(() => store.plugins.length, (n) => {
|
||||
const max = Math.max(1, Math.ceil(n / pageSize))
|
||||
const max = Math.max(1, Math.ceil(filtered.value.length / pageSize))
|
||||
if (page.value > max) page.value = max
|
||||
})
|
||||
|
||||
const GRADS = [
|
||||
'var(--grad-sky)', 'var(--grad-peach)', 'var(--grad-mint)',
|
||||
'var(--grad-lilac)', 'var(--grad-honey)', 'var(--grad-blush)',
|
||||
]
|
||||
function grad(i) { return GRADS[i % GRADS.length] }
|
||||
|
||||
function platformLabel(id) {
|
||||
return (store.platforms.find((p) => p.id === id) || {}).label || id
|
||||
}
|
||||
function platformOnline(id) {
|
||||
return !!(store.platforms.find((p) => p.id === id) || {}).online
|
||||
}
|
||||
function open(id) {
|
||||
store.selectedId = id
|
||||
store.view = 'run'
|
||||
@@ -83,57 +101,49 @@ function open(id) {
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.scenes-page { display: flex; flex-direction: column; gap: 14px; padding: 4px 2px 10px; flex-shrink: 0; }
|
||||
.head { display: flex; align-items: center; justify-content: space-between; }
|
||||
.ident { display: flex; align-items: center; gap: 12px; }
|
||||
.avatar {
|
||||
width: 36px; height: 36px; border-radius: 10px; flex-shrink: 0;
|
||||
display: grid; place-items: center; color: var(--tile-fg);
|
||||
background: var(--grad-sky); font-size: 15px;
|
||||
}
|
||||
.ident-meta h2 { margin: 0; font-size: 16px; font-weight: 700; color: var(--text); }
|
||||
.ident-meta p { margin: 2px 0 0; font-size: 12px; color: var(--text-faint); }
|
||||
.scenes-page { display: flex; flex-direction: column; gap: var(--space-3); padding: var(--page-pad); flex-shrink: 0; }
|
||||
.num { font-family: var(--f-num); font-variant-numeric: tabular-nums; }
|
||||
|
||||
.sc-list { display: flex; flex-direction: column; overflow: hidden; }
|
||||
.sc-row {
|
||||
display: flex; align-items: center; gap: 12px;
|
||||
padding: 12px 16px; width: 100%; text-align: left;
|
||||
border: none; border-bottom: 1px solid var(--border);
|
||||
background: transparent; cursor: pointer; font-family: inherit;
|
||||
transition: background .13s;
|
||||
/* ---------- 头部工具条(在 PageHead 的 actions 内) ---------- */
|
||||
.search {
|
||||
height: 32px; display: flex; align-items: center; gap: var(--space-2);
|
||||
padding: 0 var(--space-2-5); border-radius: var(--r-field);
|
||||
background: var(--surface); border: 1px solid var(--line);
|
||||
transition: background var(--dur), border-color var(--dur);
|
||||
}
|
||||
.sc-row:last-child { border-bottom: none; }
|
||||
.sc-row:hover { background: var(--surface-2); }
|
||||
.sc-row.running { background: var(--primary-tint); }
|
||||
.sc-ic {
|
||||
width: 34px; height: 34px; border-radius: 10px; flex-shrink: 0;
|
||||
display: grid; place-items: center; color: var(--tile-fg);
|
||||
font-size: 14px; font-weight: 700;
|
||||
}
|
||||
.sc-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
|
||||
.sc-title { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
|
||||
.sc-title b { font-size: 13.5px; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
|
||||
.sc-title em { font-style: normal; font-size: 10.5px; color: var(--text-faint); font-family: var(--mono); flex-shrink: 0; }
|
||||
.sc-desc { font-size: 12px; color: var(--text-sub); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
|
||||
.sc-meta { display: flex; align-items: center; gap: 6px; font-size: 10.5px; color: var(--text-faint); font-style: normal; }
|
||||
.sep-dot { width: 3px; height: 3px; border-radius: 50%; background: var(--dot-muted); }
|
||||
.plat-state { font-style: normal; color: var(--text-muted-warm); }
|
||||
.plat-state.on { color: var(--ok); }
|
||||
.sc-go {
|
||||
flex-shrink: 0; font-size: 12px; font-weight: 600;
|
||||
color: var(--primary); background: var(--primary-weak);
|
||||
border: 1px solid rgba(var(--primary-rgb), .35);
|
||||
padding: 5px 14px; border-radius: 999px;
|
||||
transition: all .15s ease;
|
||||
}
|
||||
.sc-row:hover .sc-go { background: var(--primary); color: var(--on-primary); border-color: transparent; }
|
||||
.sc-row.running .sc-go { color: var(--on-primary); background: var(--primary); border-color: transparent; font-variant-numeric: tabular-nums; }
|
||||
.search:focus-within { background: var(--surface); border-color: var(--brand-track); }
|
||||
.search svg { flex: 0 0 13px; color: var(--t4); }
|
||||
.search input { flex: 1; min-width: 0; border: 0; background: transparent; outline: none; font: 400 11.5px/16px var(--f-cn); color: var(--t1); }
|
||||
.search input::placeholder { color: var(--t4); }
|
||||
.tool-search { width: 200px; }
|
||||
.dim { font-size: 11px; color: var(--t4); }
|
||||
|
||||
/* ---------- 分类 chips ---------- */
|
||||
.cat-bar { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-1-5); }
|
||||
.chip {
|
||||
display: inline-flex; align-items: center; gap: var(--space-1-5);
|
||||
height: 26px; padding: 0 var(--space-2-5);
|
||||
border: 1px solid var(--line); border-radius: var(--r-pill);
|
||||
background: var(--surface); color: var(--t2); cursor: pointer;
|
||||
font: 500 11.5px/1 var(--f-cn);
|
||||
transition: background var(--dur), border-color var(--dur), color var(--dur);
|
||||
}
|
||||
.chip:hover { border-color: var(--border-hover); color: var(--t1); }
|
||||
.chip.on { background: var(--brand-soft); border-color: var(--brand-track); color: var(--brand-ink); }
|
||||
.chip-n { font: 500 10.5px/1 var(--f-num); color: var(--t4); }
|
||||
.chip.on .chip-n { color: var(--brand); }
|
||||
|
||||
/* ---------- 卡片网格(卡片本身为 SceneCard 共享) ---------- */
|
||||
.sc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: var(--space-3); }
|
||||
|
||||
/* ---------- 空态 ---------- */
|
||||
.sc-empty {
|
||||
display: flex; flex-direction: column; align-items: center; gap: 4px;
|
||||
padding: 34px 20px; color: var(--text-faint); font-size: 12.5px;
|
||||
grid-column: 1 / -1;
|
||||
display: flex; flex-direction: column; align-items: center; gap: var(--space-1);
|
||||
padding: var(--space-6) var(--space-5); color: var(--t4); font-size: 12px;
|
||||
background: var(--surface); border: 1px dashed var(--line);
|
||||
border-radius: var(--r-card);
|
||||
}
|
||||
.sc-empty .empty-emoji { font-size: 26px; }
|
||||
.sc-empty b { color: var(--text-sub); font-size: 13.5px; font-weight: 600; }
|
||||
.sc-pager { justify-content: center; }
|
||||
.sc-empty b { color: var(--t2); font-size: 13px; font-weight: 600; }
|
||||
.sc-pager { justify-content: center; padding: var(--space-1) 0 var(--space-2); }
|
||||
</style>
|
||||
|
||||
@@ -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%;
|
||||
|
||||
@@ -0,0 +1,93 @@
|
||||
import { computed, ref } from 'vue'
|
||||
import { store } from '../store'
|
||||
import { fetchRuns } from '../api'
|
||||
|
||||
// 左侧场景库:搜索 + 最近使用置顶 + 分类折叠分组。
|
||||
// 插件多起来后不再全量平铺靠滚动条:提供快速搜索、高频场景置顶、按分类折叠。
|
||||
// 分类来自 plugin.json 的 category(registry.pluginSchema 透传),未分类归「其他」。
|
||||
export const SHOW_SEARCH_MIN = 8 // 插件数超过该值才显示搜索框(少时保持清爽)
|
||||
const AUTO_COLLAPSE_MIN = 12 // 超过该值才默认折叠「非当前选中」的分组
|
||||
export const RECENT_KEY = '__recent__'
|
||||
const CAT_FALLBACK = '其他'
|
||||
const RECENT_MAX = 5 // 「最近使用」置顶条数
|
||||
|
||||
export function useSceneLibrary() {
|
||||
const sceneQuery = ref('')
|
||||
const recentRuns = ref([]) // 持久化最近运行(/api/runs,账号维度,新的在前)
|
||||
const groupOverride = ref({}) // 手动展开/折叠覆盖:{ groupKey: true=展开 false=折叠 }
|
||||
|
||||
function catLabel(c) { return (c || '').trim() || CAT_FALLBACK }
|
||||
|
||||
const filteredPlugins = computed(() => {
|
||||
const q = sceneQuery.value.trim().toLowerCase()
|
||||
if (!q) return store.plugins
|
||||
return store.plugins.filter((p) =>
|
||||
(p.name || '').toLowerCase().includes(q) ||
|
||||
(p.description || '').toLowerCase().includes(q) ||
|
||||
(p.id || '').toLowerCase().includes(q))
|
||||
})
|
||||
|
||||
const sceneGroups = computed(() => {
|
||||
const map = new Map()
|
||||
for (const p of filteredPlugins.value) {
|
||||
const key = catLabel(p.category)
|
||||
if (!map.has(key)) map.set(key, [])
|
||||
map.get(key).push(p)
|
||||
}
|
||||
// 大组靠前(按数量降序,再按名称),避免最常用的分组沉底
|
||||
return [...map.entries()]
|
||||
.map(([key, items]) => ({ key, label: key, items }))
|
||||
.sort((a, b) => b.items.length - a.items.length || a.label.localeCompare(b.label, 'zh'))
|
||||
})
|
||||
|
||||
// 最近使用:取持久化最近运行的「不同插件」,且仍在当前账号可用清单内
|
||||
const recentScenes = computed(() => {
|
||||
const seen = new Set()
|
||||
const out = []
|
||||
for (const r of recentRuns.value) {
|
||||
if (out.length >= RECENT_MAX) break
|
||||
if (!r.plugin_id || seen.has(r.plugin_id)) continue
|
||||
const p = store.plugins.find((x) => x.id === r.plugin_id)
|
||||
if (!p) continue
|
||||
seen.add(r.plugin_id)
|
||||
out.push(p)
|
||||
}
|
||||
return out
|
||||
})
|
||||
|
||||
// 场景色点按插件在总清单里的位置取(分组/搜索后颜色仍稳定不跳)
|
||||
function pluginIndex(p) {
|
||||
return store.plugins.findIndex((x) => x.id === p.id)
|
||||
}
|
||||
|
||||
function grpDefaultExpanded(key) {
|
||||
if (sceneQuery.value.trim()) return true // 搜索时全展开(命中即显示)
|
||||
if (key === RECENT_KEY) return true
|
||||
if (store.plugins.length <= AUTO_COLLAPSE_MIN) return true // 数量少不折叠
|
||||
const g = sceneGroups.value.find((x) => x.key === key)
|
||||
return !!(g && g.items.some((p) => p.id === store.selectedId)) // 大列表默认只展开当前选中所在组
|
||||
}
|
||||
function grpCollapsed(key) {
|
||||
const ov = groupOverride.value[key]
|
||||
if (ov !== undefined) return !ov
|
||||
return !grpDefaultExpanded(key)
|
||||
}
|
||||
function toggleGroup(key) {
|
||||
if (sceneQuery.value.trim()) return // 搜索态强制全展开,不响应折叠
|
||||
groupOverride.value = { ...groupOverride.value, [key]: grpCollapsed(key) }
|
||||
}
|
||||
|
||||
// 最近使用数据源:持久化运行历史(与右栏「最近运行」同源,重启不丢)
|
||||
async function loadRecentScenes() {
|
||||
if (!store.current) return
|
||||
try {
|
||||
const r = await fetchRuns(10)
|
||||
recentRuns.value = r.runs || []
|
||||
} catch (_) { /* 后端未就绪:静默,下次刷新再补 */ }
|
||||
}
|
||||
|
||||
return {
|
||||
sceneQuery, filteredPlugins, sceneGroups, recentScenes,
|
||||
pluginIndex, grpCollapsed, toggleGroup, loadRecentScenes,
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
import { ref } from 'vue'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import { checkShellUpdate, getShellStatus } from '../api'
|
||||
|
||||
// 手动「检查更新」:触发秒级版本比对 → 轮询检查结束后交回结果处理。
|
||||
// statusRef 为壳子状态(useDownloadJob.state),轮询期间同步回写,保证顶栏/状态栏一致。
|
||||
export function useShellCheck(statusRef, onResult) {
|
||||
const checking = ref(false)
|
||||
|
||||
async function check() {
|
||||
if (checking.value) return
|
||||
try {
|
||||
await checkShellUpdate()
|
||||
} catch (e) {
|
||||
ElMessage.error('检查更新失败:' + (e.message || e))
|
||||
return
|
||||
}
|
||||
checking.value = true
|
||||
const timer = setInterval(async () => {
|
||||
try {
|
||||
const s = await getShellStatus()
|
||||
statusRef.value = s
|
||||
if (s.checking) return
|
||||
clearInterval(timer)
|
||||
checking.value = false
|
||||
onResult(s)
|
||||
} catch (_) { /* 首次拿不到状态:继续轮询 */ }
|
||||
}, 800)
|
||||
// 兜底:30s 仍未结束则停止轮询,避免无限等待
|
||||
setTimeout(() => {
|
||||
if (checking.value) {
|
||||
clearInterval(timer)
|
||||
checking.value = false
|
||||
}
|
||||
}, 30000)
|
||||
}
|
||||
|
||||
return { checking, check }
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
import { connectWS } from '../api'
|
||||
import { handleEvent, store } from '../store'
|
||||
|
||||
// 本地服务 WebSocket:断线按 1/2/4/8/16s 指数退避重连(连续 5 次失败后停止),
|
||||
// 不整页 reload;被主动替换/关闭的旧连接不再触发重连(否则新旧交替形成死循环)。
|
||||
export function useSocket({ onPluginsSynced } = {}) {
|
||||
let retryCount = 0
|
||||
let retryTimer = null
|
||||
|
||||
function openWS() {
|
||||
// 主动新建连接时,取消上一次待执行的重连
|
||||
if (retryTimer) { clearTimeout(retryTimer); retryTimer = null }
|
||||
if (window.__ws) { try { window.__ws.close() } catch (_) {} }
|
||||
const ws = connectWS((ev) => {
|
||||
handleEvent(ev)
|
||||
// 插件同步完成事件:后台/手动同步结束后刷新清单,避免停留在「空场景/请授权」旧值
|
||||
if (ev && ev.t === 'plugins_synced' && store.current && onPluginsSynced) onPluginsSynced()
|
||||
})
|
||||
window.__ws = ws
|
||||
ws.onopen = () => { store.wsOn = true; retryCount = 0 }
|
||||
ws.onclose = () => {
|
||||
store.wsOn = false
|
||||
// 未登录被拒(1008)时静默,避免死循环
|
||||
if (!store.current) return
|
||||
if (window.__ws !== ws) return
|
||||
if (retryCount >= 5) return // 连续 5 次失败:停止,状态栏保持「本地服务重连中」
|
||||
retryCount++
|
||||
if (retryTimer) clearTimeout(retryTimer)
|
||||
retryTimer = setTimeout(openWS, Math.min(1000 * Math.pow(2, retryCount - 1), 16000))
|
||||
}
|
||||
}
|
||||
|
||||
return { openWS }
|
||||
}
|
||||
@@ -12,86 +12,3 @@ for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
|
||||
app.component(key, component)
|
||||
}
|
||||
app.use(ElementPlus, { locale: zhCn }).mount('#app')
|
||||
|
||||
/* ============================================================
|
||||
皮肤(skin):只切 token,不改组件。
|
||||
precision = 冷灰 + 压深天蓝的精密工作台(默认)
|
||||
cream = 奶油极简治愈风(旧皮肤,保留可切换)
|
||||
切换:localStorage['37du.skin'] = 'precision' | 'cream'
|
||||
============================================================ */
|
||||
const SKIN_KEY = '37du.skin'
|
||||
const SKINS = ['cream', 'precision']
|
||||
|
||||
function initSkin() {
|
||||
let skin = 'precision'
|
||||
try { skin = localStorage.getItem(SKIN_KEY) || 'precision' } catch (_) { /* 隐私模式等 */ }
|
||||
if (!SKINS.includes(skin)) skin = 'precision'
|
||||
document.documentElement.dataset.skin = skin
|
||||
}
|
||||
|
||||
// 在挂载前应用,避免首屏闪一下默认皮肤
|
||||
initSkin()
|
||||
|
||||
/* ============================================================
|
||||
奶油涂鸦装饰层:fixed 浮于页面顶层,仅视觉点缀。
|
||||
可开关:localStorage['37du.doodles'] = 'off'(登录页顶部 ✿ 按钮同源)
|
||||
注意:涂鸦是奶油皮肤专属装饰,precision 皮肤下由 CSS 整体隐藏。
|
||||
============================================================ */
|
||||
const DOODLES = {
|
||||
squiggle:
|
||||
'<svg width="90" height="46" viewBox="0 0 90 46" fill="none">' +
|
||||
'<path d="M4 34 Q 16 6 30 28 T 58 22 T 84 26" stroke="#7CC3E8" stroke-width="3" stroke-linecap="round"/>' +
|
||||
'<path d="M6 41 Q 22 20 38 38 T 66 34" stroke="#E5D9C5" stroke-width="2.4" stroke-linecap="round"/></svg>',
|
||||
cloud:
|
||||
'<svg width="70" height="44" viewBox="0 0 70 44" fill="none">' +
|
||||
'<path d="M18 36 a10 10 0 0 1-1-19.8 A13 13 0 0 1 42 14.5 a9.5 9.5 0 0 1 10 8.6 A8 8 0 0 1 51 36Z" fill="#DCEFF9" stroke="#A8D8F2" stroke-width="2"/></svg>',
|
||||
sparkles:
|
||||
'<svg width="80" height="60" viewBox="0 0 80 60" fill="none">' +
|
||||
'<path d="M14 8 l2.6 5.4 5.4 2.6 -5.4 2.6 -2.6 5.4 -2.6 -5.4 -5.4 -2.6 5.4 -2.6Z" fill="#F2C96B"/>' +
|
||||
'<path d="M62 6 l1.8 3.7 3.7 1.8 -3.7 1.8 -1.8 3.7 -1.8 -3.7 -3.7 -1.8 3.7 -1.8Z" fill="#7CC3E8"/>' +
|
||||
'<path d="M40 30 l2 4 4 2 -4 2 -2 4 -2 -4 -4 -2 4 -2Z" fill="#E58B8B"/></svg>',
|
||||
heart:
|
||||
'<svg width="46" height="42" viewBox="0 0 46 42" fill="none">' +
|
||||
'<path d="M23 38 C 10 29 3 21 3 13 A 10 10 0 0 1 23 9 A 10 10 0 0 1 43 13 C 43 21 36 29 23 38Z" fill="#FBE3E0" stroke="#E9A7A0" stroke-width="2.4"/></svg>',
|
||||
plant:
|
||||
'<svg width="60" height="66" viewBox="0 0 60 66" fill="none">' +
|
||||
'<path d="M30 62 V 26" stroke="#9BC88F" stroke-width="3" stroke-linecap="round"/>' +
|
||||
'<path d="M30 30 C 18 30 14 18 16 10 C 24 10 28 18 30 22 C 32 15 38 9 46 10 C 46 18 40 28 30 30Z" fill="#D9EED1" stroke="#9BC88F" stroke-width="2"/>' +
|
||||
'<path d="M30 44 C 22 44 18 36 19 30 C 26 30 29 36 30 40 C 34 34 40 31 45 32 C 43 40 37 44 30 44Z" fill="#C6E6BB" stroke="#9BC88F" stroke-width="2"/></svg>',
|
||||
sun:
|
||||
'<svg width="54" height="54" viewBox="0 0 54 54" fill="none">' +
|
||||
'<circle cx="27" cy="27" r="12" fill="#FFF2C9" stroke="#F2C96B" stroke-width="2.4"/>' +
|
||||
'<g stroke="#F2C96B" stroke-width="2.6" stroke-linecap="round">' +
|
||||
'<path d="M27 4v7M27 43v7M4 27h7M43 27h7M10 10l5 5M39 39l5 5M44 10l-5 5M15 39l-5 5"/></g></svg>',
|
||||
}
|
||||
|
||||
function initDoodles() {
|
||||
if (document.getElementById('dsh-doodles')) return
|
||||
const wrap = document.createElement('div')
|
||||
wrap.id = 'dsh-doodles'
|
||||
// [类型, left, top, 水平翻转]
|
||||
const spots = [
|
||||
['squiggle', '6%', '12%', false],
|
||||
['cloud', '88%', '8%', false],
|
||||
['sun', '93%', '40%', false],
|
||||
['sparkles', '78%', '66%', false],
|
||||
['heart', '5%', '68%', false],
|
||||
['plant', '13%', '36%', true],
|
||||
]
|
||||
for (const [name, left, top, flip] of spots) {
|
||||
const el = document.createElement('span')
|
||||
el.className = 'doodle'
|
||||
el.style.left = left
|
||||
el.style.top = top
|
||||
el.innerHTML = DOODLES[name] || DOODLES.sparkles
|
||||
if (flip) el.querySelector('svg').style.transform = 'scaleX(-1)'
|
||||
wrap.appendChild(el)
|
||||
}
|
||||
document.body.appendChild(wrap)
|
||||
let on = 'on'
|
||||
try { on = localStorage.getItem('37du.doodles') || 'on' } catch (_) {}
|
||||
document.documentElement.classList.toggle('no-doodles', on === 'off')
|
||||
}
|
||||
|
||||
// 应用挂载后注入(body 已存在),不阻塞首屏
|
||||
initDoodles()
|
||||
@@ -1,378 +1,357 @@
|
||||
/* ============ 37du 执行机壳 · 设计令牌(token 层) ============
|
||||
规则:组件内**只允许**引用这里的 token,不写字面色值(rgba 一律走 --*-rgb 变量)。
|
||||
换肤只需在 [data-skin="..."] 里重映射同名 token,组件代码零改动。
|
||||
默认皮肤 = cream(奶油极简治愈风,现状像素级不变)。
|
||||
权威来源:design-app/styles.css(新版设计稿)。
|
||||
规则:组件内**只允许**引用这里的 token,不写字面色值。
|
||||
—— :root 直接落地新设计体系(冷灰蓝企业风),
|
||||
下方「旧别名映射」把历史 token 名全部指到新值,
|
||||
保证未重写的旧组件也能正常渲染(单一皮肤架构)。
|
||||
============================================================ */
|
||||
:root {
|
||||
/* ---- 基础 ---- */
|
||||
--bg: #F9F7F2;
|
||||
--bg-grad: radial-gradient(1200px 720px at 50% -8%, #FDFCF8 0%, #F9F7F2 55%, #F4F1EA 100%);
|
||||
--surface: #ffffff;
|
||||
--surface-2: #F6F3EC;
|
||||
--surface-3: #FDFCF9; /* 输入框底 */
|
||||
--surface-glow: #FBFDFF; /* 卡片高亮底(运行中/渐变收尾) */
|
||||
--border: #EFE9DE;
|
||||
--border-strong: #E0D9C9;
|
||||
--border-warm: #E7E0D2; /* 登录页卡片描边 */
|
||||
--border-warm-2: #F1ECE2; /* 更浅一级描边 */
|
||||
--border-hover: #D6CFC0;
|
||||
--row-hover: #F8F5EF; /* 日志行 hover */
|
||||
--track: #EDE7DB; /* 进度条底槽 */
|
||||
--scrollbar: #DED7C8;
|
||||
--scrollbar-hover: #CCC4B2;
|
||||
/* ---- 底色与卡面 ---- */
|
||||
--canvas: #F2F4F8;
|
||||
--surface: #FFFFFF;
|
||||
--field: #F5F6FA;
|
||||
--subtle: #F7F8FC;
|
||||
--table-head: #FAFBFD;
|
||||
|
||||
--text: #222222;
|
||||
--text-sub: #666666;
|
||||
--text-faint: #9C9589;
|
||||
--text-warm-sub: #5B5B5B;
|
||||
--text-warm-faint: #8A8377;
|
||||
--text-muted-warm: #C4B89E; /* 未登录/未配置的弱提示 */
|
||||
--text-disabled: #C9C2B4;
|
||||
--placeholder: #B5AD9D;
|
||||
--on-primary: #ffffff; /* 主色/渐变底上的前景 */
|
||||
--text-rgb: 34, 34, 34;
|
||||
--on-primary-rgb: 255, 255, 255;
|
||||
/* ---- 描边 ---- */
|
||||
--line: #E8EAF1; /* 卡片外框 1px */
|
||||
--line-soft: #F0F2F7; /* 卡内分隔线 1px */
|
||||
--line-btn: #E3E6EF; /* 次要按钮描边 */
|
||||
--line-win: #DDE1EA; /* 窗口外框 */
|
||||
|
||||
--primary: #7CC3E8; /* 浅天蓝 · 辅助强调色 */
|
||||
--primary-2: #A8D8F2;
|
||||
--primary-rgb: 124, 195, 232;
|
||||
--primary-grad: linear-gradient(135deg, #92D1F0 0%, #6FBAE6 100%);
|
||||
--primary-grad-2: linear-gradient(135deg, #8FD0F0 0%, #6FBAE6 100%);
|
||||
--primary-grad-3: linear-gradient(135deg, #9BD1EE, #7CC3E8);
|
||||
--primary-strong: #5FAFD9;
|
||||
--primary-hover: #6FBAE6; /* 主按钮 hover 底(纯色,与渐变收尾同色) */
|
||||
--primary-soft: #9BD1EE;
|
||||
--primary-line: #BFE2F4;
|
||||
--primary-weak: #EFF7FC;
|
||||
--primary-weak-2: #E3F1FA;
|
||||
--primary-tint: #F4FAFD;
|
||||
--primary-disabled: #C9E6F5;
|
||||
/* ---- 文字四阶 + 更浅两阶 ---- */
|
||||
--t1: #12141B;
|
||||
--t2: #3C4250;
|
||||
--t3: #6E7686;
|
||||
--t4: #A3AAB8;
|
||||
--t5: #C6CBD6;
|
||||
|
||||
--ok: #5BBE96;
|
||||
--ok-weak: #E9F7F0;
|
||||
--ok-text: #3F9E77;
|
||||
--ok-text-2: #1a8f63;
|
||||
--ok-rgb: 91, 190, 150;
|
||||
--ok-rgb-2: 34, 176, 122;
|
||||
--err: #E58B8B;
|
||||
--err-weak: #FBF0F0;
|
||||
--err-rgb: 229, 139, 139;
|
||||
--danger: #e5484d; /* 对话框错误文案(比 --err 更重的红) */
|
||||
--warn: #E0A85C;
|
||||
--warn-weak: #FBF3E3;
|
||||
--warn-bg: #FFF4E5;
|
||||
--warn-text: #9A5B14;
|
||||
--warn-rgb: 224, 122, 40;
|
||||
--warn-icon-rgb: 247, 162, 58;
|
||||
/* ---- 主色(靛蓝) ---- */
|
||||
--brand: #4F5AE8;
|
||||
--brand-ink: #3D47D4;
|
||||
--brand-soft: #EEF0FE;
|
||||
--brand-soft-2: #EFF1FE;
|
||||
--brand-track: #DDE1F8;
|
||||
--brand-bar: #EDF0F6;
|
||||
|
||||
/* ---- 场景磁贴 / 装饰 ---- */
|
||||
--tile-fg: #ffffff; /* 磁贴前景(皮肤若改用淡色底需同步改这个) */
|
||||
--tile-faint-bg: #E3DED2;
|
||||
--dot-off: #c6ccdc;
|
||||
--dot-muted: #D0C9BA;
|
||||
--sep-warm: #CFC8B8;
|
||||
--switch-off: #D8D0BF;
|
||||
--badge-warm-text: #A08F6F;
|
||||
--badge-warm-bg: #FBF7EE;
|
||||
--badge-warm-border: #EFE4CB;
|
||||
--badge-off-text: #B09E7E;
|
||||
--badge-dot: #C9BFA6;
|
||||
--border-strong-rgb: 224, 217, 201;
|
||||
--chrome-rgb: 74, 140, 247;
|
||||
--chrome-icon: radial-gradient(circle at 30% 30%, #e6f2ff, #4a8cf7 55%, #2b6be0);
|
||||
--chrome-icon-warn: radial-gradient(circle at 30% 30%, #fff6e6, #f7a23a 55%, #e07324);
|
||||
--hero-grad: linear-gradient(120deg, #FFFFFF 0%, #FBFDFF 55%, #F7FBFE 100%);
|
||||
--profile-head-grad: linear-gradient(135deg, #dfe7ff 0%, #eef2ff 55%, #f6f8ff 100%);
|
||||
--surface-cool: #f6f8fd;
|
||||
--surface-cool-2: #fafbfe;
|
||||
/* ---- 语义色 ---- */
|
||||
--good: #0E9F76; --good-ink: #0B8A66; --good-soft: #EBF7F2; --good-line: #D3EDE3;
|
||||
--warn: #D98218; --warn-ink: #B4700F; --warn-soft: #FDF3E4; --warn-line: rgba(217, 130, 24, .28);
|
||||
--danger: #E5484D; --danger-ink: #CC3B40; --danger-soft: #FDEDED; --danger-line: #F6D7D8;
|
||||
--info: #3B9BE8; --violet: #7C6BE8;
|
||||
--idle-bar: #E4E7EF;
|
||||
|
||||
/* ---- 阴影:仅极柔和浅阴影 ---- */
|
||||
--shadow-sm: 0 1px 3px rgba(var(--text-rgb), .05), 0 2px 10px -4px rgba(var(--text-rgb), .06);
|
||||
--shadow-md: 0 8px 24px -14px rgba(var(--text-rgb), .14);
|
||||
--shadow-lift: 0 14px 34px -16px rgba(var(--text-rgb), .18);
|
||||
/* ---- 暗色控制台 ---- */
|
||||
--con: #14161C;
|
||||
--con-line: #262A34;
|
||||
--con-bg2: #22262F;
|
||||
--con-t1: #9AA3B5;
|
||||
--con-t2: #5F6879;
|
||||
--con-warn: #E8B15C;
|
||||
--con-ok: #7FD1AD;
|
||||
--con-live: #34D399;
|
||||
|
||||
/* ---- 圆角:全局大圆角 ---- */
|
||||
--radius: 16px;
|
||||
--radius-sm: 11px;
|
||||
/* ---- 圆角 ---- */
|
||||
--r-row: 8px;
|
||||
--r-field: 9px;
|
||||
--r-btn: 10px;
|
||||
--r-sub: 12px;
|
||||
--r-card: 14px;
|
||||
--r-win: 16px;
|
||||
--r-pill: 999px;
|
||||
|
||||
/* ---- 字体:正文无衬线 Inter;标题可用圆润手写装饰字体 ---- */
|
||||
--mono: "JetBrains Mono", "Consolas", "Courier New", monospace;
|
||||
--font-mono: "JetBrains Mono", "Consolas", "Courier New", monospace;
|
||||
--font-body: "Inter", "Segoe UI", "Microsoft YaHei UI", "PingFang SC", -apple-system, sans-serif;
|
||||
--font-doodle: "Segoe Script", "Comic Sans MS", "KaiTi", "STKaiti", "cursive";
|
||||
/* ---- 阴影三级(全站仅此三种 + 窗口投影) ---- */
|
||||
--sh-card: 0 2px 8px rgba(18, 20, 31, .05);
|
||||
--sh-float: 0 8px 24px rgba(18, 20, 31, .10);
|
||||
--sh-brand: 0 4px 12px rgba(79, 89, 232, .28);
|
||||
--sh-brand-sm: 0 2px 8px rgba(79, 89, 232, .24);
|
||||
--sh-console: 0 4px 16px rgba(18, 20, 31, .08);
|
||||
--sh-win: 0 18px 48px rgba(13, 15, 23, .12);
|
||||
|
||||
/* ---- element-plus 主题与浅天蓝统一 ---- */
|
||||
--el-color-primary: #7CC3E8;
|
||||
--el-color-primary-light-3: #9BD1EE;
|
||||
--el-color-primary-light-5: #BFE2F4;
|
||||
--el-color-primary-light-7: #DCEFF9;
|
||||
--el-color-primary-light-8: #E9F5FB;
|
||||
--el-color-primary-light-9: #F4FAFD;
|
||||
--el-color-primary-dark-2: #5FAFD9;
|
||||
--el-border-radius-base: 12px;
|
||||
--el-border-radius-small: 10px;
|
||||
--el-border-radius-round: 999px;
|
||||
--el-box-shadow: 0 8px 24px -16px rgba(var(--text-rgb), .14);
|
||||
--el-box-shadow-light: 0 6px 18px -14px rgba(var(--text-rgb), .10);
|
||||
/* ---- 字体 ---- */
|
||||
--f-cn: "PingFang SC", "HarmonyOS Sans SC", "Microsoft YaHei", "Noto Sans SC", system-ui, -apple-system, sans-serif;
|
||||
--f-num: "Inter", "SF Pro Display", -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
|
||||
--f-mono: "JetBrains Mono", "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
|
||||
|
||||
/* ---- 产品级排版/间距/动效 ---- */
|
||||
--radius-lg: 22px;
|
||||
--space-1: 4px;
|
||||
--space-1-5: 6px;
|
||||
--space-2: 8px;
|
||||
--space-2-5: 10px;
|
||||
--space-3: 12px;
|
||||
--space-4: 16px;
|
||||
--space-5: 20px;
|
||||
--space-6: 28px;
|
||||
--dur: .18s;
|
||||
/* 一级视图内容内边距:左右贴齐容器,底部留出滚动余量 */
|
||||
--page-pad: 2px 2px 10px;
|
||||
--dur: .15s;
|
||||
--ease: cubic-bezier(.22, 1, .36, 1);
|
||||
--grad-sky: linear-gradient(135deg, #A8D8F2, #7CC3E8);
|
||||
--grad-peach: linear-gradient(135deg, #F2C9B8, #E8A98E);
|
||||
--grad-mint: linear-gradient(135deg, #C9E6BB, #9BC88F);
|
||||
--grad-lilac: linear-gradient(135deg, #D9C7F0, #B79AE3);
|
||||
--grad-honey: linear-gradient(135deg, #F7D9A0, #EFBE6B);
|
||||
--grad-blush: linear-gradient(135deg, #F2B8C6, #E48E9F);
|
||||
}
|
||||
|
||||
/* ============================================================
|
||||
皮肤 · precision(冷灰 + 压深天蓝的"精密工作台")
|
||||
—— 只是 token 重映射的**首版脚手架**,用于后续「双皮肤同页对比」评审;
|
||||
尚未做像素级打磨,也不改变任何组件代码。默认不启用:
|
||||
启用方式 = <html data-skin="precision">(localStorage['37du.skin'])。
|
||||
============================================================ */
|
||||
[data-skin="precision"] {
|
||||
--bg: #F4F6F9;
|
||||
--bg-grad: #F4F6F9; /* 冷灰画布:去掉奶油径向渐变 */
|
||||
--surface: #FFFFFF;
|
||||
--surface-2: #F1F4F8;
|
||||
--surface-3: #FFFFFF;
|
||||
--surface-glow: #F8FAFC;
|
||||
--border: #E4E9F0;
|
||||
--border-strong: #CDD6E1;
|
||||
--border-warm: #E4E9F0;
|
||||
--border-warm-2: #EEF2F7;
|
||||
--border-hover: #CDD6E1;
|
||||
--row-hover: #F1F4F8;
|
||||
--track: #E4E9F0;
|
||||
--scrollbar: #CBD5E1;
|
||||
--scrollbar-hover: #94A3B8;
|
||||
/* ============================================================
|
||||
旧别名映射(历史组件引用名 → 新设计值,重写完成后逐步清理)
|
||||
============================================================ */
|
||||
--bg: var(--canvas);
|
||||
--bg-grad: var(--canvas);
|
||||
--surface-2: var(--subtle);
|
||||
--surface-3: var(--field);
|
||||
--surface-glow: var(--table-head);
|
||||
--border: var(--line);
|
||||
--border-strong: var(--line-btn);
|
||||
--border-warm: var(--line);
|
||||
--border-warm-2: var(--line-soft);
|
||||
--border-hover: #D9DEEF;
|
||||
--row-hover: var(--field);
|
||||
--track: var(--brand-bar);
|
||||
--scrollbar: var(--t5);
|
||||
--scrollbar-hover: var(--t4);
|
||||
|
||||
--text: #182230;
|
||||
--text-sub: #5A6674;
|
||||
--text-faint: #7C8896;
|
||||
--text-warm-sub: #5A6674;
|
||||
--text-warm-faint: #7C8896;
|
||||
--text-muted-warm: #7C8896;
|
||||
--text-disabled: #A8B3C1;
|
||||
--placeholder: #94A3B8;
|
||||
--on-primary: #FFFFFF;
|
||||
--text-rgb: 15, 23, 42;
|
||||
--text: var(--t1);
|
||||
--text-sub: var(--t2);
|
||||
--text-faint: var(--t3);
|
||||
--text-warm-sub: var(--t2);
|
||||
--text-warm-faint: var(--t3);
|
||||
--text-muted-warm: var(--t4);
|
||||
--text-disabled: var(--t5);
|
||||
--placeholder: var(--t4);
|
||||
--on-primary: #ffffff;
|
||||
--text-rgb: 18, 20, 31;
|
||||
--on-primary-rgb: 255, 255, 255;
|
||||
|
||||
--primary: #1E6FA8;
|
||||
--primary-2: #3E93CF;
|
||||
--primary-rgb: 30, 111, 168;
|
||||
--primary-grad: #17608F; /* 皮肤可把渐变 token 设成纯色 */
|
||||
--primary-grad-2: #1E6FA8;
|
||||
--primary-grad-3: #3E93CF;
|
||||
--primary-strong: #17608F;
|
||||
--primary-hover: #1E6FA8;
|
||||
--primary-soft: #3E93CF;
|
||||
--primary-line: #CDD6E1;
|
||||
--primary-weak: #E9F2FA;
|
||||
--primary-weak-2: #E9F2FA;
|
||||
--primary-tint: #E9F2FA;
|
||||
--primary-disabled: #BFD8EA;
|
||||
--primary: var(--brand);
|
||||
--primary-2: #848CEF;
|
||||
--primary-rgb: 79, 89, 232;
|
||||
--primary-grad: var(--brand);
|
||||
--primary-grad-2: var(--brand);
|
||||
--primary-grad-3: var(--brand);
|
||||
--primary-strong: var(--brand-ink);
|
||||
--primary-hover: #4550E0;
|
||||
--primary-soft: #848CEF;
|
||||
--primary-line: var(--brand-track);
|
||||
--primary-weak: var(--brand-soft);
|
||||
--primary-weak-2: var(--brand-soft-2);
|
||||
--primary-tint: var(--brand-soft-2);
|
||||
--primary-disabled: #C5C9F4;
|
||||
|
||||
/* element-plus 主题同步(否则表单/表格等内置组件会残留奶油浅蓝) */
|
||||
--el-color-primary: #1E6FA8;
|
||||
--el-color-primary-light-3: #3E93CF;
|
||||
--el-color-primary-light-5: #7FB4D8;
|
||||
--el-color-primary-light-7: #BFD8EA;
|
||||
--el-color-primary-light-8: #D9E8F4;
|
||||
--el-color-primary-light-9: #E9F2FA;
|
||||
--el-color-primary-dark-2: #17608F;
|
||||
--ok: var(--good);
|
||||
--ok-weak: var(--good-soft);
|
||||
--ok-text: var(--good-ink);
|
||||
--ok-text-2: var(--good-ink);
|
||||
--ok-rgb: 14, 159, 118;
|
||||
--ok-rgb-2: 11, 138, 102;
|
||||
--err: var(--danger);
|
||||
--err-weak: var(--danger-soft);
|
||||
--err-rgb: 229, 72, 77;
|
||||
--danger-strong: var(--danger-ink);
|
||||
--warn-weak: var(--warn-soft);
|
||||
--warn-bg: var(--warn-soft);
|
||||
--warn-text: var(--warn-ink);
|
||||
--warn-rgb: 217, 130, 24;
|
||||
--warn-icon-rgb: 217, 130, 24;
|
||||
|
||||
--ok: #1F8A4C;
|
||||
--ok-weak: #E7F5EC;
|
||||
--ok-text: #1F8A4C;
|
||||
--ok-text-2: #1F8A4C;
|
||||
--ok-rgb: 31, 138, 76;
|
||||
--ok-rgb-2: 31, 138, 76;
|
||||
--err: #D64545;
|
||||
--err-weak: #FBEBEB;
|
||||
--err-rgb: 214, 69, 69;
|
||||
--danger: #D64545;
|
||||
--warn: #B26B00;
|
||||
--warn-weak: #FBF3E0;
|
||||
--warn-bg: #FBF3E0;
|
||||
--warn-text: #B26B00;
|
||||
--warn-rgb: 178, 107, 0;
|
||||
--warn-icon-rgb: 178, 107, 0;
|
||||
|
||||
/* 场景磁贴:淡色底 + 同色系前景(v2 的 tile 风格),故前景不能再用白色 */
|
||||
--tile-fg: #1E6FA8;
|
||||
--grad-sky: #E9F2FA;
|
||||
--grad-peach: #FBF3E0;
|
||||
--grad-mint: #E7F5EC;
|
||||
--grad-lilac: #EFEAF7;
|
||||
--grad-honey: #FBF3E0;
|
||||
--grad-blush: #FBEBEB;
|
||||
--tile-faint-bg: #E9EDF3;
|
||||
--dot-off: #CBD5E1;
|
||||
--dot-muted: #CBD5E1;
|
||||
--sep-warm: #CDD6E1;
|
||||
--switch-off: #CBD5E1;
|
||||
--badge-warm-text: #B26B00;
|
||||
--badge-warm-bg: #FBF3E0;
|
||||
--badge-warm-border: #E7C88F;
|
||||
--badge-off-text: #7C8896;
|
||||
--badge-dot: #CBD5E1;
|
||||
--border-strong-rgb: 205, 214, 225;
|
||||
/* ---- 场景磁贴:淡色底 + 深字(新风格) ---- */
|
||||
--tile-fg: var(--t2);
|
||||
--tile-faint-bg: var(--idle-bar);
|
||||
--dot-off: var(--t5);
|
||||
--dot-muted: var(--t5);
|
||||
--sep-warm: var(--line-soft);
|
||||
--switch-off: var(--t5);
|
||||
--badge-warm-text: var(--warn-ink);
|
||||
--badge-warm-bg: var(--warn-soft);
|
||||
--badge-warm-border: #F1E3C7;
|
||||
--badge-off-text: var(--t3);
|
||||
--badge-dot: var(--t5);
|
||||
--border-strong-rgb: 227, 230, 239;
|
||||
--chrome-rgb: 74, 140, 247;
|
||||
--hero-grad: #FFFFFF;
|
||||
--profile-head-grad: #F1F4F8;
|
||||
--surface-cool: #F1F4F8;
|
||||
--surface-cool-2: #F8FAFC;
|
||||
--chrome-icon: radial-gradient(circle at 30% 30%, #e6f2ff, #4a8cf7 55%, #2b6be0);
|
||||
--chrome-icon-warn: radial-gradient(circle at 30% 30%, #fff6e6, #f7a23a 55%, #e07324);
|
||||
--hero-grad: var(--surface);
|
||||
--profile-head-grad: var(--subtle);
|
||||
--surface-cool: var(--subtle);
|
||||
--surface-cool-2: var(--table-head);
|
||||
|
||||
--radius: 12px;
|
||||
--radius-sm: 8px;
|
||||
--radius-lg: 14px;
|
||||
--shadow-sm: 0 1px 2px rgba(var(--text-rgb), .05);
|
||||
--shadow-md: 0 8px 24px -12px rgba(var(--text-rgb), .14);
|
||||
--shadow-lift: 0 14px 34px -16px rgba(var(--text-rgb), .18);
|
||||
--shadow-sm: var(--sh-card);
|
||||
--shadow-md: var(--sh-float);
|
||||
--shadow-lift: 0 12px 32px rgba(18, 20, 31, .14);
|
||||
|
||||
/* 精密工作台不用手写装饰字体 */
|
||||
--font-doodle: var(--font-body);
|
||||
--radius: var(--r-card);
|
||||
--radius-sm: var(--r-btn);
|
||||
--radius-lg: var(--r-card);
|
||||
--mono: var(--f-mono);
|
||||
--font-mono: var(--f-mono);
|
||||
--font-body: var(--f-cn);
|
||||
--font-doodle: var(--f-cn);
|
||||
|
||||
--grad-sky: #EEF0FE;
|
||||
--grad-peach: #FDF3E4;
|
||||
--grad-mint: #EBF7F2;
|
||||
--grad-lilac: #F0EDFE;
|
||||
--grad-honey: #FAF0DF;
|
||||
--grad-blush: #FDEDED;
|
||||
|
||||
/* ============================================================
|
||||
Element Plus 主题同步(主色靛蓝 + 语义色对齐设计稿)
|
||||
============================================================ */
|
||||
--el-color-primary: #4F5AE8;
|
||||
--el-color-primary-light-3: #848CEF;
|
||||
--el-color-primary-light-5: #A7ADF4;
|
||||
--el-color-primary-light-7: #CACEF8;
|
||||
--el-color-primary-light-8: #DCDEFA;
|
||||
--el-color-primary-light-9: #EDEFFD;
|
||||
--el-color-primary-dark-2: #3D47D4;
|
||||
--el-color-success: #0E9F76;
|
||||
--el-color-warning: #D98218;
|
||||
--el-color-danger: #E5484D;
|
||||
--el-color-error: #E5484D;
|
||||
--el-border-radius-base: 10px;
|
||||
--el-border-radius-small: 8px;
|
||||
--el-border-radius-round: 999px;
|
||||
--el-box-shadow: var(--sh-float);
|
||||
--el-box-shadow-light: var(--sh-card);
|
||||
--el-text-color-primary: var(--t1);
|
||||
--el-text-color-regular: var(--t2);
|
||||
--el-text-color-secondary: var(--t3);
|
||||
--el-text-color-placeholder: var(--t4);
|
||||
--el-border-color: var(--line);
|
||||
--el-border-color-light: var(--line-soft);
|
||||
--el-border-color-lighter: var(--line-soft);
|
||||
--el-fill-color-light: var(--field);
|
||||
--el-fill-color-lighter: var(--subtle);
|
||||
--el-fill-color-blank: var(--surface);
|
||||
}
|
||||
|
||||
/* 涂鸦层是奶油皮肤专属装饰,换肤时整体关闭(同一开关也支持手动 off) */
|
||||
html[data-skin="precision"] .doodle { display: none; }
|
||||
|
||||
* { box-sizing: border-box; }
|
||||
html, body, #app { height: 100%; margin: 0; }
|
||||
|
||||
body {
|
||||
font-family: var(--font-body);
|
||||
font-size: 13px;
|
||||
color: var(--text);
|
||||
background: var(--bg);
|
||||
font-family: var(--f-cn);
|
||||
font-size: 12px;
|
||||
line-height: 1.42;
|
||||
color: var(--t1);
|
||||
background: var(--canvas);
|
||||
-webkit-font-smoothing: antialiased;
|
||||
text-rendering: optimizeLegibility;
|
||||
}
|
||||
::selection { background: var(--brand-track); color: var(--brand-ink); }
|
||||
button { font-family: inherit; }
|
||||
|
||||
/* 应用根容器:topbar / statusbar 全宽贴边,中段内容区自行 padding */
|
||||
.__app {
|
||||
height: 100%;
|
||||
background: var(--bg-grad);
|
||||
padding: 16px 18px 18px;
|
||||
background: var(--canvas);
|
||||
padding: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
/* 滚动条(柔和) */
|
||||
::-webkit-scrollbar { width: 10px; height: 10px; }
|
||||
::-webkit-scrollbar-thumb { background: var(--scrollbar); border-radius: 6px; border: 2px solid transparent; background-clip: content-box; }
|
||||
/* 滚动条(细而柔和) */
|
||||
::-webkit-scrollbar { width: 8px; height: 8px; }
|
||||
::-webkit-scrollbar-thumb { background: var(--scrollbar); border-radius: 4px; border: 2px solid transparent; background-clip: content-box; }
|
||||
::-webkit-scrollbar-thumb:hover { background: var(--scrollbar-hover); background-clip: content-box; border: 2px solid transparent; }
|
||||
::-webkit-scrollbar-track { background: transparent; }
|
||||
|
||||
/* 通用白卡:大圆角 + 极柔和阴影 + hover 轻微上浮 */
|
||||
/* 通用白卡:静态卡片(新设计无 hover 上浮) */
|
||||
.panel {
|
||||
background: var(--surface);
|
||||
border: 1px solid var(--border);
|
||||
border-radius: var(--radius);
|
||||
box-shadow: var(--shadow-sm);
|
||||
transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
|
||||
border: 1px solid var(--line);
|
||||
border-radius: var(--r-card);
|
||||
box-shadow: var(--sh-card);
|
||||
}
|
||||
.panel:hover {
|
||||
transform: translateY(-3px);
|
||||
box-shadow: var(--shadow-md);
|
||||
border-color: var(--border-strong);
|
||||
|
||||
/* 白底圆角卡(通用卡片) */
|
||||
.card {
|
||||
background: var(--surface);
|
||||
border: 1px solid var(--line);
|
||||
border-radius: var(--r-card);
|
||||
box-shadow: var(--sh-card);
|
||||
}
|
||||
|
||||
/* 分节标题 */
|
||||
.sec-title {
|
||||
font-size: 11px;
|
||||
font-weight: 700;
|
||||
letter-spacing: 0.05em;
|
||||
text-transform: uppercase;
|
||||
color: var(--text-faint);
|
||||
font-size: 12px;
|
||||
font-weight: 600;
|
||||
color: var(--t1);
|
||||
}
|
||||
|
||||
/* 白底圆角卡(通用卡片:总览首页统计/场景/最近动态等) */
|
||||
.card {
|
||||
background: var(--surface);
|
||||
border: 1px solid var(--border);
|
||||
border-radius: var(--radius);
|
||||
box-shadow: var(--shadow-sm);
|
||||
}
|
||||
|
||||
/* 按钮 */
|
||||
/* 按钮(对齐设计稿 .btn / .btn-ghost / .btn-primary) */
|
||||
.btn {
|
||||
border: 1px solid var(--border-strong);
|
||||
height: 34px;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: var(--space-1-5);
|
||||
padding: 0 var(--space-3);
|
||||
border-radius: var(--r-btn);
|
||||
border: 1px solid var(--line-btn);
|
||||
background: var(--surface);
|
||||
color: var(--text-sub);
|
||||
border-radius: 12px;
|
||||
padding: 7px 16px;
|
||||
font-size: 13px;
|
||||
color: var(--t2);
|
||||
font-size: 12px;
|
||||
font-weight: 500;
|
||||
font-family: inherit;
|
||||
line-height: 18px;
|
||||
cursor: pointer;
|
||||
transition: all .15s ease;
|
||||
white-space: nowrap;
|
||||
transition: background .15s, border-color .15s, box-shadow .15s, transform .06s;
|
||||
}
|
||||
.btn:hover { background: var(--subtle); border-color: var(--border-hover); color: var(--t1); }
|
||||
.btn:active { background: var(--field); }
|
||||
.btn:disabled {
|
||||
color: var(--t5); border-color: var(--line-soft);
|
||||
background: var(--surface); cursor: not-allowed;
|
||||
}
|
||||
.btn:hover { color: var(--text); border-color: var(--border-hover); background: var(--surface-2); }
|
||||
.btn:active { transform: translateY(1px); }
|
||||
.btn:disabled { color: var(--text-disabled); border-color: var(--border); background: var(--surface-2); cursor: not-allowed; transform: none; }
|
||||
|
||||
.btn.primary {
|
||||
background: var(--primary-grad);
|
||||
background: var(--brand);
|
||||
color: var(--on-primary);
|
||||
border: 1px solid transparent;
|
||||
font-weight: 600;
|
||||
box-shadow: 0 6px 16px -6px rgba(var(--primary-rgb), .6);
|
||||
box-shadow: var(--sh-brand);
|
||||
}
|
||||
.btn.primary:hover:not(:disabled) { box-shadow: 0 10px 22px -8px rgba(var(--primary-rgb), .7); color: var(--on-primary); }
|
||||
.btn.primary:hover:not(:disabled) { background: var(--primary-hover); box-shadow: var(--sh-brand); color: var(--on-primary); }
|
||||
.btn.primary:active:not(:disabled) { transform: translateY(1px); box-shadow: var(--sh-brand-sm); }
|
||||
.btn.primary:disabled { background: var(--primary-disabled); box-shadow: none; }
|
||||
|
||||
/* 输入 / 选择 */
|
||||
.input {
|
||||
height: 34px;
|
||||
border: 1px solid var(--border-strong);
|
||||
border-radius: 11px;
|
||||
height: 32px;
|
||||
border: 1px solid var(--line-btn);
|
||||
border-radius: var(--r-field);
|
||||
background: var(--surface);
|
||||
color: var(--text);
|
||||
padding: 0 12px;
|
||||
font-size: 13px;
|
||||
color: var(--t1);
|
||||
padding: 0 var(--space-3);
|
||||
font-size: 12px;
|
||||
font-family: inherit;
|
||||
outline: none;
|
||||
transition: border-color .15s, box-shadow .15s;
|
||||
transition: border-color .15s, box-shadow .15s, background .15s;
|
||||
}
|
||||
.input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-weak); }
|
||||
.input:focus { border-color: var(--brand); background: var(--surface); box-shadow: 0 0 0 3px var(--brand-soft); }
|
||||
select.input { padding-right: 30px; appearance: none; cursor: pointer;
|
||||
background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%239C9589' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
|
||||
background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236E7686' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
|
||||
background-repeat: no-repeat; background-position: right 10px center; }
|
||||
.field-label { color: var(--text-sub); font-size: 13px; }
|
||||
.field-label { color: var(--t2); font-size: 12px; }
|
||||
|
||||
/* 进度条 */
|
||||
.progress { height: 8px; width: 180px; background: var(--track); border-radius: 999px; overflow: hidden; }
|
||||
.progress > div { height: 100%; border-radius: 999px;
|
||||
background: var(--primary-grad);
|
||||
transition: width .25s ease;
|
||||
box-shadow: 0 0 6px rgba(var(--primary-rgb),.5); }
|
||||
/* 进度条(对齐设计稿 .track:brand-bar 底槽 + brand 纯色条) */
|
||||
.progress { height: 6px; width: 180px; background: var(--brand-bar); border-radius: var(--r-pill); overflow: hidden; }
|
||||
.progress > div { height: 100%; border-radius: var(--r-pill);
|
||||
background: var(--brand);
|
||||
transition: width .5s ease; }
|
||||
|
||||
/* 日志 */
|
||||
/* 日志(亮色过渡样式;运行台暗色控制台由组件自建 .console) */
|
||||
.log-box {
|
||||
font-family: var(--mono);
|
||||
font-size: 12px;
|
||||
font-family: var(--f-mono);
|
||||
font-size: 11px;
|
||||
line-height: 1.75;
|
||||
color: var(--text);
|
||||
padding: 12px 14px;
|
||||
color: var(--t2);
|
||||
padding: var(--space-3);
|
||||
overflow: auto;
|
||||
white-space: pre-wrap;
|
||||
word-break: break-all;
|
||||
flex: 1 1 auto; /* 在 .log-wrap 里填满剩余高度并自己滚 */
|
||||
min-height: 0;
|
||||
}
|
||||
.log-line:hover { background: var(--row-hover); }
|
||||
.log-box .t { color: var(--text-faint); margin-right: 10px; user-select: none; }
|
||||
.log-line:hover { background: var(--field); }
|
||||
.log-box .t { color: var(--t4); margin-right: 10px; user-select: none; }
|
||||
.log-box .lv { margin-right: 6px; font-weight: 700; }
|
||||
.log-box .s-INFO { color: var(--primary); }
|
||||
.log-box .s-INFO { color: var(--brand); }
|
||||
.log-box .s-ERROR { color: var(--err); }
|
||||
.log-box .s-WARN { color: var(--warn); }
|
||||
|
||||
@@ -381,49 +360,81 @@ select.input { padding-right: 30px; appearance: none; cursor: pointer;
|
||||
.fade-enter-from { opacity: 0; transform: translateY(4px); }
|
||||
.fade-leave-to { opacity: 0; }
|
||||
|
||||
/* ============================================================
|
||||
产品级通用元素:分节标题(更大更清晰)/ 空状态
|
||||
============================================================ */
|
||||
/* 页头(对齐设计稿 .page-head 组):所有一级视图共用 PageHead 组件 */
|
||||
.page-head {
|
||||
display: flex;
|
||||
align-items: flex-end;
|
||||
gap: var(--space-3);
|
||||
flex: 0 0 auto;
|
||||
padding: var(--space-4) var(--space-5);
|
||||
background: linear-gradient(118deg, var(--brand-soft-2) 0%, var(--surface) 52%, var(--subtle) 100%);
|
||||
border: 1px solid var(--brand-track);
|
||||
border-radius: var(--r-card);
|
||||
box-shadow: var(--sh-card);
|
||||
}
|
||||
.page-title-group {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: var(--space-1);
|
||||
}
|
||||
.eyebrow {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: var(--space-1-5);
|
||||
font: 600 9.5px/14px var(--f-num);
|
||||
color: var(--brand);
|
||||
letter-spacing: .14em;
|
||||
text-transform: uppercase;
|
||||
}
|
||||
.eyebrow::before {
|
||||
content: "";
|
||||
width: 5px;
|
||||
height: 5px;
|
||||
border-radius: 50%;
|
||||
background: var(--brand);
|
||||
}
|
||||
.page-title {
|
||||
font-size: 20px;
|
||||
font-weight: 700;
|
||||
color: var(--text);
|
||||
letter-spacing: .01em;
|
||||
margin: 0;
|
||||
font: 600 24px/32px var(--f-cn);
|
||||
color: var(--t1);
|
||||
letter-spacing: -.2px;
|
||||
}
|
||||
.page-sub {
|
||||
font-size: 12.5px;
|
||||
color: var(--text-sub);
|
||||
line-height: 1.7;
|
||||
margin: 0;
|
||||
font: 400 11.5px/17px var(--f-cn);
|
||||
color: var(--t3);
|
||||
}
|
||||
/* 分区英文小标(带圆点):各一级页面的分区标题复用 */
|
||||
.sec-eyebrow {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: var(--space-1-5);
|
||||
font: 600 9.5px/14px var(--f-num);
|
||||
letter-spacing: .14em;
|
||||
text-transform: uppercase;
|
||||
color: var(--t4);
|
||||
}
|
||||
.sec-eyebrow::before {
|
||||
content: "";
|
||||
width: 5px;
|
||||
height: 5px;
|
||||
border-radius: 50%;
|
||||
background: var(--t5);
|
||||
}
|
||||
.page-head .actions {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: var(--space-2);
|
||||
flex-shrink: 0;
|
||||
}
|
||||
.empty-note {
|
||||
color: var(--text-faint);
|
||||
color: var(--t4);
|
||||
text-align: center;
|
||||
padding: 40px 20px;
|
||||
font-size: 12.5px;
|
||||
padding: var(--space-6) var(--space-5);
|
||||
font-size: 12px;
|
||||
line-height: 2;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
.empty-note b { color: var(--text-sub); font-weight: 600; }
|
||||
|
||||
|
||||
/* ============================================================
|
||||
手绘涂鸦装饰层:fixed 浮于页面顶层,仅视觉点缀,
|
||||
不参与流式布局、不拦截交互;html.no-doodles 整体关闭
|
||||
============================================================ */
|
||||
.doodle {
|
||||
position: fixed;
|
||||
pointer-events: none;
|
||||
user-select: none;
|
||||
z-index: 9999;
|
||||
opacity: .55;
|
||||
filter: drop-shadow(0 2px 3px rgba(var(--text-rgb), .06));
|
||||
animation: doodleFloat 7s ease-in-out infinite;
|
||||
}
|
||||
html.no-doodles .doodle { display: none; }
|
||||
@keyframes doodleFloat {
|
||||
0%, 100% { transform: translateY(0) rotate(-1deg); }
|
||||
50% { transform: translateY(-8px) rotate(1.5deg); }
|
||||
}
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
.doodle { animation: none; }
|
||||
}
|
||||
.empty-note b { color: var(--t2); font-weight: 600; }
|
||||
|
||||
@@ -0,0 +1,128 @@
|
||||
import { onUnmounted, ref } from 'vue'
|
||||
|
||||
// 下载/更新任务通用状态机:壳子更新、Chrome 安装包、环境包三套共用。
|
||||
// 负责状态拉取与轮询、下载态跃迁的一次性提示、弹窗可见性与忙碌态;
|
||||
// 各资源的点击分支与文案仍由调用方决定(配置回调)。
|
||||
|
||||
/**
|
||||
* @param {Object} opts
|
||||
* @param {() => Promise<Object>} opts.fetchStatus 拉取状态(返回含 dl/installed 等字段)
|
||||
* @param {() => boolean} [opts.enabled] 是否允许轮询(如未登录时暂停)
|
||||
* @param {(s:Object) => boolean} [opts.shouldPoll] 拿到状态后是否继续轮询
|
||||
* @param {(s:Object) => boolean} opts.isDownloading 是否处于下载/安装进行中(识别跃迁)
|
||||
* @param {(s:Object) => boolean} [opts.isCompleted] 结束态是否真的完成(默认视为完成)
|
||||
* @param {(s:Object) => void} [opts.onCompleted] 下载中 → 结束(成功)时提示一次
|
||||
* @param {(s:Object) => void} [opts.onFailed] 下载中 → 失败时提示一次
|
||||
* @param {(s:Object, prev:Object) => void} [opts.onTick] 每次拿到新状态(跃迁提示后)
|
||||
* @param {number} [opts.pollMs=1500] 常态轮询间隔
|
||||
* @param {number} [opts.downloadingPollMs] 下载中轮询间隔(默认同 pollMs)
|
||||
*/
|
||||
export function useDownloadJob(opts) {
|
||||
const {
|
||||
fetchStatus, enabled, shouldPoll, isDownloading, isCompleted = () => true,
|
||||
onCompleted, onFailed, onTick,
|
||||
pollMs = 1500, downloadingPollMs = pollMs,
|
||||
} = opts
|
||||
|
||||
const state = ref({})
|
||||
const busy = ref(false) // 按钮 loading
|
||||
const dialog = ref(false) // 进度弹窗
|
||||
let timer = null
|
||||
// 上一轮观察到的"进行中"标志:独立于 state 赋值保存,
|
||||
// 保证内网秒下(首轮轮询即完成)也能触发一次完成提示
|
||||
let inFlight = false
|
||||
|
||||
function stop() {
|
||||
if (timer) { clearTimeout(timer); timer = null }
|
||||
}
|
||||
|
||||
function transitions(prev, s) {
|
||||
const st = s.dl?.status || ''
|
||||
const downloading = !!isDownloading(s)
|
||||
if (inFlight && !downloading) {
|
||||
inFlight = false
|
||||
if (st === 'failed') onFailed && onFailed(s)
|
||||
else if (isCompleted(s)) onCompleted && onCompleted(s)
|
||||
}
|
||||
inFlight = downloading
|
||||
onTick && onTick(s, prev)
|
||||
}
|
||||
|
||||
async function refreshOnce() {
|
||||
const prev = state.value
|
||||
const s = await fetchStatus()
|
||||
state.value = s
|
||||
transitions(prev, s)
|
||||
return s
|
||||
}
|
||||
|
||||
async function tick() {
|
||||
timer = null
|
||||
if (enabled && !enabled()) return
|
||||
try {
|
||||
const s = await refreshOnce()
|
||||
if (shouldPoll && !shouldPoll(s)) return
|
||||
} catch (_) {
|
||||
if (shouldPoll && !shouldPoll(state.value)) return
|
||||
}
|
||||
timer = setTimeout(tick, isDownloading(state.value) ? downloadingPollMs : pollMs)
|
||||
}
|
||||
|
||||
function start() {
|
||||
if (timer) return
|
||||
tick()
|
||||
}
|
||||
|
||||
// 打断当前轮询节奏,立刻按最新状态重新排期。
|
||||
// 下载开始时必须调用:常态轮询(如壳子 15s)已排好定时器时 start() 会直接返回,
|
||||
// 整个下载期(内网秒下)一帧都刷不到,进度条会一直停在点击时的 0%。
|
||||
function restart() {
|
||||
stop()
|
||||
tick()
|
||||
}
|
||||
|
||||
async function load() {
|
||||
try { await refreshOnce() } catch (_) { /* 后端未就绪:保持当前状态继续轮询 */ }
|
||||
if (!shouldPoll || shouldPoll(state.value)) start()
|
||||
return state.value
|
||||
}
|
||||
|
||||
// 本地即刻状态(如点击安装后立即显示"安装中",等待轮询确认)
|
||||
function patch(partial) {
|
||||
state.value = { ...state.value, ...partial }
|
||||
}
|
||||
|
||||
// 点击下载:立即进入"下载中"再发请求(内网秒下,不能等轮询才给反馈);
|
||||
// 启动失败回写 failed 并抛给调用方提示
|
||||
async function beginDownload({ version = '', start: startFn, afterStart }) {
|
||||
if (busy.value) return
|
||||
busy.value = true
|
||||
dialog.value = true
|
||||
state.value = { ...state.value, dl: { status: 'downloading', version, received: 0, total: 0, pct: 0, error: '' } }
|
||||
inFlight = true
|
||||
try {
|
||||
await startFn()
|
||||
if (afterStart) await afterStart()
|
||||
else await refreshOnce()
|
||||
} catch (e) {
|
||||
const msg = (e && e.message) || String(e)
|
||||
state.value = { ...state.value, dl: { ...(state.value.dl || {}), status: 'failed', error: msg } }
|
||||
inFlight = false
|
||||
throw e
|
||||
} finally {
|
||||
busy.value = false
|
||||
// 立即切到下载轮询节奏(下载中按 downloadingPollMs 高频刷新),
|
||||
// 不等上一次常态轮询(15s)到点,否则进度条全程停在 0%
|
||||
if (state.value.dl?.status === 'downloading') restart()
|
||||
}
|
||||
}
|
||||
|
||||
// 取消"进行中"标记(请求实际未开始下载时,避免误报完成)
|
||||
function settle() {
|
||||
inFlight = false
|
||||
}
|
||||
|
||||
onUnmounted(stop)
|
||||
|
||||
return { state, busy, dialog, load, start, stop, patch, beginDownload, settle }
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
// 通用格式化:运行台历史、定时任务、下载弹窗共用,避免各组件重复实现。
|
||||
|
||||
export function fmtBytes(n) {
|
||||
if (!n) return '0 B'
|
||||
const u = ['B', 'KB', 'MB', 'GB']
|
||||
let i = 0
|
||||
while (n >= 1024 && i < u.length - 1) { n /= 1024; i++ }
|
||||
return (n >= 100 || i === 0 ? n.toFixed(0) : n.toFixed(1)) + ' ' + u[i]
|
||||
}
|
||||
|
||||
const pad2 = (n) => String(n).padStart(2, '0')
|
||||
|
||||
// 时间戳(秒)→ "10-26 14:30";空值/非法值返回占位符
|
||||
export function fmtTime(ts, fallback = '—') {
|
||||
if (!ts) return fallback
|
||||
const d = new Date(ts * 1000)
|
||||
if (isNaN(d.getTime())) return fallback
|
||||
return `${pad2(d.getMonth() + 1)}-${pad2(d.getDate())} ${pad2(d.getHours())}:${pad2(d.getMinutes())}`
|
||||
}
|
||||
|
||||
// 时间字符串(如后端 "2026-10-26 14:30:00")→ "10-26 14:30"
|
||||
export 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())}`
|
||||
}
|
||||
|
||||
// 耗时秒数 → "45s" / "2分05s"
|
||||
export function durText(s) {
|
||||
const n = parseInt(s, 10) || 0
|
||||
if (n < 60) return n + 's'
|
||||
const m = Math.floor(n / 60)
|
||||
return m + '分' + (n % 60 ? pad2(n % 60) + 's' : '')
|
||||
}
|
||||
|
||||
// 版本比较:数字段按 int(1.10.0 > 1.9.0),非数字段按小写字符串;对齐 electron/crypto.js 的 versionLt
|
||||
export function versionLt(a, b) {
|
||||
const key = (s) => String(s || '').split('.')
|
||||
.map((x) => (/^\d+$/.test(x) ? [1, parseInt(x, 10)] : [0, x.toLowerCase()]))
|
||||
const ka = key(a)
|
||||
const kb = key(b)
|
||||
for (let i = 0; i < Math.max(ka.length, kb.length); i++) {
|
||||
const x = ka[i] || [0, '']
|
||||
const y = kb[i] || [0, '']
|
||||
if (x[0] !== y[0]) return x[0] < y[0]
|
||||
if (x[1] !== y[1]) return x[1] < y[1]
|
||||
}
|
||||
return false
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
// 场景色点:语义调色板按插件在总清单中的序号取色,
|
||||
// 分组/搜索/筛选后颜色保持稳定(App.vue 场景库与 SceneCard 共用一份)。
|
||||
export const SCENE_DOTS = [
|
||||
'var(--brand)', 'var(--warn)', 'var(--good)',
|
||||
'var(--info)', 'var(--violet)', 'var(--danger)',
|
||||
]
|
||||
|
||||
export function sceneDotColor(index) {
|
||||
const i = index < 0 ? 0 : index
|
||||
return SCENE_DOTS[i % SCENE_DOTS.length]
|
||||
}
|
||||
@@ -10,6 +10,8 @@ export default defineConfig({
|
||||
proxy: {
|
||||
'/api': { target: 'http://127.0.0.1:8799', changeOrigin: true },
|
||||
'/ws': { target: 'ws://127.0.0.1:8799', ws: true },
|
||||
// 插件专属界面:运行台以同源 iframe 加载 /pui/<id>/,dev 下必须转给壳内服务
|
||||
'/pui': { target: 'http://127.0.0.1:8799', changeOrigin: true },
|
||||
},
|
||||
},
|
||||
build: {
|
||||
|
||||
Reference in New Issue
Block a user