| 8 |
| <span class="status-pill" :class="statusClass"> |
| 9 | <span class="status-dot"></span> |
| 10 | {{ proxy.status }} |
| 11 | </span> |
| 12 | </div> |
| 13 | <div class="card-address"> |
| 14 | <template v-if="proxy.remote_addr && localDisplay"> |
| 15 | {{ proxy.remote_addr }} → {{ localDisplay }} |
| 16 | </template> |
| 17 | <template v-else-if="proxy.remote_addr">{{ proxy.remote_addr }}</template> |
| 18 | <template v-else-if="localDisplay">{{ localDisplay }}</template> |
| 19 | </div> |
| 20 | </div> |
| 21 | <div class="card-right"> |
| 22 | <span v-if="showSource" class="source-label">{{ displaySource }}</span> |
| 23 | <div v-if="showActions" @click.stop> |
| 24 | <PopoverMenu :width="120" placement="bottom-end"> |
| 25 | <template #trigger> |
| 26 | <ActionButton variant="outline" size="small"> |
| 27 | <el-icon><MoreFilled /></el-icon> |
| 28 | </ActionButton> |
| 29 | </template> |
| 30 | <PopoverMenuItem v-if="proxy.status === 'disabled'" @click="$emit('toggle', proxy, true)"> |
| 31 | <el-icon><Open /></el-icon> |
| 32 | Enable |
| 33 | </PopoverMenuItem> |
| 34 | <PopoverMenuItem v-else @click="$emit('toggle', proxy, false)"> |
| 35 | <el-icon><TurnOff /></el-icon> |
| 36 | Disable |
| 37 | </PopoverMenuItem> |
| 38 | <PopoverMenuItem @click="$emit('edit', proxy)"> |
| 39 | <el-icon><Edit /></el-icon> |
| 40 | Edit |
| 41 | </PopoverMenuItem> |
| 42 | <PopoverMenuItem danger @click="$emit('delete', proxy)"> |
| 43 | <el-icon><Delete /></el-icon> |
| 44 | Delete |
| 45 | </PopoverMenuItem> |
| 46 | </PopoverMenu> |
| 47 | </div> |
| 48 | </div> |
| 49 | </div> |
| 50 | </div> |
| 51 | </template> |
| 52 |
| 53 | <script setup lang="ts"> |
| 54 | import { computed } from 'vue' |
| 55 | import { MoreFilled, Edit, Delete, Open, TurnOff } from '@element-plus/icons-vue' |
| 56 | import ActionButton from '@shared/components/ActionButton.vue' |
| 57 | import PopoverMenu from '@shared/components/PopoverMenu.vue' |
| 58 | import PopoverMenuItem from '@shared/components/PopoverMenuItem.vue' |
| 59 | import type { ProxyStatus } from '../types' |
| 60 |
| 61 | interface Props { |
| 62 | proxy: ProxyStatus |
| 63 | showSource?: boolean |
| 64 | showActions?: boolean |
| 65 | deleting?: boolean |
| 66 | } |
| 67 |
| 68 | const props = withDefaults(defineProps<Props>(), { |
| 69 | showSource: false, |
| 70 | showActions: false, |
| 71 | deleting: false, |
| 72 | }) |
| 73 |
| 74 | defineEmits<{ |
| 75 | click: [proxy: ProxyStatus] |
| 76 | edit: [proxy: ProxyStatus] |
| 77 | delete: [proxy: ProxyStatus] |
| 78 | toggle: [proxy: ProxyStatus, enabled: boolean] |
| 79 | }>() |
| 80 |
| 81 | const displaySource = computed(() => { |
| 82 | return props.proxy.source === 'store' ? 'store' : 'config' |
| 83 | }) |
| 84 |
| 85 | const localDisplay = computed(() => { |
| 86 | if (props.proxy.plugin) return `plugin:${props.proxy.plugin}` |
| 87 | return props.proxy.local_addr || '' |
| 88 | }) |
| 89 |
| 90 | const statusClass = computed(() => { |
| 91 | switch (props.proxy.status) { |
| 92 | case 'running': |
| 93 | return 'running' |
| 94 | case 'error': |
| 95 | return 'error' |
| 96 | case 'disabled': |
| 97 | return 'disabled' |
| 98 | default: |
| 99 | return 'waiting' |
| 100 | } |
| 101 | }) |
| 102 | </script> |
| 103 |
| 104 | <style scoped lang="scss"> |
| 105 | .proxy-card { |
| 106 | background: $color-bg-primary; |
| 107 | border: 1px solid $color-border-lighter; |
| 108 | border-radius: $radius-md; |
| 109 | padding: 14px 20px; |
| 110 | cursor: pointer; |
| 111 | transition: all $transition-medium; |
| 112 |
| 113 | &:hover { |
| 114 | box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04); |
| 115 | border-color: $color-border; |
| 116 | } |
| 117 |
| 118 | &.has-error { |
| 119 | border-color: rgba(245, 108, 108, 0.3); |
| 120 | } |
| 121 | } |
| 122 |
| 123 | .card-main { |
| 124 | display: flex; |
| 125 | justify-content: space-between; |
| 126 | align-items: center; |
| 127 | gap: $spacing-lg; |
| 128 | } |
| 129 |
| 130 | .card-left { |
| 131 | @include flex-column; |
| 132 | gap: $spacing-sm; |
| 133 | flex: 1; |
| 134 | min-width: 0; |
| 135 | } |
| 136 |
| 137 | .card-header { |
| 138 | display: flex; |
| 139 | align-items: center; |
| 140 | gap: $spacing-sm; |
| 141 | } |
| 142 |
| 143 | .proxy-name { |
| 144 | font-size: $font-size-lg; |
| 145 | font-weight: $font-weight-semibold; |
| 146 | color: $color-text-primary; |
| 147 | } |
| 148 |
| 149 | .type-tag { |
| 150 | font-size: $font-size-xs; |
| 151 | font-weight: $font-weight-medium; |
| 152 | padding: 2px 8px; |
| 153 | border-radius: 4px; |
| 154 | background: $color-bg-muted; |
| 155 | color: $color-text-secondary; |
| 156 | } |
| 157 |
| 158 | .card-address { |
| 159 | font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace; |
| 160 | font-size: $font-size-sm; |
| 161 | color: $color-text-muted; |
| 162 | display: flex; |
| 163 | align-items: center; |
| 164 | gap: $spacing-sm; |
| 165 | } |
| 166 |
| 167 |
| 168 |
| 169 | .card-right { |
| 170 | display: flex; |
| 171 | align-items: center; |
| 172 | gap: $spacing-md; |
| 173 | flex-shrink: 0; |
| 174 | } |
| 175 |
| 176 | .source-label { |
| 177 | font-size: $font-size-xs; |
| 178 | color: $color-text-light; |
| 179 | } |
| 180 |
| 181 |
| 182 | .status-dot { |
| 183 | width: 6px; |
| 184 | height: 6px; |
| 185 | border-radius: 50%; |
| 186 | background: currentColor; |
| 187 | } |
| 188 |
| 189 |
| 190 |
| 191 | @include mobile { |
| 192 | .card-main { |
| 193 | flex-direction: column; |
| 194 | align-items: stretch; |
| 195 | gap: $spacing-sm; |
| 196 | } |
| 197 | .card-right { |
| 198 | justify-content: space-between; |
| 199 | } |
| 200 | .card-address { |
| 201 | word-break: break-all; |
| 202 | } |
| 203 | } |
| 204 | </style> |