- 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)
295 lines
16 KiB
Vue
295 lines
16 KiB
Vue
<template>
|
||
<button class="scene-card card" :class="{ running, compact }" @click="$emit('open', plugin.id)">
|
||
<!-- 左栏「场景」紧凑态:色点 + 名称 + 版本 + 箭头(保持原样) -->
|
||
<template v-if="compact">
|
||
<span class="sc-dot" :style="{ background: dotColor }"></span>
|
||
<span class="sc-body">
|
||
<b class="sc-name">{{ plugin.name }}</b>
|
||
<span class="sc-meta">
|
||
<em class="ver">v{{ plugin.version }}</em>
|
||
<em v-if="chan" class="chan" :class="chan.kind" :title="chan.title">{{ chan.text }}</em>
|
||
<span v-if="plugin.platform" class="plat" :class="platformOnline ? 'on' : 'off'"
|
||
:title="`${platformTip} ${platformOnline ? '已登录' : '未登录,请先在运行台登录'}`">
|
||
<i class="dot"></i>{{ platformTip }} · {{ 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>
|
||
</template>
|
||
|
||
<!-- 场景库卡:竖向排版(图标块 + 分类胶囊 → 标题 → 两行描述 → 标签 → 底部最近运行/配置运行) -->
|
||
<template v-else>
|
||
<span class="sc-top">
|
||
<span class="sc-tile" :style="{ color: dotColor, background: tileBg }">
|
||
<svg width="19" height="19" viewBox="0 0 24 24" fill="none" stroke="currentColor"
|
||
stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
|
||
<path :d="iconPath" />
|
||
</svg>
|
||
</span>
|
||
<em v-if="plugin.category" class="sc-cat">{{ plugin.category }}</em>
|
||
</span>
|
||
|
||
<b class="sc-name">{{ plugin.name }}</b>
|
||
<span class="sc-desc">{{ plugin.description || '暂无描述' }}</span>
|
||
|
||
<span class="sc-tags">
|
||
<em class="sc-tag ver">v{{ plugin.version }}</em>
|
||
<em v-if="chan" class="sc-tag chan" :class="chan.kind" :title="chan.title">{{ chan.text }}</em>
|
||
<em v-if="plugin.update_available" class="sc-tag upd" title="云端有新版本,点左栏「插件同步」可升级">
|
||
↑ v{{ plugin.cloud_version }}
|
||
</em>
|
||
<em v-if="plugin.platform" class="sc-tag plat" :class="platformOnline ? 'on' : 'off'"
|
||
:title="`${platformTip} ${platformOnline ? '已登录' : '未登录,请先在运行台登录'}`">
|
||
<i class="dot"></i><span class="tx">{{ platformText }}</span>
|
||
</em>
|
||
</span>
|
||
|
||
<span class="sc-foot">
|
||
<span class="sc-when" :class="{ live: running }" :title="running ? '正在执行' : `最近一次运行:${whenText}`">
|
||
<i v-if="running" class="live-dot"></i>
|
||
<svg v-else width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor"
|
||
stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
|
||
<circle cx="12" cy="12" r="8.4" /><path d="M12 7.6V12l3 1.8" />
|
||
</svg>
|
||
{{ running ? '正在执行' : whenText }}
|
||
</span>
|
||
<span class="sc-cta" :class="{ busy: running }">
|
||
<template v-if="running">{{ store.progress }}%</template>
|
||
<template v-else>
|
||
配置运行
|
||
<svg width="11" height="11" viewBox="0 0 24 24" fill="none" stroke="currentColor"
|
||
stroke-width="2.4" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
|
||
<path d="m9 5 7 7-7 7" />
|
||
</svg>
|
||
</template>
|
||
</span>
|
||
</span>
|
||
</template>
|
||
</button>
|
||
</template>
|
||
|
||
<script setup>
|
||
import { computed } from 'vue'
|
||
import { store } from '../store'
|
||
import { sceneDotColor } from '../utils/theme'
|
||
import { pluginChannelTag } from '../utils/format'
|
||
|
||
// 场景卡:首页「常用场景」(compact,无描述)与场景库(竖向卡)共用。
|
||
// 色点按插件在总清单中的位置取色,搜索/筛选/分组后颜色仍稳定。
|
||
const props = defineProps({
|
||
plugin: { type: Object, required: true },
|
||
compact: { type: Boolean, default: false },
|
||
// 最近一次运行时间(场景库页用 /api/runs 汇总后传入),空 = 尚未运行
|
||
lastRun: { type: String, default: '' },
|
||
})
|
||
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 pluginIndex = computed(() => Math.max(0, store.plugins.findIndex((p) => p.id === props.plugin.id)))
|
||
|
||
// ---- 场景图标:按名称/分类关键词挑语义化线性图标(24×24 描边 path)----
|
||
const ICONS = {
|
||
user: 'M12 12a4 4 0 1 0 0-8 4 4 0 0 0 0 8z M5 20a7 7 0 0 1 14 0',
|
||
chart: 'M4 19V5 M4 19h16 M8 16v-4 M12 16V8 M16 16v-6',
|
||
sync: 'M4 9a8 8 0 0 1 13.2-3.4L20 8 M20 5v4h-4 M20 15a8 8 0 0 1-13.2 3.4L4 16 M4 19v-4h4',
|
||
bell: 'M15 17h5l-1.4-1.4A2 2 0 0 1 18 14.2V11a6 6 0 0 0-4-5.7V5a2 2 0 1 0-4 0v.3C7.7 6.2 6 8.4 6 11v3.2c0 .5-.2 1-.6 1.4L4 17h5 M15 17v1a3 3 0 1 1-6 0v-1',
|
||
doc: 'M14 3H7a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V8l-5-5z M14 3v5h5 M9 13h6 M9 17h4',
|
||
globe: 'M12 21a9 9 0 1 0 0-18 9 9 0 0 0 0 18z M3.6 9h16.8 M3.6 15h16.8 M12 3a15 15 0 0 1 0 18 15 15 0 0 1 0-18z',
|
||
table: 'M4 5h16v14H4z M4 10h16 M4 15h16 M10 5v14',
|
||
mail: 'M4 6h16v12H4z M4 7l8 6 8-6',
|
||
check: 'M9 12l2 2 4-4 M12 21a9 9 0 1 0 0-18 9 9 0 0 0 0 18z',
|
||
clock: 'M12 21a9 9 0 1 0 0-18 9 9 0 0 0 0 18z M12 7.5V12l3 2',
|
||
box: 'M12 3l8 4.5v9L12 21l-8-4.5v-9L12 3z M4 7.5l8 4.5 8-4.5 M12 12v9',
|
||
db: 'M4 6c0-1.7 3.6-3 8-3s8 1.3 8 3-3.6 3-8 3-8-1.3-8-3z M4 6v6c0 1.7 3.6 3 8 3s8-1.3 8-3V6 M4 12v6c0 1.7 3.6 3 8 3s8-1.3 8-3v-6',
|
||
}
|
||
const ICON_RULES = [
|
||
{ keys: ['考勤', '花名册', '人员', '员工', '人资', '社保', '招聘'], icon: ICONS.user },
|
||
{ keys: ['对账', '报表', '统计', '月报', '汇总', '分析', '台账'], icon: ICONS.chart },
|
||
{ keys: ['同步', '导入', '导出', '上传', '下载', '迁移', '入库'], icon: ICONS.sync },
|
||
{ keys: ['通知', '推送', '钉钉', '企微', '企业微信', '消息', '邮件'], icon: ICONS.bell },
|
||
{ keys: ['采集', '抓取', '爬取', '监控', '竞品', '数据'], icon: ICONS.db },
|
||
{ keys: ['审批', '流程', '工单', '待办', '签批'], icon: ICONS.doc },
|
||
{ keys: ['网页', '网站', '系统', '平台', '登录'], icon: ICONS.globe },
|
||
{ keys: ['excel', 'wps', '表格', '清单', '明细'], icon: ICONS.table },
|
||
{ keys: ['检查', '校验', '审核', '核对', '核验', '封存'], icon: ICONS.check },
|
||
{ keys: ['计划', '定时', '调度', '排班'], icon: ICONS.clock },
|
||
{ keys: ['库存', '物料', '订单', '采购', '仓库', '发货'], icon: ICONS.box },
|
||
]
|
||
const ICON_POOL = Object.values(ICONS)
|
||
// 关键词命中优先;都没命中时按清单序号从图标池轮取(同一场景始终同一个图标,不会乱跳)
|
||
const iconPath = computed(() => {
|
||
const text = `${props.plugin.name || ''} ${props.plugin.category || ''}`.toLowerCase()
|
||
const hit = ICON_RULES.find((r) => r.keys.some((k) => text.includes(k.toLowerCase())))
|
||
return hit ? hit.icon : ICON_POOL[pluginIndex.value % ICON_POOL.length]
|
||
})
|
||
const platform = computed(() => store.platforms.find((p) => p.id === props.plugin.platform) || null)
|
||
// 通道徽章(正式版/测试版):由 /api/meta 回填的 cloud channel 决定,离线时为空不显示
|
||
const chan = computed(() => pluginChannelTag(props.plugin))
|
||
const platformTip = computed(() => platform.value?.label || props.plugin.platform || '')
|
||
const platformOnline = computed(() => !!platform.value?.online)
|
||
// 已登录只留平台名(绿点即状态),未登录显式标出,避免"点进去才发现要登录"
|
||
const platformText = computed(() => (platformOnline.value ? platformTip.value : `${platformTip.value} · 未登录`))
|
||
// 最近运行时间由父级(场景库页)按 /api/runs 汇总后传入,空 = 尚未运行
|
||
const whenText = computed(() => props.lastRun || '尚未运行')
|
||
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-4); min-height: 104px; 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); min-height: 0;
|
||
}
|
||
.scene-card.compact:hover { transform: none; box-shadow: var(--sh-card); }
|
||
|
||
.sc-dot { width: 6px; height: 6px; border-radius: 3px; flex-shrink: 0; }
|
||
.sc-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
|
||
.sc-name {
|
||
min-width: 0; font: 600 13px/18px var(--f-cn); color: var(--t1);
|
||
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; }
|
||
/* 通道徽章(紧凑态):测试版=橙、正式版=绿,一眼看出当前跑的通道 */
|
||
.scene-card.compact .chan {
|
||
flex-shrink: 0; font-style: normal; font: 500 9.5px/14px var(--f-cn);
|
||
padding: 0 4px; border-radius: 3px; border: 1px solid transparent;
|
||
}
|
||
.scene-card.compact .chan.test { color: var(--warn-ink); background: var(--warn-soft); border-color: var(--warn-line); }
|
||
.scene-card.compact .chan.prod { color: var(--good-ink); background: var(--good-soft); border-color: var(--good-line); }
|
||
/* 紧凑态平台登录态(首页常用场景用):限定在 compact 内,避免污染场景库卡的标签色 */
|
||
.scene-card.compact .plat {
|
||
display: inline-flex; align-items: center; gap: 5px;
|
||
font-size: 10.5px; color: var(--t3);
|
||
white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
|
||
}
|
||
.scene-card.compact .plat .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--t5); flex-shrink: 0; }
|
||
.scene-card.compact .plat.on { color: var(--good-ink); }
|
||
.scene-card.compact .plat.on .dot { background: var(--good); }
|
||
.scene-card.compact .plat.off { color: var(--warn-ink); }
|
||
.scene-card.compact .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.compact:hover .sc-go { background: var(--brand); color: var(--on-primary); border-color: transparent; box-shadow: var(--sh-brand-sm); }
|
||
.scene-card.compact.running .sc-go { background: var(--brand); color: var(--on-primary); border-color: transparent; }
|
||
|
||
/* ================= 场景库竖向卡(对齐设计稿:图标块 + 右上徽章 → 标题 → 两行描述 → 标签 → 底栏) ================= */
|
||
.scene-card:not(.compact) {
|
||
flex-direction: column; align-items: stretch; gap: 0;
|
||
height: 100%; min-height: 0; padding: var(--space-4);
|
||
background: var(--surface); border-radius: var(--r-sub); overflow: hidden;
|
||
}
|
||
/* 设计稿 hover:只加阴影 + 描边转品牌色,卡片不上浮 */
|
||
.scene-card:not(.compact):hover { transform: none; box-shadow: var(--sh-float); border-color: var(--brand-track); }
|
||
.scene-card:not(.compact):active { transform: none; }
|
||
.scene-card:not(.compact).running { background: linear-gradient(160deg, var(--brand-soft) 0%, var(--surface) 62%); }
|
||
|
||
/* 顶部:图标块(40×40)+ 右上分类徽章 */
|
||
.sc-top {
|
||
display: flex; align-items: flex-start; justify-content: space-between;
|
||
gap: var(--space-2); margin-bottom: 10px; flex-shrink: 0;
|
||
}
|
||
.sc-tile {
|
||
width: 40px; height: 40px; border-radius: 8px; flex-shrink: 0;
|
||
display: grid; place-items: center;
|
||
}
|
||
.sc-tile svg { display: block; }
|
||
.sc-cat {
|
||
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);
|
||
max-width: 118px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
|
||
}
|
||
|
||
.scene-card:not(.compact) .sc-name {
|
||
flex-shrink: 0; font: 700 14px/20px var(--f-cn);
|
||
margin-bottom: 4px; transition: color var(--dur);
|
||
}
|
||
.scene-card:not(.compact):hover .sc-name { color: var(--brand); }
|
||
|
||
.sc-desc {
|
||
flex-shrink: 0; margin-bottom: 12px; color: var(--t3);
|
||
font-size: 12px; line-height: 18px;
|
||
display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
|
||
overflow: hidden; white-space: normal;
|
||
}
|
||
|
||
/* 标签行:版本 / 平台登录态(设计稿的灰底小标签,状态只靠圆点表达) */
|
||
.sc-tags { flex-shrink: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-bottom: 12px; }
|
||
.sc-tag {
|
||
display: inline-flex; align-items: center; gap: 4px; max-width: 100%;
|
||
font-style: normal; font: 500 10px/17px var(--f-cn); color: var(--t3);
|
||
background: var(--field); border: 1px solid var(--line);
|
||
border-radius: 4px; padding: 0 var(--space-2);
|
||
white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
|
||
}
|
||
.sc-tag.ver { font-family: var(--f-num); color: var(--t4); }
|
||
/* 通道徽章:测试版(橙)/ 正式版(绿);有新版时另给一个「↑ vX」提示 */
|
||
.sc-tag.chan.test { color: var(--warn-ink); background: var(--warn-soft); border-color: var(--warn-line); }
|
||
.sc-tag.chan.prod { color: var(--good-ink); background: var(--good-soft); border-color: var(--good-line); }
|
||
.sc-tag.upd { color: var(--brand-ink); background: var(--brand-soft); border-color: var(--brand-track); font-family: var(--f-num); }
|
||
.sc-tag.plat { flex-shrink: 1; min-width: 0; }
|
||
.sc-tag.plat .tx { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
|
||
.sc-tag.plat .dot { width: 5px; height: 5px; border-radius: 50%; background: var(--t5); flex-shrink: 0; }
|
||
.sc-tag.plat.on .dot { background: var(--good); }
|
||
.sc-tag.plat.off .dot { background: var(--warn); }
|
||
|
||
/* 底部:最近运行 / hover 出现的「配置运行」 */
|
||
.sc-foot {
|
||
flex-shrink: 0; margin-top: auto; padding-top: 10px;
|
||
border-top: 1px solid var(--line-soft);
|
||
display: flex; align-items: center; justify-content: space-between; gap: var(--space-2);
|
||
}
|
||
.sc-when {
|
||
display: inline-flex; align-items: center; gap: 5px; min-width: 0;
|
||
font: 400 11px/16px var(--f-cn); color: var(--t4);
|
||
white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
|
||
}
|
||
.sc-when svg { flex-shrink: 0; color: var(--t5); }
|
||
.sc-when.live { color: var(--brand-ink); }
|
||
.live-dot {
|
||
width: 5px; height: 5px; border-radius: 50%; background: var(--brand);
|
||
flex-shrink: 0; animation: scPulse 1.4s var(--ease) infinite;
|
||
}
|
||
@keyframes scPulse { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: .35; transform: scale(.72); } }
|
||
|
||
.sc-cta {
|
||
display: inline-flex; align-items: center; gap: 2px; flex-shrink: 0;
|
||
font: 500 12px/16px var(--f-cn); color: var(--brand);
|
||
opacity: 0; transition: opacity var(--dur), color var(--dur);
|
||
}
|
||
.sc-cta svg { display: block; }
|
||
.sc-cta.busy { font-family: var(--f-num); font-variant-numeric: tabular-nums; opacity: 1; }
|
||
.scene-card:hover .sc-cta, .scene-card.running .sc-cta { opacity: 1; }
|
||
.scene-card:hover .sc-cta { color: var(--brand-ink); }
|
||
</style>
|