Feat: add post-chat search engine powered by PostChat

This commit is contained in:
Cell
2024-12-19 12:22:48 +08:00
parent fcd72c9d66
commit 3e210af76a
5 changed files with 29 additions and 9 deletions
+2 -1
View File
@@ -117,8 +117,9 @@ I don't know why 🤷
- **Sub Menu** supported
- **Content Encryption** supported (Pages, Partial)
- **Friends** page embedded template
- **Search** supported by [algolia](https://www.algolia.com/), [Fuse.js](https://fusejs.io/) or CSE
- **Search** supported by [algolia](https://www.algolia.com/), [Fuse.js](https://fusejs.io/)、 CSE or [PostChat](https://ai.tianli0.top/?InviteID=IRE1S88Z)
- **Custom Search Engine (CSE)** supported by [Google](https://programmablesearchengine.google.com/)
- **AI Summary**、**AI Search** and **AI Chatbot** supported by [PostChat](https://ai.tianli0.top/?InviteID=IRE1S88Z)
- **Twemoji** supported
- Automatically **highlighting** code
- **Copy code** to clipboard with one click
+2 -1
View File
@@ -117,8 +117,9 @@
- 支持**二级菜单**
- 支持**内容加密**(页面、局部)
- 支持**友情链接**的页面模板
- 支持基于 [algolia](https://www.algolia.com/)、[Fuse.js](https://fusejs.io/) **CSE** 的**搜索**
- 支持基于 [algolia](https://www.algolia.com/)、[Fuse.js](https://fusejs.io/) **CSE** 或 [PostChat](https://ai.tianli0.top/?InviteID=IRE1S88Z) 的**搜索**
- 支持基于 [Google](https://programmablesearchengine.google.com/) 的**自定义搜索引擎 (CSE)**
- 支持基于 [PostChat](https://ai.tianli0.top/?InviteID=IRE1S88Z) 的 **AI 摘要**、**AI 搜索** 和 **AI 智能客服**
- 支持 **Twemoji**
- 支持**代码高亮**
- 一键**复制代码**到剪贴板
+18 -1
View File
@@ -124,6 +124,21 @@ class FixIt {
const $searchToggle = document.getElementById(`search-toggle-${suffix}`);
const $searchLoading = document.getElementById(`search-loading-${suffix}`);
const $searchClear = document.getElementById(`search-clear-${suffix}`);
const $searchCancel = document.getElementById('search-cancel-mobile');
// goto the PostChat panel rather than search results
if (searchConfig.type === 'post-chat' && window.postChatUser) {
if (isMobile) {
$searchInput.addEventListener('focus', () => {
window.postChatUser.setSearchInput('');
}, false);
} else {
$searchToggle.addEventListener('click', () => {
window.postChatUser.setSearchInput('');
}, false);
}
return;
}
if (isMobile) {
this._searchMobileOnce = true;
@@ -132,7 +147,7 @@ class FixIt {
document.body.classList.add('blur');
$header.classList.add('open');
}, false);
document.getElementById('search-cancel-mobile').addEventListener('click', () => {
$searchCancel.addEventListener('click', () => {
this.disableScrollEvent = false;
$header.classList.remove('open');
document.body.classList.remove('blur');
@@ -301,6 +316,8 @@ class FixIt {
context: cseConfig.gotoResultsPage
}]);
}
} else {
finish([]);
}
},
templates: {
+4 -5
View File
@@ -389,7 +389,7 @@ enableEmoji = true
# Search config
[params.search]
enable = false
# type of search engine ["algolia", "fuse", "cse"]
# type of search engine ["algolia", "fuse", "cse", "post-chat"]
type = "fuse"
# max index length of the chunked content
contentLength = 4000
@@ -887,12 +887,11 @@ enableEmoji = true
theme = "minimal"
# FixIt 0.3.17 | NEW PostChat AI config
# Summary AI, knowledge base search and knowledge base dialogue support
# Docs: https://postchat.zhheo.com/
# Based on your posts to build a knowledge base, support AI summary, AI search, and AI Chatbot.
# Get PostChat Key from my invitation link, thanks for your support!
# https://ai.tianli0.top/?InviteID=IRE1S88Z
[params.postChat]
enable = false
# Get PostChat Key from my invitation link, thanks for your support!
# https://ai.tianli0.top/?InviteID=IRE1S88Z
key = "ed872bf9336506bea545183089f5034f81fea6af"
# How users initiate chats: ["iframe", "magic"]
userMode = "magic"
+3 -1
View File
@@ -22,7 +22,7 @@
{{- $source := $cdn.fuseJS | default "lib/fuse/fuse.min.js" -}}
{{- dict "Source" $source "Fingerprint" $fingerprint "Defer" true | dict "Scratch" .Scratch "Data" | partial "scratch/script.html" -}}
{{- $config = dict "isCaseSensitive" $search.fuse.isCaseSensitive "minMatchCharLength" $search.fuse.minMatchCharLength "findAllMatches" $search.fuse.findAllMatches "location" $search.fuse.location "threshold" $search.fuse.threshold "distance" $search.fuse.distance "ignoreLocation" $search.fuse.ignoreLocation "useExtendedSearch" $search.fuse.useExtendedSearch "ignoreFieldNorm" $search.fuse.ignoreFieldNorm | dict "search" | merge $config -}}
{{- else if eq $search.type "cse" -}}
{{- else if eq $search.type "cse" -}}
{{- $config = dict "type" "cse" | dict "search" | merge $config -}}
{{- $cse := .Site.Params.cse -}}
{{- $config = dict "resultsPage" $cse.resultsPage "gotoResultsPage" (T "assets.gotoResultsPage") | dict "cse" | merge $config -}}
@@ -32,6 +32,8 @@
{{- if eq $cse.engine "bing" -}}
{{- /* Unsupported */ -}}
{{- end -}}
{{- else if eq $search.type "post-chat" -}}
{{- $config = dict "type" "post-chat" | dict "search" | merge $config -}}
{{- end -}}
{{- end -}}