fix: replace logo via JS img.src instead of CSS content: url()
content: url() on <img> is unreliable in modern Chrome; setting src directly in JS is the approach that works in whatsapp-api. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
+11
-1
@@ -97,7 +97,6 @@ if (enableSwagger) {
|
|||||||
align-items: center;
|
align-items: center;
|
||||||
}
|
}
|
||||||
.swagger-ui .topbar .topbar-wrapper .link img {
|
.swagger-ui .topbar .topbar-wrapper .link img {
|
||||||
content: url("./custom-logo.png");
|
|
||||||
height: 56px;
|
height: 56px;
|
||||||
width: auto;
|
width: auto;
|
||||||
grid-column: 1;
|
grid-column: 1;
|
||||||
@@ -320,6 +319,8 @@ if (enableSwagger) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var observer = new MutationObserver(function () {
|
var observer = new MutationObserver(function () {
|
||||||
|
var img = document.querySelector('.swagger-ui .topbar-wrapper .link img')
|
||||||
|
if (img && img.src.indexOf('custom-logo') === -1) fixLogo()
|
||||||
if (!document.querySelector('.neuralsys-filter-container') &&
|
if (!document.querySelector('.neuralsys-filter-container') &&
|
||||||
document.querySelector('.opblock-tag-section')) {
|
document.querySelector('.opblock-tag-section')) {
|
||||||
installFilter()
|
installFilter()
|
||||||
@@ -396,7 +397,16 @@ if (enableSwagger) {
|
|||||||
document.body.appendChild(footer)
|
document.body.appendChild(footer)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function fixLogo() {
|
||||||
|
var img = document.querySelector('.swagger-ui .topbar-wrapper .link img')
|
||||||
|
if (!img) { return setTimeout(fixLogo, 100) }
|
||||||
|
if (img.src.indexOf('custom-logo') === -1) {
|
||||||
|
img.src = '/api-docs/custom-logo.png'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function boot() {
|
function boot() {
|
||||||
|
fixLogo()
|
||||||
installFilter()
|
installFilter()
|
||||||
translateCopyButtons()
|
translateCopyButtons()
|
||||||
installFooter()
|
installFooter()
|
||||||
|
|||||||
Reference in New Issue
Block a user