feat(electron-shell): 1.8.0 执行队列、流程编排、流程定时与版本回滚
- 执行队列:多任务串行排队,可单独取消,超时自动放弃,异常退出后标记已中断 - 流程编排:画布多场景依赖图,内置确保登录/等待/通知/人工确认节点 - 流程定时:场景与流程统一配置定时(每天/工作日/每周/每月/每隔N小时) - 流程版本历史:自动留档 20 版,画布一键回滚且回滚可撤销 - 流程配置云备份:随定时任务备份到中心机,换机自动恢复 - 总览页/场景库布局调整,通知浮窗右下角堆叠显示
This commit is contained in:
@@ -5,7 +5,7 @@
|
||||
<span class="boot-dots"><i></i><i></i><i></i></span>
|
||||
</div>
|
||||
<div class="__app" v-else>
|
||||
<!-- 自定义顶栏:frameless 窗控(最小化/最大化/关闭)+ 面包屑 + 服务状态 + 版本 -->
|
||||
<!-- 自定义顶栏:frameless 窗控 + 面包屑。状态类信息统一放状态栏/右轨,顶栏不重复占位 -->
|
||||
<header class="topbar">
|
||||
<span class="brand-mark">37</span>
|
||||
<span class="brand-name">{{ store.appName }}</span>
|
||||
@@ -16,10 +16,10 @@
|
||||
<span class="crumb-cur">{{ viewName }}</span>
|
||||
</div>
|
||||
<span class="tb-spacer"></span>
|
||||
<span v-if="store.current" class="pill-service" :class="{ bad: !store.wsOn }">
|
||||
<i class="ps-dot"></i>{{ store.wsOn ? '服务正常' : '服务重连中' }}
|
||||
<!-- 只在异常时提示:正常连通不占位(状态栏已常驻) -->
|
||||
<span v-if="store.current && !store.wsOn" class="pill-service bad">
|
||||
<i class="ps-dot"></i>服务重连中
|
||||
</span>
|
||||
<span v-if="shellUpdate.current" class="tb-ver">v{{ shellUpdate.current }}</span>
|
||||
<div class="win-ctrl">
|
||||
<button class="wc-btn" title="最小化" @click="winMin">—</button>
|
||||
<button class="wc-btn" :title="isMax ? '还原' : '最大化'" @click="winMax">{{ isMax ? '❐' : '▢' }}</button>
|
||||
@@ -71,6 +71,9 @@
|
||||
<div class="nav-item" :class="{ active: store.view === 'plans' }" @click="openPlans">
|
||||
<el-icon><Clock /></el-icon><span>计划</span>
|
||||
</div>
|
||||
<div class="nav-item" :class="{ active: store.view === 'flows' }" @click="openFlows">
|
||||
<el-icon><Connection /></el-icon><span>流程</span>
|
||||
</div>
|
||||
<div class="nav-item" :class="{ active: store.view === 'platform' }" @click="openPlatform">
|
||||
<el-icon><Link /></el-icon><span>平台账号</span>
|
||||
<span class="nav-badge good">{{ onlineCount }}/{{ store.platforms.length }}</span>
|
||||
@@ -78,10 +81,10 @@
|
||||
</nav>
|
||||
<div class="hr"></div>
|
||||
|
||||
<!-- 场景库:搜索 + 最近使用置顶 + 分类折叠分组 -->
|
||||
<!-- 场景:左栏只放最近使用的 5 个(高频入口),完整清单/搜索/分类在「场景库」页 -->
|
||||
<div class="scene-head">
|
||||
<span class="sh-label">场景库</span>
|
||||
<span class="count-pill">{{ filteredPlugins.length }}<template v-if="filteredPlugins.length !== store.plugins.length">/{{ store.plugins.length }}</template></span>
|
||||
<span class="sh-label">场景</span>
|
||||
<span class="count-pill">{{ sideScenes.length }}/{{ store.plugins.length }}</span>
|
||||
<span class="tb-spacer"></span>
|
||||
<el-tooltip content="插件同步" placement="top">
|
||||
<button class="sync-btn" :class="{ spin: syncingPlugins }"
|
||||
@@ -90,50 +93,18 @@
|
||||
</button>
|
||||
</el-tooltip>
|
||||
</div>
|
||||
<!-- 场景搜索:插件多时提供快速定位(名称/描述/ID 模糊) -->
|
||||
<div v-if="store.plugins.length > SHOW_SEARCH_MIN" class="scene-search">
|
||||
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round">
|
||||
<circle cx="11" cy="11" r="7" /><path d="M21 21l-4.3-4.3" />
|
||||
</svg>
|
||||
<input v-model="sceneQuery" placeholder="搜索场景…" />
|
||||
<button v-if="sceneQuery" class="ss-clear" @click="sceneQuery = ''">✕</button>
|
||||
</div>
|
||||
<div class="scene-list">
|
||||
<!-- 最近使用:持久化最近运行的场景置顶,高频场景不随数量增长被挤到下面 -->
|
||||
<template v-if="recentScenes.length && !sceneQuery">
|
||||
<div class="grp-head" @click="toggleGroup(RECENT_KEY)">
|
||||
<span class="grp-arrow" :class="{ off: grpCollapsed(RECENT_KEY) }">▾</span>
|
||||
<span class="grp-name">最近使用</span>
|
||||
<span class="grp-count">{{ recentScenes.length }}</span>
|
||||
</div>
|
||||
<template v-if="!grpCollapsed(RECENT_KEY)">
|
||||
<div v-for="p in recentScenes" :key="p.id" class="scene-row"
|
||||
:class="{ current: p.id === store.selectedId && store.view === 'run' }" @click="openRun(p.id)">
|
||||
<span class="sr-dot" :style="{ background: sceneDotColor(pluginIndex(p)) }"></span>
|
||||
<span class="sr-name">{{ p.name }}</span>
|
||||
<em>v{{ p.version }}</em>
|
||||
</div>
|
||||
</template>
|
||||
</template>
|
||||
<!-- 按分类分组(可折叠),未分类归「其他」 -->
|
||||
<template v-for="g in sceneGroups" :key="g.key">
|
||||
<div class="grp-head" @click="toggleGroup(g.key)">
|
||||
<span class="grp-arrow" :class="{ off: grpCollapsed(g.key) }">▾</span>
|
||||
<span class="grp-name">{{ g.label }}</span>
|
||||
<span class="grp-count">{{ g.items.length }}</span>
|
||||
</div>
|
||||
<template v-if="!grpCollapsed(g.key)">
|
||||
<div v-for="p in g.items" :key="p.id" class="scene-row"
|
||||
:class="{ current: p.id === store.selectedId && store.view === 'run' }" @click="openRun(p.id)">
|
||||
<span class="sr-dot" :style="{ background: sceneDotColor(pluginIndex(p)) }"></span>
|
||||
<span class="sr-name">{{ p.name }}</span>
|
||||
<em>v{{ p.version }}</em>
|
||||
</div>
|
||||
</template>
|
||||
</template>
|
||||
<div v-for="p in sideScenes" :key="p.id" class="scene-row"
|
||||
:class="{ current: p.id === store.selectedId && store.view === 'run' }" @click="openRun(p.id)">
|
||||
<span class="sr-dot" :style="{ background: sceneDotColor(pluginIndex(p)) }"></span>
|
||||
<span class="sr-name">{{ p.name }}</span>
|
||||
<em>v{{ p.version }}</em>
|
||||
</div>
|
||||
<div v-if="!store.plugins.length" class="scene-empty">当前账号暂无可用场景<br><span>请联系管理员进行授权</span></div>
|
||||
<div v-else-if="!filteredPlugins.length" class="scene-empty">未找到匹配「{{ sceneQuery }}」的场景<br><span>换个关键词试试</span></div>
|
||||
</div>
|
||||
<button v-if="store.plugins.length" class="all-scenes" @click="openScenes">
|
||||
全部场景 {{ store.plugins.length }}<i class="arr">→</i>
|
||||
</button>
|
||||
|
||||
<!-- 账号块 -->
|
||||
<div class="account">
|
||||
@@ -146,8 +117,10 @@
|
||||
<el-tooltip content="修改密码" placement="top">
|
||||
<button class="acct-btn" @click="pwdDlg = true"><el-icon><Key /></el-icon></button>
|
||||
</el-tooltip>
|
||||
<el-tooltip content="登出" placement="top">
|
||||
<button class="acct-btn danger" @click="logout"><el-icon><SwitchButton /></el-icon></button>
|
||||
<el-tooltip :content="switchBlocked ? '任务执行中,停止后才能切换账号' : '登出'" placement="top">
|
||||
<button class="acct-btn danger" :class="{ blocked: switchBlocked }" @click="logout">
|
||||
<el-icon><SwitchButton /></el-icon>
|
||||
</button>
|
||||
</el-tooltip>
|
||||
</div>
|
||||
</aside>
|
||||
@@ -159,23 +132,26 @@
|
||||
<ScenesPage v-else-if="store.view === 'scenes'" />
|
||||
<PluginPage v-else-if="store.view === 'run'" />
|
||||
<SchedulePage v-else-if="store.view === 'plans'" />
|
||||
<FlowPage v-else-if="store.view === 'flows'" />
|
||||
<PlatformAccounts v-else-if="store.view === 'platform'" />
|
||||
</div>
|
||||
</main>
|
||||
|
||||
<!-- 右轨:活动流(当前运行 + 最近运行)+ 平台账号;只回显,细节在运行台 -->
|
||||
<!-- 右轨只回答两件事:「现在在跑什么/还排着什么」和「最近跑过什么」。
|
||||
平台账号在左栏「平台账号」页;详细日志在运行台,此处只留一行最新输出。 -->
|
||||
<aside class="side-r">
|
||||
<div class="rail-head">
|
||||
<span class="rh-label">活动</span>
|
||||
<span class="rh-label">执行</span>
|
||||
<RunIndicator v-if="store.running" variant="tag" label="进行中" />
|
||||
<span v-else class="tag off">空闲</span>
|
||||
</div>
|
||||
<div class="now-card" :class="store.running ? 'running' : 'idle'">
|
||||
<RunIndicator v-if="store.running" :name="runningName" :progress="store.progress" :show-label="false">
|
||||
<template #tail>
|
||||
<div v-for="(l, i) in tailLogs" :key="i" class="tail-line"
|
||||
:class="{ w: l.level === 'WARN', e: l.level === 'ERROR' }">{{ l.msg }}</div>
|
||||
<div v-if="!tailLogs.length" class="tail-wait">等待输出…</div>
|
||||
<div v-if="tailLogs.length" class="tail-line" :class="{ w: tailLogs[0].level === 'WARN', e: tailLogs[0].level === 'ERROR' }">
|
||||
{{ tailLogs[0].msg }}
|
||||
</div>
|
||||
<div v-else class="tail-wait">等待输出…</div>
|
||||
</template>
|
||||
</RunIndicator>
|
||||
<template v-else>
|
||||
@@ -184,58 +160,48 @@
|
||||
</template>
|
||||
</div>
|
||||
|
||||
<!-- 执行队列:只列等待中的任务(执行中的由上方「当前运行」卡负责) -->
|
||||
<QueuePanel />
|
||||
|
||||
<div class="hr"></div>
|
||||
<div class="rail-sub">
|
||||
<span class="rs-label">最近运行</span>
|
||||
<span v-if="store.recents.length" class="rs-n">{{ store.recents.length }}</span>
|
||||
</div>
|
||||
<div class="act-list">
|
||||
<div v-for="(r, i) in store.recents" :key="i" class="act-row"
|
||||
:title="r.ok ? r.name : `${r.name} — ${r.error || '失败'}`"
|
||||
<div v-for="(r, i) in store.recents.slice(0, 5)" :key="i" class="act-row"
|
||||
:title="r.ok ? r.name : `${r.name} — ${r.error || (r.cancelled ? '已取消' : '失败')}`"
|
||||
@click="openRun(r.pluginId, r.runId)">
|
||||
<i :class="r.ok ? 'ok' : 'bad'"></i>
|
||||
<i :class="r.ok ? 'ok' : (r.cancelled ? 'mid' : 'bad')"></i>
|
||||
<span class="nm">{{ r.name }}</span>
|
||||
<span class="tm">{{ r.time }}</span>
|
||||
<span class="st" :class="r.ok ? 'ok' : 'bad'">{{ r.ok ? '成功' : '失败' }}</span>
|
||||
<span class="st" :class="r.ok ? 'ok' : (r.cancelled ? 'mid' : 'bad')">{{ r.ok ? '成功' : (r.cancelled ? '已取消' : '失败') }}</span>
|
||||
</div>
|
||||
<div v-if="!store.recents.length" class="act-empty">本次会话暂无运行记录</div>
|
||||
</div>
|
||||
|
||||
<div class="hr"></div>
|
||||
<div class="rail-sub">
|
||||
<span class="rs-label">平台账号</span>
|
||||
<span class="rs-n good">{{ onlineCount }} / {{ store.platforms.length }}</span>
|
||||
</div>
|
||||
<div class="plat-list">
|
||||
<div v-for="p in store.platforms" :key="p.id" class="plat-row" @click="openPlatform">
|
||||
<i :class="p.online ? 'ok' : 'warn'"></i>
|
||||
<span class="nm">{{ p.label }}</span>
|
||||
<span class="st" :class="p.online ? 'ok' : 'warn'">{{ p.online ? '已登录' : '未登录' }}</span>
|
||||
</div>
|
||||
<div v-if="!store.platforms.length" class="act-empty">暂无平台配置</div>
|
||||
</div>
|
||||
<div class="rail-flex"></div>
|
||||
</aside>
|
||||
</div>
|
||||
|
||||
<!-- 状态栏:机器与授权事实(Chrome/环境包/授权/本地服务) -->
|
||||
<!-- 状态栏:只放"机器事实",且同一事实不重复(版本与检查更新合并成一项) -->
|
||||
<footer class="statusbar">
|
||||
<span v-if="chromeVis" class="sb-item click" :class="chromeInstalled ? 'ok' : 'warn'"
|
||||
:title="chromeTip" @click="onChromeClick">
|
||||
<i class="sb-dot"></i>{{ chromeLabel }}
|
||||
</span>
|
||||
<span class="sb-item" :class="licenseCls"><i class="sb-dot"></i>{{ licenseText }}</span>
|
||||
<span v-if="envVis" class="sb-item click" :class="envCls"
|
||||
:title="envTip" @click="onEnvClick">
|
||||
<i v-if="envBusyState" class="sb-spin"></i>
|
||||
<i v-else class="sb-dot"></i>{{ envLabel }}
|
||||
</span>
|
||||
<span class="sb-item" :class="licenseCls"><i class="sb-dot"></i>{{ licenseText }}</span>
|
||||
<!-- 浏览器常驻:需要看当前版本号(有新版时可点进来重新检测/安装) -->
|
||||
<span v-if="chromeVis" class="sb-item click" :class="chromeInstalled ? 'ok' : 'warn'"
|
||||
:title="chromeTip" @click="onChromeClick">
|
||||
<i class="sb-dot"></i>{{ chromeLabel }}
|
||||
</span>
|
||||
<span class="sb-item" :class="store.wsOn ? 'ok' : 'warn'">
|
||||
<i class="sb-dot"></i>{{ store.wsOn ? '本地服务已连接' : '本地服务重连中' }}
|
||||
</span>
|
||||
<span class="sb-spacer"></span>
|
||||
<span class="sb-item">客户端 {{ shellUpdate.current ? 'v' + shellUpdate.current : '未打包' }}</span>
|
||||
<span class="sb-upd" :class="{ disabled: shellChecking }" @click="!shellChecking && onShellCheck()">
|
||||
{{ shellChecking ? '检查中…' : '检查更新' }}
|
||||
客户端 {{ shellUpdate.current ? 'v' + shellUpdate.current : '未打包' }} · {{ shellChecking ? '检查中…' : '检查更新' }}
|
||||
</span>
|
||||
</footer>
|
||||
</template>
|
||||
@@ -282,32 +248,38 @@
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { computed, onMounted, onUnmounted, ref } from 'vue'
|
||||
import { computed, onMounted, onUnmounted, ref, watch } from 'vue'
|
||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
import { Clock, HomeFilled, Refresh, Key, Grid, Link, SwitchButton } from '@element-plus/icons-vue'
|
||||
import { Clock, HomeFilled, Refresh, Key, Grid, Link, SwitchButton, Connection } from '@element-plus/icons-vue'
|
||||
import HomePage from './components/HomePage.vue'
|
||||
import ScenesPage from './components/ScenesPage.vue'
|
||||
import PluginPage from './components/PluginPage.vue'
|
||||
import SchedulePage from './components/SchedulePage.vue'
|
||||
import FlowPage from './components/FlowPage.vue'
|
||||
import PlatformAccounts from './components/PlatformAccounts.vue'
|
||||
import LoginPage from './components/LoginPage.vue'
|
||||
import ChangePasswordDialog from './components/ChangePasswordDialog.vue'
|
||||
import DownloadDialog from './components/DownloadDialog.vue'
|
||||
import RunIndicator from './components/RunIndicator.vue'
|
||||
import QueuePanel from './components/QueuePanel.vue'
|
||||
import { useDownloadJob } from './useDownloadJob'
|
||||
import { sceneDotColor } from './utils/theme'
|
||||
import { fmtBytes, versionLt } from './utils/format'
|
||||
import { useSceneLibrary, SHOW_SEARCH_MIN, RECENT_KEY } from './composables/useSceneLibrary'
|
||||
import { useSceneLibrary } from './composables/useSceneLibrary'
|
||||
import { usePluginSync } from './composables/usePluginSync'
|
||||
import { useSocket } from './composables/useSocket'
|
||||
import { useShellCheck } from './composables/useShellCheck'
|
||||
import { store, clearLogs, log, loadAvatar, clearAvatarCache, accountAvatar } from './store'
|
||||
import { store, clearLogs, log, loadAvatar, clearAvatarCache, accountAvatar, resetQueue } from './store'
|
||||
import { fetchMeta, getBootStatus, adminLogout, adminMe, adminPassword, syncPlugins, getShellStatus, applyShellUpdate, downloadShellUpdate, getChromeStatus, checkChrome, downloadChrome, installChrome, getEnvStatus, syncEnv } from './api'
|
||||
|
||||
// ===== 左侧场景库:搜索 + 最近使用置顶 + 分类折叠分组 =====
|
||||
const {
|
||||
sceneQuery, filteredPlugins, sceneGroups, recentScenes,
|
||||
pluginIndex, grpCollapsed, toggleGroup, loadRecentScenes,
|
||||
} = useSceneLibrary()
|
||||
// ===== 左侧场景:只保留最近使用(高频入口),全量清单交给「场景库」页 =====
|
||||
const { recentScenes, pluginIndex, loadRecentScenes } = useSceneLibrary()
|
||||
|
||||
// 没有运行历史时退回清单前 10 个,避免新账号左栏空着
|
||||
const sideScenes = computed(() => {
|
||||
const list = recentScenes.value.length ? recentScenes.value : store.plugins
|
||||
return list.slice(0, 10)
|
||||
})
|
||||
|
||||
// 头像加载失败:清除缓存返回首字符兜底
|
||||
function onAvatarError() {
|
||||
@@ -335,12 +307,16 @@ function openPlans() {
|
||||
store.view = 'plans'
|
||||
}
|
||||
|
||||
function openFlows() {
|
||||
store.view = 'flows'
|
||||
}
|
||||
|
||||
function openPlatform() {
|
||||
store.view = 'platform'
|
||||
}
|
||||
|
||||
// 面包屑当前视图名(登录前显示「登录」)
|
||||
const VIEW_NAMES = { overview: '总览', scenes: '场景库', run: '运行台', plans: '计划', platform: '平台账号' }
|
||||
const VIEW_NAMES = { overview: '总览', scenes: '场景库', run: '运行台', plans: '计划', flows: '流程编排', platform: '平台账号' }
|
||||
const viewName = computed(() => !store.current ? '登录' : (VIEW_NAMES[store.view] || '总览'))
|
||||
|
||||
// 平台账号在线数(meta.platforms[].online 由 PlatformAccounts.refresh() 回写)
|
||||
@@ -359,8 +335,34 @@ const runningName = computed(() => {
|
||||
const pid = store._runPlugins[store.currentRun] || store.selectedId
|
||||
return (store.plugins.find((p) => p.id === pid) || {}).name || '正在执行'
|
||||
})
|
||||
// 运行中:右栏只回显最近几条日志,细节仍在运行台「运行日志」标签页
|
||||
const tailLogs = computed(() => store.logs.slice(-4))
|
||||
// 运行中:右栏只回显最新一行输出(完整日志在运行台「运行日志」标签页,避免两处同时刷屏)
|
||||
const tailLogs = computed(() => store.logs.slice(-1))
|
||||
// 入队轻提示:排队任务在界面上原本"点了没反应"(run_start 要等轮到自己才发),
|
||||
// 这里用一条 toast 立刻告知位置。第 1 位=马上开始,不打扰;定时触发也不弹。
|
||||
watch(() => store.lastQueued, (q) => {
|
||||
if (!q || q.position <= 1 || q.trigger === 'schedule') return
|
||||
ElMessage({
|
||||
message: `「${q.name}」已加入执行队列,当前排第 ${q.position} 位`,
|
||||
type: 'info',
|
||||
grouping: true,
|
||||
duration: 3200,
|
||||
showClose: true,
|
||||
})
|
||||
})
|
||||
|
||||
// 上次异常退出遗留的排队任务已被标记为「已中断」:启动后提示一次
|
||||
watch(() => store.lastRecovered, (r) => {
|
||||
if (!r || !r.count) return
|
||||
ElMessage({
|
||||
message: `上次退出时有 ${r.count} 个排队任务未执行,已标记为「已中断」`,
|
||||
type: 'warning',
|
||||
grouping: true,
|
||||
duration: 5000,
|
||||
showClose: true,
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
const lastRunText = computed(() => {
|
||||
const r = store.recents[0]
|
||||
if (!r) return '本次会话暂无运行记录'
|
||||
@@ -445,7 +447,7 @@ const chromeDlText = computed(() => {
|
||||
})
|
||||
|
||||
const chromeInstalled = computed(() => !!chrome.value.installed)
|
||||
// 常驻显示:只要后端返回过 Chrome 状态就展示(已安装绿色版本号 / 未安装橙色入口)
|
||||
// 常驻显示:只要后端返回过 Chrome 状态就展示(已安装 → 绿色 + 版本号 / 未安装 → 橙色入口)
|
||||
const chromeVis = computed(() => 'installed' in chrome.value)
|
||||
|
||||
const chromeLabel = computed(() => {
|
||||
@@ -715,33 +717,11 @@ function handleCheckResult(s) {
|
||||
}
|
||||
}
|
||||
|
||||
// ===== 插件同步:按当前账号权限重新同步(新装/更新/清理已删除),完成后刷新清单 =====
|
||||
// 登录成功与手动刷新共用;同步失败也补拉清单,保证离线时沿用本地已装插件
|
||||
const syncingPlugins = ref(false)
|
||||
// ===== 插件同步:逻辑收敛在 usePluginSync(左栏图标 / 场景库页按钮 / 登录后自动同步共用) =====
|
||||
const { syncing: syncingPlugins, syncNow, refreshMeta: refreshMetaBase } = usePluginSync()
|
||||
|
||||
async function onPluginSync() {
|
||||
if (syncingPlugins.value || store.running) return
|
||||
syncingPlugins.value = true
|
||||
try {
|
||||
const r = await syncPlugins()
|
||||
const parts = []
|
||||
if (r.downloaded?.length) parts.push(`新装 ${r.downloaded.length} 个`)
|
||||
if (r.updated?.length) parts.push(`更新 ${r.updated.length} 个`)
|
||||
if (r.removed?.length) parts.push(`清理 ${r.removed.length} 个`)
|
||||
if (r.failed?.length) parts.push(`失败 ${r.failed.length} 个`)
|
||||
if (parts.length) {
|
||||
ElMessage.success('插件同步完成:' + parts.join(','))
|
||||
const detail = [...(r.downloaded || []), ...(r.updated || []), ...(r.removed || [])].join('、')
|
||||
if (detail) log('INFO', `插件同步完成:${parts.join(',')}(${detail})`)
|
||||
} else {
|
||||
ElMessage.info('插件已是最新')
|
||||
}
|
||||
if (r.failed?.length) log('ERROR', `插件同步失败:${r.failed.join('、')}`)
|
||||
} catch (e) {
|
||||
ElMessage.error('插件同步失败:' + (e.message || e))
|
||||
} finally {
|
||||
await refreshMeta()
|
||||
syncingPlugins.value = false
|
||||
}
|
||||
await syncNow()
|
||||
}
|
||||
|
||||
// 带超时的 Promise:超时返回 undefined;失败/超时都打日志便于启动诊断(P7)
|
||||
@@ -770,6 +750,7 @@ async function checkSession() {
|
||||
const me = await withTimeout(adminMe(), 8000) || {}
|
||||
if (!me.account) {
|
||||
store.current = ''; store.dept = ''; store.nickname = ''; store.avatar = ''
|
||||
resetQueue()
|
||||
try { localStorage.removeItem('cp_account') } catch (_) {}
|
||||
return
|
||||
}
|
||||
@@ -802,18 +783,10 @@ function onWindowFocus() {
|
||||
|
||||
async function refreshMeta() {
|
||||
try {
|
||||
const meta = await fetchMeta()
|
||||
store.platforms = meta.platforms
|
||||
store.plugins = meta.plugins || []
|
||||
store.authExpired = !!meta.authExpired
|
||||
store.license = meta.license || null
|
||||
// 选中场景不存在(被同步清理/授权收回)时回落到第一个可用场景
|
||||
if (!store.plugins.find((p) => p.id === store.selectedId)) {
|
||||
store.selectedId = store.plugins[0]?.id || ''
|
||||
}
|
||||
await refreshMetaBase()
|
||||
// 场景清单更新后刷新「最近使用」置顶(基于持久化运行历史)
|
||||
loadRecentScenes()
|
||||
} catch (_) {}
|
||||
} catch (_) { /* 后端不可达:保留现有清单 */ }
|
||||
}
|
||||
|
||||
async function onLogin(ok) {
|
||||
@@ -857,13 +830,27 @@ async function promptChangePwd(account) {
|
||||
}
|
||||
} catch (_) { /* 用户取消 */ }
|
||||
}
|
||||
// 执行/排队中禁止切换账号:一次运行带着账号上下文(平台 cookie、凭据、上报归属),半路换号会串号
|
||||
const switchBlocked = computed(() => !!(store.running || store.queue.busy || store.queue.waiting))
|
||||
|
||||
async function logout() {
|
||||
try { await adminLogout() } catch (_) {}
|
||||
if (switchBlocked.value) {
|
||||
ElMessage.warning('有任务正在执行或排队,请先在右侧「执行队列」停止任务后再切换账号')
|
||||
return
|
||||
}
|
||||
try {
|
||||
await adminLogout()
|
||||
} catch (e) {
|
||||
// 后端拒绝(任务刚开始/刚结束的竞态)时不能清本地登录态,否则界面会"假登出"
|
||||
ElMessage.error(e.message || '退出失败,请稍后重试')
|
||||
return
|
||||
}
|
||||
store.current = ''
|
||||
store.nickname = ''
|
||||
store.avatar = ''
|
||||
store.avatarUrl = ''
|
||||
store.authExpired = false
|
||||
resetQueue()
|
||||
try { localStorage.removeItem('cp_account') } catch (_) {}
|
||||
}
|
||||
</script>
|
||||
@@ -924,6 +911,7 @@ async function logout() {
|
||||
.pill-service.bad { background: var(--warn-soft); color: var(--warn-ink); }
|
||||
.ps-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--good); flex-shrink: 0; }
|
||||
.pill-service.bad .ps-dot { background: var(--warn); }
|
||||
|
||||
.tb-ver { font-family: var(--f-num); font-size: 10.5px; color: var(--t4); }
|
||||
.win-ctrl { display: flex; gap: var(--space-1); -webkit-app-region: no-drag; }
|
||||
.wc-btn {
|
||||
@@ -959,7 +947,7 @@ async function logout() {
|
||||
.main {
|
||||
flex: 1; min-width: 0; display: flex; flex-direction: column; min-height: 0;
|
||||
background: var(--subtle); border: 1px solid var(--line); border-radius: var(--r-card);
|
||||
padding: var(--space-2); overflow: hidden;
|
||||
padding: var(--space-2-5); overflow: hidden;
|
||||
}
|
||||
/* 中栏滚动区:视图自决定内边距 */
|
||||
.page-scroll { flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; }
|
||||
@@ -967,7 +955,7 @@ async function logout() {
|
||||
/* ---------- 左轨:导航 + 场景库 + 账号 ---------- */
|
||||
.side {
|
||||
width: 232px; flex-shrink: 0; min-height: 0;
|
||||
display: flex; flex-direction: column; gap: var(--space-2); padding: var(--space-2);
|
||||
display: flex; flex-direction: column; gap: var(--space-2-5); padding: var(--space-2-5);
|
||||
background: var(--surface); border: 1px solid var(--line);
|
||||
border-radius: var(--r-card); box-shadow: var(--sh-card);
|
||||
}
|
||||
@@ -1006,39 +994,22 @@ async function logout() {
|
||||
.sync-btn.spin .el-icon { animation: sbSpin .9s linear infinite; }
|
||||
.sync-btn:disabled { opacity: .5; cursor: default; }
|
||||
|
||||
.scene-search {
|
||||
height: 32px; flex-shrink: 0; display: flex; align-items: center; gap: var(--space-1-5); padding: 0 var(--space-2);
|
||||
background: var(--field); border: 1px solid transparent; border-radius: var(--r-field);
|
||||
transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease);
|
||||
}
|
||||
.scene-search:focus-within { background: var(--surface); border-color: var(--border-hover); }
|
||||
.scene-search svg { width: 13px; height: 13px; color: var(--t4); flex-shrink: 0; }
|
||||
.scene-search input {
|
||||
flex: 1; min-width: 0; border: none; outline: none; background: transparent;
|
||||
font-size: 12px; color: var(--t1); font-family: inherit;
|
||||
}
|
||||
.scene-search input::placeholder { color: var(--t4); }
|
||||
.ss-clear {
|
||||
border: none; background: transparent; color: var(--t4); cursor: pointer;
|
||||
font-size: 10px; padding: 0; line-height: 1;
|
||||
}
|
||||
.ss-clear:hover { color: var(--t2); }
|
||||
|
||||
.scene-list {
|
||||
flex: 1; min-height: 0; overflow-y: auto;
|
||||
display: flex; flex-direction: column; gap: 1px;
|
||||
}
|
||||
.grp-head {
|
||||
display: flex; align-items: center; gap: var(--space-1-5); padding: var(--space-1-5) var(--space-1-5) var(--space-1);
|
||||
cursor: pointer; user-select: none; border-radius: var(--r-row); flex-shrink: 0;
|
||||
/* 「全部场景」:左栏只放最近使用,全量入口单独一行(不做成常驻列表项,避免与导航混淆) */
|
||||
.all-scenes {
|
||||
flex-shrink: 0; display: flex; align-items: center; justify-content: center; gap: var(--space-1);
|
||||
height: 30px; border: 1px dashed var(--line); border-radius: var(--r-row);
|
||||
background: transparent; color: var(--t3); cursor: pointer;
|
||||
font: 500 11.5px/1 var(--f-cn);
|
||||
transition: background var(--dur) var(--ease), color var(--dur) var(--ease), border-color var(--dur) var(--ease);
|
||||
}
|
||||
.grp-head:hover { background: var(--subtle); }
|
||||
.grp-arrow { font-size: 9px; color: var(--t4); transition: transform var(--dur) var(--ease); line-height: 1; }
|
||||
.grp-arrow.off { transform: rotate(-90deg); }
|
||||
.grp-name { flex: 1; min-width: 0; font-size: 11px; font-weight: 600; color: var(--t3); }
|
||||
.grp-count { font-family: var(--f-num); font-size: 10px; color: var(--t4); }
|
||||
.all-scenes:hover { background: var(--field); color: var(--brand-ink); border-color: var(--brand-track); }
|
||||
.all-scenes .arr { font-style: normal; font-family: var(--f-num); }
|
||||
.scene-row {
|
||||
height: 32px; flex-shrink: 0; display: flex; align-items: center; gap: var(--space-2); padding: 0 var(--space-2);
|
||||
height: 34px; flex-shrink: 0; display: flex; align-items: center; gap: var(--space-2); padding: 0 var(--space-2);
|
||||
border-radius: var(--r-row); cursor: pointer;
|
||||
transition: background var(--dur) var(--ease);
|
||||
}
|
||||
@@ -1047,7 +1018,7 @@ async function logout() {
|
||||
.scene-row.current .sr-name { color: var(--t1); font-weight: 500; }
|
||||
.sr-dot { width: 6px; height: 6px; border-radius: 3px; flex-shrink: 0; }
|
||||
.sr-name {
|
||||
flex: 1; min-width: 0; font-size: 12px; color: var(--t2);
|
||||
flex: 1; min-width: 0; font-size: 12.5px; color: var(--t2);
|
||||
white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
|
||||
}
|
||||
.scene-row em { font-style: normal; font-family: var(--f-num); font-size: 10px; color: var(--t4); }
|
||||
@@ -1076,11 +1047,14 @@ async function logout() {
|
||||
}
|
||||
.acct-btn:hover { background: var(--surface); color: var(--brand-ink); }
|
||||
.acct-btn.danger:hover { background: var(--danger-soft); color: var(--danger-ink); }
|
||||
/* 任务执行中:登出按钮变"受限态",点击给出说明而不是静默失败 */
|
||||
.acct-btn.blocked { color: var(--t5); }
|
||||
.acct-btn.blocked:hover { background: var(--field); color: var(--t4); }
|
||||
|
||||
/* ---------- 右轨:活动流 + 平台账号 ---------- */
|
||||
.side-r {
|
||||
width: 276px; flex-shrink: 0; min-height: 0;
|
||||
display: flex; flex-direction: column; gap: var(--space-2); padding: var(--space-2);
|
||||
display: flex; flex-direction: column; gap: var(--space-2-5); padding: var(--space-2-5);
|
||||
background: var(--surface); border: 1px solid var(--line);
|
||||
border-radius: var(--r-card); box-shadow: var(--sh-card);
|
||||
}
|
||||
@@ -1122,7 +1096,7 @@ async function logout() {
|
||||
.rs-n.good { color: var(--good-ink); }
|
||||
.act-list { flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 1px; }
|
||||
.act-row {
|
||||
height: 30px; flex-shrink: 0; display: flex; align-items: center; gap: var(--space-2); padding: 0 var(--space-2);
|
||||
height: 32px; flex-shrink: 0; display: flex; align-items: center; gap: var(--space-2); padding: 0 var(--space-2);
|
||||
border-radius: var(--r-row); cursor: pointer;
|
||||
transition: background var(--dur) var(--ease);
|
||||
}
|
||||
@@ -1130,14 +1104,16 @@ async function logout() {
|
||||
.act-row i { width: 5px; height: 5px; border-radius: 50%; flex-shrink: 0; }
|
||||
.act-row i.ok { background: var(--good); }
|
||||
.act-row i.bad { background: var(--danger); }
|
||||
.act-row i.mid { background: var(--t4); }
|
||||
.act-row .nm {
|
||||
flex: 1; min-width: 0; font-size: 11.5px; color: var(--t2);
|
||||
flex: 1; min-width: 0; font-size: 12px; color: var(--t2);
|
||||
white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
|
||||
}
|
||||
.act-row .tm { font-family: var(--f-num); font-size: 10px; color: var(--t4); flex-shrink: 0; }
|
||||
.act-row .st { width: 30px; text-align: right; font-size: 10px; flex-shrink: 0; }
|
||||
.act-row .st.ok { color: var(--good-ink); }
|
||||
.act-row .st.bad { color: var(--danger-ink); }
|
||||
.act-row .st.mid { color: var(--t4); }
|
||||
.act-empty { font-size: 11px; color: var(--t4); text-align: center; padding: var(--space-4) var(--space-2); line-height: 1.8; }
|
||||
|
||||
.plat-list { max-height: 132px; overflow-y: auto; display: flex; flex-direction: column; gap: 1px; }
|
||||
|
||||
Reference in New Issue
Block a user