diff --git a/app/src/assets/script/conversation.ts b/app/src/assets/script/conversation.ts new file mode 100644 index 0000000..ab6b09b --- /dev/null +++ b/app/src/assets/script/conversation.ts @@ -0,0 +1,60 @@ +import { reactive, ref } from "vue"; +import type { Ref } from "vue"; + +type Message = { + content: string; + role: string; + timestamp: string; +} + +export class Conversation { + id: number; + messages: Message[]; + len: Ref; + state: Ref; + + public constructor(id: number) { + this.id = id; + this.messages = reactive([]); + this.state = ref(false); + this.len = ref(0); + } + + public addMessage(message: Message): void { + this.state.value = true; + this.messages.push(message); + this.len.value++; + } + + public addMessageFromUser(content: string): void { + this.addMessage({ + content: content, + role: "user", + timestamp: new Date().toLocaleTimeString(), + }) + } + + public addMessageFromAI(content: string): void { + this.addMessage({ + content: content, + role: "bot", + timestamp: new Date().toLocaleTimeString(), + }) + } + + public getMessages(): Message[] { + return this.messages; + } + + public getMessagesByRole(role: string): Message[] { + return this.messages.filter(message => message.role === role); + } + + public getLength(): Ref { + return this.len; + } + + public getState(): Ref { + return this.state; + } +} diff --git a/app/src/assets/style/anim.css b/app/src/assets/style/anim.css new file mode 100644 index 0000000..4ac6961 --- /dev/null +++ b/app/src/assets/style/anim.css @@ -0,0 +1,21 @@ +@keyframes FlexInAnimationFromLeft { + 0% { + opacity: .2; + transform: translateX(-50px); + } + 100% { + opacity: 1; + transform: translateX(0); + } +} + +@keyframes FlexInAnimationFromRight { + 0% { + opacity: .2; + transform: translateX(50px); + } + 100% { + opacity: 1; + transform: translateX(0); + } +} diff --git a/app/src/style.css b/app/src/assets/style/base.css similarity index 100% rename from app/src/style.css rename to app/src/assets/style/base.css diff --git a/app/src/components/icons/send.vue b/app/src/components/icons/post.vue similarity index 100% rename from app/src/components/icons/send.vue rename to app/src/components/icons/post.vue diff --git a/app/src/main.ts b/app/src/main.ts index fd96715..cbad96d 100644 --- a/app/src/main.ts +++ b/app/src/main.ts @@ -1,5 +1,5 @@ import { createApp } from 'vue' -import './style.css' +import './assets/style/base.css' import App from './App.vue' import router from "../router"; diff --git a/app/views/HomeView.vue b/app/views/HomeView.vue index 7199bf4..4f51eda 100644 --- a/app/views/HomeView.vue +++ b/app/views/HomeView.vue @@ -1,13 +1,49 @@