Compare commits
27 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
07cac12dac | ||
|
|
4f3bfd1d4a | ||
|
|
451a456f58 | ||
|
|
5fe1e20e4a | ||
|
|
54381ed2e2 | ||
|
|
ffd4da91cf | ||
|
|
a2ffa3cb3a | ||
|
|
ecc2afd164 | ||
|
|
45cbfbf002 | ||
|
|
a689406b28 | ||
|
|
2ff82b1249 | ||
|
|
8e1b4edc91 | ||
|
|
dea74e242e | ||
|
|
162f561523 | ||
|
|
50e672e79b | ||
|
|
c8fa086565 | ||
|
|
cd91cb1afd | ||
|
|
e6db6a58f0 | ||
|
|
ab08df9823 | ||
|
|
8619ac4667 | ||
|
|
de34d97529 | ||
|
|
0cdacfdb2f | ||
|
|
976713490a | ||
|
|
002a57704f | ||
|
|
9dd3655b81 | ||
|
|
d1de182451 | ||
|
|
dee84e9307 |
5
.vscode/settings.json
vendored
5
.vscode/settings.json
vendored
@@ -29,10 +29,14 @@
|
||||
"dockerhub",
|
||||
"esno",
|
||||
"GPTAPI",
|
||||
"highlightjs",
|
||||
"hljs",
|
||||
"iconify",
|
||||
"katex",
|
||||
"katexmath",
|
||||
"linkify",
|
||||
"logprobs",
|
||||
"mdhljs",
|
||||
"nodata",
|
||||
"OPENAI",
|
||||
"pinia",
|
||||
@@ -40,6 +44,7 @@
|
||||
"rushstack",
|
||||
"Sider",
|
||||
"tailwindcss",
|
||||
"traptitech",
|
||||
"tsup",
|
||||
"Typecheck",
|
||||
"unplugin",
|
||||
|
||||
55
CHANGELOG.md
55
CHANGELOG.md
@@ -1,3 +1,58 @@
|
||||
## v2.10.0
|
||||
|
||||
`2023-03-07`
|
||||
|
||||
- 老规矩,手动部署的同学需要删除 `node_modules` 安装包重新安装降低出错概率,其他部署不受影响,但是可能会有缓存问题。
|
||||
- 虽然说了更新放缓,但是 `issues` 不看, `PR` 不改我睡不着,我的邮箱从每天早上`8`点到凌晨`12`永远在滴滴滴,所以求求各位,超时的`issues`自己关闭下哈,我真的需要缓冲一下。
|
||||
- 演示图片请看最后
|
||||
|
||||
## Feature
|
||||
- 添加权限功能,用法:`service/.env` 中的 `AUTH_SECRET_KEY` 变量添加密码
|
||||
- 感谢 [PeterDaveHello](https://github.com/Chanzhaoyu/chatgpt-web/pull/348) 添加「繁体中文」翻译
|
||||
- 感谢 [GermMC](https://github.com/Chanzhaoyu/chatgpt-web/pull/369) 添加聊天记录导入、导出、清空的功能
|
||||
- 感谢 [CornerSkyless](https://github.com/Chanzhaoyu/chatgpt-web/pull/374) 添加会话保存为本地图片的功能
|
||||
|
||||
|
||||
## Enhancement
|
||||
- 感谢 [CornerSkyless](https://github.com/Chanzhaoyu/chatgpt-web/pull/363) 添加 `ctrl+enter` 发送消息
|
||||
- 现在新消息只有在结束了之后才滚动到底部,而不是之前的强制性
|
||||
- 优化部分代码
|
||||
|
||||
## BugFix
|
||||
- 转义状态码前端显示,防止直接暴露 `key`(我可能需要更多的状态码补充)
|
||||
|
||||
## Other
|
||||
- 更新依赖到最新
|
||||
|
||||
## 演示
|
||||
> 不是界面最新效果,有美化改动
|
||||
|
||||
权限
|
||||
|
||||

|
||||
|
||||
聊天记录导出
|
||||
|
||||

|
||||
|
||||
保存图片到本地
|
||||
|
||||

|
||||
|
||||
## v2.9.3
|
||||
|
||||
`2023-03-06`
|
||||
|
||||
## Enhancement
|
||||
- 感谢 [ChandlerVer5](https://github.com/Chanzhaoyu/chatgpt-web/pull/305) 使用 `markdown-it` 替换 `marked`,解决代码块闪烁的问题
|
||||
- 感谢 [shansing](https://github.com/Chanzhaoyu/chatgpt-web/pull/277) 改善文档
|
||||
- 感谢 [nalf3in](https://github.com/Chanzhaoyu/chatgpt-web/pull/293) 添加英文翻译
|
||||
|
||||
## BugFix
|
||||
- 感谢[sepcnt ](https://github.com/Chanzhaoyu/chatgpt-web/pull/279) 修复切换记录时编辑状态未关闭的问题
|
||||
- 修复复制代码的兼容性报错问题
|
||||
- 修复部分优化小问题
|
||||
|
||||
## v2.9.2
|
||||
|
||||
`2023-03-04`
|
||||
|
||||
49
CONTRIBUTING.en.md
Normal file
49
CONTRIBUTING.en.md
Normal file
@@ -0,0 +1,49 @@
|
||||
# Contribution Guide
|
||||
Thank you for your valuable time. Your contributions will make this project better! Before submitting a contribution, please take some time to read the getting started guide below.
|
||||
|
||||
## Semantic Versioning
|
||||
This project follows semantic versioning. We release patch versions for important bug fixes, minor versions for new features or non-important changes, and major versions for significant and incompatible changes.
|
||||
|
||||
Each major change will be recorded in the `changelog`.
|
||||
|
||||
## Submitting Pull Request
|
||||
1. Fork [this repository](https://github.com/Chanzhaoyu/chatgpt-web) and create a branch from `main`. For new feature implementations, submit a pull request to the `feature` branch. For other changes, submit to the `main` branch.
|
||||
2. Install the `pnpm` tool using `npm install pnpm -g`.
|
||||
3. Install the `Eslint` plugin for `VSCode`, or enable `eslint` functionality for other editors such as `WebStorm`.
|
||||
4. Execute `pnpm bootstrap` in the root directory.
|
||||
5. Execute `pnpm install` in the `/service/` directory.
|
||||
6. Make changes to the codebase. If applicable, ensure that appropriate testing has been done.
|
||||
7. Execute `pnpm lint:fix` in the root directory to perform a code formatting check.
|
||||
8. Execute `pnpm type-check` in the root directory to perform a type check.
|
||||
9. Submit a git commit, following the [Commit Guidelines](#commit-guidelines).
|
||||
10. Submit a `pull request`. If there is a corresponding `issue`, please link it using the [linking-a-pull-request-to-an-issue keyword](https://docs.github.com/en/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue#linking-a-pull-request-to-an-issue-using-a-keyword).
|
||||
|
||||
## Commit Guidelines
|
||||
|
||||
Commit messages should follow the [conventional-changelog standard](https://www.conventionalcommits.org/en/v1.0.0/):
|
||||
|
||||
```bash
|
||||
<type>[optional scope]: <description>
|
||||
|
||||
[optional body]
|
||||
|
||||
[optional footer]
|
||||
```
|
||||
|
||||
### Commit Types
|
||||
|
||||
The following is a list of commit types:
|
||||
|
||||
- feat: New feature or functionality
|
||||
- fix: Bug fix
|
||||
- docs: Documentation update
|
||||
- style: Code style or component style update
|
||||
- refactor: Code refactoring, no new features or bug fixes introduced
|
||||
- perf: Performance optimization
|
||||
- test: Unit test
|
||||
- chore: Other commits that do not modify src or test files
|
||||
|
||||
|
||||
## License
|
||||
|
||||
[MIT](./license)
|
||||
322
README.en.md
Normal file
322
README.en.md
Normal file
@@ -0,0 +1,322 @@
|
||||
# ChatGPT Web
|
||||
|
||||
<div style="font-size: 1.5rem;">
|
||||
<a href="./README.md">中文</a> |
|
||||
<a href="./README.en.md">English</a>
|
||||
</div>
|
||||
</br>
|
||||
|
||||
> Disclaimer: This project is only released on GitHub, under the MIT License, free and for open-source learning purposes. There will be no account selling, paid services, discussion groups, or forums. Beware of fraud.
|
||||
|
||||

|
||||

|
||||
|
||||
- [ChatGPT Web](#chatgpt-web)
|
||||
- [Introduction](#introduction)
|
||||
- [Roadmap](#roadmap)
|
||||
- [Prerequisites](#prerequisites)
|
||||
- [Node](#node)
|
||||
- [PNPM](#pnpm)
|
||||
- [Fill in the Keys](#fill-in-the-keys)
|
||||
- [Install Dependencies](#install-dependencies)
|
||||
- [Backend](#backend)
|
||||
- [Frontend](#frontend)
|
||||
- [Run in Test Environment](#run-in-test-environment)
|
||||
- [Backend Service](#backend-service)
|
||||
- [Frontend Webpage](#frontend-webpage)
|
||||
- [Packaging](#packaging)
|
||||
- [Using Docker](#using-docker)
|
||||
- [Docker Parameter Example](#docker-parameter-example)
|
||||
- [Docker Build \& Run](#docker-build--run)
|
||||
- [Docker Compose](#docker-compose)
|
||||
- [Deployment with Railway](#deployment-with-railway)
|
||||
- [Railway Environment Variables](#railway-environment-variables)
|
||||
- [Manual packaging](#manual-packaging)
|
||||
- [Backend service](#backend-service-1)
|
||||
- [Frontend webpage](#frontend-webpage-1)
|
||||
- [Frequently Asked Questions](#frequently-asked-questions)
|
||||
- [Contributing](#contributing)
|
||||
- [Sponsorship](#sponsorship)
|
||||
- [License](#license)
|
||||
|
||||
## Introduction
|
||||
|
||||
Supports dual models, provides two unofficial `ChatGPT API` methods:
|
||||
|
||||
| Method | Free? | Reliability | Quality |
|
||||
| --------------------------------------------- | ------ | ----------- | ------- |
|
||||
| `ChatGPTAPI(gpt-3.5-turbo-0301)` | No | Reliable | Relatively clumsy |
|
||||
| `ChatGPTUnofficialProxyAPI(Web accessToken)` | Yes | Relatively unreliable | Smart |
|
||||
|
||||
Comparison:
|
||||
1. `ChatGPTAPI` uses `gpt-3.5-turbo-0301` to simulate `ChatGPT` through the official `OpenAI` completion `API` (the most reliable method, but it is not free and does not use models specifically tuned for chat).
|
||||
2. `ChatGPTUnofficialProxyAPI` accesses `ChatGPT`'s backend `API` via an unofficial proxy server to bypass `Cloudflare` (uses the real `ChatGPT`, is very lightweight, but depends on third-party servers and has rate limits).
|
||||
|
||||
[Details](https://github.com/Chanzhaoyu/chatgpt-web/issues/138)
|
||||
|
||||
Switching Methods:
|
||||
1. Go to the `service/.env` file.
|
||||
2. For `OpenAI API Key`, fill in the `OPENAI_API_KEY` field [(Get apiKey)](https://platform.openai.com/overview).
|
||||
3. For `Web API`, fill in the `OPENAI_ACCESS_TOKEN` field [(Get accessToken)](https://chat.openai.com/api/auth/session).
|
||||
4. When both are present, `OpenAI API Key` takes precedence.
|
||||
|
||||
Reverse Proxy:
|
||||
|
||||
Available when using `ChatGPTUnofficialProxyAPI`.[Details](https://github.com/transitive-bullshit/chatgpt-api#reverse-proxy)
|
||||
|
||||
```shell
|
||||
# service/.env
|
||||
API_REVERSE_PROXY=
|
||||
```
|
||||
|
||||
Environment Variables:
|
||||
|
||||
For all parameter variables, check [here](#docker-parameter-example) or see:
|
||||
|
||||
```
|
||||
/service/.env
|
||||
```
|
||||
|
||||
## Roadmap
|
||||
[✓] Dual models
|
||||
|
||||
[✓] Multiple session storage and context logic
|
||||
|
||||
[✓] Formatting and beautifying code-like message types
|
||||
|
||||
[✓] Access rights control
|
||||
|
||||
[✓] Data import and export
|
||||
|
||||
[✓] Save message to local image
|
||||
|
||||
[✓] Multilingual interface
|
||||
|
||||
[✓] Interface themes
|
||||
|
||||
[✗] More...
|
||||
|
||||
## Prerequisites
|
||||
|
||||
### Node
|
||||
|
||||
`node` requires version `^16 || ^18` (`node >= 14` requires installation of [fetch polyfill](https://github.com/developit/unfetch#usage-as-a-polyfill)), and multiple local `node` versions can be managed using [nvm](https://github.com/nvm-sh/nvm).
|
||||
|
||||
```shell
|
||||
node -v
|
||||
```
|
||||
|
||||
### PNPM
|
||||
If you have not installed `pnpm` before:
|
||||
```shell
|
||||
npm install pnpm -g
|
||||
```
|
||||
|
||||
### Fill in the Keys
|
||||
|
||||
Get `Openai Api Key` or `accessToken` and fill in the local environment variables [jump](#introduction)
|
||||
|
||||
```
|
||||
# service/.env file
|
||||
|
||||
# OpenAI API Key - https://platform.openai.com/overview
|
||||
OPENAI_API_KEY=
|
||||
|
||||
# change this to an `accessToken` extracted from the ChatGPT site's `https://chat.openai.com/api/auth/session` response
|
||||
OPENAI_ACCESS_TOKEN=
|
||||
```
|
||||
|
||||
## Install Dependencies
|
||||
|
||||
> To make it easier for `backend developers` to understand, we did not use the front-end `workspace` mode, but stored it in different folders. If you only need to do secondary development of the front-end page, delete the `service` folder.
|
||||
|
||||
### Backend
|
||||
|
||||
Enter the `/service` folder and run the following command
|
||||
|
||||
```shell
|
||||
pnpm install
|
||||
```
|
||||
|
||||
### Frontend
|
||||
Run the following command in the root directory
|
||||
```shell
|
||||
pnpm bootstrap
|
||||
```
|
||||
|
||||
## Run in Test Environment
|
||||
### Backend Service
|
||||
|
||||
Enter the `/service` folder and run the following command
|
||||
|
||||
```shell
|
||||
pnpm start
|
||||
```
|
||||
|
||||
### Frontend Webpage
|
||||
Run the following command in the root directory
|
||||
```shell
|
||||
pnpm dev
|
||||
```
|
||||
|
||||
## Packaging
|
||||
|
||||
### Using Docker
|
||||
|
||||
#### Docker Parameter Example
|
||||
|
||||
- `OPENAI_API_KEY` one of two
|
||||
- `OPENAI_ACCESS_TOKEN` one of two, `OPENAI_API_KEY` takes precedence when both are present
|
||||
- `OPENAI_API_BASE_URL` optional, available when `OPENAI_API_KEY` is set
|
||||
- `API_REVERSE_PROXY` optional, available when `OPENAI_ACCESS_TOKEN` is set [Reference](#introduction)
|
||||
- `AUTH_SECRET_KEY` Access Password,optional
|
||||
- `TIMEOUT_MS` timeout, in milliseconds, optional
|
||||
- `SOCKS_PROXY_HOST` optional, effective with SOCKS_PROXY_PORT
|
||||
- `SOCKS_PROXY_PORT` optional, effective with SOCKS_PROXY_HOST
|
||||
|
||||

|
||||
|
||||
#### Docker Build & Run
|
||||
|
||||
```bash
|
||||
docker build -t chatgpt-web .
|
||||
|
||||
# foreground operation
|
||||
docker run --name chatgpt-web --rm -it -p 3002:3002 --env OPENAI_API_KEY=your_api_key chatgpt-web
|
||||
|
||||
# background operation
|
||||
docker run --name chatgpt-web -d -p 3002:3002 --env OPENAI_API_KEY=your_api_key chatgpt-web
|
||||
|
||||
# running address
|
||||
http://localhost:3002/
|
||||
```
|
||||
|
||||
#### Docker Compose
|
||||
|
||||
[Hub Address](https://hub.docker.com/repository/docker/chenzhaoyu94/chatgpt-web/general)
|
||||
|
||||
```yml
|
||||
version: '3'
|
||||
|
||||
services:
|
||||
app:
|
||||
image: chenzhaoyu94/chatgpt-web # always use latest, pull the tag image again when updating
|
||||
ports:
|
||||
- 3002:3002
|
||||
environment:
|
||||
# one of two
|
||||
OPENAI_API_KEY: xxxxxx
|
||||
# one of two
|
||||
OPENAI_ACCESS_TOKEN: xxxxxx
|
||||
# api interface url, optional, available when OPENAI_API_KEY is set
|
||||
OPENAI_API_BASE_URL: xxxx
|
||||
# reverse proxy, optional
|
||||
API_REVERSE_PROXY: xxx
|
||||
# access password,optional
|
||||
AUTH_SECRET_KEY: xxx
|
||||
# timeout, in milliseconds, optional
|
||||
TIMEOUT_MS: 60000
|
||||
# socks proxy, optional, effective with SOCKS_PROXY_PORT
|
||||
SOCKS_PROXY_HOST: xxxx
|
||||
# socks proxy port, optional, effective with SOCKS_PROXY_HOST
|
||||
SOCKS_PROXY_PORT: xxxx
|
||||
```
|
||||
The `OPENAI_API_BASE_URL` is optional and only used when setting the `OPENAI_API_KEY`.
|
||||
|
||||
### Deployment with Railway
|
||||
|
||||
[](https://railway.app/new/template/yytmgc)
|
||||
|
||||
#### Railway Environment Variables
|
||||
|
||||
| Environment Variable | Required | Description |
|
||||
| -------------------- | -------- | ------------------------------------------------------------------------------------------------- |
|
||||
| `PORT` | Required | Default: `3002` |
|
||||
| `AUTH_SECRET_KEY` | Optional | access password |
|
||||
| `TIMEOUT_MS` | Optional | Timeout in milliseconds |
|
||||
| `OPENAI_API_KEY` | Optional | Required for `OpenAI API`. `apiKey` can be obtained from [here](https://platform.openai.com/overview). |
|
||||
| `OPENAI_ACCESS_TOKEN`| Optional | Required for `Web API`. `accessToken` can be obtained from [here](https://chat.openai.com/api/auth/session).|
|
||||
| `OPENAI_API_BASE_URL` | Optional, only for `OpenAI API` | API endpoint. |
|
||||
| `API_REVERSE_PROXY` | Optional, only for `Web API` | Reverse proxy address for `Web API`. [Details](https://github.com/transitive-bullshit/chatgpt-api#reverse-proxy) |
|
||||
| `SOCKS_PROXY_HOST` | Optional, effective with `SOCKS_PROXY_PORT` | Socks proxy. |
|
||||
| `SOCKS_PROXY_PORT` | Optional, effective with `SOCKS_PROXY_HOST` | Socks proxy port. |
|
||||
|
||||
> Note: Changing environment variables in Railway will cause re-deployment.
|
||||
|
||||
### Manual packaging
|
||||
|
||||
#### Backend service
|
||||
|
||||
> If you don't need the `node` interface of this project, you can skip the following steps.
|
||||
|
||||
Copy the `service` folder to a server that has a `node` service environment.
|
||||
|
||||
```shell
|
||||
# Install
|
||||
pnpm install
|
||||
|
||||
# Build
|
||||
pnpm build
|
||||
|
||||
# Run
|
||||
pnpm prod
|
||||
```
|
||||
|
||||
PS: You can also run `pnpm start` directly on the server without packaging.
|
||||
|
||||
#### Frontend webpage
|
||||
|
||||
1. Modify `VITE_APP_API_BASE_URL` in `.env` at the root directory to your actual backend interface address.
|
||||
2. Run the following command in the root directory and then copy the files in the `dist` folder to the root directory of your website service.
|
||||
|
||||
[Reference information](https://cn.vitejs.dev/guide/static-deploy.html#building-the-app)
|
||||
|
||||
```shell
|
||||
pnpm build
|
||||
```
|
||||
|
||||
## Frequently Asked Questions
|
||||
|
||||
Q: Why does Git always report an error when committing?
|
||||
|
||||
A: Because there is submission information verification, please follow the [Commit Guidelines](./CONTRIBUTING.en.md).
|
||||
|
||||
Q: Where to change the request interface if only the frontend page is used?
|
||||
|
||||
A: The `VITE_GLOB_API_URL` field in the `.env` file at the root directory.
|
||||
|
||||
Q: All red when saving the file?
|
||||
|
||||
A: For `vscode`, please install the recommended plug-in of the project or manually install the `Eslint` plug-in.
|
||||
|
||||
Q: Why doesn't the frontend have a typewriter effect?
|
||||
|
||||
A: One possible reason is that after Nginx reverse proxying, buffering is turned on, and Nginx will try to buffer a certain amount of data from the backend before sending it to the browser. Please try adding `proxy_buffering off;` after the reverse proxy parameter and then reloading Nginx. Other web server configurations are similar.
|
||||
|
||||
## Contributing
|
||||
|
||||
Please read the [Contributing Guidelines](./CONTRIBUTING.en.md) before contributing.
|
||||
|
||||
Thanks to all the contributors!
|
||||
|
||||
<a href="https://github.com/Chanzhaoyu/chatgpt-web/graphs/contributors">
|
||||
<img src="https://contrib.rocks/image?repo=Chanzhaoyu/chatgpt-web" />
|
||||
</a>
|
||||
|
||||
## Sponsorship
|
||||
|
||||
If you find this project helpful and circumstances permit, you can give me a little support. Thank you very much for your support~
|
||||
|
||||
<div style="display: flex; gap: 20px;">
|
||||
<div style="text-align: center">
|
||||
<img style="max-width: 100%" src="./docs/wechat.png" alt="WeChat" />
|
||||
<p>WeChat Pay</p>
|
||||
</div>
|
||||
<div style="text-align: center">
|
||||
<img style="max-width: 100%" src="./docs/alipay.png" alt="Alipay" />
|
||||
<p>Alipay</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
## License
|
||||
MIT © [ChenZhaoYu](./license)
|
||||
26
README.md
26
README.md
@@ -1,5 +1,11 @@
|
||||
# ChatGPT Web
|
||||
|
||||
<div style="font-size: 1.5rem;">
|
||||
<a href="./README.md">中文</a> |
|
||||
<a href="./README.en.md">English</a>
|
||||
</div>
|
||||
</br>
|
||||
|
||||
> 声明:此项目只发布于 Github,基于 MIT 协议,免费且作为开源学习使用。并且不会有任何形式的卖号、付费服务、讨论群、讨论组等行为。谨防受骗。
|
||||
|
||||

|
||||
@@ -55,7 +61,7 @@
|
||||
|
||||
反向代理:
|
||||
|
||||
`ChatGPTUnofficialProxyAPI`时可用
|
||||
`ChatGPTUnofficialProxyAPI`时可用,[详情](https://github.com/transitive-bullshit/chatgpt-api#reverse-proxy)
|
||||
|
||||
```shell
|
||||
# service/.env
|
||||
@@ -77,6 +83,12 @@ API_REVERSE_PROXY=
|
||||
|
||||
[✓] 对代码等消息类型的格式化美化处理
|
||||
|
||||
[✓] 访问权限控制
|
||||
|
||||
[✓] 数据导入、导出
|
||||
|
||||
[✓] 保存消息到本地图片
|
||||
|
||||
[✓] 界面多语言
|
||||
|
||||
[✓] 界面主题
|
||||
@@ -155,6 +167,7 @@ pnpm dev
|
||||
- `OPENAI_ACCESS_TOKEN` 二选一,同时存在时,`OPENAI_API_KEY` 优先
|
||||
- `OPENAI_API_BASE_URL` 可选,设置 `OPENAI_API_KEY` 时可用
|
||||
- `API_REVERSE_PROXY` 可选,设置 `OPENAI_ACCESS_TOKEN` 时可用 [参考](#介绍)
|
||||
- `AUTH_SECRET_KEY` 访问权限密钥,可选
|
||||
- `TIMEOUT_MS` 超时,单位毫秒,可选
|
||||
- `SOCKS_PROXY_HOST` 可选,和 SOCKS_PROXY_PORT 一起时生效
|
||||
- `SOCKS_PROXY_PORT` 可选,和 SOCKS_PROXY_HOST 一起时生效
|
||||
@@ -197,6 +210,8 @@ services:
|
||||
OPENAI_API_BASE_URL: xxxx
|
||||
# 反向代理,可选
|
||||
API_REVERSE_PROXY: xxx
|
||||
# 访问权限密钥,可选
|
||||
AUTH_SECRET_KEY: xxx
|
||||
# 超时,单位毫秒,可选
|
||||
TIMEOUT_MS: 60000
|
||||
# Socks代理,可选,和 SOCKS_PROXY_PORT 一起时生效
|
||||
@@ -213,8 +228,9 @@ services:
|
||||
|
||||
| 环境变量名称 | 必填 | 备注 |
|
||||
| --------------------- | ---------------------- | -------------------------------------------------------------------------------------------------- |
|
||||
| `PORT` | 必填 | 默认 `3002` |
|
||||
| `TIMEOUT_MS` | 可选 | 超时时间,单位毫秒, |
|
||||
| `PORT` | 必填 | 默认 `3002`
|
||||
| `AUTH_SECRET_KEY` | 可选 | 访问权限密钥 |
|
||||
| `TIMEOUT_MS` | 可选 | 超时时间,单位毫秒 |
|
||||
| `OPENAI_API_KEY` | `OpenAI API` 二选一 | 使用 `OpenAI API` 所需的 `apiKey` [(获取 apiKey)](https://platform.openai.com/overview) |
|
||||
| `OPENAI_ACCESS_TOKEN` | `Web API` 二选一 | 使用 `Web API` 所需的 `accessToken` [(获取 accessToken)](https://chat.openai.com/api/auth/session) |
|
||||
| `OPENAI_API_BASE_URL` | 可选,`OpenAI API` 时可用 | `API`接口地址 |
|
||||
@@ -268,6 +284,10 @@ Q: 文件保存时全部爆红?
|
||||
|
||||
A: `vscode` 请安装项目推荐插件,或手动安装 `Eslint` 插件。
|
||||
|
||||
Q: 前端没有打字机效果?
|
||||
|
||||
A: 一种可能原因是经过 Nginx 反向代理,开启了 buffer,则 Nginx 会尝试从后端缓冲一定大小的数据再发送给浏览器。请尝试在反代参数后添加 `proxy_buffering off;`,然后重载 Nginx。其他 web server 配置同理。
|
||||
|
||||
## 参与贡献
|
||||
|
||||
贡献之前请先阅读 [贡献指南](./CONTRIBUTING.md)
|
||||
|
||||
@@ -14,6 +14,8 @@ services:
|
||||
OPENAI_API_BASE_URL: xxxx
|
||||
# 反向代理,可选
|
||||
API_REVERSE_PROXY: xxx
|
||||
# 访问权限密钥,可选
|
||||
AUTH_SECRET_KEY: xxx
|
||||
# 超时,单位毫秒,可选
|
||||
TIMEOUT_MS: 60000
|
||||
# Socks代理,可选,和 SOCKS_PROXY_PORT 一起时生效
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "chatgpt-web",
|
||||
"version": "2.9.2",
|
||||
"version": "2.10.0",
|
||||
"private": false,
|
||||
"description": "ChatGPT Web",
|
||||
"author": "ChenZhaoYu <chenzhaoyu1994@gmail.com>",
|
||||
@@ -23,10 +23,12 @@
|
||||
"common:prepare": "husky install"
|
||||
},
|
||||
"dependencies": {
|
||||
"@traptitech/markdown-it-katex": "^3.6.0",
|
||||
"@vueuse/core": "^9.13.0",
|
||||
"highlight.js": "^11.7.0",
|
||||
"html2canvas": "^1.4.1",
|
||||
"katex": "^0.16.4",
|
||||
"marked": "^4.2.12",
|
||||
"markdown-it": "^13.0.1",
|
||||
"naive-ui": "^2.34.3",
|
||||
"pinia": "^2.0.32",
|
||||
"vue": "^3.2.47",
|
||||
@@ -40,7 +42,7 @@
|
||||
"@iconify/vue": "^4.1.0",
|
||||
"@types/crypto-js": "^4.1.1",
|
||||
"@types/katex": "^0.16.0",
|
||||
"@types/marked": "^4.0.8",
|
||||
"@types/markdown-it": "^12.2.3",
|
||||
"@types/node": "^18.14.6",
|
||||
"@vitejs/plugin-vue": "^4.0.0",
|
||||
"autoprefixer": "^10.4.13",
|
||||
|
||||
144
pnpm-lock.yaml
generated
144
pnpm-lock.yaml
generated
@@ -5,9 +5,10 @@ specifiers:
|
||||
'@commitlint/cli': ^17.4.4
|
||||
'@commitlint/config-conventional': ^17.4.4
|
||||
'@iconify/vue': ^4.1.0
|
||||
'@traptitech/markdown-it-katex': ^3.6.0
|
||||
'@types/crypto-js': ^4.1.1
|
||||
'@types/katex': ^0.16.0
|
||||
'@types/marked': ^4.0.8
|
||||
'@types/markdown-it': ^12.2.3
|
||||
'@types/node': ^18.14.6
|
||||
'@vitejs/plugin-vue': ^4.0.0
|
||||
'@vueuse/core': ^9.13.0
|
||||
@@ -16,11 +17,12 @@ specifiers:
|
||||
crypto-js: ^4.1.1
|
||||
eslint: ^8.35.0
|
||||
highlight.js: ^11.7.0
|
||||
html2canvas: ^1.4.1
|
||||
husky: ^8.0.3
|
||||
katex: ^0.16.4
|
||||
less: ^4.1.3
|
||||
lint-staged: ^13.1.2
|
||||
marked: ^4.2.12
|
||||
markdown-it: ^13.0.1
|
||||
naive-ui: ^2.34.3
|
||||
npm-run-all: ^4.1.5
|
||||
pinia: ^2.0.32
|
||||
@@ -35,12 +37,14 @@ specifiers:
|
||||
vue-tsc: ^1.2.0
|
||||
|
||||
dependencies:
|
||||
'@traptitech/markdown-it-katex': 3.6.0
|
||||
'@vueuse/core': 9.13.0_vue@3.2.47
|
||||
highlight.js: 11.7.0
|
||||
html2canvas: 1.4.1
|
||||
katex: 0.16.4
|
||||
marked: 4.2.12
|
||||
markdown-it: 13.0.1
|
||||
naive-ui: 2.34.3_vue@3.2.47
|
||||
pinia: 2.0.32_hmuptsblhheur2tugfgucj7gc4
|
||||
pinia: 2.0.33_hmuptsblhheur2tugfgucj7gc4
|
||||
vue: 3.2.47
|
||||
vue-i18n: 9.2.2_vue@3.2.47
|
||||
vue-router: 4.1.6_vue@3.2.47
|
||||
@@ -52,7 +56,7 @@ devDependencies:
|
||||
'@iconify/vue': 4.1.0_vue@3.2.47
|
||||
'@types/crypto-js': 4.1.1
|
||||
'@types/katex': 0.16.0
|
||||
'@types/marked': 4.0.8
|
||||
'@types/markdown-it': 12.2.3
|
||||
'@types/node': 18.14.6
|
||||
'@vitejs/plugin-vue': 4.0.0_vite@4.1.4+vue@3.2.47
|
||||
autoprefixer: 10.4.13_postcss@8.4.21
|
||||
@@ -64,7 +68,7 @@ devDependencies:
|
||||
lint-staged: 13.1.2
|
||||
npm-run-all: 4.1.5
|
||||
postcss: 8.4.21
|
||||
rimraf: 4.2.0
|
||||
rimraf: 4.3.0
|
||||
tailwindcss: 3.2.7_postcss@8.4.21
|
||||
typescript: 4.9.5
|
||||
vite: 4.1.4_4l5pdn5ozbjpiwj3fcgseihr44
|
||||
@@ -600,11 +604,11 @@ packages:
|
||||
dev: true
|
||||
optional: true
|
||||
|
||||
/@eslint-community/eslint-utils/4.1.2_eslint@8.35.0:
|
||||
resolution: {integrity: sha512-7qELuQWWjVDdVsFQ5+beUl+KPczrEDA7S3zM4QUd/bJl7oXgsmpXaEVqrRTnOBqenOV4rWf2kVZk2Ot085zPWA==}
|
||||
/@eslint-community/eslint-utils/4.2.0_eslint@8.35.0:
|
||||
resolution: {integrity: sha512-gB8T4H4DEfX2IV9zGDJPOBgP1e/DbfCPDTtEqUMckpvzS1OYtva8JdFYBqMwYk7xAQ429WGF/UPqn8uQ//h2vQ==}
|
||||
engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0}
|
||||
peerDependencies:
|
||||
eslint: ^6.0.0 || ^7.0.0 || ^8.0.0
|
||||
eslint: ^6.0.0 || ^7.0.0 || >=8.0.0
|
||||
dependencies:
|
||||
eslint: 8.35.0
|
||||
eslint-visitor-keys: 3.3.0
|
||||
@@ -744,6 +748,12 @@ packages:
|
||||
fastq: 1.15.0
|
||||
dev: true
|
||||
|
||||
/@traptitech/markdown-it-katex/3.6.0:
|
||||
resolution: {integrity: sha512-CnJzTWxsgLGXFdSrWRaGz7GZ1kUUi8g3E9HzJmeveX1YwVJavrKYqysktfHZQsujdnRqV5O7g8FPKEA/aeTkOQ==}
|
||||
dependencies:
|
||||
katex: 0.16.4
|
||||
dev: false
|
||||
|
||||
/@tsconfig/node10/1.0.9:
|
||||
resolution: {integrity: sha512-jNsYVVxU8v5g43Erja32laIDHXeoNvFEpX33OK4d6hljo3jDhCBDhx5dhCCTMWUojscpAagGiRkBKxpdl9fxqA==}
|
||||
dev: true
|
||||
@@ -780,6 +790,10 @@ packages:
|
||||
resolution: {integrity: sha512-hz+S3nV6Mym5xPbT9fnO8dDhBFQguMYpY0Ipxv06JMi1ORgnEM4M1ymWDUhUNer3ElLmT583opRo4RzxKmh9jw==}
|
||||
dev: true
|
||||
|
||||
/@types/linkify-it/3.0.2:
|
||||
resolution: {integrity: sha512-HZQYqbiFVWufzCwexrvh694SOim8z2d+xJl5UNamcvQFejLY/2YUtzXHYi3cHdI7PMlS8ejH2slRAOJQ32aNbA==}
|
||||
dev: true
|
||||
|
||||
/@types/lodash-es/4.17.6:
|
||||
resolution: {integrity: sha512-R+zTeVUKDdfoRxpAryaQNRKk3105Rrgx2CFRClIgRGaqDTdjsm8h6IYA8ir584W3ePzkZfst5xIgDwYrlh9HLg==}
|
||||
dependencies:
|
||||
@@ -790,8 +804,11 @@ packages:
|
||||
resolution: {integrity: sha512-BdZ5BCCvho3EIXw6wUCXHe7rS53AIDPLE+JzwgT+OsJk53oBfbSmZZ7CX4VaRoN78N+TJpFi9QPlfIVNmJYWxQ==}
|
||||
dev: false
|
||||
|
||||
/@types/marked/4.0.8:
|
||||
resolution: {integrity: sha512-HVNzMT5QlWCOdeuBsgXP8EZzKUf0+AXzN+sLmjvaB3ZlLqO+e4u0uXrdw9ub69wBKFs+c6/pA4r9sy6cCDvImw==}
|
||||
/@types/markdown-it/12.2.3:
|
||||
resolution: {integrity: sha512-GKMHFfv3458yYy+v/N8gjufHO6MSZKCOXpZc5GXIWWy8uldwfmPn98vp81gZ5f9SVw8YYBctgfJ22a2d7AOMeQ==}
|
||||
dependencies:
|
||||
'@types/linkify-it': 3.0.2
|
||||
'@types/mdurl': 1.0.2
|
||||
dev: true
|
||||
|
||||
/@types/mdast/3.0.10:
|
||||
@@ -800,6 +817,10 @@ packages:
|
||||
'@types/unist': 2.0.6
|
||||
dev: true
|
||||
|
||||
/@types/mdurl/1.0.2:
|
||||
resolution: {integrity: sha512-eC4U9MlIcu2q0KQmXszyn5Akca/0jrQmwDRgpAMJai7qBWq4amIQhZyNau4VYGtCeALvW1/NtjzJJ567aZxfKA==}
|
||||
dev: true
|
||||
|
||||
/@types/minimist/1.2.2:
|
||||
resolution: {integrity: sha512-jhuKLIRrhvCPLqwPcx6INqmKeiA5EWrsCOPhrlFSrbrmU4ZMPjj5Ul/oLCMDO98XRUIwVm78xICz4EPCektzeQ==}
|
||||
dev: true
|
||||
@@ -1232,7 +1253,6 @@ packages:
|
||||
|
||||
/argparse/2.0.1:
|
||||
resolution: {integrity: sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==}
|
||||
dev: true
|
||||
|
||||
/array-ify/1.0.0:
|
||||
resolution: {integrity: sha512-c5AMf34bKdvPhQ7tBGhqkgKNUzMr4WUs+WDtC2ZUGOUncbxKMTvqxYctiseW3+L4bA8ec+GcZ6/A/FW4m8ukng==}
|
||||
@@ -1300,7 +1320,7 @@ packages:
|
||||
postcss: ^8.1.0
|
||||
dependencies:
|
||||
browserslist: 4.21.5
|
||||
caniuse-lite: 1.0.30001458
|
||||
caniuse-lite: 1.0.30001460
|
||||
fraction.js: 4.2.0
|
||||
normalize-range: 0.1.2
|
||||
picocolors: 1.0.0
|
||||
@@ -1327,6 +1347,11 @@ packages:
|
||||
resolution: {integrity: sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==}
|
||||
dev: true
|
||||
|
||||
/base64-arraybuffer/1.0.2:
|
||||
resolution: {integrity: sha512-I3yl4r9QB5ZRY3XuJVEPfc2XhZO6YweFPI+UovAzn+8/hb3oJ6lnysaFcjVpkCPfVWFUDvoZ8kmVDP7WyRtYtQ==}
|
||||
engines: {node: '>= 0.6.0'}
|
||||
dev: false
|
||||
|
||||
/binary-extensions/2.2.0:
|
||||
resolution: {integrity: sha512-jDctJ/IVQbZoJykoeHbhXpOlNBqGNcwXJKJog42E5HDPUwQTSdjCHdihjj0DlnheQ7blbT6dHOafNAiS8ooQKA==}
|
||||
engines: {node: '>=8'}
|
||||
@@ -1361,8 +1386,8 @@ packages:
|
||||
engines: {node: ^6 || ^7 || ^8 || ^9 || ^10 || ^11 || ^12 || >=13.7}
|
||||
hasBin: true
|
||||
dependencies:
|
||||
caniuse-lite: 1.0.30001458
|
||||
electron-to-chromium: 1.4.315
|
||||
caniuse-lite: 1.0.30001460
|
||||
electron-to-chromium: 1.4.320
|
||||
node-releases: 2.0.10
|
||||
update-browserslist-db: 1.0.10_browserslist@4.21.5
|
||||
dev: true
|
||||
@@ -1409,8 +1434,8 @@ packages:
|
||||
engines: {node: '>=6'}
|
||||
dev: true
|
||||
|
||||
/caniuse-lite/1.0.30001458:
|
||||
resolution: {integrity: sha512-lQ1VlUUq5q9ro9X+5gOEyH7i3vm+AYVT1WDCVB69XOZ17KZRhnZ9J0Sqz7wTHQaLBJccNCHq8/Ww5LlOIZbB0w==}
|
||||
/caniuse-lite/1.0.30001460:
|
||||
resolution: {integrity: sha512-Bud7abqjvEjipUkpLs4D7gR0l8hBYBHoa+tGtKJHvT2AYzLp1z7EmVkUT4ERpVUfca8S2HGIVs883D8pUH1ZzQ==}
|
||||
dev: true
|
||||
|
||||
/chalk/2.4.2:
|
||||
@@ -1648,6 +1673,12 @@ packages:
|
||||
resolution: {integrity: sha512-o2JlM7ydqd3Qk9CA0L4NL6mTzU2sdx96a+oOfPu8Mkl/PK51vSyoi8/rQ8NknZtk44vq15lmhAj9CIAGwgeWKw==}
|
||||
dev: true
|
||||
|
||||
/css-line-break/2.1.0:
|
||||
resolution: {integrity: sha512-FHcKFCZcAha3LwfVBhCQbW2nCNbkZXn7KVUJcsT5/P8YmfsVja0FMPJr0B903j/E69HUphKiV9iQArX8SDYA4w==}
|
||||
dependencies:
|
||||
utrie: 1.0.2
|
||||
dev: false
|
||||
|
||||
/css-render/0.15.12:
|
||||
resolution: {integrity: sha512-eWzS66patiGkTTik+ipO9qNGZ+uNuGyTmnz6/+EJIiFg8+3yZRpnMwgFo8YdXhQRsiePzehnusrxVvugNjXzbw==}
|
||||
dependencies:
|
||||
@@ -1829,8 +1860,8 @@ packages:
|
||||
resolution: {integrity: sha512-I88TYZWc9XiYHRQ4/3c5rjjfgkjhLyW2luGIheGERbNQ6OY7yTybanSpDXZa8y7VUP9YmDcYa+eyq4ca7iLqWA==}
|
||||
dev: true
|
||||
|
||||
/electron-to-chromium/1.4.315:
|
||||
resolution: {integrity: sha512-ndBQYz3Eyy3rASjjQ9poMJGoAlsZ/aZnq6GBsGL4w/4sWIAwiUHVSsMuADbxa8WJw7pZ0oxLpGbtoDt4vRTdCg==}
|
||||
/electron-to-chromium/1.4.320:
|
||||
resolution: {integrity: sha512-h70iRscrNluMZPVICXYl5SSB+rBKo22XfuIS1ER0OQxQZpKTnFpuS6coj7wY9M/3trv7OR88rRMOlKmRvDty7Q==}
|
||||
dev: true
|
||||
|
||||
/emoji-regex/8.0.0:
|
||||
@@ -1841,6 +1872,11 @@ packages:
|
||||
resolution: {integrity: sha512-L18DaJsXSUk2+42pv8mLs5jJT2hqFkFE4j21wOmgbUqsZ2hL72NsUU785g9RXgo3s0ZNgVl42TiHp3ZtOv/Vyg==}
|
||||
dev: true
|
||||
|
||||
/entities/3.0.1:
|
||||
resolution: {integrity: sha512-WiyBqoomrwMdFG1e0kqvASYfnlb0lp8M5o5Fw2OFq1hNZxxcNk8Ik0Xm7LxzBhuidnZB/UtBqVCgUz3kBOP51Q==}
|
||||
engines: {node: '>=0.12'}
|
||||
dev: false
|
||||
|
||||
/entities/4.4.0:
|
||||
resolution: {integrity: sha512-oYp7156SP8LkeGD0GF85ad1X9Ai79WtRsZ2gxJqtBuzH+98YUV6jkHEKlZkMbcrjJjIVJNIDP/3WL9wQkoPbWA==}
|
||||
engines: {node: '>=0.12'}
|
||||
@@ -2162,7 +2198,7 @@ packages:
|
||||
eslint: '>=8.28.0'
|
||||
dependencies:
|
||||
'@babel/helper-validator-identifier': 7.19.1
|
||||
'@eslint-community/eslint-utils': 4.1.2_eslint@8.35.0
|
||||
'@eslint-community/eslint-utils': 4.2.0_eslint@8.35.0
|
||||
ci-info: 3.8.0
|
||||
clean-regexp: 1.0.0
|
||||
eslint: 8.35.0
|
||||
@@ -2734,6 +2770,14 @@ packages:
|
||||
lru-cache: 6.0.0
|
||||
dev: true
|
||||
|
||||
/html2canvas/1.4.1:
|
||||
resolution: {integrity: sha512-fPU6BHNpsyIhr8yyMpTLLxAbkaK8ArIBcmZIRiBLiDhjeqvXolaEmDGmELFuX9I4xDcaKKcJl+TKZLqruBbmWA==}
|
||||
engines: {node: '>=8.0.0'}
|
||||
dependencies:
|
||||
css-line-break: 2.1.0
|
||||
text-segmentation: 1.0.3
|
||||
dev: false
|
||||
|
||||
/htmlparser2/8.0.1:
|
||||
resolution: {integrity: sha512-4lVbmc1diZC7GUJQtRQ5yBAeUCL1exyMwmForWkRLnwyzWBFxN633SALPMGYaWZvKe9j1pRZJpauvmxENSp/EA==}
|
||||
dependencies:
|
||||
@@ -3144,10 +3188,21 @@ packages:
|
||||
engines: {node: '>=10'}
|
||||
dev: true
|
||||
|
||||
/lilconfig/2.1.0:
|
||||
resolution: {integrity: sha512-utWOt/GHzuUxnLKxB6dk81RoOeoNeHgbrXiuGk4yyF5qlRz+iIVWu56E2fqGHFrXz0QNUhLB/8nKqvRH66JKGQ==}
|
||||
engines: {node: '>=10'}
|
||||
dev: true
|
||||
|
||||
/lines-and-columns/1.2.4:
|
||||
resolution: {integrity: sha512-7ylylesZQ/PV29jhEDl3Ufjo6ZX7gCqJr5F7PKrqc93v7fzSymt1BpwEU8nAUXs8qzzvqhbjhK5QZg6Mt/HkBg==}
|
||||
dev: true
|
||||
|
||||
/linkify-it/4.0.1:
|
||||
resolution: {integrity: sha512-C7bfi1UZmoj8+PQx22XyeXCuBlokoyWQL5pWSP+EI6nzRylyThouddufc2c1NDIcP9k5agmN9fLpA7VNJfIiqw==}
|
||||
dependencies:
|
||||
uc.micro: 1.0.6
|
||||
dev: false
|
||||
|
||||
/lint-staged/13.1.2:
|
||||
resolution: {integrity: sha512-K9b4FPbWkpnupvK3WXZLbgu9pchUJ6N7TtVZjbaPsoizkqFUDkUReUL25xdrCljJs7uLUF3tZ7nVPeo/6lp+6w==}
|
||||
engines: {node: ^14.13.1 || >=16.0.0}
|
||||
@@ -3283,8 +3338,8 @@ packages:
|
||||
yallist: 4.0.0
|
||||
dev: true
|
||||
|
||||
/lru-cache/7.18.1:
|
||||
resolution: {integrity: sha512-8/HcIENyQnfUTCDizRu9rrDyG6XG/21M4X7/YEGZeD76ZJilFPAUVb/2zysFf7VVO1LEjCDFyHp8pMMvozIrvg==}
|
||||
/lru-cache/7.18.3:
|
||||
resolution: {integrity: sha512-jumlc0BIUrS3qJGgIkWZsyfAM7NCWiBcCDhnd+3NNM5KbBmLTgHVfWBcg6W+rLUsIpzpERPsvwUP7CckAQSOoA==}
|
||||
engines: {node: '>=12'}
|
||||
dev: true
|
||||
|
||||
@@ -3317,10 +3372,15 @@ packages:
|
||||
engines: {node: '>=8'}
|
||||
dev: true
|
||||
|
||||
/marked/4.2.12:
|
||||
resolution: {integrity: sha512-yr8hSKa3Fv4D3jdZmtMMPghgVt6TWbk86WQaWhDloQjRSQhMMYCAro7jP7VDJrjjdV8pxVxMssXS8B8Y5DZ5aw==}
|
||||
engines: {node: '>= 12'}
|
||||
/markdown-it/13.0.1:
|
||||
resolution: {integrity: sha512-lTlxriVoy2criHP0JKRhO2VDG9c2ypWCsT237eDiLqi09rmbKoUetyGHq2uOIRoRS//kfoJckS0eUzzkDR+k2Q==}
|
||||
hasBin: true
|
||||
dependencies:
|
||||
argparse: 2.0.1
|
||||
entities: 3.0.1
|
||||
linkify-it: 4.0.1
|
||||
mdurl: 1.0.1
|
||||
uc.micro: 1.0.6
|
||||
dev: false
|
||||
|
||||
/mdast-util-from-markdown/0.8.5:
|
||||
@@ -3339,6 +3399,10 @@ packages:
|
||||
resolution: {integrity: sha512-AW4DRS3QbBayY/jJmD8437V1Gombjf8RSOUCMFBuo5iHi58AGEgVCKQ+ezHkZZDpAQS75hcBMpLqjpJTjtUL7w==}
|
||||
dev: true
|
||||
|
||||
/mdurl/1.0.1:
|
||||
resolution: {integrity: sha512-/sKlQJCBYVY9Ers9hqzKou4H6V5UWc/M59TH2dvkt+84itfnq7uFOMLpOiOS4ujvHP4etln18fmIxA5R5fll0g==}
|
||||
dev: false
|
||||
|
||||
/memorystream/0.3.1:
|
||||
resolution: {integrity: sha512-S3UwM3yj5mtUSEfP41UZmt/0SCoVYUcU1rkXv+BQ5Ig8ndL4sPoJNBUJERafdPb5jjHJGuMgytgKvKIf58XNBw==}
|
||||
engines: {node: '>= 0.10.0'}
|
||||
@@ -3777,7 +3841,7 @@ packages:
|
||||
resolution: {integrity: sha512-OW+5s+7cw6253Q4E+8qQ/u1fVvcJQCJo/VFD8pje+dbJCF1n5ZRMV2AEHbGp+5Q7jxQIYJxkHopnj6nzdGeZLA==}
|
||||
engines: {node: '>=14'}
|
||||
dependencies:
|
||||
lru-cache: 7.18.1
|
||||
lru-cache: 7.18.3
|
||||
minipass: 4.2.4
|
||||
dev: true
|
||||
|
||||
@@ -3829,8 +3893,8 @@ packages:
|
||||
dev: true
|
||||
optional: true
|
||||
|
||||
/pinia/2.0.32_hmuptsblhheur2tugfgucj7gc4:
|
||||
resolution: {integrity: sha512-8Tw4OrpCSJ028UUyp0gYPP/wyjigLoEceuO/x1G+FlHVf73337e5vLm4uDmrRIoBG1hvaed/eSHnrCFjOc4nkA==}
|
||||
/pinia/2.0.33_hmuptsblhheur2tugfgucj7gc4:
|
||||
resolution: {integrity: sha512-HOj1yVV2itw6rNIrR2f7+MirGNxhORjrULL8GWgRwXsGSvEqIQ+SE0MYt6cwtpegzCda3i+rVTZM+AM7CG+kRg==}
|
||||
peerDependencies:
|
||||
'@vue/composition-api': ^1.4.0
|
||||
typescript: '>=4.4.4'
|
||||
@@ -3886,7 +3950,7 @@ packages:
|
||||
ts-node:
|
||||
optional: true
|
||||
dependencies:
|
||||
lilconfig: 2.0.6
|
||||
lilconfig: 2.1.0
|
||||
postcss: 8.4.21
|
||||
yaml: 1.10.2
|
||||
dev: true
|
||||
@@ -4103,8 +4167,8 @@ packages:
|
||||
glob: 7.2.3
|
||||
dev: true
|
||||
|
||||
/rimraf/4.2.0:
|
||||
resolution: {integrity: sha512-tPt+gLORNVqRCk0NwuJ5SlMEcOGvt4CCU8sUPqgCFtCbnoNCTd9Q6vq7JlBbxQlACiH14OR28y7piA2Bak9Sxw==}
|
||||
/rimraf/4.3.0:
|
||||
resolution: {integrity: sha512-5qVDXPbByA1qSJEWMv1qAwKsoS22vVpsL2QyxCKBw4gf6XiFo1K3uRLY6uSOOBFDwnqAZtnbILqWKKlzh8bkGg==}
|
||||
engines: {node: '>=14'}
|
||||
hasBin: true
|
||||
dependencies:
|
||||
@@ -4422,7 +4486,7 @@ packages:
|
||||
fast-glob: 3.2.12
|
||||
glob-parent: 6.0.2
|
||||
is-glob: 4.0.3
|
||||
lilconfig: 2.0.6
|
||||
lilconfig: 2.1.0
|
||||
micromatch: 4.0.5
|
||||
normalize-path: 3.0.0
|
||||
object-hash: 3.0.0
|
||||
@@ -4445,6 +4509,12 @@ packages:
|
||||
engines: {node: '>=0.10'}
|
||||
dev: true
|
||||
|
||||
/text-segmentation/1.0.3:
|
||||
resolution: {integrity: sha512-iOiPUo/BGnZ6+54OsWxZidGCsdU8YbE4PSpdPinp7DeMtUJNJBoJ/ouUSTJjHkh1KntHaltHl/gDs2FC4i5+Nw==}
|
||||
dependencies:
|
||||
utrie: 1.0.2
|
||||
dev: false
|
||||
|
||||
/text-table/0.2.0:
|
||||
resolution: {integrity: sha512-N+8UisAXDGk8PFXP4HAzVR9nbfmVJ3zYLAWiTIoqC5v5isinhr+r5uaO8+7r3BMfuNIufIsA7RdpVgacC2cSpw==}
|
||||
dev: true
|
||||
@@ -4582,6 +4652,10 @@ packages:
|
||||
engines: {node: '>=4.2.0'}
|
||||
hasBin: true
|
||||
|
||||
/uc.micro/1.0.6:
|
||||
resolution: {integrity: sha512-8Y75pvTYkLJW2hWQHXxoqRgV7qb9B+9vFEtidML+7koHUFapnVJAZ6cKs+Qjz5Aw3aZWHMC6u0wJE3At+nSGwA==}
|
||||
dev: false
|
||||
|
||||
/unbox-primitive/1.0.2:
|
||||
resolution: {integrity: sha512-61pPlCD9h51VoreyJ0BReideM3MDKMKnh6+V9L08331ipq6Q8OFXZYiqP6n/tbHx4s5I9uRhcye6BrbkizkBDw==}
|
||||
dependencies:
|
||||
@@ -4623,6 +4697,12 @@ packages:
|
||||
resolution: {integrity: sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==}
|
||||
dev: true
|
||||
|
||||
/utrie/1.0.2:
|
||||
resolution: {integrity: sha512-1MLa5ouZiOmQzUbjbu9VmjLzn1QLXBhwpUa7kdLUQK+KQ5KA9I1vk5U4YHe/X2Ch7PYnJfWuWT+VbuxbGwljhw==}
|
||||
dependencies:
|
||||
base64-arraybuffer: 1.0.2
|
||||
dev: false
|
||||
|
||||
/v8-compile-cache-lib/3.0.1:
|
||||
resolution: {integrity: sha512-wa7YjyUGfNZngI/vtK0UHAN+lgDCxBPCylVXGp0zu59Fz5aiGtNXaq3DhIov063MorB+VfufLh3JlF2KdTK3xg==}
|
||||
dev: true
|
||||
|
||||
@@ -13,6 +13,9 @@ API_REVERSE_PROXY=
|
||||
# timeout
|
||||
TIMEOUT_MS=100000
|
||||
|
||||
# Secret key
|
||||
AUTH_SECRET_KEY=
|
||||
|
||||
# Socks Proxy Host
|
||||
SOCKS_PROXY_HOST=
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
"common:cleanup": "rimraf node_modules && rimraf pnpm-lock.yaml"
|
||||
},
|
||||
"dependencies": {
|
||||
"chatgpt": "^5.0.6",
|
||||
"chatgpt": "^5.0.8",
|
||||
"dotenv": "^16.0.3",
|
||||
"esno": "^0.16.3",
|
||||
"express": "^4.18.2",
|
||||
@@ -37,7 +37,7 @@
|
||||
"@types/express": "^4.17.17",
|
||||
"@types/node": "^18.14.6",
|
||||
"eslint": "^8.35.0",
|
||||
"rimraf": "^4.2.0",
|
||||
"rimraf": "^4.3.0",
|
||||
"tsup": "^6.6.3",
|
||||
"typescript": "^4.9.5"
|
||||
}
|
||||
|
||||
216
service/pnpm-lock.yaml
generated
216
service/pnpm-lock.yaml
generated
@@ -4,20 +4,20 @@ specifiers:
|
||||
'@antfu/eslint-config': ^0.35.3
|
||||
'@types/express': ^4.17.17
|
||||
'@types/node': ^18.14.6
|
||||
chatgpt: ^5.0.6
|
||||
chatgpt: ^5.0.8
|
||||
dotenv: ^16.0.3
|
||||
eslint: ^8.35.0
|
||||
esno: ^0.16.3
|
||||
express: ^4.18.2
|
||||
isomorphic-fetch: ^3.0.0
|
||||
node-fetch: ^3.3.0
|
||||
rimraf: ^4.2.0
|
||||
rimraf: ^4.3.0
|
||||
socks-proxy-agent: ^7.0.0
|
||||
tsup: ^6.6.3
|
||||
typescript: ^4.9.5
|
||||
|
||||
dependencies:
|
||||
chatgpt: 5.0.6
|
||||
chatgpt: 5.0.8
|
||||
dotenv: 16.0.3
|
||||
esno: 0.16.3
|
||||
express: 4.18.2
|
||||
@@ -30,7 +30,7 @@ devDependencies:
|
||||
'@types/express': 4.17.17
|
||||
'@types/node': 18.14.6
|
||||
eslint: 8.35.0
|
||||
rimraf: 4.2.0
|
||||
rimraf: 4.3.0
|
||||
tsup: 6.6.3_typescript@4.9.5
|
||||
typescript: 4.9.5
|
||||
|
||||
@@ -164,7 +164,7 @@ packages:
|
||||
/@esbuild-kit/core-utils/3.1.0:
|
||||
resolution: {integrity: sha512-Uuk8RpCg/7fdHSceR1M6XbSZFSuMrxcePFuGgyvsBn+u339dk5OeL4jv2EojwTN2st/unJGsVm4qHWjWNmJ/tw==}
|
||||
dependencies:
|
||||
esbuild: 0.17.8
|
||||
esbuild: 0.17.11
|
||||
source-map-support: 0.5.21
|
||||
dev: false
|
||||
|
||||
@@ -175,187 +175,187 @@ packages:
|
||||
get-tsconfig: 4.4.0
|
||||
dev: false
|
||||
|
||||
/@esbuild/android-arm/0.17.8:
|
||||
resolution: {integrity: sha512-0/rb91GYKhrtbeglJXOhAv9RuYimgI8h623TplY2X+vA4EXnk3Zj1fXZreJ0J3OJJu1bwmb0W7g+2cT/d8/l/w==}
|
||||
/@esbuild/android-arm/0.17.11:
|
||||
resolution: {integrity: sha512-CdyX6sRVh1NzFCsf5vw3kULwlAhfy9wVt8SZlrhQ7eL2qBjGbFhRBWkkAzuZm9IIEOCKJw4DXA6R85g+qc8RDw==}
|
||||
engines: {node: '>=12'}
|
||||
cpu: [arm]
|
||||
os: [android]
|
||||
requiresBuild: true
|
||||
optional: true
|
||||
|
||||
/@esbuild/android-arm64/0.17.8:
|
||||
resolution: {integrity: sha512-oa/N5j6v1svZQs7EIRPqR8f+Bf8g6HBDjD/xHC02radE/NjKHK7oQmtmLxPs1iVwYyvE+Kolo6lbpfEQ9xnhxQ==}
|
||||
/@esbuild/android-arm64/0.17.11:
|
||||
resolution: {integrity: sha512-QnK4d/zhVTuV4/pRM4HUjcsbl43POALU2zvBynmrrqZt9LPcLA3x1fTZPBg2RRguBQnJcnU059yKr+bydkntjg==}
|
||||
engines: {node: '>=12'}
|
||||
cpu: [arm64]
|
||||
os: [android]
|
||||
requiresBuild: true
|
||||
optional: true
|
||||
|
||||
/@esbuild/android-x64/0.17.8:
|
||||
resolution: {integrity: sha512-bTliMLqD7pTOoPg4zZkXqCDuzIUguEWLpeqkNfC41ODBHwoUgZ2w5JBeYimv4oP6TDVocoYmEhZrCLQTrH89bg==}
|
||||
/@esbuild/android-x64/0.17.11:
|
||||
resolution: {integrity: sha512-3PL3HKtsDIXGQcSCKtWD/dy+mgc4p2Tvo2qKgKHj9Yf+eniwFnuoQ0OUhlSfAEpKAFzF9N21Nwgnap6zy3L3MQ==}
|
||||
engines: {node: '>=12'}
|
||||
cpu: [x64]
|
||||
os: [android]
|
||||
requiresBuild: true
|
||||
optional: true
|
||||
|
||||
/@esbuild/darwin-arm64/0.17.8:
|
||||
resolution: {integrity: sha512-ghAbV3ia2zybEefXRRm7+lx8J/rnupZT0gp9CaGy/3iolEXkJ6LYRq4IpQVI9zR97ID80KJVoUlo3LSeA/sMAg==}
|
||||
/@esbuild/darwin-arm64/0.17.11:
|
||||
resolution: {integrity: sha512-pJ950bNKgzhkGNO3Z9TeHzIFtEyC2GDQL3wxkMApDEghYx5Qers84UTNc1bAxWbRkuJOgmOha5V0WUeh8G+YGw==}
|
||||
engines: {node: '>=12'}
|
||||
cpu: [arm64]
|
||||
os: [darwin]
|
||||
requiresBuild: true
|
||||
optional: true
|
||||
|
||||
/@esbuild/darwin-x64/0.17.8:
|
||||
resolution: {integrity: sha512-n5WOpyvZ9TIdv2V1K3/iIkkJeKmUpKaCTdun9buhGRWfH//osmUjlv4Z5mmWdPWind/VGcVxTHtLfLCOohsOXw==}
|
||||
/@esbuild/darwin-x64/0.17.11:
|
||||
resolution: {integrity: sha512-iB0dQkIHXyczK3BZtzw1tqegf0F0Ab5texX2TvMQjiJIWXAfM4FQl7D909YfXWnB92OQz4ivBYQ2RlxBJrMJOw==}
|
||||
engines: {node: '>=12'}
|
||||
cpu: [x64]
|
||||
os: [darwin]
|
||||
requiresBuild: true
|
||||
optional: true
|
||||
|
||||
/@esbuild/freebsd-arm64/0.17.8:
|
||||
resolution: {integrity: sha512-a/SATTaOhPIPFWvHZDoZYgxaZRVHn0/LX1fHLGfZ6C13JqFUZ3K6SMD6/HCtwOQ8HnsNaEeokdiDSFLuizqv5A==}
|
||||
/@esbuild/freebsd-arm64/0.17.11:
|
||||
resolution: {integrity: sha512-7EFzUADmI1jCHeDRGKgbnF5sDIceZsQGapoO6dmw7r/ZBEKX7CCDnIz8m9yEclzr7mFsd+DyasHzpjfJnmBB1Q==}
|
||||
engines: {node: '>=12'}
|
||||
cpu: [arm64]
|
||||
os: [freebsd]
|
||||
requiresBuild: true
|
||||
optional: true
|
||||
|
||||
/@esbuild/freebsd-x64/0.17.8:
|
||||
resolution: {integrity: sha512-xpFJb08dfXr5+rZc4E+ooZmayBW6R3q59daCpKZ/cDU96/kvDM+vkYzNeTJCGd8rtO6fHWMq5Rcv/1cY6p6/0Q==}
|
||||
/@esbuild/freebsd-x64/0.17.11:
|
||||
resolution: {integrity: sha512-iPgenptC8i8pdvkHQvXJFzc1eVMR7W2lBPrTE6GbhR54sLcF42mk3zBOjKPOodezzuAz/KSu8CPyFSjcBMkE9g==}
|
||||
engines: {node: '>=12'}
|
||||
cpu: [x64]
|
||||
os: [freebsd]
|
||||
requiresBuild: true
|
||||
optional: true
|
||||
|
||||
/@esbuild/linux-arm/0.17.8:
|
||||
resolution: {integrity: sha512-6Ij8gfuGszcEwZpi5jQIJCVIACLS8Tz2chnEBfYjlmMzVsfqBP1iGmHQPp7JSnZg5xxK9tjCc+pJ2WtAmPRFVA==}
|
||||
/@esbuild/linux-arm/0.17.11:
|
||||
resolution: {integrity: sha512-M9iK/d4lgZH0U5M1R2p2gqhPV/7JPJcRz+8O8GBKVgqndTzydQ7B2XGDbxtbvFkvIs53uXTobOhv+RyaqhUiMg==}
|
||||
engines: {node: '>=12'}
|
||||
cpu: [arm]
|
||||
os: [linux]
|
||||
requiresBuild: true
|
||||
optional: true
|
||||
|
||||
/@esbuild/linux-arm64/0.17.8:
|
||||
resolution: {integrity: sha512-v3iwDQuDljLTxpsqQDl3fl/yihjPAyOguxuloON9kFHYwopeJEf1BkDXODzYyXEI19gisEsQlG1bM65YqKSIww==}
|
||||
/@esbuild/linux-arm64/0.17.11:
|
||||
resolution: {integrity: sha512-Qxth3gsWWGKz2/qG2d5DsW/57SeA2AmpSMhdg9TSB5Svn2KDob3qxfQSkdnWjSd42kqoxIPy3EJFs+6w1+6Qjg==}
|
||||
engines: {node: '>=12'}
|
||||
cpu: [arm64]
|
||||
os: [linux]
|
||||
requiresBuild: true
|
||||
optional: true
|
||||
|
||||
/@esbuild/linux-ia32/0.17.8:
|
||||
resolution: {integrity: sha512-8svILYKhE5XetuFk/B6raFYIyIqydQi+GngEXJgdPdI7OMKUbSd7uzR02wSY4kb53xBrClLkhH4Xs8P61Q2BaA==}
|
||||
/@esbuild/linux-ia32/0.17.11:
|
||||
resolution: {integrity: sha512-dB1nGaVWtUlb/rRDHmuDQhfqazWE0LMro/AIbT2lWM3CDMHJNpLckH+gCddQyhhcLac2OYw69ikUMO34JLt3wA==}
|
||||
engines: {node: '>=12'}
|
||||
cpu: [ia32]
|
||||
os: [linux]
|
||||
requiresBuild: true
|
||||
optional: true
|
||||
|
||||
/@esbuild/linux-loong64/0.17.8:
|
||||
resolution: {integrity: sha512-B6FyMeRJeV0NpyEOYlm5qtQfxbdlgmiGdD+QsipzKfFky0K5HW5Td6dyK3L3ypu1eY4kOmo7wW0o94SBqlqBSA==}
|
||||
/@esbuild/linux-loong64/0.17.11:
|
||||
resolution: {integrity: sha512-aCWlq70Q7Nc9WDnormntGS1ar6ZFvUpqr8gXtO+HRejRYPweAFQN615PcgaSJkZjhHp61+MNLhzyVALSF2/Q0g==}
|
||||
engines: {node: '>=12'}
|
||||
cpu: [loong64]
|
||||
os: [linux]
|
||||
requiresBuild: true
|
||||
optional: true
|
||||
|
||||
/@esbuild/linux-mips64el/0.17.8:
|
||||
resolution: {integrity: sha512-CCb67RKahNobjm/eeEqeD/oJfJlrWyw29fgiyB6vcgyq97YAf3gCOuP6qMShYSPXgnlZe/i4a8WFHBw6N8bYAA==}
|
||||
/@esbuild/linux-mips64el/0.17.11:
|
||||
resolution: {integrity: sha512-cGeGNdQxqY8qJwlYH1BP6rjIIiEcrM05H7k3tR7WxOLmD1ZxRMd6/QIOWMb8mD2s2YJFNRuNQ+wjMhgEL2oCEw==}
|
||||
engines: {node: '>=12'}
|
||||
cpu: [mips64el]
|
||||
os: [linux]
|
||||
requiresBuild: true
|
||||
optional: true
|
||||
|
||||
/@esbuild/linux-ppc64/0.17.8:
|
||||
resolution: {integrity: sha512-bytLJOi55y55+mGSdgwZ5qBm0K9WOCh0rx+vavVPx+gqLLhxtSFU0XbeYy/dsAAD6xECGEv4IQeFILaSS2auXw==}
|
||||
/@esbuild/linux-ppc64/0.17.11:
|
||||
resolution: {integrity: sha512-BdlziJQPW/bNe0E8eYsHB40mYOluS+jULPCjlWiHzDgr+ZBRXPtgMV1nkLEGdpjrwgmtkZHEGEPaKdS/8faLDA==}
|
||||
engines: {node: '>=12'}
|
||||
cpu: [ppc64]
|
||||
os: [linux]
|
||||
requiresBuild: true
|
||||
optional: true
|
||||
|
||||
/@esbuild/linux-riscv64/0.17.8:
|
||||
resolution: {integrity: sha512-2YpRyQJmKVBEHSBLa8kBAtbhucaclb6ex4wchfY0Tj3Kg39kpjeJ9vhRU7x4mUpq8ISLXRXH1L0dBYjAeqzZAw==}
|
||||
/@esbuild/linux-riscv64/0.17.11:
|
||||
resolution: {integrity: sha512-MDLwQbtF+83oJCI1Cixn68Et/ME6gelmhssPebC40RdJaect+IM+l7o/CuG0ZlDs6tZTEIoxUe53H3GmMn8oMA==}
|
||||
engines: {node: '>=12'}
|
||||
cpu: [riscv64]
|
||||
os: [linux]
|
||||
requiresBuild: true
|
||||
optional: true
|
||||
|
||||
/@esbuild/linux-s390x/0.17.8:
|
||||
resolution: {integrity: sha512-QgbNY/V3IFXvNf11SS6exkpVcX0LJcob+0RWCgV9OiDAmVElnxciHIisoSix9uzYzScPmS6dJFbZULdSAEkQVw==}
|
||||
/@esbuild/linux-s390x/0.17.11:
|
||||
resolution: {integrity: sha512-4N5EMESvws0Ozr2J94VoUD8HIRi7X0uvUv4c0wpTHZyZY9qpaaN7THjosdiW56irQ4qnJ6Lsc+i+5zGWnyqWqQ==}
|
||||
engines: {node: '>=12'}
|
||||
cpu: [s390x]
|
||||
os: [linux]
|
||||
requiresBuild: true
|
||||
optional: true
|
||||
|
||||
/@esbuild/linux-x64/0.17.8:
|
||||
resolution: {integrity: sha512-mM/9S0SbAFDBc4OPoyP6SEOo5324LpUxdpeIUUSrSTOfhHU9hEfqRngmKgqILqwx/0DVJBzeNW7HmLEWp9vcOA==}
|
||||
/@esbuild/linux-x64/0.17.11:
|
||||
resolution: {integrity: sha512-rM/v8UlluxpytFSmVdbCe1yyKQd/e+FmIJE2oPJvbBo+D0XVWi1y/NQ4iTNx+436WmDHQBjVLrbnAQLQ6U7wlw==}
|
||||
engines: {node: '>=12'}
|
||||
cpu: [x64]
|
||||
os: [linux]
|
||||
requiresBuild: true
|
||||
optional: true
|
||||
|
||||
/@esbuild/netbsd-x64/0.17.8:
|
||||
resolution: {integrity: sha512-eKUYcWaWTaYr9zbj8GertdVtlt1DTS1gNBWov+iQfWuWyuu59YN6gSEJvFzC5ESJ4kMcKR0uqWThKUn5o8We6Q==}
|
||||
/@esbuild/netbsd-x64/0.17.11:
|
||||
resolution: {integrity: sha512-4WaAhuz5f91h3/g43VBGdto1Q+X7VEZfpcWGtOFXnggEuLvjV+cP6DyLRU15IjiU9fKLLk41OoJfBFN5DhPvag==}
|
||||
engines: {node: '>=12'}
|
||||
cpu: [x64]
|
||||
os: [netbsd]
|
||||
requiresBuild: true
|
||||
optional: true
|
||||
|
||||
/@esbuild/openbsd-x64/0.17.8:
|
||||
resolution: {integrity: sha512-Vc9J4dXOboDyMXKD0eCeW0SIeEzr8K9oTHJU+Ci1mZc5njPfhKAqkRt3B/fUNU7dP+mRyralPu8QUkiaQn7iIg==}
|
||||
/@esbuild/openbsd-x64/0.17.11:
|
||||
resolution: {integrity: sha512-UBj135Nx4FpnvtE+C8TWGp98oUgBcmNmdYgl5ToKc0mBHxVVqVE7FUS5/ELMImOp205qDAittL6Ezhasc2Ev/w==}
|
||||
engines: {node: '>=12'}
|
||||
cpu: [x64]
|
||||
os: [openbsd]
|
||||
requiresBuild: true
|
||||
optional: true
|
||||
|
||||
/@esbuild/sunos-x64/0.17.8:
|
||||
resolution: {integrity: sha512-0xvOTNuPXI7ft1LYUgiaXtpCEjp90RuBBYovdd2lqAFxje4sEucurg30M1WIm03+3jxByd3mfo+VUmPtRSVuOw==}
|
||||
/@esbuild/sunos-x64/0.17.11:
|
||||
resolution: {integrity: sha512-1/gxTifDC9aXbV2xOfCbOceh5AlIidUrPsMpivgzo8P8zUtczlq1ncFpeN1ZyQJ9lVs2hILy1PG5KPp+w8QPPg==}
|
||||
engines: {node: '>=12'}
|
||||
cpu: [x64]
|
||||
os: [sunos]
|
||||
requiresBuild: true
|
||||
optional: true
|
||||
|
||||
/@esbuild/win32-arm64/0.17.8:
|
||||
resolution: {integrity: sha512-G0JQwUI5WdEFEnYNKzklxtBheCPkuDdu1YrtRrjuQv30WsYbkkoixKxLLv8qhJmNI+ATEWquZe/N0d0rpr55Mg==}
|
||||
/@esbuild/win32-arm64/0.17.11:
|
||||
resolution: {integrity: sha512-vtSfyx5yRdpiOW9yp6Ax0zyNOv9HjOAw8WaZg3dF5djEHKKm3UnoohftVvIJtRh0Ec7Hso0RIdTqZvPXJ7FdvQ==}
|
||||
engines: {node: '>=12'}
|
||||
cpu: [arm64]
|
||||
os: [win32]
|
||||
requiresBuild: true
|
||||
optional: true
|
||||
|
||||
/@esbuild/win32-ia32/0.17.8:
|
||||
resolution: {integrity: sha512-Fqy63515xl20OHGFykjJsMnoIWS+38fqfg88ClvPXyDbLtgXal2DTlhb1TfTX34qWi3u4I7Cq563QcHpqgLx8w==}
|
||||
/@esbuild/win32-ia32/0.17.11:
|
||||
resolution: {integrity: sha512-GFPSLEGQr4wHFTiIUJQrnJKZhZjjq4Sphf+mM76nQR6WkQn73vm7IsacmBRPkALfpOCHsopSvLgqdd4iUW2mYw==}
|
||||
engines: {node: '>=12'}
|
||||
cpu: [ia32]
|
||||
os: [win32]
|
||||
requiresBuild: true
|
||||
optional: true
|
||||
|
||||
/@esbuild/win32-x64/0.17.8:
|
||||
resolution: {integrity: sha512-1iuezdyDNngPnz8rLRDO2C/ZZ/emJLb72OsZeqQ6gL6Avko/XCXZw+NuxBSNhBAP13Hie418V7VMt9et1FMvpg==}
|
||||
/@esbuild/win32-x64/0.17.11:
|
||||
resolution: {integrity: sha512-N9vXqLP3eRL8BqSy8yn4Y98cZI2pZ8fyuHx6lKjiG2WABpT2l01TXdzq5Ma2ZUBzfB7tx5dXVhge8X9u0S70ZQ==}
|
||||
engines: {node: '>=12'}
|
||||
cpu: [x64]
|
||||
os: [win32]
|
||||
requiresBuild: true
|
||||
optional: true
|
||||
|
||||
/@eslint-community/eslint-utils/4.1.2_eslint@8.35.0:
|
||||
resolution: {integrity: sha512-7qELuQWWjVDdVsFQ5+beUl+KPczrEDA7S3zM4QUd/bJl7oXgsmpXaEVqrRTnOBqenOV4rWf2kVZk2Ot085zPWA==}
|
||||
/@eslint-community/eslint-utils/4.2.0_eslint@8.35.0:
|
||||
resolution: {integrity: sha512-gB8T4H4DEfX2IV9zGDJPOBgP1e/DbfCPDTtEqUMckpvzS1OYtva8JdFYBqMwYk7xAQ429WGF/UPqn8uQ//h2vQ==}
|
||||
engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0}
|
||||
peerDependencies:
|
||||
eslint: ^6.0.0 || ^7.0.0 || ^8.0.0
|
||||
eslint: ^6.0.0 || ^7.0.0 || >=8.0.0
|
||||
dependencies:
|
||||
eslint: 8.35.0
|
||||
eslint-visitor-keys: 3.3.0
|
||||
@@ -451,7 +451,7 @@ packages:
|
||||
'@types/body-parser': 1.19.2
|
||||
'@types/express-serve-static-core': 4.17.33
|
||||
'@types/qs': 6.9.7
|
||||
'@types/serve-static': 1.15.0
|
||||
'@types/serve-static': 1.15.1
|
||||
dev: true
|
||||
|
||||
/@types/json-schema/7.0.11:
|
||||
@@ -491,8 +491,8 @@ packages:
|
||||
resolution: {integrity: sha512-21cFJr9z3g5dW8B0CVI9g2O9beqaThGQ6ZFBqHfwhzLDKUxaqTIy3vnfah/UPkfOiF2pLq+tGz+W8RyCskuslw==}
|
||||
dev: true
|
||||
|
||||
/@types/serve-static/1.15.0:
|
||||
resolution: {integrity: sha512-z5xyF6uh8CbjAu9760KDKsH2FcDxZ2tFCsA4HIMWE6IkiYMXfVoa+4f9KX+FN0ZLsaMw1WNG2ETLA6N+/YA+cg==}
|
||||
/@types/serve-static/1.15.1:
|
||||
resolution: {integrity: sha512-NUo5XNiAdULrJENtJXZZ3fHtfMolzZwczzBbnAeBbqBwG+LaG6YaJtuwzwGSQZ2wsCrxjEhNNjAkKigy3n8teQ==}
|
||||
dependencies:
|
||||
'@types/mime': 3.0.1
|
||||
'@types/node': 18.14.6
|
||||
@@ -844,13 +844,13 @@ packages:
|
||||
semver: 7.3.8
|
||||
dev: true
|
||||
|
||||
/bundle-require/4.0.1_esbuild@0.17.8:
|
||||
/bundle-require/4.0.1_esbuild@0.17.11:
|
||||
resolution: {integrity: sha512-9NQkRHlNdNpDBGmLpngF3EFDcwodhMUuLz9PaWYciVcQF9SE4LFjM2DB/xV1Li5JiuDMv7ZUWuC3rGbqR0MAXQ==}
|
||||
engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0}
|
||||
peerDependencies:
|
||||
esbuild: '>=0.17'
|
||||
dependencies:
|
||||
esbuild: 0.17.8
|
||||
esbuild: 0.17.11
|
||||
load-tsconfig: 0.2.3
|
||||
dev: true
|
||||
|
||||
@@ -902,8 +902,8 @@ packages:
|
||||
resolution: {integrity: sha512-mKKUkUbhPpQlCOfIuZkvSEgktjPFIsZKRRbC6KWVEMvlzblj3i3asQv5ODsrwt0N3pHAEvjP8KTQPHkp0+6jOg==}
|
||||
dev: true
|
||||
|
||||
/chatgpt/5.0.6:
|
||||
resolution: {integrity: sha512-BQ0eN2GpAlw9ojsxkHmW+bTuekbllZbOkKqjDSIVSMtbMoYDx59vcg6xXnCPkB0OBFGuG89eqGhLAfMIW34Hcw==}
|
||||
/chatgpt/5.0.8:
|
||||
resolution: {integrity: sha512-Bjh7Y15QIsZ+SkQvbbZGymv1PGxkZ7X1vwqAwvyqaMMhbipU4kxht/GL62VCxhoUCXPwxTfScbFeNFtNldgqaw==}
|
||||
engines: {node: '>=14'}
|
||||
hasBin: true
|
||||
dependencies:
|
||||
@@ -1193,7 +1193,7 @@ packages:
|
||||
has-proto: 1.0.1
|
||||
has-symbols: 1.0.3
|
||||
internal-slot: 1.0.5
|
||||
is-array-buffer: 3.0.1
|
||||
is-array-buffer: 3.0.2
|
||||
is-callable: 1.2.7
|
||||
is-negative-zero: 2.0.2
|
||||
is-regex: 1.1.4
|
||||
@@ -1237,34 +1237,34 @@ packages:
|
||||
is-symbol: 1.0.4
|
||||
dev: true
|
||||
|
||||
/esbuild/0.17.8:
|
||||
resolution: {integrity: sha512-g24ybC3fWhZddZK6R3uD2iF/RIPnRpwJAqLov6ouX3hMbY4+tKolP0VMF3zuIYCaXun+yHwS5IPQ91N2BT191g==}
|
||||
/esbuild/0.17.11:
|
||||
resolution: {integrity: sha512-pAMImyokbWDtnA/ufPxjQg0fYo2DDuzAlqwnDvbXqHLphe+m80eF++perYKVm8LeTuj2zUuFXC+xgSVxyoHUdg==}
|
||||
engines: {node: '>=12'}
|
||||
hasBin: true
|
||||
requiresBuild: true
|
||||
optionalDependencies:
|
||||
'@esbuild/android-arm': 0.17.8
|
||||
'@esbuild/android-arm64': 0.17.8
|
||||
'@esbuild/android-x64': 0.17.8
|
||||
'@esbuild/darwin-arm64': 0.17.8
|
||||
'@esbuild/darwin-x64': 0.17.8
|
||||
'@esbuild/freebsd-arm64': 0.17.8
|
||||
'@esbuild/freebsd-x64': 0.17.8
|
||||
'@esbuild/linux-arm': 0.17.8
|
||||
'@esbuild/linux-arm64': 0.17.8
|
||||
'@esbuild/linux-ia32': 0.17.8
|
||||
'@esbuild/linux-loong64': 0.17.8
|
||||
'@esbuild/linux-mips64el': 0.17.8
|
||||
'@esbuild/linux-ppc64': 0.17.8
|
||||
'@esbuild/linux-riscv64': 0.17.8
|
||||
'@esbuild/linux-s390x': 0.17.8
|
||||
'@esbuild/linux-x64': 0.17.8
|
||||
'@esbuild/netbsd-x64': 0.17.8
|
||||
'@esbuild/openbsd-x64': 0.17.8
|
||||
'@esbuild/sunos-x64': 0.17.8
|
||||
'@esbuild/win32-arm64': 0.17.8
|
||||
'@esbuild/win32-ia32': 0.17.8
|
||||
'@esbuild/win32-x64': 0.17.8
|
||||
'@esbuild/android-arm': 0.17.11
|
||||
'@esbuild/android-arm64': 0.17.11
|
||||
'@esbuild/android-x64': 0.17.11
|
||||
'@esbuild/darwin-arm64': 0.17.11
|
||||
'@esbuild/darwin-x64': 0.17.11
|
||||
'@esbuild/freebsd-arm64': 0.17.11
|
||||
'@esbuild/freebsd-x64': 0.17.11
|
||||
'@esbuild/linux-arm': 0.17.11
|
||||
'@esbuild/linux-arm64': 0.17.11
|
||||
'@esbuild/linux-ia32': 0.17.11
|
||||
'@esbuild/linux-loong64': 0.17.11
|
||||
'@esbuild/linux-mips64el': 0.17.11
|
||||
'@esbuild/linux-ppc64': 0.17.11
|
||||
'@esbuild/linux-riscv64': 0.17.11
|
||||
'@esbuild/linux-s390x': 0.17.11
|
||||
'@esbuild/linux-x64': 0.17.11
|
||||
'@esbuild/netbsd-x64': 0.17.11
|
||||
'@esbuild/openbsd-x64': 0.17.11
|
||||
'@esbuild/sunos-x64': 0.17.11
|
||||
'@esbuild/win32-arm64': 0.17.11
|
||||
'@esbuild/win32-ia32': 0.17.11
|
||||
'@esbuild/win32-x64': 0.17.11
|
||||
|
||||
/escape-html/1.0.3:
|
||||
resolution: {integrity: sha512-NiSupZ4OeuGwr68lGIeym/ksIZMJodUGOSCZ/FSnTxcrekbvqrgdUxlJOMpijaKZVjAJrWrGs/6Jy8OMuyj9ow==}
|
||||
@@ -1382,7 +1382,7 @@ packages:
|
||||
object.values: 1.1.6
|
||||
resolve: 1.22.1
|
||||
semver: 6.3.0
|
||||
tsconfig-paths: 3.14.1
|
||||
tsconfig-paths: 3.14.2
|
||||
transitivePeerDependencies:
|
||||
- eslint-import-resolver-typescript
|
||||
- eslint-import-resolver-webpack
|
||||
@@ -1472,11 +1472,11 @@ packages:
|
||||
eslint: '>=8.28.0'
|
||||
dependencies:
|
||||
'@babel/helper-validator-identifier': 7.19.1
|
||||
'@eslint-community/eslint-utils': 4.1.2_eslint@8.35.0
|
||||
'@eslint-community/eslint-utils': 4.2.0_eslint@8.35.0
|
||||
ci-info: 3.8.0
|
||||
clean-regexp: 1.0.0
|
||||
eslint: 8.35.0
|
||||
esquery: 1.4.2
|
||||
esquery: 1.5.0
|
||||
indent-string: 4.0.0
|
||||
is-builtin-module: 3.2.1
|
||||
jsesc: 3.0.2
|
||||
@@ -1611,7 +1611,7 @@ packages:
|
||||
eslint-utils: 3.0.0_eslint@8.35.0
|
||||
eslint-visitor-keys: 3.3.0
|
||||
espree: 9.4.1
|
||||
esquery: 1.4.2
|
||||
esquery: 1.5.0
|
||||
esutils: 2.0.3
|
||||
fast-deep-equal: 3.1.3
|
||||
file-entry-cache: 6.0.1
|
||||
@@ -1656,8 +1656,8 @@ packages:
|
||||
eslint-visitor-keys: 3.3.0
|
||||
dev: true
|
||||
|
||||
/esquery/1.4.2:
|
||||
resolution: {integrity: sha512-JVSoLdTlTDkmjFmab7H/9SL9qGSyjElT3myyKp7krqjVFQCDLmj1QFaCLRFBszBKI0XVZaiiXvuPIX3ZwHe1Ng==}
|
||||
/esquery/1.5.0:
|
||||
resolution: {integrity: sha512-YQLXUplAwJgCydQ78IMJywZCceoqk1oH01OERdSAJc/7U2AylwjhSCLDEtqwg811idIS/9fIU5GjG73IgjKMVg==}
|
||||
engines: {node: '>=0.10'}
|
||||
dependencies:
|
||||
estraverse: 5.3.0
|
||||
@@ -2153,8 +2153,8 @@ packages:
|
||||
is-decimal: 1.0.4
|
||||
dev: true
|
||||
|
||||
/is-array-buffer/3.0.1:
|
||||
resolution: {integrity: sha512-ASfLknmY8Xa2XtB4wmbz13Wu202baeA18cJBCeCy0wXUHZF0IPyVEXqKEcd+t2fNSLLL1vC6k7lxZEojNbISXQ==}
|
||||
/is-array-buffer/3.0.2:
|
||||
resolution: {integrity: sha512-y+FyyR/w8vfIRq4eQcM1EYgSTnmHXPqaF+IgzgraytCFq5Xh8lllDVmAZolPJiZttZLeFSINPYMaEJ7/vWUa1w==}
|
||||
dependencies:
|
||||
call-bind: 1.0.2
|
||||
get-intrinsic: 1.2.0
|
||||
@@ -2398,8 +2398,8 @@ packages:
|
||||
type-check: 0.4.0
|
||||
dev: true
|
||||
|
||||
/lilconfig/2.0.6:
|
||||
resolution: {integrity: sha512-9JROoBW7pobfsx+Sq2JsASvCo6Pfo6WWoUW79HuB1BCoBXD4PLWJPqDF6fNj67pqBYTbAHkE57M1kS/+L1neOg==}
|
||||
/lilconfig/2.1.0:
|
||||
resolution: {integrity: sha512-utWOt/GHzuUxnLKxB6dk81RoOeoNeHgbrXiuGk4yyF5qlRz+iIVWu56E2fqGHFrXz0QNUhLB/8nKqvRH66JKGQ==}
|
||||
engines: {node: '>=10'}
|
||||
dev: true
|
||||
|
||||
@@ -2455,8 +2455,8 @@ packages:
|
||||
dependencies:
|
||||
yallist: 4.0.0
|
||||
|
||||
/lru-cache/7.18.1:
|
||||
resolution: {integrity: sha512-8/HcIENyQnfUTCDizRu9rrDyG6XG/21M4X7/YEGZeD76ZJilFPAUVb/2zysFf7VVO1LEjCDFyHp8pMMvozIrvg==}
|
||||
/lru-cache/7.18.3:
|
||||
resolution: {integrity: sha512-jumlc0BIUrS3qJGgIkWZsyfAM7NCWiBcCDhnd+3NNM5KbBmLTgHVfWBcg6W+rLUsIpzpERPsvwUP7CckAQSOoA==}
|
||||
engines: {node: '>=12'}
|
||||
dev: true
|
||||
|
||||
@@ -2841,7 +2841,7 @@ packages:
|
||||
resolution: {integrity: sha512-OW+5s+7cw6253Q4E+8qQ/u1fVvcJQCJo/VFD8pje+dbJCF1n5ZRMV2AEHbGp+5Q7jxQIYJxkHopnj6nzdGeZLA==}
|
||||
engines: {node: '>=14'}
|
||||
dependencies:
|
||||
lru-cache: 7.18.1
|
||||
lru-cache: 7.18.3
|
||||
minipass: 4.2.4
|
||||
dev: true
|
||||
|
||||
@@ -2881,7 +2881,7 @@ packages:
|
||||
ts-node:
|
||||
optional: true
|
||||
dependencies:
|
||||
lilconfig: 2.0.6
|
||||
lilconfig: 2.1.0
|
||||
yaml: 1.10.2
|
||||
dev: true
|
||||
|
||||
@@ -3048,16 +3048,16 @@ packages:
|
||||
glob: 7.2.3
|
||||
dev: true
|
||||
|
||||
/rimraf/4.2.0:
|
||||
resolution: {integrity: sha512-tPt+gLORNVqRCk0NwuJ5SlMEcOGvt4CCU8sUPqgCFtCbnoNCTd9Q6vq7JlBbxQlACiH14OR28y7piA2Bak9Sxw==}
|
||||
/rimraf/4.3.0:
|
||||
resolution: {integrity: sha512-5qVDXPbByA1qSJEWMv1qAwKsoS22vVpsL2QyxCKBw4gf6XiFo1K3uRLY6uSOOBFDwnqAZtnbILqWKKlzh8bkGg==}
|
||||
engines: {node: '>=14'}
|
||||
hasBin: true
|
||||
dependencies:
|
||||
glob: 9.2.1
|
||||
dev: true
|
||||
|
||||
/rollup/3.15.0:
|
||||
resolution: {integrity: sha512-F9hrCAhnp5/zx/7HYmftvsNBkMfLfk/dXUh73hPSM2E3CRgap65orDNJbLetoiUFwSAk6iHPLvBrZ5iHYvzqsg==}
|
||||
/rollup/3.18.0:
|
||||
resolution: {integrity: sha512-J8C6VfEBjkvYPESMQYxKHxNOh4A5a3FlP+0BETGo34HEcE4eTlgCrO2+eWzlu2a/sHs2QUkZco+wscH7jhhgWg==}
|
||||
engines: {node: '>=14.18.0', npm: '>=8.0.0'}
|
||||
hasBin: true
|
||||
optionalDependencies:
|
||||
@@ -3368,8 +3368,8 @@ packages:
|
||||
resolution: {integrity: sha512-Y/arvbn+rrz3JCKl9C4kVNfTfSm2/mEp5FSz5EsZSANGPSlQrpRI5M4PKF+mJnE52jOO90PnPSc3Ur3bTQw0gA==}
|
||||
dev: true
|
||||
|
||||
/tsconfig-paths/3.14.1:
|
||||
resolution: {integrity: sha512-fxDhWnFSLt3VuTwtvJt5fpwxBHg5AdKWMsgcPOOIilyjymcYVZoCQF8fvFRezCNfblEXmi+PcM1eYHeOAgXCOQ==}
|
||||
/tsconfig-paths/3.14.2:
|
||||
resolution: {integrity: sha512-o/9iXgCYc5L/JxCHPe3Hvh8Q/2xm5Z+p18PESBU6Ff33695QnCHBEjcytY2q19ua7Mbl/DavtBOLq+oG0RCL+g==}
|
||||
dependencies:
|
||||
'@types/json5': 0.0.29
|
||||
json5: 1.0.2
|
||||
@@ -3397,17 +3397,17 @@ packages:
|
||||
typescript:
|
||||
optional: true
|
||||
dependencies:
|
||||
bundle-require: 4.0.1_esbuild@0.17.8
|
||||
bundle-require: 4.0.1_esbuild@0.17.11
|
||||
cac: 6.7.14
|
||||
chokidar: 3.5.3
|
||||
debug: 4.3.4
|
||||
esbuild: 0.17.8
|
||||
esbuild: 0.17.11
|
||||
execa: 5.1.1
|
||||
globby: 11.1.0
|
||||
joycon: 3.1.1
|
||||
postcss-load-config: 3.1.4
|
||||
resolve-from: 5.0.0
|
||||
rollup: 3.15.0
|
||||
rollup: 3.18.0
|
||||
source-map: 0.8.0-beta.0
|
||||
sucrase: 3.29.0
|
||||
tree-kill: 1.2.2
|
||||
@@ -3548,7 +3548,7 @@ packages:
|
||||
eslint-scope: 7.1.1
|
||||
eslint-visitor-keys: 3.3.0
|
||||
espree: 9.4.1
|
||||
esquery: 1.4.2
|
||||
esquery: 1.5.0
|
||||
lodash: 4.17.21
|
||||
semver: 7.3.8
|
||||
transitivePeerDependencies:
|
||||
|
||||
@@ -7,6 +7,17 @@ import fetch from 'node-fetch'
|
||||
import { sendResponse } from '../utils'
|
||||
import type { ApiModel, ChatContext, ChatGPTUnofficialProxyAPIOptions, ModelConfig } from '../types'
|
||||
|
||||
const ErrorCodeMessage: Record<string, string> = {
|
||||
400: '[OpenAI] 模型的最大上下文长度是4096个令牌,请减少信息的长度。| This model\'s maximum context length is 4096 tokens.',
|
||||
401: '[OpenAI] 提供错误的API密钥 | Incorrect API key provided',
|
||||
403: '[OpenAI] 服务器拒绝访问,请稍后再试 | Server refused to access, please try again later',
|
||||
429: '[OpenAI] 服务器限流,请稍后再试 | Server was limited, please try again later',
|
||||
502: '[OpenAI] 错误的网关 | Bad Gateway',
|
||||
503: '[OpenAI] 服务器繁忙,请稍后再试 | Server is busy, please try again later',
|
||||
504: '[OpenAI] 网关超时 | Gateway Time-out',
|
||||
500: '[OpenAI] 服务器繁忙,请稍后再试 | Internal Server Error',
|
||||
}
|
||||
|
||||
dotenv.config()
|
||||
|
||||
const timeoutMs: number = !isNaN(+process.env.TIMEOUT_MS) ? +process.env.TIMEOUT_MS : 30 * 1000
|
||||
@@ -24,6 +35,9 @@ let api: ChatGPTAPI | ChatGPTUnofficialProxyAPI
|
||||
if (process.env.OPENAI_API_KEY) {
|
||||
const options: ChatGPTAPIOptions = {
|
||||
apiKey: process.env.OPENAI_API_KEY,
|
||||
completionParams: {
|
||||
model: 'gpt-3.5-turbo',
|
||||
},
|
||||
debug: false,
|
||||
}
|
||||
|
||||
@@ -67,28 +81,6 @@ let api: ChatGPTAPI | ChatGPTUnofficialProxyAPI
|
||||
}
|
||||
})()
|
||||
|
||||
async function chatReply(
|
||||
message: string,
|
||||
lastContext?: { conversationId?: string; parentMessageId?: string },
|
||||
) {
|
||||
if (!message)
|
||||
return sendResponse({ type: 'Fail', message: 'Message is empty' })
|
||||
|
||||
try {
|
||||
let options: SendMessageOptions = { timeoutMs }
|
||||
|
||||
if (lastContext)
|
||||
options = { ...lastContext }
|
||||
|
||||
const response = await api.sendMessage(message, { ...options })
|
||||
|
||||
return sendResponse({ type: 'Success', data: response })
|
||||
}
|
||||
catch (error: any) {
|
||||
return sendResponse({ type: 'Fail', message: error.message })
|
||||
}
|
||||
}
|
||||
|
||||
async function chatReplyProcess(
|
||||
message: string,
|
||||
lastContext?: { conversationId?: string; parentMessageId?: string },
|
||||
@@ -100,8 +92,12 @@ async function chatReplyProcess(
|
||||
try {
|
||||
let options: SendMessageOptions = { timeoutMs }
|
||||
|
||||
if (lastContext)
|
||||
options = { ...lastContext }
|
||||
if (lastContext) {
|
||||
if (apiModel === 'ChatGPTAPI')
|
||||
options = { parentMessageId: lastContext.parentMessageId }
|
||||
else
|
||||
options = { ...lastContext }
|
||||
}
|
||||
|
||||
const response = await api.sendMessage(message, {
|
||||
...options,
|
||||
@@ -113,7 +109,11 @@ async function chatReplyProcess(
|
||||
return sendResponse({ type: 'Success', data: response })
|
||||
}
|
||||
catch (error: any) {
|
||||
return sendResponse({ type: 'Fail', message: error.message })
|
||||
const code = error.statusCode
|
||||
global.console.log(error)
|
||||
if (Reflect.has(ErrorCodeMessage, code))
|
||||
return sendResponse({ type: 'Fail', message: ErrorCodeMessage[code] })
|
||||
return sendResponse({ type: 'Fail', message: error.message ?? 'Please check the back-end console' })
|
||||
}
|
||||
}
|
||||
|
||||
@@ -131,4 +131,4 @@ async function chatConfig() {
|
||||
|
||||
export type { ChatContext, ChatMessage }
|
||||
|
||||
export { chatReply, chatReplyProcess, chatConfig }
|
||||
export { chatReplyProcess, chatConfig }
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import express from 'express'
|
||||
import type { ChatContext, ChatMessage } from './chatgpt'
|
||||
import { chatConfig, chatReply, chatReplyProcess } from './chatgpt'
|
||||
import { chatConfig, chatReplyProcess } from './chatgpt'
|
||||
import { auth } from './middleware/auth'
|
||||
|
||||
const app = express()
|
||||
const router = express.Router()
|
||||
@@ -15,18 +16,7 @@ app.all('*', (_, res, next) => {
|
||||
next()
|
||||
})
|
||||
|
||||
router.post('/chat', async (req, res) => {
|
||||
try {
|
||||
const { prompt, options = {} } = req.body as { prompt: string; options?: ChatContext }
|
||||
const response = await chatReply(prompt, options)
|
||||
res.send(response)
|
||||
}
|
||||
catch (error) {
|
||||
res.send(error)
|
||||
}
|
||||
})
|
||||
|
||||
router.post('/chat-process', async (req, res) => {
|
||||
router.post('/chat-process', auth, async (req, res) => {
|
||||
res.setHeader('Content-type', 'application/octet-stream')
|
||||
|
||||
try {
|
||||
@@ -55,6 +45,33 @@ router.post('/config', async (req, res) => {
|
||||
}
|
||||
})
|
||||
|
||||
router.post('/session', async (req, res) => {
|
||||
try {
|
||||
const AUTH_SECRET_KEY = process.env.AUTH_SECRET_KEY
|
||||
const hasAuth = typeof AUTH_SECRET_KEY === 'string' && AUTH_SECRET_KEY.length > 0
|
||||
res.send({ status: 'Success', message: '', data: { auth: hasAuth } })
|
||||
}
|
||||
catch (error) {
|
||||
res.send({ status: 'Fail', message: error.message, data: null })
|
||||
}
|
||||
})
|
||||
|
||||
router.post('/verify', async (req, res) => {
|
||||
try {
|
||||
const { token } = req.body as { token: string }
|
||||
if (!token)
|
||||
throw new Error('Secret key is empty')
|
||||
|
||||
if (process.env.AUTH_SECRET_KEY !== token)
|
||||
throw new Error('密钥无效 | Secret key is invalid')
|
||||
|
||||
res.send({ status: 'Success', message: 'Verify successfully', data: null })
|
||||
}
|
||||
catch (error) {
|
||||
res.send({ status: 'Fail', message: error.message, data: null })
|
||||
}
|
||||
})
|
||||
|
||||
app.use('', router)
|
||||
app.use('/api', router)
|
||||
|
||||
|
||||
19
service/src/middleware/auth.ts
Normal file
19
service/src/middleware/auth.ts
Normal file
@@ -0,0 +1,19 @@
|
||||
const auth = async (req, res, next) => {
|
||||
const AUTH_SECRET_KEY = process.env.AUTH_SECRET_KEY
|
||||
if (typeof AUTH_SECRET_KEY === 'string' && AUTH_SECRET_KEY.length > 0) {
|
||||
try {
|
||||
const Authorization = req.header('Authorization')
|
||||
if (!Authorization || Authorization.replace('Bearer ', '').trim() !== AUTH_SECRET_KEY.trim())
|
||||
throw new Error('Error: 无访问权限 | No access rights')
|
||||
next()
|
||||
}
|
||||
catch (error) {
|
||||
res.send({ status: 'Unauthorized', message: error.message ?? 'Please authenticate.', data: null })
|
||||
}
|
||||
}
|
||||
else {
|
||||
next()
|
||||
}
|
||||
}
|
||||
|
||||
export { auth }
|
||||
@@ -33,3 +33,16 @@ export function fetchChatAPIProcess<T = any>(
|
||||
onDownloadProgress: params.onDownloadProgress,
|
||||
})
|
||||
}
|
||||
|
||||
export function fetchSession<T>() {
|
||||
return post<T>({
|
||||
url: '/session',
|
||||
})
|
||||
}
|
||||
|
||||
export function fetchVerify<T>(token: string) {
|
||||
return post<T>({
|
||||
url: '/verify',
|
||||
data: { token },
|
||||
})
|
||||
}
|
||||
|
||||
@@ -1,18 +1,13 @@
|
||||
<script lang="ts" setup>
|
||||
import { computed, ref } from 'vue'
|
||||
import { NButton, NInput, useMessage } from 'naive-ui'
|
||||
import { NButton, NInput, NPopconfirm, useMessage } from 'naive-ui'
|
||||
import type { Language, Theme } from '@/store/modules/app/helper'
|
||||
import { SvgIcon } from '@/components/common'
|
||||
import { useAppStore, useUserStore } from '@/store'
|
||||
import type { UserInfo } from '@/store/modules/user/helper'
|
||||
import { getCurrentDate } from '@/utils/functions'
|
||||
import { t } from '@/locales'
|
||||
|
||||
interface Emit {
|
||||
(event: 'update'): void
|
||||
}
|
||||
|
||||
const emit = defineEmits<Emit>()
|
||||
|
||||
const appStore = useAppStore()
|
||||
const userStore = useUserStore()
|
||||
|
||||
@@ -56,7 +51,8 @@ const themeOptions: { label: string; key: Theme; icon: string }[] = [
|
||||
]
|
||||
|
||||
const languageOptions: { label: string; key: Language; value: Language }[] = [
|
||||
{ label: '中文', key: 'zh-CN', value: 'zh-CN' },
|
||||
{ label: '简体中文', key: 'zh-CN', value: 'zh-CN' },
|
||||
{ label: '繁體中文', key: 'zh-TW', value: 'zh-TW' },
|
||||
{ label: 'English', key: 'en-US', value: 'en-US' },
|
||||
]
|
||||
|
||||
@@ -68,7 +64,56 @@ function updateUserInfo(options: Partial<UserInfo>) {
|
||||
function handleReset() {
|
||||
userStore.resetUserInfo()
|
||||
ms.success(t('common.success'))
|
||||
emit('update')
|
||||
window.location.reload()
|
||||
}
|
||||
|
||||
function exportData(): void {
|
||||
const date = getCurrentDate()
|
||||
const data: string = localStorage.getItem('chatStorage') || '{}'
|
||||
const jsonString: string = JSON.stringify(JSON.parse(data), null, 2)
|
||||
const blob: Blob = new Blob([jsonString], { type: 'application/json' })
|
||||
const url: string = URL.createObjectURL(blob)
|
||||
const link: HTMLAnchorElement = document.createElement('a')
|
||||
link.href = url
|
||||
link.download = `chat-store_${date}.json`
|
||||
document.body.appendChild(link)
|
||||
link.click()
|
||||
document.body.removeChild(link)
|
||||
}
|
||||
|
||||
function importData(event: Event): void {
|
||||
const target = event.target as HTMLInputElement
|
||||
if (!target || !target.files)
|
||||
return
|
||||
|
||||
const file: File = target.files[0]
|
||||
if (!file)
|
||||
return
|
||||
|
||||
const reader: FileReader = new FileReader()
|
||||
reader.onload = () => {
|
||||
try {
|
||||
const data = JSON.parse(reader.result as string)
|
||||
localStorage.setItem('chatStorage', JSON.stringify(data))
|
||||
ms.success(t('common.success'))
|
||||
location.reload()
|
||||
}
|
||||
catch (error) {
|
||||
ms.error(t('common.invalidFileFormat'))
|
||||
}
|
||||
}
|
||||
reader.readAsText(file)
|
||||
}
|
||||
|
||||
function clearData(): void {
|
||||
localStorage.removeItem('chatStorage')
|
||||
location.reload()
|
||||
}
|
||||
|
||||
function handleImportButtonClick(): void {
|
||||
const fileInput = document.getElementById('fileInput') as HTMLElement
|
||||
if (fileInput)
|
||||
fileInput.click()
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -102,44 +147,75 @@ function handleReset() {
|
||||
{{ $t('common.save') }}
|
||||
</NButton>
|
||||
</div>
|
||||
|
||||
<div class="flex items-center space-x-4">
|
||||
<span class="flex-shrink-0 w-[100px]">{{ $t('setting.resetUserInfo') }}</span>
|
||||
<NButton text type="primary" @click="handleReset">
|
||||
{{ $t('common.reset') }}
|
||||
</NButton>
|
||||
<span class="flex-shrink-0 w-[100px]">{{ $t('setting.chatHistory') }}</span>
|
||||
|
||||
<div class="flex flex-wrap items-center gap-4">
|
||||
<NButton size="small" @click="exportData">
|
||||
<template #icon>
|
||||
<SvgIcon icon="ri:download-2-fill" />
|
||||
</template>
|
||||
{{ $t('common.export') }}
|
||||
</NButton>
|
||||
|
||||
<input id="fileInput" type="file" style="display:none" @change="importData">
|
||||
<NButton size="small" @click="handleImportButtonClick">
|
||||
<template #icon>
|
||||
<SvgIcon icon="ri:upload-2-fill" />
|
||||
</template>
|
||||
{{ $t('common.import') }}
|
||||
</NButton>
|
||||
|
||||
<NPopconfirm placement="bottom" @positive-click="clearData">
|
||||
<template #trigger>
|
||||
<NButton size="small">
|
||||
<template #icon>
|
||||
<SvgIcon icon="ri:close-circle-line" />
|
||||
</template>
|
||||
{{ $t('common.clear') }}
|
||||
</NButton>
|
||||
</template>
|
||||
{{ $t('chat.clearHistoryConfirm') }}
|
||||
</NPopconfirm>
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex items-center space-x-4">
|
||||
<span class="flex-shrink-0 w-[100px]">{{ $t('setting.theme') }}</span>
|
||||
<div class="flex items-center space-x-4">
|
||||
<div class="flex flex-wrap items-center gap-4">
|
||||
<template v-for="item of themeOptions" :key="item.key">
|
||||
<a
|
||||
class="flex items-center justify-center h-8 px-4 border rounded-md cursor-pointer dark:border-neutral-700"
|
||||
:class="item.key === theme && ['bg-[#4ca85e]', 'border-[#4ca85e]', 'text-white']"
|
||||
<NButton
|
||||
size="small"
|
||||
:type="item.key === theme ? 'primary' : undefined"
|
||||
@click="appStore.setTheme(item.key)"
|
||||
>
|
||||
<span class="text-xl">
|
||||
<template #icon>
|
||||
<SvgIcon :icon="item.icon" />
|
||||
</span>
|
||||
</a>
|
||||
</template>
|
||||
</NButton>
|
||||
</template>
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex items-center space-x-4">
|
||||
<span class="flex-shrink-0 w-[100px]">{{ $t('setting.language') }}</span>
|
||||
<div class="flex items-center space-x-4">
|
||||
<div class="flex flex-wrap items-center gap-4">
|
||||
<template v-for="item of languageOptions" :key="item.key">
|
||||
<a
|
||||
class="flex items-center justify-center h-8 px-4 border rounded-md cursor-pointer dark:border-neutral-700"
|
||||
:class="item.key === language && ['bg-[#4ca85e]', 'border-[#4ca85e]', 'text-white']"
|
||||
<NButton
|
||||
size="small"
|
||||
:type="item.key === language ? 'primary' : undefined"
|
||||
@click="appStore.setLanguage(item.key)"
|
||||
>
|
||||
<span class="text-sm">
|
||||
{{ item.label }}
|
||||
</span>
|
||||
</a>
|
||||
{{ item.label }}
|
||||
</NButton>
|
||||
</template>
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex items-center space-x-4">
|
||||
<span class="flex-shrink-0 w-[100px]">{{ $t('setting.resetUserInfo') }}</span>
|
||||
<NButton size="small" @click="handleReset">
|
||||
{{ $t('common.reset') }}
|
||||
</NButton>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -19,8 +19,6 @@ interface Emit {
|
||||
|
||||
const active = ref('General')
|
||||
|
||||
const reload = ref(false)
|
||||
|
||||
const show = computed({
|
||||
get() {
|
||||
return props.visible
|
||||
@@ -29,18 +27,11 @@ const show = computed({
|
||||
emit('update:visible', visible)
|
||||
},
|
||||
})
|
||||
|
||||
function handleReload() {
|
||||
reload.value = true
|
||||
setTimeout(() => {
|
||||
reload.value = false
|
||||
}, 0)
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<NModal v-model:show="show" :auto-focus="false">
|
||||
<NCard role="dialog" aria-modal="true" :bordered="false" style="width: 100%; max-width: 640px">
|
||||
<NCard role="dialog" aria-modal="true" :bordered="false" style="width: 95%; max-width: 640px">
|
||||
<NTabs v-model:value="active" type="line" animated>
|
||||
<NTabPane name="General" tab="General">
|
||||
<template #tab>
|
||||
@@ -48,7 +39,7 @@ function handleReload() {
|
||||
<span class="ml-2">{{ $t('setting.general') }}</span>
|
||||
</template>
|
||||
<div class="min-h-[100px]">
|
||||
<General v-if="!reload" @update="handleReload" />
|
||||
<General />
|
||||
</div>
|
||||
</NTabPane>
|
||||
<NTabPane name="Config" tab="Config">
|
||||
|
||||
@@ -1,23 +0,0 @@
|
||||
import type { App, Directive } from 'vue'
|
||||
import hljs from 'highlight.js'
|
||||
import { includeCode } from '@/utils/format'
|
||||
|
||||
hljs.configure({ ignoreUnescapedHTML: true })
|
||||
|
||||
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 +0,0 @@
|
||||
import type { App } from 'vue'
|
||||
import setupHighlightDirective from './highlight'
|
||||
|
||||
export function setupDirectives(app: App) {
|
||||
setupHighlightDirective(app)
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
import { computed } from 'vue'
|
||||
import { enUS, zhCN } from 'naive-ui'
|
||||
import { enUS, zhCN, zhTW } from 'naive-ui'
|
||||
import { useAppStore } from '@/store'
|
||||
import { setLocale } from '@/locales'
|
||||
|
||||
@@ -14,6 +14,9 @@ export function useLanguage() {
|
||||
case 'zh-CN':
|
||||
setLocale('zh-CN')
|
||||
return zhCN
|
||||
case 'zh-TW':
|
||||
setLocale('zh-TW')
|
||||
return zhTW
|
||||
default:
|
||||
setLocale('zh-CN')
|
||||
return enUS
|
||||
|
||||
File diff suppressed because one or more lines are too long
|
Before Width: | Height: | Size: 19 KiB |
5
src/icons/403.vue
Normal file
5
src/icons/403.vue
Normal file
File diff suppressed because one or more lines are too long
5
src/icons/500.vue
Normal file
5
src/icons/500.vue
Normal file
File diff suppressed because one or more lines are too long
@@ -3,12 +3,17 @@ export default {
|
||||
delete: 'Delete',
|
||||
save: 'Save',
|
||||
reset: 'Reset',
|
||||
export: 'Export',
|
||||
import: 'Import',
|
||||
clear: 'Clear',
|
||||
yes: 'Yes',
|
||||
no: 'No',
|
||||
noData: 'No Data',
|
||||
wrong: 'Something went wrong, please try again later.',
|
||||
success: 'Success',
|
||||
failed: 'Failed',
|
||||
verify: 'Verify',
|
||||
unauthorizedTips: 'Unauthorized, please verify first.',
|
||||
},
|
||||
chat: {
|
||||
placeholder: 'Ask me anything...(Shift + Enter = line break)',
|
||||
@@ -18,9 +23,14 @@ export default {
|
||||
copyCode: 'Copy Code',
|
||||
clearChat: 'Clear Chat',
|
||||
clearChatConfirm: 'Are you sure to clear this chat?',
|
||||
exportImage: 'Export Image',
|
||||
exportImageConfirm: 'Are you sure to export this chat to png?',
|
||||
exportSuccess: 'Export Success',
|
||||
exportFailed: 'Export Failed',
|
||||
deleteMessage: 'Delete Message',
|
||||
deleteMessageConfirm: 'Are you sure to delete this message?',
|
||||
deleteHistoryConfirm: 'Are you sure to clear this history?',
|
||||
clearHistoryConfirm: 'Are you sure to clear chat history?',
|
||||
},
|
||||
setting: {
|
||||
setting: 'Setting',
|
||||
@@ -30,6 +40,7 @@ export default {
|
||||
name: 'Name',
|
||||
description: 'Description',
|
||||
resetUserInfo: 'Reset UserInfo',
|
||||
chatHistory: 'ChatHistory',
|
||||
theme: 'Theme',
|
||||
language: 'Language',
|
||||
api: 'API',
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
import type { App } from 'vue'
|
||||
import { createI18n } from 'vue-i18n'
|
||||
import en from './en-US'
|
||||
import cn from './zh-CN'
|
||||
import enUS from './en-US'
|
||||
import zhCN from './zh-CN'
|
||||
import zhTW from './zh-TW'
|
||||
import { useAppStoreWithOut } from '@/store/modules/app'
|
||||
import type { Language } from '@/store/modules/app/helper'
|
||||
|
||||
@@ -14,8 +15,9 @@ const i18n = createI18n({
|
||||
fallbackLocale: 'en-US',
|
||||
allowComposition: true,
|
||||
messages: {
|
||||
'en-US': en,
|
||||
'zh-CN': cn,
|
||||
'en-US': enUS,
|
||||
'zh-CN': zhCN,
|
||||
'zh-TW': zhTW,
|
||||
},
|
||||
})
|
||||
|
||||
|
||||
@@ -3,24 +3,34 @@ export default {
|
||||
delete: '删除',
|
||||
save: '保存',
|
||||
reset: '重置',
|
||||
export: '导出',
|
||||
import: '导入',
|
||||
clear: '清空',
|
||||
yes: '是',
|
||||
no: '否',
|
||||
noData: '暂无数据',
|
||||
wrong: '好像出错了,请稍后再试。',
|
||||
success: '操作成功',
|
||||
failed: '操作失败',
|
||||
verify: '验证',
|
||||
unauthorizedTips: '未经授权,请先进行验证。',
|
||||
},
|
||||
chat: {
|
||||
placeholder: '来说点什么...(Shift + Enter = 换行)',
|
||||
placeholder: '来说点什么吧...(Shift + Enter = 换行)',
|
||||
placeholderMobile: '来说点什么...',
|
||||
copy: '复制',
|
||||
copied: '复制成功',
|
||||
copyCode: '复制代码',
|
||||
clearChat: '清空会话',
|
||||
clearChatConfirm: '是否清空会话?',
|
||||
exportImage: '保存会话到图片',
|
||||
exportImageConfirm: '是否将会话保存为图片?',
|
||||
exportSuccess: '保存成功',
|
||||
exportFailed: '保存失败',
|
||||
deleteMessage: '删除消息',
|
||||
deleteMessageConfirm: '是否删除此消息?',
|
||||
deleteHistoryConfirm: '确定删除此记录?',
|
||||
clearHistoryConfirm: '确定清空聊天记录?',
|
||||
},
|
||||
setting: {
|
||||
setting: '设置',
|
||||
@@ -30,6 +40,7 @@ export default {
|
||||
name: '名称',
|
||||
description: '描述',
|
||||
resetUserInfo: '重置用户信息',
|
||||
chatHistory: '聊天记录',
|
||||
theme: '主题',
|
||||
language: '语言',
|
||||
api: 'API',
|
||||
|
||||
50
src/locales/zh-TW.ts
Normal file
50
src/locales/zh-TW.ts
Normal file
@@ -0,0 +1,50 @@
|
||||
export default {
|
||||
common: {
|
||||
delete: '刪除',
|
||||
save: '儲存',
|
||||
reset: '重設',
|
||||
export: '匯出',
|
||||
import: '匯入',
|
||||
clear: '清除',
|
||||
yes: '是',
|
||||
no: '否',
|
||||
noData: '暫無資料',
|
||||
wrong: '好像出錯了,請稍後再試。',
|
||||
success: '操作成功',
|
||||
failed: '操作失敗',
|
||||
verify: '驗證',
|
||||
unauthorizedTips: '未經授權,請先進行驗證。',
|
||||
},
|
||||
chat: {
|
||||
placeholder: '來說點什麼...(Shift + Enter = 換行)',
|
||||
placeholderMobile: '來說點什麼...',
|
||||
copy: '複製',
|
||||
copied: '複製成功',
|
||||
copyCode: '複製代碼',
|
||||
clearChat: '清除對話',
|
||||
clearChatConfirm: '是否清空對話?',
|
||||
exportImage: '儲存對話為圖片',
|
||||
exportImageConfirm: '是否將對話儲存為圖片?',
|
||||
exportSuccess: '儲存成功',
|
||||
exportFailed: '儲存失敗',
|
||||
deleteMessage: '刪除訊息',
|
||||
deleteMessageConfirm: '是否刪除此訊息?',
|
||||
deleteHistoryConfirm: '確定刪除此紀錄?',
|
||||
},
|
||||
setting: {
|
||||
setting: '設定',
|
||||
general: '總覽',
|
||||
config: '設定',
|
||||
avatarLink: '頭貼連結',
|
||||
name: '名稱',
|
||||
description: '描述',
|
||||
resetUserInfo: '重設使用者資訊',
|
||||
chatHistory: '紀錄',
|
||||
theme: '主題',
|
||||
language: '語言',
|
||||
api: 'API',
|
||||
reverseProxy: '反向代理',
|
||||
timeout: '逾時',
|
||||
socks: 'Socks',
|
||||
},
|
||||
}
|
||||
@@ -1,6 +1,5 @@
|
||||
import { createApp } from 'vue'
|
||||
import App from './App.vue'
|
||||
import { setupDirectives } from './directives'
|
||||
import { setupI18n } from './locales'
|
||||
import { setupAssets } from './plugins'
|
||||
import { setupStore } from './store'
|
||||
@@ -12,8 +11,6 @@ async function bootstrap() {
|
||||
|
||||
setupStore(app)
|
||||
|
||||
setupDirectives(app)
|
||||
|
||||
setupI18n(app)
|
||||
|
||||
await setupRouter(app)
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import type { App } from 'vue'
|
||||
import type { RouteRecordRaw } from 'vue-router'
|
||||
import { createRouter, createWebHashHistory } from 'vue-router'
|
||||
import { setupPageGuard } from './permission'
|
||||
import { ChatLayout } from '@/views/chat/layout'
|
||||
|
||||
const routes: RouteRecordRaw[] = [
|
||||
@@ -18,18 +19,18 @@ const routes: RouteRecordRaw[] = [
|
||||
],
|
||||
},
|
||||
|
||||
{
|
||||
path: '/403',
|
||||
name: '403',
|
||||
component: () => import('@/views/exception/403/index.vue'),
|
||||
},
|
||||
|
||||
{
|
||||
path: '/404',
|
||||
name: '404',
|
||||
component: () => import('@/views/exception/404/index.vue'),
|
||||
},
|
||||
|
||||
{
|
||||
path: '/500',
|
||||
name: '500',
|
||||
component: () => import('@/views/exception/500/index.vue'),
|
||||
},
|
||||
|
||||
{
|
||||
path: '/:pathMatch(.*)*',
|
||||
name: 'notFound',
|
||||
@@ -43,6 +44,8 @@ export const router = createRouter({
|
||||
scrollBehavior: () => ({ left: 0, top: 0 }),
|
||||
})
|
||||
|
||||
setupPageGuard(router)
|
||||
|
||||
export async function setupRouter(app: App) {
|
||||
app.use(router)
|
||||
await router.isReady()
|
||||
|
||||
25
src/router/permission.ts
Normal file
25
src/router/permission.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
import type { Router } from 'vue-router'
|
||||
import { useAuthStoreWithout } from '@/store/modules/auth'
|
||||
|
||||
export function setupPageGuard(router: Router) {
|
||||
router.beforeEach(async (from, to, next) => {
|
||||
const authStore = useAuthStoreWithout()
|
||||
if (!authStore.session) {
|
||||
try {
|
||||
const data = await authStore.getSession()
|
||||
if (String(data.auth) === 'false' && authStore.token)
|
||||
authStore.removeToken()
|
||||
next()
|
||||
}
|
||||
catch (error) {
|
||||
if (from.path !== '/500')
|
||||
next({ name: '500' })
|
||||
else
|
||||
next()
|
||||
}
|
||||
}
|
||||
else {
|
||||
next()
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -4,7 +4,7 @@ const LOCAL_NAME = 'appSetting'
|
||||
|
||||
export type Theme = 'light' | 'dark' | 'auto'
|
||||
|
||||
export type Language = 'zh-CN' | 'en-US'
|
||||
export type Language = 'zh-CN' | 'zh-TW' | 'en-US'
|
||||
|
||||
export interface AppState {
|
||||
siderCollapsed: boolean
|
||||
|
||||
15
src/store/modules/auth/helper.ts
Normal file
15
src/store/modules/auth/helper.ts
Normal file
@@ -0,0 +1,15 @@
|
||||
import { ss } from '@/utils/storage'
|
||||
|
||||
const LOCAL_NAME = 'SECRET_TOKEN'
|
||||
|
||||
export function getToken() {
|
||||
return ss.get(LOCAL_NAME)
|
||||
}
|
||||
|
||||
export function setToken(token: string) {
|
||||
return ss.set(LOCAL_NAME, token)
|
||||
}
|
||||
|
||||
export function removeToken() {
|
||||
return ss.remove(LOCAL_NAME)
|
||||
}
|
||||
43
src/store/modules/auth/index.ts
Normal file
43
src/store/modules/auth/index.ts
Normal file
@@ -0,0 +1,43 @@
|
||||
import { defineStore } from 'pinia'
|
||||
import { getToken, removeToken, setToken } from './helper'
|
||||
import { store } from '@/store'
|
||||
import { fetchSession } from '@/api'
|
||||
|
||||
export interface AuthState {
|
||||
token: string | undefined
|
||||
session: { auth: boolean } | null
|
||||
}
|
||||
|
||||
export const useAuthStore = defineStore('auth-store', {
|
||||
state: (): AuthState => ({
|
||||
token: getToken(),
|
||||
session: null,
|
||||
}),
|
||||
|
||||
actions: {
|
||||
async getSession() {
|
||||
try {
|
||||
const { data } = await fetchSession<{ auth: boolean }>()
|
||||
this.session = { ...data }
|
||||
return Promise.resolve(data)
|
||||
}
|
||||
catch (error) {
|
||||
return Promise.reject(error)
|
||||
}
|
||||
},
|
||||
|
||||
setToken(token: string) {
|
||||
this.token = token
|
||||
setToken(token)
|
||||
},
|
||||
|
||||
removeToken() {
|
||||
this.token = undefined
|
||||
removeToken()
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
export function useAuthStoreWithout() {
|
||||
return useAuthStore(store)
|
||||
}
|
||||
@@ -3,7 +3,7 @@ import { ss } from '@/utils/storage'
|
||||
const LOCAL_NAME = 'chatStorage'
|
||||
|
||||
export function defaultState(): Chat.ChatState {
|
||||
const uuid = Date.now()
|
||||
const uuid = 1002
|
||||
return { active: uuid, history: [{ uuid, title: 'New Chat', isEdit: false }], chat: [{ uuid, data: [] }] }
|
||||
}
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
export * from './app'
|
||||
export * from './chat'
|
||||
export * from './user'
|
||||
export * from './auth'
|
||||
|
||||
@@ -3,3 +3,7 @@ body,
|
||||
#app {
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
body {
|
||||
padding-bottom: constant(safe-area-inset-bottom);
|
||||
}
|
||||
|
||||
7
src/utils/functions/index.ts
Normal file
7
src/utils/functions/index.ts
Normal file
@@ -0,0 +1,7 @@
|
||||
export function getCurrentDate() {
|
||||
const date = new Date()
|
||||
const day = date.getDate()
|
||||
const month = date.getMonth() + 1
|
||||
const year = date.getFullYear()
|
||||
return `${year}-${month}-${day}`
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
import axios, { type AxiosResponse } from 'axios'
|
||||
import { useAuthStore } from '@/store'
|
||||
|
||||
const service = axios.create({
|
||||
baseURL: import.meta.env.VITE_GLOB_API_URL,
|
||||
@@ -6,6 +7,9 @@ const service = axios.create({
|
||||
|
||||
service.interceptors.request.use(
|
||||
(config) => {
|
||||
const token = useAuthStore().token
|
||||
if (token)
|
||||
config.headers.Authorization = `Bearer ${token}`
|
||||
return config
|
||||
},
|
||||
(error) => {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import type { AxiosProgressEvent, AxiosResponse, GenericAbortSignal } from 'axios'
|
||||
import request from './axios'
|
||||
import { useAuthStore } from '@/store'
|
||||
|
||||
export interface HttpOption {
|
||||
url: string
|
||||
@@ -22,9 +23,16 @@ function http<T = any>(
|
||||
{ url, data, method, headers, onDownloadProgress, signal, beforeRequest, afterRequest }: HttpOption,
|
||||
) {
|
||||
const successHandler = (res: AxiosResponse<Response<T>>) => {
|
||||
const authStore = useAuthStore()
|
||||
|
||||
if (res.data.status === 'Success' || typeof res.data === 'string')
|
||||
return res.data
|
||||
|
||||
if (res.data.status === 'Unauthorized') {
|
||||
authStore.removeToken()
|
||||
window.location.reload()
|
||||
}
|
||||
|
||||
return Promise.reject(res.data)
|
||||
}
|
||||
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
<script lang="ts" setup>
|
||||
import { computed, ref } from 'vue'
|
||||
import katex from 'katex'
|
||||
import { marked } from 'marked'
|
||||
import MarkdownIt from 'markdown-it'
|
||||
import mdKatex from '@traptitech/markdown-it-katex'
|
||||
import hljs from 'highlight.js'
|
||||
import { useBasicLayout } from '@/hooks/useBasicLayout'
|
||||
import { encodeHTML } from '@/utils/format'
|
||||
import { t } from '@/locales'
|
||||
|
||||
interface Props {
|
||||
@@ -18,77 +17,21 @@ const props = defineProps<Props>()
|
||||
|
||||
const { isMobile } = useBasicLayout()
|
||||
|
||||
const renderer = new marked.Renderer()
|
||||
|
||||
const textRef = ref<HTMLElement>()
|
||||
|
||||
renderer.html = (html) => {
|
||||
return `<p>${encodeHTML(html)}</p>`
|
||||
}
|
||||
|
||||
renderer.code = (code, language) => {
|
||||
const validLang = !!(language && hljs.getLanguage(language))
|
||||
if (validLang) {
|
||||
const lang = language ?? ''
|
||||
return `<pre class="code-block-wrapper"><div class="code-block-header"><span class="code-block-header__lang">${lang}</span><span class="code-block-header__copy">${t('chat.copyCode')}</span></div><code class="hljs code-block-body ${language}">${hljs.highlight(code, { language: lang }).value}</code></pre>`
|
||||
}
|
||||
return `<pre style="background: none">${hljs.highlightAuto(code).value}</pre>`
|
||||
}
|
||||
|
||||
marked.setOptions({
|
||||
renderer,
|
||||
highlight(code) {
|
||||
return hljs.highlightAuto(code).value
|
||||
const mdi = new MarkdownIt({
|
||||
linkify: true,
|
||||
highlight(code, language) {
|
||||
const validLang = !!(language && hljs.getLanguage(language))
|
||||
if (validLang) {
|
||||
const lang = language ?? ''
|
||||
return highlightBlock(hljs.highlight(lang, code, true).value, lang)
|
||||
}
|
||||
return highlightBlock(hljs.highlightAuto(code).value, '')
|
||||
},
|
||||
})
|
||||
|
||||
const katexOptions = {
|
||||
throwOnError: false,
|
||||
}
|
||||
|
||||
const katexInline = {
|
||||
name: 'katexInline',
|
||||
level: 'inline',
|
||||
start(src: string) {
|
||||
return src.indexOf('$')
|
||||
},
|
||||
tokenizer(src: string) {
|
||||
const match = src.match(/^\$+([^$\n]+?)\$+/)
|
||||
if (match) {
|
||||
return {
|
||||
type: 'katexInline',
|
||||
raw: match[0],
|
||||
text: match[1].trim(),
|
||||
}
|
||||
}
|
||||
},
|
||||
renderer(token: marked.Tokens.Generic) {
|
||||
return katex.renderToString(token.text, katexOptions)
|
||||
},
|
||||
}
|
||||
|
||||
const katexBlock = {
|
||||
name: 'katexBlock',
|
||||
level: 'block',
|
||||
start(src: string) {
|
||||
return src.indexOf('\n$$')
|
||||
},
|
||||
tokenizer(src: string) {
|
||||
const match = src.match(/^\$\$+\n([^$]+?)\n\$\$+\n/)
|
||||
if (match) {
|
||||
return {
|
||||
type: 'katexBlock',
|
||||
raw: match[0],
|
||||
text: match[1].trim(),
|
||||
}
|
||||
}
|
||||
},
|
||||
renderer(token: marked.Tokens.Generic) {
|
||||
return `<p>${katex.renderToString(token.text, katexOptions)}</p>`
|
||||
},
|
||||
}
|
||||
|
||||
marked.use({ extensions: [katexInline, katexBlock] })
|
||||
mdi.use(mdKatex, { blockClass: 'katexmath-block rounded-md p-[10px]', errorColor: ' #cc0000' })
|
||||
|
||||
const wrapClass = computed(() => {
|
||||
return [
|
||||
@@ -105,10 +48,14 @@ const wrapClass = computed(() => {
|
||||
const text = computed(() => {
|
||||
const value = props.text ?? ''
|
||||
if (!props.inversion)
|
||||
return marked(value)
|
||||
return mdi.render(value)
|
||||
return value
|
||||
})
|
||||
|
||||
function highlightBlock(str: string, lang?: string) {
|
||||
return `<pre class="code-block-wrapper"><div class="code-block-header"><span class="code-block-header__lang">${lang}</span><span class="code-block-header__copy">${t('chat.copyCode')}</span></div><code class="hljs code-block-body ${lang}">${str}</code></pre>`
|
||||
}
|
||||
|
||||
defineExpose({ textRef })
|
||||
</script>
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { onMounted, onUpdated } from 'vue'
|
||||
import { copyText } from '@/utils/format'
|
||||
|
||||
export function useCopyCode() {
|
||||
function copyCodeBlock() {
|
||||
@@ -8,7 +9,10 @@ export function useCopyCode() {
|
||||
const codeBlock = wrapper.querySelector('.code-block-body')
|
||||
if (copyBtn && codeBlock) {
|
||||
copyBtn.addEventListener('click', () => {
|
||||
navigator.clipboard.writeText(codeBlock.textContent ?? '')
|
||||
if (navigator.clipboard?.writeText)
|
||||
navigator.clipboard.writeText(codeBlock.textContent ?? '')
|
||||
else
|
||||
copyText({ text: codeBlock.textContent ?? '', origin: true })
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
<script setup lang='ts'>
|
||||
import { computed, onMounted, onUnmounted, ref } from 'vue'
|
||||
import { useRoute } from 'vue-router'
|
||||
import { NButton, NInput, useDialog } from 'naive-ui'
|
||||
import { NButton, NInput, useDialog, useMessage } from 'naive-ui'
|
||||
import html2canvas from 'html2canvas'
|
||||
import { Message } from './components'
|
||||
import { useScroll } from './hooks/useScroll'
|
||||
import { useChat } from './hooks/useChat'
|
||||
@@ -16,6 +17,7 @@ let controller = new AbortController()
|
||||
|
||||
const route = useRoute()
|
||||
const dialog = useDialog()
|
||||
const ms = useMessage()
|
||||
|
||||
const chatStore = useChatStore()
|
||||
|
||||
@@ -118,6 +120,7 @@ async function onConversation() {
|
||||
}
|
||||
},
|
||||
})
|
||||
scrollToBottom()
|
||||
}
|
||||
catch (error: any) {
|
||||
const errorMessage = error?.message ?? t('common.wrong')
|
||||
@@ -268,6 +271,46 @@ async function onRegenerate(index: number) {
|
||||
}
|
||||
}
|
||||
|
||||
function handleExport() {
|
||||
if (loading.value)
|
||||
return
|
||||
|
||||
const d = dialog.warning({
|
||||
title: t('chat.exportImage'),
|
||||
content: t('chat.exportImageConfirm'),
|
||||
positiveText: t('common.yes'),
|
||||
negativeText: t('common.no'),
|
||||
onPositiveClick: async () => {
|
||||
try {
|
||||
d.loading = true
|
||||
const ele = document.getElementById('image-wrapper')
|
||||
const canvas = await html2canvas(ele as HTMLDivElement)
|
||||
const imgUrl = canvas.toDataURL('image/png')
|
||||
const tempLink = document.createElement('a')
|
||||
tempLink.style.display = 'none'
|
||||
tempLink.href = imgUrl
|
||||
tempLink.setAttribute('download', 'chat-shot.png')
|
||||
if (typeof tempLink.download === 'undefined')
|
||||
tempLink.setAttribute('target', '_blank')
|
||||
|
||||
document.body.appendChild(tempLink)
|
||||
tempLink.click()
|
||||
document.body.removeChild(tempLink)
|
||||
window.URL.revokeObjectURL(imgUrl)
|
||||
d.loading = false
|
||||
ms.success(t('chat.exportSuccess'))
|
||||
Promise.resolve()
|
||||
}
|
||||
catch (error: any) {
|
||||
ms.error(t('chat.exportFailed'))
|
||||
}
|
||||
finally {
|
||||
d.loading = false
|
||||
}
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
function handleDelete(index: number) {
|
||||
if (loading.value)
|
||||
return
|
||||
@@ -305,6 +348,12 @@ function handleEnter(event: KeyboardEvent) {
|
||||
handleSubmit()
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (event.key === 'Enter' && event.ctrlKey) {
|
||||
event.preventDefault()
|
||||
handleSubmit()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function handleStop() {
|
||||
@@ -333,7 +382,7 @@ const wrapClass = computed(() => {
|
||||
const footerClass = computed(() => {
|
||||
let classes = ['p-4']
|
||||
if (isMobile.value)
|
||||
classes = ['sticky', 'left-0', 'bottom-0', 'right-0', 'p-2', 'pr-4', 'h-14', 'overflow-hidden']
|
||||
classes = ['sticky', 'left-0', 'bottom-0', 'right-0', 'p-2', 'pr-4', 'overflow-hidden']
|
||||
return classes
|
||||
})
|
||||
|
||||
@@ -354,9 +403,8 @@ onUnmounted(() => {
|
||||
id="scrollRef"
|
||||
ref="scrollRef"
|
||||
class="h-full overflow-hidden overflow-y-auto"
|
||||
:class="[isMobile ? 'p-2' : 'p-4']"
|
||||
>
|
||||
<div class="w-full max-w-screen-xl m-auto">
|
||||
<div id="image-wrapper" class="w-full max-w-screen-xl m-auto" :class="[isMobile ? 'p-2' : 'p-4']">
|
||||
<template v-if="!dataSources.length">
|
||||
<div class="flex items-center justify-center mt-4 text-center text-neutral-300">
|
||||
<SvgIcon icon="ri:bubble-chart-fill" class="mr-2 text-3xl" />
|
||||
@@ -397,6 +445,11 @@ onUnmounted(() => {
|
||||
<SvgIcon icon="ri:delete-bin-line" />
|
||||
</span>
|
||||
</HoverButton>
|
||||
<HoverButton @click="handleExport">
|
||||
<span class="text-xl text-[#4f555e] dark:text-white">
|
||||
<SvgIcon icon="ri:download-2-line" />
|
||||
</span>
|
||||
</HoverButton>
|
||||
<NInput
|
||||
v-model:value="prompt"
|
||||
type="textarea"
|
||||
|
||||
@@ -4,12 +4,14 @@ import { NLayout, NLayoutContent } from 'naive-ui'
|
||||
import { useRouter } from 'vue-router'
|
||||
import Sider from './sider/index.vue'
|
||||
import Header from './header/index.vue'
|
||||
import Permission from './Permission.vue'
|
||||
import { useBasicLayout } from '@/hooks/useBasicLayout'
|
||||
import { useAppStore, useChatStore } from '@/store'
|
||||
import { useAppStore, useAuthStore, useChatStore } from '@/store'
|
||||
|
||||
const router = useRouter()
|
||||
const appStore = useAppStore()
|
||||
const chatStore = useChatStore()
|
||||
const authStore = useAuthStore()
|
||||
|
||||
router.replace({ name: 'Chat', params: { uuid: chatStore.active } })
|
||||
|
||||
@@ -17,6 +19,8 @@ const { isMobile } = useBasicLayout()
|
||||
|
||||
const collapsed = computed(() => appStore.siderCollapsed)
|
||||
|
||||
const needPermission = computed(() => !!authStore.session?.auth && !authStore.token)
|
||||
|
||||
const getMobileClass = computed(() => {
|
||||
if (isMobile.value)
|
||||
return ['rounded-none', 'shadow-none']
|
||||
@@ -44,5 +48,6 @@ const getContainerClass = computed(() => {
|
||||
</NLayoutContent>
|
||||
</NLayout>
|
||||
</div>
|
||||
<Permission :visible="needPermission" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
81
src/views/chat/layout/Permission.vue
Normal file
81
src/views/chat/layout/Permission.vue
Normal file
@@ -0,0 +1,81 @@
|
||||
<script setup lang='ts'>
|
||||
import { computed, ref } from 'vue'
|
||||
import { NButton, NInput, NModal, useMessage } from 'naive-ui'
|
||||
import { fetchVerify } from '@/api'
|
||||
import { useAuthStore } from '@/store'
|
||||
import Icon403 from '@/icons/403.vue'
|
||||
|
||||
interface Props {
|
||||
visible: boolean
|
||||
}
|
||||
|
||||
defineProps<Props>()
|
||||
|
||||
const authStore = useAuthStore()
|
||||
|
||||
const ms = useMessage()
|
||||
|
||||
const loading = ref(false)
|
||||
const token = ref('')
|
||||
|
||||
const disabled = computed(() => !token.value.trim() || loading.value)
|
||||
|
||||
async function handleVerify() {
|
||||
const secretKey = token.value.trim()
|
||||
|
||||
if (!secretKey)
|
||||
return
|
||||
|
||||
try {
|
||||
loading.value = true
|
||||
await fetchVerify(secretKey)
|
||||
authStore.setToken(secretKey)
|
||||
ms.success('success')
|
||||
window.location.reload()
|
||||
}
|
||||
catch (error: any) {
|
||||
ms.error(error.message ?? 'error')
|
||||
authStore.removeToken()
|
||||
token.value = ''
|
||||
}
|
||||
finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
function handlePress(event: KeyboardEvent) {
|
||||
if (event.key === 'Enter' && !event.shiftKey) {
|
||||
event.preventDefault()
|
||||
handleVerify()
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<NModal :show="visible" style="width: 90%; max-width: 640px">
|
||||
<div class="p-10 bg-white rounded dark:bg-slate-800">
|
||||
<div class="space-y-4">
|
||||
<header class="space-y-2">
|
||||
<h2 class="text-2xl font-bold text-center text-slate-800 dark:text-neutral-200">
|
||||
403
|
||||
</h2>
|
||||
<p class="text-base text-center text-slate-500 dark:text-slate-500">
|
||||
{{ $t('common.unauthorizedTips') }}
|
||||
</p>
|
||||
<Icon403 class="w-[200px] m-auto" />
|
||||
</header>
|
||||
<NInput v-model:value="token" type="text" placeholder="" @keypress="handlePress" />
|
||||
|
||||
<NButton
|
||||
block
|
||||
type="primary"
|
||||
:disabled="disabled"
|
||||
:loading="loading"
|
||||
@click="handleVerify"
|
||||
>
|
||||
{{ $t('common.verify') }}
|
||||
</NButton>
|
||||
</div>
|
||||
</div>
|
||||
</NModal>
|
||||
</template>
|
||||
@@ -16,6 +16,8 @@ async function handleSelect({ uuid }: Chat.History) {
|
||||
if (isActive(uuid))
|
||||
return
|
||||
|
||||
if (chatStore.active)
|
||||
chatStore.updateHistory(chatStore.active, { isEdit: false })
|
||||
await chatStore.setActive(uuid)
|
||||
|
||||
if (isMobile.value)
|
||||
|
||||
@@ -32,6 +32,15 @@ const getMobileClass = computed<CSSProperties>(() => {
|
||||
return {}
|
||||
})
|
||||
|
||||
const mobileSafeArea = computed(() => {
|
||||
if (isMobile.value) {
|
||||
return {
|
||||
paddingBottom: 'env(safe-area-inset-bottom)',
|
||||
}
|
||||
}
|
||||
return {}
|
||||
})
|
||||
|
||||
watch(
|
||||
isMobile,
|
||||
(val) => {
|
||||
@@ -56,7 +65,7 @@ watch(
|
||||
:style="getMobileClass"
|
||||
@update-collapsed="handleUpdateCollapsed"
|
||||
>
|
||||
<div class="flex flex-col h-full">
|
||||
<div class="flex flex-col h-full" :style="mobileSafeArea">
|
||||
<main class="flex flex-col flex-1 min-h-0">
|
||||
<div class="p-4">
|
||||
<NButton dashed block @click="handleAdd">
|
||||
|
||||
@@ -1,34 +0,0 @@
|
||||
<script lang="ts" setup>
|
||||
import { NButton } from 'naive-ui'
|
||||
import { useRouter } from 'vue-router'
|
||||
|
||||
const router = useRouter()
|
||||
|
||||
function goHome() {
|
||||
router.push('/')
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="flex h-full">
|
||||
<div class="px-4 m-auto space-y-4 text-center max-[400px]">
|
||||
<h1 class="text-4xl text-slate-800 dark:text-neutral-200">
|
||||
No permission
|
||||
</h1>
|
||||
<p class="text-base text-slate-500 dark:text-neutral-400">
|
||||
The page you're trying access has restricted access.
|
||||
Please refer to your system administrator
|
||||
</p>
|
||||
<div class="flex items-center justify-center text-center">
|
||||
<div class="w-[300px]">
|
||||
<div class="w-[300px]">
|
||||
<img src="../../../icons/403.svg" alt="404">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<NButton type="primary" @click="goHome">
|
||||
Go to Home
|
||||
</NButton>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
32
src/views/exception/500/index.vue
Normal file
32
src/views/exception/500/index.vue
Normal file
@@ -0,0 +1,32 @@
|
||||
<script lang="ts" setup>
|
||||
import { NButton } from 'naive-ui'
|
||||
import { useRouter } from 'vue-router'
|
||||
import Icon500 from '@/icons/500.vue'
|
||||
|
||||
const router = useRouter()
|
||||
|
||||
function goHome() {
|
||||
router.push('/')
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="flex h-full dark:bg-neutral-800">
|
||||
<div class="px-4 m-auto space-y-4 text-center max-[400px]">
|
||||
<header class="space-y-2">
|
||||
<h2 class="text-2xl font-bold text-center text-slate-800 dark:text-neutral-200">
|
||||
500
|
||||
</h2>
|
||||
<p class="text-base text-center text-slate-500 dark:text-slate-500">
|
||||
Server error
|
||||
</p>
|
||||
<div class="flex items-center justify-center text-center">
|
||||
<Icon500 class="w-[300px]" />
|
||||
</div>
|
||||
</header>
|
||||
<NButton type="primary" @click="goHome">
|
||||
Go to Home
|
||||
</NButton>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
Reference in New Issue
Block a user