Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
cc91e95eed | ||
|
|
abbdcf9c51 | ||
|
|
b6fd9ae766 | ||
|
|
1e2f893ef6 | ||
|
|
10058f151c | ||
|
|
09359c3c46 |
@@ -1 +0,0 @@
|
|||||||
VITE_GLOB_HTTP_PROXY=Y
|
|
||||||
40
CHANGELOG.md
40
CHANGELOG.md
@@ -1,3 +1,43 @@
|
|||||||
|
## v2.7.3
|
||||||
|
|
||||||
|
`2023-02-25`
|
||||||
|
|
||||||
|
### Feature
|
||||||
|
- 适配系统深色模式 [#118](https://github.com/Chanzhaoyu/chatgpt-web/issues/103)
|
||||||
|
### BugFix
|
||||||
|
- 修复用户消息能被渲染为 `HTML` 问题 [#117](https://github.com/Chanzhaoyu/chatgpt-web/issues/117)
|
||||||
|
|
||||||
|
## v2.7.2
|
||||||
|
|
||||||
|
`2023-02-24`
|
||||||
|
### Enhancement
|
||||||
|
- 消息使用 [github-markdown-css](https://www.npmjs.com/package/github-markdown-css) 进行美化,现在支持全语法
|
||||||
|
- 移除测试无用函数
|
||||||
|
|
||||||
|
## v2.7.1
|
||||||
|
|
||||||
|
`2023-02-23`
|
||||||
|
|
||||||
|
因为消息流在 `accessToken` 中存在解析失败和消息不完整等一系列的问题,调整回正常消息形式
|
||||||
|
|
||||||
|
### Feature
|
||||||
|
- 现在可以中断请求过长没有答复的消息
|
||||||
|
- 现在可以删除单条消息
|
||||||
|
- 设置中显示当前版本信息
|
||||||
|
|
||||||
|
### BugFix
|
||||||
|
- 回退 `2.7.0` 的消息不稳定的问题
|
||||||
|
|
||||||
|
## v2.7.0
|
||||||
|
|
||||||
|
`2023-02-23`
|
||||||
|
|
||||||
|
### Feature
|
||||||
|
- 使用消息流返回信息,反应更迅速
|
||||||
|
|
||||||
|
### Enhancement
|
||||||
|
- 样式的一点小改动
|
||||||
|
|
||||||
## v2.6.2
|
## v2.6.2
|
||||||
|
|
||||||
`2023-02-22`
|
`2023-02-22`
|
||||||
|
|||||||
@@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
> 使用 `express` 和 `vue3` 搭建的支持 `ChatGPT` 双模型演示网页
|
> 使用 `express` 和 `vue3` 搭建的支持 `ChatGPT` 双模型演示网页
|
||||||
|
|
||||||

|

|
||||||

|

|
||||||
|
|
||||||
- [ChatGPT Web](#chatgpt-web)
|
- [ChatGPT Web](#chatgpt-web)
|
||||||
- [介绍](#介绍)
|
- [介绍](#介绍)
|
||||||
|
|||||||
@@ -6,9 +6,9 @@ export function createViteProxy(isOpenProxy: boolean, viteEnv: ImportMetaEnv) {
|
|||||||
|
|
||||||
const proxy: Record<string, string | ProxyOptions> = {
|
const proxy: Record<string, string | ProxyOptions> = {
|
||||||
'/api': {
|
'/api': {
|
||||||
target: viteEnv.VITE_GLOB_API_URL,
|
target: viteEnv.VITE_APP_API_BASE_URL,
|
||||||
changeOrigin: true,
|
changeOrigin: true,
|
||||||
rewrite: path => path.replace(/^\/api/, ''),
|
rewrite: path => path.replace('/api/', '/'),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
BIN
docs/c1.png
Normal file
BIN
docs/c1.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 410 KiB |
BIN
docs/c2.png
Normal file
BIN
docs/c2.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.1 MiB |
@@ -61,6 +61,12 @@
|
|||||||
transform: translateX(100%);
|
transform: translateX(100%);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@media (prefers-color-scheme: dark) {
|
||||||
|
body {
|
||||||
|
background: #121212;
|
||||||
|
}
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
<div class="loading-wrap">
|
<div class="loading-wrap">
|
||||||
<div class="balls">
|
<div class="balls">
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "chatgpt-web",
|
"name": "chatgpt-web",
|
||||||
"version": "2.6.2",
|
"version": "2.7.3",
|
||||||
"private": false,
|
"private": false,
|
||||||
"description": "ChatGPT Web",
|
"description": "ChatGPT Web",
|
||||||
"author": "ChenZhaoYu <chenzhaoyu1994@gmail.com>",
|
"author": "ChenZhaoYu <chenzhaoyu1994@gmail.com>",
|
||||||
|
|||||||
@@ -15,6 +15,7 @@
|
|||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "esno ./src/index.ts",
|
"start": "esno ./src/index.ts",
|
||||||
|
"dev": "esno watch ./src/index.ts",
|
||||||
"prod": "esno ./build/index.js",
|
"prod": "esno ./build/index.js",
|
||||||
"build": "pnpm clean && tsup",
|
"build": "pnpm clean && tsup",
|
||||||
"clean": "rimraf build",
|
"clean": "rimraf build",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import * as dotenv from 'dotenv'
|
import * as dotenv from 'dotenv'
|
||||||
import 'isomorphic-fetch'
|
import 'isomorphic-fetch'
|
||||||
import type { ChatGPTAPI, SendMessageOptions } from 'chatgpt'
|
import type { ChatGPTAPI, ChatMessage, SendMessageOptions } from 'chatgpt'
|
||||||
import { ChatGPTUnofficialProxyAPI } from 'chatgpt'
|
import { ChatGPTUnofficialProxyAPI } from 'chatgpt'
|
||||||
import { sendResponse } from './utils'
|
import { sendResponse } from './utils'
|
||||||
|
|
||||||
@@ -8,7 +8,7 @@ dotenv.config()
|
|||||||
|
|
||||||
let apiModel: 'ChatGPTAPI' | 'ChatGPTUnofficialProxyAPI' | undefined
|
let apiModel: 'ChatGPTAPI' | 'ChatGPTUnofficialProxyAPI' | undefined
|
||||||
|
|
||||||
export interface ChatContext {
|
interface ChatContext {
|
||||||
conversationId?: string
|
conversationId?: string
|
||||||
parentMessageId?: string
|
parentMessageId?: string
|
||||||
}
|
}
|
||||||
@@ -76,4 +76,6 @@ async function chatConfig() {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export type { ChatContext, ChatMessage }
|
||||||
|
|
||||||
export { chatReply, chatConfig }
|
export { chatReply, chatConfig }
|
||||||
|
|||||||
@@ -1,10 +1,17 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { NConfigProvider } from 'naive-ui'
|
import { NConfigProvider } from 'naive-ui'
|
||||||
import { NaiveProvider } from '@/components/common'
|
import { NaiveProvider } from '@/components/common'
|
||||||
|
import { useTheme } from '@/hooks/useTheme'
|
||||||
|
|
||||||
|
const { theme, themeOverrides } = useTheme()
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<NConfigProvider class="h-full">
|
<NConfigProvider
|
||||||
|
class="h-full"
|
||||||
|
:theme="theme"
|
||||||
|
:theme-overrides="themeOverrides"
|
||||||
|
>
|
||||||
<NaiveProvider>
|
<NaiveProvider>
|
||||||
<RouterView />
|
<RouterView />
|
||||||
</NaiveProvider>
|
</NaiveProvider>
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ function handleClick() {
|
|||||||
|
|
||||||
<template>
|
<template>
|
||||||
<button
|
<button
|
||||||
class="flex items-center justify-center w-10 h-10 transition rounded-full hover:bg-neutral-100"
|
class="flex items-center justify-center w-10 h-10 transition rounded-full hover:bg-neutral-100 dark:hover:bg-[#414755]"
|
||||||
@click="handleClick"
|
@click="handleClick"
|
||||||
>
|
>
|
||||||
<slot />
|
<slot />
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
<script setup lang='ts'>
|
<script setup lang='ts'>
|
||||||
import { computed, ref, watch } from 'vue'
|
import { computed, ref, watch } from 'vue'
|
||||||
import { NCard, NModal } from 'naive-ui'
|
import { NCard, NModal } from 'naive-ui'
|
||||||
|
import pkg from '../../../../package.json'
|
||||||
import { fetchChatConfig } from '@/api'
|
import { fetchChatConfig } from '@/api'
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
@@ -55,9 +56,16 @@ watch(
|
|||||||
<NModal v-model:show="show" style="width: 80%; max-width: 460px;">
|
<NModal v-model:show="show" style="width: 80%; max-width: 460px;">
|
||||||
<NCard>
|
<NCard>
|
||||||
<div class="space-y-4">
|
<div class="space-y-4">
|
||||||
<h1 class="text-xl font-bold">
|
<h2 class="text-xl font-bold text-center">
|
||||||
当前后台设置
|
Version - {{ pkg.version }}
|
||||||
</h1>
|
</h2>
|
||||||
|
<hr>
|
||||||
|
<p>
|
||||||
|
此项目开源于
|
||||||
|
<a class="text-blue-600" href="https://github.com/Chanzhaoyu/chatgpt-web" target="_blank">Github</a>
|
||||||
|
如果你觉得此项目对你有帮助,请帮我点个 Star,谢谢!
|
||||||
|
</p>
|
||||||
|
<hr>
|
||||||
<p>API方式:{{ config?.apiModel ?? '-' }}</p>
|
<p>API方式:{{ config?.apiModel ?? '-' }}</p>
|
||||||
<p>反向代理:{{ config?.reverseProxy ?? '-' }}</p>
|
<p>反向代理:{{ config?.reverseProxy ?? '-' }}</p>
|
||||||
<p>超时时间:{{ config?.timeoutMs ?? '-' }}</p>
|
<p>超时时间:{{ config?.timeoutMs ?? '-' }}</p>
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="text-center text-neutral-500">
|
<div class="text-neutral-400">
|
||||||
<span>❤️ Star on</span>
|
<span>Star on</span>
|
||||||
<a href="https://github.com/Chanzhaoyu/chatgpt-bot" target="_blank" class="text-blue-500">
|
<a href="https://github.com/Chanzhaoyu/chatgpt-bot" target="_blank" class="text-blue-500">
|
||||||
GitHub
|
GitHub
|
||||||
</a>
|
</a>
|
||||||
|
|||||||
@@ -1,21 +0,0 @@
|
|||||||
import type { App, Directive } from 'vue'
|
|
||||||
import hljs from 'highlight.js'
|
|
||||||
import includeCode from '@/utils/functions/includeCode'
|
|
||||||
|
|
||||||
function highlightCode(el: HTMLElement) {
|
|
||||||
if (includeCode(el.textContent))
|
|
||||||
hljs.highlightBlock(el)
|
|
||||||
}
|
|
||||||
|
|
||||||
export default function setupHighlightDirective(app: App) {
|
|
||||||
const highLightDirective: Directive<HTMLElement> = {
|
|
||||||
mounted(el: HTMLElement) {
|
|
||||||
highlightCode(el)
|
|
||||||
},
|
|
||||||
updated(el: HTMLElement) {
|
|
||||||
highlightCode(el)
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
app.directive('highlight', highLightDirective)
|
|
||||||
}
|
|
||||||
@@ -1,6 +1 @@
|
|||||||
import type { App } from 'vue'
|
export function setupDirectives() {}
|
||||||
import setupHighlightDirective from './highlight'
|
|
||||||
|
|
||||||
export function setupDirectives(app: App) {
|
|
||||||
setupHighlightDirective(app)
|
|
||||||
}
|
|
||||||
|
|||||||
43
src/hooks/useTheme.ts
Normal file
43
src/hooks/useTheme.ts
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
import type { GlobalThemeOverrides } from 'naive-ui'
|
||||||
|
import { computed, watch } from 'vue'
|
||||||
|
import { darkTheme, useOsTheme } from 'naive-ui'
|
||||||
|
import { useAppStore } from '@/store'
|
||||||
|
|
||||||
|
export function useTheme() {
|
||||||
|
const appStore = useAppStore()
|
||||||
|
|
||||||
|
const OsTheme = useOsTheme()
|
||||||
|
|
||||||
|
const isDark = computed(() => {
|
||||||
|
if (appStore.theme === 'auto')
|
||||||
|
return OsTheme.value === 'dark'
|
||||||
|
else
|
||||||
|
return appStore.theme === 'dark'
|
||||||
|
})
|
||||||
|
|
||||||
|
const theme = computed(() => {
|
||||||
|
return isDark.value ? darkTheme : undefined
|
||||||
|
})
|
||||||
|
|
||||||
|
const themeOverrides = computed<GlobalThemeOverrides>(() => {
|
||||||
|
if (isDark.value) {
|
||||||
|
return {
|
||||||
|
common: {},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return {}
|
||||||
|
})
|
||||||
|
|
||||||
|
watch(
|
||||||
|
() => isDark.value,
|
||||||
|
(dark) => {
|
||||||
|
if (dark)
|
||||||
|
document.documentElement.classList.add('dark')
|
||||||
|
else
|
||||||
|
document.documentElement.classList.remove('dark')
|
||||||
|
},
|
||||||
|
{ immediate: true },
|
||||||
|
)
|
||||||
|
|
||||||
|
return { theme, themeOverrides }
|
||||||
|
}
|
||||||
@@ -1,6 +1,5 @@
|
|||||||
import { createApp } from 'vue'
|
import { createApp } from 'vue'
|
||||||
import App from './App.vue'
|
import App from './App.vue'
|
||||||
import { setupDirectives } from './directives'
|
|
||||||
import { setupAssets } from '@/plugins'
|
import { setupAssets } from '@/plugins'
|
||||||
import { setupStore } from '@/store'
|
import { setupStore } from '@/store'
|
||||||
import { setupRouter } from '@/router'
|
import { setupRouter } from '@/router'
|
||||||
@@ -11,8 +10,6 @@ async function bootstrap() {
|
|||||||
|
|
||||||
setupStore(app)
|
setupStore(app)
|
||||||
|
|
||||||
setupDirectives(app)
|
|
||||||
|
|
||||||
await setupRouter(app)
|
await setupRouter(app)
|
||||||
|
|
||||||
app.mount('#app')
|
app.mount('#app')
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
import 'highlight.js/styles/xcode.css'
|
import 'highlight.js/styles/xcode.css'
|
||||||
import '@/styles/global.css'
|
import '@/styles/lib/tailwind.css'
|
||||||
|
import '@/styles/lib/github-markdown.less'
|
||||||
|
import '@/styles/global.less'
|
||||||
|
|
||||||
/** Tailwind's Preflight Style Override */
|
/** Tailwind's Preflight Style Override */
|
||||||
function naiveStyleOverride() {
|
function naiveStyleOverride() {
|
||||||
|
|||||||
@@ -2,19 +2,22 @@ import { ss } from '@/utils/storage'
|
|||||||
|
|
||||||
const LOCAL_NAME = 'appSetting'
|
const LOCAL_NAME = 'appSetting'
|
||||||
|
|
||||||
|
export type Theme = 'light' | 'dark' | 'auto'
|
||||||
|
|
||||||
export interface AppState {
|
export interface AppState {
|
||||||
siderCollapsed: boolean
|
siderCollapsed: boolean
|
||||||
|
theme: Theme
|
||||||
}
|
}
|
||||||
|
|
||||||
export function defaultSetting() {
|
export function defaultSetting(): AppState {
|
||||||
return { siderCollapsed: false }
|
return { siderCollapsed: false, theme: 'light' }
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getLocalSetting() {
|
export function getLocalSetting(): AppState {
|
||||||
const localSetting: AppState | undefined = ss.get(LOCAL_NAME)
|
const localSetting: AppState | undefined = ss.get(LOCAL_NAME)
|
||||||
return localSetting ?? defaultSetting()
|
return { ...defaultSetting(), ...localSetting }
|
||||||
}
|
}
|
||||||
|
|
||||||
export function setLocalSetting(setting: AppState) {
|
export function setLocalSetting(setting: AppState): void {
|
||||||
ss.set(LOCAL_NAME, setting)
|
ss.set(LOCAL_NAME, setting)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { defineStore } from 'pinia'
|
import { defineStore } from 'pinia'
|
||||||
import type { AppState } from './helper'
|
import type { AppState, Theme } from './helper'
|
||||||
import { getLocalSetting, setLocalSetting } from './helper'
|
import { getLocalSetting, setLocalSetting } from './helper'
|
||||||
|
|
||||||
export const useAppStore = defineStore('app-store', {
|
export const useAppStore = defineStore('app-store', {
|
||||||
@@ -7,6 +7,15 @@ export const useAppStore = defineStore('app-store', {
|
|||||||
actions: {
|
actions: {
|
||||||
setSiderCollapsed(collapsed: boolean) {
|
setSiderCollapsed(collapsed: boolean) {
|
||||||
this.siderCollapsed = collapsed
|
this.siderCollapsed = collapsed
|
||||||
|
this.recordState()
|
||||||
|
},
|
||||||
|
|
||||||
|
setTheme(theme: Theme) {
|
||||||
|
this.theme = theme
|
||||||
|
this.recordState()
|
||||||
|
},
|
||||||
|
|
||||||
|
recordState() {
|
||||||
setLocalSetting(this.$state)
|
setLocalSetting(this.$state)
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -110,6 +110,22 @@ export const useChatStore = defineStore('chat-store', {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
deleteChatByUuid(uuid: number, index: number) {
|
||||||
|
if (!uuid || uuid === 0) {
|
||||||
|
if (this.chat.length) {
|
||||||
|
this.chat[0].data.splice(index, 1)
|
||||||
|
this.recordState()
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
const chatIndex = this.chat.findIndex(item => item.uuid === uuid)
|
||||||
|
if (chatIndex !== -1) {
|
||||||
|
this.chat[chatIndex].data.splice(index, 1)
|
||||||
|
this.recordState()
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
clearChatByUuid(uuid: number) {
|
clearChatByUuid(uuid: number) {
|
||||||
if (!uuid || uuid === 0) {
|
if (!uuid || uuid === 0) {
|
||||||
if (this.chat.length) {
|
if (this.chat.length) {
|
||||||
|
|||||||
5
src/styles/global.less
Normal file
5
src/styles/global.less
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
html,
|
||||||
|
body,
|
||||||
|
#app {
|
||||||
|
height: 100%;
|
||||||
|
}
|
||||||
1102
src/styles/lib/github-markdown.less
Normal file
1102
src/styles/lib/github-markdown.less
Normal file
File diff suppressed because it is too large
Load Diff
@@ -1,9 +1,3 @@
|
|||||||
@tailwind base;
|
@tailwind base;
|
||||||
@tailwind components;
|
@tailwind components;
|
||||||
@tailwind utilities;
|
@tailwind utilities;
|
||||||
|
|
||||||
html,
|
|
||||||
body,
|
|
||||||
#app {
|
|
||||||
height: 100%;
|
|
||||||
}
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
import type { AxiosResponse, GenericAbortSignal } from 'axios'
|
import type { AxiosProgressEvent, AxiosResponse, GenericAbortSignal } from 'axios'
|
||||||
import request from './axios'
|
import request from './axios'
|
||||||
|
|
||||||
export interface HttpOption {
|
export interface HttpOption {
|
||||||
@@ -6,6 +6,7 @@ export interface HttpOption {
|
|||||||
data?: any
|
data?: any
|
||||||
method?: string
|
method?: string
|
||||||
headers?: any
|
headers?: any
|
||||||
|
onDownloadProgress?: (progressEvent: AxiosProgressEvent) => void
|
||||||
signal?: GenericAbortSignal
|
signal?: GenericAbortSignal
|
||||||
beforeRequest?: () => void
|
beforeRequest?: () => void
|
||||||
afterRequest?: () => void
|
afterRequest?: () => void
|
||||||
@@ -17,9 +18,11 @@ export interface Response<T = any> {
|
|||||||
status: string
|
status: string
|
||||||
}
|
}
|
||||||
|
|
||||||
function http<T = any>({ url, data, method, headers, signal, beforeRequest, afterRequest }: HttpOption) {
|
function http<T = any>(
|
||||||
|
{ url, data, method, headers, onDownloadProgress, signal, beforeRequest, afterRequest }: HttpOption,
|
||||||
|
) {
|
||||||
const successHandler = (res: AxiosResponse<Response<T>>) => {
|
const successHandler = (res: AxiosResponse<Response<T>>) => {
|
||||||
if (res.data.status === 'Success')
|
if (res.data.status === 'Success' || typeof res.data === 'string')
|
||||||
return res.data
|
return res.data
|
||||||
|
|
||||||
return Promise.reject(res.data)
|
return Promise.reject(res.data)
|
||||||
@@ -37,17 +40,18 @@ function http<T = any>({ url, data, method, headers, signal, beforeRequest, afte
|
|||||||
const params = Object.assign(typeof data === 'function' ? data() : data ?? {}, {})
|
const params = Object.assign(typeof data === 'function' ? data() : data ?? {}, {})
|
||||||
|
|
||||||
return method === 'GET'
|
return method === 'GET'
|
||||||
? request.get(url, { params, signal }).then(successHandler, failHandler)
|
? request.get(url, { params, signal, onDownloadProgress }).then(successHandler, failHandler)
|
||||||
: request.post(url, params, { headers, signal }).then(successHandler, failHandler)
|
: request.post(url, params, { headers, signal, onDownloadProgress }).then(successHandler, failHandler)
|
||||||
}
|
}
|
||||||
|
|
||||||
export function get<T = any>(
|
export function get<T = any>(
|
||||||
{ url, data, method = 'GET', signal, beforeRequest, afterRequest }: HttpOption,
|
{ url, data, method = 'GET', onDownloadProgress, signal, beforeRequest, afterRequest }: HttpOption,
|
||||||
): Promise<Response<T>> {
|
): Promise<Response<T>> {
|
||||||
return http<T>({
|
return http<T>({
|
||||||
url,
|
url,
|
||||||
method,
|
method,
|
||||||
data,
|
data,
|
||||||
|
onDownloadProgress,
|
||||||
signal,
|
signal,
|
||||||
beforeRequest,
|
beforeRequest,
|
||||||
afterRequest,
|
afterRequest,
|
||||||
@@ -55,13 +59,14 @@ export function get<T = any>(
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function post<T = any>(
|
export function post<T = any>(
|
||||||
{ url, data, method = 'POST', headers, signal, beforeRequest, afterRequest }: HttpOption,
|
{ url, data, method = 'POST', headers, onDownloadProgress, signal, beforeRequest, afterRequest }: HttpOption,
|
||||||
): Promise<Response<T>> {
|
): Promise<Response<T>> {
|
||||||
return http<T>({
|
return http<T>({
|
||||||
url,
|
url,
|
||||||
method,
|
method,
|
||||||
data,
|
data,
|
||||||
headers,
|
headers,
|
||||||
|
onDownloadProgress,
|
||||||
signal,
|
signal,
|
||||||
beforeRequest,
|
beforeRequest,
|
||||||
afterRequest,
|
afterRequest,
|
||||||
|
|||||||
@@ -8,9 +8,9 @@ defineProps<Props>()
|
|||||||
|
|
||||||
<template>
|
<template>
|
||||||
<img v-if="image" src="@/assets/avatar.jpg" class="object-cover w-full h-full " alt="avatar">
|
<img v-if="image" src="@/assets/avatar.jpg" class="object-cover w-full h-full " alt="avatar">
|
||||||
<span v-else class="text-[27px]">
|
<span v-else class="text-[27px] dark:text-white">
|
||||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32" aria-hidden="true" width="1em" height="1em">
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32" aria-hidden="true" width="1em" height="1em">
|
||||||
<path d="M29.71,13.09A8.09,8.09,0,0,0,20.34,2.68a8.08,8.08,0,0,0-13.7,2.9A8.08,8.08,0,0,0,2.3,18.9,8,8,0,0,0,3,25.45a8.08,8.08,0,0,0,8.69,3.87,8,8,0,0,0,6,2.68,8.09,8.09,0,0,0,7.7-5.61,8,8,0,0,0,5.33-3.86A8.09,8.09,0,0,0,29.71,13.09Zm-12,16.82a6,6,0,0,1-3.84-1.39l.19-.11,6.37-3.68a1,1,0,0,0,.53-.91v-9l2.69,1.56a.08.08,0,0,1,.05.07v7.44A6,6,0,0,1,17.68,29.91ZM4.8,24.41a6,6,0,0,1-.71-4l.19.11,6.37,3.68a1,1,0,0,0,1,0l7.79-4.49V22.8a.09.09,0,0,1,0,.08L13,26.6A6,6,0,0,1,4.8,24.41ZM3.12,10.53A6,6,0,0,1,6.28,7.9v7.57a1,1,0,0,0,.51.9l7.75,4.47L11.85,22.4a.14.14,0,0,1-.09,0L5.32,18.68a6,6,0,0,1-2.2-8.18Zm22.13,5.14-7.78-4.52L20.16,9.6a.08.08,0,0,1,.09,0l6.44,3.72a6,6,0,0,1-.9,10.81V16.56A1.06,1.06,0,0,0,25.25,15.67Zm2.68-4-.19-.12-6.36-3.7a1,1,0,0,0-1.05,0l-7.78,4.49V9.2a.09.09,0,0,1,0-.09L19,5.4a6,6,0,0,1,8.91,6.21ZM11.08,17.15,8.38,15.6a.14.14,0,0,1-.05-.08V8.1a6,6,0,0,1,9.84-4.61L18,3.6,11.61,7.28a1,1,0,0,0-.53.91ZM12.54,14,16,12l3.47,2v4L16,20l-3.47-2Z" />
|
<path d="M29.71,13.09A8.09,8.09,0,0,0,20.34,2.68a8.08,8.08,0,0,0-13.7,2.9A8.08,8.08,0,0,0,2.3,18.9,8,8,0,0,0,3,25.45a8.08,8.08,0,0,0,8.69,3.87,8,8,0,0,0,6,2.68,8.09,8.09,0,0,0,7.7-5.61,8,8,0,0,0,5.33-3.86A8.09,8.09,0,0,0,29.71,13.09Zm-12,16.82a6,6,0,0,1-3.84-1.39l.19-.11,6.37-3.68a1,1,0,0,0,.53-.91v-9l2.69,1.56a.08.08,0,0,1,.05.07v7.44A6,6,0,0,1,17.68,29.91ZM4.8,24.41a6,6,0,0,1-.71-4l.19.11,6.37,3.68a1,1,0,0,0,1,0l7.79-4.49V22.8a.09.09,0,0,1,0,.08L13,26.6A6,6,0,0,1,4.8,24.41ZM3.12,10.53A6,6,0,0,1,6.28,7.9v7.57a1,1,0,0,0,.51.9l7.75,4.47L11.85,22.4a.14.14,0,0,1-.09,0L5.32,18.68a6,6,0,0,1-2.2-8.18Zm22.13,5.14-7.78-4.52L20.16,9.6a.08.08,0,0,1,.09,0l6.44,3.72a6,6,0,0,1-.9,10.81V16.56A1.06,1.06,0,0,0,25.25,15.67Zm2.68-4-.19-.12-6.36-3.7a1,1,0,0,0-1.05,0l-7.78,4.49V9.2a.09.09,0,0,1,0-.09L19,5.4a6,6,0,0,1,8.91,6.21ZM11.08,17.15,8.38,15.6a.14.14,0,0,1-.05-.08V8.1a6,6,0,0,1,9.84-4.61L18,3.6,11.61,7.28a1,1,0,0,0-.53.91ZM12.54,14,16,12l3.47,2v4L16,20l-3.47-2Z" fill="currentColor" />
|
||||||
</svg>
|
</svg>
|
||||||
</span>
|
</span>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@@ -1,7 +1,16 @@
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { computed } from 'vue'
|
import { computed } from 'vue'
|
||||||
import { marked } from 'marked'
|
import { marked } from 'marked'
|
||||||
import includeCode from '@/utils/functions/includeCode'
|
import hljs from 'highlight.js'
|
||||||
|
|
||||||
|
const props = defineProps<Props>()
|
||||||
|
|
||||||
|
marked.setOptions({
|
||||||
|
renderer: new marked.Renderer(),
|
||||||
|
highlight(code) {
|
||||||
|
return hljs.highlightAuto(code).value
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
inversion?: boolean
|
inversion?: boolean
|
||||||
@@ -10,51 +19,39 @@ interface Props {
|
|||||||
loading?: boolean
|
loading?: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
const props = defineProps<Props>()
|
|
||||||
|
|
||||||
const wrapClass = computed(() => {
|
const wrapClass = computed(() => {
|
||||||
return [
|
return [
|
||||||
'text-wrap',
|
'text-wrap',
|
||||||
'p-2',
|
'p-3',
|
||||||
'min-w-[20px]',
|
'min-w-[20px]',
|
||||||
'rounded-md',
|
'rounded-md',
|
||||||
props.inversion ? 'bg-[#d2f9d1]' : 'bg-[#f4f6f8]',
|
props.inversion ? 'bg-[#d2f9d1]' : 'bg-[#f4f6f8]',
|
||||||
|
props.inversion ? 'dark:bg-[#a1dc95]' : 'dark:bg-[#1e1e20]',
|
||||||
{ 'text-red-500': props.error },
|
{ 'text-red-500': props.error },
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
|
|
||||||
const text = computed(() => {
|
const text = computed(() => {
|
||||||
if (props.text) {
|
if (props.text && !props.inversion)
|
||||||
if (!includeCode(props.text))
|
return marked(props.text)
|
||||||
return marked.parse(props.text)
|
return props.text
|
||||||
return props.text
|
|
||||||
}
|
|
||||||
return ''
|
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div :class="wrapClass">
|
<div class="text-black" :class="wrapClass">
|
||||||
<template v-if="loading">
|
<template v-if="loading">
|
||||||
<span class="w-[3px] h-[20px] block animate-blink" />
|
<span class="dark:text-white w-[4px] h-[20px] block animate-blink" />
|
||||||
</template>
|
</template>
|
||||||
<template v-else>
|
<template v-else>
|
||||||
<code v-if="includeCode(text)" v-highlight class="leading-relaxed" v-text="text" />
|
<div class="leading-relaxed break-all">
|
||||||
<div v-else class="leading-relaxed break-all" v-html="text" />
|
<div v-if="!inversion" class="markdown-body" v-html="text" />
|
||||||
|
<div v-else v-text="text" />
|
||||||
|
</div>
|
||||||
</template>
|
</template>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<style lang="less">
|
<style lang="less">
|
||||||
.text-wrap{
|
@import url(./style.less);
|
||||||
img{
|
|
||||||
max-width: 100%;
|
|
||||||
vertical-align: middle;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.hljs {
|
|
||||||
background-color: #fff0 !important;
|
|
||||||
white-space: break-spaces;
|
|
||||||
}
|
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<script setup lang='ts'>
|
<script setup lang='ts'>
|
||||||
import Avatar from './Avatar.vue'
|
import AvatarComponent from './Avatar.vue'
|
||||||
import Text from './Text.vue'
|
import TextComponent from './Text.vue'
|
||||||
import { SvgIcon } from '@/components/common'
|
import { SvgIcon } from '@/components/common'
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
@@ -13,38 +13,60 @@ interface Props {
|
|||||||
|
|
||||||
interface Emit {
|
interface Emit {
|
||||||
(ev: 'regenerate'): void
|
(ev: 'regenerate'): void
|
||||||
|
(ev: 'copy'): void
|
||||||
|
(ev: 'delete'): void
|
||||||
}
|
}
|
||||||
|
|
||||||
defineProps<Props>()
|
defineProps<Props>()
|
||||||
|
|
||||||
const emit = defineEmits<Emit>()
|
const emit = defineEmits<Emit>()
|
||||||
|
|
||||||
|
function handleDelete() {
|
||||||
|
emit('delete')
|
||||||
|
}
|
||||||
|
|
||||||
function handleRegenerate() {
|
function handleRegenerate() {
|
||||||
emit('regenerate')
|
emit('regenerate')
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div class="flex w-full mb-6" :class="[{ 'flex-row-reverse': inversion }]">
|
<div class="flex w-full mb-6 overflow-hidden" :class="[{ 'flex-row-reverse': inversion }]">
|
||||||
<div
|
<div
|
||||||
class="flex items-center justify-center rounded-full overflow-hidden w-[32px] h-[32px]"
|
class="flex items-center justify-center rounded-full overflow-hidden flex-shrink-0 w-[32px] h-[32px]"
|
||||||
:class="[inversion ? 'ml-3' : 'mr-3']"
|
:class="[inversion ? 'ml-3' : 'mr-3']"
|
||||||
>
|
>
|
||||||
<Avatar :image="inversion" />
|
<AvatarComponent :image="inversion" />
|
||||||
</div>
|
</div>
|
||||||
<div class="flex flex-col flex-1 text-sm" :class="[inversion ? 'items-end' : 'items-start']">
|
<div class="flex flex-col flex-1 text-sm" :class="[inversion ? 'items-end' : 'items-start']">
|
||||||
<span class="text-xs text-[#b4bbc4]">
|
<span class="text-xs text-[#b4bbc4]">
|
||||||
{{ dateTime }}
|
{{ dateTime }}
|
||||||
</span>
|
</span>
|
||||||
<div class="flex items-end mt-2">
|
<div
|
||||||
<Text :inversion="inversion" :error="error" :text="text" :loading="loading" />
|
class="flex items-end gap-2 mt-2"
|
||||||
<button
|
:class="[inversion ? 'flex-row-reverse' : 'flex-row']"
|
||||||
v-if="!inversion && !loading"
|
>
|
||||||
class="mb-2 ml-2 transition text-neutral-400 hover:text-neutral-800"
|
<TextComponent
|
||||||
@click="handleRegenerate"
|
:inversion="inversion"
|
||||||
>
|
:error="error"
|
||||||
<SvgIcon icon="ri:restart-line" />
|
:text="text"
|
||||||
</button>
|
:loading="loading"
|
||||||
|
/>
|
||||||
|
<div class="flex flex-col">
|
||||||
|
<button
|
||||||
|
v-if="!inversion"
|
||||||
|
class="mb-2 transition text-neutral-400 hover:text-neutral-800 dark:hover:text-neutral-200"
|
||||||
|
@click="handleRegenerate"
|
||||||
|
>
|
||||||
|
<SvgIcon icon="ri:restart-line" />
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
class="mb-1 transition text-neutral-400 hover:text-neutral-800 dark:hover:text-neutral-200"
|
||||||
|
@click="handleDelete"
|
||||||
|
>
|
||||||
|
<SvgIcon icon="ri:delete-bin-6-line" />
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
31
src/views/chat/components/Message/style.less
Normal file
31
src/views/chat/components/Message/style.less
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
.markdown-body {
|
||||||
|
background-color: transparent;
|
||||||
|
font-size: 14px;
|
||||||
|
|
||||||
|
ol {
|
||||||
|
list-style-type: decimal;
|
||||||
|
}
|
||||||
|
|
||||||
|
ul {
|
||||||
|
list-style-type: disc;
|
||||||
|
}
|
||||||
|
|
||||||
|
pre code,
|
||||||
|
pre tt {
|
||||||
|
line-height: 1.65;
|
||||||
|
}
|
||||||
|
|
||||||
|
.highlight pre,
|
||||||
|
pre {
|
||||||
|
background-color: #fff;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.dark{
|
||||||
|
.markdown-body{
|
||||||
|
.highlight pre,
|
||||||
|
pre {
|
||||||
|
background-color: #18181c;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
<script setup lang='ts'>
|
<script setup lang='ts'>
|
||||||
import { computed, onMounted, onUnmounted, ref } from 'vue'
|
import { computed, onMounted, onUnmounted, ref } from 'vue'
|
||||||
import { useRoute } from 'vue-router'
|
import { useRoute } from 'vue-router'
|
||||||
import { NButton, NInput, useDialog } from 'naive-ui'
|
import { NButton, NInput, useDialog, useMessage } from 'naive-ui'
|
||||||
import { Message } from './components'
|
import { Message } from './components'
|
||||||
import { useScroll } from './hooks/useScroll'
|
import { useScroll } from './hooks/useScroll'
|
||||||
import { useChat } from './hooks/useChat'
|
import { useChat } from './hooks/useChat'
|
||||||
@@ -14,6 +14,7 @@ let controller = new AbortController()
|
|||||||
|
|
||||||
const route = useRoute()
|
const route = useRoute()
|
||||||
const dialog = useDialog()
|
const dialog = useDialog()
|
||||||
|
const ms = useMessage()
|
||||||
|
|
||||||
const chatStore = useChatStore()
|
const chatStore = useChatStore()
|
||||||
|
|
||||||
@@ -195,6 +196,22 @@ async function onRegenerate(index: number) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function handleDelete(index: number) {
|
||||||
|
if (loading.value)
|
||||||
|
return
|
||||||
|
|
||||||
|
dialog.warning({
|
||||||
|
title: 'Delete Message',
|
||||||
|
content: 'Are you sure to delete this message?',
|
||||||
|
positiveText: 'Yes',
|
||||||
|
negativeText: 'No',
|
||||||
|
onPositiveClick: () => {
|
||||||
|
chatStore.deleteChatByUuid(+uuid, index)
|
||||||
|
ms.success('Message deleted successfully.')
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
function handleClear() {
|
function handleClear() {
|
||||||
if (loading.value)
|
if (loading.value)
|
||||||
return
|
return
|
||||||
@@ -217,13 +234,20 @@ function handleEnter(event: KeyboardEvent) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function handleStop() {
|
||||||
|
if (loading.value) {
|
||||||
|
controller.abort()
|
||||||
|
loading.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const buttonDisabled = computed(() => {
|
const buttonDisabled = computed(() => {
|
||||||
return loading.value || !prompt.value || prompt.value.trim() === ''
|
return loading.value || !prompt.value || prompt.value.trim() === ''
|
||||||
})
|
})
|
||||||
|
|
||||||
const wrapClass = computed(() => {
|
const wrapClass = computed(() => {
|
||||||
if (isMobile.value)
|
if (isMobile.value)
|
||||||
return ['pt-14', 'pb-14']
|
return ['pt-14', 'pb-16']
|
||||||
|
|
||||||
return []
|
return []
|
||||||
})
|
})
|
||||||
@@ -266,7 +290,16 @@ onUnmounted(() => {
|
|||||||
:error="item.error"
|
:error="item.error"
|
||||||
:loading="item.loading"
|
:loading="item.loading"
|
||||||
@regenerate="onRegenerate(index)"
|
@regenerate="onRegenerate(index)"
|
||||||
|
@delete="handleDelete(index)"
|
||||||
/>
|
/>
|
||||||
|
<div class="flex justify-center">
|
||||||
|
<NButton v-if="loading" ghost @click="handleStop">
|
||||||
|
<template #icon>
|
||||||
|
<SvgIcon icon="ri:stop-circle-line" />
|
||||||
|
</template>
|
||||||
|
Stop Responding
|
||||||
|
</NButton>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
</div>
|
</div>
|
||||||
@@ -274,7 +307,7 @@ onUnmounted(() => {
|
|||||||
<footer :class="footerClass">
|
<footer :class="footerClass">
|
||||||
<div class="flex items-center justify-between space-x-2">
|
<div class="flex items-center justify-between space-x-2">
|
||||||
<HoverButton @click="handleClear">
|
<HoverButton @click="handleClear">
|
||||||
<span class="text-xl text-[#4f555e]">
|
<span class="text-xl text-[#4f555e] dark:text-white">
|
||||||
<SvgIcon icon="ri:delete-bin-line" />
|
<SvgIcon icon="ri:delete-bin-line" />
|
||||||
</span>
|
</span>
|
||||||
</HoverButton>
|
</HoverButton>
|
||||||
@@ -287,7 +320,9 @@ onUnmounted(() => {
|
|||||||
/>
|
/>
|
||||||
<NButton type="primary" :disabled="buttonDisabled" @click="handleSubmit">
|
<NButton type="primary" :disabled="buttonDisabled" @click="handleSubmit">
|
||||||
<template #icon>
|
<template #icon>
|
||||||
<SvgIcon icon="ri:send-plane-fill" />
|
<span class="dark:text-black">
|
||||||
|
<SvgIcon icon="ri:send-plane-fill" />
|
||||||
|
</span>
|
||||||
</template>
|
</template>
|
||||||
</NButton>
|
</NButton>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ const collapsed = computed(() => appStore.siderCollapsed)
|
|||||||
const getMobileClass = computed(() => {
|
const getMobileClass = computed(() => {
|
||||||
if (isMobile.value)
|
if (isMobile.value)
|
||||||
return ['rounded-none', 'shadow-none']
|
return ['rounded-none', 'shadow-none']
|
||||||
return ['border', 'rounded-md', 'shadow-md']
|
return ['border', 'rounded-md', 'shadow-md', 'dark:border-neutral-800']
|
||||||
})
|
})
|
||||||
|
|
||||||
const getContainerClass = computed(() => {
|
const getContainerClass = computed(() => {
|
||||||
@@ -32,7 +32,7 @@ const getContainerClass = computed(() => {
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div class="h-full" :class="[isMobile ? 'p-0' : 'p-4']">
|
<div class="h-full dark:bg-[#24272e] transition-all" :class="[isMobile ? 'p-0' : 'p-4']">
|
||||||
<div class="h-full overflow-hidden" :class="getMobileClass">
|
<div class="h-full overflow-hidden" :class="getMobileClass">
|
||||||
<NLayout class="z-40 transition" :class="getContainerClass" has-sider>
|
<NLayout class="z-40 transition" :class="getContainerClass" has-sider>
|
||||||
<Sider />
|
<Sider />
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ function handleUpdateCollapsed() {
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<header class="fixed top-0 left-0 right-0 z-30 border-b bg-white/80 backdrop-blur">
|
<header class="fixed top-0 left-0 right-0 z-30 border-b dark:border-neutral-800 bg-white/80 dark:bg-black/30 backdrop-blur">
|
||||||
<div class="relative flex items-center justify-between h-14">
|
<div class="relative flex items-center justify-between h-14">
|
||||||
<button class="flex items-center justify-center w-11 h-11" @click="handleUpdateCollapsed">
|
<button class="flex items-center justify-center w-11 h-11" @click="handleUpdateCollapsed">
|
||||||
<SvgIcon v-if="collapsed" class="text-2xl" icon="ri:align-justify" />
|
<SvgIcon v-if="collapsed" class="text-2xl" icon="ri:align-justify" />
|
||||||
|
|||||||
@@ -1,15 +1,60 @@
|
|||||||
<script setup lang='ts'>
|
<script setup lang='ts'>
|
||||||
import { ref } from 'vue'
|
import { computed, h, ref } from 'vue'
|
||||||
|
import { NDropdown } from 'naive-ui'
|
||||||
import { HoverButton, Setting, SvgIcon, UserAvatar } from '@/components/common'
|
import { HoverButton, Setting, SvgIcon, UserAvatar } from '@/components/common'
|
||||||
|
import { useAppStore } from '@/store'
|
||||||
|
|
||||||
|
const appStore = useAppStore()
|
||||||
|
|
||||||
const show = ref(false)
|
const show = ref(false)
|
||||||
|
|
||||||
|
const theme = computed(() => appStore.theme)
|
||||||
|
|
||||||
|
const options = [
|
||||||
|
{
|
||||||
|
label: 'Dark',
|
||||||
|
key: 'dark',
|
||||||
|
icon: renderIcon('ri:moon-foggy-line'),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'Light',
|
||||||
|
key: 'light',
|
||||||
|
icon: renderIcon('ri:sun-foggy-line'),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'Auto',
|
||||||
|
key: 'auto',
|
||||||
|
icon: renderIcon('ri:contrast-line'),
|
||||||
|
},
|
||||||
|
]
|
||||||
|
|
||||||
|
function renderIcon(icon: string) {
|
||||||
|
return () => {
|
||||||
|
return h(SvgIcon, { icon })
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleThemeChange(key: 'light' | 'dark' | 'auto') {
|
||||||
|
appStore.setTheme(key)
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<footer class="flex items-center justify-between min-w-0 p-4 overflow-hidden border-t">
|
<footer class="flex items-center justify-between min-w-0 p-4 overflow-hidden border-t dark:border-neutral-800">
|
||||||
<UserAvatar />
|
<UserAvatar />
|
||||||
|
|
||||||
|
<NDropdown :options="options" placement="top" trigger="click" @select="handleThemeChange">
|
||||||
|
<HoverButton>
|
||||||
|
<span class="text-xl text-[#4f555e] dark:text-white">
|
||||||
|
<SvgIcon v-if="theme === 'dark'" icon="ri:sun-foggy-line" />
|
||||||
|
<SvgIcon v-if="theme === 'light'" icon="ri:moon-foggy-line" />
|
||||||
|
<SvgIcon v-if="theme === 'auto'" icon="ri:contrast-line" />
|
||||||
|
</span>
|
||||||
|
</HoverButton>
|
||||||
|
</NDropdown>
|
||||||
|
|
||||||
<HoverButton tooltip="Setting" @click="show = true">
|
<HoverButton tooltip="Setting" @click="show = true">
|
||||||
<span class="text-xl text-[#4f555e]">
|
<span class="text-xl text-[#4f555e] dark:text-white">
|
||||||
<SvgIcon icon="ri:settings-4-line" />
|
<SvgIcon icon="ri:settings-4-line" />
|
||||||
</span>
|
</span>
|
||||||
</HoverButton>
|
</HoverButton>
|
||||||
|
|||||||
@@ -55,8 +55,8 @@ function isActive(uuid: number) {
|
|||||||
<template v-else>
|
<template v-else>
|
||||||
<div v-for="(item, index) of dataSources" :key="index">
|
<div v-for="(item, index) of dataSources" :key="index">
|
||||||
<a
|
<a
|
||||||
class="relative flex items-center gap-3 px-3 py-3 break-all border rounded-md cursor-pointer hover:bg-neutral-100 group"
|
class="relative flex items-center gap-3 px-3 py-3 break-all border rounded-md cursor-pointer hover:bg-neutral-100 group dark:border-neutral-800 dark:hover:bg-[#24272e]"
|
||||||
:class="isActive(item.uuid) && ['border-[#4b9e5f]', 'bg-neutral-100', 'text-[#4b9e5f]', 'pr-14']"
|
:class="isActive(item.uuid) && ['border-[#4b9e5f]', 'bg-neutral-100', 'text-[#4b9e5f]', 'dark:bg-[#24272e]', 'dark:border-[#4b9e5f]', 'pr-14']"
|
||||||
@click="handleSelect(item)"
|
@click="handleSelect(item)"
|
||||||
>
|
>
|
||||||
<span>
|
<span>
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
/** @type {import('tailwindcss').Config} */
|
/** @type {import('tailwindcss').Config} */
|
||||||
module.exports = {
|
module.exports = {
|
||||||
|
darkMode: 'class',
|
||||||
content: [
|
content: [
|
||||||
'./index.html',
|
'./index.html',
|
||||||
'./src/**/*.{vue,js,ts,jsx,tsx}',
|
'./src/**/*.{vue,js,ts,jsx,tsx}',
|
||||||
@@ -11,7 +12,7 @@ module.exports = {
|
|||||||
},
|
},
|
||||||
keyframes: {
|
keyframes: {
|
||||||
blink: {
|
blink: {
|
||||||
'0%, 100%': { 'background-color': '#000' },
|
'0%, 100%': { 'background-color': 'currentColor' },
|
||||||
'50%': { 'background-color': 'transparent' },
|
'50%': { 'background-color': 'transparent' },
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user