Skip to content

Commit

Permalink
chore: 将默认组件加入排序
Browse files Browse the repository at this point in the history
  • Loading branch information
likui628 committed Aug 5, 2024
1 parent 0f8c4ab commit 607407b
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 25 deletions.
1 change: 0 additions & 1 deletion apps/web-antd/src/layouts/basic.vue
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,6 @@ function handleMakeAll() {

<template>
<BasicLayout @clear-preferences-and-logout="handleLogout">
<!-- <template #header-1>插槽1</template>-->
<template #user-dropdown>
<UserDropdown
:avatar
Expand Down
59 changes: 46 additions & 13 deletions packages/effects/layouts/src/basic/header/header.vue
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,38 @@ const accessStore = useAccessStore();
const { globalSearchShortcutKey } = usePreferences();
const slots = useSlots();
const headerSlots = computed(() => {
const list = [{ index: 20, name: 'user-dropdown' }];
const list = [{ index: 30, name: 'user-dropdown' }];
if (preferences.widget.globalSearch) {
list.push({
index: 5,
name: 'global-search',
});
}
if (preferences.widget.themeToggle) {
list.push({
index: 10,
name: 'theme-toggle',
});
}
if (preferences.widget.languageToggle) {
list.push({
index: 15,
name: 'language-toggle',
});
}
if (preferences.widget.fullscreen) {
list.push({
index: 20,
name: 'fullscreen',
});
}
if (preferences.widget.notification) {
list.push({
index: 25,
name: 'notification',
});
}
Object.keys(slots).forEach((key) => {
const name = key.split('-');
if (key.startsWith('header-')) {
Expand All @@ -51,17 +76,25 @@ const headerSlots = computed(() => {
<slot name="menu"></slot>
</div>
<div class="flex h-full min-w-0 flex-shrink-0 items-center">
<GlobalSearch
v-if="preferences.widget.globalSearch"
:enable-shortcut-key="globalSearchShortcutKey"
:menus="accessStore.accessMenus"
class="mr-4"
/>
<ThemeToggle v-if="preferences.widget.themeToggle" class="mr-2" />
<LanguageToggle v-if="preferences.widget.languageToggle" class="mr-2" />
<VbenFullScreen v-if="preferences.widget.fullscreen" class="mr-2" />
<!-- <slot v-if="preferences.widget.notification" name="notification"></slot>-->
<!-- <slot name="user-dropdown"></slot>-->
<slot v-for="slot in headerSlots" :name="slot.name"></slot>
<template v-for="slot in headerSlots" :key="slot.name">
<slot :name="slot.name">
<template v-if="slot.name === 'global-search'">
<GlobalSearch
:enable-shortcut-key="globalSearchShortcutKey"
:menus="accessStore.accessMenus"
class="mr-4"
/>
</template>
<template v-else-if="slot.name === 'theme-toggle'">
<ThemeToggle class="mr-2" />
</template>
<template v-else-if="slot.name === 'language-toggle'">
<LanguageToggle class="mr-2" />
</template>
<template v-else-if="slot.name === 'fullscreen'">
<VbenFullScreen class="mr-2" />
</template>
</slot>
</template>
</div>
</template>
14 changes: 3 additions & 11 deletions packages/effects/layouts/src/basic/layout.vue
Original file line number Diff line number Diff line change
Expand Up @@ -135,27 +135,19 @@ watch(
() => preferences.app.watermark,
async (val) => {
if (val) {
// await nextTick();
updateWatermark({
await updateWatermark({
content: `${preferences.app.name} 用户名: ${userStore.userInfo?.username}`,
// parent: contentRef.value,
});
}
},
{
immediate: true,
},
);
const slots = useSlots();
const headerSlots = computed(() => {
const array: string[] = [];
Object.keys(slots).forEach((key: string) => {
if (key.startsWith('header-')) {
array.push(key);
}
});
return array;
return Object.keys(slots).filter((key) => key.startsWith('header-'));
});
</script>

Expand Down

0 comments on commit 607407b

Please sign in to comment.