feat: 完成插件管理系统产品化P0闭环落地
此提交实现完整的插件管理产品化闭环: 1. 中心机新增Ed25519密钥、审计/运行上报表、插件扩展字段,实现票据/管控清单签发、鉴权下载能力 2. 部署端新增设备级单活调度器、用户私有插件库、离线/联网校验链、插件下载安装流程 3. 控制面与部署前端同步更新UI与接口适配,新增审计页、插件管理增强功能 4. 修复两个工作流脚本的过滤与Excel导出问题,优化打包依赖与日志面板 5. 新增完整架构设计与实施文档
This commit is contained in:
@@ -1,95 +1,114 @@
|
||||
<template>
|
||||
<div class="mask" @click.self="emit('close')">
|
||||
<aside class="profile">
|
||||
<header class="head">
|
||||
<div class="avatar" aria-hidden="true">
|
||||
<img v-if="store.avatarUrl && !avatarFailed" :src="store.avatarUrl" alt="" @error="onAvatarError">
|
||||
<span v-else>{{ store.current.slice(0, 1).toUpperCase() }}</span>
|
||||
</div>
|
||||
<div class="meta">
|
||||
<div class="name-line">
|
||||
<strong>{{ store.current }}</strong>
|
||||
<em v-if="store.isAdmin" class="tag">管理员</em>
|
||||
</div>
|
||||
<span class="dept">{{ store.dept || '未设置部门' }}</span>
|
||||
</div>
|
||||
<button class="close" title="关闭" @click="emit('close')">✕</button>
|
||||
</header>
|
||||
|
||||
<div class="body">
|
||||
<!-- 分节:平台登录态 -->
|
||||
<div class="sec">
|
||||
<div class="sec-title">平台登录态</div>
|
||||
<div v-for="p in store.platforms" :key="p.id" class="prow">
|
||||
<i class="dot" :class="{ on: p.online }"></i>
|
||||
<span class="pname">{{ p.label }}</span>
|
||||
<span class="pstat">{{ p.online ? '已登录' : '未登录' }}</span>
|
||||
<button class="btn mini" :disabled="busy === p.id" @click="relogin(p.id)">
|
||||
{{ busy === p.id ? '处理中…' : '重新登录' }}
|
||||
</button>
|
||||
<button class="btn mini" :disabled="busy === p.id || !p.online" @click="logout(p.id)">登出</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 分节:我的插件 -->
|
||||
<div class="sec">
|
||||
<div class="sec-title">我的插件</div>
|
||||
<div v-if="store.plugins.length" class="plist">
|
||||
<div v-for="p in store.plugins" :key="p.id" class="prow flat">
|
||||
<span class="pname">{{ p.name }}</span>
|
||||
<span class="ver">v{{ p.version }}</span>
|
||||
<el-drawer
|
||||
v-model="visible"
|
||||
title="个人中心"
|
||||
direction="rtl"
|
||||
size="350px"
|
||||
:with-header="true"
|
||||
@close="emit('close')"
|
||||
>
|
||||
<!-- 个人信息卡片 -->
|
||||
<el-card class="info-card" shadow="never">
|
||||
<template #header>
|
||||
<div class="info-head">
|
||||
<el-avatar :size="46" :src="store.avatarUrl" @error="onAvatarError" class="avatar">
|
||||
<span>{{ store.current.slice(0, 1).toUpperCase() }}</span>
|
||||
</el-avatar>
|
||||
<div class="info-meta">
|
||||
<div class="name-line">
|
||||
<strong>{{ store.current }}</strong>
|
||||
<el-tag v-if="store.isAdmin" size="small" type="primary" effect="light" round>管理员</el-tag>
|
||||
</div>
|
||||
<span class="dept">{{ store.dept || '未设置部门' }}</span>
|
||||
</div>
|
||||
<p v-else class="empty">当前账号暂无可用插件</p>
|
||||
</div>
|
||||
</template>
|
||||
</el-card>
|
||||
|
||||
<!-- 分节:修改密码 -->
|
||||
<div class="sec">
|
||||
<div class="sec-title">修改密码</div>
|
||||
<input class="input" v-model="oldPwd" type="password" placeholder="旧密码">
|
||||
<input class="input" v-model="newPwd" type="password" placeholder="新密码">
|
||||
<input class="input" v-model="againPwd" type="password" placeholder="确认新密码">
|
||||
<button class="btn primary block" :disabled="pwdBusy" @click="changePwd">
|
||||
{{ pwdBusy ? '提交中…' : '保存新密码' }}
|
||||
</button>
|
||||
<p v-if="pwdMsg" class="msg" :class="{ ok: pwdOk }">{{ pwdMsg }}</p>
|
||||
<!-- 平台登录态 -->
|
||||
<el-collapse v-model="activeNames">
|
||||
<el-collapse-item name="platforms">
|
||||
<template #title>
|
||||
<div class="panel-title">
|
||||
<el-icon><Connection /></el-icon>
|
||||
<span>平台登录态</span>
|
||||
</div>
|
||||
</template>
|
||||
<div v-for="p in store.platforms" :key="p.id" class="prow">
|
||||
<i class="dot" :class="{ on: p.online }"></i>
|
||||
<span class="pname">{{ p.label }}</span>
|
||||
<span class="pstat">{{ p.online ? '已登录' : '未登录' }}</span>
|
||||
<el-button size="small" :disabled="busy === p.id" @click="relogin(p.id)">
|
||||
{{ busy === p.id ? '处理中…' : '重新登录' }}
|
||||
</el-button>
|
||||
<el-button size="small" :disabled="busy === p.id || !p.online" @click="logout(p.id)">登出</el-button>
|
||||
</div>
|
||||
</div>
|
||||
<transition name="fade">
|
||||
<div v-if="tipMsg" class="tip">{{ tipMsg }}</div>
|
||||
</transition>
|
||||
</aside>
|
||||
</div>
|
||||
</el-collapse-item>
|
||||
|
||||
<!-- 我的插件 -->
|
||||
<el-collapse-item name="plugins">
|
||||
<template #title>
|
||||
<div class="panel-title">
|
||||
<el-icon><Box /></el-icon>
|
||||
<span>我的插件 ({{ store.plugins.length }})</span>
|
||||
</div>
|
||||
</template>
|
||||
<el-empty v-if="!store.plugins.length" description="当前账号暂无可用插件" />
|
||||
<div v-else class="plist">
|
||||
<div v-for="p in store.plugins" :key="p.id" class="prow flat">
|
||||
<span class="pname">{{ p.name }}</span>
|
||||
<span class="ver">v{{ p.version }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</el-collapse-item>
|
||||
</el-collapse>
|
||||
|
||||
<!-- 修改密码 -->
|
||||
<el-card class="pwd-card" shadow="never" title="修改密码">
|
||||
<el-form label-position="top" :model="form" :rules="rules" ref="formRef">
|
||||
<el-form-item label="旧密码" prop="oldPwd">
|
||||
<el-input v-model="form.oldPwd" type="password" show-password placeholder="请输入旧密码" />
|
||||
</el-form-item>
|
||||
<el-form-item label="新密码" prop="newPwd">
|
||||
<el-input v-model="form.newPwd" type="password" show-password placeholder="至少 6 位,不与原密码相同" />
|
||||
</el-form-item>
|
||||
<el-form-item label="确认新密码" prop="newPwd2">
|
||||
<el-input v-model="form.newPwd2" type="password" show-password placeholder="再次输入新密码" />
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" :loading="pwdBusy" @click="changePwd" style="width: 100%">
|
||||
{{ pwdBusy ? '提交中…' : '保存新密码' }}
|
||||
</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</el-card>
|
||||
</el-drawer>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref } from 'vue'
|
||||
import { ref, reactive } from 'vue'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import { Connection, Box } from '@element-plus/icons-vue'
|
||||
import { store, log, clearAvatarCache } from '../store'
|
||||
import { loginPlatform, logoutPlatform, adminPassword } from '../api'
|
||||
|
||||
const emit = defineEmits(['close'])
|
||||
// 由父组件 v-if 控制挂载,挂载即展开;关闭经 @close 通知父组件卸载
|
||||
const visible = ref(true)
|
||||
|
||||
// 头像:复用全局 store 的在线头像(带 localStorage 缓存);加载失败时清除缓存并回退首字符色块
|
||||
const avatarFailed = ref(false)
|
||||
function onAvatarError() {
|
||||
avatarFailed.value = true
|
||||
clearAvatarCache()
|
||||
}
|
||||
|
||||
const activeNames = ref(['platforms', 'plugins'])
|
||||
const busy = ref('')
|
||||
// 面板内轻提示:已登录再点击等操作反馈
|
||||
const tipMsg = ref('')
|
||||
let tipTimer = null
|
||||
function tip(m) {
|
||||
tipMsg.value = m
|
||||
if (tipTimer) clearTimeout(tipTimer)
|
||||
tipTimer = setTimeout(() => (tipMsg.value = ''), 2000)
|
||||
}
|
||||
|
||||
async function relogin(id) {
|
||||
if (busy.value) return
|
||||
const p = store.platforms.find((x) => x.id === id)
|
||||
if (p?.online) {
|
||||
tip(`${p.label} 已登录`)
|
||||
ElMessage.success(`${p.label} 已登录`)
|
||||
return
|
||||
}
|
||||
busy.value = id
|
||||
@@ -98,10 +117,11 @@ async function relogin(id) {
|
||||
if (p) {
|
||||
p.online = !!r.online
|
||||
log('INFO', `平台 ${p.label} 登录成功`)
|
||||
ElMessage.success(`平台 ${p.label} 登录成功`)
|
||||
}
|
||||
} catch (e) {
|
||||
log('ERROR', `平台 ${(store.platforms.find((x) => x.id === id) || {}).label || id} 登录失败:${e.message || e}`)
|
||||
alert('登录失败:' + (e.message || e))
|
||||
ElMessage.error(`登录失败:${e.message || e}`)
|
||||
} finally {
|
||||
busy.value = ''
|
||||
}
|
||||
@@ -114,39 +134,54 @@ async function logout(id) {
|
||||
if (p) {
|
||||
p.online = !!r.online
|
||||
log('INFO', `平台 ${p.label} 已登出`)
|
||||
ElMessage.success(`平台 ${p.label} 已登出`)
|
||||
}
|
||||
} catch (e) {
|
||||
log('ERROR', `平台 ${(store.platforms.find((x) => x.id === id) || {}).label || id} 登出失败:${e.message || e}`)
|
||||
tip('登出失败:' + (e.message || e))
|
||||
ElMessage.error(`登出失败:${e.message || e}`)
|
||||
} finally {
|
||||
busy.value = ''
|
||||
}
|
||||
}
|
||||
|
||||
const oldPwd = ref('')
|
||||
const newPwd = ref('')
|
||||
const againPwd = ref('')
|
||||
// 修改密码
|
||||
const formRef = ref()
|
||||
const form = reactive({ oldPwd: '', newPwd: '', newPwd2: '' })
|
||||
const rules = {
|
||||
oldPwd: [{ required: true, message: '请输入原密码', trigger: 'blur' }],
|
||||
newPwd: [
|
||||
{ required: true, message: '请输入新密码', trigger: 'blur' },
|
||||
{ min: 6, message: '新密码至少 6 位', trigger: 'blur' },
|
||||
{
|
||||
validator: (_, v, cb) => (v && v === form.oldPwd
|
||||
? cb(new Error('新密码不能与原密码相同')) : cb()),
|
||||
trigger: 'blur'
|
||||
},
|
||||
],
|
||||
newPwd2: [
|
||||
{ required: true, message: '请再次输入新密码', trigger: 'blur' },
|
||||
{
|
||||
validator: (_, v, cb) => (v !== form.newPwd
|
||||
? cb(new Error('两次输入的密码不一致')) : cb()),
|
||||
trigger: 'blur'
|
||||
},
|
||||
],
|
||||
}
|
||||
const pwdBusy = ref(false)
|
||||
const pwdMsg = ref('')
|
||||
const pwdOk = ref(false)
|
||||
async function changePwd() {
|
||||
pwdMsg.value = ''
|
||||
if (!oldPwd.value || !newPwd.value) return (pwdMsg.value = '请填写完整密码')
|
||||
if (newPwd.value !== againPwd.value) return (pwdMsg.value = '两次新密码不一致')
|
||||
await formRef.value.validate().catch(() => Promise.reject())
|
||||
pwdBusy.value = true
|
||||
try {
|
||||
await adminPassword({
|
||||
account: store.current,
|
||||
old_password: oldPwd.value,
|
||||
new_password: newPwd.value,
|
||||
old_password: form.oldPwd,
|
||||
new_password: form.newPwd,
|
||||
})
|
||||
pwdMsg.value = '密码已修改'
|
||||
pwdOk.value = true
|
||||
oldPwd.value = newPwd.value = againPwd.value = ''
|
||||
ElMessage.success('密码已修改,下次登录请使用新密码')
|
||||
form.oldPwd = form.newPwd = form.newPwd2 = ''
|
||||
setTimeout(() => emit('close'), 800)
|
||||
} catch (e) {
|
||||
pwdOk.value = false
|
||||
pwdMsg.value = '修改失败:' + (e.message || e)
|
||||
ElMessage.error('修改失败:' + (e.message || e))
|
||||
} finally {
|
||||
pwdBusy.value = false
|
||||
}
|
||||
@@ -154,76 +189,28 @@ async function changePwd() {
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.mask {
|
||||
position: fixed; inset: 0; z-index: 50;
|
||||
background: rgba(31, 38, 51, 0.35);
|
||||
display: flex; justify-content: flex-end;
|
||||
animation: fade .18s ease;
|
||||
}
|
||||
.tip {
|
||||
position: absolute; top: 18px; left: 50%; transform: translateX(-50%);
|
||||
background: rgba(24, 39, 75, .92); color: #fff;
|
||||
padding: 8px 18px; border-radius: 999px; font-size: 12.5px;
|
||||
z-index: 5; box-shadow: 0 8px 24px -8px rgba(24, 39, 75, .4);
|
||||
animation: fade .15s ease;
|
||||
}
|
||||
.profile {
|
||||
width: 320px; height: 100%;
|
||||
background: var(--surface);
|
||||
display: flex; flex-direction: column;
|
||||
box-shadow: -12px 0 34px -12px rgba(24, 39, 75, 0.3);
|
||||
animation: slide .2s ease;
|
||||
}
|
||||
@keyframes slide { from { transform: translateX(100%); } to { transform: translateX(0); } }
|
||||
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
|
||||
|
||||
.head {
|
||||
display: flex; align-items: center; gap: 12px;
|
||||
padding: 18px 20px 14px;
|
||||
border-bottom: 1px solid var(--border);
|
||||
}
|
||||
.avatar {
|
||||
width: 46px; height: 46px; border-radius: 50%;
|
||||
position: relative; overflow: hidden; flex-shrink: 0;
|
||||
display: grid; place-items: center;
|
||||
color: #fff; font-size: 18px; font-weight: 700;
|
||||
background: var(--primary-grad);
|
||||
}
|
||||
.avatar img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
|
||||
.meta { flex: 1; min-width: 0; }
|
||||
.info-card { margin-bottom: 16px; }
|
||||
.info-head { display: flex; align-items: center; gap: 12px; }
|
||||
.avatar { flex-shrink: 0; }
|
||||
.info-meta { flex: 1; min-width: 0; }
|
||||
.name-line { display: flex; align-items: center; gap: 8px; }
|
||||
.name-line strong { font-size: 15px; }
|
||||
.tag { font-style: normal; font-size: 10px; color: var(--primary);
|
||||
background: var(--primary-weak); border-radius: 999px; padding: 1px 8px; }
|
||||
.dept { font-size: 11.5px; color: var(--text-faint); }
|
||||
.close {
|
||||
border: none; background: transparent; cursor: pointer;
|
||||
color: var(--text-faint); font-size: 14px; padding: 6px; border-radius: 8px;
|
||||
}
|
||||
.close:hover { color: var(--text); background: var(--surface-2); }
|
||||
|
||||
.body { flex: 1; overflow: auto; padding: 4px 20px 20px; }
|
||||
.sec { padding: 14px 0 4px; }
|
||||
.sec + .sec { border-top: 1px dashed var(--border); margin-top: 6px; }
|
||||
.sec-title {
|
||||
font-size: 11px; font-weight: 700; letter-spacing: 0.04em;
|
||||
color: var(--text-faint); margin-bottom: 10px;
|
||||
}
|
||||
.panel-title { display: flex; align-items: center; gap: 8px; }
|
||||
|
||||
.prow { display: flex; align-items: center; gap: 8px; padding: 7px 0; }
|
||||
.prow {
|
||||
display: flex; align-items: center; gap: 8px;
|
||||
padding: 8px 0;
|
||||
}
|
||||
.prow.flat { padding: 6px 0; }
|
||||
.dot { width: 8px; height: 8px; border-radius: 50%; background: #c6ccdc; flex-shrink: 0; }
|
||||
.dot.on { background: var(--ok); box-shadow: 0 0 0 3px rgba(34, 176, 122, 0.18); }
|
||||
.pname { flex: 1; color: var(--text-sub); font-size: 13px;
|
||||
white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
|
||||
.pname { flex: 1; color: var(--text-sub); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
|
||||
.pstat { font-size: 11px; color: var(--text-faint); }
|
||||
.ver { font-size: 11px; color: var(--text-faint); }
|
||||
.plist { display: flex; flex-direction: column; }
|
||||
.empty { color: var(--text-faint); font-size: 12px; margin: 4px 0; }
|
||||
.btn.mini { padding: 3px 10px; font-size: 12px; }
|
||||
|
||||
.input { width: 100%; margin-bottom: 10px; }
|
||||
.btn.block { width: 100%; margin-top: 2px; }
|
||||
.msg { font-size: 12px; color: var(--err); margin: 8px 0 0; }
|
||||
.msg.ok { color: var(--ok); }
|
||||
</style>
|
||||
.pwd-card { margin-top: 16px; }
|
||||
</style>
|
||||
Reference in New Issue
Block a user