diff --git a/assets/js/theme.js b/assets/js/theme.js index fb33748b..eca93e9d 100644 --- a/assets/js/theme.js +++ b/assets/js/theme.js @@ -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(); diff --git a/layouts/partials/plugin/post-chat-ai.html b/layouts/partials/plugin/post-chat-ai.html index 0ef13076..252c2e18 100644 --- a/layouts/partials/plugin/post-chat-ai.html +++ b/layouts/partials/plugin/post-chat-ai.html @@ -2,7 +2,6 @@ PostChat AI service. PostChat: https://postchat.zhheo.com/addCode.html PostSummary: https://postchat.zhheo.com/summary.html - TODO dark/light mode switch TODO chat API development */ -}} {{- $params := .Params | merge .Site.Params -}}