import useRouterStore, { type RouteStr } from '@/useRouterStore' import { computed, defineComponent, ref, Transition, watch } from 'vue' import { OhVueIcon, addIcons } from 'oh-vue-icons' import { MdClose, MdOpeninfull, MdClosefullscreen } from 'oh-vue-icons/icons' import asyncLoader from './utils/asyncLoader' import widgetList from '@/widgets' addIcons(MdClose, MdOpeninfull, MdClosefullscreen) const SearchPage = asyncLoader(() => import('@/layout/header/search/SearchPage')) const AdderPage = asyncLoader(() => import('@/layout/adder/AdderPage')) const BackgroundSwtich = asyncLoader(() => import('@/layout/background/BackgroundSwtich')) const noFullList: RouteStr[] = ['global-search', 'global-adder', 'global-background'] export default defineComponent(() => { const router = useRouterStore() const show = computed( () => router.path.startsWith('widget-') || router.path === 'global-search' || router.path === 'global-adder' || router.path === 'global-background' ) const full = ref(false) watch(router, () => { full.value = false }) return () => (
{/* 背景遮罩 */} {show.value && (
{ router.back() }} >
)}
{/* 弹框主体 */} {show.value && (
{/* 关闭按钮 */}
{ router.back() }} >
{/* 全屏按钮 */} {noFullList.includes(router.path) ? null : (
{ full.value = !full.value }} >
)}
{router.path === 'global-search' ? ( ) : router.path === 'global-adder' ? ( ) : router.path === 'global-background' ? ( ) : router.path.startsWith('widget-') ? ( (() => { const name = router.path.split('-')[1] const selected = widgetList.find((el) => el.name === name) if (!selected) return (
组件维护中
) const compo = selected.modal console.log(compo) return })() ) : null}
)}
) })