Compare commits

..

2 Commits

Author SHA1 Message Date
Wong Saang
65629ca5a6 Merge pull request #2 from Afeigege/main
fix: Send button doesn't work, input box doesn't wrap on mobile
2023-02-13 12:57:11 +08:00
Afeigege
f64a45c0ee fix: Send button doesn't work, input box doesn't wrap on mobile 2023-02-13 12:47:30 +08:00
4 changed files with 34 additions and 9 deletions

View File

@@ -1,21 +1,21 @@
<template> <template>
<v-textarea <v-textarea
v-model="message" v-model="message"
clearable label="Write a message..."
label="Message" placeholder="Write a message..."
placeholder="Type your message here"
rows="1" rows="1"
:auto-grow="autoGrow" :auto-grow="autoGrow"
:disabled="disabled" :disabled="disabled"
:loading="loading" :loading="loading"
hide-details :hint="hint"
append-inner-icon="send" append-inner-icon="send"
@keyup.enter="send" @keyup.enter.exact="enterOnly"
@click:append="send" @click:appendInner="clickSendBtn"
></v-textarea> ></v-textarea>
</template> </template>
<script> <script>
import { isMobile } from 'is-mobile'
export default { export default {
name: "MsgEditor", name: "MsgEditor",
props: { props: {
@@ -30,6 +30,11 @@ export default {
autoGrow: true, autoGrow: true,
}; };
}, },
computed: {
hint() {
return isMobile() ? "" : "Press Enter to send your message or Shift+Enter to add a new line.";
},
},
watch: { watch: {
message(val) { message(val) {
const lines = val.split(/\r\n|\r|\n/).length; const lines = val.split(/\r\n|\r|\n/).length;
@@ -44,10 +49,24 @@ export default {
}, },
methods: { methods: {
send() { send() {
const msg = this.message let msg = this.message
// remove the last "\n"
if (msg[msg.length - 1] === "\n") {
msg = msg.slice(0, -1)
}
if (msg.length > 0) {
this.sendMessage(msg)
}
this.message = "" this.message = ""
this.sendMessage(msg);
}, },
clickSendBtn () {
this.send()
},
enterOnly () {
if (!isMobile()) {
this.send()
}
}
}, },
} }
</script> </script>

View File

@@ -17,6 +17,7 @@
"@microsoft/fetch-event-source": "^2.0.1", "@microsoft/fetch-event-source": "^2.0.1",
"@waylaidwanderer/chatgpt-api": "^1.12.2", "@waylaidwanderer/chatgpt-api": "^1.12.2",
"highlight.js": "^11.7.0", "highlight.js": "^11.7.0",
"is-mobile": "^3.1.1",
"marked": "^4.2.12", "marked": "^4.2.12",
"vuetify": "^3.0.6" "vuetify": "^3.0.6"
} }

View File

@@ -112,7 +112,7 @@ createNewConversation()
elevation="0" elevation="0"
v-for="(conversation, index) in currentConversation.messages" v-for="(conversation, index) in currentConversation.messages"
:key="index" :key="index"
:variant="conversation.from === 'ai' ? 'tonal' : ''" :variant="conversation.from === 'ai' ? 'tonal' : 'text'"
> >
<v-container> <v-container>
<v-card-text class="text-caption text-disabled">{{ conversation.from }}</v-card-text> <v-card-text class="text-caption text-disabled">{{ conversation.from }}</v-card-text>

View File

@@ -2887,6 +2887,11 @@ is-lambda@^1.0.1:
resolved "https://registry.npmmirror.com/is-lambda/-/is-lambda-1.0.1.tgz#3d9877899e6a53efc0160504cde15f82e6f061d5" resolved "https://registry.npmmirror.com/is-lambda/-/is-lambda-1.0.1.tgz#3d9877899e6a53efc0160504cde15f82e6f061d5"
integrity sha512-z7CMFGNrENq5iFB9Bqo64Xk6Y9sg+epq1myIcdHaGnbMTYOxvzsEtdYqQUylB7LxfkvgrrjP32T6Ywciio9UIQ== integrity sha512-z7CMFGNrENq5iFB9Bqo64Xk6Y9sg+epq1myIcdHaGnbMTYOxvzsEtdYqQUylB7LxfkvgrrjP32T6Ywciio9UIQ==
is-mobile@^3.1.1:
version "3.1.1"
resolved "https://registry.npmmirror.com/is-mobile/-/is-mobile-3.1.1.tgz#3b9e48f40068e4ea2da411f5009779844ce8d6aa"
integrity sha512-RRoXXR2HNFxNkUnxtaBdGBXtFlUMFa06S0NUKf/LCF+MuGLu13gi9iBCkoEmc6+rpXuwi5Mso5V8Zf7mNynMBQ==
is-module@^1.0.0: is-module@^1.0.0:
version "1.0.0" version "1.0.0"
resolved "https://registry.npmmirror.com/is-module/-/is-module-1.0.0.tgz#3258fb69f78c14d5b815d664336b4cffb6441591" resolved "https://registry.npmmirror.com/is-module/-/is-module-1.0.0.tgz#3258fb69f78c14d5b815d664336b4cffb6441591"