Files
SpectraElement/Hardware-Vue/src/components/AdminFunctionPanel.vue
T
2026-11-17 16:28:24 +08:00

258 lines
6.1 KiB
Vue

<script setup lang="ts">
import { nextTick, onBeforeUnmount, ref, watch } from 'vue'
const props = defineProps<{
open: boolean
}>()
const emit = defineEmits<{
close: []
'system-config': []
ruler: []
}>()
const firstButton = ref<HTMLButtonElement | null>(null)
function close() {
emit('close')
}
function onKeydown(event: KeyboardEvent) {
if (event.key === 'Escape') close()
}
watch(
() => props.open,
async (open) => {
if (open) {
window.addEventListener('keydown', onKeydown)
await nextTick()
firstButton.value?.focus()
} else {
window.removeEventListener('keydown', onKeydown)
}
},
)
onBeforeUnmount(() => {
window.removeEventListener('keydown', onKeydown)
})
</script>
<template>
<Teleport to="body">
<Transition name="function-panel">
<div v-if="open" class="panel-backdrop" @click.self="close">
<section
class="panel-card"
role="dialog"
aria-modal="true"
aria-label="管理员功能选择"
>
<header class="panel-card__header">
<h2>管理员功能</h2>
<p>请选择需要进入的功能</p>
</header>
<div class="panel-grid">
<button
ref="firstButton"
class="function-card"
type="button"
@click="emit('system-config')"
>
<span class="function-card__icon" aria-hidden="true">
<svg viewBox="0 0 64 64">
<path
d="M26 8h12l2 7a20 20 0 0 1 5 3l7-1 6 10-5 5a20 20 0 0 1 0 6l5 5-6 10-7-1a20 20 0 0 1-5 3l-2 7H26l-2-7a20 20 0 0 1-5-3l-7 1-6-10 5-5a20 20 0 0 1 0-6l-5-5 6-10 7 1a20 20 0 0 1 5-3Z"
fill="none"
stroke="currentColor"
stroke-width="3"
stroke-linejoin="round"
/>
<circle
cx="32"
cy="32"
r="8"
fill="none"
stroke="currentColor"
stroke-width="3"
/>
</svg>
</span>
<span class="function-card__label">参数设置</span>
<span class="function-card__desc">管理系统运行参数</span>
</button>
<button
class="function-card"
type="button"
@click="emit('ruler')"
>
<span class="function-card__icon" aria-hidden="true">
<svg viewBox="0 0 64 64">
<rect
x="7"
y="22"
width="50"
height="20"
rx="3"
fill="none"
stroke="currentColor"
stroke-width="3"
transform="rotate(-12 32 32)"
/>
<path
d="M16 26v7M24 24v7M32 22v7M40 20v7M48 18v7"
fill="none"
stroke="currentColor"
stroke-width="3"
stroke-linecap="round"
transform="rotate(-12 32 32)"
/>
</svg>
</span>
<span class="function-card__label">标尺设定</span>
<span class="function-card__desc">配置标尺与校准参数</span>
</button>
</div>
<button class="panel-card__close" type="button" @click="close">
取消
</button>
</section>
</div>
</Transition>
</Teleport>
</template>
<style scoped>
.panel-backdrop {
position: fixed;
inset: 0;
z-index: 70;
display: grid;
place-items: center;
padding: 24px;
background: rgba(18, 33, 54, 0.44);
backdrop-filter: blur(5px);
}
.panel-card {
width: 820px;
padding: 42px 46px 34px;
border: 1px solid rgba(255, 255, 255, 0.65);
border-radius: 24px;
background: #fff;
box-shadow: 0 30px 80px rgba(12, 30, 55, 0.3);
text-align: center;
}
.panel-card__header h2 {
color: #1f2937;
font-size: 32px;
font-weight: 600;
letter-spacing: 2px;
}
.panel-card__header p {
margin-top: 12px;
color: #778394;
font-size: 19px;
letter-spacing: 1px;
}
.panel-grid {
display: grid;
grid-template-columns: repeat(2, minmax(0, 1fr));
gap: 24px;
margin-top: 32px;
}
.function-card {
display: flex;
flex-direction: column;
align-items: center;
gap: 12px;
padding: 30px 24px 28px;
border: 2px solid var(--line);
border-radius: 18px;
background: linear-gradient(180deg, #ffffff 0%, #f7f9fc 100%);
transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}
.function-card:hover {
border-color: #b9d1f3;
box-shadow: 0 16px 34px rgba(47, 111, 208, 0.16);
transform: translateY(-3px);
}
.function-card__icon {
display: grid;
place-items: center;
width: 88px;
height: 88px;
border-radius: 50%;
color: var(--blue);
background: linear-gradient(145deg, #f1f7ff, #dfeaff);
box-shadow: inset 0 1px 0 #fff, 0 8px 22px rgba(47, 111, 208, 0.14);
}
.function-card__icon svg {
width: 48px;
height: 48px;
}
.function-card__label {
color: #1f2937;
font-size: 26px;
font-weight: 600;
letter-spacing: 2px;
}
.function-card__desc {
color: var(--muted);
font-size: 17px;
letter-spacing: 0.5px;
}
.panel-card__close {
width: 180px;
height: 54px;
margin-top: 30px;
border: 2px solid var(--line-strong);
border-radius: 12px;
color: var(--ink-soft);
font-size: 19px;
font-weight: 600;
letter-spacing: 3px;
background: #fff;
transition: background 0.2s ease;
}
.panel-card__close:hover {
background: var(--surface-soft);
}
.function-panel-enter-active,
.function-panel-leave-active {
transition: opacity 0.24s ease;
}
.function-panel-enter-active .panel-card,
.function-panel-leave-active .panel-card {
transition: transform 0.24s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.24s ease;
}
.function-panel-enter-from,
.function-panel-leave-to {
opacity: 0;
}
.function-panel-enter-from .panel-card,
.function-panel-leave-to .panel-card {
opacity: 0;
transform: translateY(16px) scale(0.97);
}
</style>