Skip to content

Commit

Permalink
新增哀悼模式和色弱模式
Browse files Browse the repository at this point in the history
  • Loading branch information
hooray committed Jun 28, 2024
1 parent fa3114e commit 7501268
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/components/AppSetting/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,18 @@ function handleCopy() {
</div>
<HToggle v-model="settingsStore.settings.app.enableProgress" />
</div>
<div class="flex items-center justify-between gap-4 rounded-2 px-4 py-2">
<div class="flex flex-shrink-0 items-center gap-2 text-sm">
哀悼模式
</div>
<HToggle v-model="settingsStore.settings.app.enableMournMode" />
</div>
<div class="flex items-center justify-between gap-4 rounded-2 px-4 py-2">
<div class="flex flex-shrink-0 items-center gap-2 text-sm">
色弱模式
</div>
<HToggle v-model="settingsStore.settings.app.enableColorAmblyopiaMode" />
</div>
<div class="flex items-center justify-between gap-4 rounded-2 px-4 py-2">
<div class="flex flex-shrink-0 items-center gap-2 text-sm">
返回顶部
Expand Down
2 changes: 2 additions & 0 deletions src/settings.default.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
const globalSettingsDefault: RecursiveRequired<Settings.all> = {
app: {
colorScheme: 'light',
enableMournMode: false,
enableColorAmblyopiaMode: false,
enablePermission: false,
enableProgress: true,
enableDynamicTitle: false,
Expand Down
17 changes: 17 additions & 0 deletions src/store/modules/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,23 @@ const useSettingsStore = defineStore(
break
}
}
watch([
() => settings.value.app.enableMournMode,
() => settings.value.app.enableColorAmblyopiaMode,
], (val) => {
document.documentElement.style.removeProperty('filter')
if (val[0] && val[1]) {
document.documentElement.style.setProperty('filter', 'grayscale(100%) invert(80%)')
}
else if (val[0]) {
document.documentElement.style.setProperty('filter', 'grayscale(100%)')
}
else if (val[1]) {
document.documentElement.style.setProperty('filter', 'invert(80%)')
}
}, {
immediate: true,
})

const title = ref('')
// 设置网页标题
Expand Down
10 changes: 10 additions & 0 deletions src/types/global.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,16 @@ declare namespace Settings {
* @可选值 `'dark'` 暗黑模式
*/
colorScheme?: '' | 'light' | 'dark'
/**
* 是否开启哀悼模式
* @默认值 `false`
*/
enableMournMode?: boolean
/**
* 是否开启色弱模式
* @默认值 `false`
*/
enableColorAmblyopiaMode?: boolean
/**
* 是否开启权限功能
* @默认值 `false`
Expand Down

0 comments on commit 7501268

Please sign in to comment.