Compare commits

...

2 Commits

Author SHA1 Message Date
31255bc11c update
Some checks failed
Deploy / deploy (build, debian, 22, /root/OJDeploy/data/clientnext) (push) Has been cancelled
Deploy / deploy (build:staging, school, 8822, /root/OJ/data/dist) (push) Has been cancelled
2026-04-09 05:45:21 -06:00
9fc0a91f5e style: disable default view-transition cross-fade 2026-04-09 05:39:57 -06:00
3 changed files with 44 additions and 1 deletions

8
src/env.d.ts vendored
View File

@@ -14,3 +14,11 @@ interface ImportMetaEnv {
interface ImportMeta { interface ImportMeta {
readonly env: ImportMetaEnv readonly env: ImportMetaEnv
} }
interface Document {
startViewTransition?: (callback: () => void | Promise<void>) => {
ready: Promise<void>
finished: Promise<void>
updateCallbackDone: Promise<void>
}
}

View File

@@ -9,3 +9,9 @@ body {
.md-editor-dark div.vuepress-theme { .md-editor-dark div.vuepress-theme {
--md-theme-color: var(--n-text-color) !important; --md-theme-color: var(--n-text-color) !important;
} }
::view-transition-old(root),
::view-transition-new(root) {
animation: none;
mix-blend-mode: normal;
}

View File

@@ -20,6 +20,35 @@ const { isMobile, isDesktop } = useBreakpoints()
const isDark = useDark() const isDark = useDark()
function toggleDark(event: MouseEvent) {
const { clientX: x, clientY: y } = event
const radius = Math.hypot(
Math.max(x, window.innerWidth - x),
Math.max(y, window.innerHeight - y),
)
if (!document.startViewTransition) {
isDark.value = !isDark.value
return
}
document.startViewTransition(() => {
isDark.value = !isDark.value
}).ready.then(() => {
document.documentElement.animate(
{
clipPath: [
`circle(0px at ${x}px ${y}px)`,
`circle(${radius}px at ${x}px ${y}px)`,
],
},
{
duration: 400,
easing: "ease-in-out",
pseudoElement: "::view-transition-new(root)",
},
)
}).catch(() => {})
}
// 从 store 中获取屏幕模式状态 // 从 store 中获取屏幕模式状态
const { screenMode } = storeToRefs(screenModeStore) const { screenMode } = storeToRefs(screenModeStore)
@@ -270,7 +299,7 @@ function handleMenuSelect(key: string) {
</n-button> </n-button>
</n-flex> </n-flex>
</div> </div>
<n-button :bordered="false" circle @click="isDark = !isDark"> <n-button :bordered="false" circle @click="toggleDark">
<template #icon> <template #icon>
<Icon v-if="isDark" icon="twemoji:sun-behind-small-cloud"></Icon> <Icon v-if="isDark" icon="twemoji:sun-behind-small-cloud"></Icon>
<Icon v-else icon="twemoji:cloud-with-lightning-and-rain"></Icon> <Icon v-else icon="twemoji:cloud-with-lightning-and-rain"></Icon>