Skip to content

Commit bec6074

Browse files
committed
✨ feat: 支持关闭搜索关键词建议功能
1 parent 3838668 commit bec6074

5 files changed

Lines changed: 19 additions & 4 deletions

File tree

auto-eslint.mjs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ export default {
5959
"isRef": true,
6060
"isShallow": true,
6161
"makeDestructurable": true,
62+
"manualResetRef": true,
6263
"markRaw": true,
6364
"nextTick": true,
6465
"onActivated": true,
@@ -96,11 +97,11 @@ export default {
9697
"refAutoReset": true,
9798
"refDebounced": true,
9899
"refDefault": true,
100+
"refManualReset": true,
99101
"refThrottled": true,
100102
"refWithControl": true,
101103
"resolveComponent": true,
102104
"resolveRef": true,
103-
"resolveUnref": true,
104105
"shallowReactive": true,
105106
"shallowReadonly": true,
106107
"shallowRef": true,

src/components/Search/SearchInp.vue

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,10 @@ const setSearchHistory = (keyword: string) => {
8686
8787
// 更换搜索框关键词
8888
const updatePlaceholder = async () => {
89+
if (!settingStore.enableSearchKeyword) {
90+
searchPlaceholder.value = "搜索音乐 / 视频";
91+
return;
92+
}
8993
try {
9094
const result = await searchDefault();
9195
searchPlaceholder.value = result.data.showKeyword;
@@ -162,7 +166,7 @@ const toSearch = async (key: any, type: string = "keyword") => {
162166
163167
onMounted(() => {
164168
// 每分钟更新
165-
if (settingStore.useOnlineService) {
169+
if (settingStore.useOnlineService && settingStore.enableSearchKeyword) {
166170
useIntervalFn(updatePlaceholder, 60 * 1000, { immediate: true });
167171
}
168172
});

src/components/Setting/GeneralSetting.vue

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,13 @@
8888
</div>
8989
<n-switch class="set" v-model:value="settingStore.showSearchHistory" :round="false" />
9090
</n-card>
91+
<n-card class="set-item">
92+
<div class="label">
93+
<n-text class="name">搜索关键词建议</n-text>
94+
<n-text class="tip" :depth="3">是否启用搜索关键词建议</n-text>
95+
</div>
96+
<n-switch class="set" v-model:value="settingStore.enableSearchKeyword" :round="false" />
97+
</n-card>
9198
<n-card class="set-item">
9299
<div class="label">
93100
<n-text class="name">侧边栏显示封面</n-text>

src/stores/setting.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,8 @@ export interface SettingState {
202202
hideLikedPlaylists: boolean;
203203
/** 隐藏心动模式 */
204204
hideHeartbeatMode: boolean;
205+
/** 启用搜索关键词获取 */
206+
enableSearchKeyword: boolean;
205207
}
206208

207209
export const useSettingStore = defineStore("setting", {
@@ -300,6 +302,7 @@ export const useSettingStore = defineStore("setting", {
300302
hideUserPlaylists: false,
301303
hideLikedPlaylists: false,
302304
hideHeartbeatMode: false,
305+
enableSearchKeyword: true,
303306
}),
304307
getters: {
305308
/**

src/utils/modal.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { h, defineAsyncComponent } from "vue";
1+
import { h } from "vue";
22
import type { CoverType, UpdateInfoType, SettingType, SongType } from "@/types/main";
33
import { isLogin } from "./auth";
44
import { isArray, isFunction } from "lodash-es";
@@ -14,7 +14,7 @@ import CloudMatch from "@/components/Modal/CloudMatch.vue";
1414
import CreatePlaylist from "@/components/Modal/CreatePlaylist.vue";
1515
import UpdatePlaylist from "@/components/Modal/UpdatePlaylist.vue";
1616
import DownloadSong from "@/components/Modal/DownloadSong.vue";
17-
const MainSetting = defineAsyncComponent(() => import("@/components/Setting/MainSetting.vue"));
17+
import MainSetting from "@/components/Setting/MainSetting.vue";
1818
import UpdateApp from "@/components/Modal/UpdateApp.vue";
1919
import ExcludeLyrics from "@/components/Modal/ExcludeLyrics.vue";
2020
import ChangeRate from "@/components/Modal/ChangeRate.vue";

0 commit comments

Comments
 (0)