From 2aa592e48edae9dd47f5318dc608d872938ccacd Mon Sep 17 00:00:00 2001 From: expdsn <18111002318@163.com> Date: Wed, 20 Nov 2024 15:09:54 +0800 Subject: [PATCH] save --- src/App.vue | 88 ++++++------- src/layout/grid/AiSetting.tsx | 157 ++++++++++++++++++++++++ src/settings/SettingItem.tsx | 16 ++- src/settings/SettingsOverlayContent.tsx | 3 + src/settings/useSettingsStore.ts | 4 +- src/utils/parent.ts | 5 +- src/widgets/discount/Modal.tsx | 7 ++ 7 files changed, 231 insertions(+), 49 deletions(-) create mode 100644 src/layout/grid/AiSetting.tsx diff --git a/src/App.vue b/src/App.vue index 5f117ab..d719197 100644 --- a/src/App.vue +++ b/src/App.vue @@ -32,52 +32,52 @@ const layout = useLayoutStore() diff --git a/src/layout/grid/AiSetting.tsx b/src/layout/grid/AiSetting.tsx new file mode 100644 index 0000000..82577b3 --- /dev/null +++ b/src/layout/grid/AiSetting.tsx @@ -0,0 +1,157 @@ +import SettingItem from '@/settings/SettingItem' +import useSettingsStore from '@/settings/useSettingsStore' +import { Radio, Switch } from 'ant-design-vue' +import clsx from 'clsx' +import { defineComponent, watch } from 'vue' +import useLayoutStore from '../useLayoutStore' +import { sendParent } from '@/utils/parent' + +export default defineComponent({ + setup() { + const settings = useSettingsStore() + const layout = useLayoutStore() + watch( + () => ({ + autoSearch: settings.state.autoUseAi === 'show', + showTabButton: settings.state.showPetOnTab, + isSearch: settings.state.autoUseAi === '' + }), + (val) => { + console.log(val) + sendParent([ + 'configAI', + { + autoSearch: val.autoSearch, + showTabButton: val.showTabButton, + isSearch: val.isSearch + } + ]) + }, + { + immediate: true + } + ) + return () => ( +
+
+ + AI助手 + + 设置AI助手样式 +
+
+ + 功能开关 + +
标签页助手
+ }} + noRoundedB + desc="fatfox标签页内的小助手" + > + { + if (e) settings.state.showPet = true + else settings.state.showPet = false + }} + /> +
+
标签页助手
+ }} + desc="fatfox标签页内的小助手" + noRoundedT + > + { + if (e) settings.state.showPetOnTab = true + else settings.state.showPetOnTab = false + }} + /> +
+ + 结果增强 + +
结果增强开关
+ }} + desc="使用搜索引擎时,Fatfox会给您更多有效的结果" + > + { + if (e) settings.state.autoUseAi = 'show' + else settings.state.autoUseAi = '' + }} + /> +
+ +
+ 何时使用结果增强 +
每次询问
+ }} + noBg + desc="每次搜索直接询问fatfox" + > + { + settings.state.autoUseAi = 'show' + }} + onUpdate:checked={(e) => { + if (e) settings.state.showSider = 'auto' + else settings.state.showSider = 'show' + }} + /> +
+
手动询问
+ }} + noBg + desc="每次搜索,提示您进行手动查询" + > + { + settings.state.autoUseAi = 'auto' + }} + /> +
+
+
+ ) + } +}) diff --git a/src/settings/SettingItem.tsx b/src/settings/SettingItem.tsx index f0664b1..b49a0e3 100644 --- a/src/settings/SettingItem.tsx +++ b/src/settings/SettingItem.tsx @@ -15,6 +15,9 @@ export default defineComponent({ noBg: { type: Boolean, default: false + }, + desc: { + type: String } }, slots: {} as SlotsType<{ @@ -39,8 +42,17 @@ export default defineComponent({ marginBottom: props.noRoundedB ? 0 : '12px' }} > -
- {ctx.slots.label?.()} +
+ {ctx.slots.label?.()} + {props.desc ? ( + + {props.desc} + + ) : null}
{ctx.slots.default?.()}
{/* {ctx.slots.end?.()} */} diff --git a/src/settings/SettingsOverlayContent.tsx b/src/settings/SettingsOverlayContent.tsx index 4e9792d..6c0ed8b 100644 --- a/src/settings/SettingsOverlayContent.tsx +++ b/src/settings/SettingsOverlayContent.tsx @@ -10,6 +10,7 @@ import SiderSetting from '@/layout/grid/SiderSetting' import DockSetting from '@/layout/grid/DockSetting' import Feedback from '@/layout/grid/Feedback' import Reset from '@/layout/grid/Reset' +import AiSetting from '@/layout/grid/AiSetting' export default defineComponent(() => { const router = useRouterStore() @@ -35,6 +36,8 @@ export default defineComponent(() => { ) : router.path === 'settings-fallback' ? ( + ) : router.path === 'settings-ai' ? ( + ) : null}
diff --git a/src/settings/useSettingsStore.ts b/src/settings/useSettingsStore.ts index d0c8fa7..2fdf3d9 100644 --- a/src/settings/useSettingsStore.ts +++ b/src/settings/useSettingsStore.ts @@ -40,7 +40,9 @@ export default defineStore( // 显示隐藏 showSider: 'show' as VisibleState, showDock: 'show' as VisibleState, - showPet: 'show' as VisibleState, + showPet: true, + showPetOnTab: true, + autoUseAi: 'show' as VisibleState, showTop: 'show' as VisibleState, showTime: true, timeOptions: ['date', 'week', '12hour', 'lunal', 'second'] as TimeUnit[], diff --git a/src/utils/parent.ts b/src/utils/parent.ts index f8e26c1..70cf472 100644 --- a/src/utils/parent.ts +++ b/src/utils/parent.ts @@ -7,8 +7,9 @@ export function sendParent( | [ 'configAI', { - autoSearch: true - showTabButton: true + autoSearch: boolean + showTabButton: boolean + isSearch: boolean } ] ) { diff --git a/src/widgets/discount/Modal.tsx b/src/widgets/discount/Modal.tsx index b29640f..57d614e 100644 --- a/src/widgets/discount/Modal.tsx +++ b/src/widgets/discount/Modal.tsx @@ -29,10 +29,13 @@ export default defineComponent(() => { }, 500) // watch(searchText, (newValue) => { debouncedHandler(newValue) + }, { + immediate: true }) onMounted(() => { store.state.pageIndex = 1 store.getNews() + searchText.value = '' }) return () => (
{ }} >
{ + e.stopPropagation() + searchText.value = '' + }} class={ 'absolute cursor-pointer hidden group-hover:block right-3 top-1/2 -translate-y-1/2' }