Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 33 additions & 1 deletion layout/_partials/comments/cusdis.ejs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<% if (theme.cusdis.host && theme.cusdis.app_id) { %>
<div class="cusdis" style="width:100%">
<div class="cusdis" style="width:100%; overflow:visible; min-height:480px;">
<div id="cusdis_thread"
style="width:100%; overflow:visible;"
data-host="<%= theme.cusdis.host %>"
data-app-id="<%= theme.cusdis.app_id %>"
data-page-id="<%= md5(page.path) %>"
Expand All @@ -15,6 +16,37 @@
Fluid.utils.createScript('<%= url_join(theme.cusdis.host,
`/js/widget/lang/${ String(theme.cusdis.lang || 'zh-cn').toLowerCase() }.js`) %>');
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
Expand Down
Loading