update prettier 替换为 oxfmt 格式化整个项目的代码结构
This commit is contained in:
@@ -1,59 +1,82 @@
|
||||
<template>
|
||||
<el-menu class="topbar-menu" :ellipsis="false" :default-active="activeMenu" :active-text-color="theme" mode="horizontal">
|
||||
<sidebar-item :key="route.path + index" v-for="(route, index) in topMenus" :item="route" :base-path="route.path" popper-class="topbar-menu-popper" />
|
||||
<el-menu
|
||||
class="topbar-menu"
|
||||
:ellipsis="false"
|
||||
:default-active="activeMenu"
|
||||
:active-text-color="theme"
|
||||
mode="horizontal"
|
||||
>
|
||||
<sidebar-item
|
||||
:key="route.path + index"
|
||||
v-for="(route, index) in topMenus"
|
||||
:item="route"
|
||||
:base-path="route.path"
|
||||
popper-class="topbar-menu-popper"
|
||||
/>
|
||||
|
||||
<el-sub-menu index="more" class="el-sub-menu__hide-arrow" popper-class="topbar-menu-popper" v-if="moreRoutes.length > 0">
|
||||
<el-sub-menu
|
||||
index="more"
|
||||
class="el-sub-menu__hide-arrow"
|
||||
popper-class="topbar-menu-popper"
|
||||
v-if="moreRoutes.length > 0"
|
||||
>
|
||||
<template #title>
|
||||
<span>更多菜单</span>
|
||||
</template>
|
||||
<sidebar-item :key="route.path + index" v-for="(route, index) in moreRoutes" :item="route" :base-path="route.path" popper-class="topbar-menu-popper" />
|
||||
<sidebar-item
|
||||
:key="route.path + index"
|
||||
v-for="(route, index) in moreRoutes"
|
||||
:item="route"
|
||||
:base-path="route.path"
|
||||
popper-class="topbar-menu-popper"
|
||||
/>
|
||||
</el-sub-menu>
|
||||
</el-menu>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import SidebarItem from '../Sidebar/SidebarItem'
|
||||
import {useSettingsStore} from '@/store/modules/settings'
|
||||
import {usePermissionStore} from '@/store/modules/permission'
|
||||
import SidebarItem from '../Sidebar/SidebarItem';
|
||||
import { useSettingsStore } from '@/store/modules/settings';
|
||||
import { usePermissionStore } from '@/store/modules/permission';
|
||||
|
||||
const route = useRoute()
|
||||
const settingsStore = useSettingsStore()
|
||||
const permissionStore = usePermissionStore()
|
||||
const route = useRoute();
|
||||
const settingsStore = useSettingsStore();
|
||||
const permissionStore = usePermissionStore();
|
||||
|
||||
const theme = computed(() => settingsStore.theme)
|
||||
const theme = computed(() => settingsStore.theme);
|
||||
const activeMenu = computed(() => {
|
||||
const { meta, path } = route
|
||||
const { meta, path } = route;
|
||||
if (meta.activeMenu) {
|
||||
return meta.activeMenu
|
||||
return meta.activeMenu;
|
||||
}
|
||||
return path
|
||||
})
|
||||
return path;
|
||||
});
|
||||
|
||||
const visibleNumber = ref(5)
|
||||
const visibleNumber = ref(5);
|
||||
const topMenus = computed(() => {
|
||||
return permissionStore.sidebarRouters.filter((f) => !f.hidden).slice(0, visibleNumber.value)
|
||||
})
|
||||
return permissionStore.sidebarRouters.filter(f => !f.hidden).slice(0, visibleNumber.value);
|
||||
});
|
||||
const moreRoutes = computed(() => {
|
||||
return permissionStore.sidebarRouters.filter((f) => !f.hidden).slice(visibleNumber.value)
|
||||
})
|
||||
return permissionStore.sidebarRouters.filter(f => !f.hidden).slice(visibleNumber.value);
|
||||
});
|
||||
function setVisibleNumber() {
|
||||
let width = document.body.getBoundingClientRect().width
|
||||
let width = document.body.getBoundingClientRect().width;
|
||||
if (width >= 1000) {
|
||||
width -= 420
|
||||
width -= 420;
|
||||
}
|
||||
visibleNumber.value = Math.max(1, Math.floor(width / 3 / 92) + 2)
|
||||
visibleNumber.value = Math.max(1, Math.floor(width / 3 / 92) + 2);
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
window.addEventListener('resize', setVisibleNumber)
|
||||
})
|
||||
window.addEventListener('resize', setVisibleNumber);
|
||||
});
|
||||
onBeforeUnmount(() => {
|
||||
window.removeEventListener('resize', setVisibleNumber)
|
||||
})
|
||||
window.removeEventListener('resize', setVisibleNumber);
|
||||
});
|
||||
|
||||
onMounted(() => {
|
||||
setVisibleNumber()
|
||||
})
|
||||
setVisibleNumber();
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
|
||||
@@ -26,7 +26,9 @@
|
||||
</el-input>
|
||||
|
||||
<div v-if="state.menuQuery && state.options.length > 0" class="result-count">
|
||||
找到 <strong>{{ state.options.length }}</strong> 个结果
|
||||
找到
|
||||
<strong>{{ state.options.length }}</strong>
|
||||
个结果
|
||||
</div>
|
||||
|
||||
<el-scrollbar wrap-class="layout-search-scrollbar">
|
||||
@@ -57,7 +59,9 @@
|
||||
<div v-else-if="state.menuQuery" class="empty-state">
|
||||
<el-icon class="empty-icon"><Search /></el-icon>
|
||||
<p class="empty-text">
|
||||
未找到 "<strong>{{ state.menuQuery }}</strong>" 相关菜单
|
||||
未找到 "
|
||||
<strong>{{ state.menuQuery }}</strong>
|
||||
" 相关菜单
|
||||
</p>
|
||||
<p class="empty-tip">试试其他关键词或路径</p>
|
||||
</div>
|
||||
@@ -65,9 +69,19 @@
|
||||
</el-scrollbar>
|
||||
|
||||
<div class="search-footer">
|
||||
<span class="shortcut-item"><kbd>↑</kbd><kbd>↓</kbd> 切换</span>
|
||||
<span class="shortcut-item"><kbd>↵</kbd> 选择</span>
|
||||
<span class="shortcut-item"><kbd>Esc</kbd> 关闭</span>
|
||||
<span class="shortcut-item">
|
||||
<kbd>↑</kbd>
|
||||
<kbd>↓</kbd>
|
||||
切换
|
||||
</span>
|
||||
<span class="shortcut-item">
|
||||
<kbd>↵</kbd>
|
||||
选择
|
||||
</span>
|
||||
<span class="shortcut-item">
|
||||
<kbd>Esc</kbd>
|
||||
关闭
|
||||
</span>
|
||||
</div>
|
||||
</el-dialog>
|
||||
</div>
|
||||
@@ -143,7 +157,7 @@ const handleClose = () => {
|
||||
|
||||
const generateRoutes = (routeList: RouteRecordRaw[], basePath = '', prefixTitle: string[] = []): SearchMenuItem[] => {
|
||||
let result: SearchMenuItem[] = [];
|
||||
routeList.forEach((route) => {
|
||||
routeList.forEach(route => {
|
||||
if (route.hidden) {
|
||||
return;
|
||||
}
|
||||
@@ -183,7 +197,7 @@ const querySearch = (query: string) => {
|
||||
}
|
||||
|
||||
const keyword = query.toLowerCase();
|
||||
state.options = state.menuList.filter((item) => {
|
||||
state.options = state.menuList.filter(item => {
|
||||
return item.fullTitle.toLowerCase().includes(keyword) || item.path.toLowerCase().includes(keyword);
|
||||
});
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user