-
Notifications
You must be signed in to change notification settings - Fork 50
Expand file tree
/
Copy pathSourceDialog.vue
More file actions
141 lines (121 loc) · 3.05 KB
/
SourceDialog.vue
File metadata and controls
141 lines (121 loc) · 3.05 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
<template>
<a-modal
:visible="visible"
:title="title"
:width="dialogWidth"
class="change_rule_dialog"
append-to-body
:on-before-cancel="handleConfirmClear"
>
<a-input
v-model="siteFilter"
placeholder="请输入站源名称"
class="site_filter_input"
allow-clear
/>
<a-form
:model="form"
label-width="120px"
class="change_rule_form"
>
<div class="button-container">
<div
v-for="(site, index) in filteredSites"
:key="index"
class="btn-item"
>
<a-button
type="primary"
:status="form.new_site.key === site.key ? 'success' : 'primary'"
size="medium"
@click="handleChangeRule(site)"
>
{{ site.name }}
</a-button>
</div>
</div>
</a-form>
<template #footer>
<div class="dialog-footer-right dialog-footer">
<a-button type="primary" status="danger" @click="handleConfirmClear">清除缓存</a-button>
<a-button type="primary" @click="handleConfirmChange">确认换源</a-button>
</div>
</template>
</a-modal>
</template>
<script setup>
import { ref, computed, nextTick } from 'vue';
const props = defineProps({
visible: Boolean,
title: String,
sites: Array,
currentSiteKey: String,
});
const emit = defineEmits(['update:visible', 'confirm-clear', 'confirm-change', 'change-rule']);
const siteFilter = ref('');
const form = ref({ new_site: {} });
const filteredSites = computed(() => {
const inputLower = siteFilter.value.toLowerCase();
return props.sites.filter(site => site.name.toLowerCase().includes(inputLower));
});
const dialogWidth = computed(() => (window.innerWidth < 768 ? '100%' : '600px'));
const handleChangeRule = (site) => {
form.value.new_site = site;
emit('change-rule', site);
};
const handleConfirmClear = () => {
emit('confirm-clear');
emit('update:visible', false);
};
const handleConfirmChange = () => {
emit('confirm-change', form.value.new_site);
emit('update:visible', false);
};
</script>
<style>
.change_rule_dialog .arco-modal-body {
padding: 1px !important; /* 使用 !important 强制覆盖 */
}
</style>
<style scoped>
.change_rule_form {
min-height: 200px;
max-height: 400px;
}
.site_filter_input {
padding: 5px 5px 5px 5px;
border-radius: 12px;
width: calc(31.3% * 3);
}
.dialog-footer button {
margin-right: 20px;
}
.dialog-footer-left {
display: flex;
justify-content: flex-start; /* 将按钮对齐到左侧 */
}
.dialog-footer-right {
display: flex;
justify-content: flex-end; /* 将按钮对齐到右侧 */
}
.custom-confirm {
max-width: 90%; /* 最大宽度为 90% */
width: auto; /* 宽度自适应内容 */
}
.button-container {
width: 100%;
max-height: 400px;
overflow-y: scroll;
display: flex;
flex-wrap: wrap;
}
/* .btn-item:nth-child(8) {
margin-right: 0;
} */
.btn-item {
text-align: center;
width: calc(31.3%);
padding: 2px;
}
.btn-item button {width: 100%;}
</style>