Skip to content

Commit 36eff8a

Browse files
committed
pref: 优化部份内容
1 parent 93f4af2 commit 36eff8a

File tree

8 files changed

+107
-44
lines changed

8 files changed

+107
-44
lines changed

README.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,21 @@
11
# ChatGPT Bot Web
22

3+
This is a ChatGPT web application demo with express and vue3
4+
5+
![cover](./docs/cover.png)
6+
## Intro
7+
1. `node >= 18`
8+
1. `pnpm install` node deps
9+
2. set `OPENAI_API_KEY` in `.env`
10+
11+
## Run
12+
```shell
13+
# 1. run service
14+
pnpm run service
15+
16+
# 2. run web
17+
pnpm run dev
18+
```
19+
20+
## License
21+
MIT © [ChenZhaoYu](./license)

docs/cover.png

91.5 KB
Loading

env.d.ts

Lines changed: 0 additions & 1 deletion
This file was deleted.

license

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2023 ChenZhaoYu
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

package.json

Lines changed: 47 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,49 @@
11
{
2-
"name": "chatgpt-bot",
3-
"version": "1.0.0",
4-
"private": true,
5-
"scripts": {
6-
"dev": "vite",
7-
"service": "esno ./service/index.ts",
8-
"build": "run-p type-check build-only",
9-
"preview": "vite preview",
10-
"build-only": "vite build",
11-
"type-check": "vue-tsc --noEmit",
12-
"lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --fix --ignore-path .gitignore"
13-
},
14-
"dependencies": {
15-
"naive-ui": "^2.34.3",
16-
"vue": "^3.2.45"
17-
},
18-
"devDependencies": {
19-
"@antfu/eslint-config": "^0.35.2",
20-
"@iconify/vue": "^4.1.0",
21-
"@types/babel__core": "^7.20.0",
22-
"@types/express": "^4.17.17",
23-
"@types/node": "^18.11.12",
24-
"@vitejs/plugin-vue": "^4.0.0",
25-
"autoprefixer": "^10.4.13",
26-
"axios": "^1.3.2",
27-
"chatgpt": "^4.2.0",
28-
"dotenv": "^16.0.3",
29-
"eslint": "^8.22.0",
30-
"esno": "^0.16.3",
31-
"express": "^4.18.2",
32-
"npm-run-all": "^4.1.5",
33-
"postcss": "^8.4.21",
34-
"prettier": "^2.7.1",
35-
"tailwindcss": "^3.2.6",
36-
"typescript": "~4.7.4",
37-
"vite": "^4.0.0",
38-
"vite-plugin-svg-icons": "^2.0.1",
39-
"vue-tsc": "^1.0.12"
40-
}
2+
"name": "chatgpt-bot",
3+
"version": "1.0.0",
4+
"description": "ChatGPT Web Bot",
5+
"author": "ChenZhaoYu <[email protected]>",
6+
"private": false,
7+
"keywords": [
8+
"chatgpt",
9+
"chatbot",
10+
"web",
11+
"vue"
12+
],
13+
"scripts": {
14+
"dev": "vite",
15+
"service": "esno ./service/index.ts",
16+
"build": "run-p type-check build-only",
17+
"preview": "vite preview",
18+
"build-only": "vite build",
19+
"type-check": "vue-tsc --noEmit",
20+
"lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --fix --ignore-path .gitignore"
21+
},
22+
"dependencies": {
23+
"naive-ui": "^2.34.3",
24+
"vue": "^3.2.45"
25+
},
26+
"devDependencies": {
27+
"@antfu/eslint-config": "^0.35.2",
28+
"@iconify/vue": "^4.1.0",
29+
"@types/babel__core": "^7.20.0",
30+
"@types/express": "^4.17.17",
31+
"@types/node": "^18.11.12",
32+
"@vitejs/plugin-vue": "^4.0.0",
33+
"autoprefixer": "^10.4.13",
34+
"axios": "^1.3.2",
35+
"chatgpt": "^4.2.0",
36+
"dotenv": "^16.0.3",
37+
"eslint": "^8.22.0",
38+
"esno": "^0.16.3",
39+
"express": "^4.18.2",
40+
"npm-run-all": "^4.1.5",
41+
"postcss": "^8.4.21",
42+
"prettier": "^2.7.1",
43+
"tailwindcss": "^3.2.6",
44+
"typescript": "~4.7.4",
45+
"vite": "^4.0.0",
46+
"vite-plugin-svg-icons": "^2.0.1",
47+
"vue-tsc": "^1.0.12"
48+
}
4149
}

src/App.vue

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,18 @@ import Chat from '@/views/Chat/index.vue'
77
<template>
88
<NConfigProvider class="h-full" preflight-style-disabled>
99
<NaiveProvider>
10-
<div class="h-full p-4">
11-
<Chat />
10+
<div class="flex flex-col h-full p-4">
11+
<div class="flex-1">
12+
<div class="container h-full m-auto">
13+
<Chat />
14+
</div>
15+
</div>
16+
<div class="px-4 mt-4 text-sm text-center text-neutral-500">
17+
Made By ChenZhaoYu
18+
<a href="https://github.com/Chanzhaoyu/chatgpt-bot" target="_blank" class="text-blue-500">
19+
Github
20+
</a>
21+
</div>
1222
</div>
1323
</NaiveProvider>
1424
</NConfigProvider>

src/typings/env.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
/// <reference types="vite/client" />
2+
13
interface ImportMetaEnv {
24
/** api url */
35
readonly VITE_GLOB_API_URL: string;

src/views/Chat/index.vue

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,9 @@ function addMessage(message: string, user = false, error = false) {
7474
<template>
7575
<div class="flex flex-col h-full overflow-hidden border rounded-md shadow-md">
7676
<header class="flex items-center justify-between p-4">
77-
<div>会话</div>
77+
<h1 class="text-xl font-bold">
78+
Chat
79+
</h1>
7880
<div>
7981
<button
8082
class="w-[40px] h-[40px] rounded-full hover:bg-neutral-100 transition flex justify-center items-center"
@@ -103,7 +105,9 @@ function addMessage(message: string, user = false, error = false) {
103105
@keyup="handleEnter"
104106
/>
105107
<NButton type="primary" :loading="loading" @click="handleSubmit">
106-
<SvgIcon icon="ri:send-plane-fill" />
108+
<template #icon>
109+
<SvgIcon icon="ri:send-plane-fill" />
110+
</template>
107111
</NButton>
108112
</div>
109113
</footer>

0 commit comments

Comments
 (0)