Skip to content

Commit

Permalink
refactor!: 应用配置 toolbar 对象内属性调整
Browse files Browse the repository at this point in the history
  • Loading branch information
hooray committed Jan 4, 2024
1 parent df1cf24 commit e2aaf24
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 29 deletions.
7 changes: 4 additions & 3 deletions src/settings.default.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,12 @@ const globalSettingsDefault: RecursiveRequired<Settings.all> = {
enableHotkeys: false,
},
toolbar: {
enableFullscreen: false,
enableColorScheme: false,
previewWindows: true,
navSearch: true,
fullscreen: false,
colorScheme: false,
},
navSearch: {
enable: true,
enableHotkeys: true,
},
window: {
Expand Down
19 changes: 12 additions & 7 deletions src/types/global.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,23 +61,28 @@ declare namespace Settings {
enableHotkeys?: boolean
}
interface toolbar {
/**
* 是否开启窗口预览
* @默认值 `true`
*/
previewWindows?: boolean
/**
* 是否开启导航搜索
* @默认值 `true`
*/
navSearch?: boolean
/**
* 是否开启全屏
* @默认值 `false`
*/
enableFullscreen?: boolean
fullscreen?: boolean
/**
* 是否开启颜色主题
* @默认值 `false`
*/
enableColorScheme?: boolean
colorScheme?: boolean
}
interface navSearch {
/**
* 是否开启导航搜索
* @默认值 `true`
*/
enable?: boolean
/**
* 是否开启导航搜索快捷键
* @默认值 `true`
Expand Down
30 changes: 18 additions & 12 deletions src/views/components/AppSetting/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -155,11 +155,26 @@ function handleCopy() {
<div class="divider">
工具栏
</div>
<div class="setting-item">
<div class="label">
窗口预览
</div>
<HToggle v-model="settingsStore.settings.toolbar.previewWindows" />
</div>
<div class="setting-item">
<div class="label">
导航搜索
<HTooltip text="对导航进行快捷搜索">
<SvgIcon name="ri:question-line" />
</HTooltip>
</div>
<HToggle v-model="settingsStore.settings.toolbar.navSearch" />
</div>
<div class="setting-item">
<div class="label">
全屏
</div>
<HToggle v-model="settingsStore.settings.toolbar.enableFullscreen" />
<HToggle v-model="settingsStore.settings.toolbar.fullscreen" />
</div>
<div class="setting-item">
<div class="label">
Expand All @@ -168,7 +183,7 @@ function handleCopy() {
<SvgIcon name="ri:question-line" />
</HTooltip>
</div>
<HToggle v-model="settingsStore.settings.toolbar.enableColorScheme" />
<HToggle v-model="settingsStore.settings.toolbar.colorScheme" />
</div>
<div class="divider">
窗口
Expand All @@ -182,20 +197,11 @@ function handleCopy() {
<div class="divider">
导航搜索
</div>
<div class="setting-item">
<div class="label">
是否启用
<HTooltip text="对导航进行快捷搜索">
<SvgIcon name="ri:question-line" />
</HTooltip>
</div>
<HToggle v-model="settingsStore.settings.navSearch.enable" />
</div>
<div class="setting-item">
<div class="label">
是否启用快捷键
</div>
<HToggle v-model="settingsStore.settings.navSearch.enableHotkeys" :disabled="!settingsStore.settings.navSearch.enable" />
<HToggle v-model="settingsStore.settings.navSearch.enableHotkeys" :disabled="!settingsStore.settings.toolbar.navSearch" />
</div>
<div class="divider">
底部版权
Expand Down
2 changes: 1 addition & 1 deletion src/views/components/HotkeysIntro/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ onMounted(() => {
<HKbd>I</HKbd>
查看系统信息
</li>
<li v-if="settingsStore.settings.navSearch.enable && settingsStore.settings.navSearch.enableHotkeys" class="py-1">
<li v-if="settingsStore.settings.toolbar.navSearch && settingsStore.settings.navSearch.enableHotkeys" class="py-1">
<HKbd>{{ settingsStore.os === 'mac' ? '⌥' : 'Alt' }}</HKbd>
<HKbd>S</HKbd>
唤起导航搜索
Expand Down
4 changes: 2 additions & 2 deletions src/views/components/Search/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -109,13 +109,13 @@ onMounted(() => {
isShow.value = !isShow.value
})
hotkeys('alt+s', (e) => {
if (settingsStore.settings.navSearch.enable && settingsStore.settings.navSearch.enableHotkeys) {
if (settingsStore.settings.toolbar.navSearch && settingsStore.settings.navSearch.enableHotkeys) {
e.preventDefault()
isShow.value = true
}
})
hotkeys('esc', (e) => {
if (settingsStore.settings.navSearch.enable && settingsStore.settings.navSearch.enableHotkeys) {
if (settingsStore.settings.toolbar.navSearch && settingsStore.settings.navSearch.enableHotkeys) {
e.preventDefault()
eventBus.emit('global-search-toggle')
}
Expand Down
8 changes: 4 additions & 4 deletions src/views/components/Tools/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -58,19 +58,19 @@ watch(() => userStore.avatar, () => {

<template>
<div class="tools flex items-center gap-4 whitespace-nowrap px-4">
<span v-if="settingsStore.settings.navSearch.enable" class="group inline-flex cursor-pointer items-center gap-1 rounded-2 bg-stone-1 px-2 py-1.5 text-dark ring-stone-3 ring-inset transition dark:bg-stone-9 dark:text-white hover:ring-1 dark:ring-stone-7" @click="eventBus.emit('global-search-toggle')">
<span v-if="settingsStore.settings.toolbar.navSearch" class="group inline-flex cursor-pointer items-center gap-1 rounded-2 bg-stone-1 px-2 py-1.5 text-dark ring-stone-3 ring-inset transition dark:bg-stone-9 dark:text-white hover:ring-1 dark:ring-stone-7" @click="eventBus.emit('global-search-toggle')">
<SvgIcon name="ri:search-line" />
<span class="text-sm text-stone-5 transition group-hover:text-dark dark:group-hover:text-white">搜索</span>
<HKbd v-if="settingsStore.settings.navSearch.enableHotkeys" class="ml-2">{{ settingsStore.os === 'mac' ? '⌥' : 'Alt' }} S</HKbd>
</span>
<div class="flex items-center empty:hidden">
<span v-if="windowStore.list.length > 1" class="item" @click="previewAllWindows">
<span v-if="settingsStore.settings.toolbar.previewWindows && windowStore.list.length > 0" class="item" @click="previewAllWindows">
<SvgIcon name="i-icon-park-outline:all-application" />
</span>
<span v-if="settingsStore.settings.toolbar.enableFullscreen" class="item" @click="toggle">
<span v-if="settingsStore.settings.toolbar.fullscreen" class="item" @click="toggle">
<SvgIcon :name="isFullscreen ? 'ri:fullscreen-exit-line' : 'ri:fullscreen-line'" />
</span>
<span v-if="settingsStore.settings.toolbar.enableColorScheme" class="item" @click="toggleColorScheme">
<span v-if="settingsStore.settings.toolbar.colorScheme" class="item" @click="toggleColorScheme">
<SvgIcon :name="settingsStore.settings.app.colorScheme === 'light' ? 'ri:sun-line' : 'ri:moon-line'" />
</span>
</div>
Expand Down

0 comments on commit e2aaf24

Please sign in to comment.