From 9f5df958233e9e071968ad2b00f715a73f13c820 Mon Sep 17 00:00:00 2001 From: Nicolas Bonamy Date: Thu, 26 Dec 2024 18:44:12 -0400 Subject: [PATCH] dialog refactor --- src/components/AlertDialog.vue | 141 ++++++++++++++++++++++----------- src/screens/ChatEditor.vue | 22 +++-- src/screens/Main.vue | 5 +- 3 files changed, 116 insertions(+), 52 deletions(-) diff --git a/src/components/AlertDialog.vue b/src/components/AlertDialog.vue index 3a55ecb..5358818 100644 --- a/src/components/AlertDialog.vue +++ b/src/components/AlertDialog.vue @@ -1,20 +1,36 @@ - \ No newline at end of file diff --git a/src/screens/ChatEditor.vue b/src/screens/ChatEditor.vue index 6efdc62..77957c0 100644 --- a/src/screens/ChatEditor.vue +++ b/src/screens/ChatEditor.vue @@ -1,5 +1,5 @@ @@ -34,6 +36,7 @@ import Chat from '../models/chat' export type ChatEditorCallback = ({title, engine, model}: {title: string, engine: string, model: string}) => void +const dialog = ref(null) const title = ref('') const engine = ref('') const model = ref('') @@ -60,13 +63,17 @@ onMounted(async () => { }, { immediate: true }) }) +const close = () => { + dialog.value.close('#chat-editor') +} + const onChangeEngine = () => { const llmFactory = new LlmFactory(store.config) model.value = llmFactory.getChatModel(engine.value, false) } const onCancel = () => { - document.querySelector('#chat-editor').close() + close() } const onSave = () => { @@ -86,9 +93,14 @@ const onSave = () => { engine: engine.value, model: model.value, }) - onCancel() + close() } +defineExpose({ + show: () => dialog.value.show('#chat-editor'), + close, +}) +