-
Notifications
You must be signed in to change notification settings - Fork 173
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Jerry
committed
Jun 10, 2024
1 parent
8c75899
commit 2a47b46
Showing
7 changed files
with
5,982 additions
and
4,615 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,89 +1,93 @@ | ||
<template> | ||
<div class="wrapper w-full h-full bg-[#f1f5f9] dark:bg-slate-800 rounded-md dark:text-[#C0BEBF]"> | ||
<ScrollArea class="h-full" type="hover"> | ||
<div class="main lg:w-[567px] mx-auto shadow-2xl bg-white dark:bg-[#181818]"> | ||
<HeaderImg /> | ||
<slot /> | ||
<Footer /> | ||
</div> | ||
</ScrollArea> | ||
</div> | ||
|
||
<Toaster position="top-center" rich-colors /> | ||
|
||
</template> | ||
|
||
<script setup lang="ts"> | ||
import { ScrollArea } from '@/components/ui/scroll-area'; | ||
import { Toaster } from '@/components/ui/sonner'; | ||
import { memoUpdateEvent } from '~/lib/event'; | ||
import type { Memo, PrivateConfig, PublicConfig, User } from '~/lib/types'; | ||
const { data } = await useFetch('/api/user/validateToken', { | ||
method: 'POST' | ||
}) | ||
if (!data.value?.success) { | ||
const token = useCookie('token') | ||
token.value = undefined | ||
} else { | ||
const privateConfigData = await useFetch('/api/config/private', { | ||
method: 'POST' | ||
}) | ||
useState<PrivateConfig | null>('privateConfig', () => privateConfigData.data.value!) | ||
} | ||
const publicConfigData = await useFetch('/api/config/public', { | ||
method: 'POST' | ||
}) | ||
const publicConfig = useState<PublicConfig | null>('publicConfig', () => publicConfigData.data.value!) | ||
const userinfo = useState<User>('userinfo') | ||
await callOnce(async () => { | ||
const { data: res } = await useAsyncData('userinfo', async () => await $fetch('/api/user/settings/get')) | ||
userinfo.value = res.value?.data as any as User | ||
}) | ||
memoUpdateEvent.on((event: Memo & { index?: number }) => { | ||
const target = document.querySelector('div[data-radix-scroll-area-viewport]') | ||
if (target) { | ||
target.scrollTop = 0 | ||
} | ||
}) | ||
useHead({ | ||
link: [ | ||
{ | ||
rel: 'shortcut icon', | ||
type: 'image/png', | ||
href: userinfo.value?.favicon || '/favicon.png', | ||
}, | ||
], | ||
style: [ | ||
{ | ||
innerHTML: userinfo.value?.css || '', | ||
} | ||
], | ||
script: [ | ||
{ | ||
type: 'text/javascript', | ||
innerHTML: userinfo.value?.js || '', | ||
} | ||
] | ||
}) | ||
if (publicConfig.value?.googleRecaptchaSiteKey) { | ||
useHead({ | ||
script: [ | ||
{ | ||
type: 'text/javascript', | ||
src: 'https://recaptcha.net/recaptcha/api.js?render=' + publicConfig.value?.googleRecaptchaSiteKey | ||
} | ||
] | ||
}) | ||
} | ||
</script> | ||
<template> | ||
<div class="wrapper w-full h-full bg-[#f1f5f9] dark:bg-slate-800 rounded-md dark:text-[#C0BEBF]"> | ||
<ScrollArea class="h-full" type="hover"> | ||
<div class="main lg:w-[567px] mx-auto shadow-2xl bg-white dark:bg-[#181818]"> | ||
<HeaderImg /> | ||
<slot /> | ||
<Footer /> | ||
</div> | ||
</ScrollArea> | ||
</div> | ||
|
||
<Toaster position="top-center" rich-colors /> | ||
|
||
</template> | ||
|
||
<script setup lang="ts"> | ||
import { ScrollArea } from '@/components/ui/scroll-area'; | ||
import { Toaster } from '@/components/ui/sonner'; | ||
import { memoUpdateEvent } from '~/lib/event'; | ||
import type { Memo, PrivateConfig, PublicConfig, User } from '~/lib/types'; | ||
const { data } = await useFetch('/api/user/validateToken', { | ||
method: 'POST' | ||
}) | ||
if (!data.value?.success) { | ||
const token = useCookie('token') | ||
token.value = undefined | ||
} else { | ||
const privateConfigData = await useFetch('/api/config/private', { | ||
method: 'POST' | ||
}) | ||
useState<PrivateConfig | null>('privateConfig', () => privateConfigData.data.value!) | ||
} | ||
const publicConfigData = await useFetch('/api/config/public', { | ||
method: 'POST' | ||
}) | ||
const publicConfig = useState<PublicConfig | null>('publicConfig', () => publicConfigData.data.value!) | ||
const userinfo = useState<User>('userinfo') | ||
await callOnce(async () => { | ||
const { data: res } = await useAsyncData('userinfo', async () => await $fetch('/api/user/settings/get')) | ||
userinfo.value = res.value?.data as any as User | ||
}) | ||
memoUpdateEvent.on((event: Memo & { index?: number }) => { | ||
const target = document.querySelector('div[data-radix-scroll-area-viewport]') | ||
if (target) { | ||
target.scrollTop = 0 | ||
} | ||
}) | ||
useHead({ | ||
link: [ | ||
{ | ||
rel: 'shortcut icon', | ||
type: 'image/png', | ||
href: userinfo.value?.favicon || '/favicon.png', | ||
}, | ||
// { | ||
// rel: 'stylesheet', | ||
// href: '/css/APlayer.min.css' | ||
// } | ||
], | ||
style: [ | ||
{ | ||
innerHTML: userinfo.value?.css || '', | ||
} | ||
], | ||
script: [ | ||
{ | ||
type: 'text/javascript', | ||
innerHTML: userinfo.value?.js || '', | ||
} | ||
] | ||
}) | ||
if (publicConfig.value?.googleRecaptchaSiteKey) { | ||
useHead({ | ||
script: [ | ||
{ | ||
type: 'text/javascript', | ||
src: 'https://recaptcha.net/recaptcha/api.js?render=' + publicConfig.value?.googleRecaptchaSiteKey | ||
} | ||
] | ||
}) | ||
} | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.