refactor: 移除设置页键盘操作支持并升级 1.0.7

- SettingsView 删除方向键切换、roving tabindex、ARIA 单选组语义与焦点环,仅保留原生按钮点击切换
- README 清理过时描述并补充 v1.0.7 更新日志
- 版本升级 1.0.7
This commit is contained in:
2026-08-08 20:11:28 +08:00
parent df9cd52de6
commit 96dd1ef4d3
5 changed files with 80 additions and 60 deletions
+3 -57
View File
@@ -1,7 +1,7 @@
<script setup lang="ts">
import type { ThemeMode } from '../composables/useDarkMode'
import { useDarkMode } from '../composables/useDarkMode'
import { computed, nextTick, ref } from 'vue'
import { computed } from 'vue'
const { theme, isDark, setTheme } = useDarkMode()
@@ -17,42 +17,6 @@ const modeOptions: { value: ThemeMode; label: string; description: string }[] =
{ value: 'dark', label: '深色', description: '始终使用深色模式' },
{ value: 'auto', label: '跟随系统', description: '根据系统设置自动切换' },
]
const optionEls = ref<HTMLButtonElement[]>([])
const activeIndex = computed(() =>
Math.max(
0,
modeOptions.findIndex((option) => option.value === theme.value),
),
)
function setOptionRef(el: unknown, index: number): void {
if (el) {
optionEls.value[index] = el as HTMLButtonElement
}
}
function focusOption(index: number): void {
const next = (index + modeOptions.length) % modeOptions.length
setTheme(modeOptions[next].value)
void nextTick(() => optionEls.value[next]?.focus())
}
function onKeydown(event: KeyboardEvent): void {
if (event.key === 'ArrowDown' || event.key === 'ArrowRight') {
event.preventDefault()
focusOption(activeIndex.value + 1)
} else if (event.key === 'ArrowUp' || event.key === 'ArrowLeft') {
event.preventDefault()
focusOption(activeIndex.value - 1)
} else if (event.key === 'Home') {
event.preventDefault()
focusOption(0)
} else if (event.key === 'End') {
event.preventDefault()
focusOption(modeOptions.length - 1)
}
}
</script>
<template>
@@ -67,26 +31,13 @@ function onKeydown(event: KeyboardEvent): void {
当前生效<strong>{{ currentEffectiveMode }}</strong>
</div>
<div
class="dark-mode-settings__options"
role="radiogroup"
aria-label="主题模式"
@keydown="onKeydown"
>
<div class="dark-mode-settings__options">
<button
v-for="(option, index) in modeOptions"
v-for="option in modeOptions"
:key="option.value"
type="button"
role="radio"
class="dark-mode-settings__option"
:class="{ 'is-active': theme === option.value }"
:aria-checked="theme === option.value"
:tabindex="theme === option.value ? 0 : -1"
:ref="
(el: unknown) => {
setOptionRef(el, index)
}
"
@click="setTheme(option.value)"
>
<div class="dark-mode-settings__option-label">{{ option.label }}</div>
@@ -163,11 +114,6 @@ function onKeydown(event: KeyboardEvent): void {
background-color: var(--halo-bg-hover);
}
.dark-mode-settings__option:focus-visible {
outline: 2px solid var(--halo-accent-primary);
outline-offset: 2px;
}
.dark-mode-settings__option.is-active {
background-color: var(--halo-menu-item-active);
border-color: var(--halo-accent-primary);