Files
37duAutomation/desktop/controlplane-next/frontend/src/views/creds/index.vue
T
puddy 60c28fe507 feat: 重构控制台为37du自动化平台,新增权限授权与通知中心功能
- 更新系统名称、登录页宣传文案为37du平台相关内容
- 移除聊天功能相关代码与配置
- 新增客户端版本上报字段与设备统计接口
- 新增通知中心功能(60s轮询、localStorage已读标记)
- 新增权限授权工作台相关接口与页面
- 新增统一页头组件ArtPageHeader
- 调整快速入口配置指向真实功能页面
- 修复控制面地址为内网生产库
2026-10-15 18:01:29 +08:00

118 lines
4.3 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<script setup lang="ts">
/**
* 敏感凭证(37du 控制台)
* 已登记账号列表 + 明文源录入(对接 /api/admin/creds/manage、creds/seed)
*/
import { onMounted, reactive, ref } from 'vue'
import { ElMessage } from 'element-plus'
import { fetchCredsManage, seedCreds } from '@/api/business'
const loading = ref(false)
const list = ref<any[]>([])
const total = ref(0)
const query = reactive({ page: 1, page_size: 20 })
async function load() {
loading.value = true
try {
const r = await fetchCredsManage(query)
list.value = r.items || []
total.value = r.total || 0
allowedKeys.value = r.allowed_keys || []
} finally {
loading.value = false
}
}
const allowedKeys = ref<string[]>([])
// ---- 录入明文源 ----
const seedOpen = ref(false)
const saving = ref(false)
const seedForm = reactive<{ account: string; values: Record<string, string> }>({ account: '', values: {} })
function openSeed(row: any) {
seedForm.account = row.account
seedForm.values = {}
for (const k of allowedKeys.value) seedForm.values[k] = row.creds?.[k] || ''
seedOpen.value = true
}
async function submitSeed() {
if (!seedForm.account) return ElMessage.warning('account 不能为空')
saving.value = true
try {
await seedCreds({ account: seedForm.account, values: seedForm.values })
ElMessage.success('明文源已保存')
seedOpen.value = false
load()
} finally {
saving.value = false
}
}
onMounted(load)
</script>
<template>
<div class="p-5 space-y-4">
<ArtPageHeader title="敏感凭证" description="执行机敏感凭证明文源录入与 RSA 加密下发">
<template #actions>
<el-button :loading="loading" @click="load"><ArtSvgIcon icon="ri:refresh-line" class="mr-1" />刷新</el-button>
</template>
</ArtPageHeader>
<el-card shadow="never" class="rounded-xl">
<el-table v-loading="loading" :data="list" border stripe>
<el-table-column prop="account" label="账号" min-width="140" />
<el-table-column prop="nickname" label="昵称" min-width="120" />
<el-table-column label="已上报公钥" width="110">
<template #default="{ row }">
<el-tag :type="row.has_pubkey ? 'success' : 'info'" size="small">{{ row.has_pubkey ? '是' : '否' }}</el-tag>
</template>
</el-table-column>
<el-table-column label="已配置键" min-width="300">
<template #default="{ row }">
<div class="flex flex-wrap items-center gap-1">
<template v-if="Object.keys(row.creds || {}).length">
<el-tag
v-for="k in Object.keys(row.creds || {})"
:key="k"
size="small"
effect="plain"
class="!max-w-44 truncate"
>{{ k }}</el-tag>
</template>
<span v-else class="text-gray-400 text-xs">未配置</span>
</div>
</template>
</el-table-column>
<el-table-column prop="updated_at" label="更新时间" width="170" />
<el-table-column label="操作" width="120" fixed="right">
<template #default="{ row }">
<el-button link type="primary" @click="openSeed(row)">录入明文</el-button>
</template>
</el-table-column>
</el-table>
<div class="flex justify-end mt-4">
<el-pagination v-model:current-page="query.page" v-model:page-size="query.page_size" :total="total"
layout="total, prev, pager, next" @current-change="load" />
</div>
</el-card>
<el-dialog v-model="seedOpen" title="录入敏感凭证明文源" width="560px">
<el-form label-width="auto" label-position="left">
<el-form-item label="账号">
<span class="text-sm font-medium">{{ seedForm.account }}</span>
</el-form-item>
<el-form-item v-for="k in allowedKeys" :key="k" :label="k">
<el-input v-model="seedForm.values[k]" type="password" show-password placeholder="留空则清除" />
</el-form-item>
</el-form>
<template #footer>
<el-button @click="seedOpen = false">取消</el-button>
<el-button type="primary" :loading="saving" @click="submitSeed">保存</el-button>
</template>
</el-dialog>
</div>
</template>