mirror of
https://gitee.com/SuperManito/LinuxMirrors
synced 2025-11-05 08:50:25 +08:00
为文档添加 AI 搜索与聊天
This commit is contained in:
47
docs/assets/js/components/orama-ui/index-native.js
Normal file
47
docs/assets/js/components/orama-ui/index-native.js
Normal file
@@ -0,0 +1,47 @@
|
||||
function loadOramaWebComponent() {
|
||||
const searchBox = document.querySelector('orama-search-box')
|
||||
if (searchBox) {
|
||||
Object.assign(searchBox, getOramaSearchBoxConfig())
|
||||
}
|
||||
|
||||
// custom button style and localization
|
||||
const searchButton = document.querySelector('orama-search-button')
|
||||
if (searchButton) {
|
||||
searchButton.textContent = '搜索'
|
||||
const observer = new MutationObserver((mutations, obs) => {
|
||||
if (searchButton.shadowRoot) {
|
||||
const button = searchButton.shadowRoot.querySelector('button')
|
||||
if (button) {
|
||||
button.style = 'border-radius: 8px !important;'
|
||||
button.querySelector('.button__label').style = 'height: 22px; padding: 2px 8px; font-size: 0.75rem;'
|
||||
button.querySelector('span[slot="adorment-end"], .kyb-shortcut').style = 'display: none;'
|
||||
// search icon style
|
||||
const magnifyingGlassShadowRoot = button.querySelector('ph-magnifying-glass').shadowRoot
|
||||
const styleElement = document.createElement('style')
|
||||
styleElement.textContent = `
|
||||
svg {
|
||||
font-size: 24px;
|
||||
}`
|
||||
if (!magnifyingGlassShadowRoot.querySelector('style[data-custom="icon-style"]')) {
|
||||
styleElement.setAttribute('data-custom', 'icon-style')
|
||||
magnifyingGlassShadowRoot.appendChild(styleElement)
|
||||
}
|
||||
obs.disconnect()
|
||||
}
|
||||
}
|
||||
})
|
||||
observer.observe(searchButton, {
|
||||
childList: true,
|
||||
subtree: true,
|
||||
attributes: true,
|
||||
characterData: true,
|
||||
})
|
||||
setTimeout(() => observer.disconnect(), 2000)
|
||||
}
|
||||
|
||||
searchButton.addEventListener('click', function () {
|
||||
const searchBox = document.querySelector('orama-search-box')
|
||||
// localization chat box component
|
||||
localizationOramaSearchBox(searchBox)
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user