forked from shuyu-labs/WebCode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathActivityBar.razor
More file actions
105 lines (93 loc) · 5.76 KB
/
ActivityBar.razor
File metadata and controls
105 lines (93 loc) · 5.76 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
@* Activity Bar - IDE风格侧边图标菜单栏 *@
<div class="activity-bar hidden lg:flex flex-col h-screen w-[50px] flex-shrink-0 z-50">
<!-- 主菜单图标区域 -->
<div class="flex-1 flex flex-col items-center pt-2">
<!-- 聊天助手 -->
<button class="activity-bar-item @GetItemClass(ChatKey)"
@onclick="@(() => HandleItemClick(ChatKey))"
title="@ChatTitle">
<svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="1.8" d="M8 12h.01M12 12h.01M16 12h.01M21 12c0 4.418-4.03 8-9 8a9.863 9.863 0 01-4.255-.949L3 20l1.395-3.72C3.512 15.042 3 13.574 3 12c0-4.418 4.03-8 9-8s9 3.582 9 8z"></path>
</svg>
</button>
<!-- 会话历史 -->
<button class="activity-bar-item @GetItemClass(SessionsKey)"
@onclick="@(() => HandleItemClick(SessionsKey))"
title="@SessionsTitle">
<svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="1.8" d="M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z"></path>
</svg>
</button>
<!-- 模板库 -->
<button class="activity-bar-item @GetItemClass(TemplatesKey)"
@onclick="@(() => HandleItemClick(TemplatesKey))"
title="@TemplatesTitle">
<svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="1.8" d="M19 11H5m14 0a2 2 0 012 2v6a2 2 0 01-2 2H5a2 2 0 01-2-2v-6a2 2 0 012-2m14 0V9a2 2 0 00-2-2M5 11V9a2 2 0 012-2m0 0V5a2 2 0 012-2h6a2 2 0 012 2v2M7 7h10"></path>
</svg>
</button>
<!-- 项目管理 -->
<button class="activity-bar-item @GetItemClass(ProjectsKey)"
@onclick="@(() => HandleItemClick(ProjectsKey))"
title="@ProjectsTitle">
<svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="1.8" d="M3 7v10a2 2 0 002 2h14a2 2 0 002-2V9a2 2 0 00-2-2h-6l-2-2H5a2 2 0 00-2 2z"></path>
</svg>
</button>
<!-- 上下文管理 -->
<button class="activity-bar-item @GetItemClass(ContextKey)"
@onclick="@(() => HandleItemClick(ContextKey))"
title="@ContextTitle">
<svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="1.8" d="M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"></path>
</svg>
</button>
<!-- 任务管理 -->
<button class="activity-bar-item @GetItemClass(TasksKey)"
@onclick="@(() => HandleItemClick(TasksKey))"
title="@TasksTitle">
<svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="1.8" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"></path>
</svg>
</button>
</div>
<!-- 底部设置图标 -->
<div class="flex flex-col items-center pb-2">
<button class="activity-bar-item @GetItemClass(SettingsKey)"
@onclick="@(() => HandleItemClick(SettingsKey))"
title="@SettingsTitle">
<svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="1.8" d="M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.065 2.572c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.572 1.065c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.065-2.572c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065z"></path>
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="1.8" d="M15 12a3 3 0 11-6 0 3 3 0 016 0z"></path>
</svg>
</button>
</div>
</div>
@code {
// 菜单项键值常量
private const string ChatKey = "chat";
private const string SessionsKey = "sessions";
private const string TemplatesKey = "templates";
private const string ProjectsKey = "projects";
private const string ContextKey = "context";
private const string TasksKey = "tasks";
private const string SettingsKey = "settings";
[Parameter] public string ActiveItem { get; set; } = "chat";
[Parameter] public EventCallback<string> OnItemChanged { get; set; }
// 本地化文本
[Parameter] public string ChatTitle { get; set; } = "聊天助手";
[Parameter] public string SessionsTitle { get; set; } = "会话历史";
[Parameter] public string TemplatesTitle { get; set; } = "模板库";
[Parameter] public string ProjectsTitle { get; set; } = "项目管理";
[Parameter] public string ContextTitle { get; set; } = "上下文";
[Parameter] public string TasksTitle { get; set; } = "任务管理";
[Parameter] public string SettingsTitle { get; set; } = "设置";
private string GetItemClass(string itemKey)
{
return ActiveItem == itemKey ? "active" : "";
}
private async Task HandleItemClick(string itemKey)
{
await OnItemChanged.InvokeAsync(itemKey);
}
}