日志改常驻收集,加清空按钮;原生 select 统一换成 SelectBox

日志收集从请求页组件搬进模块级单例(web/log-store.ts,模式同 telemetry),
切走页面不再清空;离线时保留已收的日志,只提示不再更新。清空只清界面。

五处原生 <select> 在三个文件里各自重复同一套自绘箭头样式,而且原生控件
没有「展开中」状态可读,箭头做不了开合动画——提成 SelectBox 组件统一替换:
箭头随开合旋转 180 度,弹层带出入场动画,下方视口不够时向上弹。背景色
留 --select-bg 口子,对话框里沉一档、页面上浮一档,一个值满足不了两边。
This commit is contained in:
2026-08-11 23:47:28 +08:00
parent 60fb015e36
commit f927f9fff7
7 changed files with 473 additions and 187 deletions
+13 -21
View File
@@ -9,6 +9,7 @@
import { computed, ref, watch } from 'vue'
import { inferRuleFormat, ruleProviderPath } from '@shared/rules.ts'
import type { ConfigObject } from '../../vendor/config-editor/index.ts'
import SelectBox from '../components/SelectBox.vue'
import IconClose from '~icons/ri/close-line'
const props = defineProps<{
@@ -27,10 +28,14 @@ const dialog = ref<HTMLDialogElement | null>(null)
const name = ref('')
const source = ref('')
const behavior = ref('classical')
const format = ref<'yaml' | 'text' | 'mrs'>('yaml')
// 值域就是选项里那三个,SelectBox 的 v-model 是宽的 string,这里不再收窄
const format = ref<string>('yaml')
/** 用户手选过格式就不再跟着来源推断 */
const formatTouched = ref(false)
const BEHAVIOR_OPTIONS = [{ value: 'classical' }, { value: 'domain' }, { value: 'ipcidr' }]
const FORMAT_OPTIONS = [{ value: 'yaml' }, { value: 'text' }, { value: 'mrs' }]
const isUrl = computed(() => /^https?:\/\//i.test(source.value.trim()))
watch(source, (value) => {
@@ -122,11 +127,7 @@ function submit() {
<label class="row">
<span class="k">行为</span>
<span class="v">
<select v-model="behavior">
<option value="classical">classical</option>
<option value="domain">domain</option>
<option value="ipcidr">ipcidr</option>
</select>
<SelectBox v-model="behavior" :options="BEHAVIOR_OPTIONS" />
<span class="note">
清单每行带 DOMAIN,、IP-CIDR, 这类前缀的是 classical;纯域名列表是 domain;
纯 IP 网段列表是 ipcidr
@@ -137,11 +138,11 @@ function submit() {
<label class="row">
<span class="k">格式</span>
<span class="v">
<select v-model="format" @change="formatTouched = true">
<option value="yaml">yaml</option>
<option value="text">text</option>
<option value="mrs">mrs</option>
</select>
<SelectBox
v-model="format"
:options="FORMAT_OPTIONS"
@update:model-value="formatTouched = true"
/>
<span v-if="mrsConflict" class="bad">mrs 格式只支持 domain 和 ipcidr 两种行为</span>
</span>
</label>
@@ -227,8 +228,7 @@ function submit() {
min-width: 0;
}
input,
select {
input {
width: 100%;
padding: var(--s-2) var(--s-3);
border: 1px solid var(--c-border-strong);
@@ -236,14 +236,6 @@ select {
background: var(--c-bg);
}
select {
appearance: none;
padding-right: var(--s-6);
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' width='16' height='16'%3E%3Cpath fill='%23898f98' d='M12 15.6 5.7 9.3l1.4-1.4 4.9 4.9 4.9-4.9 1.4 1.4z'/%3E%3C/svg%3E");
background-repeat: no-repeat;
background-position: right var(--s-3) center;
}
.note {
font-size: var(--t-xs);
color: var(--c-text-faint);