mirror of
https://github.com/open-webui/open-webui.git
synced 2025-12-13 21:05:19 +00:00
37 lines
908 B
Svelte
37 lines
908 B
Svelte
<script lang="ts">
|
|
import { onMount } from 'svelte';
|
|
import { shortcuts } from '$lib/shortcuts';
|
|
import { settings } from '$lib/stores';
|
|
|
|
export let name: string;
|
|
export let className = '';
|
|
|
|
let isMac = false;
|
|
let mounted = false;
|
|
let keys: string[] = [];
|
|
let isVisible = true;
|
|
|
|
onMount(() => {
|
|
isMac = /Mac/i.test(navigator.userAgent);
|
|
keys = shortcuts[name]?.keys ?? [];
|
|
mounted = true;
|
|
});
|
|
|
|
function formatKey(key: string): string {
|
|
const lowerKey = key.toLowerCase();
|
|
|
|
if (lowerKey === 'mod') return isMac ? '⌘' : 'Ctrl';
|
|
if (lowerKey === 'shift') return isMac ? '⇧' : 'Shift';
|
|
if (lowerKey.startsWith('key')) return key.slice(-1);
|
|
|
|
return key;
|
|
}
|
|
</script>
|
|
|
|
{#if mounted && isVisible}
|
|
<div
|
|
class="hidden md:flex items-center self-center text-xs text-gray-400 dark:text-gray-600 {className}"
|
|
>
|
|
<span>{keys.map(formatKey).join(isMac ? '' : '+')}</span>
|
|
</div>
|
|
{/if}
|