fix: fix some known problems

This commit is contained in:
vben 2024-06-30 22:58:57 +08:00
parent 692225cfff
commit 8252d116f1
6 changed files with 35 additions and 25 deletions

View File

@ -72,7 +72,6 @@ class PreferenceManager {
private handleUpdates(updates: DeepPartial<Preferences>) { private handleUpdates(updates: DeepPartial<Preferences>) {
const themeUpdates = updates.theme || {}; const themeUpdates = updates.theme || {};
const appUpdates = updates.app || {}; const appUpdates = updates.app || {};
if (themeUpdates && Object.keys(themeUpdates).length > 0) { if (themeUpdates && Object.keys(themeUpdates).length > 0) {
this.updateTheme(this.state); this.updateTheme(this.state);
} }
@ -162,15 +161,14 @@ class PreferenceManager {
private updateColorMode(preference: Preferences) { private updateColorMode(preference: Preferences) {
if (preference.app) { if (preference.app) {
const { colorGrayMode, colorWeakMode } = preference.app; const { colorGrayMode, colorWeakMode } = preference.app;
const body = document.body;
const COLOR_WEAK = 'invert-mode'; const COLOR_WEAK = 'invert-mode';
const COLOR_GRAY = 'grayscale-mode'; const COLOR_GRAY = 'grayscale-mode';
colorWeakMode colorWeakMode
? body.classList.add(COLOR_WEAK) ? document.documentElement.classList.add(COLOR_WEAK)
: body.classList.remove(COLOR_WEAK); : document.documentElement.classList.remove(COLOR_WEAK);
colorGrayMode colorGrayMode
? body.classList.add(COLOR_GRAY) ? document.documentElement.classList.add(COLOR_GRAY)
: body.classList.remove(COLOR_GRAY); : document.documentElement.classList.remove(COLOR_GRAY);
} }
} }
@ -341,13 +339,14 @@ class PreferenceManager {
[STORAGE_KEY, STORAGE_KEY_THEME, STORAGE_KEY_LOCALE].forEach((key) => { [STORAGE_KEY, STORAGE_KEY_THEME, STORAGE_KEY_LOCALE].forEach((key) => {
this.cache?.removeItem(key); this.cache?.removeItem(key);
}); });
this.updatePreferences(this.state);
} }
/** /**
* *
* @param updates - * @param updates -
*/ */
public updatePreferences(updates: DeepPartial<Preferences>) { public async updatePreferences(updates: DeepPartial<Preferences>) {
const mergedState = merge({}, updates, markRaw(this.state)); const mergedState = merge({}, updates, markRaw(this.state));
Object.assign(this.state, mergedState); Object.assign(this.state, mergedState);

View File

@ -21,11 +21,11 @@ html {
border-width: 0; border-width: 0;
} }
body.invert-mode { html.invert-mode {
@apply invert; @apply invert;
} }
body.grayscale-mode { html.grayscale-mode {
@apply grayscale; @apply grayscale;
} }

View File

@ -92,7 +92,7 @@ const props = withDefaults(defineProps<Props>(), {
domVisible: true, domVisible: true,
extraWidth: 180, extraWidth: 180,
fixedExtra: false, fixedExtra: false,
isSideMixed: false, isSidebarMixed: false,
mixedWidth: 80, mixedWidth: 80,
paddingTop: 60, paddingTop: 60,
show: true, show: true,
@ -118,13 +118,13 @@ const hiddenSideStyle = computed((): CSSProperties => {
}); });
const style = computed((): CSSProperties => { const style = computed((): CSSProperties => {
const { isSideMixed, paddingTop, zIndex } = props; const { isSidebarMixed, paddingTop, zIndex } = props;
return { return {
...calcMenuWidthStyle(false), ...calcMenuWidthStyle(false),
paddingTop: `${paddingTop}px`, paddingTop: `${paddingTop}px`,
zIndex, zIndex,
...(isSideMixed && extraVisible.value ? { transition: 'none' } : {}), ...(isSidebarMixed && extraVisible.value ? { transition: 'none' } : {}),
}; };
}); });
@ -147,8 +147,8 @@ const extraTitleStyle = computed((): CSSProperties => {
}); });
const contentWidthStyle = computed((): CSSProperties => { const contentWidthStyle = computed((): CSSProperties => {
const { collapseWidth, fixedExtra, isSideMixed, mixedWidth } = props; const { collapseWidth, fixedExtra, isSidebarMixed, mixedWidth } = props;
if (isSideMixed && fixedExtra) { if (isSidebarMixed && fixedExtra) {
return { width: `${collapse.value ? collapseWidth : mixedWidth}px` }; return { width: `${collapse.value ? collapseWidth : mixedWidth}px` };
} }
return {}; return {};
@ -165,10 +165,10 @@ const contentStyle = computed((): CSSProperties => {
}); });
const headerStyle = computed((): CSSProperties => { const headerStyle = computed((): CSSProperties => {
const { headerHeight, isSideMixed } = props; const { headerHeight, isSidebarMixed } = props;
return { return {
...(isSideMixed ? { display: 'flex', justifyContent: 'center' } : {}), ...(isSidebarMixed ? { display: 'flex', justifyContent: 'center' } : {}),
height: `${headerHeight}px`, height: `${headerHeight}px`,
...contentWidthStyle.value, ...contentWidthStyle.value,
}; };
@ -195,10 +195,16 @@ watchEffect(() => {
}); });
function calcMenuWidthStyle(isHiddenDom: boolean): CSSProperties { function calcMenuWidthStyle(isHiddenDom: boolean): CSSProperties {
const { backgroundColor, extraWidth, fixedExtra, isSideMixed, show, width } = const {
props; backgroundColor,
extraWidth,
fixedExtra,
isSidebarMixed,
show,
width,
} = props;
let widthValue = `${width + (isSideMixed && fixedExtra && extraVisible.value ? extraWidth : 0)}px`; let widthValue = `${width + (isSidebarMixed && fixedExtra && extraVisible.value ? extraWidth : 0)}px`;
const { collapseWidth } = props; const { collapseWidth } = props;

View File

@ -27,10 +27,8 @@ const props = withDefaults(defineProps<Props>(), {
contentPaddingRight: 0, contentPaddingRight: 0,
contentPaddingTop: 0, contentPaddingTop: 0,
footerEnable: false, footerEnable: false,
// footerBackgroundColor: '#fff',
footerFixed: true, footerFixed: true,
footerHeight: 32, footerHeight: 32,
// headerBackgroundColor: 'hsl(var(--background))',
headerHeight: 50, headerHeight: 50,
headerHeightOffset: 10, headerHeightOffset: 10,
headerHidden: false, headerHidden: false,
@ -39,7 +37,6 @@ const props = withDefaults(defineProps<Props>(), {
headerVisible: true, headerVisible: true,
isMobile: false, isMobile: false,
layout: 'sidebar-nav', layout: 'sidebar-nav',
// sideCollapse: false,
sideCollapseWidth: 60, sideCollapseWidth: 60,
sidebarCollapseShowTitle: false, sidebarCollapseShowTitle: false,
sidebarHidden: false, sidebarHidden: false,
@ -48,7 +45,6 @@ const props = withDefaults(defineProps<Props>(), {
sidebarTheme: 'dark', sidebarTheme: 'dark',
sidebarWidth: 180, sidebarWidth: 180,
tabbarEnable: true, tabbarEnable: true,
// tabsBackgroundColor: 'hsl(var(--background))',
tabsHeight: 36, tabsHeight: 36,
zIndex: 200, zIndex: 200,
}); });
@ -134,6 +130,7 @@ const headerWrapperHeight = computed(() => {
const getSideCollapseWidth = computed(() => { const getSideCollapseWidth = computed(() => {
const { sideCollapseWidth, sidebarCollapseShowTitle, sidebarMixedWidth } = const { sideCollapseWidth, sidebarCollapseShowTitle, sidebarMixedWidth } =
props; props;
return sidebarCollapseShowTitle || isSidebarMixedNav.value return sidebarCollapseShowTitle || isSidebarMixedNav.value
? sidebarMixedWidth ? sidebarMixedWidth
: sideCollapseWidth; : sideCollapseWidth;
@ -187,6 +184,7 @@ const getSidebarWidth = computed(() => {
*/ */
const getExtraWidth = computed(() => { const getExtraWidth = computed(() => {
const { sidebarWidth } = props; const { sidebarWidth } = props;
return sidebarExtraCollapse.value ? getSideCollapseWidth.value : sidebarWidth; return sidebarExtraCollapse.value ? getSideCollapseWidth.value : sidebarWidth;
}); });

View File

@ -52,7 +52,7 @@ function handleMouseenter(menu: MenuRecordRaw) {
@mouseenter="handleMouseenter(menu)" @mouseenter="handleMouseenter(menu)"
> >
<VbenIcon :class="e('icon')" :icon="menu.icon" fallback /> <VbenIcon :class="e('icon')" :icon="menu.icon" fallback />
<span :class="e('name')"> {{ menu.name }}</span> <span :class="e('name')" class="truncate"> {{ menu.name }}</span>
</li> </li>
</template> </template>
</ul> </ul>

View File

@ -41,8 +41,15 @@ const theme = computed(() => {
}); });
const logoClass = computed(() => { const logoClass = computed(() => {
let cls = '';
const { collapsed, collapsedShowTitle } = preferences.sidebar; const { collapsed, collapsedShowTitle } = preferences.sidebar;
return collapsedShowTitle && collapsed && !isMixedNav.value ? 'mx-auto' : ''; if (collapsedShowTitle && collapsed && !isMixedNav.value) {
cls += ' mx-auto';
}
if (isSideMixedNav.value) {
cls += ' flex-center';
}
return cls;
}); });
const isMenuRounded = computed(() => { const isMenuRounded = computed(() => {