- libs: 新增 hr_sdk / hotel_report / dingtalk,更新 desktopauto - controlplane-next: SDK 管理模块(controller/entity/migrations)与前端视图 - electron-shell: 插件同步、注册表、runner 调整 - plugins: XQ0035/XQ0041/XQ0042/XQ0045_XQ0046/XQ0048/XQ0076/XQ0078 等版本更新 - tests/tools: 新增 SDK 兼容性检查与打包工具(sdk_pack.py、sdk_compat_check.py)
1454 lines
68 KiB
Vue
1454 lines
68 KiB
Vue
<template>
|
||
<div v-if="booting" class="boot">
|
||
<span class="boot-logo">37</span>
|
||
<span class="boot-txt">{{ bootStep }}</span>
|
||
<span class="boot-dots"><i></i><i></i><i></i></span>
|
||
</div>
|
||
<div class="__app" v-else>
|
||
<!-- 自定义顶栏:frameless 窗控 + 面包屑。状态类信息统一放状态栏/右轨,顶栏不重复占位 -->
|
||
<header class="topbar">
|
||
<span class="brand-mark">37</span>
|
||
<span class="brand-name">{{ store.appName }}</span>
|
||
<div class="crumbs">
|
||
<i class="crumb-sep"></i>
|
||
<span class="crumb-root">工作台</span>
|
||
<span class="crumb-slash">/</span>
|
||
<span class="crumb-cur">{{ viewName }}</span>
|
||
</div>
|
||
<span class="tb-spacer"></span>
|
||
<!-- 只在异常时提示:正常连通不占位(状态栏已常驻) -->
|
||
<span v-if="store.current && !store.wsOn" class="pill-service bad">
|
||
<i class="ps-dot"></i>服务重连中
|
||
</span>
|
||
<div class="win-ctrl">
|
||
<button class="wc-btn" title="最小化" @click="winMin">—</button>
|
||
<button class="wc-btn" :title="isMax ? '还原' : '最大化'" @click="winMax">{{ isMax ? '❐' : '▢' }}</button>
|
||
<button class="wc-btn wc-close" title="关闭" @click="winClose">✕</button>
|
||
</div>
|
||
</header>
|
||
|
||
<!-- 壳子更新提示:已就绪重启更新 / 下载失败重试 / 发现新版本可下载(下载进度改用弹窗) -->
|
||
<div v-if="updBarVisible" class="update-bar">
|
||
<template v-if="shellUpdate.downloaded">
|
||
<span class="upd-txt">发现新版本 <b>v{{ shellUpdate.new }}</b><em v-if="shellUpdate.notes">{{ shellUpdate.notes }}</em></span>
|
||
<el-button size="small" type="primary" round :loading="updating" @click="doShellUpdate">重启更新</el-button>
|
||
</template>
|
||
<template v-else-if="updDl.status === 'failed'">
|
||
<span class="upd-txt">新版本下载失败<em>{{ updDl.error }}</em></span>
|
||
<el-button size="small" type="primary" round :loading="downloading" @click="onShellDownload">重试</el-button>
|
||
</template>
|
||
<template v-else-if="shellUpdate.available">
|
||
<span class="upd-txt">发现新版本 <b>v{{ shellUpdate.latest }}</b><em v-if="shellUpdate.notes">{{ shellUpdate.notes }}</em></span>
|
||
<div class="upd-actions">
|
||
<el-button size="small" type="primary" round :loading="downloading" @click="onShellDownload">立即下载</el-button>
|
||
<el-button size="small" round @click="shellDismissed = true">暂不</el-button>
|
||
</div>
|
||
</template>
|
||
</div>
|
||
<!-- 授权已过期:离线超 7 天须联网刷新票据后才能继续使用 -->
|
||
<div v-if="store.current && store.authExpired" class="auth-bar">
|
||
<span class="ae-txt">授权已过期(最长离线 7 天),需联网刷新授权后才能继续使用</span>
|
||
<el-button size="small" type="primary" round :loading="syncingPlugins" @click="onPluginSync">立即刷新</el-button>
|
||
</div>
|
||
|
||
<!-- 登录态:顶栏下方挂登录页(顶栏常驻保证 frameless 窗控可用) -->
|
||
<div v-if="!store.current" class="login-wrap">
|
||
<LoginPage :app-name="store.appName" @ok="onLogin" />
|
||
</div>
|
||
|
||
<template v-else>
|
||
<div class="body">
|
||
<!-- 左轨:导航 + 场景库 + 账号 -->
|
||
<aside class="side">
|
||
<nav class="nav">
|
||
<div class="nav-item" :class="{ active: store.view === 'overview' }" @click="openOverview">
|
||
<el-icon><HomeFilled /></el-icon><span>总览</span>
|
||
</div>
|
||
<div class="nav-item" :class="{ active: store.view === 'scenes' }" @click="openScenes">
|
||
<el-icon><Grid /></el-icon><span>场景库</span>
|
||
<span class="nav-badge">{{ store.plugins.length }}</span>
|
||
</div>
|
||
<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>
|
||
</div>
|
||
</nav>
|
||
<div class="hr"></div>
|
||
|
||
<!-- 场景:左栏只放最近使用的 5 个(高频入口),完整清单/搜索/分类在「场景库」页 -->
|
||
<div class="scene-head">
|
||
<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 }"
|
||
:disabled="store.running || syncingPlugins" @click="onPluginSync">
|
||
<el-icon><Refresh /></el-icon>
|
||
</button>
|
||
</el-tooltip>
|
||
</div>
|
||
<div class="scene-list">
|
||
<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)"
|
||
:title="`${p.name} · v${p.version}${p.channel === 'test' ? ' · 测试版' : ''}`">
|
||
<span class="sr-dot" :style="{ background: sceneDotColor(pluginIndex(p)) }"></span>
|
||
<span class="sr-name">{{ p.name }}</span>
|
||
<em v-if="p.channel === 'test'" class="sr-test">测试版</em>
|
||
<em>v{{ p.version }}</em>
|
||
</div>
|
||
<div v-if="!store.plugins.length" class="scene-empty">当前账号暂无可用场景<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">
|
||
<el-avatar :size="26" class="avatar" :src="accountAvatar()" :key="accountAvatar()" @error="onAvatarError">
|
||
<span class="avatar-fb">{{ (store.nickname || store.current).slice(0, 1).toUpperCase() }}</span>
|
||
</el-avatar>
|
||
<div class="who">
|
||
<b>{{ store.nickname || store.current }}</b>
|
||
</div>
|
||
<el-tooltip content="修改密码" placement="top">
|
||
<button class="acct-btn" @click="pwdDlg = true"><el-icon><Key /></el-icon></button>
|
||
</el-tooltip>
|
||
<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>
|
||
|
||
<!-- 中栏:上下文区(视图路由),与左右轨同级的浅底面板,形成完整 3 栏 -->
|
||
<main class="main">
|
||
<div class="page-scroll">
|
||
<HomePage v-if="store.view === 'overview'" />
|
||
<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>
|
||
<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-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>
|
||
<div class="idle-top"><i class="okdot"></i><b>当前空闲</b></div>
|
||
<div class="idle-sub">{{ lastRunText }}</div>
|
||
</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.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' : (r.cancelled ? 'mid' : 'bad')"></i>
|
||
<span class="nm">{{ r.name }}</span>
|
||
<span class="tm">{{ r.time }}</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="rail-flex"></div>
|
||
</aside>
|
||
</div>
|
||
|
||
<!-- 状态栏:只放"机器事实";客户端/环境包/SDK/Chrome 收敛成一个「本机组件」入口 -->
|
||
<footer class="statusbar">
|
||
<span class="sb-item" :class="licenseCls"><i class="sb-dot"></i>{{ licenseText }}</span>
|
||
<span class="sb-item click" :class="compCls" :title="compTip" @click="compPanel = true">
|
||
<i v-if="compBusy" class="sb-spin"></i>
|
||
<i v-else class="sb-dot"></i>{{ compLabel }}
|
||
</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-upd click" :title="compTip" @click="compPanel = true">
|
||
客户端 {{ shellUpdate.current ? 'v' + shellUpdate.current : '未打包' }}
|
||
</span>
|
||
</footer>
|
||
</template>
|
||
</div>
|
||
<ChangePasswordDialog v-if="pwdDlg" @close="pwdDlg = false" />
|
||
<!-- 本机组件:客户端 / 运行环境 / 场景插件 / SDK / 浏览器 一处看全(状态栏唯一更新入口) -->
|
||
<el-dialog v-model="compPanel" title="本机组件" width="740px" align-center>
|
||
<div class="cmp-top">
|
||
<span class="cmp-note">
|
||
客户端、运行环境、插件与 SDK 每 30 分钟自动检查一次(设备空闲时),无需重启软件。
|
||
</span>
|
||
<el-button size="small" :icon="Refresh" :loading="compChecking" @click="onCheckAll">全部检查</el-button>
|
||
</div>
|
||
|
||
<div class="cmp-list">
|
||
<!-- 客户端(执行机外壳) -->
|
||
<div class="cmp-row">
|
||
<div class="cmp-ico">壳</div>
|
||
<div class="cmp-main">
|
||
<div class="cmp-name">
|
||
客户端 · 执行机外壳
|
||
<span class="cmp-tag" :class="shellTagCls">{{ shellTagText }}</span>
|
||
</div>
|
||
<div class="cmp-desc">
|
||
当前 {{ shellUpdate.current ? 'v' + shellUpdate.current : '未打包' }}
|
||
<template v-if="shellUpdate.latest || shellUpdate.new">
|
||
· 云端 v{{ shellUpdate.latest || shellUpdate.new }}
|
||
</template>
|
||
<template v-if="shellUpdate.notes"> · {{ shellUpdate.notes }}</template>
|
||
</div>
|
||
</div>
|
||
<div class="cmp-ops">
|
||
<el-button size="small" :loading="shellChecking" @click="onShellCheck()">检查</el-button>
|
||
<el-button v-if="shellUpdate.downloaded" size="small" type="primary" :loading="updating" @click="doShellUpdate">
|
||
重启更新
|
||
</el-button>
|
||
<el-button v-else-if="shellUpdate.available" size="small" type="primary" :loading="downloading" @click="onShellDownload">
|
||
下载更新
|
||
</el-button>
|
||
</div>
|
||
</div>
|
||
|
||
<!-- 运行环境(便携 Python) -->
|
||
<div class="cmp-row">
|
||
<div class="cmp-ico">环</div>
|
||
<div class="cmp-main">
|
||
<div class="cmp-name">
|
||
运行环境 · 便携 Python
|
||
<span class="cmp-tag" :class="envTagCls">{{ envTagText }}</span>
|
||
</div>
|
||
<div class="cmp-desc">
|
||
{{ envInstalled ? '当前 v' + envVersion : '未安装' }}
|
||
<template v-if="envCloud"> · 云端 v{{ envCloud }}</template>
|
||
<template v-if="envBusyState">
|
||
· {{ envDl.status === 'extracting' ? '正在解压安装…' : '下载中 ' + (envDl.pct || 0) + '%' }}
|
||
</template>
|
||
</div>
|
||
</div>
|
||
<div class="cmp-ops">
|
||
<el-button size="small" :loading="envChecking" @click="onEnvCheck()">检查</el-button>
|
||
<el-button v-if="envHasUpdate || (!envInstalled && env.cloud_available)" size="small" type="primary"
|
||
:loading="envBusy" @click="onEnvClick">立即更新</el-button>
|
||
</div>
|
||
</div>
|
||
|
||
<!-- 场景插件(含 SDK 运行库):插件安装前必须先有 SDK,两者本就是一次动作,合并成一行避免「两个按钮干同一件事」 -->
|
||
<div class="cmp-row">
|
||
<div class="cmp-ico">件</div>
|
||
<div class="cmp-main">
|
||
<div class="cmp-name">
|
||
场景插件 · 含 SDK 运行库
|
||
<span class="cmp-tag" :class="pluginUpdateCount ? 'warn' : 'ok'">
|
||
{{ pluginUpdateCount ? pluginUpdateCount + ' 个可更新' : '已是最新' }}
|
||
</span>
|
||
<span v-if="sdkExpired" class="cmp-tag warn">SDK 授权缓存过期</span>
|
||
</div>
|
||
<div class="cmp-desc">
|
||
本账号可用 {{ (store.plugins || []).length }} 个场景 · SDK 已装 {{ sdkList.length }} 个{{ sdkLastSyncText ? '(上次同步 ' + sdkLastSyncText + ')' : '' }}
|
||
· 同步会一并补齐插件依赖的 SDK,无需重启
|
||
</div>
|
||
</div>
|
||
<div class="cmp-ops">
|
||
<el-button size="small" @click="sdkPanel = true">SDK 详情</el-button>
|
||
<el-button size="small" type="primary" plain :loading="syncingPlugins" :disabled="store.running"
|
||
@click="onPluginSync">同步</el-button>
|
||
</div>
|
||
</div>
|
||
|
||
<!-- 浏览器 -->
|
||
<div class="cmp-row">
|
||
<div class="cmp-ico">览</div>
|
||
<div class="cmp-main">
|
||
<div class="cmp-name">
|
||
浏览器 · Chrome
|
||
<span class="cmp-tag" :class="chromeInstalled ? 'ok' : 'warn'">
|
||
{{ chromeInstalled ? '已安装' : '未安装' }}
|
||
</span>
|
||
</div>
|
||
<div class="cmp-desc">
|
||
<template v-if="chromeInstalled">v{{ chrome.version || '—' }} · 插件运行依赖</template>
|
||
<template v-else>{{ chrome.cloud_available ? '点右侧「安装」下载并安装' : '中心机暂未登记安装包' }}</template>
|
||
</div>
|
||
</div>
|
||
<div class="cmp-ops">
|
||
<el-button size="small" :loading="chromeBusy" @click="onChromeClick">
|
||
{{ chromeInstalled ? '重新检测' : '安装' }}
|
||
</el-button>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
<template #footer>
|
||
<span class="cmp-foot">设备正在执行任务时会自动顺延,不会打断运行</span>
|
||
<el-button size="small" @click="compPanel = false">关闭</el-button>
|
||
</template>
|
||
</el-dialog>
|
||
<!-- SDK 状态面板:本机组件面板「详情」打开,看已装版本 / 上次同步 / 离线授权缓存 -->
|
||
<SdkPanel v-if="sdkPanel" @close="sdkPanel = false" />
|
||
<!-- 壳子更新下载进度弹窗:点击「立即下载」后弹出,可最小化到后台继续下载 -->
|
||
<DownloadDialog v-model="updDlg" :title="`下载更新 v${updDl.version || ''}`" :dl="updDl" :body-text="shellDlText">
|
||
<template #footer>
|
||
<el-button v-if="updDl.status === 'failed'" size="small" type="primary" round
|
||
:loading="downloading" @click="onShellDownload">重试</el-button>
|
||
<el-button size="small" round @click="updDlg = false">后台下载</el-button>
|
||
</template>
|
||
</DownloadDialog>
|
||
<!-- 浏览器(Chrome)下载/安装进度弹窗:点击「装浏览器/立即安装」后弹出,进度经轮询展示 -->
|
||
<DownloadDialog v-model="chromeDlg" :title="chromeDlgTitle" :dl="chromeDl" :body-text="chromeDlText">
|
||
<template #footer>
|
||
<el-button v-if="chromeDl.status === 'failed'" size="small" type="primary" round
|
||
:loading="chromeBusy" @click="onChromeClick">重试下载</el-button>
|
||
<el-button v-else-if="chrome.downloaded && !chrome.installing" size="small" type="primary" round
|
||
:loading="chromeBusy" @click="onChromeClick">立即安装</el-button>
|
||
<el-button size="small" round @click="chromeDlg = false">
|
||
{{ chromeDl.status === 'downloading' ? '后台下载' : (chrome.installing ? '后台安装' : '关闭') }}
|
||
</el-button>
|
||
</template>
|
||
</DownloadDialog>
|
||
<!-- 环境包(便携 Python 运行时)更新进度弹窗:点击状态栏环境项后弹出,进度经轮询展示 -->
|
||
<DownloadDialog v-model="envDlg" title="环境包更新" :dl="envDl" :body-text="envDlText" fail-label="更新失败">
|
||
<template #footer>
|
||
<el-button v-if="envDl.status === 'failed'" size="small" type="primary" round
|
||
:loading="envBusy" @click="onEnvClick">重试</el-button>
|
||
<el-button v-else-if="!envBusyState && (envHasUpdate || (!envInstalled && env.cloud_available))"
|
||
size="small" type="primary" round :loading="envBusy" @click="onEnvClick">立即更新</el-button>
|
||
<el-button v-else-if="!envBusyState" size="small" round :loading="envChecking" @click="onEnvCheck">
|
||
检查更新
|
||
</el-button>
|
||
<el-button size="small" round @click="envDlg = false">关闭</el-button>
|
||
</template>
|
||
</DownloadDialog>
|
||
<!-- 重启更新遮罩:本进程即将退出,随后由独立「升级等待窗口」接管提示 -->
|
||
<div v-if="updating" class="upd-mask">
|
||
<div class="upd-card">
|
||
<span class="upd-ring"></span>
|
||
<div class="upd-title">正在重启并安装新版本{{ shellUpdate.new ? ' v' + shellUpdate.new : '' }}</div>
|
||
<div class="upd-sub">安装期间会显示升级窗口,完成后自动重新打开客户端,请稍候…</div>
|
||
</div>
|
||
</div>
|
||
</template>
|
||
|
||
<script setup>
|
||
import { computed, onMounted, onUnmounted, ref, watch } from 'vue'
|
||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||
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 SdkPanel from './components/SdkPanel.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 } 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, resetQueue } from './store'
|
||
import { fetchMeta, getBootStatus, adminLogout, adminMe, adminPassword, syncPlugins, getShellStatus, applyShellUpdate, downloadShellUpdate, getChromeStatus, checkChrome, downloadChrome, installChrome, getEnvStatus, syncEnv, checkEnv } from './api'
|
||
|
||
// ===== 左侧场景:只保留最近使用(高频入口),全量清单交给「场景库」页 =====
|
||
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() {
|
||
clearAvatarCache()
|
||
}
|
||
|
||
// ===== 视图路由(总览 / 场景库 / 运行台 / 计划 / 平台账号)=====
|
||
function openRun(id, runId) {
|
||
store.selectedId = id
|
||
store.view = 'run'
|
||
// 活动流「最近运行」点击:直达该次运行的回看(运行台消费后清空);
|
||
// 左栏场景点击不带 runId,顺带清掉可能残留的回看意图
|
||
store.pendingReplay = runId ? { pluginId: id, runId } : null
|
||
}
|
||
|
||
function openOverview() {
|
||
store.view = 'overview'
|
||
}
|
||
|
||
function openScenes() {
|
||
store.view = 'scenes'
|
||
}
|
||
|
||
function openPlans() {
|
||
store.view = 'plans'
|
||
}
|
||
|
||
function openFlows() {
|
||
store.view = 'flows'
|
||
}
|
||
|
||
function openPlatform() {
|
||
store.view = 'platform'
|
||
}
|
||
|
||
// 面包屑当前视图名(登录前显示「登录」)
|
||
const VIEW_NAMES = { overview: '总览', scenes: '场景库', run: '运行台', plans: '计划', flows: '流程编排', platform: '平台账号' }
|
||
const viewName = computed(() => !store.current ? '登录' : (VIEW_NAMES[store.view] || '总览'))
|
||
|
||
// 平台账号在线数(meta.platforms[].online 由 PlatformAccounts.refresh() 回写)
|
||
const onlineCount = computed(() => store.platforms.filter((p) => p.online).length)
|
||
|
||
// ===== 自定义顶栏:frameless 窗口控制(preload 注入 dshShell.winControl)=====
|
||
const isMax = ref(false)
|
||
let unbindMax = null
|
||
function winMin() { window.dshShell?.winControl?.minimize?.() }
|
||
function winMax() { window.dshShell?.winControl?.toggleMaximize?.() }
|
||
function winClose() { window.dshShell?.winControl?.close?.() }
|
||
|
||
// ===== 右栏活动流 + 状态栏:由现有 store 派生,不引入新请求 =====
|
||
// 当前运行中的场景名(run_start 已把 run_id→plugin_id 登记在 store._runPlugins)
|
||
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(-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 '本次会话暂无运行记录'
|
||
return `上次 ${r.name} · ${r.time}`
|
||
})
|
||
// 授权票据概要(状态栏):后端 /api/meta 的 license 字段
|
||
const licenseText = computed(() => {
|
||
const l = store.license
|
||
if (!l || !l.status || l.status === 'missing') return '未授权'
|
||
if (l.status === 'invalid') return '授权无效'
|
||
if (l.status === 'expired') return '授权已过期'
|
||
if (l.days_left === null || l.days_left === undefined) return '授权有效'
|
||
return `授权有效 · 剩余 ${l.days_left} 天`
|
||
})
|
||
const licenseCls = computed(() => {
|
||
const s = store.license && store.license.status
|
||
if (s === 'ok') return 'ok'
|
||
if (s === 'expired' || s === 'invalid') return 'err'
|
||
return 'warn'
|
||
})
|
||
|
||
// 本地服务 WebSocket(断线按 1/2/4/8/16s 指数退避重连;插件同步完成刷新清单)
|
||
const { openWS } = useSocket({ onPluginsSynced: refreshMeta })
|
||
|
||
onMounted(async () => {
|
||
// 顶栏窗控:订阅主进程最大化状态推送(开发态无注入 API 时静默)
|
||
try { unbindMax = window.dshShell?.winControl?.onMaximized?.((v) => { isMax.value = !!v }) } catch (_) {}
|
||
refreshBootStatus() // 启动页实时展示"当前在干嘛"
|
||
window.addEventListener('focus', onWindowFocus)
|
||
// fetchMeta/checkSession 全部带超时:后端/中心机慢或不可达时也必须在几十秒内进入界面,
|
||
// 不能无限等(否则就是"启动后毫无反馈的未响应")
|
||
const meta = await withTimeout(fetchMeta(), 8000) || {}
|
||
store.appName = meta.appName || store.appName
|
||
store.platforms = meta.platforms || []
|
||
store.plugins = meta.plugins || []
|
||
store.authExpired = !!meta.authExpired
|
||
store.license = meta.license || null
|
||
store.sdks = meta.sdks || []
|
||
store.sdkAllow = meta.sdk_allow || null
|
||
store.sdkLastSync = meta.sdk_last_sync || null
|
||
store.selectedId = store.plugins[0]?.id || ''
|
||
clearLogs()
|
||
openWS()
|
||
await withTimeout(checkSession(), 30000)
|
||
// 首屏前预加载:头像/壳子/Chrome/环境包状态全部拉一遍再进入,
|
||
// 保证状态栏信息一进来就是完整的(单次调用带超时兜底,避免后端异常卡在启动页)
|
||
await Promise.all([loadAvatar(), shellJob.load(), chromeJob.load(), envJob.load()]
|
||
.map((p) => Promise.race([Promise.resolve(p), new Promise((r) => setTimeout(r, 6000))])))
|
||
booting.value = false // 会话判定 + 首屏状态均就绪后再渲染
|
||
})
|
||
|
||
onUnmounted(() => {
|
||
try { unbindMax && unbindMax() } catch (_) {}
|
||
window.removeEventListener('focus', onWindowFocus)
|
||
})
|
||
|
||
// ===== 浏览器(Chrome)检测/下载/安装 =====
|
||
const chromeJob = useDownloadJob({
|
||
fetchStatus: getChromeStatus,
|
||
// 未安装或操作中才轮询;已安装无需常驻
|
||
shouldPoll: (s) => !s.installed || s.installing || s.dl?.status === 'downloading',
|
||
isDownloading: (s) => s.dl?.status === 'downloading',
|
||
isCompleted: (s) => !!s.downloaded || !!s.installed,
|
||
onCompleted: () => ElMessage.success('Chrome 安装包已下载完成,点击「立即安装」'),
|
||
onFailed: (s) => ElMessage.warning('Chrome 安装包下载失败:' + (s.dl?.error || '')),
|
||
onTick: (s, prev) => {
|
||
// 安装器完成:由"安装中 → 已安装"跃迁触发一次提示并收窗
|
||
if (prev.installing && !s.installing && s.installed) {
|
||
chromeJob.dialog.value = false
|
||
ElMessage.success(`Chrome ${s.version} 安装完成,可正常使用`)
|
||
log('INFO', `Chrome 安装完成:${s.version}`)
|
||
}
|
||
},
|
||
})
|
||
const chrome = chromeJob.state
|
||
const chromeBusy = chromeJob.busy
|
||
const chromeDlg = chromeJob.dialog
|
||
const chromeDl = computed(() => chrome.value.dl || {})
|
||
|
||
const chromeDlText = computed(() => {
|
||
const c = chrome.value
|
||
if (c.installing) return '已弹出 Chrome 安装器窗口,请在弹出的窗口中点击完成安装(如未弹出请查看任务栏)…'
|
||
if (c.downloaded) return `Chrome 安装包已下载完成(${fmtBytes(c.dl?.received)}),点击「立即安装」。`
|
||
return '正在准备下载 Chrome 安装包…'
|
||
})
|
||
|
||
const chromeInstalled = computed(() => !!chrome.value.installed)
|
||
|
||
// ===== SDK 状态(下发到本机的纯 Python 运行库,插件按 requires.sdks 挂载)=====
|
||
const sdkPanel = ref(false)
|
||
const sdkList = computed(() => store.sdks || [])
|
||
const sdkExpired = computed(() => !!(store.sdkAllow && store.sdkAllow.expired))
|
||
|
||
const chromeDlgTitle = computed(() => {
|
||
const c = chrome.value
|
||
if (c.installing) return '安装 Chrome'
|
||
if (c.dl?.status === 'downloading') return '下载 Chrome 安装包'
|
||
if (c.dl?.status === 'failed') return 'Chrome 下载失败'
|
||
if (c.downloaded) return 'Chrome 安装包已就绪'
|
||
return '安装 Chrome'
|
||
})
|
||
|
||
async function onChromeClick() {
|
||
if (chromeBusy.value) return
|
||
const c = chrome.value
|
||
// 安装中:仅展示进度弹窗
|
||
if (c.installing) { chromeDlg.value = true; return }
|
||
// 已安装:优先重新检测(不再重复安装)
|
||
if (c.installed) {
|
||
chromeBusy.value = true
|
||
try { await checkChrome(); await chromeJob.load() }
|
||
catch (e) { ElMessage.error('检测失败:' + (e.message || e)) }
|
||
chromeBusy.value = false
|
||
return
|
||
}
|
||
// 已下载:直接安装
|
||
if (c.downloaded) {
|
||
chromeBusy.value = true
|
||
chromeDlg.value = true
|
||
try {
|
||
await installChrome()
|
||
chromeJob.patch({ installing: true })
|
||
chromeJob.start()
|
||
} catch (e) {
|
||
chromeDlg.value = false
|
||
ElMessage.error('安装失败:' + (e.message || e))
|
||
}
|
||
chromeBusy.value = false
|
||
return
|
||
}
|
||
// 未装且中心机有登记:下载(点击即进入"下载中",不等轮询)
|
||
if (c.cloud_available) {
|
||
try { await chromeJob.beginDownload({ start: downloadChrome }); chromeJob.start() }
|
||
catch (e) { ElMessage.error('开始下载失败:' + (e.message || e)) }
|
||
return
|
||
}
|
||
// 其余:重新检测
|
||
chromeBusy.value = true
|
||
try { await checkChrome(); await chromeJob.load() }
|
||
catch (e) { ElMessage.error('检测失败:' + (e.message || e)) }
|
||
chromeBusy.value = false
|
||
}
|
||
|
||
// ===== 环境包(便携 Python 运行时)检测/更新 =====
|
||
const envJob = useDownloadJob({
|
||
fetchStatus: getEnvStatus,
|
||
shouldPoll: (s) => !s.installed || s.dl?.status === 'downloading' || s.dl?.status === 'extracting',
|
||
isDownloading: (s) => s.dl?.status === 'downloading' || s.dl?.status === 'extracting',
|
||
isCompleted: (s) => !!s.installed,
|
||
onCompleted: (s) => {
|
||
if (!s.installed) return
|
||
envJob.dialog.value = false
|
||
ElMessage.success(`环境包已更新到 v${s.version}`)
|
||
log('INFO', `环境包更新完成 v${s.version}`)
|
||
},
|
||
onFailed: (s) => ElMessage.warning('环境包更新失败:' + (s.dl?.error || '')),
|
||
})
|
||
const env = envJob.state
|
||
const envBusy = envJob.busy
|
||
const envDlg = envJob.dialog
|
||
const envDl = computed(() => env.value.dl || {})
|
||
|
||
const envInstalled = computed(() => !!env.value.installed)
|
||
const envVersion = computed(() => env.value.version || '')
|
||
const envCloud = computed(() => env.value.cloud_version || '')
|
||
const envHasUpdate = computed(() =>
|
||
envInstalled.value && envCloud.value && versionLt(envVersion.value, envCloud.value))
|
||
// 安装进行中(下载/解压):状态栏/面板显示转圈,弹窗展示进度
|
||
const envBusyState = computed(() =>
|
||
env.value.dl?.status === 'downloading' || env.value.dl?.status === 'extracting')
|
||
const envDlText = computed(() => {
|
||
if (envInstalled.value) {
|
||
return `当前环境 v${envVersion.value}${envHasUpdate.value ? `,云端 v${envCloud.value},点击下方按钮更新` : ',已是最新版本'}`
|
||
}
|
||
return '环境包未安装,点击下方按钮安装'
|
||
})
|
||
|
||
async function onEnvClick() {
|
||
if (envBusy.value) return
|
||
const e = env.value
|
||
// 下载中/解压中:展示进度弹窗
|
||
if (envBusyState.value) { envDlg.value = true; return }
|
||
// 有更新 或 未安装且云端有包:触发更新(后台下载+切换),弹窗展示进度
|
||
if (envHasUpdate.value || (!e.installed && e.cloud_available)) {
|
||
try {
|
||
await envJob.beginDownload({
|
||
start: syncEnv, // 后端后台执行,立即返回
|
||
afterStart: async () => {
|
||
envJob.settle() // 先清点击时的兜底标记,按真实状态重新判定
|
||
await envJob.load() // 抢拉真实进度,避免停在"准备中"
|
||
if (!envBusyState.value) {
|
||
// 未真正开始(如已有同步在跑):关弹窗提示
|
||
envDlg.value = false
|
||
ElMessage.info(env.value.installed ? '环境包已是最新,无需更新' : '环境包暂不可用,请稍后重试')
|
||
}
|
||
},
|
||
})
|
||
} catch (err) {
|
||
envDlg.value = false
|
||
ElMessage.error('开始更新失败:' + (err.message || err))
|
||
}
|
||
return
|
||
}
|
||
// 已安装且(本地看)最新:打开弹窗并真的向中心机重新检查一次
|
||
// (状态栏文案承诺"点击重新检查",不能只读本地缓存)
|
||
envDlg.value = true
|
||
await onEnvCheck()
|
||
}
|
||
|
||
// 「检查更新」:只向中心机拉一次云端版本(有新版自动下载切换),不强制重装
|
||
// quiet = true 时用于「全部检查」,不逐项弹消息(结果看面板里的状态)
|
||
const envChecking = ref(false)
|
||
async function onEnvCheck(quiet = false) {
|
||
if (envChecking.value || envBusyState.value) return
|
||
envChecking.value = true
|
||
try {
|
||
await checkEnv()
|
||
// 后端 checkAndSync 先拉云端信息再决定下不下载,给它一点时间后刷新状态
|
||
await new Promise((r) => setTimeout(r, 1200))
|
||
await envJob.load()
|
||
if (quiet) return
|
||
if (envBusyState.value) {
|
||
ElMessage.info(`发现新版本 v${envCloud.value},正在下载更新…`)
|
||
} else if (envHasUpdate.value) {
|
||
ElMessage.info(`发现新版本 v${envCloud.value},点「立即更新」升级`)
|
||
} else if (envInstalled.value) {
|
||
ElMessage.success(`环境包 v${envVersion.value} 已是最新`)
|
||
} else if (env.value.cloud_available) {
|
||
ElMessage.warning('环境包未安装,点「立即更新」安装')
|
||
} else {
|
||
ElMessage.warning('中心机暂未登记环境包')
|
||
}
|
||
} catch (e) {
|
||
if (!quiet) ElMessage.error('检查更新失败:' + (e.message || e))
|
||
} finally {
|
||
envChecking.value = false
|
||
}
|
||
}
|
||
|
||
const pwdDlg = ref(false)
|
||
const booting = ref(true) // 鉴权判定中:未确定会话前先显示加载骨架,避免「闪一下登录页再进首页」
|
||
const syncing = ref(false) // 首次启动/启动时:按账号权限自下载/更新插件(等待下载界面)
|
||
|
||
// 启动页"当前在干嘛":后端轮询 /api/boot/status 展示初始化步骤;
|
||
// 进入 checkSession 后由前端各阶段接管文案(bootPhaseOwned=true 时后端轮询不再覆盖)
|
||
const bootStep = ref('正在启动…')
|
||
let bootPollTimer = null
|
||
let bootPhaseOwned = false
|
||
async function refreshBootStatus() {
|
||
if (!bootPhaseOwned) {
|
||
try {
|
||
const b = await getBootStatus()
|
||
// await 期间 checkSession 可能已接管文案(bootPhaseOwned 置真),迟到响应不得回写覆盖
|
||
if (!bootPhaseOwned) {
|
||
bootStep.value = b.done
|
||
? (syncing.value ? '正在同步插件,请稍候…' : (store.appName || '自动化工作台'))
|
||
: `正在初始化:${b.step || '…'}`
|
||
}
|
||
} catch (_) { /* 后端未就绪:保持当前文案,继续轮询 */ }
|
||
}
|
||
if (booting.value) bootPollTimer = setTimeout(refreshBootStatus, 1200)
|
||
}
|
||
|
||
// ===== 壳子自动更新:检查 → 用户确认下载(带进度)→ 重启更新 =====
|
||
const shellJob = useDownloadJob({
|
||
fetchStatus: getShellStatus,
|
||
enabled: () => !!store.current, // 状态接口需登录;未登录/登出后暂停,避免持续打 401
|
||
pollMs: 15000,
|
||
downloadingPollMs: 400, // 下载中加快轮询,进度条更连续
|
||
isDownloading: (s) => s.dl?.status === 'downloading',
|
||
isCompleted: (s) => !!s.downloaded,
|
||
onCompleted: (s) => {
|
||
// 内网直链下载很快(80MB 秒下),延迟收窗让人看清 100% 完成态,再转顶部「重启更新」条
|
||
setTimeout(() => { shellJob.dialog.value = false }, 1500)
|
||
ElMessage.success(`新版本 v${s.new} 已下载完成,点击顶部「重启更新」完成升级`)
|
||
log('INFO', `客户端新版本 v${s.new} 已就绪,可重启更新`)
|
||
},
|
||
onFailed: (s) => ElMessage.warning('新版本下载失败:' + (s.dl?.error || '')),
|
||
})
|
||
const shellUpdate = shellJob.state
|
||
const updating = ref(false)
|
||
const downloading = shellJob.busy
|
||
const shellDismissed = ref(false) // 用户点了"暂不",本会话内隐藏"立即下载"提示
|
||
// 手动「检查更新」:秒级比对 + 轮询检查结果(见 composables/useShellCheck)
|
||
const { checking: shellChecking, check: onShellCheck } = useShellCheck(shellUpdate, handleCheckResult)
|
||
|
||
const updDl = computed(() => shellUpdate.value.dl || {})
|
||
const updDlg = shellJob.dialog // 下载进度弹窗(点击「立即下载」后弹出)
|
||
const shellDlText = computed(() => (shellUpdate.value.downloaded ? '已下载完成' : '正在准备下载…'))
|
||
const updBarVisible = computed(() =>
|
||
shellUpdate.value.downloaded ||
|
||
(updDl.value.status === 'failed' && !updDlg.value) ||
|
||
(shellUpdate.value.available && !shellDismissed.value)
|
||
)
|
||
|
||
async function doShellUpdate() {
|
||
updating.value = true
|
||
try {
|
||
await applyShellUpdate() // 后端运行静默安装并退出进程,升级后自动重启
|
||
} catch (e) {
|
||
updating.value = false
|
||
ElMessage.error('更新失败:' + (e.message || e))
|
||
}
|
||
}
|
||
|
||
async function onShellDownload() {
|
||
if (downloading.value) return
|
||
shellDismissed.value = false
|
||
const v = shellUpdate.value.latest || shellUpdate.value.new || ''
|
||
try {
|
||
// 点击即进入下载中(不等轮询),后端后台流式下载,进度经轮询展示
|
||
await shellJob.beginDownload({ version: v, start: downloadShellUpdate })
|
||
shellJob.start()
|
||
} catch (e) {
|
||
ElMessage.error('开始下载失败:' + (e.message || e))
|
||
}
|
||
}
|
||
|
||
function handleCheckResult(s, opts = {}) {
|
||
// 批量检查(「全部检查」):结果直接呈现在本机组件面板里,不弹确认框打断
|
||
if (opts.silent) return
|
||
if (!s.current) {
|
||
ElMessage.info('当前为源码开发模式,不参与客户端自更新')
|
||
return
|
||
}
|
||
if (s.downloaded) {
|
||
ElMessage.info(`新版本 v${s.new} 已就绪,点击顶部「重启更新」完成升级`)
|
||
return
|
||
}
|
||
if (updDl.value.status === 'downloading') return // 正在下载,进度条展示中
|
||
if (s.error) {
|
||
ElMessage.warning('检查更新失败:' + s.error)
|
||
log('WARN', `检查客户端更新失败:${s.error}`)
|
||
return
|
||
}
|
||
if (s.available) {
|
||
ElMessageBox.confirm(
|
||
`发现新版本 v${s.latest},是否立即下载?${s.notes ? '\n\n更新说明:' + s.notes : ''}`,
|
||
'发现新版本',
|
||
{ confirmButtonText: '立即下载', cancelButtonText: '稍后再说', type: 'info' }
|
||
).then(() => onShellDownload()).catch(() => {})
|
||
} else {
|
||
ElMessage.info(`已是最新版本 v${s.current}`)
|
||
}
|
||
}
|
||
|
||
// ===== 插件同步:逻辑收敛在 usePluginSync(左栏图标 / 场景库页按钮 / 登录后自动同步共用) =====
|
||
const { syncing: syncingPlugins, syncNow, refreshMeta: refreshMetaBase } = usePluginSync()
|
||
|
||
async function onPluginSync() {
|
||
await syncNow()
|
||
}
|
||
|
||
// ===== 本机组件:客户端 / 运行环境 / 场景插件 / SDK / 浏览器 的统一更新入口 =====
|
||
// 状态栏只留这一个入口,避免「环境要在这里点、SDK 在那里点、壳子再另一个地方」的分散认知。
|
||
const compPanel = ref(false)
|
||
const compChecking = ref(false)
|
||
|
||
/** 当前账号可见插件里,云端有更新的个数(meta 已下发 update_available) */
|
||
const pluginUpdateCount = computed(() => (store.plugins || []).filter((p) => p.update_available).length)
|
||
|
||
/** 有下载/安装/同步在进行 → 状态栏转圈 */
|
||
const compBusy = computed(
|
||
() =>
|
||
updDl.value.status === 'downloading' ||
|
||
envBusyState.value ||
|
||
!!chrome.value.installing ||
|
||
chromeDl.value.status === 'downloading' ||
|
||
syncingPlugins.value
|
||
)
|
||
|
||
/** 待更新项数(客户端 / 环境 / 插件 / 浏览器 各算一项) */
|
||
const compPending = computed(() => {
|
||
let n = 0
|
||
if (shellUpdate.value.available || shellUpdate.value.downloaded) n += 1
|
||
if (envHasUpdate.value || (!envInstalled.value && env.value.cloud_available)) n += 1
|
||
if (pluginUpdateCount.value) n += 1
|
||
if (!chromeInstalled.value && chrome.value.cloud_available) n += 1
|
||
return n
|
||
})
|
||
|
||
const compLabel = computed(() => {
|
||
if (compBusy.value) return '本机组件 · 更新中'
|
||
if (compPending.value) return `本机组件 · ${compPending.value} 项待更新`
|
||
return '本机组件'
|
||
})
|
||
const compCls = computed(() =>
|
||
compPending.value || sdkExpired.value || store.authExpired ? 'warn' : 'ok'
|
||
)
|
||
const compTip = computed(
|
||
() =>
|
||
[
|
||
`客户端 ${shellUpdate.value.current ? 'v' + shellUpdate.value.current : '未打包'}`,
|
||
`环境 ${envInstalled.value ? 'v' + envVersion.value : env.value.cloud_available ? '待安装' : '未登记'}`,
|
||
`插件 ${(store.plugins || []).length} 个${pluginUpdateCount.value ? `(${pluginUpdateCount.value} 个可更新)` : ''}`,
|
||
`SDK ${sdkList.value.length} 个`,
|
||
chromeInstalled.value ? `Chrome ${chrome.value.version || '已装'}` : 'Chrome 未安装'
|
||
].join(' · ') + ';点击查看 / 手动检查更新'
|
||
)
|
||
|
||
// ---- 面板内每行的状态标签 ----
|
||
const shellTagText = computed(() => {
|
||
const s = shellUpdate.value
|
||
if (s.downloaded) return '待重启生效'
|
||
if (s.available) return '有新版本'
|
||
if (s.current) return '已是最新'
|
||
return '未打包'
|
||
})
|
||
const shellTagCls = computed(() =>
|
||
shellUpdate.value.downloaded || shellUpdate.value.available
|
||
? 'warn'
|
||
: shellUpdate.value.current
|
||
? 'ok'
|
||
: 'muted'
|
||
)
|
||
const envTagText = computed(() => {
|
||
if (envBusyState.value) return envDl.value.status === 'extracting' ? '安装中' : '下载中'
|
||
if (envHasUpdate.value) return '有新版本'
|
||
if (envInstalled.value) return '已是最新'
|
||
return env.value.cloud_available ? '待安装' : '未登记'
|
||
})
|
||
const envTagCls = computed(() =>
|
||
envBusyState.value || envHasUpdate.value || !envInstalled.value ? 'warn' : 'ok'
|
||
)
|
||
function shortTs(v) {
|
||
if (!v) return ''
|
||
const d = new Date(v)
|
||
if (Number.isNaN(d.getTime())) return String(v).replace('T', ' ').slice(0, 16)
|
||
const p = (n) => String(n).padStart(2, '0')
|
||
return `${p(d.getMonth() + 1)}-${p(d.getDate())} ${p(d.getHours())}:${p(d.getMinutes())}`
|
||
}
|
||
const sdkLastSyncText = computed(() => shortTs(store.sdkLastSync && store.sdkLastSync.at))
|
||
|
||
/** 全部检查:四类各查一次,静默(结果直接体现在面板状态里,不逐个弹框) */
|
||
async function onCheckAll() {
|
||
if (compChecking.value) return
|
||
compChecking.value = true
|
||
try {
|
||
await Promise.allSettled([
|
||
onShellCheck({ silent: true }),
|
||
onEnvCheck(true),
|
||
(async () => {
|
||
try {
|
||
await checkChrome()
|
||
await chromeJob.load()
|
||
} catch (_) {
|
||
/* 检测失败保持原状态 */
|
||
}
|
||
})(),
|
||
onPluginSync()
|
||
])
|
||
} finally {
|
||
compChecking.value = false
|
||
}
|
||
}
|
||
|
||
// 打开面板即刷新一次本机状态,避免看到上一次缓存的旧版本号
|
||
watch(compPanel, (v) => {
|
||
if (!v) return
|
||
void shellJob.load()
|
||
void chromeJob.load()
|
||
void envJob.load()
|
||
void refreshMetaBase().catch(() => {})
|
||
})
|
||
|
||
// 带超时的 Promise:超时返回 undefined;失败/超时都打日志便于启动诊断(P7)
|
||
function withTimeout(promise, ms) {
|
||
let timer
|
||
const timeout = new Promise((r) => {
|
||
timer = setTimeout(() => {
|
||
log('WARN', `启动请求超时(${ms}ms),已跳过`)
|
||
r(undefined)
|
||
}, ms)
|
||
})
|
||
const safe = Promise.resolve(promise).then(
|
||
(v) => { clearTimeout(timer); return v },
|
||
(e) => { clearTimeout(timer); log('WARN', `启动请求失败:${(e && e.message) || e}`); return undefined }
|
||
)
|
||
return Promise.race([safe, timeout])
|
||
}
|
||
|
||
async function checkSession() {
|
||
// 登录态一律以**后端会话 cookie** 为准(钉钉扫码/账号登录/后端重启后均从 admin/me 判定),
|
||
// 不再以 localStorage 的 cp_account 早退——否则全新扫码流程(未写过 cp_account)回跳后无法进入插件页。
|
||
// 各阶段由前端接管启动页文案(P2),且内层预算 8+15+5=28s 必须落在外层 30s 内(P1)
|
||
bootPhaseOwned = true
|
||
try {
|
||
bootStep.value = '正在校验登录会话…'
|
||
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
|
||
}
|
||
store.current = me.account
|
||
store.dept = me.dept || ''
|
||
store.nickname = me.nickname || ''
|
||
store.avatar = me.avatar || ''
|
||
try { localStorage.setItem('cp_account', me.account) } catch (_) {}
|
||
// 会话确认后:按账号权限自下载/更新插件。预算 15s,中心机不可达/超时则后台继续、
|
||
// 不卡启动页;手动「插件同步」按钮不受影响(onPluginSync 单独无超时等待结果)
|
||
bootStep.value = '正在同步插件,请稍候…'
|
||
syncing.value = true
|
||
try { await withTimeout(syncPlugins(), 15000) } catch (_) {}
|
||
syncing.value = false
|
||
// 会话有效:补拉插件清单(未登录时 meta 不返回插件)
|
||
bootStep.value = '正在加载插件清单…'
|
||
await withTimeout(refreshMeta(), 5000)
|
||
} catch (_) { /* 后端 down:无法校验,保持现状(可能为登录页或本地态) */ }
|
||
}
|
||
|
||
// 后台调整场景分类/授权后,切回客户端时轻量刷新元数据(60s 节流)
|
||
let lastMetaFocusTs = 0
|
||
function onWindowFocus() {
|
||
if (!store.current || document.visibilityState !== 'visible') return
|
||
const now = Date.now()
|
||
if (now - lastMetaFocusTs < 60000) return
|
||
lastMetaFocusTs = now
|
||
refreshMeta()
|
||
}
|
||
|
||
async function refreshMeta() {
|
||
try {
|
||
await refreshMetaBase()
|
||
// 场景清单更新后刷新「最近使用」置顶(基于持久化运行历史)
|
||
loadRecentScenes()
|
||
} catch (_) { /* 后端不可达:保留现有清单 */ }
|
||
}
|
||
|
||
async function onLogin(ok) {
|
||
store.current = ok.account
|
||
store.dept = ok.dept || ''
|
||
store.nickname = ok.nickname || ''
|
||
store.avatar = ok.avatar || ''
|
||
try { localStorage.setItem('cp_account', ok.account) } catch (_) {}
|
||
// 登录成功后立即按该账号权限同步插件(新装机首次登录即下载授权插件),再刷新平台/清单
|
||
await onPluginSync()
|
||
openWS()
|
||
loadAvatar()
|
||
shellJob.load() // 挂载时未登录拉不到更新状态,登录后补拉(版本显示/更新提示)
|
||
chromeJob.load() // 浏览器状态同此
|
||
// 首次登录/钉钉自动建号的默认密码:提示立即改密
|
||
if (ok.must_change_pwd) { promptChangePwd(ok.account) }
|
||
}
|
||
|
||
async function promptChangePwd(account) {
|
||
try {
|
||
// 旧密码 = 钉钉通知下发的初始密码,必须输入校验(与个人中心改密一致)
|
||
let op = ''
|
||
try {
|
||
const { value } = await ElMessageBox.prompt(
|
||
'当前账号正使用默认密码,请输入钉钉通知中的初始密码',
|
||
'首次登录 · 身份验证',
|
||
{ inputType: 'password', inputPlaceholder: '请输入初始密码',
|
||
confirmButtonText: '下一步', cancelButtonText: '稍后再说' })
|
||
op = value
|
||
} catch (_) { return /* 用户取消 */ }
|
||
const { value: np } = await ElMessageBox.prompt(
|
||
'请设置新密码(至少 6 位),避免他人误登录',
|
||
'首次登录 · 设置新密码',
|
||
{ inputType: 'password', inputPattern: /^.{6,}$/, inputErrorMessage: '密码至少 6 位',
|
||
confirmButtonText: '设置新密码', cancelButtonText: '稍后再说' })
|
||
try {
|
||
await adminPassword({ account, old_password: op, new_password: np })
|
||
ElMessage.success('密码已更新')
|
||
} catch (e) {
|
||
ElMessage.warning('改密失败:' + (e.message || e))
|
||
}
|
||
} catch (_) { /* 用户取消 */ }
|
||
}
|
||
// 执行/排队中禁止切换账号:一次运行带着账号上下文(平台 cookie、凭据、上报归属),半路换号会串号
|
||
const switchBlocked = computed(() => !!(store.running || store.queue.busy || store.queue.waiting))
|
||
|
||
async function logout() {
|
||
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>
|
||
|
||
<style scoped>
|
||
/* ---------- 启动页 ---------- */
|
||
.boot {
|
||
height: 100vh;
|
||
display: flex; flex-direction: column; align-items: center; justify-content: center;
|
||
gap: var(--space-3); background: var(--canvas);
|
||
}
|
||
.boot-logo {
|
||
width: 54px; height: 54px; border-radius: var(--r-win);
|
||
display: grid; place-items: center;
|
||
background: var(--brand); color: var(--on-primary);
|
||
font-family: var(--f-num); font-size: 20px; font-weight: 700;
|
||
box-shadow: var(--sh-brand);
|
||
animation: bootpop .4s var(--ease);
|
||
}
|
||
.boot-txt { font-size: 12px; color: var(--t3); letter-spacing: .06em; }
|
||
.boot-dots { display: flex; gap: var(--space-1); }
|
||
.boot-dots i {
|
||
width: 6px; height: 6px; border-radius: 50%; background: var(--brand);
|
||
animation: bootblink 1s infinite ease-in-out;
|
||
}
|
||
.boot-dots i:nth-child(2) { animation-delay: .15s; }
|
||
.boot-dots i:nth-child(3) { animation-delay: .3s; }
|
||
@keyframes bootpop { from { transform: scale(.7); opacity: 0; } to { transform: scale(1); opacity: 1; } }
|
||
@keyframes bootblink { 0%,80%,100% { opacity: .25; } 40% { opacity: 1; transform: translateY(-2px); } }
|
||
|
||
/* ---------- 自定义顶栏(frameless 窗控区,可拖拽) ---------- */
|
||
.topbar {
|
||
height: 52px; flex-shrink: 0;
|
||
display: flex; align-items: center; gap: var(--space-3); padding: 0 var(--space-4);
|
||
background: var(--surface); border-bottom: 1px solid var(--line);
|
||
-webkit-app-region: drag; user-select: none;
|
||
}
|
||
.brand-mark {
|
||
width: 26px; height: 26px; border-radius: var(--r-row); flex-shrink: 0;
|
||
display: grid; place-items: center;
|
||
background: var(--brand); color: var(--on-primary);
|
||
font-family: var(--f-num); font-size: 10.5px; font-weight: 700;
|
||
box-shadow: var(--sh-brand);
|
||
}
|
||
.brand-name { font-size: 13px; font-weight: 600; color: var(--t1); white-space: nowrap; }
|
||
.crumbs { display: flex; align-items: center; gap: var(--space-2); font-size: 12px; }
|
||
.crumb-sep { width: 1px; height: 12px; background: var(--line); }
|
||
.crumb-root { color: var(--t4); }
|
||
.crumb-slash { color: var(--t5); }
|
||
.crumb-cur { color: var(--t2); font-weight: 500; }
|
||
.tb-spacer { flex: 1; }
|
||
.pill-service {
|
||
display: inline-flex; align-items: center; gap: var(--space-1-5);
|
||
height: 24px; padding: 0 var(--space-2-5); border-radius: var(--r-pill);
|
||
background: var(--good-soft); color: var(--good-ink); font-size: 11px; font-weight: 500;
|
||
white-space: nowrap;
|
||
}
|
||
.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 {
|
||
width: 28px; height: 28px; padding: 0; border: none; border-radius: 8px;
|
||
background: transparent; color: var(--t3); font-family: var(--f-cn); font-size: 12px;
|
||
display: grid; place-items: center; cursor: pointer; line-height: 1;
|
||
transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
|
||
}
|
||
.wc-btn:hover { background: var(--field); color: var(--t1); }
|
||
.wc-close:hover { background: var(--danger-soft); color: var(--danger-ink); }
|
||
|
||
/* ---------- 顶部提示条(更新/授权) ---------- */
|
||
.update-bar, .auth-bar {
|
||
display: flex; align-items: center; justify-content: space-between; gap: var(--space-3);
|
||
margin: var(--space-2) var(--space-2) 0; padding: var(--space-2) var(--space-3); flex-shrink: 0;
|
||
border-radius: var(--r-sub); font-size: 12px;
|
||
}
|
||
.update-bar { background: var(--brand-soft-2); border: 1px solid var(--brand-track); color: var(--t2); }
|
||
.update-bar b { color: var(--brand-ink); font-weight: 600; }
|
||
.update-bar em, .auth-bar em { font-style: normal; color: var(--t3); margin-left: var(--space-1-5); }
|
||
.update-bar .upd-actions { display: flex; align-items: center; gap: var(--space-2); }
|
||
.auth-bar { background: var(--warn-soft); border: 1px solid var(--warn-line); color: var(--warn-ink); }
|
||
.auth-bar .ae-txt { flex: 1; }
|
||
|
||
/* ---------- 登录态挂载(抵消登录页自身 100vh,避免顶栏下方溢出) ---------- */
|
||
.login-wrap { flex: 1; min-height: 0; display: flex; flex-direction: column; overflow: hidden; }
|
||
.login-wrap :deep(.login) { min-height: 0; height: 100%; flex: 1; }
|
||
|
||
/* ---------- 三栏骨架 ---------- */
|
||
.body { flex: 1; min-height: 0; display: flex; gap: var(--space-2); padding: var(--space-2); container-type: inline-size; }
|
||
/* 中栏:上下文区。与左右轨同级的面板容器(浅底 + 细边 + 圆角),
|
||
内部卡片仍是白底,既成完整 3 栏、又不出现"卡片套卡片"的双边框 */
|
||
/* 中栏:白底面板,内部由各视图自己排布(页头 + 内容),不再在里面套第二层面板 */
|
||
.main {
|
||
flex: 1; min-width: 0; display: flex; flex-direction: column; min-height: 0;
|
||
background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-card);
|
||
padding: 0; overflow: hidden;
|
||
}
|
||
/* 中栏滚动区:视图自决定内边距 */
|
||
.page-scroll { flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; }
|
||
|
||
/* ---------- 左轨:导航 + 场景库 + 账号 ---------- */
|
||
.side {
|
||
width: 232px; flex-shrink: 0; min-height: 0;
|
||
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);
|
||
}
|
||
.nav { display: flex; flex-direction: column; gap: 2px; }
|
||
.nav-item {
|
||
height: 34px; display: flex; align-items: center; gap: var(--space-2); padding: 0 var(--space-2-5);
|
||
border-radius: var(--r-btn); cursor: pointer; font-size: 12.5px; color: var(--t2);
|
||
user-select: none; flex-shrink: 0;
|
||
transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
|
||
}
|
||
.nav-item:hover { background: var(--field); color: var(--t1); }
|
||
.nav-item.active { background: var(--brand-soft); color: var(--brand-ink); font-weight: 600; }
|
||
.nav-item .el-icon { font-size: 15px; }
|
||
.nav-badge {
|
||
margin-left: auto; font-family: var(--f-num); font-size: 10px; color: var(--t3);
|
||
background: var(--field); border-radius: 6px; padding: 1px var(--space-1-5);
|
||
}
|
||
.nav-item.active .nav-badge { background: var(--surface); color: var(--brand-ink); }
|
||
.nav-badge.good { color: var(--good-ink); background: var(--good-soft); }
|
||
.nav-item.active .nav-badge.good { color: var(--good-ink); }
|
||
.hr { height: 1px; background: var(--line-soft); flex-shrink: 0; }
|
||
|
||
.scene-head { display: flex; align-items: center; gap: var(--space-1-5); flex-shrink: 0; }
|
||
.sh-label { font-size: 11px; font-weight: 600; color: var(--t4); letter-spacing: .04em; }
|
||
.count-pill {
|
||
font-family: var(--f-num); font-size: 10px; color: var(--t3);
|
||
background: var(--field); border-radius: 6px; padding: 1px var(--space-1-5);
|
||
}
|
||
.sync-btn {
|
||
width: 22px; height: 22px; padding: 0; border: none; border-radius: 6px;
|
||
background: transparent; color: var(--t4); cursor: pointer;
|
||
display: grid; place-items: center;
|
||
transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
|
||
}
|
||
.sync-btn:hover { background: var(--field); color: var(--brand-ink); }
|
||
.sync-btn.spin .el-icon { animation: sbSpin .9s linear infinite; }
|
||
.sync-btn:disabled { opacity: .5; cursor: default; }
|
||
|
||
.scene-list {
|
||
flex: 1; min-height: 0; overflow-y: auto;
|
||
display: flex; flex-direction: column; gap: 1px;
|
||
}
|
||
/* 「全部场景」:左栏只放最近使用,全量入口单独一行(不做成常驻列表项,避免与导航混淆) */
|
||
.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);
|
||
}
|
||
.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: 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);
|
||
}
|
||
.scene-row:hover { background: var(--field); }
|
||
.scene-row.current { background: var(--field); }
|
||
.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: 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); }
|
||
/* 测试通道标记:正式版不标注(默认态),只在跑测试包时亮橙,避免误把测试版当正式版用 */
|
||
.scene-row .sr-test {
|
||
font-family: var(--f-cn); color: var(--warn-ink); background: var(--warn-soft);
|
||
border: 1px solid var(--warn-line); border-radius: 3px; padding: 0 3px; flex-shrink: 0;
|
||
}
|
||
.scene-empty {
|
||
flex: 1; display: grid; place-items: center; text-align: center;
|
||
font-size: 12px; color: var(--t3); line-height: 1.9; padding: var(--space-5) var(--space-3);
|
||
}
|
||
.scene-empty span { font-size: 11px; color: var(--t4); }
|
||
|
||
.rail-flex { flex: 1; min-height: 8px; }
|
||
.account {
|
||
display: flex; align-items: center; gap: var(--space-2); padding: var(--space-2); flex-shrink: 0;
|
||
background: var(--field); border-radius: var(--r-btn);
|
||
}
|
||
.account .avatar {
|
||
flex-shrink: 0; border-radius: 50%;
|
||
--el-avatar-bg-color: var(--brand-soft); color: var(--brand-ink); font-size: 11px; font-weight: 700;
|
||
}
|
||
.who { flex: 1; min-width: 0; }
|
||
.who b { font-size: 12px; color: var(--t1); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
|
||
.acct-btn {
|
||
width: 22px; height: 22px; padding: 0; border: none; border-radius: 6px; flex-shrink: 0;
|
||
background: transparent; color: var(--t3); cursor: pointer;
|
||
display: grid; place-items: center;
|
||
transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
|
||
}
|
||
.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-5); padding: var(--space-2-5);
|
||
background: var(--surface); border: 1px solid var(--line);
|
||
border-radius: var(--r-card); box-shadow: var(--sh-card);
|
||
}
|
||
.rail-head { display: flex; align-items: center; justify-content: space-between; padding: 2px var(--space-1) 0; flex-shrink: 0; }
|
||
.rh-label { font-size: 11px; font-weight: 600; color: var(--t4); letter-spacing: .04em; }
|
||
.tag {
|
||
display: inline-flex; align-items: center; gap: var(--space-1);
|
||
height: 20px; padding: 0 var(--space-2); border-radius: var(--r-pill); font-size: 10px; font-weight: 500;
|
||
}
|
||
.tag.off { background: var(--field); color: var(--t3); }
|
||
|
||
.now-card {
|
||
border-radius: var(--r-sub); padding: var(--space-2) var(--space-3); flex-shrink: 0;
|
||
display: flex; flex-direction: column; gap: var(--space-2);
|
||
}
|
||
.now-card.idle {
|
||
background: linear-gradient(150deg, var(--subtle) 0%, var(--surface) 72%);
|
||
border: 1px solid var(--line-soft);
|
||
}
|
||
.now-card.running {
|
||
background: linear-gradient(150deg, var(--brand-soft) 0%, var(--brand-soft-2) 100%);
|
||
border: 1px solid var(--brand-track);
|
||
}
|
||
.tail-line {
|
||
font-family: var(--f-mono); font-size: 10px; line-height: 1.5; color: var(--brand-ink);
|
||
white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
|
||
}
|
||
.tail-line.w { color: var(--warn-ink); }
|
||
.tail-line.e { color: var(--danger-ink); }
|
||
.tail-wait { font-size: 10px; color: var(--t4); }
|
||
.idle-top { display: flex; align-items: center; gap: var(--space-2); }
|
||
.okdot { width: 7px; height: 7px; border-radius: 50%; background: var(--good); flex-shrink: 0; }
|
||
.idle-top b { font-size: 12px; font-weight: 600; color: var(--t1); }
|
||
.idle-sub { font-size: 10.5px; color: var(--t4); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
|
||
|
||
.rail-sub { display: flex; align-items: center; justify-content: space-between; padding: 2px var(--space-1) 0; flex-shrink: 0; }
|
||
.rs-label { font-size: 11px; font-weight: 600; color: var(--t4); letter-spacing: .04em; }
|
||
.rs-n { font-family: var(--f-num); font-size: 10px; color: var(--t4); }
|
||
.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: 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);
|
||
}
|
||
.act-row:hover { background: var(--field); }
|
||
.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: 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; }
|
||
.plat-row {
|
||
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; background: var(--subtle);
|
||
transition: background var(--dur) var(--ease);
|
||
}
|
||
.plat-row:hover { background: var(--field); }
|
||
.plat-row i { width: 5px; height: 5px; border-radius: 50%; flex-shrink: 0; }
|
||
.plat-row i.ok { background: var(--good); }
|
||
.plat-row i.warn { background: var(--warn); }
|
||
.plat-row .nm {
|
||
flex: 1; min-width: 0; font-size: 11.5px; color: var(--t2);
|
||
white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
|
||
}
|
||
.plat-row .st { font-size: 10px; flex-shrink: 0; }
|
||
.plat-row .st.ok { color: var(--good-ink); }
|
||
.plat-row .st.warn { color: var(--warn-ink); }
|
||
|
||
/* ---------- 状态栏 ---------- */
|
||
.statusbar {
|
||
height: 38px; flex-shrink: 0;
|
||
display: flex; align-items: center; gap: var(--space-3); padding: 0 var(--space-4);
|
||
background: var(--surface); border-top: 1px solid var(--line);
|
||
font-size: 10px; color: var(--t3);
|
||
}
|
||
.sb-item { display: inline-flex; align-items: center; gap: var(--space-1-5); white-space: nowrap; }
|
||
.sb-item.click { cursor: pointer; }
|
||
.sb-item.click:hover { color: var(--t1); }
|
||
.sb-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--t5); flex-shrink: 0; }
|
||
.sb-item.ok .sb-dot { background: var(--good); }
|
||
.sb-item.warn { color: var(--warn-ink); }
|
||
.sb-item.warn .sb-dot { background: var(--warn); }
|
||
.sb-item.err { color: var(--danger-ink); }
|
||
.sb-item.err .sb-dot { background: var(--danger); }
|
||
/* 环境包下载/解压中:转圈替代状态点(跟随文字颜色,warn/ok 自适应) */
|
||
.sb-spin {
|
||
width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0;
|
||
border: 1.5px solid currentColor; border-top-color: transparent;
|
||
animation: sbSpin .8s linear infinite;
|
||
}
|
||
@keyframes sbSpin { to { transform: rotate(360deg); } }
|
||
.sb-spacer { flex: 1; }
|
||
.sb-upd { color: var(--brand); font-weight: 500; cursor: pointer; white-space: nowrap; }
|
||
.sb-upd:hover { color: var(--brand-ink); }
|
||
.sb-upd.disabled { color: var(--t4); cursor: default; }
|
||
|
||
/* ---------- 本机组件面板(客户端 / 环境 / 插件 / SDK / 浏览器 统一入口) ---------- */
|
||
.cmp-top {
|
||
display: flex; align-items: center; justify-content: space-between;
|
||
gap: var(--space-3); margin-bottom: var(--space-3);
|
||
}
|
||
.cmp-note { font: 400 12px/1.6 var(--f-cn); color: var(--t3); }
|
||
.cmp-list { display: flex; flex-direction: column; gap: var(--space-2); }
|
||
.cmp-row {
|
||
display: flex; align-items: center; gap: var(--space-3);
|
||
padding: var(--space-3); border: 1px solid var(--line); border-radius: var(--r-card);
|
||
background: var(--surface);
|
||
}
|
||
.cmp-ico {
|
||
width: 32px; height: 32px; flex-shrink: 0; border-radius: 8px;
|
||
display: grid; place-items: center;
|
||
background: var(--field); color: var(--t2);
|
||
font: 600 11px/1 var(--f-cn);
|
||
}
|
||
.cmp-main { flex: 1; min-width: 0; }
|
||
.cmp-name {
|
||
display: flex; align-items: center; gap: var(--space-2);
|
||
font: 600 13px/1.5 var(--f-cn); color: var(--t1);
|
||
}
|
||
.cmp-desc { margin-top: 2px; font: 400 11.5px/1.6 var(--f-cn); color: var(--t3); }
|
||
.cmp-ops { display: flex; gap: var(--space-2); flex-shrink: 0; }
|
||
.cmp-tag {
|
||
padding: 1px 6px; border-radius: 999px;
|
||
font: 500 10.5px/1.6 var(--f-cn);
|
||
background: var(--field); color: var(--t3);
|
||
}
|
||
.cmp-tag.ok { background: var(--field); color: var(--good-ink); }
|
||
.cmp-tag.warn { background: var(--field); color: var(--warn-ink); }
|
||
.cmp-tag.muted { color: var(--t4); }
|
||
.cmp-foot { float: left; font: 400 11px/30px var(--f-cn); color: var(--t4); }
|
||
|
||
/* 下载/更新弹窗(DownloadDialog 共享)及其内部样式见 components/DownloadDialog.vue */
|
||
|
||
/* ---------- 重启更新遮罩 ---------- */
|
||
.upd-mask {
|
||
position: fixed; inset: 0; z-index: 3000;
|
||
display: grid; place-items: center;
|
||
background: rgba(18, 22, 30, .55);
|
||
backdrop-filter: blur(2px);
|
||
-webkit-app-region: no-drag;
|
||
}
|
||
.upd-card {
|
||
width: 340px; padding: var(--space-5) var(--space-5) var(--space-4);
|
||
display: flex; flex-direction: column; align-items: center; gap: var(--space-3);
|
||
background: var(--surface); border-radius: var(--r-win); box-shadow: var(--sh-3);
|
||
text-align: center;
|
||
}
|
||
.upd-ring {
|
||
width: 34px; height: 34px; border-radius: 50%;
|
||
border: 3px solid var(--brand-soft, rgba(64, 128, 255, .18));
|
||
border-top-color: var(--brand);
|
||
animation: updSpin .8s linear infinite;
|
||
}
|
||
@keyframes updSpin { to { transform: rotate(360deg); } }
|
||
.upd-title { font-size: 14px; font-weight: 600; color: var(--t1); }
|
||
.upd-sub { font-size: 12px; line-height: 1.6; color: var(--t3); }
|
||
|
||
/* 窄窗(如分屏):按工作区自身宽度收敛,收起右栏保证中栏可用宽度 */
|
||
@container (max-width: 1220px) {
|
||
.side-r { display: none; }
|
||
}
|
||
</style>
|