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

View File

@ -32,7 +32,7 @@ export default defineComponent({
menu.open(props.block)
}}
onClick={() => {
router.path = `widget-${props.block.name}`
router.go(`widget-${props.block.name}`)
}}
>
<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"
onClick={() => {
if (layout.state.content[layout.state.current].pages[layout.state.currentPage]) {
router.path = 'global-adder'
router.go('global-adder')
} else {
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"
onClick={() => {
search.showSearchConfig = false
router.path = 'global-search'
router.go('global-search')
}}
>
<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"
label="反馈"
onClick={() => {
router.path = 'settings-fallback'
router.go('settings-fallback')
}}
/>
<div
class="w-[56px] h-[56px] rounded-full border-white border-[2px] border-solid overflow-hidden cursor-pointer"
onClick={() => {
if (user.isLogin) {
router.path = 'settings-user'
router.go('settings-user')
} 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"
style="filter: drop-shadow(0 0 4px rgba(0,0,0,0.2))"
onClick={() => {
router.path = 'settings-background'
router.go('settings-background')
}}
>
<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' : '')
}
onClick={() => {
router.path = props.path as any
router.go(props.path as any)
}}
>
{props.label}
@ -44,7 +44,7 @@ export default defineComponent(() => {
<div
class="w-full h-screen"
onClick={() => {
router.path = ''
router.back()
}}
></div>
)}
@ -52,45 +52,41 @@ export default defineComponent(() => {
<Transition name="settings">
{show.value && (
<div class="absolute left-6 bottom-20 w-[600px] h-[480px] rounded-lg overflow-hidden shadow-2xl flex">
{
router.path.startsWith('settings-') ?
<>
<div class="w-[200px] p-4 h-full bg-white/60 backdrop-blur flex flex-col">
<div
class={
'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' : '')
}
onClick={() => {
router.path = 'settings-user'
}}
>
<div class="w-12 h-12 relative">
<AvatarCircle />
</div>
{router.path.startsWith('settings-') ? (
<>
<div class="w-[200px] p-4 h-full bg-white/60 backdrop-blur flex flex-col">
<div
class={
'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' : '')
}
onClick={() => {
router.go('settings-user')
}}
>
<div class="w-12 h-12 relative">
<AvatarCircle />
</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>
<Content />
</>
:
router.path.startsWith('s2') ?
<>
<div class="w-full h-full flex justify-center items-center bg-red-300">
</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>
<Content />
</>
) : router.path.startsWith('s2') ? (
<>
<div class="w-full h-full flex justify-center items-center bg-red-300"></div>
</>
) : (
''
)}
</div>
)}
</Transition>

View File

@ -1,5 +1,5 @@
import { defineStore } from 'pinia'
import { ref } from 'vue'
import { computed, ref, watch } from 'vue'
export type GlobalStr = 'search' | 'block' | 'adder' | 'login'
export type SettingStr =
@ -16,8 +16,24 @@ export type SettingStr =
export type RouteStr = '' | `widget-${string}` | `global-${GlobalStr}` | `settings-${SettingStr}`
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 {
path
path,
go,
back
}
})

View File

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

View File

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