mirror of
https://github.com/hugo-fixit/FixIt.git
synced 2026-08-24 15:28:57 +00:00
feat(i): PostChat dark theme compatibility
NOTE: This feature may be removed from the theme's built-in functionality in the future.
This commit is contained in:
@@ -69,8 +69,8 @@ export interface MiscService {
|
||||
initSiteTime: () => void
|
||||
initAutoMark: () => void
|
||||
initReward: () => void
|
||||
initPostChatUser: () => void
|
||||
initComment: () => void
|
||||
initPostChat: () => void
|
||||
setup: () => void
|
||||
}
|
||||
|
||||
|
||||
+33
-16
@@ -104,22 +104,39 @@ export class MiscModule implements MiscService {
|
||||
document.querySelector('#comments')!.remove()
|
||||
}
|
||||
|
||||
/** Initialize PostChat theme sync if configured. */
|
||||
initPostChatUser() {
|
||||
if (!window.postChatUser || !window.postChatConfig || window.postChatConfig.userMode === 'magic')
|
||||
return
|
||||
window.postChat_theme = this.core.isDark ? 'dark' : 'light'
|
||||
eventBus.on('fixit:switch-theme', ({ detail }) => {
|
||||
if (!detail.isChanged)
|
||||
/**
|
||||
* Initialize PostChat and postSummary for HongMoAI
|
||||
*/
|
||||
initPostChat() {
|
||||
const initThemeCompatibility = () => {
|
||||
if (this.core.config.postChat) {
|
||||
document.body.classList.toggle('dark', this.core.isDark)
|
||||
eventBus.on('fixit:switch-theme', ({ detail }) => {
|
||||
if (!detail.isChanged)
|
||||
return
|
||||
document.body.classList.toggle('dark', detail.isDark)
|
||||
})
|
||||
}
|
||||
}
|
||||
/** Initialize PostChat theme sync if configured. */
|
||||
const initPostChatUser = () => {
|
||||
if (!window.postChatUser || !window.postChatConfig || window.postChatConfig.userMode === 'magic')
|
||||
return
|
||||
const targetFrame = document.getElementById('postChat_iframeContainer')
|
||||
if (targetFrame) {
|
||||
window.postChatUser.setPostChatTheme(detail.isDark ? 'dark' : 'light')
|
||||
}
|
||||
else {
|
||||
window.postChat_theme = detail.isDark ? 'dark' : 'light'
|
||||
}
|
||||
})
|
||||
window.postChat_theme = this.core.isDark ? 'dark' : 'light'
|
||||
eventBus.on('fixit:switch-theme', ({ detail }) => {
|
||||
if (!detail.isChanged)
|
||||
return
|
||||
const targetFrame = document.getElementById('postChat_iframeContainer')
|
||||
if (targetFrame) {
|
||||
window.postChatUser.setPostChatTheme(detail.isDark ? 'dark' : 'light')
|
||||
}
|
||||
else {
|
||||
window.postChat_theme = detail.isDark ? 'dark' : 'light'
|
||||
}
|
||||
})
|
||||
}
|
||||
initThemeCompatibility()
|
||||
initPostChatUser()
|
||||
}
|
||||
|
||||
/** Initialize all miscellaneous features. */
|
||||
@@ -127,7 +144,7 @@ export class MiscModule implements MiscService {
|
||||
this.initSiteTime()
|
||||
this.initAutoMark()
|
||||
this.initReward()
|
||||
this.initPostChatUser()
|
||||
this.initComment()
|
||||
this.initPostChat()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,6 +31,7 @@ export interface FixItConfig {
|
||||
autoBookmark?: boolean
|
||||
encryption?: EncryptionConfig
|
||||
print?: PrintConfig
|
||||
postChat?: boolean
|
||||
}
|
||||
|
||||
export interface EchartsConfig {
|
||||
|
||||
@@ -836,7 +836,7 @@ fullscreen = true
|
||||
|
||||
# PostChat AI configuration.
|
||||
# Based on your posts to build a knowledge base, support AI summary, AI search, and AI Chatbot.
|
||||
# See: [洪墨 AI](https://ai.zhheo.com/docs/)
|
||||
# See: [HongMoAI](https://ai.zhheo.com/docs/)
|
||||
# Get PostChat Key from my invitation link, thanks for your support!
|
||||
# https://ai.zhheo.com/console/login?InviteID=85041330
|
||||
[params.post_chat]
|
||||
|
||||
@@ -334,7 +334,10 @@
|
||||
{{- $config = partial "function/camel-case-keys.html" .Site.Params.print | dict "print" | merge $config -}}
|
||||
|
||||
{{- /* PostChat */ -}}
|
||||
{{- partial "plugin/post-chat-ai.html" . -}}
|
||||
{{- $postChatEnable := partial "plugin/post-chat-ai.html" . -}}
|
||||
{{- if $postChatEnable -}}
|
||||
{{- $config = dict "postChat" true | merge $config -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- $library := dict "Page" . "Key" "library" | partial "function/param.html" -}}
|
||||
{{- range $library.css -}}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
{{- hugo.Store.Set "version" "v1.0.0-mrma4qc1" -}}
|
||||
{{- hugo.Store.Set "version" "v1.0.0-mrmd49g5" -}}
|
||||
{{- .Store.Set "this" dict -}}
|
||||
|
||||
{{- partial "init/detection-env.html" . -}}
|
||||
|
||||
@@ -109,3 +109,5 @@
|
||||
{{- $sourceOpts = dict "Source" $postChatJS | merge $sourceOpts -}}
|
||||
{{- $sourceOpts | dict "Page" . "Data" | partial "store/script.html" -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- return $enable -}}
|
||||
|
||||
Reference in New Issue
Block a user