Merge pull request #1932 from nextcloud/fix/favicon

fix(title-bar): use actual favicon as server logo in the menu
This commit is contained in:
Grigorii K. Shartsev authored and GitHub committed 2026-09-24 17:38:11 +02:00
commit 7d30c6dbf6
6 files changed
+76 -51

No files matched your search

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

@@ -77,11 +77,12 @@ export async function extractNextcloudStyles({
// --- COPYING STATIC FILES -------------------------------------------------------------------------------------------
echo(chalk.cyan('· Copying static styles ...'))
echo(chalk.cyan('· Copying static styles and base assets ...'))
await Promise.all([
dockerCp(CONTAINER, '/var/www/html/', 'dist/icons.css'),
dockerCp(CONTAINER, '/var/www/html/', 'core/css/server.css'),
dockerCp(CONTAINER, '/var/www/html/', 'core/img/favicon.ico'),
dockerCp(CONTAINER, '/var/www/html/', 'core/img/filetypes/'),
dockerCp(CONTAINER, '/var/www/html/', 'core/img/logo/'),
dockerCp(CONTAINER, '/var/www/html/', 'apps/theming/css/default.css'),
+72
View File
@@ -0,0 +1,72 @@
<!--
- SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors
- SPDX-License-Identifier: AGPL-3.0-or-later
-->
<script setup lang="ts">
import { computed, ref, watch } from 'vue'
import { appData } from '../../app/AppData.js'
const {
serverUrl = appData.serverUrl,
themingCapabilities = appData.capabilities?.theming,
size = 20 as number | string,
} = defineProps<{
/**
* Nextcloud server URL to get the favicon from.
* If not defined, fallback to the latest server favicon.
*/
serverUrl?: string
/**
* Theming capabilities. Used for:
* - Determining whether the theming app is enabled
* - Getting the cache buster
*
* Note that capabilities also have "favicon" property.
* However, since the beginning it has never had the actual favicon URL.
* Same as the "logoheader" property, it has the same value as the "logo" property.
*/
themingCapabilities?: {
cacheBuster?: string
}
/**
* Favicon size
*/
size?: number | string
}>()
const defaultBuiltInFavicon = new URL('@global-styles/core/img/favicon.ico', import.meta.url).href
const failedLoading = ref(false)
watch(() => serverUrl, () => failedLoading.value = false)
const faviconUrl = computed(() => {
if (!serverUrl || failedLoading.value) {
return defaultBuiltInFavicon
}
return themingCapabilities
// Custom theming favicon
? `${serverUrl}/index.php/apps/theming/favicon?v=${themingCapabilities.cacheBuster || Date.now()}`
// Default server favicon in case theming is disabled
: `${serverUrl}/core/img/favicon.ico`
})
const cssSize = computed(() => typeof size === 'number' ? `${size}px` : size)
</script>
<template>
<img
class="theme-logo"
:src="faviconUrl"
alt=""
@error="failedLoading = true">
</template>
<style scoped>
.theme-logo {
width: v-bind(cssSize);
height: v-bind(cssSize);
object-fit: contain;
}
</style>
@@ -1,48 +0,0 @@
<!--
- SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors
- SPDX-License-Identifier: AGPL-3.0-or-later
-->
<script setup lang="ts">
import type { CSSProperties } from 'vue'
import { computed } from 'vue'
import { appData } from '../../../../app/AppData.js'
const { size = 20 as number | string } = defineProps<{
size?: number | string
}>()
const theming = appData.capabilities.theming
const logoUrl = theming.logo
const primaryColor = theming.color
const cssVars = computed<CSSProperties>(() => ({
'--ThemeLogo-size': typeof size === 'number' ? `${size}px` : size,
'--ThemeLogo-background-color': primaryColor,
}))
</script>
<template>
<span class="theme-logo" :style="cssVars">
<img class="theme-logo__img" :src="logoUrl" alt="">
</span>
</template>
<style scoped>
.theme-logo {
display: flex;
align-items: stretch;
justify-content: center;
aspect-ratio: 1 / 1;
border-radius: var(--border-radius);
width: var(--ThemeLogo-size);
height: var(--ThemeLogo-size);
background-color: var(--ThemeLogo-background-color);
padding: 10%;
}
.theme-logo__img {
max-width: 100%;
}
</style>
@@ -20,8 +20,8 @@ import IconEmoticonOutline from 'vue-material-design-icons/EmoticonOutline.vue'
import IconLogout from 'vue-material-design-icons/Logout.vue'
import IconPencilOutline from 'vue-material-design-icons/PencilOutline.vue'
import IconPower from 'vue-material-design-icons/Power.vue'
import AccountFavicon from '../../../../shared/components/AccountFavicon.vue'
import UserStatusDialog from '../../UserStatus/UserStatusDialog.vue'
import ThemeLogo from './ThemeLogo.vue'
import UiMenu from './UiMenu.vue'
import UiMenuItem from './UiMenuItem.vue'
import UiMenuSeparator from './UiMenuSeparator.vue'
@@ -145,7 +145,7 @@ function handleUserStatusChange(status: UserStatusStatusType) {
<UiMenuItem tag="a" :href="serverUrl" target="_blank">
<template #icon>
<ThemeLogo :size="24" />
<AccountFavicon :size="20" />
</template>
<span class="user-menu__item-multiline">
<span>