mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-09-25 06:01:40 +08:00
refactor(llm): use dedicated widget for llm chat button
This commit is contained in:
parent
7b643a7d82
commit
d7167131cb
15
src/public/app/widgets/buttons/llm_chat_button.ts
Normal file
15
src/public/app/widgets/buttons/llm_chat_button.ts
Normal file
@ -0,0 +1,15 @@
|
||||
import type FNote from "../../entities/fnote.js";
|
||||
import CommandButtonWidget from "./command_button.js";
|
||||
|
||||
export default class LlmChatButton extends CommandButtonWidget {
|
||||
|
||||
constructor(note: FNote) {
|
||||
super();
|
||||
|
||||
this.command("showLlmChat")
|
||||
.title(() => note.title)
|
||||
.icon(() => note.getIcon())
|
||||
.class("launcher-button");
|
||||
}
|
||||
|
||||
}
|
@ -13,6 +13,7 @@ import HistoryNavigationButton from "../buttons/history_navigation.js";
|
||||
import QuickSearchLauncherWidget from "../quick_search_launcher.js";
|
||||
import type FNote from "../../entities/fnote.js";
|
||||
import type { CommandNames } from "../../components/app_context.js";
|
||||
import LlmChatButton from "../buttons/llm_chat_button.js";
|
||||
|
||||
interface InnerWidget extends BasicWidget {
|
||||
settings?: {
|
||||
@ -124,7 +125,7 @@ export default class LauncherWidget extends BasicWidget {
|
||||
case "quickSearch":
|
||||
return new QuickSearchLauncherWidget(this.isHorizontalLayout);
|
||||
case "llmChatLauncher":
|
||||
return new ScriptLauncher(note);
|
||||
return new LlmChatButton(note);
|
||||
default:
|
||||
throw new Error(`Unrecognized builtin widget ${builtinWidget} for launcher ${note.noteId} "${note.title}"`);
|
||||
}
|
||||
|
@ -72,11 +72,10 @@ export default function buildLaunchBarConfig() {
|
||||
id: "_lbLlmChat",
|
||||
title: t("hidden-subtree.llm-chat-title"),
|
||||
type: "launcher",
|
||||
command: "showLlmChat",
|
||||
icon: "bx bx-bot",
|
||||
builtinWidget: "llmChatLauncher",
|
||||
attributes: [
|
||||
{ type: "label", name: "desktopOnly" },
|
||||
{ type: "label", name: "launcherType", value: "command" }
|
||||
{ type: "label", name: "desktopOnly" }
|
||||
]
|
||||
},
|
||||
{ id: "_lbCalendar", ...sharedLaunchers.calendar },
|
||||
|
Loading…
x
Reference in New Issue
Block a user