Compare commits

7 Commits

Author SHA1 Message Date
ChenZhaoYu
98e75c0c5c chore: release v1.0.5 2023-02-12 10:40:22 +08:00
ChenZhaoYu
06fd5a861c chore: CHANGELOG.md 2023-02-12 10:38:17 +08:00
ChenZhaoYu
fc0d2073aa chore: 默认 MD 文件 2023-02-12 10:34:51 +08:00
ChenZhaoYu
2c816afbd2 pref: 取消 disabled 以使 input 焦点连续输入 2023-02-12 10:29:21 +08:00
ChenZhaoYu
1bf2399a45 feat: chat 回复样式错误 2023-02-12 10:28:35 +08:00
Redon
ddec57f562 Merge pull request #6 from jjm2473/patch-1
fix: 防止中文输入法输入英文时触发提交
2023-02-12 10:24:04 +08:00
练亮斌
63af4a8e97 fix: 防止中文输入法输入英文时触发提交
部分输入法支持中英文混输,输入过程中按空格选择中文,按回车把当前的英文直接上屏。

至少在Chrome浏览器中,会把输入法选英文词的回车作为keyup事件,导致未输入完成的句子被提交。改成监听keypress事件就没问题了。
其他浏览器未测试。
2023-02-11 23:51:09 +08:00
8 changed files with 73 additions and 60 deletions

View File

@@ -1,3 +1,14 @@
## v1.0.5
`2023-02-12`
### Enhancement
- 输入框焦点,连续提交
### BugFix
- 修复信息框样式问题
- 修复中文输入法提交问题
## v1.0.4 ## v1.0.4
`2023-02-11` `2023-02-11`

39
README.en.md Normal file
View File

@@ -0,0 +1,39 @@
# ChatGPT Web Bot
[中文](./README.md) | English
ChartGPT demo page built with express and vue3
![cover](./docs/cover.png)
## Usage
> Make sure `node >= 18`
If pnpm is not installed
```shell
npm install pnpm -g
```
install node deps
```shell
pnpm install
```
Sign up for an [OpenAI API key](https://platform.openai.com/overview) and store it in your environment.
```
# .env
OPENAI_API_KEY="Your Key"
```
Run service
```shell
pnpm run service
```
Run web
```shell
pnpm run dev
```
## License

View File

@@ -1,36 +1,37 @@
# ChatGPT Web Bot # ChatGPT Web Bot
English | [中文](./README.zh-CN.md) 中文 | [English](./README.en.md)
ChartGPT demo page built with express and vue3 使用 express vue3 搭建的 ChartGPT 演示网页
![cover](./docs/cover.png) ![cover](./docs/cover.png)
## Usage
> Make sure `node >= 18`
If pnpm is not installed ## 使用
> 确保 `node >= 18`
如果你没有安装过 `pnpm`
```shell ```shell
npm install pnpm -g npm install pnpm -g
``` ```
install node deps 安装依赖
```shell ```shell
pnpm install pnpm install
``` ```
Sign up for an [OpenAI API key](https://platform.openai.com/overview) and store it in your environment. 获取 [OpenAI API key](https://platform.openai.com/overview) 到本地环境变量
``` ```
# .env # .env
OPENAI_API_KEY="Your Key" OPENAI_API_KEY="Your Key"
``` ```
Run service 运行服务
```shell ```shell
pnpm run service pnpm run service
``` ```
Run web 运行网页
```shell ```shell
pnpm run dev pnpm run dev
``` ```

View File

@@ -1,40 +0,0 @@
# ChatGPT Web Bot
[English](./README.md) | 中文
使用 express 和 vue3 搭建的 ChartGPT 演示网页
![cover](./docs/cover.png)
## 使用
> Make sure `node >= 18`
如果你没有安装过 `pnpm`
```shell
npm install pnpm -g
```
安装依赖
```shell
pnpm install
```
获取 [OpenAI API key](https://platform.openai.com/overview) 到本地环境变量
```
# .env
OPENAI_API_KEY="Your Key"
```
运行服务
```shell
pnpm run service
```
运行网页
```shell
pnpm run dev
```
## License
MIT © [ChenZhaoYu](./license)

View File

@@ -1,6 +1,6 @@
{ {
"name": "chatgpt-web", "name": "chatgpt-web",
"version": "1.0.4", "version": "1.0.5",
"private": false, "private": false,
"description": "ChatGPT Web Bot", "description": "ChatGPT Web Bot",
"author": "ChenZhaoYu <chenzhaoyu1994@gami.com>", "author": "ChenZhaoYu <chenzhaoyu1994@gami.com>",

6
pnpm-lock.yaml generated
View File

@@ -1412,8 +1412,8 @@ packages:
fsevents: 2.3.2 fsevents: 2.3.2
dev: true dev: true
/ci-info/3.7.1: /ci-info/3.8.0:
resolution: {integrity: sha512-4jYS4MOAaCIStSRwiuxc4B8MYhIe676yO1sYGzARnjXkWpmzZMMYxY6zu8WYWDhSuth5zhrQ1rhNSibyyvv4/w==} resolution: {integrity: sha512-eXTggHWSooYhq49F2opQhuHWgzucfF2YgODK4e1566GQs5BIfP30B0oenwBJHfWxAs2fyPB1s7Mg949zLf61Yw==}
engines: {node: '>=8'} engines: {node: '>=8'}
dev: true dev: true
@@ -2030,7 +2030,7 @@ packages:
dependencies: dependencies:
'@babel/helper-validator-identifier': 7.19.1 '@babel/helper-validator-identifier': 7.19.1
'@eslint-community/eslint-utils': 4.1.2_eslint@8.34.0 '@eslint-community/eslint-utils': 4.1.2_eslint@8.34.0
ci-info: 3.7.1 ci-info: 3.8.0
clean-regexp: 1.0.0 clean-regexp: 1.0.0
eslint: 8.34.0 eslint: 8.34.0
esquery: 1.4.0 esquery: 1.4.0

View File

@@ -19,7 +19,7 @@ defineProps<Props>()
> >
<Avatar :image="reversal" /> <Avatar :image="reversal" />
</div> </div>
<div class="flex flex-col flex-1 text-sm" :class="[{ 'items-end': reversal }]"> <div class="flex flex-col flex-1 text-sm" :class="[reversal ? 'items-end' : 'items-start']">
<span class="text-xs text-[#b4bbc4]"> <span class="text-xs text-[#b4bbc4]">
{{ dateTime }} {{ dateTime }}
</span> </span>

View File

@@ -15,7 +15,7 @@ const scrollRef = ref<HTMLDivElement>()
const ms = useMessage() const ms = useMessage()
const value = ref('') const prompt = ref('')
const loading = ref(false) const loading = ref(false)
@@ -45,17 +45,19 @@ function handleEnter(event: KeyboardEvent) {
} }
async function handleSubmit() { async function handleSubmit() {
if (!value.value) { const message = prompt.value.trim()
if (!message || !message.length) {
ms.warning('Please enter a message') ms.warning('Please enter a message')
return return
} }
addMessage(value.value, true) addMessage(message, true)
prompt.value = ''
try { try {
loading.value = true loading.value = true
const { text } = await fetchChatAPI(value.value) const { text } = await fetchChatAPI(message)
value.value = ''
addMessage(text, false) addMessage(text, false)
} }
catch (error: any) { catch (error: any) {
@@ -104,7 +106,7 @@ function addMessage(message: string, reversal = false) {
</main> </main>
<footer class="p-4"> <footer class="p-4">
<div class="flex items-center justify-between space-x-2"> <div class="flex items-center justify-between space-x-2">
<NInput v-model:value="value" :disabled="loading" placeholder="Type a message..." @keyup="handleEnter" /> <NInput v-model:value="prompt" placeholder="Type a message..." @keypress="handleEnter" />
<NButton type="primary" :loading="loading" @click="handleSubmit"> <NButton type="primary" :loading="loading" @click="handleSubmit">
<template #icon> <template #icon>
<Icon icon="ri:send-plane-fill" /> <Icon icon="ri:send-plane-fill" />