Skip to content

Commit baba5d7

Browse files
committed
🐞 fix: 修复搜索框失焦
1 parent b4a2aa5 commit baba5d7

2 files changed

Lines changed: 10 additions & 7 deletions

File tree

src/components/Setting/SettingSearch.vue

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<template>
22
<div class="setting-search" :class="{ focus: isFocus }">
33
<n-input
4+
ref="inputInst"
45
v-model:value="inputValue"
56
clearable
67
placeholder="搜索设置项..."
@@ -36,7 +37,7 @@
3637
</template>
3738

3839
<script setup lang="ts">
39-
import type { SelectOption } from "naive-ui";
40+
import { SelectOption, NInput } from "naive-ui";
4041
import Fuse from "fuse.js";
4142
4243
interface SearchOption extends SelectOption {
@@ -51,6 +52,7 @@ const props = defineProps<{
5152
5253
const emit = defineEmits(["select", "active-change"]);
5354
55+
const inputInst = ref<InstanceType<typeof NInput> | null>(null);
5456
const inputValue = ref("");
5557
const isFocus = ref(false);
5658
const resultList = ref<SearchOption[]>([]);
@@ -88,7 +90,7 @@ watch(inputValue, (val) => {
8890
8991
// 处理失焦
9092
const handleBlur = () => {
91-
// isFocus.value = false;
93+
isFocus.value = false;
9294
};
9395
9496
// 处理选择
@@ -97,6 +99,7 @@ const handleSelect = (value: string | number) => {
9799
isFocus.value = false;
98100
inputValue.value = "";
99101
emit("active-change", false);
102+
inputInst.value?.blur();
100103
};
101104
</script>
102105

src/style/main.scss

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,23 +14,23 @@
1414
:root {
1515
// 图片模式
1616
&.image {
17-
--background-hex: rgba(0, 0, 0, 0.2) !important;
18-
--surface-container-hex: rgba(0, 0, 0, 0.1) !important;
17+
--background-hex: rgba(0, 0, 0, 0.1) !important;
18+
--surface-container-hex: rgba(0, 0, 0, 0.2) !important;
1919
body {
2020
--background-hex: rgba(var(--background), 0.1) !important;
21-
--surface-container-hex: rgba(var(--surface-container), 0.1) !important;
21+
--surface-container-hex: rgba(var(--surface-container), 0.2) !important;
2222
--n-toggle-bar-color: rgba(var(--background), 0.2) !important;
2323
--n-toggle-bar-color-hover: rgba(var(--background), 0.4) !important;
2424
}
2525
.n-layout-sider {
26-
background-color: rgba(var(--surface-container), 0.2) !important;
26+
background-color: var(--surface-container-hex) !important;
2727
}
2828
.n-layout {
2929
background-color: transparent !important;
3030
}
3131
.main-player {
3232
background-color: var(--surface-container-hex);
33-
backdrop-filter: blur(20px);
33+
backdrop-filter: blur(10px);
3434
}
3535
// 内置组件
3636
.n-card,

0 commit comments

Comments
 (0)