Skip to content

Commit

Permalink
工具栏文件目录结构调整
Browse files Browse the repository at this point in the history
  • Loading branch information
hooray committed Dec 30, 2023
1 parent f0fc82f commit 4af1e44
Show file tree
Hide file tree
Showing 12 changed files with 256 additions and 204 deletions.
33 changes: 15 additions & 18 deletions src/layouts/components/AppSetting/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,21 @@ function handleCopy() {
<div class="divider">
工具栏
</div>
<div v-if="settingsStore.mode === 'pc'" class="setting-item">
<div class="label">
面包屑导航
</div>
<HToggle v-model="settingsStore.settings.toolbar.breadcrumb" />
</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 v-if="settingsStore.mode === 'pc'" class="setting-item">
<div class="label">
全屏
Expand All @@ -200,15 +215,6 @@ function handleCopy() {
</div>
<HToggle v-model="settingsStore.settings.toolbar.colorScheme" />
</div>
<div v-if="settingsStore.mode === 'pc'" class="divider">
面包屑导航
</div>
<div v-if="settingsStore.mode === 'pc'" class="setting-item">
<div class="label">
是否启用
</div>
<HToggle v-model="settingsStore.settings.toolbar.breadcrumb" />
</div>
<div class="divider">
页面
</div>
Expand All @@ -221,15 +227,6 @@ 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.toolbar.navSearch" />
</div>
<div class="setting-item">
<div class="label">
是否启用快捷键
Expand Down
4 changes: 2 additions & 2 deletions src/layouts/components/Header/index.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script setup lang="ts">
import Logo from '../Logo/index.vue'
import Tools from '../Tools/index.vue'
import ToolbarRightSide from '../Topbar/Toolbar/rightSide.vue'
import useMenuStore from '@/store/modules/menu'
import useSettingsStore from '@/store/modules/settings'
Expand Down Expand Up @@ -55,7 +55,7 @@ function handlerMouserScroll(event: WheelEvent) {
</div>
</div>
</div>
<Tools />
<ToolbarRightSide />
</div>
</header>
</Transition>
Expand Down
104 changes: 0 additions & 104 deletions src/layouts/components/Tools/index.vue

This file was deleted.

58 changes: 58 additions & 0 deletions src/layouts/components/Topbar/Toolbar/Breadcrumb/index.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<script setup lang="ts">
import { compile } from 'path-to-regexp'
import Breadcrumb from '../../../Breadcrumb/index.vue'
import BreadcrumbItem from '../../../Breadcrumb/item.vue'
import useSettingsStore from '@/store/modules/settings'
const route = useRoute()
const settingsStore = useSettingsStore()
const breadcrumbList = computed(() => {
const breadcrumbList = []
if (settingsStore.settings.home.enable) {
breadcrumbList.push({
path: settingsStore.settings.home.fullPath,
title: settingsStore.settings.home.title,
})
}
if (route.meta.breadcrumbNeste) {
route.meta.breadcrumbNeste.forEach((item) => {
if (item.hide === false) {
breadcrumbList.push({
path: item.path,
title: item.title,
})
}
})
}
return breadcrumbList
})
function pathCompile(path: string) {
const toPath = compile(path)
return toPath(route.params)
}
</script>

<template>
<Breadcrumb v-if="settingsStore.mode === 'pc' && settingsStore.settings.app.routeBaseOn !== 'filesystem'" class="breadcrumb whitespace-nowrap px-2">
<TransitionGroup name="breadcrumb">
<BreadcrumbItem v-for="(item, index) in breadcrumbList" :key="`${index}_${item.path}_${item.title}`" :to="index < breadcrumbList.length - 1 && item.path !== '' ? pathCompile(item.path) : ''">
{{ item.title }}
</BreadcrumbItem>
</TransitionGroup>
</Breadcrumb>
</template>

<style lang="scss" scoped>
// 面包屑动画
.breadcrumb-enter-active {
transition: transform 0.3s, opacity 0.3s;
}
.breadcrumb-enter-from {
opacity: 0;
transform: translateX(30px) skewX(-50deg);
}
</style>
43 changes: 43 additions & 0 deletions src/layouts/components/Topbar/Toolbar/ColorScheme/index.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<script setup lang="ts">
import useSettingsStore from '@/store/modules/settings'
defineOptions({
name: 'ColorScheme',
})
const settingsStore = useSettingsStore()
function toggleColorScheme(event: MouseEvent) {
const { startViewTransition } = useViewTransition(() => {
settingsStore.setColorScheme(settingsStore.settings.app.colorScheme === 'dark' ? 'light' : 'dark')
})
startViewTransition()?.ready.then(() => {
const x = event.clientX
const y = event.clientY
const endRadius = Math.hypot(
Math.max(x, innerWidth - x),
Math.max(y, innerHeight - y),
)
const clipPath = [
`circle(0px at ${x}px ${y}px)`,
`circle(${endRadius}px at ${x}px ${y}px)`,
]
document.documentElement.animate(
{
clipPath: settingsStore.settings.app.colorScheme !== 'dark' ? clipPath : clipPath.reverse(),
},
{
duration: 300,
easing: 'ease-out',
pseudoElement: settingsStore.settings.app.colorScheme !== 'dark' ? '::view-transition-new(root)' : '::view-transition-old(root)',
},
)
})
}
</script>

<template>
<span class="flex-center cursor-pointer px-2 py-1" @click="toggleColorScheme">
<SvgIcon :name="settingsStore.settings.app.colorScheme === 'light' ? 'ri:sun-line' : 'ri:moon-line'" />
</span>
</template>
18 changes: 18 additions & 0 deletions src/layouts/components/Topbar/Toolbar/Fullscreen/index.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<script setup lang="ts">
import { useFullscreen } from '@vueuse/core'
import useSettingsStore from '@/store/modules/settings'
defineOptions({
name: 'Fullscreen',
})
const settingsStore = useSettingsStore()
const { isFullscreen, toggle } = useFullscreen()
</script>

<template>
<span v-if="settingsStore.mode === 'pc'" class="flex-center cursor-pointer px-2 py-1" @click="toggle">
<SvgIcon :name="isFullscreen ? 'ri:fullscreen-exit-line' : 'ri:fullscreen-line'" />
</span>
</template>
21 changes: 21 additions & 0 deletions src/layouts/components/Topbar/Toolbar/NavSearch/index.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<script setup lang="ts">
import eventBus from '@/utils/eventBus'
import useSettingsStore from '@/store/modules/settings'
defineOptions({
name: 'ToolbarRightSide',
})
const settingsStore = useSettingsStore()
</script>

<template>
<span class="flex-center cursor-pointer px-2 py-1" @click="eventBus.emit('global-search-toggle')">
<SvgIcon v-if="settingsStore.mode === 'mobile'" name="ri:search-line" />
<span v-else class="group inline-flex cursor-pointer items-center gap-1 whitespace-nowrap 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">
<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>
</span>
</template>
13 changes: 13 additions & 0 deletions src/layouts/components/Topbar/Toolbar/PageReload/index.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<script setup lang="ts">
defineOptions({
name: 'PageReload',
})
const mainPage = useMainPage()
</script>

<template>
<span class="flex-center cursor-pointer px-2 py-1" @click="mainPage.reload()">
<SvgIcon name="iconoir:refresh-double" />
</span>
</template>
Loading

0 comments on commit 4af1e44

Please sign in to comment.