This commit is contained in:
expdsn 2024-11-20 15:09:54 +08:00
parent eac8854337
commit 2aa592e48e
7 changed files with 231 additions and 49 deletions

View File

@ -32,52 +32,52 @@ const layout = useLayoutStore()
</script>
<template>
<!-- <ConfigProvider :locale="zhCN"> -->
<div class="fixed left-0 top-0 w-full h-screen style-root" @contextmenu.prevent>
<Header />
<Background
@dblclick="
() => {
layout.state.simple = !layout.state.simple
}
"
/>
<GLobalModal />
<SettingsOverlay />
<SettingsButton />
<div class="fixed left-0 top-0 w-full h-screen style-root" @contextmenu.prevent>
<Header />
<Background
@dblclick="
() => {
layout.state.simple = !layout.state.simple
}
"
/>
<GLobalModal />
<SettingsOverlay />
<SettingsButton />
<Sider
v-if="
!layout.state.simple ||
(layout.state.simple && settings.state.simpleModeShowString.includes('showSider'))
"
/>
<LoginModal v-if="router.path === 'global-login'" />
<Transition>
<Grid v-if="layout.ready && !layout.state.simple" />
</Transition>
<Dock
v-if="
!layout.state.simple ||
(layout.state.simple && settings.state.simpleModeShowString.includes('showDock'))
"
/>
<div
class="fixed z-40 right-[14%] top-8"
v-if="
!layout.state.simple ||
(layout.state.simple && settings.state.simpleModeShowString.includes('showPet'))
"
>
<Fox />
</div>
<DirModal />
<GlobalMenu />
<WelcomePage></WelcomePage>
<TomatoPage></TomatoPage>
<BackupRecovery v-if="router.path === 'global-backup'"></BackupRecovery>
<Sider
v-if="
!layout.state.simple ||
(layout.state.simple && settings.state.simpleModeShowString.includes('showSider'))
"
/>
<LoginModal v-if="router.path === 'global-login'" />
<Transition>
<Grid v-if="layout.ready && !layout.state.simple" />
</Transition>
<Dock
v-if="
!layout.state.simple ||
(layout.state.simple && settings.state.simpleModeShowString.includes('showDock'))
"
/>
<div
class="fixed z-40 right-[14%] top-8"
v-if="
(!layout.state.simple && settings.state.showPet) ||
(layout.state.simple && settings.state.simpleModeShowString.includes('showPet'))
"
>
<Fox />
</div>
<ModalPgae />
<DirModal />
<GlobalMenu />
<WelcomePage></WelcomePage>
<TomatoPage></TomatoPage>
<BackupRecovery v-if="router.path === 'global-backup'"></BackupRecovery>
</div>
<ModalPgae />
<!-- </ConfigProvider> -->
</template>

View File

@ -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 () => (
<div class="p-4 flex flex-col ">
<div class={'flex flex-col'}>
<span
class={clsx(
'text-[14px] font-bold',
useLayoutStore().state.current === 0 ? 'text-white' : ' text-[#333]'
)}
>
AI助手
</span>
<span class={'text-[13px] text-[#666] '}>AI助手样式</span>
<div
class={clsx(
'w-full h-[1px] bg-black/10 mt-1 mb-2',
useLayoutStore().state.current === 0 ? 'bg-white/10' : ' bg-black/10'
)}
></div>
</div>
<span
class={clsx(
'text-[14px] font-bold my-2',
useLayoutStore().state.current === 0 ? 'text-white' : 'text-[#333]'
)}
>
</span>
<SettingItem
v-slots={{
label: () => <div></div>
}}
noRoundedB
desc="fatfox标签页内的小助手"
>
<Switch
checked={settings.state.showPet}
onUpdate:checked={(e) => {
if (e) settings.state.showPet = true
else settings.state.showPet = false
}}
/>
</SettingItem>
<SettingItem
v-slots={{
label: () => <div></div>
}}
desc="fatfox标签页内的小助手"
noRoundedT
>
<Switch
checked={settings.state.showPetOnTab}
onUpdate:checked={(e) => {
if (e) settings.state.showPetOnTab = true
else settings.state.showPetOnTab = false
}}
/>
</SettingItem>
<span
class={clsx(
'text-[14px] font-bold my-2',
useLayoutStore().state.current === 0 ? 'text-white' : 'text-[#333]'
)}
>
</span>
<SettingItem
v-slots={{
label: () => <div></div>
}}
desc="使用搜索引擎时Fatfox会给您更多有效的结果"
>
<Switch
checked={settings.state.autoUseAi !== ''}
onUpdate:checked={(e) => {
if (e) settings.state.autoUseAi = 'show'
else settings.state.autoUseAi = ''
}}
/>
</SettingItem>
<div
class={clsx('flex w-full py-2 px-3 rounded-lg flex-col', {
'bg-black/5': useLayoutStore().state.current !== 0,
'bg-white/10': useLayoutStore().state.current === 0
})}
>
<span>使</span>
<SettingItem
v-slots={{
label: () => <div></div>
}}
noBg
desc="每次搜索直接询问fatfox"
>
<Radio
checked={settings.state.autoUseAi === 'show'}
onClick={() => {
settings.state.autoUseAi = 'show'
}}
onUpdate:checked={(e) => {
if (e) settings.state.showSider = 'auto'
else settings.state.showSider = 'show'
}}
/>
</SettingItem>
<SettingItem
v-slots={{
label: () => <div></div>
}}
noBg
desc="每次搜索,提示您进行手动查询"
>
<Radio
checked={settings.state.autoUseAi === 'auto'}
onClick={() => {
settings.state.autoUseAi = 'auto'
}}
/>
</SettingItem>
</div>
</div>
)
}
})

View File

@ -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'
}}
>
<div class={clsx('text-sm mr-4', isGame.value ? 'text-white' : 'text-black/60')}>
{ctx.slots.label?.()}
<div
class={clsx('text-sm mr-4 flex flex-col', isGame.value ? 'text-white' : 'text-black/60')}
>
<span> {ctx.slots.label?.()}</span>
{props.desc ? (
<span
class={clsx('text-[12px] ', isGame.value ? 'text-white opacity-50 ' : 'text-black/60')}
>
{props.desc}
</span>
) : null}
</div>
<div class="">{ctx.slots.default?.()}</div>
{/* {ctx.slots.end?.()} */}

View File

@ -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(() => {
<Reset />
) : router.path === 'settings-fallback' ? (
<Feedback />
) : router.path === 'settings-ai' ? (
<AiSetting />
) : null}
</ThemeProvider>
</div>

View File

@ -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[],

View File

@ -7,8 +7,9 @@ export function sendParent(
| [
'configAI',
{
autoSearch: true
showTabButton: true
autoSearch: boolean
showTabButton: boolean
isSearch: boolean
}
]
) {

View File

@ -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 () => (
<div
@ -59,6 +62,10 @@ export default defineComponent(() => {
}}
></input>
<div
onClick={(e) => {
e.stopPropagation()
searchText.value = ''
}}
class={
'absolute cursor-pointer hidden group-hover:block right-3 top-1/2 -translate-y-1/2'
}