Skip to content

Commit acdf1f2

Browse files
committed
refactor(AppHeader): moving header items to PageNavigation, removing logout and settings icons
1 parent 63de6a4 commit acdf1f2

File tree

5 files changed

+61
-68
lines changed

5 files changed

+61
-68
lines changed

app/components/AppHeader.vue

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
<script setup lang="ts">
22
const uiStore = useUiStore();
3-
const { signOut } = useAuth();
43
const route = useRoute();
54
</script>
65

@@ -40,16 +39,6 @@ const route = useRoute();
4039
uiStore.setCommandPaletteVisible(!uiStore.commandPaletteVisible)
4140
"
4241
/>
43-
<Icon
44-
name="lucide:settings"
45-
class="text-(--main-color) cursor-pointer scale-125 header-icon"
46-
@mousedown="navigateTo('/settings')"
47-
/>
48-
<Icon
49-
name="lucide:log-out"
50-
class="text-(--main-color) cursor-pointer scale-125 header-icon"
51-
@click="signOut"
52-
/>
5342
</div>
5443
</div>
5544
</template>

app/components/CommandPalette/CommandPalette.vue

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,10 @@ watch(
6767
<div
6868
class="flex flex-col backdrop-blur-lg bg-(--bg-color)/80 w-[600px] h-[600px] m-4 rounded-lg shadow-lg font-mono command-palette border border-(--sub-color)"
6969
:style="{
70-
translate: uiStore.chatListVisible
71-
? uiStore.chatListWidth / 2 + 'px'
72-
: '0px',
70+
translate:
71+
uiStore.chatListVisible && route.path.startsWith('/chat')
72+
? uiStore.chatListWidth / 2 + 'px'
73+
: '0px',
7374
}"
7475
@click.stop
7576
>

app/components/PageNavigation.vue

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,34 @@
11
<script setup lang="ts">
2+
const chatStore = useChatStore();
23
const pages = {
34
chat: {
45
name: "chat",
6+
action: () => {
7+
if (chatStore.currentChatId) {
8+
navigateTo(`/chat/${chatStore.currentChatId}`);
9+
} else {
10+
navigateTo("/chat");
11+
}
12+
},
513
url: "/chat",
614
icon: "lucide:message-square",
715
},
816
knowledge: {
917
name: "knowledge",
18+
action: () => {
19+
navigateTo("/knowledge");
20+
},
1021
url: "/knowledge",
1122
icon: "lucide:library",
1223
},
24+
settings: {
25+
name: "settings",
26+
action: () => {
27+
navigateTo("/settings");
28+
},
29+
url: "/settings",
30+
icon: "lucide:settings",
31+
},
1332
};
1433
1534
const popupVisible = ref(false);
@@ -106,12 +125,7 @@ onBeforeUnmount(() => {
106125
? 'bg-(--sub-color)/20'
107126
: 'hover:bg-(--sub-color)/10',
108127
]"
109-
@click="
110-
() => {
111-
navigateTo(page.url);
112-
popupVisible = false;
113-
}
114-
"
128+
@click="page.action()"
115129
>
116130
<Icon :name="page.icon" class="text-(--main-color) scale-125" />
117131
<div class="flex flex-col overflow-hidden">
Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,11 @@
11
<script setup lang="ts">
22
const uiStore = useUiStore();
3-
const { signOut } = useAuth();
4-
const chatStore = useChatStore();
53
</script>
64

75
<template>
86
<div class="flex justify-between py-2 px-4 items-center gap-4 app-header">
97
<div class="flex gap-4 items-center app-header-left">
10-
<Icon
11-
name="lucide:bot-message-square"
12-
class="text-(--main-color) cursor-pointer scale-125 header-icon"
13-
@click="
14-
() => {
15-
if (chatStore.currentChatId) {
16-
navigateTo(`/chat/${chatStore.currentChatId}`);
17-
} else {
18-
navigateTo('/chat');
19-
}
20-
}
21-
"
22-
/>
8+
<PageNavigation />
239
</div>
2410
<div class="flex gap-4 items-center app-header-right">
2511
<Icon
@@ -29,11 +15,6 @@ const chatStore = useChatStore();
2915
uiStore.setCommandPaletteVisible(!uiStore.commandPaletteVisible)
3016
"
3117
/>
32-
<Icon
33-
name="lucide:log-out"
34-
class="text-(--main-color) cursor-pointer scale-125 header-icon"
35-
@click="signOut"
36-
/>
3718
</div>
3819
</div>
3920
</template>

app/composables/useCommandPalette.ts

Lines changed: 36 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,42 @@ export function useCommandPalette() {
3232
const allThemes = computed<Theme[]>(() => sortedThemesList);
3333

3434
const options = ref<Option[]>([
35+
{
36+
label: "new chat",
37+
icon: "lucide:message-square-plus",
38+
action: goToNewChat,
39+
},
40+
{
41+
label: "search chats",
42+
icon: "lucide:search",
43+
action: () => {
44+
useUiStore().setChatSearchVisible(true);
45+
useUiStore().setCommandPaletteVisible(false);
46+
},
47+
},
48+
{
49+
label: "knowledge",
50+
icon: "lucide:library",
51+
action: () => {
52+
useUiStore().setCommandPaletteVisible(false);
53+
navigateTo("/knowledge");
54+
},
55+
},
56+
{
57+
label: "model",
58+
icon: "lucide:cpu",
59+
options: getModelOptions(),
60+
},
61+
{
62+
label: "system prompt",
63+
icon: "lucide:message-square",
64+
options: getPromptOptions(),
65+
},
66+
{
67+
label: "title generator model",
68+
icon: "lucide:book-a",
69+
options: getTitleModelOptions(),
70+
},
3571
{ label: "theme", icon: "lucide:palette" },
3672
{ label: "favorite themes", icon: "lucide:star" },
3773
{
@@ -60,34 +96,6 @@ export function useCommandPalette() {
6096
icon: "lucide:message-square-text",
6197
options: getMessageDisplayModeOptions(),
6298
},
63-
{
64-
label: "model",
65-
icon: "lucide:cpu",
66-
options: getModelOptions(),
67-
},
68-
{
69-
label: "title generator model",
70-
icon: "lucide:book-a",
71-
options: getTitleModelOptions(),
72-
},
73-
{
74-
label: "system prompt",
75-
icon: "lucide:message-square",
76-
options: getPromptOptions(),
77-
},
78-
{
79-
label: "new chat",
80-
icon: "lucide:message-square-plus",
81-
action: goToNewChat,
82-
},
83-
{
84-
label: "search chats",
85-
icon: "lucide:search",
86-
action: () => {
87-
useUiStore().setChatSearchVisible(true);
88-
useUiStore().setCommandPaletteVisible(false);
89-
},
90-
},
9199
{
92100
label: "funbox",
93101
icon: "lucide:party-popper",

0 commit comments

Comments
 (0)