From f0f19687b0382b16d7d161541bc2c8b3994a0676 Mon Sep 17 00:00:00 2001 From: riqo Date: Thu, 3 Dec 2020 16:32:08 -0600 Subject: [PATCH] refactor messageItem functionality + update design add dynamic title bar updat Message object type --- src/background.ts | 46 ++--- src/components/AI/index.vue | 38 ++-- src/components/UI/UIDetails/messageItem.vue | 19 +- src/components/UI/UIDetails/messages.ts | 174 +++++++++--------- src/components/UI/index.vue | 4 +- .../audioRenderer/useAudioRenderer.ts | 53 ++++++ .../messageItem/useMessageItemAnims.ts | 5 +- .../messageItem/useMessageItemComp.ts | 77 ++++---- src/types/message/index.ts | 6 +- 9 files changed, 245 insertions(+), 177 deletions(-) create mode 100644 src/composables/audioRenderer/useAudioRenderer.ts diff --git a/src/background.ts b/src/background.ts index 8bcbbe3..c937b1b 100644 --- a/src/background.ts +++ b/src/background.ts @@ -19,7 +19,7 @@ import { SpeechRecorder } from "speech-recorder"; // }); // -const recorder = new SpeechRecorder({ sampleRate: 16000, framesPerBuffer: 320 }); +// const recorder = new SpeechRecorder({ sampleRate: 16000, framesPerBuffer: 320 }); // Keep a global reference of the window object, if you don't, the window will // be closed automatically when the JavaScript object is garbage collected. @@ -33,9 +33,9 @@ protocol.registerSchemesAsPrivileged([ function createWindow() { // Create the browser window. win = new BrowserWindow({ - width: 350, - height: 525, - resizable: false, + width: 450, + height: 1025, + resizable: true, webPreferences: { // Use pluginOptions.nodeIntegration, leave this alone // See nklayman.github.io/vue-cli-plugin-electron-builder/guide/security.html#node-integration for more info @@ -56,24 +56,26 @@ function createWindow() { win.loadURL("app://./index.html"); } - win.webContents.on('did-finish-load', () => { - if (win) { - recorder.start({ - onAudio: (audio: object, speech: boolean) => { - if (win) { - win.webContents.send('render-audio', { - audio: audio, - speech: speech - }) - } - if (speech) { - // TODO: send audio to crimata BE - // ws.send(audio); - } - } - }); - } - }) + // win.webContents.on('did-finish-load', () => { + // if (win) { + // recorder.start({ + // onAudio: (audio: object, speech: boolean) => { + // if (win) { + // win.setTitle("Listening..."); + // // win.webContents.send('render-audio', { + // // audio: audio, + // // speech: speech + // // }) + // if (speech) { + // win.setTitle("Recording..."); + // // TODO: send audio to crimata BE + // // ws.send(audio); + // } + // } + // } + // }); + // } + // }) win.on("closed", () => { win = null; diff --git a/src/components/AI/index.vue b/src/components/AI/index.vue index 87a2aa0..d263eb0 100644 --- a/src/components/AI/index.vue +++ b/src/components/AI/index.vue @@ -48,7 +48,7 @@ export default defineComponent({ let gradient; const radius = ref(0); const think = ref(false); - const aiOffset = ref(1.0); + const aiOffset = ref(0.7); const anime = inject("animejs"); let thinkAnimation; @@ -100,24 +100,24 @@ export default defineComponent({ } }); - watch(think, async (think, prevThink) => { - if (think) { - anime({ - targets: gradient, - cy: "0.7", - }); - thinkAnimation.play(); - } else { - thinkAnimation.pause(); - // thinkAnimation.reset(); - anime({ - targets: gradient, - cy: "1", - }); - - // thinkAnimation.reset(); - } - }); + // watch(think, async (think, prevThink) => { + // if (think) { + // anime({ + // targets: gradient, + // cy: "0.7", + // }); + // thinkAnimation.play(); + // } else { + // thinkAnimation.pause(); + // // thinkAnimation.reset(); + // anime({ + // targets: gradient, + // cy: "1", + // }); + // + // // thinkAnimation.reset(); + // } + // }); return { radius, aiOffset, diff --git a/src/components/UI/UIDetails/messageItem.vue b/src/components/UI/UIDetails/messageItem.vue index bbd4343..95049f8 100644 --- a/src/components/UI/UIDetails/messageItem.vue +++ b/src/components/UI/UIDetails/messageItem.vue @@ -1,21 +1,26 @@