<script setup lang="ts">
defineProps<{ ctx: any }>();
</script>

<template>
  <section class="panel page-stack">
    <div class="section-head"><h2>审计日志</h2><button class="btn ghost" @click="ctx.loadAudit">刷新</button></div>
    <table>
      <thead><tr><th>类型</th><th>目标</th><th>信息</th><th>IP</th><th>时间</th></tr></thead>
      <tbody>
        <tr v-for="item in ctx.auditLogs" :key="item.id">
          <td><span class="badge neutral">{{ ctx.auditTypeLabel(item.type) }}</span></td>
          <td>{{ item.target }}</td>
          <td>{{ ctx.auditMessage(item) }}</td>
          <td>{{ item.ip || "-" }}</td>
          <td>{{ item.createdAt }}</td>
        </tr>
        <tr v-if="ctx.auditLogs.length === 0"><td colspan="5">暂无审计日志。</td></tr>
      </tbody>
    </table>
  </section>
</template>
