mirror of
https://github.com/open-webui/computer.git
synced 2026-11-23 06:00:43 -05:00
refac
This commit is contained in:
1 parent
ea922ecd38
commit
d32b1d8e42
3 files changed
+40
-16
No files matched your search
@@ -331,8 +331,7 @@
|
||||
{#if tabHint}
|
||||
<span class="text-[10px] text-gray-400 whitespace-nowrap shrink-0">{tabHint}</span>
|
||||
{/if}
|
||||
<span
|
||||
class="text-[10px] font-mono font-medium px-1.5 py-0.5 rounded bg-gray-100 dark:bg-white/6 text-gray-400 shrink-0"
|
||||
<span class="text-[10px] font-mono px-1.5 py-0.5 rounded bg-gray-100 dark:bg-white/6 text-gray-400 shrink-0"
|
||||
>TAB</span
|
||||
>
|
||||
</div>
|
||||
@@ -352,7 +351,7 @@
|
||||
>{/if}
|
||||
{#if i === breadcrumbs.length - 1}
|
||||
<span
|
||||
class="text-[11px] font-mono font-medium text-gray-900 dark:text-white whitespace-nowrap overflow-hidden text-ellipsis"
|
||||
class="text-[11px] font-mono text-gray-900 dark:text-white whitespace-nowrap overflow-hidden text-ellipsis"
|
||||
>{seg.name}</span
|
||||
>
|
||||
{:else}
|
||||
@@ -443,11 +442,11 @@
|
||||
title={currentPath}>{currentPath}</span
|
||||
>
|
||||
<button
|
||||
class="text-xs font-medium text-gray-500 hover:text-gray-700 dark:hover:text-gray-300 px-3 py-1.5 rounded-lg transition-colors duration-100 shrink-0"
|
||||
class="text-xs text-gray-500 hover:text-gray-700 dark:hover:text-gray-300 px-3 py-1.5 rounded-lg transition-colors duration-100 shrink-0"
|
||||
onclick={onclose}>{$t('directory.cancel')}</button
|
||||
>
|
||||
<button
|
||||
class="text-xs font-medium text-white dark:text-black bg-gray-900 dark:bg-white hover:bg-gray-800 dark:hover:bg-gray-200 px-3 py-1.5 rounded-lg transition-colors duration-100 shrink-0"
|
||||
class="text-xs text-white dark:text-black bg-gray-900 dark:bg-white hover:bg-gray-800 dark:hover:bg-gray-200 px-3 py-1.5 rounded-lg transition-colors duration-100 shrink-0"
|
||||
onclick={selectCurrent}>{$t('directory.open', { name: currentFolderName })}</button
|
||||
>
|
||||
</div>
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<script lang="ts">
|
||||
import { onMount, untrack } from 'svelte';
|
||||
import Icon from './Icon.svelte';
|
||||
import Modal from './Modal.svelte';
|
||||
import General from './Settings/General.svelte';
|
||||
@@ -41,17 +42,23 @@
|
||||
|
||||
let { onclose, initialTab = 'general' }: Props = $props();
|
||||
|
||||
let activeTab = $state<Tab>(initialTab);
|
||||
let activeTab = $state<Tab>(untrack(() => (initialTab === 'pwa' ? 'general' : initialTab)));
|
||||
let showPwaSettings = $state(false);
|
||||
|
||||
const isAdmin = $derived($session?.role === 'admin');
|
||||
|
||||
const personalTabs: { id: Tab; label: string; icon: string }[] = $derived([
|
||||
{ id: 'general', label: $t('settings.general'), icon: 'settings' },
|
||||
{ id: 'keyboard', label: $t('settings.keyboard'), icon: 'terminal' },
|
||||
{ id: 'account', label: $t('settings.account'), icon: 'user' },
|
||||
{ id: 'pwa', label: 'PWA', icon: 'phone' },
|
||||
{ id: 'about', label: $t('settings.about'), icon: 'info' }
|
||||
]);
|
||||
type SettingsTab = { id: Tab; label: string; icon: string };
|
||||
|
||||
const personalTabs: SettingsTab[] = $derived.by(() => {
|
||||
const tabs: SettingsTab[] = [
|
||||
{ id: 'general', label: $t('settings.general'), icon: 'settings' },
|
||||
{ id: 'keyboard', label: $t('settings.keyboard'), icon: 'terminal' },
|
||||
{ id: 'account', label: $t('settings.account'), icon: 'user' }
|
||||
];
|
||||
if (showPwaSettings) tabs.push({ id: 'pwa', label: 'PWA', icon: 'phone' });
|
||||
tabs.push({ id: 'about', label: $t('settings.about'), icon: 'info' });
|
||||
return tabs;
|
||||
});
|
||||
|
||||
const adminTabs: { id: Tab; label: string; icon: string }[] = $derived([
|
||||
{ id: 'users', label: $t('admin.users'), icon: 'user' },
|
||||
@@ -64,6 +71,26 @@
|
||||
{ id: 'toolservers', label: $t('admin.toolServers'), icon: 'plug' },
|
||||
{ id: 'subagents', label: $t('admin.subagents'), icon: 'user' }
|
||||
]);
|
||||
|
||||
onMount(() => {
|
||||
showPwaSettings = isInstalledPwa();
|
||||
if (showPwaSettings && initialTab === 'pwa') {
|
||||
activeTab = 'pwa';
|
||||
} else if (initialTab !== 'pwa') {
|
||||
activeTab = initialTab;
|
||||
} else {
|
||||
activeTab = 'general';
|
||||
}
|
||||
});
|
||||
|
||||
function isInstalledPwa(): boolean {
|
||||
const nav = navigator as Navigator & { standalone?: boolean };
|
||||
return (
|
||||
window.matchMedia('(display-mode: standalone)').matches ||
|
||||
window.matchMedia('(display-mode: window-controls-overlay)').matches ||
|
||||
nav.standalone === true
|
||||
);
|
||||
}
|
||||
</script>
|
||||
|
||||
<Modal
|
||||
@@ -121,7 +148,7 @@
|
||||
<div class="flex-1 overflow-y-auto min-h-0 p-4 md:px-5">
|
||||
{#if activeTab === 'general'}
|
||||
<General />
|
||||
{:else if activeTab === 'pwa'}
|
||||
{:else if activeTab === 'pwa' && showPwaSettings}
|
||||
<PWA />
|
||||
{:else if activeTab === 'keyboard'}
|
||||
<Keyboard />
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
<script lang="ts">
|
||||
import Modal from './Modal.svelte';
|
||||
import Icon from './Icon.svelte';
|
||||
import type { LaunchIntent, ShareBehavior } from '$lib/intents/types';
|
||||
import { t } from '$lib/i18n';
|
||||
|
||||
@@ -79,7 +78,6 @@
|
||||
onclick={() => chooseWorkspace(ws)}
|
||||
onmouseenter={() => (selectedIndex = i)}
|
||||
>
|
||||
<Icon name="folder" size={14} class="shrink-0 text-gray-400" />
|
||||
<span class="text-xs shrink-0 truncate max-w-[34%]">{ws.name}</span>
|
||||
<span
|
||||
class="text-[11px] text-gray-400 overflow-hidden text-ellipsis whitespace-nowrap font-mono"
|
||||
|
||||
Reference in new issue
Block a user