Files
yhy-mager/frontend/src/views/Overview.vue
xiewenjun 09910db251
Some checks failed
Check / delivery-static (push) Has been cancelled
Check / api (push) Has been cancelled
Check / web (push) Has been cancelled
feat: localize license states and restore revoked licenses
Co-Authored-By: Craft Agent <agents-noreply@craft.do>
2026-10-12 16:11:09 +08:00

144 lines
26 KiB
Vue

<script setup lang="ts">
import { formatDateTime } from '../date-format'
import { computed, onMounted, ref, watch } from 'vue'
import { useRoute, useRouter } from 'vue-router'
import DashboardPanel from './DashboardPanel.vue'
import AuditPanel from './AuditPanel.vue'
import SettingsPanel from './SettingsPanel.vue'
import AdminsPanel from './AdminsPanel.vue'
import IntegrationPanel from './IntegrationPanel.vue'
import TrustDeliveryPanel from './TrustDeliveryPanel.vue'
import InstanceProvisionPanel from './InstanceProvisionPanel.vue'
import { getSettings, type SiteSettings } from '../admin-api'
const siteSettings = ref<SiteSettings|null>(null)
async function loadSiteSettings() { try { siteSettings.value = (await getSettings()).data.data } catch { siteSettings.value = null } }
import { getLicense } from '../api'
import { ElMessage, ElMessageBox } from 'element-plus'
import { createCustomer, createProduct, deleteCustomer, deleteLicense, deleteProduct, issueLicense, listCustomers, listLicenses, listProducts, login, logout, me, renewLicense, revokeLicense, restoreLicense, type Customer, type License, type Product } from '../api'
import { checkApiHealth, type Connection } from '../api-health'
import OrdersPanel from './OrdersPanel.vue'
import ReleasesPanel from './ReleasesPanel.vue'
import { listLicenseInstances, setInstanceFrozen, type LicenseInstance } from '../api'
const selectedLicenseID = ref<number | null>(null), changingInstance = ref('')
const freezeRetries = new Map<string, { frozen: boolean; key: string }>()
async function changeFreeze(instance: LicenseInstance) {
if (changingInstance.value) return
const frozen = instance.freeze_state !== 'frozen'
try { await ElMessageBox.confirm(frozen ? '确认冻结该实例?离线旧租约不会立即失效。' : '确认恢复该实例?撤销的授权不会因此恢复。', frozen ? '冻结确认' : '恢复确认') } catch { return }
const previous = freezeRetries.get(instance.instance_id)
const retry = previous?.frozen === frozen ? previous : { frozen, key: crypto.randomUUID() }
freezeRetries.set(instance.instance_id, retry)
changingInstance.value = instance.instance_id
try { await setInstanceFrozen(instance.instance_id, frozen, retry.key); freezeRetries.delete(instance.instance_id); if (selectedLicenseID.value !== null) await showInstances(selectedLicenseID.value) } catch (e) { instanceError.value = e instanceof Error ? e.message : '状态更新失败' } finally { changingInstance.value = '' }
}
const instanceDrawer = ref(false), instancesLoading = ref(false), instanceError = ref(''), instances = ref<LicenseInstance[]>([])
async function showInstances(id:number) { selectedLicenseID.value = id; instanceDrawer.value = true; instancesLoading.value = true; instanceError.value = ''; instances.value = []; try { instances.value = (await listLicenseInstances(id)).data.data } catch (e) { instanceError.value = e instanceof Error ? e.message : '实例加载失败' } finally { instancesLoading.value = false } }
const route = useRoute() || ({ meta: {}, query: {} } as ReturnType<typeof useRoute>)
const router = useRouter() || ({ push: async () => undefined, replace: async () => undefined } as unknown as ReturnType<typeof useRouter>)
const pageView = computed(() => route.meta.view as string || 'dashboard')
const title=computed(()=>({dashboard:'仪表盘',licenses:'License 授权',customers:'客户管理',products:'产品目录',orders:'订单与套餐',releases:'版本管理',integration:'客户端接入',audit:'审计日志',settings:'系统设置',admins:'管理员账户'}[pageView.value] || '仪表盘'))
const nav=[{view:'dashboard',path:'/',name:'仪表盘',icon:'▦'},{view:'licenses',path:'/licenses',name:'License 授权',icon:'◇'},{view:'customers',path:'/customers',name:'客户管理',icon:'♙'},{view:'products',path:'/products',name:'产品目录',icon:'◫'},{view:'orders',path:'/orders',name:'订单与套餐',icon:'▤'},{view:'releases',path:'/releases',name:'版本管理',icon:'↥'},{view:'integration',path:'/integration',name:'客户端接入',icon:'⌘'},{view:'audit',path:'/audit',name:'审计日志',icon:'≡'},{view:'settings',path:'/settings',name:'系统设置',icon:'⚙'},{view:'admins',path:'/admins',name:'管理员账户',icon:'♙'}]
const adminEmail=ref('管理员'), detail=ref<License|null>(null),detailOpen=ref(false),detailLoading=ref(false),detailError=ref('')
async function showDetail(id:number){detailOpen.value=true;detail.value=null;detailError.value='';detailLoading.value=true;try{detail.value=(await getLicense(id)).data.data}catch(e){detailError.value=e instanceof Error?e.message:'详情加载失败'}finally{detailLoading.value=false}}
async function openIssue(){await router.push('/licenses');document.getElementById('license-issue')?.scrollIntoView({behavior:'smooth'})}
watch(()=>route.query.status,(value)=>{licensePage.value=1;licenseStatus.value=String(value??'');if(loggedIn.value)refresh()})
const loggedIn = ref(false), username = ref(''), password = ref(''), loading = ref(false), error = ref(''), connection = ref<Connection>('checking')
const customers = ref<Customer[]>([]), products = ref<Product[]>([]), licenses = ref<License[]>([]), customerTotal = ref(0), licenseTotal = ref(0), query = ref(''), licenseQuery=ref(String(route.query.q??'')), licenseStatus=ref(String(route.query.status??'')), customerPage=ref(1)
const issueForm = ref({ customer_id: null as number | null, product_id: null as number | null, starts_at: new Date().toISOString(), expires_at: new Date(Date.now() + 365 * 86400000).toISOString() })
const issuing = ref(false), licensePage = ref(1)
let pendingIssue: { body: string; key: string } | null = null
const pendingLicenseOps = new Map<string, { body: string; key: string }>()
function statusLabel(status:string) { return ({active:'有效',scheduled:'未开始',pending:'未开始',expired:'已到期',revoked:'已撤销',activated:'已激活',provisioned:'未激活',not_activated:'未激活',frozen:'已冻结',none:'未冻结',unknown:'未知'} as Record<string,string>)[status] ?? '未知' }
const restoringLicense = ref<number|null>(null)
async function restore(id:number) {
if (restoringLicense.value !== null) return
try { await ElMessageBox.confirm('恢复后沿用原有效期和实例绑定。已过期授权仍需续期,冻结实例仍需解除冻结;客户端将在下一次心跳时获取恢复后的状态。确认恢复?', '恢复授权确认', { confirmButtonText:'恢复授权', cancelButtonText:'取消' }) } catch { return }
const operation = `restore:${id}`, body = '{}', previous = pendingLicenseOps.get(operation)
const retry = previous ?? { body, key:crypto.randomUUID() }
pendingLicenseOps.set(operation, retry)
restoringLicense.value = id
try { await restoreLicense(id, retry.key); pendingLicenseOps.delete(operation); ElMessage.success('授权已恢复'); await refresh(); if (selectedLicenseID.value === id) await showInstances(id) } catch (e) { ElMessage.error(e instanceof Error ? e.message : '恢复失败') } finally { restoringLicense.value = null }
}
const newCustomer = ref({ name: '', contact_email: '' }), newProduct = ref({ code: '', name: '', description: '' })
async function refresh() { loading.value = true; error.value = ''; try { const [cs, ps, ls] = await Promise.all([listCustomers({ q: query.value, page:customerPage.value }), listProducts(), listLicenses({ page: licensePage.value, q:licenseQuery.value, status:String(route.query.status??licenseStatus.value) })]); customers.value = cs.data.data; customerTotal.value = cs.data.meta.total; products.value = ps.data.data; licenses.value = ls.data.data; licenseTotal.value = ls.data.meta.total } catch (e) { error.value = e instanceof Error ? e.message : '加载失败' } finally { loading.value = false } }
async function checkConnection() { connection.value = 'checking'; connection.value = await checkApiHealth() }
async function checkSession() { try { const session=await me(); adminEmail.value=session.data.data.username || session.data.data.email || '管理员'; loggedIn.value = true; await Promise.all([loadSiteSettings(), refresh()]) } catch { loggedIn.value = false } }
async function signIn() { loading.value = true; error.value = ''; try { const session=await login(username.value, password.value); adminEmail.value=session.data.data.username; loggedIn.value = true; password.value = ''; await Promise.all([loadSiteSettings(), refresh()]) } catch (e) { error.value = e instanceof Error ? e.message : '登录失败' } finally { loading.value = false } }
async function signOut() { await logout(); loggedIn.value = false; customers.value = []; products.value = [] }
async function addCustomer() { try { await createCustomer(newCustomer.value); newCustomer.value = { name: '', contact_email: '' }; ElMessage.success('客户已创建'); await refresh() } catch (e) { ElMessage.error(e instanceof Error ? e.message : '创建失败') } }
async function addProduct() { try { await createProduct(newProduct.value); newProduct.value = { code: '', name: '', description: '' }; ElMessage.success('产品已创建'); await refresh() } catch (e) { ElMessage.error(e instanceof Error ? e.message : '创建失败') } }
async function issue() {
if (issuing.value) return
issuing.value = true
try {
if (!issueForm.value.customer_id || !issueForm.value.product_id) throw new Error('请选择客户和产品')
const payload = { customer_id: issueForm.value.customer_id, product_id: issueForm.value.product_id, starts_at: new Date(issueForm.value.starts_at).toISOString(), expires_at: new Date(issueForm.value.expires_at).toISOString() }
const body = JSON.stringify(payload)
if (!pendingIssue || pendingIssue.body !== body) pendingIssue = { body, key: crypto.randomUUID() }
await issueLicense(payload, pendingIssue.key)
pendingIssue = null
licensePage.value = 1
ElMessage.success('授权已签发')
await refresh()
} catch (e) { ElMessage.error(e instanceof Error ? e.message : '签发失败') }
finally { issuing.value = false }
}
async function removeCustomer(id:number) { await ElMessageBox.confirm('确认删除该客户?','删除确认'); await deleteCustomer(id); await refresh() }
async function removeProduct(id:number) { await ElMessageBox.confirm('确认删除该产品?','删除确认'); await deleteProduct(id); await refresh() }
async function removeLicense(id:number) {
try { await ElMessageBox.confirm('仅未激活的授权可删除。删除将清理预置实例和操作记录、解除关联订单的授权引用,并保留审计摘要;此操作不可恢复。确认继续?', '删除授权确认', { type: 'warning', confirmButtonText: '永久删除', cancelButtonText: '取消' }) } catch { return }
try { await deleteLicense(id); ElMessage.success('授权已删除'); await refresh() } catch (e) { ElMessage.error(e instanceof Error ? e.message : '删除失败') }
}
async function revoke(id:number) {
try { await ElMessageBox.confirm('撤销将影响该授权下所有实例。后续可恢复授权,客户端在下一次心跳时获取状态;离线旧租约不会立即失效。确认继续?','撤销确认') } catch { return }
const operation = `revoke:${id}`, body = '{}', previous = pendingLicenseOps.get(operation)
const retry = previous && previous.body === body ? previous : { body, key: crypto.randomUUID() }
pendingLicenseOps.set(operation, retry)
try { await revokeLicense(id, retry.key); pendingLicenseOps.delete(operation); ElMessage.success('授权已撤销'); await refresh() } catch (e) { ElMessage.error(e instanceof Error ? e.message : '撤销失败') }
}
const renewalLicense = ref<License|null>(null), renewalOpen = ref(false), renewing = ref(false)
const renewalDate = ref<Date|null>(null), renewalError = ref('')
function renew(license:License) {
renewalLicense.value = license
const initial = new Date(Math.max(Date.now(), new Date(license.expires_at).getTime()))
initial.setFullYear(initial.getFullYear() + 1)
renewalDate.value = initial
renewalError.value = ''
renewalOpen.value = true
}
function disabledRenewalDate(date:Date) {
if (!renewalLicense.value) return false
const earliest = new Date(renewalLicense.value.expires_at)
earliest.setHours(0, 0, 0, 0)
return date.getTime() < earliest.getTime()
}
async function submitRenewal() {
if (renewing.value || !renewalLicense.value) return
renewalError.value = ''
const selected = renewalDate.value ? new Date(renewalDate.value) : null
if (!selected || !Number.isFinite(selected.getTime())) { renewalError.value = '请选择新的到期时间'; return }
if (selected.getTime() <= new Date(renewalLicense.value.expires_at).getTime()) { renewalError.value = '新的到期时间必须晚于当前到期时间'; return }
const id = renewalLicense.value.id, expiresAt = selected.toISOString()
const operation = `renew:${id}`, body = JSON.stringify({ expires_at: expiresAt }), previous = pendingLicenseOps.get(operation)
const retry = previous && previous.body === body ? previous : { body, key: crypto.randomUUID() }
pendingLicenseOps.set(operation, retry)
renewing.value = true
try { await renewLicense(id,expiresAt,retry.key); pendingLicenseOps.delete(operation); renewalOpen.value = false; ElMessage.success('授权已续期'); await refresh() } catch (e) { renewalError.value = e instanceof Error ? e.message : '续期失败' } finally { renewing.value = false }
}
onMounted(() => { checkConnection(); checkSession() })
</script>
<template>
<div class="workspace" :class="{'admin-workspace':loggedIn}"><aside v-if="loggedIn" class="sidebar"><div class="brand"><span class="brand-mark">L</span><div>{{siteSettings?.site_name || 'License Hub'}}<small>统一授权管理平台</small></div></div><nav class="nav" aria-label="管理台导航"><template v-for="(item,index) in nav" :key="item.path"><div v-if="index===0||index===1||index===6" class="nav-label">{{index===0?'工作台':index===1?'业务管理':'系统'}}</div><router-link :to="item.path" :class="{active:pageView===item.view}" :title="item.name"><span class="ico">{{item.icon}}</span><span>{{item.name}}</span></router-link></template></nav><div class="sidebar-footer"><span class="user-dot">{{adminEmail.slice(0,1).toUpperCase()}}</span><span>{{adminEmail}}</span></div></aside><div class="main"><header class="topbar"><span v-if="loggedIn" class="crumb">{{pageView==='dashboard'?'工作台':'管理台'}} <strong>/ {{title}}</strong></span><span v-else class="wordmark"><span class="mark">L</span>License Hub</span><span class="environment">内部管理台 <el-button v-if="loggedIn" link @click="signOut">退出</el-button></span></header>
<main class="content" v-if="!loggedIn"><section class="status-section" aria-labelledby="api-title"><div><h2 id="api-title">API 连通性</h2><p>服务状态仅表示存活端点可访问。</p></div><div><span class="status" :class="connection" role="status">{{ connection === 'checking' ? '检测中' : connection === 'online' ? '服务在线' : '服务未连接' }}</span><el-button link @click="checkConnection">重新检测</el-button></div></section><section class="login-panel"><p class="eyebrow">内部管理员</p><h1>登录管理台</h1><p class="subheading">使用管理员用户名和密码登录。</p><el-form @submit.prevent="signIn"><el-input v-model="username" aria-label="用户名" placeholder="用户名" autocomplete="username"/><el-input v-model="password" type="password" show-password placeholder="密码" autocomplete="current-password" @keyup.enter="signIn"/><el-button type="primary" :loading="loading" @click="signIn">登录</el-button></el-form><p v-if="error" class="error">{{ error }}</p></section></main>
<main class="content" v-else><p v-if="siteSettings?.announcement" class="site-announcement" role="note">{{siteSettings.announcement}}</p><p v-if="siteSettings?.support_email" class="subheading">支持联系:<a :href="`mailto:${siteSettings.support_email}`">{{siteSettings.support_email}}</a></p><DashboardPanel v-if="pageView==='dashboard'" @issue="openIssue" @detail="showDetail"/><div v-else class="heading"><div><p class="eyebrow">内部管理台</p><h1>{{title}}</h1><p class="subheading">{{pageView==='admins'?'管理后台账户、启停状态和密码':pageView==='audit'?'查看管理员操作记录':pageView==='settings'?'管理站点展示信息及管理员密码':'客户、订单、授权及实例状态'}}</p></div><el-button v-if="pageView!=='admins'&&pageView!=='audit'&&pageView!=='settings'" :loading="loading" @click="refresh">刷新</el-button></div><p v-if="error&&pageView!=='admins'&&pageView!=='audit'&&pageView!=='settings'" class="error">{{ error }}</p>
<section v-if="pageView==='customers'" class="data-section"><div class="section-heading"><div><h2>客户档案</h2><p>共 {{ customerTotal }} 条</p></div><div class="inline-form"><el-input v-model="newCustomer.name" placeholder="客户名称"/><el-input v-model="newCustomer.contact_email" placeholder="联系邮箱"/><el-button type="primary" @click="addCustomer">新增客户</el-button></div></div><el-input v-model="query" placeholder="搜索客户" clearable @change="refresh"/><div class="business-table"><el-table :data="customers" v-loading="loading" empty-text="暂无客户"><el-table-column prop="name" label="名称"/><el-table-column prop="contact_email" label="邮箱"/><el-table-column prop="status" label="状态"/><el-table-column label="操作" width="90"><template #default="scope"><el-button link type="danger" @click="removeCustomer(scope.row.id)">删除</el-button></template></el-table-column></el-table></div></section>
<section v-if="pageView==='products'" class="data-section"><div class="section-heading"><div><h2>产品目录</h2><p>可用于后续授权规则接入</p></div><div class="inline-form"><el-input v-model="newProduct.code" placeholder="产品编码"/><el-input v-model="newProduct.name" placeholder="产品名称"/><el-button type="primary" @click="addProduct">新增产品</el-button></div></div><div class="business-table"><el-table :data="products" v-loading="loading" empty-text="暂无产品"><el-table-column prop="code" label="编码" width="150"/><el-table-column prop="name" label="名称"/><el-table-column prop="description" label="说明"/><el-table-column label="操作" width="90"><template #default="scope"><el-button link type="danger" @click="removeProduct(scope.row.id)">删除</el-button></template></el-table-column></el-table></div></section>
<section v-if="pageView==='licenses'" id="license-issue" class="data-section"><form class="filters" @submit.prevent="licensePage=1;router.replace({query:{...(route.query),q:licenseQuery||undefined}});refresh()"><input v-model="licenseQuery" placeholder="搜索客户或 License"/><select v-model="licenseStatus" @change="router.replace({query:{...(route.query),status:licenseStatus||undefined}})"><option value="">全部状态</option><option value="active">有效</option><option value="expiring">即将到期</option><option value="pending">未开始</option><option value="expired">已到期</option><option value="revoked">已撤销</option></select><button class="search-button">搜索</button></form><div class="section-heading"><div><h2>期限授权</h2><p>共 {{ licenseTotal }} 条,签发后通过“实例”创建并交付客户端激活凭据</p></div><div class="inline-form license-form"><el-select v-model="issueForm.customer_id" placeholder="选择客户"><el-option v-for="item in customers" :key="item.id" :label="item.name" :value="item.id" :disabled="item.status !== 'active'"/></el-select><el-select v-model="issueForm.product_id" placeholder="选择产品"><el-option v-for="item in products" :key="item.id" :label="item.name" :value="item.id" :disabled="!item.active"/></el-select><el-date-picker v-model="issueForm.starts_at" type="datetime" value-format="YYYY-MM-DDTHH:mm:ssZ" placeholder="开始时间" aria-label="开始时间"/><el-date-picker v-model="issueForm.expires_at" type="datetime" value-format="YYYY-MM-DDTHH:mm:ssZ" placeholder="结束时间" aria-label="结束时间"/><el-button type="primary" :loading="issuing" @click="issue">签发授权</el-button></div></div><div class="business-table"><el-table :data="licenses" v-loading="loading" empty-text="暂无授权"><el-table-column prop="license_key" label="授权密钥" min-width="230"/><el-table-column prop="customer_name" label="客户"/><el-table-column prop="product_name" label="产品"/><el-table-column prop="status" label="状态"><template #default="scope">{{statusLabel(scope.row.status)}}</template></el-table-column><el-table-column label="开始(本地时间)" min-width="190"><template #default="scope">{{ formatDateTime(scope.row.starts_at) }}</template></el-table-column><el-table-column label="结束(本地时间)" min-width="190"><template #default="scope">{{ formatDateTime(scope.row.expires_at) }}</template></el-table-column><el-table-column label="操作" width="250"><template #default="scope"><el-button link @click="showDetail(scope.row.id)">详情</el-button><el-button link @click="showInstances(scope.row.id)">实例</el-button><el-button link @click="renew(scope.row)" :disabled="scope.row.status === 'revoked'">续期</el-button><el-button v-if="scope.row.status === 'revoked'" link type="primary" :loading="restoringLicense === scope.row.id" :disabled="restoringLicense !== null" @click="restore(scope.row.id)">恢复授权</el-button><el-button v-else link type="danger" @click="revoke(scope.row.id)">撤销</el-button><el-button link type="danger" @click="removeLicense(scope.row.id)">删除</el-button></template></el-table-column></el-table><el-pagination v-model:current-page="licensePage" :total="licenseTotal" :page-size="20" layout="prev, pager, next" @current-change="refresh"/></div></section>
<ReleasesPanel v-if="pageView==='releases'" :products="products"/>
<OrdersPanel v-if="pageView==='orders'" :customers="customers" :products="products" @issued="refresh"/>
<AdminsPanel v-if="pageView==='admins'" :current-username="adminEmail"/><IntegrationPanel v-if="pageView==='integration'"/><AuditPanel v-if="pageView==='audit'"/><SettingsPanel v-if="pageView==='settings'" @saved="siteSettings=$event"/><el-dialog v-model="renewalOpen" title="续期授权" width="min(480px, 95vw)" :close-on-click-modal="!renewing" :close-on-press-escape="!renewing" :show-close="!renewing"><template v-if="renewalLicense"><p>当前到期时间:{{ formatDateTime(renewalLicense.expires_at) }}</p><label for="renewal-date">新的到期时间(本地时间)</label><el-date-picker id="renewal-date" v-model="renewalDate" type="datetime" format="YYYY-MM-DD HH:mm:ss" placeholder="选择新的到期日期与时间" aria-label="新的到期时间" :disabled-date="disabledRenewalDate" :disabled="renewing" style="width:100%;margin-top:8px"/><p class="subheading">请选择晚于当前到期时间的日期和时间。</p><p v-if="renewalError" class="error" role="alert">{{ renewalError }}</p></template><template #footer><el-button :disabled="renewing" @click="renewalOpen=false">取消</el-button><el-button type="primary" :loading="renewing" @click="submitRenewal">确认续期</el-button></template></el-dialog><el-dialog v-model="detailOpen" title="授权详情" width="min(520px, 95vw)"><div v-loading="detailLoading"><p v-if="detailError" class="error" role="alert">{{detailError}}</p><dl v-if="detail" class="license-detail"><dt>License 密钥</dt><dd class="license-code">{{detail.license_key}}</dd><dt>客户</dt><dd>{{detail.customer_name}}</dd><dt>产品</dt><dd>{{detail.product_name}}</dd><dt>类型</dt><dd>期限授权</dd><dt>开始时间</dt><dd>{{formatDateTime(detail.starts_at)}}</dd><dt>到期时间</dt><dd>{{formatDateTime(detail.expires_at)}}</dd><dt>状态</dt><dd>{{statusLabel(detail.status)}}</dd></dl><el-button v-if="detail" @click="showInstances(detail.id)">查看实例 / 冻结管理</el-button></div></el-dialog><el-drawer v-model="instanceDrawer" title="授权实例与激活凭据" size="min(100%, 680px)"><InstanceProvisionPanel v-if="instanceDrawer&&selectedLicenseID!==null" :key="selectedLicenseID" :license-id="selectedLicenseID" :has-instance="instances.length>0" :ready="!instancesLoading&&!instanceError" @created="showInstances(selectedLicenseID!)"/><TrustDeliveryPanel v-for="instance in instances" :key="instance.instance_id" :instance="instance"/><el-button :loading="instancesLoading" @click="selectedLicenseID !== null && showInstances(selectedLicenseID)">刷新状态</el-button><p class="subheading">在线表示服务端最近 3 分钟收到心跳;超时显示离线,从未心跳显示从未上报。离线不代表授权失效;状态在刷新时更新。</p><p v-if="instanceError" class="error">{{ instanceError }}</p><div class="business-table"><el-table :data="instances" v-loading="instancesLoading" empty-text="未绑定实例"><el-table-column prop="instance_id" label="实例 ID" min-width="290"/><el-table-column label="激活状态" min-width="110"><template #default="scope"><el-tag :type="scope.row.status==='activated'?'success':'info'">{{statusLabel(scope.row.status)}}</el-tag></template></el-table-column><el-table-column label="连接状态" min-width="120"><template #default="scope"><el-tag :type="scope.row.online_state==='online'?'success':scope.row.online_state==='offline'?'warning':'info'">{{scope.row.online_state==='online'?'在线':scope.row.online_state==='offline'?'离线':scope.row.online_state==='never_seen'?'从未上报':'未知'}}</el-tag></template></el-table-column><el-table-column prop="certificate_version" label="证书版本"/><el-table-column label="激活时间" min-width="200"><template #default="scope">{{ formatDateTime(scope.row.activated_at) }}</template></el-table-column><el-table-column label="最后在线" min-width="200"><template #default="scope">{{ formatDateTime(scope.row.last_seen_at) }}</template></el-table-column><el-table-column label="租约到期" min-width="200"><template #default="scope">{{ formatDateTime(scope.row.lease_expires_at) }}</template></el-table-column><el-table-column prop="freeze_state" label="冻结状态"><template #default="scope">{{statusLabel(scope.row.freeze_state)}}</template></el-table-column><el-table-column prop="entitlement_state" label="授权状态"><template #default="scope">{{statusLabel(scope.row.entitlement_state)}}</template></el-table-column><el-table-column prop="observed_state" label="已传播状态"><template #default="scope">{{statusLabel(scope.row.observed_state)}}</template></el-table-column><el-table-column label="管理" fixed="right" width="90"><template #default="scope"><el-button link :type="scope.row.freeze_state === 'frozen' ? 'primary' : 'danger'" :loading="changingInstance === scope.row.instance_id" :disabled="!!changingInstance" @click="changeFreeze(scope.row)">{{ scope.row.freeze_state === 'frozen' ? '恢复' : '冻结' }}</el-button></template></el-table-column></el-table></div></el-drawer>
</main>
</div></div>
</template>