π The open-source, offline-first Notion, Obsidian & Confluence alternative. Advanced Markdown, multi-tenant teams, OIDC/SSO, and local S3 backups. Deploy in one command.
Vue dockergolangkanbanknowledge-baseknowledge-managementmarkdownnote-takingnotesnotes-appnotionnuxtnuxtjsoffline-firstoidcpwaselfhostedssovuevuejswiki
<template>
<div class="command-center">
<div class="search-header">
<div class="search-input-wrapper">
<Icon name="search" class="search-icon" />
<input
ref="searchInput"
:value="searchQuery"
type="text"
:placeholder="t('components.commandCenter.searchPlaceholder')"
class="search-input"
@input="handleSearchInput"
@keydown="handleKeydown"
/>
</div>
</div>
<TabNavigation />
<div class="tab-content">
<QuickSearchTab
v-if="activeTab === 'quick'"
ref="quickSearchTab"
:search-query="searchQuery"
:selected-index="selectedIndex"
@update-selected-index="setSelectedIndex"
/>
<AdvancedSearchTab v-else ref="advancedSearchTab" :query="searchQuery" :selected-index="selectedIndex" @update-selected-index="setSelectedIndex" />
</div>
<div class="search-footer">
<div class="shortcuts">
<kbd>ββ</kbd> {{ t('components.commandCenter.navigate') }} <kbd>Enter</kbd> {{ t('components.commandCenter.select') }} <kbd>β</kbd>
{{ t('components.commandCenter.switchTabs') }} <kbd>Esc</kbd> {{ t('components.commandCenter.close') }}
</div>
</div>
</div>
</template>
<script setup lang="ts">
import TabNavigation from './TabNavigation.vue';
import QuickSearchTab from './QuickSearchTab.vue';
import AdvancedSearchTab from './AdvancedSearchTab.vue';
const { t } = useI18nT();
const { searchQuery, selectedIndex, activeTab, close, setSearchQuery, setSelectedIndex } = useCommandCenter();
const searchInput = ref<HTMLInputElement>();
const quickSearchTab = ref<InstanceType<typeof QuickSearchTab>>();
const advancedSearchTab = ref<InstanceType<typeof AdvancedSearchTab>>();
onMounted(() => nextTick(() => searchInput.value?.focus()));
function getItems() {
return activeTab.value === 'quick' ? quickSearchTab.value?.flattenedItems || [] : advancedSearchTab.value?.flattenedItems || [];
}
function handleSearchInput(e: Event) {
setSearchQuery((e.target as HTMLInputElement).value);
}
function handleKeydown(e: KeyboardEvent) {
const items = getItems();
const max = items.length - 1;
if (e.key === 'ArrowDown' || (e.key === 'Tab' && !e.shiftKey)) {
e.preventDefault();
setSelectedIndex(selectedIndex.value < max ? selectedIndex.value + 1 : 0);
} else if (e.key === 'ArrowUp' || (e.key === 'Tab' && e.shiftKey)) {
e.preventDefault();
setSelectedIndex(selectedIndex.value > 0 ? selectedIndex.value - 1 : max);
} else if (e.key === 'Enter' && items.length) {
e.preventDefault();
const item = items[selectedIndex.value];
if (item?.path) {
close();
navigateTo(item.path);
}
}
}
</script>
<style scoped lang="scss">
.command-center {
display: flex;
flex-direction: column;
border-radius: 16px;
overflow: auto;
}
.search-header {
display: flex;
align-items: center;
gap: 12px;
padding: 20px;
border-bottom: 1px solid var(--border);
}
.search-input-wrapper {
position: relative;
display: flex;
flex: 1;
align-items: center;
}
.search-icon {
position: absolute;
top: 50%;
left: 12px;
width: 20px;
height: 20px;
transform: translateY(-50%);
}
.search-input {
width: 100%;
padding: 12px 12px 12px 44px;
border: none;
font-size: 16px;
background: transparent;
outline: none;
}
.tag {
margin-right: 25px;
}
.tab-content {
flex: 1;
min-height: 0;
overflow: auto;
}
.search-footer {
padding: 16px 20px;
border-top: 1px solid var(--border);
}
.shortcuts {
display: flex;
flex-wrap: wrap;
align-items: center;
gap: 10px;
font-size: 13px;
font-weight: 500;
}
</style>