mirror of
https://github.com/Chanzhaoyu/chatgpt-web.git
synced 2025-07-21 11:57:47 +00:00
feat: 删除多余的内容
This commit is contained in:
@@ -1,11 +1,11 @@
|
||||
<script setup lang="ts">
|
||||
import { NConfigProvider, dateZhCN, zhCN } from 'naive-ui'
|
||||
import NaiveProvider from '@/components/NaiveProvider.vue'
|
||||
import { NConfigProvider } from 'naive-ui'
|
||||
import { NaiveProvider } from '@/components'
|
||||
import Chat from '@/views/Chat/index.vue'
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<NConfigProvider :locale="zhCN" :date-locale="dateZhCN" class="h-full" preflight-style-disabled>
|
||||
<NConfigProvider class="h-full" preflight-style-disabled>
|
||||
<NaiveProvider>
|
||||
<div class="h-full p-4">
|
||||
<Chat />
|
||||
|
@@ -1,12 +1,9 @@
|
||||
<script setup lang="ts">
|
||||
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() {
|
||||
window.$loadingBar = useLoadingBar()
|
||||
window.$dialog = useDialog()
|
||||
window.$message = useMessage()
|
||||
window.$notification = useNotification()
|
||||
}
|
||||
|
||||
const NaiveProviderContent = defineComponent({
|
||||
@@ -21,14 +18,8 @@ const NaiveProviderContent = defineComponent({
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<NLoadingBarProvider>
|
||||
<NDialogProvider>
|
||||
<NNotificationProvider>
|
||||
<NMessageProvider>
|
||||
<slot />
|
||||
<NaiveProviderContent />
|
||||
</NMessageProvider>
|
||||
</NNotificationProvider>
|
||||
</NDialogProvider>
|
||||
</NLoadingBarProvider>
|
||||
<NMessageProvider>
|
||||
<slot />
|
||||
<NaiveProviderContent />
|
||||
</NMessageProvider>
|
||||
</template>
|
||||
|
@@ -1,3 +1,4 @@
|
||||
import NaiveProvider from './NaiveProvider.vue'
|
||||
import SvgIcon from './SvgIcon.vue'
|
||||
|
||||
export { SvgIcon }
|
||||
export { NaiveProvider, SvgIcon }
|
||||
|
@@ -1,9 +1,8 @@
|
||||
import 'virtual:svg-icons-register'
|
||||
import './styles/css/tailwind.css'
|
||||
import './styles/less/global.less'
|
||||
import './styles/tailwind.css'
|
||||
import './styles/global.css'
|
||||
|
||||
import { createApp } from 'vue'
|
||||
import { createPinia } from 'pinia'
|
||||
import App from './App.vue'
|
||||
|
||||
function injectMeta() {
|
||||
@@ -15,7 +14,6 @@ function injectMeta() {
|
||||
function bootstrap() {
|
||||
const app = createApp(App)
|
||||
injectMeta()
|
||||
app.use(createPinia())
|
||||
app.mount('#app')
|
||||
}
|
||||
|
||||
|
3
src/typings/global.d.ts
vendored
3
src/typings/global.d.ts
vendored
@@ -1,6 +1,3 @@
|
||||
interface Window {
|
||||
$loadingBar?: import('naive-ui').LoadingBarProviderInst;
|
||||
$dialog?: import('naive-ui').DialogProviderInst;
|
||||
$message?: import('naive-ui').MessageProviderInst;
|
||||
$notification?: import('naive-ui').NotificationProviderInst;
|
||||
}
|
||||
|
@@ -25,7 +25,7 @@ defineProps<Props>()
|
||||
{{ date }}
|
||||
</span>
|
||||
<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>
|
||||
|
@@ -96,7 +96,12 @@ function addMessage(message: string, user = false, error = false) {
|
||||
</main>
|
||||
<footer class="p-4">
|
||||
<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">
|
||||
<SvgIcon icon="ri:send-plane-fill" />
|
||||
</NButton>
|
||||
|
@@ -1,12 +1,14 @@
|
||||
import axios from 'axios'
|
||||
|
||||
async function fetchChatAPI(message: string) {
|
||||
const url = `${import.meta.env.VITE_GLOB_API_URL}/chat`
|
||||
|
||||
if (!message || message.trim() === '')
|
||||
return Promise.reject(new Error('Message is empty'))
|
||||
|
||||
try {
|
||||
const { status, data } = await axios.post(
|
||||
'http://192.168.110.170:3002/chat',
|
||||
url,
|
||||
{ message },
|
||||
)
|
||||
|
||||
|
Reference in New Issue
Block a user