Perf(postChat): auto switch dark/light theme mode

This commit is contained in:
Cell
2024-12-19 10:59:55 +08:00
parent 68b028e9b6
commit fcd72c9d66
2 changed files with 17 additions and 1 deletions
+17
View File
@@ -1130,6 +1130,22 @@ class FixIt {
this.scrollEventSet.add(_closeRewardExclude);
}
initPostChatUser() {
window.postChat_mode = postChatConfig.userMode || 'iframe';
if (window.postChat_mode !== 'iframe' || !window.postChatUser) {
return;
}
postChat_theme = this.isDark ? 'dark' : 'light';
this.switchThemeEventSet.add((isDark) => {
const targetFrame = document.getElementById("postChat_iframeContainer")
if (targetFrame) {
window.postChatUser.setPostChatTheme(isDark ? 'dark' : 'light');
} else {
postChat_theme = isDark ? 'dark' : 'light';
}
});
}
onScroll() {
const $headers = [];
const ACCURACY = 20;
@@ -1269,6 +1285,7 @@ class FixIt {
this.initWatermark();
this.initAutoMark();
this.initReward();
this.initPostChatUser();
window.setTimeout(() => {
this.initComment();