ConfigDrawer.vue
3.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
<script setup lang="ts">
defineProps<{
open: boolean
groups: Array<{
title: string
fields: Array<{
key: string
label: string
type: string
value: string
}>
}>
loading: boolean
saving: boolean
}>()
const emit = defineEmits<{
'update:open': [value: boolean]
updateField: [key: string, value: string]
refresh: []
save: []
}>()
</script>
<template>
<transition name="fade">
<div v-if="open" class="drawer-overlay" @click.self="$emit('update:open', false)">
<aside class="drawer">
<div class="drawer-head">
<div>
<p class="drawer-kicker">Configuration</p>
<h2>配置中心</h2>
</div>
<div class="drawer-actions">
<button class="ghost-button" type="button" :disabled="loading" @click="$emit('refresh')">刷新</button>
<button class="ghost-button" type="button" @click="$emit('update:open', false)">关闭</button>
</div>
</div>
<div class="drawer-body">
<section v-for="group in groups" :key="group.title" class="config-group">
<header class="config-group-head">
<h3>{{ group.title }}</h3>
</header>
<div class="config-grid">
<label v-for="field in group.fields" :key="field.key" class="field">
<span class="field-label">{{ field.label }}</span>
<input
class="field-control"
:type="field.type"
:value="field.value"
@input="$emit('updateField', field.key, ($event.target as HTMLInputElement).value)"
/>
</label>
</div>
</section>
</div>
<div class="drawer-footer">
<button class="solid-button" type="button" :disabled="saving" @click="$emit('save')">
{{ saving ? '保存中…' : '保存配置' }}
</button>
</div>
</aside>
</div>
</transition>
</template>
<style scoped>
.drawer-overlay {
position: fixed;
inset: 0;
z-index: 50;
display: flex;
justify-content: flex-end;
background: rgba(15, 18, 16, 0.28);
backdrop-filter: blur(10px);
}
.drawer {
width: min(720px, 100vw);
height: 100vh;
display: grid;
grid-template-rows: auto 1fr auto;
background: rgba(250, 245, 237, 0.98);
border-left: 1px solid var(--border-strong);
box-shadow: -24px 0 80px rgba(23, 27, 24, 0.14);
}
.drawer-head,
.drawer-actions {
display: flex;
}
.drawer-head {
justify-content: space-between;
gap: 18px;
padding: 24px 28px;
border-bottom: 1px solid var(--border-soft);
}
.drawer-kicker,
.field-label {
margin: 0 0 10px;
font-family: var(--font-mono);
font-size: 11px;
letter-spacing: 0.2em;
text-transform: uppercase;
color: var(--text-muted);
}
.drawer-head h2,
.config-group-head h3 {
margin: 0;
}
.drawer-actions {
gap: 12px;
}
.drawer-body {
overflow: auto;
padding: 24px 28px;
display: grid;
gap: 22px;
}
.config-group {
padding: 20px;
border-radius: 24px;
border: 1px solid var(--border-soft);
background: rgba(255, 252, 246, 0.74);
}
.config-grid {
display: grid;
grid-template-columns: repeat(2, minmax(0, 1fr));
gap: 14px;
margin-top: 16px;
}
.field {
display: grid;
gap: 10px;
}
.field-control {
min-height: 50px;
padding: 14px 16px;
border-radius: 16px;
border: 1px solid var(--border-soft);
background: rgba(255, 255, 255, 0.74);
font: inherit;
}
.drawer-footer {
padding: 20px 28px 28px;
border-top: 1px solid var(--border-soft);
}
.fade-enter-active,
.fade-leave-active {
transition: opacity 0.18s ease;
}
.fade-enter-from,
.fade-leave-to {
opacity: 0;
}
@media (max-width: 720px) {
.config-grid {
grid-template-columns: 1fr;
}
}
</style>