feat(branding): default the site icons to assets/img/favicon.png
- Point the 浏览器图标 / 移动端图标 schema defaults (PHP + VUE) at assets/img/favicon.png instead of an empty media field. - Fall back to the same PNG in Settings::favicon_url() when no custom favicon and no native site_icon are configured. - Add Settings::mobile_icon_url() and emit apple-touch-icon from SEOHead; the 移动端图标 field previously had no consumer and never reached the page. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
b56b9bbe37
commit
3ce5bfc20c
5 files changed
+27
-8
No files matched your search
@@ -1,3 +1,8 @@
|
||||
const themeRoot = typeof window !== 'undefined' && window.jioAdminData?.themeUri
|
||||
? String(window.jioAdminData.themeUri).replace(/\/$/, '')
|
||||
: ''
|
||||
const defaultFavicon = themeRoot ? `${themeRoot}/assets/img/favicon.png` : ''
|
||||
|
||||
export const logoSchema = {
|
||||
key: 'global.logo',
|
||||
title: 'LOGO & 品牌',
|
||||
@@ -6,8 +11,8 @@ export const logoSchema = {
|
||||
defaults: {
|
||||
site_logo: '',
|
||||
site_logo_dark: '',
|
||||
site_favicon: '',
|
||||
site_icon: '',
|
||||
site_favicon: defaultFavicon,
|
||||
site_icon: defaultFavicon,
|
||||
logo_width: 150,
|
||||
logo_text: '',
|
||||
},
|
||||
@@ -28,8 +33,8 @@ export const logoSchema = {
|
||||
title: '站点图标',
|
||||
icon: 'fa fas fa-id-badge',
|
||||
fields: [
|
||||
{ key: 'site_favicon', label: '浏览器图标 (Favicon)', type: 'media', help: '建议 32x32 或 16x16 的 ICO/PNG 文件' },
|
||||
{ key: 'site_icon', label: '移动端图标', type: 'media', help: '建议 192x192 的 PNG,用于移动端添加到桌面' },
|
||||
{ key: 'site_favicon', label: '浏览器图标 (Favicon)', type: 'media', default: defaultFavicon, help: '建议 32x32 或 16x16 的 ICO/PNG 文件' },
|
||||
{ key: 'site_icon', label: '移动端图标', type: 'media', default: defaultFavicon, help: '建议 192x192 的 PNG,用于移动端添加到桌面' },
|
||||
],
|
||||
},
|
||||
],
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 1.5 KiB |
@@ -162,8 +162,8 @@ class GlobalSchema {
|
||||
['key' => 'logo_text', 'label' => 'Logo 文字', 'type' => 'input', 'default' => ''],
|
||||
]],
|
||||
['key' => 'favicon', 'title' => '站点图标', 'fields' => [
|
||||
['key' => 'site_favicon', 'label' => '浏览器图标', 'type' => 'media', 'default' => ''],
|
||||
['key' => 'site_icon', 'label' => '移动端图标', 'type' => 'media', 'default' => ''],
|
||||
['key' => 'site_favicon', 'label' => '浏览器图标', 'type' => 'media', 'default' => get_template_directory_uri() . '/assets/img/favicon.png'],
|
||||
['key' => 'site_icon', 'label' => '移动端图标', 'type' => 'media', 'default' => get_template_directory_uri() . '/assets/img/favicon.png'],
|
||||
]],
|
||||
],
|
||||
],
|
||||
|
||||
@@ -236,11 +236,17 @@ class SEOHead {
|
||||
|
||||
echo "\n<!-- Jio SEO -->\n";
|
||||
|
||||
// Favicon(无站点图标时回退)。
|
||||
// Favicon(无站点图标时回退);移动端图标走 apple-touch-icon。
|
||||
if (function_exists('jio_get_favicon_url')) {
|
||||
$favicon = (string) jio_get_favicon_url();
|
||||
if ($favicon !== '' && !has_site_icon()) {
|
||||
printf('<link rel="icon" href="%s">' . "\n", esc_url($favicon));
|
||||
if (class_exists('\Jio\Settings\Settings')) {
|
||||
$mobile_icon = \Jio\Settings\Settings::mobile_icon_url();
|
||||
if ($mobile_icon !== '') {
|
||||
printf('<link rel="apple-touch-icon" href="%s">' . "\n", esc_url($mobile_icon));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -222,7 +222,15 @@ trait FacadeBulk {
|
||||
}
|
||||
|
||||
$site_icon = get_site_icon_url(512);
|
||||
return $site_icon ? (string) $site_icon : self::default_asset_url('default-favicon.svg');
|
||||
return $site_icon ? (string) $site_icon : get_template_directory_uri() . '/assets/img/favicon.png';
|
||||
}
|
||||
|
||||
|
||||
|
||||
/** 移动端添加到桌面的图标 URL(留空时跟随浏览器图标) */
|
||||
public static function mobile_icon_url(): string {
|
||||
$custom = trim((string) self::get_value('site_icon', ''));
|
||||
return $custom !== '' ? $custom : self::favicon_url();
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user