This commit is contained in:
plightfield 2024-09-29 16:16:13 +08:00
parent 5c3bd6b7b3
commit ca3e3dec19
10 changed files with 68 additions and 56 deletions

View File

@ -30,7 +30,7 @@ export default defineComponent(() => {
<div <div
class="w-full h-screen bg-black/20 backdrop-blur" class="w-full h-screen bg-black/20 backdrop-blur"
onClick={() => { onClick={() => {
router.path = '' router.back()
}} }}
></div> ></div>
)} )}
@ -53,7 +53,7 @@ export default defineComponent(() => {
(router.path === 'global-adder' ? 'top-6 right-4' : 'top-2 right-2') (router.path === 'global-adder' ? 'top-6 right-4' : 'top-2 right-2')
} }
onClick={() => { onClick={() => {
router.path = '' router.back()
}} }}
> >
<OhVueIcon name="md-close" scale={0.7} fill="white" /> <OhVueIcon name="md-close" scale={0.7} fill="white" />

View File

@ -32,7 +32,7 @@ export default defineComponent({
menu.open(props.block) menu.open(props.block)
}} }}
onClick={() => { onClick={() => {
router.path = `widget-${props.block.name}` router.go(`widget-${props.block.name}`)
}} }}
> >
<compo /> <compo />

View File

@ -67,7 +67,7 @@ export default defineComponent(() => {
class="w-full h-full overflow-hidden rounded-[calc(var(--block-radius)_*_var(--block-size))] bg-white/60 backdrop-blur flex justify-center items-center cursor-pointer hover:scale-105 transition-all" class="w-full h-full overflow-hidden rounded-[calc(var(--block-radius)_*_var(--block-size))] bg-white/60 backdrop-blur flex justify-center items-center cursor-pointer hover:scale-105 transition-all"
onClick={() => { onClick={() => {
if (layout.state.content[layout.state.current].pages[layout.state.currentPage]) { if (layout.state.content[layout.state.current].pages[layout.state.currentPage]) {
router.path = 'global-adder' router.go('global-adder')
} else { } else {
globalToast.warning('请先添加页面') globalToast.warning('请先添加页面')
} }

View File

@ -53,7 +53,7 @@ export default defineComponent({
class="w-full h-10 rounded-lg overflow-hidden flex justify-center items-center p-2 transition-all cursor-pointer bg-white/40 hover:bg-white/60" class="w-full h-10 rounded-lg overflow-hidden flex justify-center items-center p-2 transition-all cursor-pointer bg-white/40 hover:bg-white/60"
onClick={() => { onClick={() => {
search.showSearchConfig = false search.showSearchConfig = false
router.path = 'global-search' router.go('global-search')
}} }}
> >
<OhVueIcon name="fa-plus" scale={1.4} fill="rgba(0,0,0,.4)" /> <OhVueIcon name="fa-plus" scale={1.4} fill="rgba(0,0,0,.4)" />

View File

@ -114,16 +114,16 @@ export default defineComponent(() => {
name="px-headset" name="px-headset"
label="反馈" label="反馈"
onClick={() => { onClick={() => {
router.path = 'settings-fallback' router.go('settings-fallback')
}} }}
/> />
<div <div
class="w-[56px] h-[56px] rounded-full border-white border-[2px] border-solid overflow-hidden cursor-pointer" class="w-[56px] h-[56px] rounded-full border-white border-[2px] border-solid overflow-hidden cursor-pointer"
onClick={() => { onClick={() => {
if (user.isLogin) { if (user.isLogin) {
router.path = 'settings-user' router.go('settings-user')
} else { } else {
router.path = 'global-login' router.go('global-login')
} }
}} }}
> >

View File

@ -10,7 +10,7 @@ export default defineComponent(() => {
class="absolute left-10 bottom-8 p-1 z-10 flex justify-center items-center cursor-pointer rounded-lg hover:bg-black/20 transition-all" class="absolute left-10 bottom-8 p-1 z-10 flex justify-center items-center cursor-pointer rounded-lg hover:bg-black/20 transition-all"
style="filter: drop-shadow(0 0 4px rgba(0,0,0,0.2))" style="filter: drop-shadow(0 0 4px rgba(0,0,0,0.2))"
onClick={() => { onClick={() => {
router.path = 'settings-background' router.go('settings-background')
}} }}
> >
<OhVueIcon name="md-settings" fill="white" scale={1.2} /> <OhVueIcon name="md-settings" fill="white" scale={1.2} />

View File

@ -25,7 +25,7 @@ const SettingsTab = defineComponent({
(router.path === props.path ? 'bg-white/70 font-bold shadow-lg' : '') (router.path === props.path ? 'bg-white/70 font-bold shadow-lg' : '')
} }
onClick={() => { onClick={() => {
router.path = props.path as any router.go(props.path as any)
}} }}
> >
{props.label} {props.label}
@ -44,7 +44,7 @@ export default defineComponent(() => {
<div <div
class="w-full h-screen" class="w-full h-screen"
onClick={() => { onClick={() => {
router.path = '' router.back()
}} }}
></div> ></div>
)} )}
@ -52,45 +52,41 @@ export default defineComponent(() => {
<Transition name="settings"> <Transition name="settings">
{show.value && ( {show.value && (
<div class="absolute left-6 bottom-20 w-[600px] h-[480px] rounded-lg overflow-hidden shadow-2xl flex"> <div class="absolute left-6 bottom-20 w-[600px] h-[480px] rounded-lg overflow-hidden shadow-2xl flex">
{ {router.path.startsWith('settings-') ? (
router.path.startsWith('settings-') ? <>
<> <div class="w-[200px] p-4 h-full bg-white/60 backdrop-blur flex flex-col">
<div class="w-[200px] p-4 h-full bg-white/60 backdrop-blur flex flex-col"> <div
<div class={
class={ 'w-full h-0 flex-grow mb-4 rounded-lg hover:bg-white/70 transition-all cursor-pointer flex justify-center items-center ' +
'w-full h-0 flex-grow mb-4 rounded-lg hover:bg-white/70 transition-all cursor-pointer flex justify-center items-center ' + (router.path === 'settings-user' ? 'bg-white/70 shadow-lg' : '')
(router.path === 'settings-user' ? 'bg-white/70 shadow-lg' : '') }
} onClick={() => {
onClick={() => { router.go('settings-user')
router.path = 'settings-user' }}
}} >
> <div class="w-12 h-12 relative">
<div class="w-12 h-12 relative"> <AvatarCircle />
<AvatarCircle />
</div>
</div> </div>
<SettingsTab label="壁纸" path="settings-background" />
<SettingsTab label="图标" path="settings-block" />
<SettingsTab label="搜索" path="settings-search" />
<SettingsTab label="时间" path="settings-time" />
<SettingsTab label="侧边栏" path="settings-sider" />
<SettingsTab label="AI助手" path="settings-ai" />
<SettingsTab label="快捷栏" path="settings-dock" />
<SettingsTab label="重置" path="settings-reset" />
<SettingsTab label="问题反馈" path="settings-fallback" />
</div> </div>
<Content /> <SettingsTab label="壁纸" path="settings-background" />
</> <SettingsTab label="图标" path="settings-block" />
: <SettingsTab label="搜索" path="settings-search" />
router.path.startsWith('s2') ? <SettingsTab label="时间" path="settings-time" />
<> <SettingsTab label="侧边栏" path="settings-sider" />
<div class="w-full h-full flex justify-center items-center bg-red-300"> <SettingsTab label="AI助手" path="settings-ai" />
</div> <SettingsTab label="快捷栏" path="settings-dock" />
</> <SettingsTab label="重置" path="settings-reset" />
: '' <SettingsTab label="问题反馈" path="settings-fallback" />
</div>
} <Content />
</>
) : router.path.startsWith('s2') ? (
<>
<div class="w-full h-full flex justify-center items-center bg-red-300"></div>
</>
) : (
''
)}
</div> </div>
)} )}
</Transition> </Transition>

View File

@ -1,5 +1,5 @@
import { defineStore } from 'pinia' import { defineStore } from 'pinia'
import { ref } from 'vue' import { computed, ref, watch } from 'vue'
export type GlobalStr = 'search' | 'block' | 'adder' | 'login' export type GlobalStr = 'search' | 'block' | 'adder' | 'login'
export type SettingStr = export type SettingStr =
@ -16,8 +16,24 @@ export type SettingStr =
export type RouteStr = '' | `widget-${string}` | `global-${GlobalStr}` | `settings-${SettingStr}` export type RouteStr = '' | `widget-${string}` | `global-${GlobalStr}` | `settings-${SettingStr}`
export default defineStore('router', () => { export default defineStore('router', () => {
const path = ref<RouteStr>('') const his = ref<RouteStr[]>([])
const go = (p: RouteStr) => {
his.value.unshift(p)
if (his.value.length > 10) {
his.value.pop()
}
}
const back = () => {
if (his.value.length > 0) {
his.value.shift()
}
}
const path = computed(() => {
return his.value[0] || ''
})
return { return {
path path,
go,
back
} }
}) })

View File

@ -17,7 +17,7 @@ export default defineComponent(() => {
<div <div
class="w-full h-screen bg-black/20 backdrop-blur" class="w-full h-screen bg-black/20 backdrop-blur"
onClick={() => { onClick={() => {
router.path = '' router.back()
}} }}
></div> ></div>
)} )}
@ -45,7 +45,7 @@ export default defineComponent(() => {
returnType: 'text' returnType: 'text'
}).then((res) => { }).then((res) => {
user.token = res user.token = res
router.path = '' router.go('')
}) })
}} }}
> >

View File

@ -43,7 +43,7 @@ export default defineComponent(() => {
<> <>
<Button <Button
onClick={() => { onClick={() => {
router.path = 'global-login' router.go('global-login')
}} }}
icon={<EditOutlined />} icon={<EditOutlined />}
type="primary" type="primary"
@ -58,7 +58,7 @@ export default defineComponent(() => {
title: '退出登录', title: '退出登录',
content: '确定要退出登录吗?', content: '确定要退出登录吗?',
onOk: () => { onOk: () => {
router.path = '' router.go('')
user.logout() user.logout()
globalToast.success('已退出登录') globalToast.success('已退出登录')
} }
@ -74,7 +74,7 @@ export default defineComponent(() => {
icon={<LoginOutlined />} icon={<LoginOutlined />}
size="large" size="large"
onClick={() => { onClick={() => {
router.path = 'global-login' router.go('global-login')
}} }}
> >