feat: 删除多余的内容

This commit is contained in:
ChenZhaoYu 2023-02-09 15:18:30 +08:00
parent d796e10ec6
commit 93f4af22a2
15 changed files with 37 additions and 761 deletions

6
.env
View File

@ -1,3 +1,5 @@
OPENAI_API_KEY='' # OpenAI API Key
OPENAI_API_KEY='xxxx'
VITE_GLOB_API_URL='http://192.168.110.170:3002' # Glob API URL
VITE_GLOB_API_URL='http://localhost:3002'

View File

@ -1,2 +1,2 @@
# chatgpt-bot # ChatGPT Bot Web

View File

@ -1,6 +1,6 @@
{ {
"name": "chatgpt-bot", "name": "chatgpt-bot",
"version": "0.1.0", "version": "1.0.0",
"private": true, "private": true,
"scripts": { "scripts": {
"dev": "vite", "dev": "vite",
@ -12,21 +12,16 @@
"lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --fix --ignore-path .gitignore" "lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --fix --ignore-path .gitignore"
}, },
"dependencies": { "dependencies": {
"@vueuse/core": "^9.12.0",
"dayjs": "^1.11.7",
"naive-ui": "^2.34.3", "naive-ui": "^2.34.3",
"pinia": "^2.0.28",
"vue": "^3.2.45" "vue": "^3.2.45"
}, },
"devDependencies": { "devDependencies": {
"@antfu/eslint-config": "^0.35.2", "@antfu/eslint-config": "^0.35.2",
"@iconify/json": "^2.2.19",
"@iconify/vue": "^4.1.0", "@iconify/vue": "^4.1.0",
"@types/babel__core": "^7.20.0", "@types/babel__core": "^7.20.0",
"@types/express": "^4.17.17", "@types/express": "^4.17.17",
"@types/node": "^18.11.12", "@types/node": "^18.11.12",
"@vitejs/plugin-vue": "^4.0.0", "@vitejs/plugin-vue": "^4.0.0",
"@vitejs/plugin-vue-jsx": "^3.0.0",
"autoprefixer": "^10.4.13", "autoprefixer": "^10.4.13",
"axios": "^1.3.2", "axios": "^1.3.2",
"chatgpt": "^4.2.0", "chatgpt": "^4.2.0",
@ -34,13 +29,11 @@
"eslint": "^8.22.0", "eslint": "^8.22.0",
"esno": "^0.16.3", "esno": "^0.16.3",
"express": "^4.18.2", "express": "^4.18.2",
"less": "^4.1.3",
"npm-run-all": "^4.1.5", "npm-run-all": "^4.1.5",
"postcss": "^8.4.21", "postcss": "^8.4.21",
"prettier": "^2.7.1", "prettier": "^2.7.1",
"tailwindcss": "^3.2.6", "tailwindcss": "^3.2.6",
"typescript": "~4.7.4", "typescript": "~4.7.4",
"unplugin-icons": "^0.15.2",
"vite": "^4.0.0", "vite": "^4.0.0",
"vite-plugin-svg-icons": "^2.0.1", "vite-plugin-svg-icons": "^2.0.1",
"vue-tsc": "^1.0.12" "vue-tsc": "^1.0.12"

File diff suppressed because it is too large Load Diff

View File

@ -1,11 +1,11 @@
<script setup lang="ts"> <script setup lang="ts">
import { NConfigProvider, dateZhCN, zhCN } from 'naive-ui' import { NConfigProvider } from 'naive-ui'
import NaiveProvider from '@/components/NaiveProvider.vue' import { NaiveProvider } from '@/components'
import Chat from '@/views/Chat/index.vue' import Chat from '@/views/Chat/index.vue'
</script> </script>
<template> <template>
<NConfigProvider :locale="zhCN" :date-locale="dateZhCN" class="h-full" preflight-style-disabled> <NConfigProvider class="h-full" preflight-style-disabled>
<NaiveProvider> <NaiveProvider>
<div class="h-full p-4"> <div class="h-full p-4">
<Chat /> <Chat />

View File

@ -1,12 +1,9 @@
<script setup lang="ts"> <script setup lang="ts">
import { defineComponent, h } from 'vue' import { defineComponent, h } from 'vue'
import { NDialogProvider, NLoadingBarProvider, NMessageProvider, NNotificationProvider, useDialog, useLoadingBar, useMessage, useNotification } from 'naive-ui' import { NMessageProvider, useMessage } from 'naive-ui'
function registerNaiveTools() { function registerNaiveTools() {
window.$loadingBar = useLoadingBar()
window.$dialog = useDialog()
window.$message = useMessage() window.$message = useMessage()
window.$notification = useNotification()
} }
const NaiveProviderContent = defineComponent({ const NaiveProviderContent = defineComponent({
@ -21,14 +18,8 @@ const NaiveProviderContent = defineComponent({
</script> </script>
<template> <template>
<NLoadingBarProvider> <NMessageProvider>
<NDialogProvider> <slot />
<NNotificationProvider> <NaiveProviderContent />
<NMessageProvider> </NMessageProvider>
<slot />
<NaiveProviderContent />
</NMessageProvider>
</NNotificationProvider>
</NDialogProvider>
</NLoadingBarProvider>
</template> </template>

View File

@ -1,3 +1,4 @@
import NaiveProvider from './NaiveProvider.vue'
import SvgIcon from './SvgIcon.vue' import SvgIcon from './SvgIcon.vue'
export { SvgIcon } export { NaiveProvider, SvgIcon }

View File

@ -1,9 +1,8 @@
import 'virtual:svg-icons-register' import 'virtual:svg-icons-register'
import './styles/css/tailwind.css' import './styles/tailwind.css'
import './styles/less/global.less' import './styles/global.css'
import { createApp } from 'vue' import { createApp } from 'vue'
import { createPinia } from 'pinia'
import App from './App.vue' import App from './App.vue'
function injectMeta() { function injectMeta() {
@ -15,7 +14,6 @@ function injectMeta() {
function bootstrap() { function bootstrap() {
const app = createApp(App) const app = createApp(App)
injectMeta() injectMeta()
app.use(createPinia())
app.mount('#app') app.mount('#app')
} }

View File

@ -1,6 +1,3 @@
interface Window { interface Window {
$loadingBar?: import('naive-ui').LoadingBarProviderInst;
$dialog?: import('naive-ui').DialogProviderInst;
$message?: import('naive-ui').MessageProviderInst; $message?: import('naive-ui').MessageProviderInst;
$notification?: import('naive-ui').NotificationProviderInst;
} }

View File

@ -25,7 +25,7 @@ defineProps<Props>()
{{ date }} {{ date }}
</span> </span>
<div class="p-2 mt-2 rounded-md" :class="[user ? 'bg-[#d2f9d1]' : 'bg-[#f4f6f8]']"> <div class="p-2 mt-2 rounded-md" :class="[user ? 'bg-[#d2f9d1]' : 'bg-[#f4f6f8]']">
<span class="leading-relaxed" :class="error ?? 'text-red-500'" v-html="message" /> <span class="leading-relaxed" :class="[{ 'text-red-500': error }]" v-html="message" />
</div> </div>
</div> </div>
</div> </div>

View File

@ -96,7 +96,12 @@ function addMessage(message: string, user = false, error = 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" placeholder="Type a message" :disabled="loading" @keyup="handleEnter" /> <NInput
v-model:value="value"
placeholder="Type a message"
:disabled="loading"
@keyup="handleEnter"
/>
<NButton type="primary" :loading="loading" @click="handleSubmit"> <NButton type="primary" :loading="loading" @click="handleSubmit">
<SvgIcon icon="ri:send-plane-fill" /> <SvgIcon icon="ri:send-plane-fill" />
</NButton> </NButton>

View File

@ -1,12 +1,14 @@
import axios from 'axios' import axios from 'axios'
async function fetchChatAPI(message: string) { async function fetchChatAPI(message: string) {
const url = `${import.meta.env.VITE_GLOB_API_URL}/chat`
if (!message || message.trim() === '') if (!message || message.trim() === '')
return Promise.reject(new Error('Message is empty')) return Promise.reject(new Error('Message is empty'))
try { try {
const { status, data } = await axios.post( const { status, data } = await axios.post(
'http://192.168.110.170:3002/chat', url,
{ message }, { message },
) )

View File

@ -1,7 +1,6 @@
import path from 'path' import path from 'path'
import { defineConfig } from 'vite' import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue' import vue from '@vitejs/plugin-vue'
import vueJsx from '@vitejs/plugin-vue-jsx'
import { createSvgIconsPlugin } from 'vite-plugin-svg-icons' import { createSvgIconsPlugin } from 'vite-plugin-svg-icons'
export default defineConfig(() => { export default defineConfig(() => {
@ -12,7 +11,7 @@ export default defineConfig(() => {
'@': path.resolve(process.cwd(), 'src'), '@': path.resolve(process.cwd(), 'src'),
}, },
}, },
plugins: [vue(), vueJsx(), createSvgIconsPlugin({ plugins: [vue(), createSvgIconsPlugin({
iconDirs: [path.resolve(process.cwd(), 'src/icons')], iconDirs: [path.resolve(process.cwd(), 'src/icons')],
symbolId: 'icon-local-[dir]-[name]', symbolId: 'icon-local-[dir]-[name]',
inject: 'body-last', inject: 'body-last',