diff --git a/layout/_partials/comments/cusdis.ejs b/layout/_partials/comments/cusdis.ejs index 8e401dc5..7d9c2473 100644 --- a/layout/_partials/comments/cusdis.ejs +++ b/layout/_partials/comments/cusdis.ejs @@ -1,6 +1,7 @@ <% if (theme.cusdis.host && theme.cusdis.app_id) { %> -
+
'); Fluid.utils.createScript('<%= url_join(theme.cusdis.host, 'js/cusdis.es.js') %>'); + + // 取消容器滚动条,尝试让 iframe 展开显示 + var container = document.querySelector('.cusdis'); + var thread = document.querySelector('#cusdis_thread'); + if (container) container.style.overflow = 'visible'; + if (thread) thread.style.overflow = 'visible'; + + // 等待 widget 加载后调整 iframe 样式 + setTimeout(function() { + try { + var iframe = thread && thread.querySelector('iframe'); + if (iframe) { + iframe.style.width = '100%'; + iframe.style.border = 'none'; + iframe.style.overflow = 'visible'; + iframe.style.minHeight = '600px'; + iframe.setAttribute('scrolling', 'no'); + + // 若同源,尝试根据内容自适应高度 + try { + var doc = iframe.contentDocument || iframe.contentWindow.document; + if (doc && doc.body) { + iframe.style.height = doc.body.scrollHeight + 'px'; + } + } catch (e) { + } + } + } catch (e) { + } + }, 600); + var schema = document.documentElement.getAttribute('data-user-color-scheme'); if (schema) { document.querySelector('#cusdis_thread').dataset.theme = schema