重构主题切换和题目页面的切换

This commit is contained in:
2024-07-05 13:05:02 +08:00
parent fdf0de9db1
commit 2e260db9e5
4 changed files with 91 additions and 84 deletions

View File

@@ -1,17 +1,19 @@
import { ScreenMode } from "~/utils/constants"
export const screenMode = ref(ScreenMode.both)
export const { state: screenMode, next: switchScreenMode } = useCycleList(
Object.values(ScreenMode),
{
initialValue: ScreenMode.both,
},
)
export const screenSwitchLabel = computed(() => {
if (screenMode.value === ScreenMode.both) return "题目 | 自测"
else if (screenMode.value === ScreenMode.problem) return "仅题目"
return "仅自测"
})
export function switchScreenMode() {
if (screenMode.value === ScreenMode.both) {
screenMode.value = ScreenMode.problem
return
}
screenMode.value += 1
export function resetScreenMode() {
screenMode.value = ScreenMode.both
}
export const bothAndProblem = computed(
() =>
screenMode.value === ScreenMode.both ||
screenMode.value === ScreenMode.problem,
)