feat(Logo): Add Logo component
This commit is contained in:
parent
41281c4d54
commit
958edefe7b
|
@ -0,0 +1,3 @@
|
||||||
|
import Backtop from './src/Backtop.vue'
|
||||||
|
|
||||||
|
export { Backtop }
|
|
@ -0,0 +1,7 @@
|
||||||
|
<script setup lang="ts">
|
||||||
|
import { ElBacktop } from 'element-plus'
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<ElBacktop target=".v-content .el-scrollbar__wrap" />
|
||||||
|
</template>
|
|
@ -0,0 +1,3 @@
|
||||||
|
import Logo from './src/Logo.vue'
|
||||||
|
|
||||||
|
export { Logo }
|
|
@ -0,0 +1,52 @@
|
||||||
|
<script setup lang="ts">
|
||||||
|
import { ref, watch, computed } from 'vue'
|
||||||
|
import { useAppStore } from '@/store/modules/app'
|
||||||
|
|
||||||
|
const appStore = useAppStore()
|
||||||
|
|
||||||
|
const show = ref(true)
|
||||||
|
|
||||||
|
const title = computed(() => appStore.getLogoTitle)
|
||||||
|
|
||||||
|
const layout = computed(() => appStore.getLayout)
|
||||||
|
|
||||||
|
const collapse = computed(() => appStore.getCollapse)
|
||||||
|
|
||||||
|
watch(
|
||||||
|
() => collapse.value,
|
||||||
|
(collapse: boolean) => {
|
||||||
|
if (layout.value !== 'classic') {
|
||||||
|
show.value = true
|
||||||
|
} else {
|
||||||
|
if (!collapse) {
|
||||||
|
setTimeout(() => {
|
||||||
|
show.value = !collapse
|
||||||
|
}, 400)
|
||||||
|
} else {
|
||||||
|
show.value = !collapse
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<router-link
|
||||||
|
:class="[
|
||||||
|
'v-logo',
|
||||||
|
{
|
||||||
|
'v-logo__Top': layout !== 'classic'
|
||||||
|
},
|
||||||
|
'flex h-[var(--logo-height)] items-center cursor-pointer pl-8px'
|
||||||
|
]"
|
||||||
|
to="/"
|
||||||
|
>
|
||||||
|
<img
|
||||||
|
src="@/assets/imgs/logo.png"
|
||||||
|
class="w-[calc(var(--logo-height)-10px)] h-[calc(var(--logo-height)-10px)]"
|
||||||
|
/>
|
||||||
|
<div v-if="show" class="text-[var(--logo-title-text-color)] ml-10px text-16px font-700">{{
|
||||||
|
title
|
||||||
|
}}</div>
|
||||||
|
</router-link>
|
||||||
|
</template>
|
|
@ -7,6 +7,7 @@ import type { LayoutType } from '@/config/app'
|
||||||
import { useRenderMenuItem } from './components/useRenderMenuItem'
|
import { useRenderMenuItem } from './components/useRenderMenuItem'
|
||||||
import { useRouter } from 'vue-router'
|
import { useRouter } from 'vue-router'
|
||||||
import { isUrl } from '@/utils/is'
|
import { isUrl } from '@/utils/is'
|
||||||
|
import { Logo } from '@/components/Logo'
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
name: 'Menu',
|
name: 'Menu',
|
||||||
|
@ -53,14 +54,15 @@ export default defineComponent({
|
||||||
<div
|
<div
|
||||||
class={[
|
class={[
|
||||||
'v-menu',
|
'v-menu',
|
||||||
'h-[100%] overflow-hidden z-100',
|
'h-[100%] overflow-hidden z-100 flex-col',
|
||||||
appStore.getCollapse
|
appStore.getCollapse
|
||||||
? 'w-[var(--left-menu-min-width)]'
|
? 'w-[var(--left-menu-min-width)]'
|
||||||
: 'w-[var(--left-menu-max-width)]',
|
: 'w-[var(--left-menu-max-width)]',
|
||||||
'bg-[var(--left-menu-bg-color)]'
|
'bg-[var(--left-menu-bg-color)]'
|
||||||
]}
|
]}
|
||||||
>
|
>
|
||||||
<ElScrollbar>
|
<Logo></Logo>
|
||||||
|
<ElScrollbar class={[{ '!h-[calc(100%-var(--top-tool-height))]': true }]}>
|
||||||
<ElMenu
|
<ElMenu
|
||||||
defaultActive={unref(activeMenu)}
|
defaultActive={unref(activeMenu)}
|
||||||
mode={unref(menuMode)}
|
mode={unref(menuMode)}
|
||||||
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
import Setting from './src/Setting.vue'
|
||||||
|
|
||||||
|
export { Setting }
|
|
@ -0,0 +1,25 @@
|
||||||
|
<script setup lang="ts">
|
||||||
|
import { ElDrawer } from 'element-plus'
|
||||||
|
import { ref } from 'vue'
|
||||||
|
|
||||||
|
const drawer = ref(false)
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<div
|
||||||
|
class="v-setting fixed top-[45%] right-0 w-40px h-40px text-center leading-40px bg-[var(--el-color-primary)] cursor-pointer"
|
||||||
|
@click="drawer = true"
|
||||||
|
>
|
||||||
|
<Icon icon="ant-design:setting-outlined" color="#fff" />
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<ElDrawer v-model="drawer" :with-header="false" direction="rtl" size="300px">ddd</ElDrawer>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<style lang="less" scoped>
|
||||||
|
@prefix-cls: ~'@{namespace}-setting';
|
||||||
|
|
||||||
|
.@{prefix-cls} {
|
||||||
|
border-radius: 6px 0 0 6px;
|
||||||
|
}
|
||||||
|
</style>
|
|
@ -199,7 +199,7 @@ watch(
|
||||||
}
|
}
|
||||||
]"
|
]"
|
||||||
>
|
>
|
||||||
<router-link :to="{ ...item }" custom #default="{ navigate }">
|
<router-link :to="{ ...item }" custom v-slot="{ navigate }">
|
||||||
<div @click="navigate" class="h-full flex justify-center items-center">
|
<div @click="navigate" class="h-full flex justify-center items-center">
|
||||||
{{ t(item?.meta?.title as string) }}
|
{{ t(item?.meta?.title as string) }}
|
||||||
<Icon
|
<Icon
|
||||||
|
@ -277,7 +277,7 @@ watch(
|
||||||
<span
|
<span
|
||||||
class="v-tags-view__tool w-[40px] h-[40px] text-center leading-[40px] cursor-pointer block"
|
class="v-tags-view__tool w-[40px] h-[40px] text-center leading-[40px] cursor-pointer block"
|
||||||
>
|
>
|
||||||
<Icon icon="ant-design:down-outlined" color="#333" />
|
<Icon icon="ant-design:setting-outlined" color="#333" />
|
||||||
</span>
|
</span>
|
||||||
</ContextMenu>
|
</ContextMenu>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -39,7 +39,7 @@ export const appModules: AppState = {
|
||||||
showScreenfull: true, // 是否全屏按钮
|
showScreenfull: true, // 是否全屏按钮
|
||||||
showUserInfo: true, // 是否显示用户头像
|
showUserInfo: true, // 是否显示用户头像
|
||||||
title: 'butterfly-admin', // 标题
|
title: 'butterfly-admin', // 标题
|
||||||
logoTitle: 'butterfly-admin', // logo标题
|
logoTitle: 'ButterflyAdmin', // logo标题
|
||||||
userInfo: 'userInfo', // 登录信息存储字段-建议每个项目换一个字段,避免与其他项目冲突
|
userInfo: 'userInfo', // 登录信息存储字段-建议每个项目换一个字段,避免与其他项目冲突
|
||||||
greyMode: false, // 是否开始灰色模式,用于特殊悼念日
|
greyMode: false, // 是否开始灰色模式,用于特殊悼念日
|
||||||
showBackTop: true, // 是否显示回到顶部
|
showBackTop: true, // 是否显示回到顶部
|
||||||
|
|
|
@ -9,6 +9,8 @@ import { UserInfo } from '@/components/UserInfo'
|
||||||
import { Screenfull } from '@/components/Screenfull'
|
import { Screenfull } from '@/components/Screenfull'
|
||||||
import { Breadcrumb } from '@/components/Breadcrumb'
|
import { Breadcrumb } from '@/components/Breadcrumb'
|
||||||
import { TagsView } from '@/components/TagsView'
|
import { TagsView } from '@/components/TagsView'
|
||||||
|
import { Backtop } from '@/components/Backtop'
|
||||||
|
import { Setting } from '@/components/Setting'
|
||||||
import AppView from './components/AppView.vue'
|
import AppView from './components/AppView.vue'
|
||||||
|
|
||||||
const appStore = useAppStore()
|
const appStore = useAppStore()
|
||||||
|
@ -70,6 +72,10 @@ export default defineComponent({
|
||||||
</div>
|
</div>
|
||||||
<AppView></AppView>
|
<AppView></AppView>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<Backtop></Backtop>
|
||||||
|
|
||||||
|
<Setting></Setting>
|
||||||
</section>
|
</section>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,11 +10,22 @@ const getCaches = computed((): string[] => {
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<router-view>
|
<el-scrollbar
|
||||||
<template #default="{ Component, route }">
|
:class="[
|
||||||
<keep-alive :include="getCaches">
|
'v-content',
|
||||||
<component :is="Component" :key="route.fullPath" />
|
{
|
||||||
</keep-alive>
|
'!h-[calc(100%-var(--top-tool-height)-var(--tags-view-height))]': true
|
||||||
</template>
|
}
|
||||||
</router-view>
|
]"
|
||||||
|
>
|
||||||
|
<section class="p-[var(--app-content-padding)]">
|
||||||
|
<router-view>
|
||||||
|
<template #default="{ Component, route }">
|
||||||
|
<keep-alive :include="getCaches">
|
||||||
|
<component :is="Component" :key="route.fullPath" />
|
||||||
|
</keep-alive>
|
||||||
|
</template>
|
||||||
|
</router-view>
|
||||||
|
</section>
|
||||||
|
</el-scrollbar>
|
||||||
</template>
|
</template>
|
||||||
|
|
|
@ -19,6 +19,13 @@
|
||||||
--left-menu-collapse-bg-active-color: var(--el-color-primary);
|
--left-menu-collapse-bg-active-color: var(--el-color-primary);
|
||||||
/* left menu end */
|
/* left menu end */
|
||||||
|
|
||||||
|
/* logo start */
|
||||||
|
--logo-height: 50px;
|
||||||
|
|
||||||
|
--logo-title-text-color: #fff;
|
||||||
|
/* logo end */
|
||||||
|
|
||||||
|
/* header start */
|
||||||
--top-tool-height: 40px;
|
--top-tool-height: 40px;
|
||||||
|
|
||||||
--top-tool-p-x: 0;
|
--top-tool-p-x: 0;
|
||||||
|
@ -26,6 +33,9 @@
|
||||||
--top-tool-border-color: #eee;
|
--top-tool-border-color: #eee;
|
||||||
|
|
||||||
--tags-view-height: 40px;
|
--tags-view-height: 40px;
|
||||||
|
/* header start */
|
||||||
|
|
||||||
|
--app-content-padding: 20px;
|
||||||
|
|
||||||
--transition-time-02: 0.2s;
|
--transition-time-02: 0.2s;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue