restore: 恢复 11-06~11-09 本地未提交改动
- 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)
This commit is contained in:
@@ -1,211 +1,300 @@
|
||||
<script setup lang="ts">
|
||||
/**
|
||||
* 授权矩阵总览(账号 × 插件)—— 面向插件持续膨胀(25 → 50 → 100+)
|
||||
*
|
||||
* 纯横向铺列在几十个插件时就没法用了,所以按「降维」思路收敛:
|
||||
* 1) 分类 Tab:一次只看一个分类(财务 / 人事 / 其他…),列数天然有界;
|
||||
* 2) 列分页:单分类也很长时按每页 N 列翻页(默认 15),账号列与行始终不变、只翻插件列;
|
||||
* 3) 列筛选:插件多选(空=全部)/ 搜索 / 仅看已授权插件,选择记 localStorage;
|
||||
* 4) 两行 sticky 表头(分类分组 + 插件)+ 悬停列高亮 + 点击列头只看该插件,长表也能横向跟踪。
|
||||
* 单元格仍是 [⬇下载][▶运行] 徽标,点一下切一位,两位都关掉自动整行撤销。
|
||||
*/
|
||||
import { computed, ref, watch } from 'vue'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import { grantPlugin } from '@/api/business'
|
||||
/**
|
||||
* 授权矩阵总览(账号 × 插件)—— 面向插件持续膨胀(25 → 50 → 100+)
|
||||
*
|
||||
* 可读性设计(每个格子 = 一个账号对一个插件的授权):
|
||||
* 1) 格子内两个中文按钮「下」(允许下载)/「运」(允许运行),亮绿=已开、灰色空=未开,
|
||||
* 不再用 ⬇ ▶ 这类需要猜的符号;两个都关 = 自动撤销整条授权;
|
||||
* 2) 格子淡色底一眼扫状态:绿=完整授权、黄=只开了一项、白=未授权,图例与格子同款样式;
|
||||
* 3) 分类 Tab + 列分页 + 列筛选,避免几十个插件时横铺到天边;
|
||||
* 4) 列头显示「已授权 N 人」,行首显示已授权插件数,避免逐个格子去数;
|
||||
* 5) 列头眼睛按钮 = 只看该插件(不用点整列头,避免误触);
|
||||
* 6) 左右双向 sticky(账号列 + 两行表头)+ 悬停列高亮,长表也不串行。
|
||||
*/
|
||||
import { computed, ref, watch } from 'vue'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import { grantPlugin } from '@/api/business'
|
||||
|
||||
interface Props {
|
||||
matrix: any
|
||||
}
|
||||
const props = defineProps<Props>()
|
||||
const emit = defineEmits<{ (e: 'changed'): void }>()
|
||||
|
||||
const LS_COLS = 'xq.grants.matrix.cols'
|
||||
const LS_COMPACT = 'xq.grants.matrix.compact'
|
||||
const LS_PAGE_SIZE = 'xq.grants.matrix.pageSize'
|
||||
const PAGE_SIZES = [10, 15, 20, 30, 50]
|
||||
|
||||
function readCols(): string[] {
|
||||
try {
|
||||
const raw = localStorage.getItem(LS_COLS)
|
||||
const arr = raw ? JSON.parse(raw) : []
|
||||
return Array.isArray(arr) ? arr.map(String) : []
|
||||
} catch {
|
||||
return []
|
||||
interface Props {
|
||||
matrix: any
|
||||
}
|
||||
}
|
||||
const props = defineProps<Props>()
|
||||
const emit = defineEmits<{ (e: 'changed'): void }>()
|
||||
|
||||
function readPageSize(): number {
|
||||
const n = Number(localStorage.getItem(LS_PAGE_SIZE))
|
||||
return PAGE_SIZES.includes(n) ? n : 15
|
||||
}
|
||||
const LS_COLS = 'xq.grants.matrix.cols'
|
||||
const LS_COMPACT = 'xq.grants.matrix.compact'
|
||||
const LS_PAGE_SIZE = 'xq.grants.matrix.pageSize'
|
||||
const PAGE_SIZES = [10, 15, 20, 30, 50]
|
||||
|
||||
// 账号侧
|
||||
const kw = ref('')
|
||||
const deptFilter = ref<string | null>(null)
|
||||
const onlyGranted = ref(false)
|
||||
|
||||
// 插件侧
|
||||
const picked = ref<string[]>(readCols())
|
||||
const pluginKw = ref('')
|
||||
const onlyGrantedPlugins = ref(false)
|
||||
const catFilter = ref('')
|
||||
const compact = ref(localStorage.getItem(LS_COMPACT) === '1')
|
||||
const pageSize = ref(readPageSize())
|
||||
const page = ref(1)
|
||||
|
||||
const plugins = computed<any[]>(() => props.matrix.plugins || [])
|
||||
const grants = computed<any[]>(() => props.matrix.grants || [])
|
||||
|
||||
watch(picked, v => localStorage.setItem(LS_COLS, JSON.stringify(v)), { deep: true })
|
||||
watch(compact, v => localStorage.setItem(LS_COMPACT, v ? '1' : '0'))
|
||||
watch(pageSize, v => localStorage.setItem(LS_PAGE_SIZE, String(v)))
|
||||
|
||||
const deptOptions = computed(() => {
|
||||
const set = new Set<string>()
|
||||
for (const a of props.matrix.accounts || []) if (a.dept) set.add(a.dept)
|
||||
return [...set]
|
||||
})
|
||||
|
||||
const catOf = (p: any) => String(p.category || '未分类')
|
||||
|
||||
/** 分类清单(带插件数),只有一个分类时不显示 Tab */
|
||||
const categories = computed(() => {
|
||||
const map = new Map<string, number>()
|
||||
for (const p of plugins.value) map.set(catOf(p), (map.get(catOf(p)) || 0) + 1)
|
||||
return [...map.entries()].map(([label, count]) => ({ label, count }))
|
||||
})
|
||||
|
||||
/** grants 快速索引:(account, pluginId) -> {can_download, can_run} */
|
||||
const grantIndex = computed(() => {
|
||||
const idx = new Map<string, any>()
|
||||
for (const g of grants.value) idx.set(`${g.account}|${g.plugin_id}`, g)
|
||||
return idx
|
||||
})
|
||||
|
||||
function cellOf(account: string, pluginId: string) {
|
||||
return grantIndex.value.get(`${account}|${pluginId}`)
|
||||
}
|
||||
|
||||
function cellState(account: string, pluginId: string): 'full' | 'partial' | 'none' {
|
||||
const c = cellOf(account, pluginId)
|
||||
if (!c) return 'none'
|
||||
return c.can_download && c.can_run ? 'full' : 'partial'
|
||||
}
|
||||
|
||||
const grantedPluginIds = computed(() => new Set(grants.value.map((g: any) => String(g.plugin_id))))
|
||||
|
||||
/** 插件列过滤(分类 Tab + 多选 + 搜索 + 仅已授权) */
|
||||
const visiblePlugins = computed<any[]>(() => {
|
||||
const kwv = pluginKw.value.trim().toLowerCase()
|
||||
return plugins.value.filter((p: any) => {
|
||||
if (catFilter.value && catOf(p) !== catFilter.value) return false
|
||||
if (picked.value.length && !picked.value.includes(p.id)) return false
|
||||
if (onlyGrantedPlugins.value && !grantedPluginIds.value.has(p.id)) return false
|
||||
if (kwv) {
|
||||
const hay = `${p.name || ''} ${p.id} ${catOf(p)}`.toLowerCase()
|
||||
if (!hay.includes(kwv)) return false
|
||||
function readCols(): string[] {
|
||||
try {
|
||||
const raw = localStorage.getItem(LS_COLS)
|
||||
const arr = raw ? JSON.parse(raw) : []
|
||||
return Array.isArray(arr) ? arr.map(String) : []
|
||||
} catch {
|
||||
return []
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
function readPageSize(): number {
|
||||
const n = Number(localStorage.getItem(LS_PAGE_SIZE))
|
||||
return PAGE_SIZES.includes(n) ? n : 15
|
||||
}
|
||||
|
||||
// 账号侧
|
||||
const kw = ref('')
|
||||
const deptFilter = ref<string | null>(null)
|
||||
const onlyGranted = ref(false)
|
||||
|
||||
// 插件侧
|
||||
const picked = ref<string[]>(readCols())
|
||||
const pluginKw = ref('')
|
||||
const onlyGrantedPlugins = ref(false)
|
||||
const catFilter = ref('')
|
||||
const compact = ref(localStorage.getItem(LS_COMPACT) === '1')
|
||||
const pageSize = ref(readPageSize())
|
||||
const page = ref(1)
|
||||
|
||||
const plugins = computed<any[]>(() => props.matrix.plugins || [])
|
||||
|
||||
/** 只统计真正生效的授权行(两个权限都关的空行不算) */
|
||||
const activeGrants = computed<any[]>(() =>
|
||||
(props.matrix.grants || []).filter((g: any) => g.can_download || g.can_run)
|
||||
)
|
||||
|
||||
watch(picked, (v) => localStorage.setItem(LS_COLS, JSON.stringify(v)), { deep: true })
|
||||
watch(compact, (v) => localStorage.setItem(LS_COMPACT, v ? '1' : '0'))
|
||||
watch(pageSize, (v) => localStorage.setItem(LS_PAGE_SIZE, String(v)))
|
||||
|
||||
const deptOptions = computed(() => {
|
||||
const set = new Set<string>()
|
||||
for (const a of props.matrix.accounts || []) if (a.dept) set.add(a.dept)
|
||||
return [...set]
|
||||
})
|
||||
})
|
||||
|
||||
/** 同分类连续排列,两级表头才能成段 */
|
||||
const columns = computed<any[]>(() => {
|
||||
const list = [...visiblePlugins.value]
|
||||
const order: string[] = []
|
||||
for (const p of list) {
|
||||
const c = catOf(p)
|
||||
if (!order.includes(c)) order.push(c)
|
||||
}
|
||||
return list.sort((a, b) => order.indexOf(catOf(a)) - order.indexOf(catOf(b)))
|
||||
})
|
||||
const catOf = (p: any) => String(p.category || '未分类')
|
||||
|
||||
const totalPages = computed(() => Math.max(1, Math.ceil(columns.value.length / pageSize.value)))
|
||||
|
||||
/** 当前页要渲染的插件列(账号行不参与分页) */
|
||||
const pagedColumns = computed(() =>
|
||||
columns.value.slice((page.value - 1) * pageSize.value, page.value * pageSize.value)
|
||||
)
|
||||
|
||||
const rangeText = computed(() => {
|
||||
const total = columns.value.length
|
||||
if (!total) return '0 / 0 列'
|
||||
const from = (page.value - 1) * pageSize.value + 1
|
||||
const to = Math.min(total, page.value * pageSize.value)
|
||||
return `${from}-${to} / 共 ${total} 列`
|
||||
})
|
||||
|
||||
const pluginGroups = computed(() => {
|
||||
const out: { label: string; span: number }[] = []
|
||||
for (const p of pagedColumns.value) {
|
||||
const label = catOf(p)
|
||||
const last = out[out.length - 1]
|
||||
if (last && last.label === label) last.span += 1
|
||||
else out.push({ label, span: 1 })
|
||||
}
|
||||
return out
|
||||
})
|
||||
|
||||
watch([picked, pluginKw, onlyGrantedPlugins, catFilter, pageSize], () => {
|
||||
page.value = 1
|
||||
})
|
||||
watch(totalPages, tp => {
|
||||
if (page.value > tp) page.value = tp
|
||||
})
|
||||
|
||||
const rows = computed(() => {
|
||||
const kwv = kw.value.trim().toLowerCase()
|
||||
return (props.matrix.accounts || []).filter((a: any) => {
|
||||
const kwOk =
|
||||
!kwv ||
|
||||
String(a.account).toLowerCase().includes(kwv) ||
|
||||
String(a.nickname || '').toLowerCase().includes(kwv)
|
||||
const deptOk = !deptFilter.value || a.dept === deptFilter.value
|
||||
const grantedOk = !onlyGranted.value || grants.value.some((g: any) => g.account === a.account)
|
||||
return kwOk && deptOk && grantedOk
|
||||
/** 分类清单(带插件数),只有一个分类时不显示 Tab */
|
||||
const categories = computed(() => {
|
||||
const map = new Map<string, number>()
|
||||
for (const p of plugins.value) map.set(catOf(p), (map.get(catOf(p)) || 0) + 1)
|
||||
return [...map.entries()].map(([label, count]) => ({ label, count }))
|
||||
})
|
||||
})
|
||||
|
||||
/** 悬停列高亮,缓解长表横向串行 */
|
||||
const hoverCol = ref('')
|
||||
/** grants 快速索引:(account, pluginId) -> {can_download, can_run} */
|
||||
const grantIndex = computed(() => {
|
||||
const idx = new Map<string, any>()
|
||||
for (const g of activeGrants.value) idx.set(`${g.account}|${g.plugin_id}`, g)
|
||||
return idx
|
||||
})
|
||||
|
||||
function focusPlugin(id: string) {
|
||||
picked.value = picked.value.length === 1 && picked.value[0] === id ? [] : [id]
|
||||
}
|
||||
|
||||
const toggling = ref(false)
|
||||
|
||||
async function toggle(account: string, pluginId: string, field: 'can_download' | 'can_run') {
|
||||
if (toggling.value) return
|
||||
const cur = cellOf(account, pluginId)
|
||||
const next = { can_download: !!cur?.can_download, can_run: !!cur?.can_run, [field]: !cur?.[field] }
|
||||
toggling.value = true
|
||||
try {
|
||||
const granted = next.can_download || next.can_run
|
||||
await grantPlugin({ account, plugin_id: pluginId, granted, ...next })
|
||||
emit('changed')
|
||||
} catch (e) {
|
||||
ElMessage.error('切换失败')
|
||||
} finally {
|
||||
toggling.value = false
|
||||
function cellOf(account: string, pluginId: string) {
|
||||
return grantIndex.value.get(`${account}|${pluginId}`)
|
||||
}
|
||||
|
||||
function pinOf(account: string, pluginId: string, field: 'can_download' | 'can_run') {
|
||||
return !!cellOf(account, pluginId)?.[field]
|
||||
}
|
||||
|
||||
function cellState(account: string, pluginId: string): 'full' | 'partial' | 'none' {
|
||||
const c = cellOf(account, pluginId)
|
||||
if (!c) return 'none'
|
||||
return c.can_download && c.can_run ? 'full' : 'partial'
|
||||
}
|
||||
|
||||
const grantedPluginIds = computed(
|
||||
() => new Set(activeGrants.value.map((g: any) => String(g.plugin_id)))
|
||||
)
|
||||
|
||||
/** 每个插件被多少人授权 / 每个账号授权了多少插件 */
|
||||
const grantedCountByPlugin = computed(() => {
|
||||
const m = new Map<string, number>()
|
||||
for (const g of activeGrants.value)
|
||||
m.set(String(g.plugin_id), (m.get(String(g.plugin_id)) || 0) + 1)
|
||||
return m
|
||||
})
|
||||
|
||||
const grantedCountByAccount = computed(() => {
|
||||
const m = new Map<string, number>()
|
||||
for (const g of activeGrants.value)
|
||||
m.set(String(g.account), (m.get(String(g.account)) || 0) + 1)
|
||||
return m
|
||||
})
|
||||
|
||||
/** 插件列过滤(分类 Tab + 多选 + 搜索 + 仅已授权) */
|
||||
const visiblePlugins = computed<any[]>(() => {
|
||||
const kwv = pluginKw.value.trim().toLowerCase()
|
||||
return plugins.value.filter((p: any) => {
|
||||
if (catFilter.value && catOf(p) !== catFilter.value) return false
|
||||
if (picked.value.length && !picked.value.includes(p.id)) return false
|
||||
if (onlyGrantedPlugins.value && !grantedPluginIds.value.has(p.id)) return false
|
||||
if (kwv) {
|
||||
const hay = `${p.name || ''} ${p.id} ${catOf(p)}`.toLowerCase()
|
||||
if (!hay.includes(kwv)) return false
|
||||
}
|
||||
return true
|
||||
})
|
||||
})
|
||||
|
||||
/** 同分类连续排列,两级表头才能成段 */
|
||||
const columns = computed<any[]>(() => {
|
||||
const list = [...visiblePlugins.value]
|
||||
const order: string[] = []
|
||||
for (const p of list) {
|
||||
const c = catOf(p)
|
||||
if (!order.includes(c)) order.push(c)
|
||||
}
|
||||
return list.sort((a, b) => order.indexOf(catOf(a)) - order.indexOf(catOf(b)))
|
||||
})
|
||||
|
||||
const totalPages = computed(() => Math.max(1, Math.ceil(columns.value.length / pageSize.value)))
|
||||
|
||||
/** 当前页要渲染的插件列(账号行不参与分页) */
|
||||
const pagedColumns = computed(() =>
|
||||
columns.value.slice((page.value - 1) * pageSize.value, page.value * pageSize.value)
|
||||
)
|
||||
|
||||
/** 只有出现多个分类、或唯一分类有实际业务名时才需要分类分组行(全是「未分类」时不加那条灰带) */
|
||||
const hasGroups = computed(() => {
|
||||
if (catFilter.value) return false
|
||||
const set = new Set(pagedColumns.value.map(catOf))
|
||||
if (set.size > 1) return true
|
||||
return set.size === 1 && !set.has('未分类')
|
||||
})
|
||||
|
||||
const rangeText = computed(() => {
|
||||
const total = columns.value.length
|
||||
if (!total) return '0 / 0 列'
|
||||
const from = (page.value - 1) * pageSize.value + 1
|
||||
const to = Math.min(total, page.value * pageSize.value)
|
||||
return `${from}-${to} / 共 ${total} 列`
|
||||
})
|
||||
|
||||
const pluginGroups = computed(() => {
|
||||
const out: { label: string; span: number }[] = []
|
||||
for (const p of pagedColumns.value) {
|
||||
const label = catOf(p)
|
||||
const last = out[out.length - 1]
|
||||
if (last && last.label === label) last.span += 1
|
||||
else out.push({ label, span: 1 })
|
||||
}
|
||||
if (!hasGroups.value) return []
|
||||
// 单分类时合并成一个分组标签,避免被分页切断成多段
|
||||
return out.length > 1 ? out : [{ label: out[0].label, span: out[0].span }]
|
||||
})
|
||||
|
||||
watch([picked, pluginKw, onlyGrantedPlugins, catFilter, pageSize], () => {
|
||||
page.value = 1
|
||||
})
|
||||
watch(totalPages, (tp) => {
|
||||
if (page.value > tp) page.value = tp
|
||||
})
|
||||
|
||||
const rows = computed(() => {
|
||||
const kwv = kw.value.trim().toLowerCase()
|
||||
return (props.matrix.accounts || []).filter((a: any) => {
|
||||
const kwOk =
|
||||
!kwv ||
|
||||
String(a.account).toLowerCase().includes(kwv) ||
|
||||
String(a.nickname || '')
|
||||
.toLowerCase()
|
||||
.includes(kwv)
|
||||
const deptOk = !deptFilter.value || a.dept === deptFilter.value
|
||||
const grantedOk = !onlyGranted.value || grantedCountByAccount.value.has(String(a.account))
|
||||
return kwOk && deptOk && grantedOk
|
||||
})
|
||||
})
|
||||
|
||||
/** 悬停列高亮,缓解长表横向串行 */
|
||||
const hoverCol = ref('')
|
||||
const isPinned = (id: string) => picked.value.length === 1 && picked.value[0] === id
|
||||
|
||||
function focusPlugin(id: string) {
|
||||
picked.value = isPinned(id) ? [] : [id]
|
||||
}
|
||||
|
||||
const toggling = ref(false)
|
||||
|
||||
async function toggle(account: string, pluginId: string, field: 'can_download' | 'can_run') {
|
||||
if (toggling.value) return
|
||||
const cur = cellOf(account, pluginId)
|
||||
const next = {
|
||||
can_download: !!cur?.can_download,
|
||||
can_run: !!cur?.can_run,
|
||||
[field]: !cur?.[field]
|
||||
}
|
||||
toggling.value = true
|
||||
try {
|
||||
const granted = next.can_download || next.can_run
|
||||
await grantPlugin({ account, plugin_id: pluginId, granted, ...next })
|
||||
emit('changed')
|
||||
} catch {
|
||||
ElMessage.error('切换失败')
|
||||
} finally {
|
||||
toggling.value = false
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div>
|
||||
<!-- 工具条 1:账号维度 -->
|
||||
<!-- 工具条 1:账号筛选 + 状态图例 -->
|
||||
<div class="flex items-center gap-3 mb-2 flex-wrap">
|
||||
<el-input v-model="kw" placeholder="搜索账号 / 昵称" clearable style="width: 200px" />
|
||||
<el-select v-model="deptFilter" placeholder="全部部门" clearable style="width: 130px">
|
||||
<span class="text-xs text-gray-400 shrink-0">账号</span>
|
||||
<el-input
|
||||
v-model="kw"
|
||||
placeholder="搜索账号 / 昵称"
|
||||
clearable
|
||||
size="small"
|
||||
style="width: 190px"
|
||||
/>
|
||||
<el-select
|
||||
v-model="deptFilter"
|
||||
placeholder="全部部门"
|
||||
clearable
|
||||
size="small"
|
||||
style="width: 130px"
|
||||
>
|
||||
<el-option v-for="d in deptOptions" :key="d" :label="d" :value="d" />
|
||||
</el-select>
|
||||
<el-switch v-model="onlyGranted" size="small" active-text="仅看已授权账号" />
|
||||
<div class="ml-auto flex items-center gap-2 text-xs text-gray-400">
|
||||
<span>图例:</span>
|
||||
<el-tag size="small" type="success" effect="light">下载+运行</el-tag>
|
||||
<el-tag size="small" type="warning" effect="light">部分授权</el-tag>
|
||||
<el-tag size="small" type="info" effect="plain">未授权</el-tag>
|
||||
|
||||
<div class="ml-auto flex items-center gap-2.5 text-xs text-gray-400 flex-wrap">
|
||||
<span class="inline-flex items-center gap-1">
|
||||
格内 <i class="legend-chip is-on">下</i> = 允许下载
|
||||
<i class="legend-chip is-on">运</i> = 允许运行
|
||||
</span>
|
||||
<span class="w-px h-3.5 bg-[var(--el-border-color)]" />
|
||||
<span class="inline-flex items-center gap-1">
|
||||
<i class="legend-chip is-on">下</i>
|
||||
<i class="legend-chip is-on">运</i>
|
||||
<span class="ml-0.5">完整授权</span>
|
||||
</span>
|
||||
<span class="inline-flex items-center gap-1">
|
||||
<i class="legend-chip is-on">下</i>
|
||||
<i class="legend-chip">运</i>
|
||||
<span class="ml-0.5">部分授权</span>
|
||||
</span>
|
||||
<span class="inline-flex items-center gap-1">
|
||||
<i class="legend-chip">下</i>
|
||||
<i class="legend-chip">运</i>
|
||||
<span class="ml-0.5">未授权</span>
|
||||
</span>
|
||||
<el-popover placement="bottom-end" trigger="click" :width="300">
|
||||
<template #reference>
|
||||
<el-button size="small" text bg circle>
|
||||
<ArtSvgIcon icon="ri:question-line" />
|
||||
</el-button>
|
||||
</template>
|
||||
<div class="text-xs leading-6 text-g-600">
|
||||
<div class="font-semibold mb-1">怎么看这张表</div>
|
||||
<div>· 行 = 账号,列 = 插件,交叉格 = 这个人对这个插件有什么权限。</div>
|
||||
<div>· 格内两个按钮:<b>下</b> 允许下载安装,<b>运</b> 允许在本机运行。</div>
|
||||
<div>· 点一下即开/关并立即保存;两个都关掉,等于撤销这个插件的授权。</div>
|
||||
<div>· 绿底 = 下载+运行都有;黄底 = 只开了一项;白底 = 未授权。</div>
|
||||
<div>· 列头 <ArtSvgIcon icon="ri:eye-line" /> 按钮可只看该插件,再点一次恢复。</div>
|
||||
</div>
|
||||
</el-popover>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -222,13 +311,15 @@ async function toggle(account: string, pluginId: string, field: 'can_download' |
|
||||
|
||||
<!-- 工具条 3:插件列筛选 + 分页 -->
|
||||
<div class="flex items-center gap-3 mb-3 flex-wrap">
|
||||
<span class="text-xs text-gray-400 shrink-0">插件列</span>
|
||||
<el-select
|
||||
v-model="picked"
|
||||
multiple
|
||||
filterable
|
||||
collapse-tags
|
||||
collapse-tags-tooltip
|
||||
placeholder="全部插件列"
|
||||
placeholder="全部插件"
|
||||
size="small"
|
||||
style="width: 220px"
|
||||
>
|
||||
<el-option
|
||||
@@ -238,18 +329,24 @@ async function toggle(account: string, pluginId: string, field: 'can_download' |
|
||||
:value="p.id"
|
||||
/>
|
||||
</el-select>
|
||||
<el-input v-model="pluginKw" placeholder="搜索插件名 / ID / 分类" clearable style="width: 190px" />
|
||||
<el-input
|
||||
v-model="pluginKw"
|
||||
placeholder="搜索插件名 / ID"
|
||||
clearable
|
||||
size="small"
|
||||
style="width: 170px"
|
||||
/>
|
||||
<el-switch v-model="onlyGrantedPlugins" size="small" active-text="仅看已授权插件" />
|
||||
<el-switch v-model="compact" size="small" active-text="紧凑模式" />
|
||||
<el-button v-if="picked.length" size="small" text bg @click="picked = []">
|
||||
显示全部插件列
|
||||
取消只看({{ picked.length }})
|
||||
</el-button>
|
||||
|
||||
<div class="ml-auto flex items-center gap-2">
|
||||
<span class="text-xs text-gray-400">
|
||||
账号 {{ rows.length }} / {{ (matrix.accounts || []).length }}
|
||||
</span>
|
||||
<span class="text-xs text-gray-400">·</span>
|
||||
<el-divider direction="vertical" />
|
||||
<span class="text-xs text-gray-400">{{ rangeText }}</span>
|
||||
<template v-if="totalPages > 1">
|
||||
<el-button size="small" :disabled="page <= 1" @click="page--">上一页</el-button>
|
||||
@@ -264,11 +361,11 @@ async function toggle(account: string, pluginId: string, field: 'can_download' |
|
||||
|
||||
<!-- 矩阵 -->
|
||||
<el-scrollbar :max-height="compact ? 560 : 520" class="border border-g-300/50 rounded-lg">
|
||||
<table class="matrix-table" :class="{ 'is-compact': compact }">
|
||||
<table class="matrix-table" :class="{ 'is-compact': compact, 'has-groups': hasGroups }">
|
||||
<thead>
|
||||
<tr class="group-row">
|
||||
<tr v-if="hasGroups" class="group-row">
|
||||
<th class="sticky-col">
|
||||
<div class="text-xs text-gray-400 font-normal">账号 / 插件</div>
|
||||
<span class="text-[11px] text-gray-400 font-normal">插件分类</span>
|
||||
</th>
|
||||
<th
|
||||
v-for="(g, gi) in pluginGroups"
|
||||
@@ -281,24 +378,40 @@ async function toggle(account: string, pluginId: string, field: 'can_download' |
|
||||
</tr>
|
||||
<tr>
|
||||
<th class="sticky-col">
|
||||
<div class="text-xs text-gray-400 font-normal">账号 / 插件</div>
|
||||
<div class="flex items-center gap-1 text-[11px] text-gray-400 font-normal">
|
||||
<span>账号</span>
|
||||
<ArtSvgIcon icon="ri:arrow-down-line" class="text-[10px]" />
|
||||
<span>插件</span>
|
||||
<ArtSvgIcon icon="ri:arrow-right-line" class="text-[10px]" />
|
||||
</div>
|
||||
</th>
|
||||
<th
|
||||
v-for="p in pagedColumns"
|
||||
:key="p.id"
|
||||
class="plugin-col"
|
||||
:class="{ 'col-active': hoverCol === p.id }"
|
||||
:title="`${p.name}(${p.id})· 点击只看此插件`"
|
||||
@click="focusPlugin(p.id)"
|
||||
:class="{ 'col-active': hoverCol === p.id, 'is-pinned': isPinned(p.id) }"
|
||||
:title="`${p.name}(${p.id})· v${p.latest_version}`"
|
||||
@mouseenter="hoverCol = p.id"
|
||||
@mouseleave="hoverCol = ''"
|
||||
>
|
||||
<div class="font-medium text-[13px] name">{{ p.name }}</div>
|
||||
<div v-if="!compact" class="text-[11px] text-gray-400 font-normal">
|
||||
v{{ p.latest_version }}
|
||||
<span v-if="p.status && p.status !== 'published'" class="text-gray-400">
|
||||
· {{ p.status }}
|
||||
</span>
|
||||
<div class="flex items-center gap-1 justify-center">
|
||||
<span class="name font-medium text-[13px]">{{ p.name }}</span>
|
||||
<button
|
||||
class="pin-btn"
|
||||
:class="{ 'is-on': isPinned(p.id) }"
|
||||
:title="isPinned(p.id) ? '恢复显示全部插件列' : '只看此插件'"
|
||||
@click.stop="focusPlugin(p.id)"
|
||||
>
|
||||
<ArtSvgIcon icon="ri:eye-line" />
|
||||
</button>
|
||||
</div>
|
||||
<div v-if="!compact" class="text-[11px] text-gray-400 font-normal mt-0.5">
|
||||
{{ grantedCountByPlugin.get(p.id) || 0 }} 人已授权
|
||||
<span
|
||||
v-if="p.status && p.status !== 'published'"
|
||||
class="text-[var(--el-color-warning)]"
|
||||
>· {{ p.status }}</span
|
||||
>
|
||||
</div>
|
||||
</th>
|
||||
<th v-if="!pagedColumns.length">无匹配插件列</th>
|
||||
@@ -314,55 +427,75 @@ async function toggle(account: string, pluginId: string, field: 'can_download' |
|
||||
{{ (a.nickname || a.account || '?').slice(0, 1).toUpperCase() }}
|
||||
</div>
|
||||
<div class="min-w-0">
|
||||
<div class="text-sm leading-tight truncate">{{ a.nickname || a.account }}</div>
|
||||
<div class="text-[11px] text-gray-400 truncate">{{ a.account }} · {{ a.dept || '—' }}</div>
|
||||
<div class="text-sm leading-tight truncate flex items-center gap-1.5">
|
||||
<span class="truncate">{{ a.nickname || a.account }}</span>
|
||||
<span v-if="a.status === 0" class="badge-off">停用</span>
|
||||
</div>
|
||||
<div class="text-[11px] text-gray-400 truncate"
|
||||
>{{ a.account }} · {{ a.dept || '—' }}</div
|
||||
>
|
||||
</div>
|
||||
<el-tag
|
||||
v-if="grantedCountByAccount.get(a.account)"
|
||||
size="small"
|
||||
type="primary"
|
||||
effect="light"
|
||||
round
|
||||
class="shrink-0 ml-auto"
|
||||
:title="`已授权 ${grantedCountByAccount.get(a.account)} 个插件`"
|
||||
>
|
||||
{{ grantedCountByAccount.get(a.account) }}
|
||||
</el-tag>
|
||||
</div>
|
||||
</td>
|
||||
<td
|
||||
v-for="p in pagedColumns"
|
||||
:key="p.id"
|
||||
align="center"
|
||||
class="perm-cell"
|
||||
:class="[`state-${cellState(a.account, p.id)}`, { 'col-active': hoverCol === p.id }]"
|
||||
@mouseenter="hoverCol = p.id"
|
||||
@mouseleave="hoverCol = ''"
|
||||
>
|
||||
<div class="flex items-center justify-center gap-1.5">
|
||||
<el-tag
|
||||
size="small"
|
||||
:type="cellOf(a.account, p.id)?.can_download ? 'success' : 'info'"
|
||||
:effect="cellOf(a.account, p.id)?.can_download ? 'light' : 'plain'"
|
||||
class="cursor-pointer select-none cell-tag"
|
||||
:title="cellOf(a.account, p.id)?.can_download ? '允许下载(点击撤销)' : '禁止下载(点击放行)'"
|
||||
<div class="flex items-center justify-center gap-1">
|
||||
<button
|
||||
class="perm-chip"
|
||||
:class="{ 'is-on': pinOf(a.account, p.id, 'can_download') }"
|
||||
:title="
|
||||
pinOf(a.account, p.id, 'can_download') ? '已允许下载,点击关闭' : '点击允许下载'
|
||||
"
|
||||
:disabled="toggling"
|
||||
@click="toggle(a.account, p.id, 'can_download')"
|
||||
>
|
||||
⬇
|
||||
</el-tag>
|
||||
<el-tag
|
||||
size="small"
|
||||
:type="cellOf(a.account, p.id)?.can_run ? 'success' : 'info'"
|
||||
:effect="cellOf(a.account, p.id)?.can_run ? 'light' : 'plain'"
|
||||
class="cursor-pointer select-none cell-tag"
|
||||
:title="cellOf(a.account, p.id)?.can_run ? '允许运行(点击撤销)' : '禁止运行(点击放行)'"
|
||||
下
|
||||
</button>
|
||||
<button
|
||||
class="perm-chip"
|
||||
:class="{ 'is-on': pinOf(a.account, p.id, 'can_run') }"
|
||||
:title="
|
||||
pinOf(a.account, p.id, 'can_run') ? '已允许运行,点击关闭' : '点击允许运行'
|
||||
"
|
||||
:disabled="toggling"
|
||||
@click="toggle(a.account, p.id, 'can_run')"
|
||||
>
|
||||
▶
|
||||
</el-tag>
|
||||
运
|
||||
</button>
|
||||
</div>
|
||||
</td>
|
||||
<td v-if="!pagedColumns.length" align="center">—</td>
|
||||
</tr>
|
||||
<tr v-if="!rows.length">
|
||||
<td :colspan="pagedColumns.length + 1" align="center" class="py-8 text-gray-400 text-sm">
|
||||
无匹配账号
|
||||
<td :colspan="pagedColumns.length + 1" align="center" class="py-6">
|
||||
<el-empty description="没有匹配的账号" :image-size="60" />
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</el-scrollbar>
|
||||
|
||||
<div class="mt-2 text-xs text-gray-400">
|
||||
点击单元格内的 ⬇ / ▶ 徽标切换对应权限;下载与运行都关闭时自动撤销整条授权。点击插件列头可只看该插件;
|
||||
插件多时先用「插件分类」Tab 收窄,再按需翻页。
|
||||
绿底 = 下载与运行都已允许;黄底 = 只开了一项;白底 =
|
||||
未授权。点格子里的「下」「运」即时生效,两个都关掉即撤销该授权。
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@@ -390,30 +523,62 @@ async function toggle(account: string, pluginId: string, field: 'can_download' |
|
||||
z-index: 2;
|
||||
text-align: center;
|
||||
}
|
||||
/* 分组行固定在更上层,插件行紧随其后 */
|
||||
/* 分组行固定在更上层,插件行紧随其后下移 30px(重叠 1px 消缝) */
|
||||
.matrix-table thead .group-row th {
|
||||
top: 0;
|
||||
height: 26px;
|
||||
padding: 3px 10px;
|
||||
height: 30px;
|
||||
padding: 0 10px;
|
||||
font-size: 11px;
|
||||
font-weight: 600;
|
||||
color: var(--el-text-color-secondary);
|
||||
letter-spacing: 0.3px;
|
||||
}
|
||||
.matrix-table thead tr:not(.group-row) th {
|
||||
top: 32px;
|
||||
cursor: pointer;
|
||||
.matrix-table.has-groups thead tr:not(.group-row) th {
|
||||
top: 29px;
|
||||
}
|
||||
.matrix-table .plugin-col {
|
||||
max-width: 132px;
|
||||
min-width: 96px;
|
||||
cursor: default;
|
||||
}
|
||||
.matrix-table .plugin-col .name {
|
||||
max-width: 116px;
|
||||
max-width: 104px;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.matrix-table .plugin-col.is-pinned {
|
||||
background: var(--el-color-primary-light-9);
|
||||
}
|
||||
|
||||
/* 列头「只看」按钮:常显低透明度,悬停变亮,避免整列头点击误触 */
|
||||
.pin-btn {
|
||||
display: inline-grid;
|
||||
place-items: center;
|
||||
width: 18px;
|
||||
height: 18px;
|
||||
border-radius: 4px;
|
||||
border: none;
|
||||
background: transparent;
|
||||
color: var(--el-text-color-placeholder);
|
||||
opacity: 0.55;
|
||||
font-size: 12px;
|
||||
cursor: pointer;
|
||||
transition: all 0.15s;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
.matrix-table th:hover .pin-btn,
|
||||
.pin-btn.is-on {
|
||||
opacity: 1;
|
||||
color: var(--el-color-primary);
|
||||
}
|
||||
.pin-btn.is-on {
|
||||
background: var(--el-color-primary-light-8);
|
||||
}
|
||||
.pin-btn:hover {
|
||||
background: var(--el-color-primary-light-8);
|
||||
}
|
||||
|
||||
.matrix-table .sticky-col {
|
||||
position: sticky;
|
||||
left: 0;
|
||||
@@ -448,10 +613,72 @@ async function toggle(account: string, pluginId: string, field: 'can_download' |
|
||||
.matrix-table tbody tr:hover td.state-partial {
|
||||
background: var(--el-color-warning-light-8);
|
||||
}
|
||||
.cell-tag {
|
||||
font-size: 12px;
|
||||
padding: 0 7px;
|
||||
|
||||
/* 权限按钮:开=实心绿,关=灰色空心,中文单字不需要猜符号含义 */
|
||||
.perm-chip {
|
||||
width: 26px;
|
||||
height: 21px;
|
||||
padding: 0;
|
||||
border-radius: 5px;
|
||||
border: 1px solid var(--el-border-color);
|
||||
background: var(--el-bg-color);
|
||||
color: var(--el-text-color-placeholder);
|
||||
font-size: 11px;
|
||||
line-height: 1;
|
||||
display: inline-grid;
|
||||
place-items: center;
|
||||
cursor: pointer;
|
||||
transition: all 0.15s;
|
||||
}
|
||||
.perm-chip:hover:not(:disabled) {
|
||||
border-color: var(--el-color-primary);
|
||||
color: var(--el-color-primary);
|
||||
}
|
||||
.perm-chip.is-on {
|
||||
background: var(--el-color-success);
|
||||
border-color: var(--el-color-success);
|
||||
color: #fff;
|
||||
font-weight: 600;
|
||||
}
|
||||
.perm-chip.is-on:hover:not(:disabled) {
|
||||
background: var(--el-color-success-dark-2);
|
||||
border-color: var(--el-color-success-dark-2);
|
||||
color: #fff;
|
||||
}
|
||||
.perm-chip:disabled {
|
||||
cursor: not-allowed;
|
||||
opacity: 0.6;
|
||||
}
|
||||
|
||||
.legend-chip {
|
||||
width: 22px;
|
||||
height: 18px;
|
||||
border-radius: 4px;
|
||||
border: 1px solid var(--el-border-color);
|
||||
background: var(--el-bg-color);
|
||||
color: var(--el-text-color-placeholder);
|
||||
font-size: 10px;
|
||||
font-style: normal;
|
||||
display: inline-grid;
|
||||
place-items: center;
|
||||
}
|
||||
.legend-chip.is-on {
|
||||
background: var(--el-color-success);
|
||||
border-color: var(--el-color-success);
|
||||
color: #fff;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.badge-off {
|
||||
font-size: 10px;
|
||||
line-height: 14px;
|
||||
padding: 0 4px;
|
||||
border-radius: 3px;
|
||||
background: var(--el-fill-color);
|
||||
color: var(--el-text-color-secondary);
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
/* 紧凑模式:压窄列宽,塞下更多插件列 */
|
||||
.matrix-table.is-compact th,
|
||||
.matrix-table.is-compact td {
|
||||
@@ -462,11 +689,12 @@ async function toggle(account: string, pluginId: string, field: 'can_download' |
|
||||
min-width: 64px;
|
||||
}
|
||||
.matrix-table.is-compact .plugin-col .name {
|
||||
max-width: 66px;
|
||||
max-width: 52px;
|
||||
font-size: 12px;
|
||||
}
|
||||
.matrix-table.is-compact .cell-tag {
|
||||
padding: 0 4px;
|
||||
font-size: 11px;
|
||||
.matrix-table.is-compact .perm-chip {
|
||||
width: 22px;
|
||||
height: 18px;
|
||||
font-size: 10px;
|
||||
}
|
||||
</style>
|
||||
|
||||
Reference in New Issue
Block a user