|
2 | 2 | <div class="exclude"> |
3 | 3 | <n-alert :show-icon="false">请勿添加过多,以免影响歌词的正常显示</n-alert> |
4 | 4 |
|
5 | | - <n-tabs type="line" v-model:value="page" animated> |
| 5 | + <n-tabs v-model:value="page" animated> |
6 | 6 | <n-tab-pane name="keywords" tab="关键词"> |
7 | | - <n-dynamic-tags v-model:value="settingStore.excludeKeywords" /> |
| 7 | + <n-scrollbar style="max-height: 70vh"> |
| 8 | + <n-flex vertical :size="12"> |
| 9 | + <n-dynamic-tags v-model:value="settingStore.excludeUserKeywords" /> |
| 10 | + <n-button type="primary" strong secondary size="small" @click="resetUserKeywords"> |
| 11 | + 重置规则 |
| 12 | + </n-button> |
| 13 | + </n-flex> |
| 14 | + </n-scrollbar> |
8 | 15 | </n-tab-pane> |
| 16 | + |
9 | 17 | <n-tab-pane name="regexes" tab="正则表达式"> |
10 | | - <n-dynamic-tags v-model:value="settingStore.excludeRegexes" /> |
| 18 | + <n-scrollbar style="max-height: 70vh"> |
| 19 | + <n-flex vertical :size="12"> |
| 20 | + <n-dynamic-tags v-model:value="settingStore.excludeUserRegexes" /> |
| 21 | + <n-button type="primary" strong secondary size="small" @click="resetUserRegexes"> |
| 22 | + 重置规则 |
| 23 | + </n-button> |
| 24 | + </n-flex> |
| 25 | + </n-scrollbar> |
11 | 26 | </n-tab-pane> |
12 | | - |
13 | | - <template #suffix> |
14 | | - <n-flex> |
15 | | - <n-button type="primary" strong secondary @click="clear">清空此页</n-button> |
16 | | - <n-button type="primary" strong secondary @click="reset">重置此页</n-button> |
17 | | - </n-flex> |
18 | | - </template> |
19 | 27 | </n-tabs> |
20 | 28 | </div> |
21 | 29 | </template> |
22 | 30 |
|
23 | 31 | <script setup lang="ts"> |
24 | 32 | import { useSettingStore } from "@/stores"; |
25 | | -import { keywords, regexes } from "@/assets/data/exclude"; |
26 | 33 |
|
27 | 34 | const settingStore = useSettingStore(); |
28 | 35 |
|
29 | 36 | const page = ref("keywords"); |
30 | 37 |
|
31 | | -const pageConfig = { |
32 | | - keywords: { |
33 | | - name: "关键词", |
34 | | - storeKey: "excludeKeywords", |
35 | | - defaultValue: keywords, |
36 | | - }, |
37 | | - regexes: { |
38 | | - name: "正则表达式", |
39 | | - storeKey: "excludeRegexes", |
40 | | - defaultValue: regexes, |
41 | | - }, |
42 | | -} as const; |
43 | | -
|
44 | | -const handleAction = (action: "clear" | "reset") => { |
45 | | - const pageKey = page.value as keyof typeof pageConfig; |
46 | | - const { name, storeKey, defaultValue } = pageConfig[pageKey]; |
47 | | - const isClear = action === "clear"; |
48 | | -
|
49 | | - const actionText = isClear ? "清空" : "重置"; |
50 | | - const contentDetail = isClear ? "" : "为默认值"; |
51 | | - const successMessage = isClear ? "列表已清空" : "列表已重置为默认值"; |
52 | | -
|
| 38 | +// 重置规则 |
| 39 | +const resetUserKeywords = () => { |
53 | 40 | window.$dialog.warning({ |
54 | | - title: `${actionText}确认`, |
55 | | - content: `确认${actionText}${name}列表${contentDetail}?该操作不可撤销!`, |
| 41 | + title: "重置确认", |
| 42 | + content: "确认清空所有关键词规则?该操作不可撤销!", |
56 | 43 | positiveText: "确认", |
57 | 44 | negativeText: "取消", |
58 | 45 | onPositiveClick: () => { |
59 | | - settingStore[storeKey] = isClear ? [] : defaultValue; |
60 | | - window.$message.success(`${name}${successMessage}`); |
| 46 | + settingStore.excludeUserKeywords = []; |
| 47 | + window.$message.success("关键词规则已清空"); |
61 | 48 | }, |
62 | 49 | }); |
63 | 50 | }; |
64 | 51 |
|
65 | | -const clear = () => handleAction("clear"); |
66 | | -const reset = () => handleAction("reset"); |
| 52 | +const resetUserRegexes = () => { |
| 53 | + window.$dialog.warning({ |
| 54 | + title: "重置确认", |
| 55 | + content: "确认清空所有正则表达式规则?该操作不可撤销!", |
| 56 | + positiveText: "确认", |
| 57 | + negativeText: "取消", |
| 58 | + onPositiveClick: () => { |
| 59 | + settingStore.excludeUserRegexes = []; |
| 60 | + window.$message.success("正则表达式规则已清空"); |
| 61 | + }, |
| 62 | + }); |
| 63 | +}; |
67 | 64 | </script> |
68 | 65 |
|
69 | 66 | <style lang="scss" scoped> |
|
0 commit comments