mirror of
https://gitee.com/SuperManito/LinuxMirrors
synced 2025-12-20 15:16:34 +08:00
为文档添加 AI 搜索与聊天
This commit is contained in:
30
docs/assets/js/components/orama-ui/index.js
Normal file
30
docs/assets/js/components/orama-ui/index.js
Normal file
@@ -0,0 +1,30 @@
|
||||
function loadOramaWebComponent() {
|
||||
const searchBox = document.querySelector('orama-search-box')
|
||||
if (searchBox) {
|
||||
Object.assign(searchBox, getOramaSearchBoxConfig())
|
||||
}
|
||||
|
||||
// define global function
|
||||
window.openOramaSearch = function (event) {
|
||||
const element = document.querySelector('orama-search-box')
|
||||
if (element) {
|
||||
element.open = true
|
||||
localizationOramaSearchBox(element)
|
||||
}
|
||||
return false
|
||||
}
|
||||
// localization chat box component
|
||||
if (searchBox) {
|
||||
const openObserver = new MutationObserver((mutations) => {
|
||||
mutations.forEach((mutation) => {
|
||||
if (mutation.type === 'attributes' && mutation.attributeName === 'open' && searchBox.hasAttribute('open')) {
|
||||
localizationOramaSearchBox(searchBox)
|
||||
}
|
||||
})
|
||||
})
|
||||
openObserver.observe(searchBox, { attributes: true })
|
||||
if (searchBox.hasAttribute('open')) {
|
||||
localizationOramaSearchBox(searchBox)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user