Skip to content
This repository has been archived by the owner on Aug 28, 2024. It is now read-only.

Commit

Permalink
fix: the logo is show in the settings has no effect. close #214 (#216)
Browse files Browse the repository at this point in the history
* fix: the logo is show in the settings has no effect. close #214

* chore: Recordable 泛型参数设定默认值

* feat(AppConfig):  设置为左侧菜单混合模式,设定logo为打开

* refactor(AppConfig): 增加预处理config方法
  • Loading branch information
wangjue666 authored Oct 27, 2023
1 parent ee0bd36 commit eb3b7a2
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 9 deletions.
15 changes: 9 additions & 6 deletions apps/admin/src/layout/components/logo.vue
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
<script lang="ts" setup>
import { computed, unref } from 'vue';
import { useRouter } from 'vue-router'
import { BASIC_HOME_PATH } from '@vben/constants'
import { createNamespace, getGlobalConfig } from '@vben/utils'
import logo from '@/assets/images/logo.png'
import { useRootSetting } from '@vben/hooks'
const { bem } = createNamespace('app-logo')
Expand All @@ -21,19 +23,20 @@ const props = defineProps({
const { push } = useRouter()
const { title } = getGlobalConfig(import.meta.env)
const { getShowLogo } = useRootSetting();
const getIsShowLogo = computed(() => unref(getShowLogo));
function goHome() {
push(props.homePath)
}
</script>

<template>
<div :class="bem()" @click="goHome">
<div v-if="getIsShowLogo" :class="bem()" @click="goHome">
<img :src="logo" alt="logo" />
<div
class="ml-2 truncate md:opacity-100"
:class="bem('title')"
v-show="showTitle"
>
<div class="ml-2 truncate md:opacity-100" :class="bem('title')" v-show="showTitle">
{{ title }}
</div>
</div>
Expand Down
15 changes: 13 additions & 2 deletions packages/hooks/src/config/useAppConfig.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { storeToRefs, useAppConfig as appConfigStore } from '@vben/stores'
import { DefineAppConfigOptions } from '@vben/types'
import { HandlerSettingEnum } from '@vben/constants'
import { HandlerSettingEnum, NavBarModeEnum } from '@vben/constants'
import { _merge } from '@vben/utils'
import { computed, reactive, unref } from 'vue'
import { useClipboard, _omit } from '@vben/utils'
Expand All @@ -13,10 +13,21 @@ export const useAppConfig = () => {

const setAppConfig = (configs: DeepPartial<DefineAppConfigOptions>) => {
useAppConfigStore.$patch((state) => {
_merge(state, configs)
_merge(state, preDealConfig(configs))
})
}

function preDealConfig(configs: DeepPartial<DefineAppConfigOptions>) {
if (
configs.navBarMode &&
configs.navBarMode === NavBarModeEnum.MIX_SIDEBAR
) {
configs.logo = { show: true, visible: true }
}

return configs
}

function toggleOpenSettingDrawer() {
useAppConfigStore.setOpenSettingDrawer(!unref(openSettingDrawer))
}
Expand Down
2 changes: 1 addition & 1 deletion packages/types/src/global.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ declare global {
ReturnType<T>
>
type Nullable<T> = T | null
type Recordable<T> = Record<string, T>
type Recordable<T = any> = Record<string, T>
type TimeoutHandle = ReturnType<typeof setTimeout>
type IntervalHandle = ReturnType<typeof setInterval>
type DeepPartial<T> = {
Expand Down

0 comments on commit eb3b7a2

Please sign in to comment.