|
| 1 | +<template> |
| 2 | + <el-card class="router_card p-1 sm:p-0"> |
| 3 | + <div class="flex w-full flex-col justify-start items-start sm:flex-row sm:items-center sm:justify-between"> |
| 4 | + <el-radio-group v-model="activePath" @change="handleChange"> |
| 5 | + <el-radio-button |
| 6 | + v-for="item in buttons" |
| 7 | + :key="item.path" |
| 8 | + class="router_card_button" |
| 9 | + :value="item.path" |
| 10 | + size="large" |
| 11 | + > |
| 12 | + {{ item.label }} |
| 13 | + </el-radio-button> |
| 14 | + </el-radio-group> |
| 15 | + </div> |
| 16 | + </el-card> |
| 17 | +</template> |
| 18 | + |
| 19 | +<script lang="ts" setup> |
| 20 | +import { ref, watch } from 'vue'; |
| 21 | +import { useRoute, useRouter } from 'vue-router'; |
| 22 | +
|
| 23 | +const buttons = [ |
| 24 | + { |
| 25 | + label: 'Ollama', |
| 26 | + path: '/ai/model/ollama', |
| 27 | + }, |
| 28 | + { |
| 29 | + label: 'vLLM', |
| 30 | + path: '/ai/model/vllm', |
| 31 | + }, |
| 32 | + { |
| 33 | + label: 'TensorRT LLM', |
| 34 | + path: '/ai/model/tensorrt', |
| 35 | + }, |
| 36 | +]; |
| 37 | +
|
| 38 | +const route = useRoute(); |
| 39 | +const router = useRouter(); |
| 40 | +const activePath = ref(''); |
| 41 | +
|
| 42 | +watch( |
| 43 | + () => route.path, |
| 44 | + (path) => { |
| 45 | + activePath.value = path; |
| 46 | + }, |
| 47 | + { immediate: true }, |
| 48 | +); |
| 49 | +
|
| 50 | +const handleChange = async (path: string) => { |
| 51 | + if (!path || path === route.path) { |
| 52 | + return; |
| 53 | + } |
| 54 | + await router.push({ path }); |
| 55 | +}; |
| 56 | +</script> |
| 57 | + |
| 58 | +<style lang="scss"> |
| 59 | +.router_card { |
| 60 | + --el-card-padding: 0; |
| 61 | +
|
| 62 | + .el-card__body { |
| 63 | + display: flex; |
| 64 | + justify-content: space-between; |
| 65 | + align-items: center; |
| 66 | + } |
| 67 | +} |
| 68 | +
|
| 69 | +.router_card_button { |
| 70 | + .el-radio-button__inner { |
| 71 | + min-width: 100px; |
| 72 | + height: 100%; |
| 73 | + background-color: var(--panel-button-active) !important; |
| 74 | + box-shadow: none !important; |
| 75 | + border: 2px solid transparent !important; |
| 76 | + color: var(--el-text-color-regular) !important; |
| 77 | + } |
| 78 | +
|
| 79 | + .el-radio-button__original-radio:checked + .el-radio-button__inner { |
| 80 | + color: var(--panel-button-text-color) !important; |
| 81 | + background-color: var(--panel-button-bg-color) !important; |
| 82 | + border-color: var(--panel-color-primary) !important; |
| 83 | + border-radius: 4px; |
| 84 | + } |
| 85 | +} |
| 86 | +</style> |
0 commit comments