Files
crawler-plugin/frontend-vue/src/shared/components/ai-workflow/AiModuleSwitch.vue
2026-06-09 21:07:50 +08:00

106 lines
2.3 KiB
Vue

<template>
<div class="ai-module-switch" role="tablist" aria-label="功能模块切换">
<button
v-for="item in options"
:key="item.value"
type="button"
class="ai-module-switch__item"
:class="{
'ai-module-switch__item--active': modelValue === item.value,
'ai-module-switch__item--disabled': item.disabled,
}"
:disabled="item.disabled"
@click="$emit('update:modelValue', item.value)"
>
<span class="ai-module-switch__label">{{ item.label }}</span>
<span v-if="item.description" class="ai-module-switch__description">
{{ item.description }}
</span>
</button>
</div>
</template>
<script setup lang="ts">
export type AiModuleSwitchOption = {
label: string
value: string
description?: string
disabled?: boolean
}
defineProps<{
modelValue: string
options: AiModuleSwitchOption[]
}>()
defineEmits<{
(event: 'update:modelValue', value: string): void
}>()
</script>
<style scoped>
.ai-module-switch {
display: grid;
grid-template-columns: repeat(3, minmax(0, 1fr));
gap: 12px;
}
.ai-module-switch__item {
display: flex;
flex-direction: column;
align-items: flex-start;
gap: 6px;
min-height: 84px;
padding: 16px 18px;
border: 1px solid rgba(71, 85, 105, 0.65);
border-radius: 16px;
background: rgba(15, 23, 42, 0.72);
color: #cbd5e1;
text-align: left;
cursor: pointer;
transition:
border-color 0.2s ease,
transform 0.2s ease,
box-shadow 0.2s ease,
background 0.2s ease;
}
.ai-module-switch__item:hover:not(:disabled) {
border-color: rgba(96, 165, 250, 0.7);
box-shadow: 0 14px 24px rgba(8, 15, 31, 0.34);
transform: translateY(-1px);
}
.ai-module-switch__item--active {
border-color: rgba(96, 165, 250, 0.82);
background:
linear-gradient(180deg, rgba(30, 41, 59, 0.96), rgba(15, 23, 42, 0.96));
box-shadow:
0 0 0 1px rgba(59, 130, 246, 0.18),
0 18px 28px rgba(8, 15, 31, 0.36);
}
.ai-module-switch__item--disabled {
opacity: 0.62;
cursor: not-allowed;
}
.ai-module-switch__label {
color: #f8fafc;
font-size: 16px;
font-weight: 600;
}
.ai-module-switch__description {
color: #94a3b8;
font-size: 12px;
line-height: 1.45;
}
@media (max-width: 900px) {
.ai-module-switch {
grid-template-columns: 1fr;
}
}
</style>