移除告警规则界面、恢复 Chat 端点并优化列表
This commit is contained in:
@@ -1,8 +1,6 @@
|
||||
import { mockLogEvents, mockLogRelays, mockLogWebhooks } from './mock'
|
||||
import { mockOn, mocked, request } from './request'
|
||||
import type {
|
||||
AlertRule,
|
||||
AlertRuleBody,
|
||||
LogEventPage,
|
||||
LogRelayView,
|
||||
LogWebhookInfo,
|
||||
@@ -30,27 +28,6 @@ export function listLogEvents(params: LogEventParams): Promise<LogEventPage> {
|
||||
return request('/log-events', { query: { ...params } })
|
||||
}
|
||||
|
||||
// ---- 告警规则 ----
|
||||
export function listAlertRules(): Promise<AlertRule[]> {
|
||||
if (mockOn) return mocked([])
|
||||
return request<{ items: AlertRule[] }>('/log-events/alert-rules').then((r) => r.items)
|
||||
}
|
||||
|
||||
export function createAlertRule(body: AlertRuleBody): Promise<AlertRule> {
|
||||
if (mockOn) return mocked({ ...body, id: 1, createdAt: '', updatedAt: '' }, 300)
|
||||
return request('/log-events/alert-rules', { method: 'POST', body })
|
||||
}
|
||||
|
||||
export function updateAlertRule(id: number, body: AlertRuleBody): Promise<AlertRule> {
|
||||
if (mockOn) return mocked({ ...body, id, createdAt: '', updatedAt: '' }, 300)
|
||||
return request(`/log-events/alert-rules/${id}`, { method: 'PUT', body })
|
||||
}
|
||||
|
||||
export function deleteAlertRule(id: number): Promise<void> {
|
||||
if (mockOn) return mocked(undefined, 300)
|
||||
return request(`/log-events/alert-rules/${id}`, { method: 'DELETE' })
|
||||
}
|
||||
|
||||
export function getLogWebhook(cfgId: number): Promise<LogWebhookState> {
|
||||
if (mockOn) {
|
||||
const info = mockLogWebhooks.get(cfgId)
|
||||
|
||||
@@ -1,313 +0,0 @@
|
||||
<script setup lang="ts">
|
||||
import {
|
||||
NButton,
|
||||
NInput,
|
||||
NModal,
|
||||
NPopconfirm,
|
||||
NSelect,
|
||||
NSwitch,
|
||||
type SelectOption,
|
||||
} from 'naive-ui'
|
||||
import { computed, reactive, ref, watch } from 'vue'
|
||||
|
||||
import {
|
||||
createAlertRule,
|
||||
deleteAlertRule,
|
||||
listAlertRules,
|
||||
updateAlertRule,
|
||||
} from '@/api/logevents'
|
||||
import { listNotifyTemplates } from '@/api/settings'
|
||||
import AppInputNumber from '@/components/AppInputNumber.vue'
|
||||
import FormField from '@/components/FormField.vue'
|
||||
import NotifyTemplateModal from '@/components/settings/NotifyTemplateModal.vue'
|
||||
import TenantPicker from '@/components/TenantPicker.vue'
|
||||
import { eventLabel } from '@/composables/useEventLabel'
|
||||
import { useAsync } from '@/composables/useAsync'
|
||||
import { useScopeStore } from '@/stores/scope'
|
||||
import type { AlertRule, AlertRuleBody, NotifyTemplateItem } from '@/types/api'
|
||||
import { useToast } from '@/composables/useToast'
|
||||
|
||||
const show = defineModel<boolean>('show', { required: true })
|
||||
|
||||
const message = useToast()
|
||||
const scope = useScopeStore()
|
||||
|
||||
/** 可选事件短名 = 回传链路的关键事件清单(Connector 侧 filter 一致) */
|
||||
const RELAY_EVENTS = [
|
||||
'LaunchInstance', 'TerminateInstance', 'InstanceAction',
|
||||
'CreateUser', 'DeleteUser', 'UpdateUser',
|
||||
'CreateApiKey', 'DeleteApiKey', 'UpdateUserCapabilities',
|
||||
'CreateRegionSubscription', 'CreatePolicy', 'UpdatePolicy', 'DeletePolicy',
|
||||
'InteractiveLogin',
|
||||
]
|
||||
const eventOptions: SelectOption[] = RELAY_EVENTS.map((e) => ({
|
||||
value: e,
|
||||
label: eventLabel(e) ? `${eventLabel(e)}(${e})` : e,
|
||||
}))
|
||||
|
||||
const rules = useAsync(listAlertRules, false)
|
||||
watch(show, (v) => {
|
||||
if (v) void rules.run()
|
||||
})
|
||||
|
||||
// ---- 编辑表单:editing 非 null 时进入表单视图,id=0 表示新建 ----
|
||||
const editing = ref<AlertRule | null>(null)
|
||||
const saving = ref(false)
|
||||
const form = reactive({
|
||||
name: '',
|
||||
enabled: true,
|
||||
cfgId: null as number | null,
|
||||
eventTypes: [] as string[],
|
||||
sourceIps: '',
|
||||
sourceIpMode: 'in' as 'in' | 'notin',
|
||||
resourceMatch: '',
|
||||
threshold: 1 as number | null,
|
||||
windowMinutes: 5 as number | null,
|
||||
})
|
||||
|
||||
function openCreate() {
|
||||
editing.value = {
|
||||
id: 0, name: '', enabled: true, ociConfigId: 0, eventTypes: '', sourceIps: '',
|
||||
sourceIpMode: 'in', resourceMatch: '', threshold: 1, windowMinutes: 5,
|
||||
createdAt: '', updatedAt: '',
|
||||
}
|
||||
}
|
||||
|
||||
function openEdit(rule: AlertRule) {
|
||||
editing.value = rule
|
||||
}
|
||||
|
||||
// 进入表单时由所编辑规则回填
|
||||
watch(editing, (r) => {
|
||||
if (!r) return
|
||||
form.name = r.name
|
||||
form.enabled = r.enabled
|
||||
form.cfgId = r.ociConfigId || null
|
||||
form.eventTypes = r.eventTypes ? r.eventTypes.split(',') : []
|
||||
form.sourceIps = r.sourceIps
|
||||
form.sourceIpMode = r.sourceIpMode || 'in'
|
||||
form.resourceMatch = r.resourceMatch
|
||||
form.threshold = r.threshold || 1
|
||||
form.windowMinutes = r.windowMinutes || 5
|
||||
})
|
||||
|
||||
function buildBody(): AlertRuleBody {
|
||||
return {
|
||||
name: form.name.trim(),
|
||||
enabled: form.enabled,
|
||||
ociConfigId: form.cfgId ?? 0,
|
||||
eventTypes: form.eventTypes.join(','),
|
||||
sourceIps: form.sourceIps.trim(),
|
||||
sourceIpMode: form.sourceIpMode,
|
||||
resourceMatch: form.resourceMatch.trim(),
|
||||
threshold: form.threshold ?? 1,
|
||||
windowMinutes: form.windowMinutes ?? 5,
|
||||
}
|
||||
}
|
||||
|
||||
async function save() {
|
||||
if (!editing.value) return
|
||||
saving.value = true
|
||||
try {
|
||||
const body = buildBody()
|
||||
if (editing.value.id) await updateAlertRule(editing.value.id, body)
|
||||
else await createAlertRule(body)
|
||||
message.success(editing.value.id ? '规则已更新' : '规则已创建')
|
||||
editing.value = null
|
||||
void rules.run()
|
||||
} catch (e) {
|
||||
message.error(e instanceof Error ? e.message : '保存失败')
|
||||
} finally {
|
||||
saving.value = false
|
||||
}
|
||||
}
|
||||
|
||||
/** 列表行的启停开关:就地整体覆盖保存 */
|
||||
async function toggleRule(rule: AlertRule, enabled: boolean) {
|
||||
try {
|
||||
await updateAlertRule(rule.id, { ...rule, enabled })
|
||||
rule.enabled = enabled
|
||||
} catch (e) {
|
||||
message.error(e instanceof Error ? e.message : '操作失败')
|
||||
}
|
||||
}
|
||||
|
||||
async function removeRule(rule: AlertRule) {
|
||||
try {
|
||||
await deleteAlertRule(rule.id)
|
||||
message.success(`已删除「${rule.name}」`)
|
||||
void rules.run()
|
||||
} catch (e) {
|
||||
message.error(e instanceof Error ? e.message : '删除失败')
|
||||
}
|
||||
}
|
||||
|
||||
/** 条件摘要:留空条件不出现 */
|
||||
function ruleSummary(r: AlertRule): string {
|
||||
const parts: string[] = []
|
||||
const alias = scope.cfgOptions.find((o) => Number(o.value) === r.ociConfigId)?.label
|
||||
parts.push(r.ociConfigId ? `租户 ${alias ?? `#${r.ociConfigId}`}` : '全部租户')
|
||||
parts.push(r.eventTypes ? `${r.eventTypes.split(',').length} 种事件` : '全部事件')
|
||||
if (r.sourceIps) parts.push(`IP ${r.sourceIpMode === 'notin' ? '不在' : '命中'} ${r.sourceIps}`)
|
||||
if (r.resourceMatch) parts.push(`资源含「${r.resourceMatch}」`)
|
||||
parts.push(r.threshold > 1 ? `${r.windowMinutes} 分钟内 ${r.threshold} 次` : '即时触发')
|
||||
return parts.join(' · ')
|
||||
}
|
||||
|
||||
// ---- 通知模板入口:复用设置页模板编辑弹窗(kind=audit_alert) ----
|
||||
const templates = useAsync(listNotifyTemplates, false)
|
||||
const tplShow = ref(false)
|
||||
const tplItem = ref<NotifyTemplateItem | null>(null)
|
||||
|
||||
async function openTemplate() {
|
||||
if (!templates.data.value) await templates.run()
|
||||
const item = (templates.data.value ?? []).find((t) => t.kind === 'audit_alert')
|
||||
if (!item) {
|
||||
message.error('模板加载失败,请稍后再试')
|
||||
return
|
||||
}
|
||||
tplItem.value = item
|
||||
tplShow.value = true
|
||||
}
|
||||
|
||||
const canSave = computed(() => !!form.name.trim())
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<NModal
|
||||
v-model:show="show"
|
||||
preset="card"
|
||||
closable
|
||||
title="审计告警规则"
|
||||
:style="{ width: '680px', maxWidth: 'calc(100vw - 24px)' }"
|
||||
>
|
||||
<!-- 表单视图 -->
|
||||
<div v-if="editing" class="flex flex-col">
|
||||
<FormField label="规则名称" required>
|
||||
<NInput v-model:value="form.name" placeholder="如:非白名单终止实例" />
|
||||
</FormField>
|
||||
<div class="grid grid-cols-2 gap-3 max-md:grid-cols-1">
|
||||
<FormField label="租户范围" hint="留空对全部租户生效">
|
||||
<TenantPicker
|
||||
v-model:value="form.cfgId"
|
||||
clearable
|
||||
placeholder="全部租户"
|
||||
:configs="scope.configs.data ?? []"
|
||||
:loading="scope.configs.loading"
|
||||
/>
|
||||
</FormField>
|
||||
<FormField label="事件类型" hint="留空匹配全部回传事件">
|
||||
<NSelect
|
||||
v-model:value="form.eventTypes"
|
||||
multiple
|
||||
clearable
|
||||
:options="eventOptions"
|
||||
placeholder="全部事件"
|
||||
:max-tag-count="2"
|
||||
/>
|
||||
</FormField>
|
||||
</div>
|
||||
<FormField
|
||||
label="来源 IP 条件"
|
||||
hint="逗号分隔 IP 或 CIDR;「不在列表才告警」适合白名单场景(非我发起的操作)"
|
||||
>
|
||||
<div class="mb-1.5 flex gap-1.5">
|
||||
<button
|
||||
v-for="m in [
|
||||
{ v: 'in', t: '命中列表告警' },
|
||||
{ v: 'notin', t: '不在列表才告警' },
|
||||
]"
|
||||
:key="m.v"
|
||||
type="button"
|
||||
class="cursor-pointer rounded-md border px-3 py-1 text-xs"
|
||||
:class="
|
||||
form.sourceIpMode === m.v
|
||||
? 'border-accent bg-accent/10 font-semibold text-accent'
|
||||
: 'border-line bg-white text-ink-2 hover:border-ink-3'
|
||||
"
|
||||
@click="form.sourceIpMode = m.v as 'in' | 'notin'"
|
||||
>
|
||||
{{ m.t }}
|
||||
</button>
|
||||
</div>
|
||||
<NInput v-model:value="form.sourceIps" class="mono" placeholder="203.0.113.8, 10.0.0.0/8(留空=任意)" />
|
||||
</FormField>
|
||||
<div class="grid grid-cols-3 gap-3 max-md:grid-cols-1">
|
||||
<FormField label="资源名包含" hint="子串匹配,留空=任意">
|
||||
<NInput v-model:value="form.resourceMatch" placeholder="web-" />
|
||||
</FormField>
|
||||
<FormField label="触发阈值(次)" hint="1=每次命中即告警">
|
||||
<AppInputNumber v-model:value="form.threshold" :min="1" :max="100" class="!w-full" />
|
||||
</FormField>
|
||||
<FormField label="聚合窗口(分钟)" hint="阈值>1 时生效,告警后同窗冷却">
|
||||
<AppInputNumber
|
||||
v-model:value="form.windowMinutes"
|
||||
:min="1"
|
||||
:max="1440"
|
||||
:disabled="(form.threshold ?? 1) <= 1"
|
||||
class="!w-full"
|
||||
/>
|
||||
</FormField>
|
||||
</div>
|
||||
<div class="flex items-center justify-between rounded-lg bg-wash px-3 py-2">
|
||||
<span class="text-[12.5px]">启用该规则</span>
|
||||
<NSwitch v-model:value="form.enabled" size="small" />
|
||||
</div>
|
||||
<div class="mt-3 flex items-center gap-2">
|
||||
<NButton size="small" type="primary" :loading="saving" :disabled="!canSave" @click="save">
|
||||
保存
|
||||
</NButton>
|
||||
<NButton size="small" @click="editing = null">返回列表</NButton>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 列表视图 -->
|
||||
<div v-else class="flex flex-col">
|
||||
<div class="mb-2 flex items-center justify-between gap-2">
|
||||
<div class="text-xs text-ink-3">
|
||||
命中规则的回传事件经「通知方式」的启用渠道推送;仅已建回传链路的租户产生事件
|
||||
</div>
|
||||
<div class="flex flex-none items-center gap-2">
|
||||
<NButton size="tiny" quaternary type="primary" @click="openTemplate">通知模板</NButton>
|
||||
<NButton size="small" type="primary" @click="openCreate">新建规则</NButton>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
v-for="rule in rules.data.value ?? []"
|
||||
:key="rule.id"
|
||||
class="flex items-center gap-3 border-b border-line-soft py-2.5 last:border-b-0"
|
||||
>
|
||||
<div class="min-w-0 flex-1">
|
||||
<div class="text-[13px] font-medium">{{ rule.name }}</div>
|
||||
<div class="mt-0.5 truncate text-xs text-ink-3" :title="ruleSummary(rule)">
|
||||
{{ ruleSummary(rule) }}
|
||||
</div>
|
||||
</div>
|
||||
<NSwitch
|
||||
size="small"
|
||||
:value="rule.enabled"
|
||||
@update:value="(v: boolean) => toggleRule(rule, v)"
|
||||
/>
|
||||
<NButton size="tiny" quaternary type="primary" @click="openEdit(rule)">编辑</NButton>
|
||||
<NPopconfirm @positive-click="removeRule(rule)">
|
||||
<template #trigger>
|
||||
<NButton size="tiny" quaternary type="error">删除</NButton>
|
||||
</template>
|
||||
删除规则「{{ rule.name }}」?
|
||||
</NPopconfirm>
|
||||
</div>
|
||||
<div
|
||||
v-if="!rules.loading.value && !(rules.data.value ?? []).length"
|
||||
class="py-8 text-center text-[13px] text-ink-3"
|
||||
>
|
||||
暂无规则,点击「新建规则」创建第一条
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<NotifyTemplateModal
|
||||
v-model:show="tplShow"
|
||||
:item="tplItem"
|
||||
hint="命中告警规则时推送;变量:rule / tenant / event / resource / ip / count"
|
||||
/>
|
||||
</NModal>
|
||||
</template>
|
||||
@@ -1,11 +1,10 @@
|
||||
<script setup lang="ts">
|
||||
import { NButton, NDataTable, NModal, NPopover, type DataTableColumns } from 'naive-ui'
|
||||
import { NDataTable, NModal, NPopover, type DataTableColumns } from 'naive-ui'
|
||||
import { computed, h, reactive, ref } from 'vue'
|
||||
import { useRouter } from 'vue-router'
|
||||
|
||||
import { listConfigs } from '@/api/configs'
|
||||
import { listLogEvents } from '@/api/logevents'
|
||||
import AlertRuleModal from '@/components/logs/AlertRuleModal.vue'
|
||||
import DetailFieldList, { type DetailRow } from '@/components/DetailFieldList.vue'
|
||||
import DetailHero, { type HeroChip } from '@/components/DetailHero.vue'
|
||||
import FootNote from '@/components/FootNote.vue'
|
||||
@@ -41,7 +40,6 @@ const cfgById = computed(() => {
|
||||
|
||||
const detail = ref<LogEvent | null>(null)
|
||||
const showDetail = ref(false)
|
||||
const showRules = ref(false)
|
||||
|
||||
/** 受控远程分页:字面量对象会在重渲染时被重建导致状态丢失 */
|
||||
const pagination = reactive({
|
||||
@@ -223,7 +221,6 @@ useAutoRefresh(() => load(true))
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex flex-wrap items-center gap-2">
|
||||
<NButton size="small" @click="showRules = true">告警规则</NButton>
|
||||
<TenantPicker
|
||||
v-model:value="cfgFilter"
|
||||
size="small"
|
||||
@@ -251,12 +248,9 @@ useAutoRefresh(() => load(true))
|
||||
在租户详情「其他」tab 一键创建链路后,实例生命周期(Launch/Terminate/InstanceAction)、
|
||||
用户与凭据(Create/Delete/UpdateUser、Create/DeleteApiKey、UpdateUserCapabilities)、
|
||||
区域订阅与策略变更等关键审计事件将自动回传;消息按 MessageId 幂等去重,保留 90
|
||||
天、总量超 2 万条时删除最旧,关键事件另经「通知管理 → 云端事件」推送告警;
|
||||
更细粒度的条件告警(事件/来源 IP/资源/频率)在「告警规则」中配置
|
||||
天、总量超 2 万条时删除最旧,关键事件另经「通知管理 → 云端事件」推送告警
|
||||
</FootNote>
|
||||
|
||||
<AlertRuleModal v-model:show="showRules" />
|
||||
|
||||
<NModal v-model:show="showDetail" preset="card" closable :style="{ width: '720px', maxWidth: 'calc(100vw - 24px)' }">
|
||||
<template #header>
|
||||
<DetailHero
|
||||
|
||||
@@ -185,7 +185,6 @@ useAutoRefresh(() => load(true))
|
||||
:loading="loading"
|
||||
:pagination="pagination"
|
||||
:scroll-x="880"
|
||||
:max-height="480"
|
||||
:row-key="(r: SystemLog) => r.id"
|
||||
:row-props="rowProps"
|
||||
/>
|
||||
|
||||
@@ -222,7 +222,6 @@ const columns: DataTableColumns<AuditEvent> = [
|
||||
:loading="loading"
|
||||
:pagination="pagination"
|
||||
:scroll-x="820"
|
||||
:max-height="480"
|
||||
:row-props="rowProps"
|
||||
/>
|
||||
<FootNote>
|
||||
|
||||
@@ -222,7 +222,6 @@ const columns = computed(() => (withAvail.value ? [...baseColumns, ...availColum
|
||||
:loading="limits.loading.value"
|
||||
:pagination="pagination"
|
||||
:scroll-x="withAvail ? 660 : 380"
|
||||
:max-height="440"
|
||||
:row-key="(r: LimitItem) => r.name + (r.availabilityDomain ?? '')"
|
||||
/>
|
||||
<FootNote>
|
||||
|
||||
@@ -878,32 +878,6 @@ export interface LogEventPage {
|
||||
total: number
|
||||
}
|
||||
|
||||
/** 回传事件告警规则;条件间 AND,空条件视为任意 */
|
||||
export interface AlertRule {
|
||||
id: number
|
||||
name: string
|
||||
enabled: boolean
|
||||
/** 0=全部租户 */
|
||||
ociConfigId: number
|
||||
/** 逗号分隔事件短名(如 TerminateInstance),空=全部 */
|
||||
eventTypes: string
|
||||
/** 逗号分隔 IP/CIDR,空=任意 */
|
||||
sourceIps: string
|
||||
/** in:命中列表告警;notin:不在列表才告警(白名单) */
|
||||
sourceIpMode: 'in' | 'notin'
|
||||
/** 资源名子串,空=任意 */
|
||||
resourceMatch: string
|
||||
/** 触发阈值,默认 1(即时) */
|
||||
threshold: number
|
||||
/** 聚合窗口分钟,threshold>1 时必填 */
|
||||
windowMinutes: number
|
||||
createdAt: string
|
||||
updatedAt: string
|
||||
}
|
||||
|
||||
/** 创建/更新告警规则请求体 */
|
||||
export type AlertRuleBody = Omit<AlertRule, 'id' | 'createdAt' | 'updatedAt'>
|
||||
|
||||
/** 每租户回传回调地址;path 需以面板公网域名拼接完整 URL */
|
||||
export interface LogWebhookInfo {
|
||||
path: string
|
||||
|
||||
@@ -27,6 +27,7 @@ const blacklist = useAsync(listAiBlacklist)
|
||||
const baseUrl = `${window.location.origin}/ai/v1`
|
||||
|
||||
const endpoints = [
|
||||
{ method: 'POST', path: '/chat/completions', note: 'OpenAI · 流式/非流式' },
|
||||
{ method: 'POST', path: '/responses', note: 'OpenAI Responses · 无状态子集' },
|
||||
{ method: 'POST', path: '/messages', note: 'Claude · 流式/非流式' },
|
||||
{ method: 'POST', path: '/embeddings', note: 'OpenAI Embeddings · 向量化' },
|
||||
|
||||
@@ -163,7 +163,8 @@ const currencySymbol = computed(() => {
|
||||
{{ ov?.tenants.alive ?? 0 }}/{{ ov?.tenants.total ?? 0 }} 存活
|
||||
</div>
|
||||
</div>
|
||||
<div class="px-4.5 py-1.5">
|
||||
<!-- 限高内部滚动:租户多时不撑高整行,底部露半行暗示可滚 -->
|
||||
<div class="max-h-90 overflow-y-auto px-4.5 py-1.5">
|
||||
<div
|
||||
v-for="c in configs.data.value ?? []"
|
||||
:key="c.id"
|
||||
@@ -188,13 +189,13 @@ const currencySymbol = computed(() => {
|
||||
</div>
|
||||
<div class="w-18 flex-none text-right text-xs text-ink-3">{{ fmtRelative(c.lastVerifiedAt) }}</div>
|
||||
</div>
|
||||
<div class="py-2.5 text-center">
|
||||
<RouterLink
|
||||
class="text-[13px] font-medium text-accent hover:text-accent-hover"
|
||||
:to="{ name: 'tenants' }"
|
||||
>查看全部租户</RouterLink
|
||||
>
|
||||
</div>
|
||||
</div>
|
||||
<div class="border-t border-line-soft py-2.5 text-center">
|
||||
<RouterLink
|
||||
class="text-[13px] font-medium text-accent hover:text-accent-hover"
|
||||
:to="{ name: 'tenants' }"
|
||||
>查看全部租户</RouterLink
|
||||
>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -143,7 +143,7 @@ async function remove() {
|
||||
<div class="max-w-80 text-[13px] leading-relaxed">
|
||||
<div class="font-medium">删除「{{ config.data.value.alias }}」?</div>
|
||||
<div class="mt-1 text-xs text-ink-3">
|
||||
将清理面板内关联数据:后台任务、测活 / 成本快照、回传事件、Webhook 密钥、告警规则与 AI 渠道。
|
||||
将清理面板内关联数据:后台任务、测活 / 成本快照、回传事件、Webhook 密钥与 AI 渠道。
|
||||
</div>
|
||||
<div class="mt-0.5 text-xs text-ink-3">
|
||||
OCI 云端资源不受影响;云端日志回传链路请先在「其他」页销毁。
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<script setup lang="ts">
|
||||
import { NButton, NDataTable, NInput, NInputGroup, NInputGroupLabel, NPopconfirm, NPopover, NSelect, NTooltip, type DataTableColumns } from 'naive-ui'
|
||||
import { computed, h, ref, type VNodeChild } from 'vue'
|
||||
import { computed, h, reactive, ref, watch, type VNodeChild } from 'vue'
|
||||
import { RouterLink, useRouter } from 'vue-router'
|
||||
|
||||
import { listAiChannels } from '@/api/aigateway'
|
||||
@@ -63,6 +63,25 @@ const filtered = computed(() => {
|
||||
)
|
||||
})
|
||||
|
||||
/** 客户端分页:字面量对象会在重渲染时被重建导致状态丢失,须用 reactive 受控 */
|
||||
const pagination = reactive({
|
||||
page: 1,
|
||||
pageSize: 10,
|
||||
showSizePicker: true,
|
||||
pageSizes: [10, 20, 50, 100],
|
||||
onUpdatePage: (p: number) => {
|
||||
pagination.page = p
|
||||
},
|
||||
onUpdatePageSize: (ps: number) => {
|
||||
pagination.pageSize = ps
|
||||
pagination.page = 1
|
||||
},
|
||||
})
|
||||
/** 搜索或分组过滤变化后回第 1 页,避免停留在越界页码 */
|
||||
watch([keyword, groupFilter], () => {
|
||||
pagination.page = 1
|
||||
})
|
||||
|
||||
/** 任务是否作用于该租户:抢机看目标租户;AI 探测看号池渠道(仅入池租户);
|
||||
* 测活 / 成本看范围(空 = 全部租户) */
|
||||
function taskTouchesCfg(task: Task, cfgId: number): boolean {
|
||||
@@ -227,7 +246,7 @@ function renderActions(row: OciConfigSummary): VNodeChild {
|
||||
h(
|
||||
'div',
|
||||
{ class: 'mt-1 text-xs text-ink-3' },
|
||||
'将清理面板内关联数据:后台任务、测活 / 成本快照、回传事件、Webhook 密钥、告警规则与 AI 渠道。',
|
||||
'将清理面板内关联数据:后台任务、测活 / 成本快照、回传事件、Webhook 密钥与 AI 渠道。',
|
||||
),
|
||||
h(
|
||||
'div',
|
||||
@@ -332,7 +351,7 @@ const columns = computed<DataTableColumns<OciConfigSummary>>(() => [
|
||||
:columns="columns"
|
||||
:data="filtered"
|
||||
:loading="configs.loading.value"
|
||||
:pagination="{ pageSize: 10 }"
|
||||
:pagination="pagination"
|
||||
:scroll-x="1200"
|
||||
:row-key="(r: OciConfigSummary) => r.id"
|
||||
/>
|
||||
|
||||
Reference in New Issue
Block a user