Skip to content

Commit

Permalink
pref: 优化部份内容
Browse files Browse the repository at this point in the history
  • Loading branch information
Chanzhaoyu committed Feb 9, 2023
1 parent 93f4af2 commit 36eff8a
Show file tree
Hide file tree
Showing 8 changed files with 107 additions and 44 deletions.
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,21 @@
# ChatGPT Bot Web

This is a ChatGPT web application demo with express and vue3

![cover](./docs/cover.png)
## Intro
1. `node >= 18`
1. `pnpm install` node deps
2. set `OPENAI_API_KEY` in `.env`

## Run
```shell
# 1. run service
pnpm run service

# 2. run web
pnpm run dev
```

## License
MIT © [ChenZhaoYu](./license)
Binary file added docs/cover.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 0 additions & 1 deletion env.d.ts

This file was deleted.

21 changes: 21 additions & 0 deletions license
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2023 ChenZhaoYu

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
86 changes: 47 additions & 39 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,41 +1,49 @@
{
"name": "chatgpt-bot",
"version": "1.0.0",
"private": true,
"scripts": {
"dev": "vite",
"service": "esno ./service/index.ts",
"build": "run-p type-check build-only",
"preview": "vite preview",
"build-only": "vite build",
"type-check": "vue-tsc --noEmit",
"lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --fix --ignore-path .gitignore"
},
"dependencies": {
"naive-ui": "^2.34.3",
"vue": "^3.2.45"
},
"devDependencies": {
"@antfu/eslint-config": "^0.35.2",
"@iconify/vue": "^4.1.0",
"@types/babel__core": "^7.20.0",
"@types/express": "^4.17.17",
"@types/node": "^18.11.12",
"@vitejs/plugin-vue": "^4.0.0",
"autoprefixer": "^10.4.13",
"axios": "^1.3.2",
"chatgpt": "^4.2.0",
"dotenv": "^16.0.3",
"eslint": "^8.22.0",
"esno": "^0.16.3",
"express": "^4.18.2",
"npm-run-all": "^4.1.5",
"postcss": "^8.4.21",
"prettier": "^2.7.1",
"tailwindcss": "^3.2.6",
"typescript": "~4.7.4",
"vite": "^4.0.0",
"vite-plugin-svg-icons": "^2.0.1",
"vue-tsc": "^1.0.12"
}
"name": "chatgpt-bot",
"version": "1.0.0",
"description": "ChatGPT Web Bot",
"author": "ChenZhaoYu <[email protected]>",
"private": false,
"keywords": [
"chatgpt",
"chatbot",
"web",
"vue"
],
"scripts": {
"dev": "vite",
"service": "esno ./service/index.ts",
"build": "run-p type-check build-only",
"preview": "vite preview",
"build-only": "vite build",
"type-check": "vue-tsc --noEmit",
"lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --fix --ignore-path .gitignore"
},
"dependencies": {
"naive-ui": "^2.34.3",
"vue": "^3.2.45"
},
"devDependencies": {
"@antfu/eslint-config": "^0.35.2",
"@iconify/vue": "^4.1.0",
"@types/babel__core": "^7.20.0",
"@types/express": "^4.17.17",
"@types/node": "^18.11.12",
"@vitejs/plugin-vue": "^4.0.0",
"autoprefixer": "^10.4.13",
"axios": "^1.3.2",
"chatgpt": "^4.2.0",
"dotenv": "^16.0.3",
"eslint": "^8.22.0",
"esno": "^0.16.3",
"express": "^4.18.2",
"npm-run-all": "^4.1.5",
"postcss": "^8.4.21",
"prettier": "^2.7.1",
"tailwindcss": "^3.2.6",
"typescript": "~4.7.4",
"vite": "^4.0.0",
"vite-plugin-svg-icons": "^2.0.1",
"vue-tsc": "^1.0.12"
}
}
14 changes: 12 additions & 2 deletions src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,18 @@ import Chat from '@/views/Chat/index.vue'
<template>
<NConfigProvider class="h-full" preflight-style-disabled>
<NaiveProvider>
<div class="h-full p-4">
<Chat />
<div class="flex flex-col h-full p-4">
<div class="flex-1">
<div class="container h-full m-auto">
<Chat />
</div>
</div>
<div class="px-4 mt-4 text-sm text-center text-neutral-500">
Made By ChenZhaoYu
<a href="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/Chanzhaoyu/chatgpt-bot" target="_blank" class="text-blue-500">
Github
</a>
</div>
</div>
</NaiveProvider>
</NConfigProvider>
Expand Down
2 changes: 2 additions & 0 deletions src/typings/env.d.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/// <reference types="vite/client" />

interface ImportMetaEnv {
/** api url */
readonly VITE_GLOB_API_URL: string;
Expand Down
8 changes: 6 additions & 2 deletions src/views/Chat/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,9 @@ function addMessage(message: string, user = false, error = false) {
<template>
<div class="flex flex-col h-full overflow-hidden border rounded-md shadow-md">
<header class="flex items-center justify-between p-4">
<div>会话</div>
<h1 class="text-xl font-bold">
Chat
</h1>
<div>
<button
class="w-[40px] h-[40px] rounded-full hover:bg-neutral-100 transition flex justify-center items-center"
Expand Down Expand Up @@ -103,7 +105,9 @@ function addMessage(message: string, user = false, error = false) {
@keyup="handleEnter"
/>
<NButton type="primary" :loading="loading" @click="handleSubmit">
<SvgIcon icon="ri:send-plane-fill" />
<template #icon>
<SvgIcon icon="ri:send-plane-fill" />
</template>
</NButton>
</div>
</footer>
Expand Down

0 comments on commit 36eff8a

Please sign in to comment.