发布 0.1.0:通知渠道、告警规则与多项体验修复
CI / test (push) Successful in 27s
Release / release (push) Successful in 26s

This commit is contained in:
Wang Defa
2026-07-10 17:31:19 +08:00
parent 9d0c116ce3
commit 5464d2dfea
68 changed files with 1604 additions and 359 deletions
+87 -19
View File
@@ -1,30 +1,98 @@
<script setup lang="ts">
// 项目 logo:星爆贴纸(波普风,十二角星爆 + O!)。
// 固定品牌色值不走 CSS 变量——favicon 与深浅主题共用同一套颜色。
// 项目 logo:波普贴纸,双款式跟随 app store(burst 星爆 / seal 波浪封印,
// 设置 · 关于点击 logo 切换)。固定品牌色值不走 CSS 变量——favicon 与深浅主题共用同一套颜色。
import { computed } from 'vue'
import { useAppStore } from '@/stores/app'
withDefaults(defineProps<{ size?: number }>(), { size: 48 })
const BURST =
'M24 5 L27.9 9.5 L33.5 7.5 L34.6 13.4 L40.5 14.5 L38.5 20.1 L43 24 L38.5 27.9 ' +
'L40.5 33.5 L34.6 34.6 L33.5 40.5 L27.9 38.5 L24 43 L20.1 38.5 L14.5 40.5 L13.4 34.6 ' +
'L7.5 33.5 L9.5 27.9 L5 24 L9.5 20.1 L7.5 14.5 L13.4 13.4 L14.5 7.5 L20.1 9.5 Z'
// 十二瓣扇贝圆(经典价签贴纸),内圈虚线封印
const SEAL =
'M39.5 19.9 A5.8 5.8 0 0 0 35.3 12.7 A5.8 5.8 0 0 0 28.1 8.5 A5.8 5.8 0 0 0 19.9 8.5 ' +
'A5.8 5.8 0 0 0 12.7 12.7 A5.8 5.8 0 0 0 8.5 19.9 A5.8 5.8 0 0 0 8.5 28.1 ' +
'A5.8 5.8 0 0 0 12.7 35.3 A5.8 5.8 0 0 0 19.9 39.5 A5.8 5.8 0 0 0 28.1 39.5 ' +
'A5.8 5.8 0 0 0 35.3 35.3 A5.8 5.8 0 0 0 39.5 28.1 A5.8 5.8 0 0 0 39.5 19.9 Z'
const VARIANTS = {
burst: { d: BURST, strokeWidth: 2.6, textY: 28.8, fontSize: 13, ring: false },
seal: { d: SEAL, strokeWidth: 2.4, textY: 28.6, fontSize: 12.5, ring: true },
} as const
const app = useAppStore()
const v = computed(() => VARIANTS[app.logoVariant])
</script>
<template>
<svg :width="size" :height="size" viewBox="0 0 48 48" aria-hidden="true">
<g transform="rotate(-8 24 24)">
<path :d="BURST" fill="#3A2418" transform="translate(1.9,2.4)"></path>
<path :d="BURST" fill="#C96442" stroke="#FFFDF7" stroke-width="2.6" stroke-linejoin="round"></path>
<text
x="24"
y="28.8"
text-anchor="middle"
font-family="Georgia,'Times New Roman',serif"
font-size="13"
font-weight="900"
fill="#FAF3E3"
>
O!
</text>
</g>
</svg>
<span class="logo-wrap" :style="{ width: `${size}px`, height: `${size}px` }">
<Transition name="logo-slide">
<svg :key="app.logoVariant" :width="size" :height="size" viewBox="0 0 48 48" aria-hidden="true">
<g transform="rotate(-8 24 24)">
<path :d="v.d" fill="#3A2418" transform="translate(1.9,2.4)"></path>
<path :d="v.d" fill="#C96442" stroke="#FFFDF7" :stroke-width="v.strokeWidth" stroke-linejoin="round"></path>
<circle
v-if="v.ring"
cx="24"
cy="24"
r="12.5"
fill="none"
stroke="#FAF3E3"
stroke-width="1"
stroke-dasharray="2.4 2.6"
opacity="0.7"
></circle>
<text
x="24"
:y="v.textY"
text-anchor="middle"
font-family="Georgia,'Times New Roman',serif"
:font-size="v.fontSize"
font-weight="900"
fill="#FAF3E3"
>
O!
</text>
</g>
</svg>
</Transition>
</span>
</template>
<style scoped>
/* 款式切换:旧款右滑淡出、新款自左滑入(整体从左到右);
离开元素绝对定位避免过渡期双元素撑开布局 */
.logo-wrap {
position: relative;
display: inline-block;
line-height: 0;
}
.logo-slide-enter-active,
.logo-slide-leave-active {
transition:
transform 0.35s ease,
opacity 0.35s ease;
}
.logo-slide-leave-active {
position: absolute;
left: 0;
top: 0;
}
.logo-slide-enter-from {
transform: translateX(-45%);
opacity: 0;
}
.logo-slide-leave-to {
transform: translateX(45%);
opacity: 0;
}
@media (prefers-reduced-motion: reduce) {
.logo-slide-enter-active,
.logo-slide-leave-active {
transition: none;
}
}
</style>
+11 -5
View File
@@ -1,7 +1,7 @@
<script setup lang="ts">
/** 租户失联占位:租户详情各 tab 与实例 / 网络 / 存储等资源页在
* 当前租户失联时整体替换内容区,避免各处「无数据」/ 报错造成误判。 */
defineProps<{ lastError?: string }>()
/** 租户失联/暂停占位:租户详情各 tab 与实例 / 网络 / 存储等资源页在
* 当前租户不可用时整体替换内容区,避免各处「无数据」/ 报错造成误判。 */
defineProps<{ lastError?: string; suspended?: boolean }>()
</script>
<template>
@@ -23,12 +23,18 @@ defineProps<{ lastError?: string }>()
<line x1="16" y1="19" x2="16" y2="22" />
<line x1="19" y1="16" x2="22" y2="16" />
</svg>
<div class="text-sm font-semibold text-ink-2">租户已失联</div>
<div class="text-sm font-semibold text-ink-2">
{{ suspended ? '租户已被云端暂停' : '租户已失联' }}
</div>
<div v-if="lastError" class="mono max-w-130 text-xs break-all whitespace-pre-wrap text-ink-3">
{{ lastError }}
</div>
<div class="max-w-95 text-[12.5px] text-ink-3">
请检查 API Key 是否有效修复后在租户页重新测活
{{
suspended
? '账户被 Oracle 暂停(欠费 / 封禁 / 终止),请到官方控制台或工单处理,恢复后重新测活'
: '请检查 API Key 是否有效,修复后在租户页重新测活'
}}
</div>
</div>
</template>
+2 -2
View File
@@ -1,13 +1,13 @@
<script setup lang="ts">
import { useMessage } from 'naive-ui'
import { computed, ref } from 'vue'
import { useToast } from '@/composables/useToast'
/** 拖拽或点击上传的文本文件选择区;文件内容仅在浏览器本地读取。
* compact:单行紧凑形态,用于表单内与其他字段并排。 */
const props = defineProps<{ accept?: string; label?: string; hint?: string; compact?: boolean }>()
const emit = defineEmits<{ load: [text: string, name: string] }>()
const message = useMessage()
const message = useToast()
const inputEl = ref<HTMLInputElement>()
const fileName = ref('')
const dragging = ref(false)
+3 -2
View File
@@ -1,6 +1,7 @@
<script setup lang="ts">
import { NButton, useMessage } from 'naive-ui'
import { NButton } from 'naive-ui'
import { computed } from 'vue'
import { useToast } from '@/composables/useToast'
/** 统一的 JSON 展示块:美化缩进 + 语法高亮 + 复制;三个日志详情共用。
* 传 title 时渲染工具栏头(左标签 + meta + 右复制按钮),否则复制按钮浮动。
@@ -14,7 +15,7 @@ const props = defineProps<{
wide?: boolean
}>()
const message = useMessage()
const message = useToast()
const pretty = computed(() => {
const v = props.value
+3 -2
View File
@@ -1,11 +1,12 @@
<script setup lang="ts">
import { NButton, NIcon, useMessage } from 'naive-ui'
import { NButton, NIcon } from 'naive-ui'
import { truncOcid } from '@/composables/useFormat'
import { useToast } from '@/composables/useToast'
const props = defineProps<{ ocid: string }>()
const message = useMessage()
const message = useToast()
async function copy() {
await navigator.clipboard.writeText(props.ocid)
+11 -12
View File
@@ -1,5 +1,5 @@
<script setup lang="ts">
import { NButton, NDataTable, NInput, NSelect, NTooltip, useDialog, useMessage, type DataTableColumns } from 'naive-ui'
import { NButton, NDataTable, NInput, NSelect, NTooltip, useDialog, type DataTableColumns } from 'naive-ui'
import { computed, h, reactive, ref } from 'vue'
import { createAiChannel, deleteAiChannel, probeAiChannel, syncAiChannelModels, updateAiChannel } from '@/api/aigateway'
@@ -18,7 +18,6 @@ import type { AiChannel, AiProbeStatus } from '@/types/api'
defineProps<{ channels: AiChannel[]; loading: boolean }>()
const emit = defineEmits<{ changed: [] }>()
const message = useMessage()
const toast = useToast()
const dialog = useDialog()
const scope = useScopeStore()
@@ -67,7 +66,7 @@ async function submit() {
try {
if (editing.value) {
await updateAiChannel(editing.value.id, { name: form.name, group: form.group, priority: form.priority, weight: form.weight })
message.success('已更新渠道')
toast.success('已更新渠道')
showForm.value = false
emit('changed')
} else {
@@ -77,11 +76,11 @@ async function submit() {
})
showForm.value = false
emit('changed')
message.success('渠道已添加,正在探测…')
toast.success('渠道已添加,正在探测…')
void doProbe(ch.id)
}
} catch (e) {
message.error(e instanceof Error ? e.message : '保存失败')
toast.error(e instanceof Error ? e.message : '保存失败')
} finally {
submitting.value = false
}
@@ -95,12 +94,12 @@ async function doProbe(id: number) {
const ch = await probeAiChannel(id)
const meta = ch.probeStatus ? PROBE_META[ch.probeStatus as Exclude<AiProbeStatus, ''>] : null
if (ch.probeStatus === 'ok') {
message.success('探测完成:可用')
toast.success('探测完成:可用')
} else {
toast.warning(`探测完成:${meta?.label ?? ch.probeStatus}`, ch.probeError || undefined)
}
} catch (e) {
message.error(e instanceof Error ? e.message : '探测失败')
toast.error(e instanceof Error ? e.message : '探测失败')
} finally {
probing.value.delete(id)
emit('changed')
@@ -110,20 +109,20 @@ async function doProbe(id: number) {
async function doSync(id: number) {
try {
const models = await syncAiChannelModels(id)
message.success(`已同步 ${models.length} 个模型`)
toast.success(`已同步 ${models.length} 个模型`)
emit('changed')
} catch (e) {
message.error(e instanceof Error ? e.message : '同步失败')
toast.error(e instanceof Error ? e.message : '同步失败')
}
}
async function toggle(ch: AiChannel) {
try {
await updateAiChannel(ch.id, { enabled: !ch.enabled })
message.success(ch.enabled ? '已停用' : '已启用')
toast.success(ch.enabled ? '已停用' : '已启用')
emit('changed')
} catch (e) {
message.error(e instanceof Error ? e.message : '操作失败')
toast.error(e instanceof Error ? e.message : '操作失败')
}
}
@@ -135,7 +134,7 @@ function confirmRemove(ch: AiChannel) {
negativeText: '取消',
onPositiveClick: async () => {
await deleteAiChannel(ch.id)
message.success('已删除')
toast.success('已删除')
emit('changed')
},
})
+3 -2
View File
@@ -1,5 +1,5 @@
<script setup lang="ts">
import { NButton, NDataTable, NInput, useDialog, useMessage, type DataTableColumns } from 'naive-ui'
import { NButton, NDataTable, NInput, useDialog, type DataTableColumns } from 'naive-ui'
import { computed, h, reactive, ref } from 'vue'
import { createAiKey, deleteAiKey, updateAiKey, updateAiKeyContentLog } from '@/api/aigateway'
@@ -9,11 +9,12 @@ import FormModal from '@/components/FormModal.vue'
import StatusBadge from '@/components/StatusBadge.vue'
import { fmtTime } from '@/composables/useFormat'
import type { AiKey } from '@/types/api'
import { useToast } from '@/composables/useToast'
const props = defineProps<{ keys: AiKey[]; loading: boolean; groups: string[] }>()
const emit = defineEmits<{ changed: [] }>()
const message = useMessage()
const message = useToast()
const dialog = useDialog()
// ---- 新建 / 编辑弹窗 ----
+3 -2
View File
@@ -1,5 +1,5 @@
<script setup lang="ts">
import { NInput, NSelect, useMessage } from 'naive-ui'
import { NInput, NSelect } from 'naive-ui'
import { computed, reactive, watch } from 'vue'
import { ref } from 'vue'
@@ -12,11 +12,12 @@ import ToggleCard from '@/components/ToggleCard.vue'
import { useProxyOptions } from '@/composables/useProxyOptions'
import { useScopeStore } from '@/stores/scope'
import type { OciConfigSummary } from '@/types/api'
import { useToast } from '@/composables/useToast'
const props = defineProps<{ show: boolean; config: OciConfigSummary | null }>()
const emit = defineEmits<{ 'update:show': [boolean]; updated: [] }>()
const message = useMessage()
const message = useToast()
const submitting = ref(false)
const form = reactive({
+3 -2
View File
@@ -1,5 +1,5 @@
<script setup lang="ts">
import { NInput, NSelect, NTabPane, NTabs, useMessage } from 'naive-ui'
import { NInput, NSelect, NTabPane, NTabs } from 'naive-ui'
import { computed, reactive, ref, watch } from 'vue'
import { importConfig } from '@/api/configs'
@@ -11,11 +11,12 @@ import ToggleCard from '@/components/ToggleCard.vue'
import { useProxyOptions } from '@/composables/useProxyOptions'
import { useScopeStore } from '@/stores/scope'
import type { ImportConfigRequest } from '@/types/api'
import { useToast } from '@/composables/useToast'
const props = defineProps<{ show: boolean }>()
const emit = defineEmits<{ 'update:show': [boolean]; imported: [] }>()
const message = useMessage()
const message = useToast()
const mode = ref<'ini' | 'fields'>('ini')
const submitting = ref(false)
+3 -2
View File
@@ -1,5 +1,5 @@
<script setup lang="ts">
import { NInput, NSelect, useMessage, type SelectOption } from 'naive-ui'
import { NInput, NSelect, type SelectOption } from 'naive-ui'
import { computed, ref, watch } from 'vue'
import { attachVnic } from '@/api/instances'
@@ -9,6 +9,7 @@ import FormModal from '@/components/FormModal.vue'
import ToggleCard from '@/components/ToggleCard.vue'
import { useAsync } from '@/composables/useAsync'
import { shortAd } from '@/composables/useFormat'
import { useToast } from '@/composables/useToast'
const props = defineProps<{
show: boolean
@@ -21,7 +22,7 @@ const props = defineProps<{
const emit = defineEmits<{ 'update:show': [boolean]; attached: [] }>()
const message = useMessage()
const message = useToast()
const submitting = ref(false)
const subnetId = ref<string | null>(null)
const displayName = ref('')
@@ -1,5 +1,5 @@
<script setup lang="ts">
import { NCheckbox, NSelect, useMessage, type SelectGroupOption } from 'naive-ui'
import { NCheckbox, NSelect, type SelectGroupOption } from 'naive-ui'
import { computed, ref, watch } from 'vue'
import { listBootVolumes } from '@/api/bootVolumes'
@@ -7,6 +7,7 @@ import { attachVolume, listVolumes } from '@/api/instances'
import FormField from '@/components/FormField.vue'
import FormModal from '@/components/FormModal.vue'
import { useAsync } from '@/composables/useAsync'
import { useToast } from '@/composables/useToast'
const props = defineProps<{
show: boolean
@@ -19,7 +20,7 @@ const props = defineProps<{
const emit = defineEmits<{ 'update:show': [boolean]; attached: [] }>()
const message = useMessage()
const message = useToast()
const submitting = ref(false)
const volumeId = ref<string | null>(null)
const readOnly = ref(false)
+3 -2
View File
@@ -1,15 +1,16 @@
<script setup lang="ts">
import { NInput, useMessage } from 'naive-ui'
import { NInput } from 'naive-ui'
import { computed, ref, watch } from 'vue'
import { createConsoleConnection } from '@/api/instances'
import FormField from '@/components/FormField.vue'
import FormModal from '@/components/FormModal.vue'
import { useToast } from '@/composables/useToast'
const props = defineProps<{ show: boolean; cfgId: number; instanceId: string; region?: string }>()
const emit = defineEmits<{ 'update:show': [boolean]; created: [] }>()
const message = useMessage()
const message = useToast()
const submitting = ref(false)
const publicKey = ref('')
@@ -1,5 +1,5 @@
<script setup lang="ts">
import { NInput, useMessage } from 'naive-ui'
import { NInput } from 'naive-ui'
import { computed, reactive, ref, watch } from 'vue'
import { createInstances } from '@/api/instances'
@@ -8,6 +8,7 @@ import FormField from '@/components/FormField.vue'
import FormModal from '@/components/FormModal.vue'
import InstanceSpecForm from '@/components/instance/InstanceSpecForm.vue'
import { defaultResourceName } from '@/composables/useFormat'
import { useToast } from '@/composables/useToast'
/** 租户 / 区间 / 区域直接使用父页面当前值,不在表单中出现 */
const props = defineProps<{
@@ -18,7 +19,7 @@ const props = defineProps<{
}>()
const emit = defineEmits<{ 'update:show': [boolean]; created: [] }>()
const message = useMessage()
const message = useToast()
const submitting = ref(false)
const specForm = ref<InstanceType<typeof InstanceSpecForm> | null>(null)
@@ -1,6 +1,4 @@
<script setup lang="ts">
import { useMessage } from 'naive-ui'
import AppInputNumber from '@/components/AppInputNumber.vue'
import { reactive, ref, watch } from 'vue'
@@ -8,6 +6,7 @@ import { updateBootVolume } from '@/api/bootVolumes'
import FormField from '@/components/FormField.vue'
import FormModal from '@/components/FormModal.vue'
import type { BootVolume } from '@/types/api'
import { useToast } from '@/composables/useToast'
const props = defineProps<{
show: boolean
@@ -17,7 +16,7 @@ const props = defineProps<{
}>()
const emit = defineEmits<{ 'update:show': [boolean]; updated: [] }>()
const message = useMessage()
const message = useToast()
const submitting = ref(false)
const form = reactive({ sizeInGBs: 50, vpusPerGB: 10 })
@@ -1,5 +1,5 @@
<script setup lang="ts">
import { NSelect, useMessage } from 'naive-ui'
import { NSelect } from 'naive-ui'
import { computed, ref, watch } from 'vue'
import { listBootVolumes } from '@/api/bootVolumes'
@@ -7,6 +7,7 @@ import { replaceBootVolume } from '@/api/instances'
import FormField from '@/components/FormField.vue'
import FormModal from '@/components/FormModal.vue'
import { useAsync } from '@/composables/useAsync'
import { useToast } from '@/composables/useToast'
const props = defineProps<{
show: boolean
@@ -18,7 +19,7 @@ const props = defineProps<{
const emit = defineEmits<{ 'update:show': [boolean]; replaced: [] }>()
const message = useMessage()
const message = useToast()
const submitting = ref(false)
const bootVolumeId = ref<string | null>(null)
+3 -2
View File
@@ -1,5 +1,5 @@
<script setup lang="ts">
import { NSelect, useMessage } from 'naive-ui'
import { NSelect } from 'naive-ui'
import { computed, reactive, ref, watch } from 'vue'
import { listShapes, updateInstance } from '@/api/instances'
@@ -7,6 +7,7 @@ import AppInputNumber from '@/components/AppInputNumber.vue'
import FormField from '@/components/FormField.vue'
import FormModal from '@/components/FormModal.vue'
import { useAsync } from '@/composables/useAsync'
import { useToast } from '@/composables/useToast'
const props = defineProps<{
show: boolean
@@ -20,7 +21,7 @@ const props = defineProps<{
const emit = defineEmits<{ 'update:show': [boolean]; resized: [] }>()
const message = useMessage()
const message = useToast()
const submitting = ref(false)
const form = reactive({ shape: props.shape, ocpus: props.ocpus, memoryInGBs: props.memoryInGBs })
+5 -12
View File
@@ -2,11 +2,12 @@
import { FitAddon } from '@xterm/addon-fit'
import { Terminal } from '@xterm/xterm'
import '@xterm/xterm/css/xterm.css'
import { NSpin, useMessage } from 'naive-ui'
import { NSpin } from 'naive-ui'
import { nextTick, onBeforeUnmount, ref, watch } from 'vue'
import { consoleSessionWsUrl, createConsoleSession, deleteConsoleSession } from '@/api/instances'
import { useAuthStore } from '@/stores/auth'
import { useToast } from '@/composables/useToast'
const props = defineProps<{
show: boolean
@@ -14,12 +15,11 @@ const props = defineProps<{
instanceId: string
region?: string
instanceName?: string
rootPassword?: string
}>()
const emit = defineEmits<{ 'update:show': [boolean] }>()
const message = useMessage()
const message = useToast()
const auth = useAuthStore()
const termEl = ref<HTMLDivElement | null>(null)
@@ -153,12 +153,6 @@ function syncWinsize() {
term.focus()
}
async function copyRootPassword() {
await navigator.clipboard.writeText(props.rootPassword ?? '')
message.success('已复制 root 密码')
term?.focus()
}
function reconnect() {
teardown()
void open()
@@ -250,7 +244,6 @@ onBeforeUnmount(teardown)
</span>
<span v-if="phase === 'creating'" class="text-xs">准备连接中</span>
<div class="flex-1" />
<button v-if="rootPassword" class="ser-btn" @click="copyRootPassword">复制 root 密码</button>
<button class="ser-btn" :disabled="phase !== 'connected'" @click="pasteFromClipboard">
粘贴
</button>
@@ -299,8 +292,8 @@ onBeforeUnmount(teardown)
<template v-else-if="phase === 'closed'">
<div class="max-w-[80%] break-all text-center">{{ error || '连接已关闭' }}</div>
<div class="max-w-[80%] text-center text-xs leading-relaxed">
串口登录需实例本地账户密码SSH 公钥无效创建实例时若启用随机 root
密码可从顶栏复制无密码也可查看启动日志或经 GRUB 单用户模式救援
串口登录需实例本地账户密码SSH 公钥无效随机 root 密码可在实例详情
验证身份后查看无密码也可查看启动日志或经 GRUB 单用户模式救援
</div>
<button class="ser-btn !border !border-[#3a3835] !px-3 !py-1" @click="reconnect">
重新连接
+3 -2
View File
@@ -1,5 +1,5 @@
<script setup lang="ts">
import { NButton, NPopconfirm, NSpin, useMessage } from 'naive-ui'
import { NButton, NPopconfirm, NSpin } from 'naive-ui'
import { computed, ref } from 'vue'
@@ -10,6 +10,7 @@ import LifecycleBadge from '@/components/LifecycleBadge.vue'
import OcidText from '@/components/OcidText.vue'
import { useAsync } from '@/composables/useAsync'
import { ATTACHMENT_TRANSIENT_STATES, useTransientPoll } from '@/composables/useTransientPoll'
import { useToast } from '@/composables/useToast'
/** 网卡(VNIC)区块:每卡一主行 + IPv6 副行;IPv6 增删按卡操作。
* 删除复用实例级接口(后端按地址遍历全部网卡),添加走 per-VNIC 接口。 */
@@ -23,7 +24,7 @@ const props = defineProps<{
const emit = defineEmits<{ changed: [] }>()
const message = useMessage()
const message = useToast()
const vnics = useAsync(() => listVnics(props.cfgId, props.instanceId, props.region))
useTransientPoll(
+3 -2
View File
@@ -1,5 +1,5 @@
<script setup lang="ts">
import { NDataTable, NModal, NTooltip, useMessage, type DataTableColumns } from 'naive-ui'
import { NDataTable, NModal, NTooltip, type DataTableColumns } from 'naive-ui'
import { computed, h, onMounted, reactive, ref } from 'vue'
import { listAiCallLogs, listAiContentLogs } from '@/api/aigateway'
@@ -9,8 +9,9 @@ import StatusBadge from '@/components/StatusBadge.vue'
import { useAutoRefresh } from '@/composables/useAutoRefresh'
import { fmtTime } from '@/composables/useFormat'
import type { AiCallLog, AiContentLog } from '@/types/api'
import { useToast } from '@/composables/useToast'
const message = useMessage()
const message = useToast()
const rows = ref<AiCallLog[]>([])
const loading = ref(false)
+313
View File
@@ -0,0 +1,313 @@
<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>
+22 -13
View File
@@ -1,10 +1,11 @@
<script setup lang="ts">
import { NDataTable, NModal, NPopover, useMessage, type DataTableColumns } from 'naive-ui'
import { NButton, 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'
@@ -18,8 +19,9 @@ import { useAsync } from '@/composables/useAsync'
import { useRegionAlias } from '@/composables/useRegionAlias'
import { useScopeStore } from '@/stores/scope'
import type { LogEvent, OciConfigSummary } from '@/types/api'
import { useToast } from '@/composables/useToast'
const message = useMessage()
const message = useToast()
const router = useRouter()
const scope = useScopeStore()
const { alias: regionAlias } = useRegionAlias()
@@ -39,6 +41,7 @@ const cfgById = computed(() => {
const detail = ref<LogEvent | null>(null)
const showDetail = ref(false)
const showRules = ref(false)
/** 受控远程分页:字面量对象会在重渲染时被重建导致状态丢失 */
const pagination = reactive({
@@ -219,16 +222,19 @@ useAutoRefresh(() => load(true))
OCI 侧推送的关键审计事件(Connector Hub Notifications 面板 webhook)
</div>
</div>
<TenantPicker
v-model:value="cfgFilter"
size="small"
clearable
placeholder="全部租户"
class="w-52"
:configs="scope.configs.data ?? []"
:loading="scope.configs.loading"
@update:value="onFilter"
/>
<div class="flex flex-wrap items-center gap-2">
<NButton size="small" @click="showRules = true">告警规则</NButton>
<TenantPicker
v-model:value="cfgFilter"
size="small"
clearable
placeholder="全部租户"
class="w-52"
:configs="scope.configs.data ?? []"
:loading="scope.configs.loading"
@update:value="onFilter"
/>
</div>
</div>
<NDataTable
remote
@@ -245,9 +251,12 @@ useAutoRefresh(() => load(true))
在租户详情「其他」tab 一键创建链路后,实例生命周期(Launch/Terminate/InstanceAction)、
用户与凭据(Create/Delete/UpdateUser、Create/DeleteApiKey、UpdateUserCapabilities)、
区域订阅与策略变更等关键审计事件将自动回传;消息按 MessageId 幂等去重,保留 90
天、总量超 2 万条时删除最旧,关键事件另经「通知管理 → 云端事件」推送告警
天、总量超 2 万条时删除最旧,关键事件另经「通知管理 → 云端事件」推送告警;
更细粒度的条件告警(事件/来源 IP/资源/频率)在「告警规则」中配置
</FootNote>
<AlertRuleModal v-model:show="showRules" />
<NModal v-model:show="showDetail" preset="card" closable :style="{ width: '720px', maxWidth: 'calc(100vw - 24px)' }">
<template #header>
<DetailHero
+3 -2
View File
@@ -1,5 +1,5 @@
<script setup lang="ts">
import { NDataTable, NInput, NModal, useMessage, type DataTableColumns } from 'naive-ui'
import { NDataTable, NInput, NModal, type DataTableColumns } from 'naive-ui'
import { computed, h, reactive, ref } from 'vue'
import { listSystemLogs } from '@/api/settings'
@@ -12,8 +12,9 @@ import { actionLabel } from '@/composables/useActionLabel'
import { useAutoRefresh } from '@/composables/useAutoRefresh'
import { fmtTime } from '@/composables/useFormat'
import type { SystemLog } from '@/types/api'
import { useToast } from '@/composables/useToast'
const message = useMessage()
const message = useToast()
const rows = ref<SystemLog[]>([])
const loading = ref(false)
+3 -2
View File
@@ -1,11 +1,12 @@
<script setup lang="ts">
import { NCheckbox, NInput, useMessage } from 'naive-ui'
import { NCheckbox, NInput } from 'naive-ui'
import { computed, reactive, ref, watch } from 'vue'
import { createVcn } from '@/api/networks'
import FormField from '@/components/FormField.vue'
import FormModal from '@/components/FormModal.vue'
import { defaultResourceName } from '@/composables/useFormat'
import { useToast } from '@/composables/useToast'
/** 租户 / 区间 / 区域直接使用父页面当前值,不在表单中出现 */
const props = defineProps<{
@@ -16,7 +17,7 @@ const props = defineProps<{
}>()
const emit = defineEmits<{ 'update:show': [boolean]; created: [] }>()
const message = useMessage()
const message = useToast()
const submitting = ref(false)
const blank = {
+2 -2
View File
@@ -7,7 +7,6 @@ import {
NPopconfirm,
NRadioButton,
NRadioGroup,
useMessage,
type DataTableColumns,
} from 'naive-ui'
import { computed, h, onUnmounted, ref } from 'vue'
@@ -25,8 +24,9 @@ import FootNote from '@/components/FootNote.vue'
import FormField from '@/components/FormField.vue'
import { useAsync } from '@/composables/useAsync'
import type { ProxyImportResult, ProxyInfo } from '@/types/api'
import { useToast } from '@/composables/useToast'
const message = useMessage()
const message = useToast()
const proxies = useAsync(listProxies)
const rows = computed(() => proxies.data.value?.items ?? [])
+28 -1
View File
@@ -5,8 +5,12 @@ import { onMounted, ref } from 'vue'
import { getAbout } from '@/api/settings'
import AppLogo from '@/components/AppLogo.vue'
import { useParticles } from '@/composables/useParticles'
import { useAppStore } from '@/stores/app'
import type { AboutInfo } from '@/types/api'
// 点击 logo 在星爆 / 波浪封印两款间切换(全局生效并记忆)
const app = useAppStore()
// GitHub 仓库地址;空串时按钮禁用并显示占位
const REPO_URL = 'https://github.com/wangdefaa/oci-portal'
@@ -45,7 +49,15 @@ function openRepo() {
<canvas ref="pcanvas" class="absolute inset-0 h-full w-full"></canvas>
</div>
<div class="relative">
<span class="floaty mx-auto block w-fit"><AppLogo :size="84" /></span>
<button
type="button"
class="floaty logo-btn mx-auto block w-fit"
title="切换 logo 款式"
aria-label="切换 logo 款式"
@click="app.toggleLogoVariant()"
>
<AppLogo :size="84" />
</button>
<div class="mt-5 font-serif text-[34px] leading-tight font-semibold">OCI Portal</div>
<div class="mt-1 text-[13px] text-ink-3">OCI 账号批量管理面板 · 自托管</div>
<div v-if="loading" class="mt-6 flex justify-center"><NSpin size="small" /></div>
@@ -98,6 +110,21 @@ function openRepo() {
border-radius: 50%;
border: 1.5px dashed color-mix(in srgb, var(--color-line) 70%, var(--color-accent) 30%);
}
/* logo 即款式开关:去按钮底色,悬停轻微放大提示可点 */
.logo-btn {
cursor: pointer;
border: none;
background: none;
padding: 0;
line-height: 0;
transition: scale 0.25s ease;
}
.logo-btn:hover {
scale: 1.06;
}
.logo-btn:active {
scale: 0.96;
}
@media (prefers-reduced-motion: no-preference) {
.spin {
animation: about-sp 52s linear infinite;
+51 -11
View File
@@ -1,11 +1,12 @@
<script setup lang="ts">
import { NButton, NInput, NModal, NPopconfirm, NQrCode, NSpin, NSwitch, useMessage } from 'naive-ui'
import { NButton, NInput, NModal, NPopconfirm, NQrCode, NSpin, NSwitch } from 'naive-ui'
import { computed, reactive, ref } from 'vue'
import { useRouter } from 'vue-router'
import {
activateTotp,
disableTotp,
revokeSessions,
getCredentials,
getOAuthSettings,
getOauthAuthorizeUrl,
@@ -24,12 +25,17 @@ import { useAsync } from '@/composables/useAsync'
import { useAppStore } from '@/stores/app'
import { useAuthStore } from '@/stores/auth'
import { fmtTime } from '@/composables/useFormat'
import type { TotpSetup, UpdateOAuthRequest } from '@/types/api'
import type { SessionRefresh, TotpSetup, UpdateOAuthRequest } from '@/types/api'
import { useToast } from '@/composables/useToast'
const message = useMessage()
const message = useToast()
const router = useRouter()
const auth = useAuthStore()
const app = useAppStore()
/** 敏感操作响应携带新会话时无感替换;204 降级(undefined)交由 401 流程重登 */
function applySession(r: SessionRefresh) {
if (r?.token) auth.setSession(r.token, r.expiresAt)
}
const providerLabels: Record<string, string> = { github: 'GitHub', oidc: 'OIDC 单点登录' }
@@ -69,7 +75,7 @@ async function confirmTotpActivate() {
}
totpBusy.value = true
try {
await activateTotp(totpActivateCode.value)
applySession(await activateTotp(totpActivateCode.value))
message.success('两步验证已启用,下次登录需输入动态验证码')
showTotpSetup.value = false
totpPending.value = null
@@ -86,7 +92,7 @@ async function confirmTotpDisable() {
totpBusy.value = true
try {
// 6 位纯数字按验证码提交,其余按密码
await disableTotp(/^\d{6}$/.test(input) ? { code: input } : { password: input })
applySession(await disableTotp(/^\d{6}$/.test(input) ? { code: input } : { password: input }))
message.success('两步验证已停用')
totpDisableInput.value = ''
showTotpDisable.value = false
@@ -151,15 +157,22 @@ async function saveCredentials() {
const { nameChanged, pwChanged } = credChanges.value
savingCred.value = true
try {
await updateCredentials({
const refresh = await updateCredentials({
...(nameChanged ? { newUsername: credForm.newUsername.trim() } : {}),
...(pwChanged ? { newPassword: credForm.newPassword } : {}),
currentPassword: credForm.currentPassword,
})
message.success('登录凭据已更新,请使用新凭据重新登录')
showCredModal.value = false
auth.logout()
void router.push('/login')
if (refresh?.token) {
// 版本递增使其余会话全部失效;当前会话经新 token 无感延续
applySession(refresh)
message.success('登录凭据已更新,其他已登录会话已全部失效')
void creds.run({ silent: true })
} else {
message.success('登录凭据已更新,请使用新凭据重新登录')
auth.logout()
void router.push('/login')
}
} catch (e) {
message.error(e instanceof Error ? e.message : '保存失败')
} finally {
@@ -171,7 +184,7 @@ async function saveCredentials() {
async function togglePasswordLogin(disabled: boolean) {
togglingPwLogin.value = true
try {
await updatePasswordLogin(disabled)
applySession(await updatePasswordLogin(disabled))
message.success(disabled ? '已禁用密码登录,仅外部身份可登录' : '已恢复密码登录')
} catch (e) {
message.error(e instanceof Error ? e.message : '操作失败')
@@ -204,7 +217,7 @@ async function bindProvider(provider: string) {
async function removeIdentity(id: number) {
try {
await unbindIdentity(id)
applySession(await unbindIdentity(id))
message.success('已解绑;该身份后续无法登录面板')
void identities.run()
} catch (e) {
@@ -212,6 +225,21 @@ async function removeIdentity(id: number) {
}
}
// ---- 撤销全部会话:令牌版本递增,除本会话(换新)外全部立即失效 ----
const revoking = ref(false)
async function revokeAllSessions() {
revoking.value = true
try {
applySession(await revokeSessions())
message.success('已撤销全部会话;其他设备须重新登录')
} catch (e) {
message.error(e instanceof Error ? e.message : '操作失败')
} finally {
revoking.value = false
}
}
// ---- 登录方式配置(OAuth provider):表格 + 弹窗增改;禁用仅隐藏登录入口,删除清全部配置 ----
type ProviderType = 'github' | 'oidc'
@@ -419,6 +447,18 @@ async function deleteProvider(p: ProviderType) {
<NButton size="tiny" quaternary @click="openCredModal">修改</NButton>
</div>
<div class="flex items-center justify-between gap-3 border-b border-line-soft py-2.5">
<div class="min-w-0">
<div class="text-[13px] font-medium">撤销全部会话</div>
<div class="mt-0.5 text-xs text-ink-3">
怀疑令牌泄露时使用;其他设备与旧令牌立即失效,本会话自动换新
</div>
</div>
<NButton size="tiny" type="error" quaternary :loading="revoking" @click="revokeAllSessions">
撤销
</NButton>
</div>
<div class="flex items-center justify-between gap-3 border-b border-line-soft py-2.5">
<div class="min-w-0">
<div class="text-[13px] font-medium">禁用密码登录</div>
@@ -0,0 +1,282 @@
<script setup lang="ts">
import { NButton, NCollapseTransition, NInput, NSwitch } from 'naive-ui'
import { computed, reactive, ref, watch } from 'vue'
import { testNotifyChannel, updateNotifyChannel } from '@/api/settings'
import AppInputNumber from '@/components/AppInputNumber.vue'
import FormField from '@/components/FormField.vue'
import { useToast } from '@/composables/useToast'
import type { NotifyChannelItem, NotifyChannelType } from '@/types/api'
const props = defineProps<{ item: NotifyChannelItem }>()
const emit = defineEmits<{ saved: [NotifyChannelItem[]] }>()
const message = useToast()
/** 渠道展示元数据:图标字符 + 名称 + 一句话说明 + 密文字段文案 */
const CHANNEL_META: Record<
NotifyChannelType,
{ icon: string; name: string; hint: string; secretLabel?: string; secretHint?: string }
> = {
webhook: {
icon: 'W',
name: 'Webhook',
hint: '通用 HTTP POST,可对接飞书 / 钉钉 / Slack / 企业微信机器人',
},
ntfy: {
icon: 'N',
name: 'ntfy',
hint: '开源推送服务,官方 ntfy.sh 或自建服务端',
secretLabel: 'Access Token',
secretHint: '服务端开启鉴权时填写;留空表示沿用已保存值',
},
bark: {
icon: 'B',
name: 'Bark',
hint: 'iOS 推送,官方 api.day.app 或自建服务端',
secretLabel: 'Device Key',
secretHint: 'Bark App 内的设备 key;留空表示沿用已保存值',
},
smtp: {
icon: 'M',
name: 'SMTP 邮件',
hint: '465 端口走隐式 TLS,其余端口自动 STARTTLS',
secretLabel: '密码',
secretHint: 'SMTP 授权码或密码;留空表示沿用已保存值',
},
}
/** Webhook body 模板预设(占位符 {{title}} / {{text}} 发送时替换并做 JSON 转义) */
const WEBHOOK_PRESETS = [
{ label: 'Slack', tpl: '{"text": "{{title}}\\n{{text}}"}' },
{ label: '飞书', tpl: '{"msg_type": "text", "content": {"text": "{{title}}\\n{{text}}"}}' },
{ label: '钉钉', tpl: '{"msgtype": "text", "text": {"content": "{{title}}\\n{{text}}"}}' },
{ label: '企业微信', tpl: '{"msgtype": "text", "text": {"content": "{{title}}\\n{{text}}"}}' },
]
const meta = computed(() => CHANNEL_META[props.item.type])
const expanded = ref(false)
const saving = ref(false)
const testing = ref(false)
const form = reactive({
enabled: false,
url: '',
bodyTemplate: '',
server: '',
topic: '',
host: '',
port: 587 as number | null,
username: '',
from: '',
to: '',
secret: '',
})
// 服务端数据到达/保存后回填;密文字段不回明文,输入框留空表示沿用
watch(
() => props.item,
(it) => {
form.enabled = it.enabled
form.url = it.url ?? ''
form.bodyTemplate = it.bodyTemplate ?? ''
form.server = it.server ?? ''
form.topic = it.topic ?? ''
form.host = it.host ?? ''
form.port = it.port || 587
form.username = it.username ?? ''
form.from = it.from ?? ''
form.to = it.to ?? ''
form.secret = ''
},
{ immediate: true },
)
const secretPlaceholder = computed(() =>
props.item.secretSet
? `已配置${props.item.secretTail ? `(尾号 ${props.item.secretTail}` : ''},留空沿用`
: '',
)
async function save() {
saving.value = true
try {
const secret = form.secret.trim()
const items = await updateNotifyChannel(props.item.type, {
enabled: form.enabled,
url: form.url.trim(),
bodyTemplate: form.bodyTemplate,
server: form.server.trim(),
topic: form.topic.trim(),
host: form.host.trim(),
port: form.port ?? 0,
username: form.username.trim(),
from: form.from.trim(),
to: form.to.trim(),
// 留空表示沿用已保存的密文字段
...(secret ? { secret } : {}),
})
message.success(`${meta.value.name} 配置已保存`)
form.secret = ''
emit('saved', items)
} catch (e) {
message.error(e instanceof Error ? e.message : '保存失败')
} finally {
saving.value = false
}
}
async function sendTest() {
testing.value = true
try {
await testNotifyChannel(props.item.type)
message.success(`测试消息已发送,请在 ${meta.value.name} 侧查收`)
} catch (e) {
message.error(e instanceof Error ? e.message : '发送失败')
} finally {
testing.value = false
}
}
</script>
<template>
<div class="border-b border-line-soft last:border-b-0">
<button
type="button"
class="flex w-full cursor-pointer items-center gap-3 px-4.5 py-3.5 text-left"
@click="expanded = !expanded"
>
<span
class="flex h-8.5 w-8.5 flex-none items-center justify-center rounded-full bg-wash text-[15px] font-bold text-ink-2"
>
{{ meta.icon }}
</span>
<div class="min-w-0 flex-1">
<div class="flex flex-wrap items-center gap-2">
<span class="text-[13px] font-medium">{{ meta.name }}</span>
<span
class="inline-flex items-center gap-1.5 rounded-full bg-wash px-2 py-px text-[11.5px] text-ink-2"
>
<span
class="h-1.5 w-1.5 rounded-full"
:class="item.enabled ? 'bg-ok' : 'bg-ink-3/50'"
/>
{{ item.enabled ? '已启用' : '未启用' }}
</span>
</div>
<div class="mt-0.5 text-xs text-ink-3">{{ meta.hint }}</div>
</div>
<span class="text-xs text-ink-3">{{ expanded ? '收起' : '配置' }}</span>
</button>
<NCollapseTransition :show="expanded">
<div class="px-4.5 pb-3.5">
<div class="mb-3 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>
<!-- Webhook -->
<template v-if="item.type === 'webhook'">
<FormField label="Webhook URL" hint="机器人/集成的完整回调地址,含鉴权参数">
<NInput v-model:value="form.url" placeholder="https://open.feishu.cn/open-apis/bot/v2/hook/…" />
</FormField>
<FormField
label="Body 模板"
hint="发送时 {{title}} / {{text}} 按 JSON 字符串转义后替换;留空按 Slack 形状发送"
>
<div class="mb-1.5 flex flex-wrap gap-1.5">
<NButton
v-for="p in WEBHOOK_PRESETS"
:key="p.label"
size="tiny"
quaternary
type="primary"
@click="form.bodyTemplate = p.tpl"
>
{{ p.label }}
</NButton>
</div>
<NInput
v-model:value="form.bodyTemplate"
type="textarea"
:autosize="{ minRows: 2, maxRows: 5 }"
class="mono"
:placeholder="WEBHOOK_PRESETS[0].tpl"
/>
</FormField>
</template>
<!-- ntfy -->
<template v-else-if="item.type === 'ntfy'">
<div class="grid grid-cols-2 gap-3 max-md:grid-cols-1">
<FormField label="服务端" hint="留空用官方 ntfy.sh">
<NInput v-model:value="form.server" placeholder="https://ntfy.sh" />
</FormField>
<FormField label="Topic" hint="订阅的主题名">
<NInput v-model:value="form.topic" placeholder="oci-portal" />
</FormField>
</div>
<FormField :label="meta.secretLabel!" :hint="meta.secretHint">
<NInput
v-model:value="form.secret"
type="password"
show-password-on="click"
:placeholder="secretPlaceholder || 'tk_…(可选)'"
/>
</FormField>
</template>
<!-- Bark -->
<template v-else-if="item.type === 'bark'">
<FormField label="服务端" hint="留空用官方 api.day.app">
<NInput v-model:value="form.server" placeholder="https://api.day.app" />
</FormField>
<FormField :label="meta.secretLabel!" :hint="meta.secretHint">
<NInput
v-model:value="form.secret"
type="password"
show-password-on="click"
:placeholder="secretPlaceholder || 'Bark App 内复制'"
/>
</FormField>
</template>
<!-- SMTP -->
<template v-else>
<div class="grid grid-cols-2 gap-3 max-md:grid-cols-1">
<FormField label="主机">
<NInput v-model:value="form.host" placeholder="smtp.example.com" />
</FormField>
<FormField label="端口" hint="465 隐式 TLS,587 STARTTLS">
<AppInputNumber v-model:value="form.port" :min="1" :max="65535" class="!w-full" />
</FormField>
<FormField label="用户名" hint="留空表示免认证">
<NInput v-model:value="form.username" placeholder="user@example.com" />
</FormField>
<FormField :label="meta.secretLabel!" :hint="meta.secretHint">
<NInput
v-model:value="form.secret"
type="password"
show-password-on="click"
:placeholder="secretPlaceholder || 'SMTP 授权码'"
/>
</FormField>
<FormField label="发件人">
<NInput v-model:value="form.from" placeholder="noreply@example.com" />
</FormField>
<FormField label="收件人">
<NInput v-model:value="form.to" placeholder="me@example.com" />
</FormField>
</div>
</template>
<div class="mt-1 flex items-center gap-2">
<NButton size="small" type="primary" :loading="saving" @click="save">保存</NButton>
<NButton size="small" :loading="testing" @click="sendTest">发送测试消息</NButton>
<span class="text-xs text-ink-3">测试使用已保存的配置,修改后请先保存</span>
</div>
</div>
</NCollapseTransition>
</div>
</template>
@@ -1,9 +1,10 @@
<script setup lang="ts">
import { NButton, NInput, NModal, useMessage } from 'naive-ui'
import { NButton, NInput, NModal } from 'naive-ui'
import { computed, ref, watch } from 'vue'
import { testNotifyTemplate, updateNotifyTemplate } from '@/api/settings'
import type { NotifyTemplateItem } from '@/types/api'
import { useToast } from '@/composables/useToast'
const props = defineProps<{
show: boolean
@@ -18,7 +19,7 @@ const emit = defineEmits<{
saved: [kind: string, template: string]
}>()
const message = useMessage()
const message = useToast()
const draft = ref('')
const saving = ref(false)
const testing = ref(false)
@@ -1,5 +1,5 @@
<script setup lang="ts">
import { NSelect, useMessage } from 'naive-ui'
import { NSelect } from 'naive-ui'
import { computed, ref, watch } from 'vue'
import { attachBootVolume, listInstances } from '@/api/instances'
@@ -8,6 +8,7 @@ import FormModal from '@/components/FormModal.vue'
import { shortAd } from '@/composables/useFormat'
import { useAsync } from '@/composables/useAsync'
import type { BootVolume } from '@/types/api'
import { useToast } from '@/composables/useToast'
const props = defineProps<{
show: boolean
@@ -17,7 +18,7 @@ const props = defineProps<{
}>()
const emit = defineEmits<{ 'update:show': [boolean]; attached: [] }>()
const message = useMessage()
const message = useToast()
const submitting = ref(false)
const instanceId = ref<string | null>(null)
@@ -1,5 +1,5 @@
<script setup lang="ts">
import { NInput, useMessage } from 'naive-ui'
import { NInput } from 'naive-ui'
import AppInputNumber from '@/components/AppInputNumber.vue'
import { computed, reactive, ref, watch } from 'vue'
@@ -8,6 +8,7 @@ import { updateBootVolume } from '@/api/bootVolumes'
import FormField from '@/components/FormField.vue'
import FormModal from '@/components/FormModal.vue'
import type { BootVolume, UpdateBootVolumeRequest } from '@/types/api'
import { useToast } from '@/composables/useToast'
const props = defineProps<{
show: boolean
@@ -17,7 +18,7 @@ const props = defineProps<{
}>()
const emit = defineEmits<{ 'update:show': [boolean]; updated: [] }>()
const message = useMessage()
const message = useToast()
const submitting = ref(false)
const form = reactive({ displayName: '', sizeInGBs: 50, vpusPerGB: 10 })
+3 -2
View File
@@ -1,5 +1,5 @@
<script setup lang="ts">
import { NInput, NSelect, useMessage } from 'naive-ui'
import { NInput, NSelect } from 'naive-ui'
import { computed, nextTick, reactive, ref, watch } from 'vue'
import { listCachedCompartments, listCachedRegions, listConfigs } from '@/api/configs'
@@ -15,6 +15,7 @@ import TenantPicker from '@/components/TenantPicker.vue'
import { defaultResourceName } from '@/composables/useFormat'
import { useAsync } from '@/composables/useAsync'
import type { Task, TaskType } from '@/types/api'
import { useToast } from '@/composables/useToast'
/** task 传入即为编辑模式:回填全部字段,任务类型锁定不可切换 */
const props = defineProps<{ show: boolean; task?: Task | null }>()
@@ -29,7 +30,7 @@ const TYPE_CARDS: { value: TaskType; title: string; desc: string }[] = [
{ value: 'snatch', title: '抢机', desc: '容量不足时反复尝试创建,抢满自停' },
]
const message = useMessage()
const message = useToast()
const submitting = ref(false)
const specForm = ref<InstanceType<typeof InstanceSpecForm> | null>(null)
+41 -47
View File
@@ -1,6 +1,6 @@
<script setup lang="ts">
import { NButton, NDataTable, NModal, NSelect, useMessage, type DataTableColumns } from 'naive-ui'
import { computed, h, onMounted, reactive, ref, watch } from 'vue'
import { NButton, NDataTable, NModal, type DataTableColumns } from 'naive-ui'
import { computed, h, onMounted, reactive, ref } from 'vue'
import { getAuditEventDetail, listAuditEvents } from '@/api/tenant'
import DetailFieldList, { type DetailRow } from '@/components/DetailFieldList.vue'
@@ -11,17 +11,21 @@ import StatusBadge from '@/components/StatusBadge.vue'
import { eventLabel } from '@/composables/useEventLabel'
import { fmtTime } from '@/composables/useFormat'
import type { AuditEvent } from '@/types/api'
import { useToast } from '@/composables/useToast'
const props = defineProps<{ cfgId: number }>()
const message = useMessage()
const message = useToast()
const hours = ref(24)
const hourOptions = [
{ label: '近 1 小时', value: 1 },
{ label: '近 6 小时', value: 6 },
{ label: '近 24 小时', value: 24 },
{ label: '近 72 小时', value: 72 },
]
const loading = ref(false)
const loadingMore = ref(false)
const error = ref('')
const rows = ref<AuditEvent[]>([])
// 服务端分窗回溯游标:空且 exhausted 表示已到 365 天保留期尽头
const cursor = ref('')
const exhausted = ref(false)
const pageCount = computed(() => Math.max(1, Math.ceil(rows.value.length / pagination.pageSize)))
const hasMore = computed(() => cursor.value !== '' && !exhausted.value)
/** 受控分页:字面量对象会在重渲染时被重建导致页大小切换失效 */
const pagination = reactive({
@@ -29,8 +33,13 @@ const pagination = reactive({
pageSize: 20,
showSizePicker: true,
pageSizes: [20, 50, 100],
prefix: () =>
`已加载 ${rows.value.length} 条 · ` +
(loadingMore.value ? '正在加载更早…' : exhausted.value ? '已到 365 天保留期尽头' : '翻到末页自动加载更早'),
onUpdatePage: (p: number) => {
pagination.page = p
// 懒加载触发点:翻到已加载数据的最后一页即向后端续取一批
if (p >= pageCount.value) void fetchBatch()
},
onUpdatePageSize: (ps: number) => {
pagination.pageSize = ps
@@ -38,55 +47,48 @@ const pagination = reactive({
},
})
const loading = ref(false)
const loadingMore = ref(false)
const error = ref('')
const rows = ref<AuditEvent[]>([])
const truncated = ref(false)
const nextPage = ref('')
// 本次查询的绝对时间窗:续查游标绑定查询参数,必须原样带回
const win = ref<{ start: string; end: string } | null>(null)
/** 重置信息流:回到最新一批 */
async function load() {
loading.value = true
error.value = ''
rows.value = []
cursor.value = ''
exhausted.value = false
pagination.page = 1
try {
const r = await listAuditEvents(props.cfgId, { hours: hours.value })
rows.value = r.items
truncated.value = r.truncated
nextPage.value = r.nextPage ?? ''
win.value = { start: r.start, end: r.end }
pagination.page = 1
} catch (e) {
error.value = e instanceof Error ? e.message : '查询失败'
await fetchBatch(true)
} finally {
loading.value = false
}
}
/** 截断续查:同一绝对窗带游标断点续翻,追加去重后按时间重排 */
async function loadMore() {
if (!win.value || !nextPage.value || loadingMore.value) return
/** 向更早方向续取一批(~100 条):追加去重后按时间重排;
* 末页不满且还有更早数据时自动补一批,避免首屏残页 */
async function fetchBatch(first = false) {
if (loadingMore.value || (!first && !hasMore.value)) return
loadingMore.value = true
try {
const r = await listAuditEvents(props.cfgId, { ...win.value, page: nextPage.value })
const r = await listAuditEvents(props.cfgId, { cursor: cursor.value || undefined })
const seen = new Set(rows.value.map((e) => e.eventId))
rows.value = [...rows.value, ...r.items.filter((e) => !seen.has(e.eventId))].sort((a, b) =>
(b.eventTime ?? '').localeCompare(a.eventTime ?? ''),
)
truncated.value = r.truncated
nextPage.value = r.nextPage ?? ''
cursor.value = r.cursor ?? ''
exhausted.value = r.exhausted
} catch (e) {
// 追加失败不清空已有列表;游标过期时提示重新查询
message.error(e instanceof Error ? e.message : '继续加载失败,请刷新重新查询')
if (first) {
error.value = e instanceof Error ? e.message : '查询失败'
} else {
// 追加失败不清空已有列表;游标过期时提示刷新重来
message.error(e instanceof Error ? e.message : '继续加载失败,请刷新重新查询')
}
} finally {
loadingMore.value = false
}
if (hasMore.value && rows.value.length < pagination.pageSize) void fetchBatch()
}
onMounted(() => void load())
// 切换时间窗自动重查并回到第一页
watch(hours, () => void load())
// ---- 行点击详情:原始 JSON 懒取(命中服务端缓存秒开,过期走小窗重查) ----
const detail = ref<AuditEvent | null>(null)
@@ -202,16 +204,8 @@ const columns: DataTableColumns<AuditEvent> = [
<div class="panel">
<div class="flex flex-wrap items-center gap-2.5 border-b border-line-soft px-4.5 py-3">
<div class="text-sm font-semibold">审计日志</div>
<template v-if="truncated">
<StatusBadge kind="warn" label="结果已截断" />
<NButton v-if="nextPage" size="tiny" :loading="loadingMore" @click="loadMore">
继续加载更早
</NButton>
</template>
<StatusBadge v-if="exhausted" kind="run" label="已加载全部保留期数据" :dot="false" />
<div class="flex-1" />
<div class="w-32 max-md:w-full">
<NSelect v-model:value="hours" size="small" :options="hourOptions" />
</div>
<NButton size="small" :loading="loading" @click="load()">刷新</NButton>
</div>
@@ -235,7 +229,7 @@ const columns: DataTableColumns<AuditEvent> = [
OCI Audit 免费且默认开启事件保留 365 无需在云端做任何配置 ·
实时查询不入库事件通常延迟数分钟可见 ·
已默认过滤遥测噪声SummarizeMetricsData与内网地址发起的服务互调 ·
单次最多翻 10 截断时点继续加载更早断点续查 · 点击行查看完整详情
从最新事件起每批约 100 翻到末页自动向更早加载空档期自动扩窗回溯 · 点击行查看完整详情
</FootNote>
<NModal v-model:show="showDetail" preset="card" closable :style="{ width: '720px', maxWidth: 'calc(100vw - 24px)' }">
+7 -6
View File
@@ -1,16 +1,17 @@
<script setup lang="ts">
import { NCheckbox, NInput, NSelect, NSwitch, useMessage } from 'naive-ui'
import { NCheckbox, NInput, NSelect, NSwitch } from 'naive-ui'
import { computed, reactive, ref, watch } from 'vue'
import { createIdp, getIdentitySetting, type CreateIdpBody } from '@/api/tenant'
import FilePicker from '@/components/FilePicker.vue'
import FormField from '@/components/FormField.vue'
import FormModal from '@/components/FormModal.vue'
import { useToast } from '@/composables/useToast'
const props = defineProps<{ show: boolean; cfgId: number }>()
const props = defineProps<{ show: boolean; cfgId: number; domainId?: string }>()
const emit = defineEmits<{ 'update:show': [boolean]; created: [] }>()
const message = useMessage()
const message = useToast()
const submitting = ref(false)
// 「用户需要提供主电子邮件地址」开启时 JIT 必须映射邮箱
const primaryEmailRequired = ref(false)
@@ -32,7 +33,7 @@ const userAttrOptions = [
]
// 默认值与控制台一致:名称 ID 格式「无」、NameID 映射用户名、
// JIT 开启建用户不更新、分配 Administrators
// JIT 开启建用户不更新、分配租户管理员
const blank = {
name: '',
metadata: '',
@@ -103,7 +104,7 @@ function buildBody(): CreateIdpBody {
async function submit() {
submitting.value = true
try {
const created = await createIdp(props.cfgId, buildBody())
const created = await createIdp(props.cfgId, buildBody(), props.domainId)
message.success(`IdP「${created.name}」已创建(禁用态),激活后显示到登录页`)
emit('update:show', false)
emit('created')
@@ -199,7 +200,7 @@ async function submit() {
<NCheckbox v-model:checked="form.jitCreate">首次联邦登录时自动创建用户</NCheckbox>
<NCheckbox v-model:checked="form.jitUpdate">每次登录时按断言更新既有用户</NCheckbox>
<NCheckbox v-model:checked="form.jitAssignAdminGroup">
JIT 用户加入 Administrators
JIT 用户加入租户管理员
</NCheckbox>
<NCheckbox
v-model:checked="form.jitMapEmail"
+12 -11
View File
@@ -1,5 +1,5 @@
<script setup lang="ts">
import { NButton, NDataTable, NPopconfirm, NSwitch, useDialog, useMessage, type DataTableColumns } from 'naive-ui'
import { NButton, NDataTable, NPopconfirm, NSwitch, useDialog, type DataTableColumns } from 'naive-ui'
import { h, ref } from 'vue'
import {
@@ -16,13 +16,14 @@ import StatusBadge from '@/components/StatusBadge.vue'
import IdpFormModal from '@/components/tenant/IdpFormModal.vue'
import { useAsync } from '@/composables/useAsync'
import type { IdentityProvider, SignOnRule } from '@/types/api'
import { useToast } from '@/composables/useToast'
const props = defineProps<{ cfgId: number }>()
const props = defineProps<{ cfgId: number; domainId?: string }>()
const message = useMessage()
const message = useToast()
const dialog = useDialog()
const idps = useAsync(() => listIdps(props.cfgId))
const rules = useAsync(() => listSignOnRules(props.cfgId))
const idps = useAsync(() => listIdps(props.cfgId, props.domainId))
const rules = useAsync(() => listSignOnRules(props.cfgId, props.domainId))
const showCreate = ref(false)
async function act(fn: () => Promise<unknown>, ok: string) {
@@ -74,7 +75,7 @@ const idpColumns: DataTableColumns<IdentityProvider> = [
size: 'small',
value: row.enabled,
onUpdateValue: (v: boolean) =>
act(() => activateIdp(props.cfgId, row.id, v), v ? '已激活并显示到登录页' : '已停用'),
act(() => activateIdp(props.cfgId, row.id, v, props.domainId), v ? '已激活并显示到登录页' : '已停用'),
}),
h(
NButton,
@@ -123,7 +124,7 @@ const ruleColumns: DataTableColumns<SignOnRule> = [
NPopconfirm,
{
onPositiveClick: () =>
act(() => deleteSignOnExemption(props.cfgId, row.id), '已删除免 MFA 规则并恢复优先级'),
act(() => deleteSignOnExemption(props.cfgId, row.id, props.domainId), '已删除免 MFA 规则并恢复优先级'),
},
{
trigger: () =>
@@ -136,7 +137,7 @@ const ruleColumns: DataTableColumns<SignOnRule> = [
async function doDownloadMetadata() {
try {
await downloadSamlMetadata(props.cfgId)
await downloadSamlMetadata(props.cfgId, props.domainId)
message.success('SAML 元数据已下载')
} catch (e) {
message.error(e instanceof Error ? e.message : '下载失败')
@@ -154,7 +155,7 @@ function confirmDeleteIdp(row: IdentityProvider) {
positiveText: '确认删除',
negativeText: '取消',
onPositiveClick: () =>
act(() => deleteIdp(props.cfgId, row.id), `已删除 IdP「${row.name}」及其关联规则`),
act(() => deleteIdp(props.cfgId, row.id, props.domainId), `已删除 IdP「${row.name}」及其关联规则`),
})
}
@@ -165,7 +166,7 @@ function addExemption() {
return
}
void act(
() => createSignOnExemption(props.cfgId, enabled.id),
() => createSignOnExemption(props.cfgId, enabled.id, props.domainId),
`已为 ${enabled.name} 创建免 MFA 规则并置顶`,
)
}
@@ -211,6 +212,6 @@ function addExemption() {
</FootNote>
</div>
<IdpFormModal v-model:show="showCreate" :cfg-id="cfgId" @created="idps.run()" />
<IdpFormModal v-model:show="showCreate" :cfg-id="cfgId" :domain-id="domainId" @created="idps.run()" />
</div>
</template>
+10 -8
View File
@@ -1,5 +1,5 @@
<script setup lang="ts">
import { NButton, NDynamicTags, NPopconfirm, NSpin, NSwitch, useMessage } from 'naive-ui'
import { NButton, NDynamicTags, NPopconfirm, NSpin, NSwitch } from 'naive-ui'
import { computed, ref, watch } from 'vue'
import {
@@ -22,14 +22,15 @@ import StatusBadge from '@/components/StatusBadge.vue'
import PolicyEditModal from '@/components/tenant/PolicyEditModal.vue'
import { useAsync } from '@/composables/useAsync'
import type { PasswordPolicy } from '@/types/api'
import { useToast } from '@/composables/useToast'
const props = defineProps<{ cfgId: number }>()
const props = defineProps<{ cfgId: number; domainId?: string }>()
const message = useMessage()
const message = useToast()
const policies = useAsync(() => listPasswordPolicies(props.cfgId))
const recipients = useAsync(() => getNotificationRecipients(props.cfgId))
const identity = useAsync(() => getIdentitySetting(props.cfgId))
const policies = useAsync(() => listPasswordPolicies(props.cfgId, props.domainId))
const recipients = useAsync(() => getNotificationRecipients(props.cfgId, props.domainId))
const identity = useAsync(() => getIdentitySetting(props.cfgId, props.domainId))
const webhook = useAsync(() => getLogWebhook(props.cfgId))
const relay = useAsync(() => getLogRelay(props.cfgId))
const savingIdentity = ref(false)
@@ -114,7 +115,7 @@ watch(
async function saveRecipients() {
saving.value = true
try {
await updateNotificationRecipients(props.cfgId, emails.value)
await updateNotificationRecipients(props.cfgId, emails.value, props.domainId)
message.success(emails.value.length ? '通知收件人已保存' : '已关闭 test mode,恢复默认发送')
void recipients.run()
} catch (e) {
@@ -127,7 +128,7 @@ async function saveRecipients() {
async function toggleEmailRequired(v: boolean) {
savingIdentity.value = true
try {
await updateIdentitySetting(props.cfgId, v)
await updateIdentitySetting(props.cfgId, v, props.domainId)
message.success(v ? '已开启:添加用户 / JIT 预配必须提供邮箱' : '已关闭:邮箱变为可选')
void identity.run()
} catch (e) {
@@ -402,6 +403,7 @@ function policyDesc(p: PasswordPolicy): string {
<PolicyEditModal
v-model:show="showPolicyEdit"
:cfg-id="cfgId"
:domain-id="domainId"
:policy="editingPolicy"
@updated="policies.run()"
/>
+5 -4
View File
@@ -1,19 +1,20 @@
<script setup lang="ts">
import { NSwitch, useMessage } from 'naive-ui'
import { NSwitch } from 'naive-ui'
import { reactive, ref, watch } from 'vue'
import { updatePasswordPolicy } from '@/api/tenant'
import FormModal from '@/components/FormModal.vue'
import type { PasswordPolicy } from '@/types/api'
import { useToast } from '@/composables/useToast'
const props = defineProps<{ show: boolean; cfgId: number; policy: PasswordPolicy | null }>()
const props = defineProps<{ show: boolean; cfgId: number; domainId?: string; policy: PasswordPolicy | null }>()
const emit = defineEmits<{ 'update:show': [boolean]; updated: [] }>()
// 关闭开关时写回的控制台默认值
const DEFAULT_EXPIRES_DAYS = 120
const DEFAULT_HISTORY_COUNT = 4
const message = useMessage()
const message = useToast()
const submitting = ref(false)
const form = reactive({ neverExpires: true, allowReuse: true })
@@ -45,7 +46,7 @@ async function submit() {
}
submitting.value = true
try {
await updatePasswordPolicy(props.cfgId, props.policy.id, body)
await updatePasswordPolicy(props.cfgId, props.policy.id, body, props.domainId)
message.success('密码策略已更新')
emit('update:show', false)
emit('updated')
@@ -1,11 +1,12 @@
<script setup lang="ts">
import { NCheckbox, NSelect, useMessage } from 'naive-ui'
import { NCheckbox, NSelect } from 'naive-ui'
import { computed, ref, watch } from 'vue'
import { listRegions, subscribeRegion } from '@/api/configs'
import FormField from '@/components/FormField.vue'
import FormModal from '@/components/FormModal.vue'
import { useAsync } from '@/composables/useAsync'
import { useToast } from '@/composables/useToast'
const props = defineProps<{
show: boolean
@@ -16,7 +17,7 @@ const props = defineProps<{
}>()
const emit = defineEmits<{ 'update:show': [boolean]; subscribed: [] }>()
const message = useMessage()
const message = useToast()
const submitting = ref(false)
const regionKey = ref<string | null>(null)
const acknowledged = ref(false)
+21 -16
View File
@@ -1,5 +1,5 @@
<script setup lang="ts">
import { NCheckbox, NInput, useMessage } from 'naive-ui'
import { NCheckbox, NInput } from 'naive-ui'
import { computed, reactive, ref, watch } from 'vue'
import {
@@ -12,12 +12,13 @@ import {
import FormField from '@/components/FormField.vue'
import FormModal from '@/components/FormModal.vue'
import type { IamUser, IamUserDetail } from '@/types/api'
import { useToast } from '@/composables/useToast'
// user
const props = defineProps<{ show: boolean; cfgId: number; user?: IamUser | null }>()
const props = defineProps<{ show: boolean; cfgId: number; domainId?: string; user?: IamUser | null }>()
const emit = defineEmits<{ 'update:show': [boolean]; created: [] }>()
const message = useMessage()
const message = useToast()
const submitting = ref(false)
//
const emailRequired = ref(false)
@@ -57,7 +58,7 @@ watch(
async function loadIdentitySetting() {
try {
emailRequired.value = (await getIdentitySetting(props.cfgId)).primaryEmailRequired
emailRequired.value = (await getIdentitySetting(props.cfgId, props.domainId)).primaryEmailRequired
} catch {
emailRequired.value = false
}
@@ -67,7 +68,7 @@ async function loadIdentitySetting() {
async function loadDetail(userId: string) {
detailLoading.value = true
try {
const d = await getUserDetail(props.cfgId, userId)
const d = await getUserDetail(props.cfgId, userId, props.domainId)
if (props.user?.id !== userId) return
detail.value = d
if (!d.inDomain) return
@@ -139,20 +140,24 @@ async function submitEdit(u: IamUser) {
emit('update:show', false)
return
}
await updateUser(props.cfgId, u.id, body)
await updateUser(props.cfgId, u.id, body, props.domainId)
message.success(`用户「${u.name}」已更新`)
}
async function submitCreate() {
const created = await createUser(props.cfgId, {
name: form.name.trim(),
givenName: form.givenName.trim(),
familyName: form.familyName.trim(),
email: form.email.trim() || undefined,
description: form.description.trim() || undefined,
grantDomainAdmin: form.grantDomainAdmin,
addToAdminGroup: form.addToAdminGroup,
})
const created = await createUser(
props.cfgId,
{
name: form.name.trim(),
givenName: form.givenName.trim(),
familyName: form.familyName.trim(),
email: form.email.trim() || undefined,
description: form.description.trim() || undefined,
grantDomainAdmin: form.grantDomainAdmin,
addToAdminGroup: form.addToAdminGroup,
},
props.domainId,
)
message.success(`用户「${created.name}」已创建,可再执行「重置密码」下发初始密码`)
}
@@ -225,7 +230,7 @@ async function submit() {
{{ editing ? '身份域管理员' : '添加到身份域管理员' }}
</NCheckbox>
<NCheckbox v-model:checked="form.addToAdminGroup" :disabled="classicUser || detailLoading">
{{ editing ? '管理员组Administrators成员' : '添加到管理员组Administrators' }}
{{ editing ? '租户管理员组成员' : '添加到租户管理员组' }}
</NCheckbox>
<div v-if="adminHint" class="text-xs text-ink-3">{{ adminHint }}</div>
</div>
+9 -7
View File
@@ -1,5 +1,5 @@
<script setup lang="ts">
import { NButton, NDataTable, NPopconfirm, useDialog, useMessage, type DataTableColumns } from 'naive-ui'
import { NButton, NDataTable, NPopconfirm, useDialog, type DataTableColumns } from 'naive-ui'
import { h, ref } from 'vue'
import { clearUserMfa, deleteUser, deleteUserApiKeys, listUsers, resetUserPassword } from '@/api/tenant'
@@ -9,12 +9,13 @@ import UserFormModal from '@/components/tenant/UserFormModal.vue'
import { fmtTime } from '@/composables/useFormat'
import { useAsync } from '@/composables/useAsync'
import type { IamUser } from '@/types/api'
import { useToast } from '@/composables/useToast'
const props = defineProps<{ cfgId: number }>()
const props = defineProps<{ cfgId: number; domainId?: string }>()
const message = useMessage()
const message = useToast()
const dialog = useDialog()
const users = useAsync(() => listUsers(props.cfgId))
const users = useAsync(() => listUsers(props.cfgId, props.domainId))
const showForm = ref(false)
const editingUser = ref<IamUser | null>(null)
@@ -48,13 +49,13 @@ function confirmDelete(row: IamUser) {
]),
positiveText: '确认删除',
negativeText: '取消',
onPositiveClick: () => act(() => deleteUser(props.cfgId, row.id), `已删除用户 ${row.name}`),
onPositiveClick: () => act(() => deleteUser(props.cfgId, row.id, props.domainId), `已删除用户 ${row.name}`),
})
}
async function resetPwd(row: IamUser) {
try {
const { password } = await resetUserPassword(props.cfgId, row.id)
const { password } = await resetUserPassword(props.cfgId, row.id, props.domainId)
dialog.success({
title: '一次性密码',
content: () =>
@@ -119,7 +120,7 @@ const columns: DataTableColumns<IamUser> = [
NPopconfirm,
{
onPositiveClick: () =>
act(() => clearUserMfa(props.cfgId, row.id), `已清除 ${row.name} 的全部 MFA`),
act(() => clearUserMfa(props.cfgId, row.id, props.domainId), `已清除 ${row.name} 的全部 MFA`),
},
{
trigger: () => h(NButton, { size: 'tiny', quaternary: true }, { default: () => '清 MFA' }),
@@ -169,6 +170,7 @@ const columns: DataTableColumns<IamUser> = [
<UserFormModal
v-model:show="showForm"
:cfg-id="cfgId"
:domain-id="domainId"
:user="editingUser"
@created="users.run()"
/>