Compare commits
68 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7a8dc393b5 | ||
|
|
5fca2e9fa3 | ||
|
|
917feec5d8 | ||
|
|
c52195cef8 | ||
|
|
630e88b8c4 | ||
|
|
734eb7a3fb | ||
|
|
e55fc06686 | ||
|
|
5fee11323b | ||
|
|
814c3a2565 | ||
|
|
d2a22a3ee5 | ||
|
|
92278932ef | ||
|
|
9c6a3d6110 | ||
|
|
e30217542d | ||
|
|
1edf591721 | ||
|
|
60fd2ae0e0 | ||
|
|
3e509f6663 | ||
|
|
bf48eae9fe | ||
|
|
31a84325d4 | ||
|
|
b1d0056429 | ||
|
|
6ecc61ac5d | ||
|
|
e02ab1fbad | ||
|
|
47dc009505 | ||
|
|
f1584b60e8 | ||
|
|
d1c15f58c4 | ||
|
|
d422a805f6 | ||
|
|
08b5772420 | ||
|
|
8fad91ade7 | ||
|
|
560378fd45 | ||
|
|
95ce026813 | ||
|
|
71c5a88c01 | ||
|
|
a8e9a24ca7 | ||
|
|
95724845cf | ||
|
|
c5552893d7 | ||
|
|
e46d3685a0 | ||
|
|
116ed7b0bf | ||
|
|
2ad7567548 | ||
|
|
b3cfe7a976 | ||
|
|
0b13846861 | ||
|
|
951e9d8d39 | ||
|
|
1411c45811 | ||
|
|
c797ff5cb3 | ||
|
|
25692f8371 | ||
|
|
3a1466bace | ||
|
|
cf788b190a | ||
|
|
6cd16826fd | ||
|
|
b288cd612e | ||
|
|
efc9e81e83 | ||
|
|
db502e1412 | ||
|
|
41ddc6a8e1 | ||
|
|
0481726608 | ||
|
|
73bf8c01a9 | ||
|
|
8a0cb90ccc | ||
|
|
f4be5b985a | ||
|
|
0a9f9b618b | ||
|
|
af76b89fd4 | ||
|
|
de6632d631 | ||
|
|
7bebee202e | ||
|
|
bc5e835f78 | ||
|
|
a4cfd0c380 | ||
|
|
86d720ecee | ||
|
|
379bbcdd14 | ||
|
|
84a19aafc2 | ||
|
|
cf03b65a4d | ||
|
|
461d70a696 | ||
|
|
6b8ba6302a | ||
|
|
c0a1b5606e | ||
|
|
00ade41a76 | ||
|
|
514ab7e9e4 |
3
.env
3
.env
@@ -5,3 +5,6 @@ VITE_APP_API_BASE_URL=http://localhost:3002/
|
|||||||
|
|
||||||
# Whether long replies are supported, which may result in higher API fees
|
# Whether long replies are supported, which may result in higher API fees
|
||||||
VITE_GLOB_OPEN_LONG_REPLY=false
|
VITE_GLOB_OPEN_LONG_REPLY=false
|
||||||
|
|
||||||
|
# When you want to use PWA
|
||||||
|
VITE_GLOB_APP_PWA=false
|
||||||
|
|||||||
25
.vscode/launch.json
vendored
Normal file
25
.vscode/launch.json
vendored
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
{
|
||||||
|
// Use IntelliSense to learn about possible attributes.
|
||||||
|
// Hover to view descriptions of existing attributes.
|
||||||
|
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
||||||
|
"version": "0.2.0",
|
||||||
|
"configurations": [
|
||||||
|
{
|
||||||
|
"type": "chrome",
|
||||||
|
"request": "launch",
|
||||||
|
"name": "Launch Web App",
|
||||||
|
"url": "http://localhost:1002",
|
||||||
|
"webRoot": "${workspaceFolder}"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "node",
|
||||||
|
"request": "launch",
|
||||||
|
"name": "Launch Service Server",
|
||||||
|
"runtimeExecutable": "${workspaceFolder}/service/node_modules/.bin/esno",
|
||||||
|
"skipFiles": ["<node_internals>/**"],
|
||||||
|
"program": "${workspaceFolder}/service/src/index.ts",
|
||||||
|
"outFiles": ["${workspaceFolder}/service/**/*.js"],
|
||||||
|
"envFile": "${workspaceFolder}/service/.env"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
1
.vscode/settings.json
vendored
1
.vscode/settings.json
vendored
@@ -37,6 +37,7 @@
|
|||||||
"linkify",
|
"linkify",
|
||||||
"logprobs",
|
"logprobs",
|
||||||
"mdhljs",
|
"mdhljs",
|
||||||
|
"mila",
|
||||||
"nodata",
|
"nodata",
|
||||||
"OPENAI",
|
"OPENAI",
|
||||||
"pinia",
|
"pinia",
|
||||||
|
|||||||
111
CHANGELOG.md
111
CHANGELOG.md
@@ -1,3 +1,114 @@
|
|||||||
|
## v2.10.8
|
||||||
|
|
||||||
|
`2023-03-23`
|
||||||
|
|
||||||
|
如遇问题,请删除 `node_modules` 重新安装依赖。
|
||||||
|
|
||||||
|
## Feature
|
||||||
|
- 显示回复消息原文的选项 [[yilozt](https://github.com/Chanzhaoyu/chatgpt-web/pull/672)]
|
||||||
|
- 添加单 `IP` 每小时请求限制。环境变量: `MAX_REQUEST_PER_HOUR` [[zhuxindong ](https://github.com/Chanzhaoyu/chatgpt-web/pull/718)]
|
||||||
|
- 前端添加角色设定,仅 `API` 方式可见 [[quzard](https://github.com/Chanzhaoyu/chatgpt-web/pull/768)]
|
||||||
|
- `OPENAI_API_MODEL` 变量现在对 `ChatGPTUnofficialProxyAPI` 也生效,注意:`Token` 和 `API` 的模型命名不一致,不能直接填入 `gpt-3.5` 或者 `gpt-4` [[hncboy](https://github.com/Chanzhaoyu/chatgpt-web/pull/632)]
|
||||||
|
- 添加繁体中文 `Prompts` [[PeterDaveHello](https://github.com/Chanzhaoyu/chatgpt-web/pull/796)]
|
||||||
|
|
||||||
|
## Enhancement
|
||||||
|
- 重置回答时滚动定位至该回答 [[shunyue1320](https://github.com/Chanzhaoyu/chatgpt-web/pull/781)]
|
||||||
|
- 当 `API` 是 `gpt-4` 时增加可用的 `Max Tokens` [[simonwu53](https://github.com/Chanzhaoyu/chatgpt-web/pull/729)]
|
||||||
|
- 判断和忽略回复字符 [[liut](https://github.com/Chanzhaoyu/chatgpt-web/pull/474)]
|
||||||
|
- 切换会话时,自动聚焦输入框 [[JS-an](https://github.com/Chanzhaoyu/chatgpt-web/pull/735)]
|
||||||
|
- 渲染的链接新窗口打开
|
||||||
|
- 查询余额可选 `API_BASE_URL` 代理地址
|
||||||
|
- `config` 接口添加验证防止被无限制调用
|
||||||
|
- `PWA` 默认不开启,现在需手动修改 `.env` 文件 `VITE_GLOB_APP_PWA` 变量
|
||||||
|
- 当网络连接时,刷新页面,`500` 错误页自动跳转到主页
|
||||||
|
|
||||||
|
## BugFix
|
||||||
|
- `scrollToBottom` 调回 `scrollToBottomIfAtBottom` [[shunyue1320](https://github.com/Chanzhaoyu/chatgpt-web/pull/771)]
|
||||||
|
- 重置异常的 `loading` 会话
|
||||||
|
|
||||||
|
## Common
|
||||||
|
- 创建 `start.cmd` 在 `windows` 下也可以运行 [vulgatecnn](https://github.com/Chanzhaoyu/chatgpt-web/pull/656)]
|
||||||
|
- 添加 `visual-studio-code` 中调试配置 [[ChandlerVer5](https://github.com/Chanzhaoyu/chatgpt-web/pull/296)]
|
||||||
|
- 修复文档中 `docker` 端口为本地 [[kilvn](https://github.com/Chanzhaoyu/chatgpt-web/pull/802)]
|
||||||
|
## Other
|
||||||
|
- 依赖更新
|
||||||
|
|
||||||
|
|
||||||
|
## v2.10.7
|
||||||
|
|
||||||
|
`2023-03-17`
|
||||||
|
|
||||||
|
## BugFix
|
||||||
|
- 回退 `chatgpt` 版本,原因:导致 `OPENAI_API_BASE_URL` 代理失效
|
||||||
|
- 修复缺省状态的 `usingContext` 默认值
|
||||||
|
|
||||||
|
## v2.10.6
|
||||||
|
|
||||||
|
`2023-03-17`
|
||||||
|
|
||||||
|
## Feature
|
||||||
|
- 显示 `API` 余额 [[pzcn](https://github.com/Chanzhaoyu/chatgpt-web/pull/582)]
|
||||||
|
|
||||||
|
## Enhancement
|
||||||
|
- 美化滚动条样式和 `UI` 保持一致 [[haydenull](https://github.com/Chanzhaoyu/chatgpt-web/pull/617)]
|
||||||
|
- 优化移动端 `Prompt` 样式 [[CornerSkyless](https://github.com/Chanzhaoyu/chatgpt-web/pull/608)]
|
||||||
|
- 上下文开关改为全局开关,现在记录在本地缓存中
|
||||||
|
- 配置信息按接口类型显示
|
||||||
|
|
||||||
|
## Perf
|
||||||
|
- 优化函数方法 [[kirklin](https://github.com/Chanzhaoyu/chatgpt-web/pull/583)]
|
||||||
|
- 字符错误 [[pdsuwwz](https://github.com/Chanzhaoyu/chatgpt-web/pull/585)]
|
||||||
|
- 文档描述错误 [[lizhongyuan3](https://github.com/Chanzhaoyu/chatgpt-web/pull/636)]
|
||||||
|
|
||||||
|
## BugFix
|
||||||
|
- 修复 `Prompt` 导入、导出兼容性错误
|
||||||
|
- 修复 `highlight.js` 控制台兼容性警告
|
||||||
|
|
||||||
|
## Other
|
||||||
|
- 依赖更新
|
||||||
|
|
||||||
|
## v2.10.5
|
||||||
|
|
||||||
|
`2023-03-13`
|
||||||
|
|
||||||
|
更新依赖,`access_token` 默认代理为 [acheong08](https://github.com/acheong08) 的 `https://bypass.duti.tech/api/conversation`
|
||||||
|
|
||||||
|
## Feature
|
||||||
|
- `Prompt` 商店在线导入可以导入两种 `recommend.json`里提到的模板 [simonwu53](https://github.com/Chanzhaoyu/chatgpt-web/pull/521)
|
||||||
|
- 支持 `HTTPS_PROXY` [whatwewant](https://github.com/Chanzhaoyu/chatgpt-web/pull/308)
|
||||||
|
- `Prompt` 添加查询筛选
|
||||||
|
|
||||||
|
## Enhancement
|
||||||
|
- 调整输入框最大行数 [yi-ge](https://github.com/Chanzhaoyu/chatgpt-web/pull/502)
|
||||||
|
- 优化 `docker` 打包 [whatwewant](https://github.com/Chanzhaoyu/chatgpt-web/pull/520)
|
||||||
|
- `Prompt` 添加翻译和优化布局
|
||||||
|
- 「繁体中文」补全和审阅 [PeterDaveHello](https://github.com/Chanzhaoyu/chatgpt-web/pull/542)
|
||||||
|
- 语言选择调整为下路框形式
|
||||||
|
- 权限输入框类型调整为密码形式
|
||||||
|
|
||||||
|
## BugFix
|
||||||
|
- `JSON` 导入检查 [Nothing1024](https://github.com/Chanzhaoyu/chatgpt-web/pull/523)
|
||||||
|
- 修复 `AUTH_SECRET_KEY` 模式下跨域异常并添加对 `node.js 19` 版本的支持 [yi-ge](https://github.com/Chanzhaoyu/chatgpt-web/pull/499)
|
||||||
|
- 确定清空上下文时不应该重置会话标题
|
||||||
|
|
||||||
|
## Other
|
||||||
|
- 调整文档
|
||||||
|
- 更新依赖
|
||||||
|
|
||||||
|
## v2.10.4
|
||||||
|
|
||||||
|
`2023-03-11`
|
||||||
|
|
||||||
|
## Feature
|
||||||
|
- 感谢 [Nothing1024](https://github.com/Chanzhaoyu/chatgpt-web/pull/268) 添加 `Prompt` 模板和 `Prompt` 商店支持
|
||||||
|
|
||||||
|
## Enhancement
|
||||||
|
- 设置添加关闭按钮[#495]
|
||||||
|
|
||||||
|
## Demo
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
## v2.10.3
|
## v2.10.3
|
||||||
|
|
||||||
`2023-03-10`
|
`2023-03-10`
|
||||||
|
|||||||
56
Dockerfile
56
Dockerfile
@@ -1,28 +1,56 @@
|
|||||||
# build front-end
|
# build front-end
|
||||||
FROM node:lts-alpine AS builder
|
FROM node:lts-alpine AS frontend
|
||||||
|
|
||||||
|
RUN npm install pnpm -g
|
||||||
|
|
||||||
COPY ./ /app
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
RUN apk add --no-cache git \
|
COPY ./package.json /app
|
||||||
&& npm install pnpm -g \
|
|
||||||
&& pnpm install \
|
COPY ./pnpm-lock.yaml /app
|
||||||
&& pnpm run build \
|
|
||||||
&& rm -rf /root/.npm /root/.pnpm-store /usr/local/share/.cache /tmp/*
|
RUN pnpm install
|
||||||
|
|
||||||
|
COPY . /app
|
||||||
|
|
||||||
|
RUN pnpm run build
|
||||||
|
|
||||||
|
# build backend
|
||||||
|
FROM node:lts-alpine as backend
|
||||||
|
|
||||||
|
RUN npm install pnpm -g
|
||||||
|
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
COPY /service/package.json /app
|
||||||
|
|
||||||
|
COPY /service/pnpm-lock.yaml /app
|
||||||
|
|
||||||
|
RUN pnpm install
|
||||||
|
|
||||||
|
COPY /service /app
|
||||||
|
|
||||||
|
RUN pnpm build
|
||||||
|
|
||||||
# service
|
# service
|
||||||
FROM node:lts-alpine
|
FROM node:lts-alpine
|
||||||
|
|
||||||
COPY /service /app
|
RUN npm install pnpm -g
|
||||||
COPY --from=builder /app/dist /app/public
|
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
RUN apk add --no-cache git \
|
|
||||||
&& npm install pnpm -g \
|
|
||||||
&& pnpm install --only=production \
|
|
||||||
&& rm -rf /root/.npm /root/.pnpm-store /usr/local/share/.cache /tmp/*
|
|
||||||
|
|
||||||
|
COPY /service/package.json /app
|
||||||
|
|
||||||
|
COPY /service/pnpm-lock.yaml /app
|
||||||
|
|
||||||
|
RUN pnpm install --production && rm -rf /root/.npm /root/.pnpm-store /usr/local/share/.cache /tmp/*
|
||||||
|
|
||||||
|
COPY /service /app
|
||||||
|
|
||||||
|
COPY --from=frontend /app/dist /app/public
|
||||||
|
|
||||||
|
COPY --from=backend /app/build /app/build
|
||||||
|
|
||||||
EXPOSE 3002
|
EXPOSE 3002
|
||||||
|
|
||||||
CMD ["pnpm", "run", "start"]
|
CMD ["pnpm", "run", "prod"]
|
||||||
|
|||||||
14
README.en.md
14
README.en.md
@@ -174,6 +174,8 @@ pnpm dev
|
|||||||
- `TIMEOUT_MS` timeout, in milliseconds, optional
|
- `TIMEOUT_MS` timeout, in milliseconds, optional
|
||||||
- `SOCKS_PROXY_HOST` optional, effective with SOCKS_PROXY_PORT
|
- `SOCKS_PROXY_HOST` optional, effective with SOCKS_PROXY_PORT
|
||||||
- `SOCKS_PROXY_PORT` optional, effective with SOCKS_PROXY_HOST
|
- `SOCKS_PROXY_PORT` optional, effective with SOCKS_PROXY_HOST
|
||||||
|
- `HTTPS_PROXY` optional, support http,https, socks5
|
||||||
|
- `ALL_PROXY` optional, support http,https, socks5
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
@@ -183,10 +185,10 @@ pnpm dev
|
|||||||
docker build -t chatgpt-web .
|
docker build -t chatgpt-web .
|
||||||
|
|
||||||
# foreground operation
|
# foreground operation
|
||||||
docker run --name chatgpt-web --rm -it -p 3002:3002 --env OPENAI_API_KEY=your_api_key chatgpt-web
|
docker run --name chatgpt-web --rm -it -p 127.0.0.1:3002:3002 --env OPENAI_API_KEY=your_api_key chatgpt-web
|
||||||
|
|
||||||
# background operation
|
# background operation
|
||||||
docker run --name chatgpt-web -d -p 3002:3002 --env OPENAI_API_KEY=your_api_key chatgpt-web
|
docker run --name chatgpt-web -d -p 127.0.0.1:3002:3002 --env OPENAI_API_KEY=your_api_key chatgpt-web
|
||||||
|
|
||||||
# running address
|
# running address
|
||||||
http://localhost:3002/
|
http://localhost:3002/
|
||||||
@@ -203,7 +205,7 @@ services:
|
|||||||
app:
|
app:
|
||||||
image: chenzhaoyu94/chatgpt-web # always use latest, pull the tag image again when updating
|
image: chenzhaoyu94/chatgpt-web # always use latest, pull the tag image again when updating
|
||||||
ports:
|
ports:
|
||||||
- 3002:3002
|
- 127.0.0.1:3002:3002
|
||||||
environment:
|
environment:
|
||||||
# one of two
|
# one of two
|
||||||
OPENAI_API_KEY: xxxxxx
|
OPENAI_API_KEY: xxxxxx
|
||||||
@@ -223,6 +225,8 @@ services:
|
|||||||
SOCKS_PROXY_HOST: xxxx
|
SOCKS_PROXY_HOST: xxxx
|
||||||
# socks proxy port, optional, effective with SOCKS_PROXY_HOST
|
# socks proxy port, optional, effective with SOCKS_PROXY_HOST
|
||||||
SOCKS_PROXY_PORT: xxxx
|
SOCKS_PROXY_PORT: xxxx
|
||||||
|
# HTTPS Proxy,optional, support http, https, socks5
|
||||||
|
HTTPS_PROXY: http://xxx:7890
|
||||||
```
|
```
|
||||||
The `OPENAI_API_BASE_URL` is optional and only used when setting the `OPENAI_API_KEY`.
|
The `OPENAI_API_BASE_URL` is optional and only used when setting the `OPENAI_API_KEY`.
|
||||||
The `OPENAI_API_MODEL` is optional and only used when setting the `OPENAI_API_KEY`.
|
The `OPENAI_API_MODEL` is optional and only used when setting the `OPENAI_API_KEY`.
|
||||||
@@ -245,6 +249,8 @@ The `OPENAI_API_MODEL` is optional and only used when setting the `OPENAI_API_KE
|
|||||||
| `API_REVERSE_PROXY` | Optional, only for `Web API` | Reverse proxy address for `Web API`. [Details](https://github.com/transitive-bullshit/chatgpt-api#reverse-proxy) |
|
| `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_HOST` | Optional, effective with `SOCKS_PROXY_PORT` | Socks proxy. |
|
||||||
| `SOCKS_PROXY_PORT` | Optional, effective with `SOCKS_PROXY_HOST` | Socks proxy port. |
|
| `SOCKS_PROXY_PORT` | Optional, effective with `SOCKS_PROXY_HOST` | Socks proxy port. |
|
||||||
|
| `HTTPS_PROXY` | Optional | HTTPS Proxy. |
|
||||||
|
| `ALL_PROXY` | Optional | ALL Proxy. |
|
||||||
|
|
||||||
> Note: Changing environment variables in Railway will cause re-deployment.
|
> Note: Changing environment variables in Railway will cause re-deployment.
|
||||||
|
|
||||||
@@ -271,7 +277,7 @@ PS: You can also run `pnpm start` directly on the server without packaging.
|
|||||||
|
|
||||||
#### Frontend webpage
|
#### Frontend webpage
|
||||||
|
|
||||||
1. Refer to the root directory `.env.example` file content to create `.env` file, modify `VITE_APP_API_BASE_URL` in `.env` at the root directory to your actual backend interface address.
|
1. Refer to the root directory `.env.example` file content to create `.env` file, modify `VITE_GLOB_API_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.
|
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)
|
[Reference information](https://cn.vitejs.dev/guide/static-deploy.html#building-the-app)
|
||||||
|
|||||||
83
README.md
83
README.md
@@ -24,6 +24,7 @@
|
|||||||
- [测试环境运行](#测试环境运行)
|
- [测试环境运行](#测试环境运行)
|
||||||
- [后端服务](#后端服务)
|
- [后端服务](#后端服务)
|
||||||
- [前端网页](#前端网页)
|
- [前端网页](#前端网页)
|
||||||
|
- [环境变量](#环境变量)
|
||||||
- [打包](#打包)
|
- [打包](#打包)
|
||||||
- [使用 Docker](#使用-docker)
|
- [使用 Docker](#使用-docker)
|
||||||
- [Docker 参数示例](#docker-参数示例)
|
- [Docker 参数示例](#docker-参数示例)
|
||||||
@@ -51,7 +52,12 @@
|
|||||||
1. `ChatGPTAPI` 使用 `gpt-3.5-turbo-0301` 通过官方`OpenAI`补全`API`模拟`ChatGPT`(最稳健的方法,但它不是免费的,并且没有使用针对聊天进行微调的模型)
|
1. `ChatGPTAPI` 使用 `gpt-3.5-turbo-0301` 通过官方`OpenAI`补全`API`模拟`ChatGPT`(最稳健的方法,但它不是免费的,并且没有使用针对聊天进行微调的模型)
|
||||||
2. `ChatGPTUnofficialProxyAPI` 使用非官方代理服务器访问 `ChatGPT` 的后端`API`,绕过`Cloudflare`(使用真实的的`ChatGPT`,非常轻量级,但依赖于第三方服务器,并且有速率限制)
|
2. `ChatGPTUnofficialProxyAPI` 使用非官方代理服务器访问 `ChatGPT` 的后端`API`,绕过`Cloudflare`(使用真实的的`ChatGPT`,非常轻量级,但依赖于第三方服务器,并且有速率限制)
|
||||||
|
|
||||||
[查看详情](https://github.com/Chanzhaoyu/chatgpt-web/issues/138)
|
警告:
|
||||||
|
1. 你应该首先使用 `API` 方式
|
||||||
|
2. 使用 `API` 时,如果网络不通,那是国内被墙了,你需要自建代理,绝对不要使用别人的公开代理,那是危险的。
|
||||||
|
3. 使用 `accessToken` 方式时反向代理将向第三方暴露您的访问令牌,这样做应该不会产生任何不良影响,但在使用这种方法之前请考虑风险。
|
||||||
|
4. 使用 `accessToken` 时,不管你是国内还是国外的机器,都会使用代理。默认代理为 [acheong08](https://github.com/acheong08) 大佬的 `https://bypass.duti.tech/api/conversation`,这不是后门也不是监听,除非你有能力自己翻过 `CF` 验证,用前请知悉。[社区代理](https://github.com/transitive-bullshit/chatgpt-api#reverse-proxy)(注意:只有这两个是推荐,其他第三方来源,请自行甄别)
|
||||||
|
5. 把项目发布到公共网络时,你应该设置 `AUTH_SECRET_KEY` 变量添加你的密码访问权限,你也应该修改 `index.html` 中的 `title`,防止被关键词搜索到。
|
||||||
|
|
||||||
切换方式:
|
切换方式:
|
||||||
1. 进入 `service/.env.example` 文件,复制内容到 `service/.env` 文件
|
1. 进入 `service/.env.example` 文件,复制内容到 `service/.env` 文件
|
||||||
@@ -59,21 +65,12 @@
|
|||||||
3. 使用 `Web API` 请填写 `OPENAI_ACCESS_TOKEN` 字段 [(获取 accessToken)](https://chat.openai.com/api/auth/session)
|
3. 使用 `Web API` 请填写 `OPENAI_ACCESS_TOKEN` 字段 [(获取 accessToken)](https://chat.openai.com/api/auth/session)
|
||||||
4. 同时存在时以 `OpenAI API Key` 优先
|
4. 同时存在时以 `OpenAI API Key` 优先
|
||||||
|
|
||||||
反向代理:
|
|
||||||
|
|
||||||
`ChatGPTUnofficialProxyAPI`时可用,[详情](https://github.com/transitive-bullshit/chatgpt-api#reverse-proxy)
|
|
||||||
|
|
||||||
```shell
|
|
||||||
# service/.env
|
|
||||||
API_REVERSE_PROXY=
|
|
||||||
```
|
|
||||||
|
|
||||||
环境变量:
|
环境变量:
|
||||||
|
|
||||||
全部参数变量请查看或[这里](#docker-参数示例)
|
全部参数变量请查看或[这里](#环境变量)
|
||||||
|
|
||||||
```
|
```
|
||||||
/service/.env
|
/service/.env.example
|
||||||
```
|
```
|
||||||
|
|
||||||
## 待实现路线
|
## 待实现路线
|
||||||
@@ -99,7 +96,7 @@ API_REVERSE_PROXY=
|
|||||||
|
|
||||||
### Node
|
### Node
|
||||||
|
|
||||||
`node` 需要 `^16 || ^18` 版本(`node >= 14` 需要安装 [fetch polyfill](https://github.com/developit/unfetch#usage-as-a-polyfill)),使用 [nvm](https://github.com/nvm-sh/nvm) 可管理本地多个 `node` 版本
|
`node` 需要 `^16 || ^18 || ^19` 版本(`node >= 14` 需要安装 [fetch polyfill](https://github.com/developit/unfetch#usage-as-a-polyfill)),使用 [nvm](https://github.com/nvm-sh/nvm) 可管理本地多个 `node` 版本
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
node -v
|
node -v
|
||||||
@@ -157,22 +154,35 @@ pnpm start
|
|||||||
pnpm dev
|
pnpm dev
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## 环境变量
|
||||||
|
|
||||||
|
`API` 可用:
|
||||||
|
|
||||||
|
- `OPENAI_API_KEY` 和 `OPENAI_ACCESS_TOKEN` 二选一
|
||||||
|
- `OPENAI_API_MODEL` 设置模型,可选,默认:`gpt-3.5-turbo`
|
||||||
|
- `OPENAI_API_BASE_URL` 设置接口地址,可选,默认:`https://api.openai.com`
|
||||||
|
|
||||||
|
`ACCESS_TOKEN` 可用:
|
||||||
|
|
||||||
|
- `OPENAI_ACCESS_TOKEN` 和 `OPENAI_API_KEY` 二选一,同时存在时,`OPENAI_API_KEY` 优先
|
||||||
|
- `API_REVERSE_PROXY` 设置反向代理,可选,默认:`https://bypass.duti.tech/api/conversation`,[社区](https://github.com/transitive-bullshit/chatgpt-api#reverse-proxy)(注意:只有这两个是推荐,其他第三方来源,请自行甄别)
|
||||||
|
|
||||||
|
通用:
|
||||||
|
|
||||||
|
- `AUTH_SECRET_KEY` 访问权限密钥,可选
|
||||||
|
- `MAX_REQUEST_PER_HOUR` 每小时最大请求次数,可选,默认无限
|
||||||
|
- `TIMEOUT_MS` 超时,单位毫秒,可选
|
||||||
|
- `SOCKS_PROXY_HOST` 和 `SOCKS_PROXY_PORT` 一起时生效,可选
|
||||||
|
- `SOCKS_PROXY_PORT` 和 `SOCKS_PROXY_HOST` 一起时生效,可选
|
||||||
|
- `HTTPS_PROXY` 支持 `http`,`https`, `socks5`,可选
|
||||||
|
- `ALL_PROXY` 支持 `http`,`https`, `socks5`,可选
|
||||||
|
|
||||||
## 打包
|
## 打包
|
||||||
|
|
||||||
### 使用 Docker
|
### 使用 Docker
|
||||||
|
|
||||||
#### Docker 参数示例
|
#### Docker 参数示例
|
||||||
|
|
||||||
- `OPENAI_API_KEY` 二选一
|
|
||||||
- `OPENAI_ACCESS_TOKEN` 二选一,同时存在时,`OPENAI_API_KEY` 优先
|
|
||||||
- `OPENAI_API_BASE_URL` 可选,设置 `OPENAI_API_KEY` 时可用
|
|
||||||
- `OPENAI_API_MODEL` 可选,设置 `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 一起时生效
|
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
#### Docker build & Run
|
#### Docker build & Run
|
||||||
@@ -181,10 +191,10 @@ pnpm dev
|
|||||||
docker build -t chatgpt-web .
|
docker build -t chatgpt-web .
|
||||||
|
|
||||||
# 前台运行
|
# 前台运行
|
||||||
docker run --name chatgpt-web --rm -it -p 3002:3002 --env OPENAI_API_KEY=your_api_key chatgpt-web
|
docker run --name chatgpt-web --rm -it -p 127.0.0.1:3002:3002 --env OPENAI_API_KEY=your_api_key chatgpt-web
|
||||||
|
|
||||||
# 后台运行
|
# 后台运行
|
||||||
docker run --name chatgpt-web -d -p 3002:3002 --env OPENAI_API_KEY=your_api_key chatgpt-web
|
docker run --name chatgpt-web -d -p 127.0.0.1:3002:3002 --env OPENAI_API_KEY=your_api_key chatgpt-web
|
||||||
|
|
||||||
# 运行地址
|
# 运行地址
|
||||||
http://localhost:3002/
|
http://localhost:3002/
|
||||||
@@ -201,26 +211,30 @@ services:
|
|||||||
app:
|
app:
|
||||||
image: chenzhaoyu94/chatgpt-web # 总是使用 latest ,更新时重新 pull 该 tag 镜像即可
|
image: chenzhaoyu94/chatgpt-web # 总是使用 latest ,更新时重新 pull 该 tag 镜像即可
|
||||||
ports:
|
ports:
|
||||||
- 3002:3002
|
- 127.0.0.1:3002:3002
|
||||||
environment:
|
environment:
|
||||||
# 二选一
|
# 二选一
|
||||||
OPENAI_API_KEY: xxxxxx
|
OPENAI_API_KEY: sk-xxx
|
||||||
# 二选一
|
# 二选一
|
||||||
OPENAI_ACCESS_TOKEN: xxxxxx
|
OPENAI_ACCESS_TOKEN: xxx
|
||||||
# API接口地址,可选,设置 OPENAI_API_KEY 时可用
|
# API接口地址,可选,设置 OPENAI_API_KEY 时可用
|
||||||
OPENAI_API_BASE_URL: xxxx
|
OPENAI_API_BASE_URL: xxx
|
||||||
# API模型,可选,设置 OPENAI_API_KEY 时可用
|
# API模型,可选,设置 OPENAI_API_KEY 时可用
|
||||||
OPENAI_API_MODEL: xxxx
|
OPENAI_API_MODEL: xxx
|
||||||
# 反向代理,可选
|
# 反向代理,可选
|
||||||
API_REVERSE_PROXY: xxx
|
API_REVERSE_PROXY: xxx
|
||||||
# 访问权限密钥,可选
|
# 访问权限密钥,可选
|
||||||
AUTH_SECRET_KEY: xxx
|
AUTH_SECRET_KEY: xxx
|
||||||
|
# 每小时最大请求次数,可选,默认无限
|
||||||
|
MAX_REQUEST_PER_HOUR: 0
|
||||||
# 超时,单位毫秒,可选
|
# 超时,单位毫秒,可选
|
||||||
TIMEOUT_MS: 60000
|
TIMEOUT_MS: 60000
|
||||||
# Socks代理,可选,和 SOCKS_PROXY_PORT 一起时生效
|
# Socks代理,可选,和 SOCKS_PROXY_PORT 一起时生效
|
||||||
SOCKS_PROXY_HOST: xxxx
|
SOCKS_PROXY_HOST: xxx
|
||||||
# Socks代理端口,可选,和 SOCKS_PROXY_HOST 一起时生效
|
# Socks代理端口,可选,和 SOCKS_PROXY_HOST 一起时生效
|
||||||
SOCKS_PROXY_PORT: xxxx
|
SOCKS_PROXY_PORT: xxx
|
||||||
|
# HTTPS 代理,可选,支持 http,https,socks5
|
||||||
|
HTTPS_PROXY: http://xxx:7890
|
||||||
```
|
```
|
||||||
- `OPENAI_API_BASE_URL` 可选,设置 `OPENAI_API_KEY` 时可用
|
- `OPENAI_API_BASE_URL` 可选,设置 `OPENAI_API_KEY` 时可用
|
||||||
- `OPENAI_API_MODEL` 可选,设置 `OPENAI_API_KEY` 时可用
|
- `OPENAI_API_MODEL` 可选,设置 `OPENAI_API_KEY` 时可用
|
||||||
@@ -234,6 +248,7 @@ services:
|
|||||||
| --------------------- | ---------------------- | -------------------------------------------------------------------------------------------------- |
|
| --------------------- | ---------------------- | -------------------------------------------------------------------------------------------------- |
|
||||||
| `PORT` | 必填 | 默认 `3002`
|
| `PORT` | 必填 | 默认 `3002`
|
||||||
| `AUTH_SECRET_KEY` | 可选 | 访问权限密钥 |
|
| `AUTH_SECRET_KEY` | 可选 | 访问权限密钥 |
|
||||||
|
| `MAX_REQUEST_PER_HOUR` | 可选 | 每小时最大请求次数,可选,默认无限 |
|
||||||
| `TIMEOUT_MS` | 可选 | 超时时间,单位毫秒 |
|
| `TIMEOUT_MS` | 可选 | 超时时间,单位毫秒 |
|
||||||
| `OPENAI_API_KEY` | `OpenAI API` 二选一 | 使用 `OpenAI API` 所需的 `apiKey` [(获取 apiKey)](https://platform.openai.com/overview) |
|
| `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_ACCESS_TOKEN` | `Web API` 二选一 | 使用 `Web API` 所需的 `accessToken` [(获取 accessToken)](https://chat.openai.com/api/auth/session) |
|
||||||
@@ -242,6 +257,8 @@ services:
|
|||||||
| `API_REVERSE_PROXY` | 可选,`Web API` 时可用 | `Web API` 反向代理地址 [详情](https://github.com/transitive-bullshit/chatgpt-api#reverse-proxy) |
|
| `API_REVERSE_PROXY` | 可选,`Web API` 时可用 | `Web API` 反向代理地址 [详情](https://github.com/transitive-bullshit/chatgpt-api#reverse-proxy) |
|
||||||
| `SOCKS_PROXY_HOST` | 可选,和 `SOCKS_PROXY_PORT` 一起时生效 | Socks代理 |
|
| `SOCKS_PROXY_HOST` | 可选,和 `SOCKS_PROXY_PORT` 一起时生效 | Socks代理 |
|
||||||
| `SOCKS_PROXY_PORT` | 可选,和 `SOCKS_PROXY_HOST` 一起时生效 | Socks代理端口 |
|
| `SOCKS_PROXY_PORT` | 可选,和 `SOCKS_PROXY_HOST` 一起时生效 | Socks代理端口 |
|
||||||
|
| `HTTPS_PROXY` | 可选 | HTTPS 代理,支持 http,https, socks5 |
|
||||||
|
| `ALL_PROXY` | 可选 | 所有代理 代理,支持 http,https, socks5 |
|
||||||
|
|
||||||
> 注意: `Railway` 修改环境变量会重新 `Deploy`
|
> 注意: `Railway` 修改环境变量会重新 `Deploy`
|
||||||
|
|
||||||
@@ -266,7 +283,7 @@ PS: 不进行打包,直接在服务器上运行 `pnpm start` 也可
|
|||||||
|
|
||||||
#### 前端网页
|
#### 前端网页
|
||||||
|
|
||||||
1、修改根目录下 `.env` 文件中的 `VITE_APP_API_BASE_URL` 为你的实际后端接口地址
|
1、修改根目录下 `.env` 文件中的 `VITE_GLOB_API_URL` 为你的实际后端接口地址
|
||||||
|
|
||||||
2、根目录下运行以下命令,然后将 `dist` 文件夹内的文件复制到你网站服务的根目录下
|
2、根目录下运行以下命令,然后将 `dist` 文件夹内的文件复制到你网站服务的根目录下
|
||||||
|
|
||||||
|
|||||||
@@ -7,23 +7,27 @@ services:
|
|||||||
- 3002:3002
|
- 3002:3002
|
||||||
environment:
|
environment:
|
||||||
# 二选一
|
# 二选一
|
||||||
OPENAI_API_KEY: xxxx
|
OPENAI_API_KEY: sk-xxx
|
||||||
# 二选一
|
# 二选一
|
||||||
OPENAI_ACCESS_TOKEN: xxxxxx
|
OPENAI_ACCESS_TOKEN: xxx
|
||||||
# API接口地址,可选,设置 OPENAI_API_KEY 时可用
|
# API接口地址,可选,设置 OPENAI_API_KEY 时可用
|
||||||
OPENAI_API_BASE_URL: xxxx
|
OPENAI_API_BASE_URL: xxx
|
||||||
# API模型,可选,设置 OPENAI_API_KEY 时可用
|
# API模型,可选,设置 OPENAI_API_KEY 时可用
|
||||||
OPENAI_API_MODEL: xxxx
|
OPENAI_API_MODEL: xxx
|
||||||
# 反向代理,可选
|
# 反向代理,可选
|
||||||
API_REVERSE_PROXY: xxx
|
API_REVERSE_PROXY: xxx
|
||||||
# 访问权限密钥,可选
|
# 访问权限密钥,可选
|
||||||
AUTH_SECRET_KEY: xxx
|
AUTH_SECRET_KEY: xxx
|
||||||
|
# 每小时最大请求次数,可选,默认无限
|
||||||
|
MAX_REQUEST_PER_HOUR: 0
|
||||||
# 超时,单位毫秒,可选
|
# 超时,单位毫秒,可选
|
||||||
TIMEOUT_MS: 60000
|
TIMEOUT_MS: 60000
|
||||||
# Socks代理,可选,和 SOCKS_PROXY_PORT 一起时生效
|
# Socks代理,可选,和 SOCKS_PROXY_PORT 一起时生效
|
||||||
SOCKS_PROXY_HOST: xxxx
|
SOCKS_PROXY_HOST: xxx
|
||||||
# Socks代理端口,可选,和 SOCKS_PROXY_HOST 一起时生效
|
# Socks代理端口,可选,和 SOCKS_PROXY_HOST 一起时生效
|
||||||
SOCKS_PROXY_PORT: xxxx
|
SOCKS_PROXY_PORT: xxx
|
||||||
|
# HTTPS_PROXY 代理,可选
|
||||||
|
HTTPS_PROXY: http://xxx:7890
|
||||||
nginx:
|
nginx:
|
||||||
image: nginx:alpine
|
image: nginx:alpine
|
||||||
ports:
|
ports:
|
||||||
|
|||||||
BIN
docs/c1-2.9.0.png
Normal file
BIN
docs/c1-2.9.0.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 282 KiB |
BIN
docs/c1.png
BIN
docs/c1.png
Binary file not shown.
|
Before Width: | Height: | Size: 282 KiB After Width: | Height: | Size: 96 KiB |
BIN
docs/c2-2.9.0.png
Normal file
BIN
docs/c2-2.9.0.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 128 KiB |
BIN
docs/c2.png
BIN
docs/c2.png
Binary file not shown.
|
Before Width: | Height: | Size: 128 KiB After Width: | Height: | Size: 78 KiB |
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "chatgpt-web",
|
"name": "chatgpt-web",
|
||||||
"version": "2.10.3",
|
"version": "2.10.8",
|
||||||
"private": false,
|
"private": false,
|
||||||
"description": "ChatGPT Web",
|
"description": "ChatGPT Web",
|
||||||
"author": "ChenZhaoYu <chenzhaoyu1994@gmail.com>",
|
"author": "ChenZhaoYu <chenzhaoyu1994@gmail.com>",
|
||||||
@@ -30,7 +30,7 @@
|
|||||||
"katex": "^0.16.4",
|
"katex": "^0.16.4",
|
||||||
"markdown-it": "^13.0.1",
|
"markdown-it": "^13.0.1",
|
||||||
"naive-ui": "^2.34.3",
|
"naive-ui": "^2.34.3",
|
||||||
"pinia": "^2.0.32",
|
"pinia": "^2.0.33",
|
||||||
"vue": "^3.2.47",
|
"vue": "^3.2.47",
|
||||||
"vue-i18n": "^9.2.2",
|
"vue-i18n": "^9.2.2",
|
||||||
"vue-router": "^4.1.6"
|
"vue-router": "^4.1.6"
|
||||||
@@ -43,6 +43,7 @@
|
|||||||
"@types/crypto-js": "^4.1.1",
|
"@types/crypto-js": "^4.1.1",
|
||||||
"@types/katex": "^0.16.0",
|
"@types/katex": "^0.16.0",
|
||||||
"@types/markdown-it": "^12.2.3",
|
"@types/markdown-it": "^12.2.3",
|
||||||
|
"@types/markdown-it-link-attributes": "^3.0.1",
|
||||||
"@types/node": "^18.14.6",
|
"@types/node": "^18.14.6",
|
||||||
"@vitejs/plugin-vue": "^4.0.0",
|
"@vitejs/plugin-vue": "^4.0.0",
|
||||||
"autoprefixer": "^10.4.13",
|
"autoprefixer": "^10.4.13",
|
||||||
@@ -52,12 +53,13 @@
|
|||||||
"husky": "^8.0.3",
|
"husky": "^8.0.3",
|
||||||
"less": "^4.1.3",
|
"less": "^4.1.3",
|
||||||
"lint-staged": "^13.1.2",
|
"lint-staged": "^13.1.2",
|
||||||
|
"markdown-it-link-attributes": "^4.0.1",
|
||||||
"npm-run-all": "^4.1.5",
|
"npm-run-all": "^4.1.5",
|
||||||
"postcss": "^8.4.21",
|
"postcss": "^8.4.21",
|
||||||
"rimraf": "^4.2.0",
|
"rimraf": "^4.2.0",
|
||||||
"tailwindcss": "^3.2.7",
|
"tailwindcss": "^3.2.7",
|
||||||
"typescript": "~4.9.5",
|
"typescript": "~4.9.5",
|
||||||
"vite": "^4.1.4",
|
"vite": "^4.2.0",
|
||||||
"vite-plugin-pwa": "^0.14.4",
|
"vite-plugin-pwa": "^0.14.4",
|
||||||
"vue-tsc": "^1.2.0"
|
"vue-tsc": "^1.2.0"
|
||||||
},
|
},
|
||||||
|
|||||||
188
pnpm-lock.yaml
generated
188
pnpm-lock.yaml
generated
@@ -9,6 +9,7 @@ specifiers:
|
|||||||
'@types/crypto-js': ^4.1.1
|
'@types/crypto-js': ^4.1.1
|
||||||
'@types/katex': ^0.16.0
|
'@types/katex': ^0.16.0
|
||||||
'@types/markdown-it': ^12.2.3
|
'@types/markdown-it': ^12.2.3
|
||||||
|
'@types/markdown-it-link-attributes': ^3.0.1
|
||||||
'@types/node': ^18.14.6
|
'@types/node': ^18.14.6
|
||||||
'@vitejs/plugin-vue': ^4.0.0
|
'@vitejs/plugin-vue': ^4.0.0
|
||||||
'@vueuse/core': ^9.13.0
|
'@vueuse/core': ^9.13.0
|
||||||
@@ -23,14 +24,15 @@ specifiers:
|
|||||||
less: ^4.1.3
|
less: ^4.1.3
|
||||||
lint-staged: ^13.1.2
|
lint-staged: ^13.1.2
|
||||||
markdown-it: ^13.0.1
|
markdown-it: ^13.0.1
|
||||||
|
markdown-it-link-attributes: ^4.0.1
|
||||||
naive-ui: ^2.34.3
|
naive-ui: ^2.34.3
|
||||||
npm-run-all: ^4.1.5
|
npm-run-all: ^4.1.5
|
||||||
pinia: ^2.0.32
|
pinia: ^2.0.33
|
||||||
postcss: ^8.4.21
|
postcss: ^8.4.21
|
||||||
rimraf: ^4.2.0
|
rimraf: ^4.2.0
|
||||||
tailwindcss: ^3.2.7
|
tailwindcss: ^3.2.7
|
||||||
typescript: ~4.9.5
|
typescript: ~4.9.5
|
||||||
vite: ^4.1.4
|
vite: ^4.2.0
|
||||||
vite-plugin-pwa: ^0.14.4
|
vite-plugin-pwa: ^0.14.4
|
||||||
vue: ^3.2.47
|
vue: ^3.2.47
|
||||||
vue-i18n: ^9.2.2
|
vue-i18n: ^9.2.2
|
||||||
@@ -58,8 +60,9 @@ devDependencies:
|
|||||||
'@types/crypto-js': 4.1.1
|
'@types/crypto-js': 4.1.1
|
||||||
'@types/katex': 0.16.0
|
'@types/katex': 0.16.0
|
||||||
'@types/markdown-it': 12.2.3
|
'@types/markdown-it': 12.2.3
|
||||||
|
'@types/markdown-it-link-attributes': 3.0.1
|
||||||
'@types/node': 18.14.6
|
'@types/node': 18.14.6
|
||||||
'@vitejs/plugin-vue': 4.0.0_vite@4.1.4+vue@3.2.47
|
'@vitejs/plugin-vue': 4.0.0_vite@4.2.0+vue@3.2.47
|
||||||
autoprefixer: 10.4.13_postcss@8.4.21
|
autoprefixer: 10.4.13_postcss@8.4.21
|
||||||
axios: 1.3.4
|
axios: 1.3.4
|
||||||
crypto-js: 4.1.1
|
crypto-js: 4.1.1
|
||||||
@@ -67,13 +70,14 @@ devDependencies:
|
|||||||
husky: 8.0.3
|
husky: 8.0.3
|
||||||
less: 4.1.3
|
less: 4.1.3
|
||||||
lint-staged: 13.1.2
|
lint-staged: 13.1.2
|
||||||
|
markdown-it-link-attributes: 4.0.1
|
||||||
npm-run-all: 4.1.5
|
npm-run-all: 4.1.5
|
||||||
postcss: 8.4.21
|
postcss: 8.4.21
|
||||||
rimraf: 4.3.0
|
rimraf: 4.3.0
|
||||||
tailwindcss: 3.2.7_postcss@8.4.21
|
tailwindcss: 3.2.7_postcss@8.4.21
|
||||||
typescript: 4.9.5
|
typescript: 4.9.5
|
||||||
vite: 4.1.4_4l5pdn5ozbjpiwj3fcgseihr44
|
vite: 4.2.0_4l5pdn5ozbjpiwj3fcgseihr44
|
||||||
vite-plugin-pwa: 0.14.4_vite@4.1.4
|
vite-plugin-pwa: 0.14.4_vite@4.2.0
|
||||||
vue-tsc: 1.2.0_typescript@4.9.5
|
vue-tsc: 1.2.0_typescript@4.9.5
|
||||||
|
|
||||||
packages:
|
packages:
|
||||||
@@ -1531,8 +1535,8 @@ packages:
|
|||||||
resolution: {integrity: sha512-kBJtf7PH6aWwZ6fka3zQ0p6SBYzx4fl1LoZXE2RrnYST9Xljm7WfKJrU4g/Xr3Beg72MLrp1AWNUmuYJTL7Cow==}
|
resolution: {integrity: sha512-kBJtf7PH6aWwZ6fka3zQ0p6SBYzx4fl1LoZXE2RrnYST9Xljm7WfKJrU4g/Xr3Beg72MLrp1AWNUmuYJTL7Cow==}
|
||||||
dev: false
|
dev: false
|
||||||
|
|
||||||
/@esbuild/android-arm/0.16.17:
|
/@esbuild/android-arm/0.17.11:
|
||||||
resolution: {integrity: sha512-N9x1CMXVhtWEAMS7pNNONyA14f71VPQN9Cnavj1XQh6T7bskqiLLrSca4O0Vr8Wdcga943eThxnVp3JLnBMYtw==}
|
resolution: {integrity: sha512-CdyX6sRVh1NzFCsf5vw3kULwlAhfy9wVt8SZlrhQ7eL2qBjGbFhRBWkkAzuZm9IIEOCKJw4DXA6R85g+qc8RDw==}
|
||||||
engines: {node: '>=12'}
|
engines: {node: '>=12'}
|
||||||
cpu: [arm]
|
cpu: [arm]
|
||||||
os: [android]
|
os: [android]
|
||||||
@@ -1540,8 +1544,8 @@ packages:
|
|||||||
dev: true
|
dev: true
|
||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
/@esbuild/android-arm64/0.16.17:
|
/@esbuild/android-arm64/0.17.11:
|
||||||
resolution: {integrity: sha512-MIGl6p5sc3RDTLLkYL1MyL8BMRN4tLMRCn+yRJJmEDvYZ2M7tmAf80hx1kbNEUX2KJ50RRtxZ4JHLvCfuB6kBg==}
|
resolution: {integrity: sha512-QnK4d/zhVTuV4/pRM4HUjcsbl43POALU2zvBynmrrqZt9LPcLA3x1fTZPBg2RRguBQnJcnU059yKr+bydkntjg==}
|
||||||
engines: {node: '>=12'}
|
engines: {node: '>=12'}
|
||||||
cpu: [arm64]
|
cpu: [arm64]
|
||||||
os: [android]
|
os: [android]
|
||||||
@@ -1549,8 +1553,8 @@ packages:
|
|||||||
dev: true
|
dev: true
|
||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
/@esbuild/android-x64/0.16.17:
|
/@esbuild/android-x64/0.17.11:
|
||||||
resolution: {integrity: sha512-a3kTv3m0Ghh4z1DaFEuEDfz3OLONKuFvI4Xqczqx4BqLyuFaFkuaG4j2MtA6fuWEFeC5x9IvqnX7drmRq/fyAQ==}
|
resolution: {integrity: sha512-3PL3HKtsDIXGQcSCKtWD/dy+mgc4p2Tvo2qKgKHj9Yf+eniwFnuoQ0OUhlSfAEpKAFzF9N21Nwgnap6zy3L3MQ==}
|
||||||
engines: {node: '>=12'}
|
engines: {node: '>=12'}
|
||||||
cpu: [x64]
|
cpu: [x64]
|
||||||
os: [android]
|
os: [android]
|
||||||
@@ -1558,8 +1562,8 @@ packages:
|
|||||||
dev: true
|
dev: true
|
||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
/@esbuild/darwin-arm64/0.16.17:
|
/@esbuild/darwin-arm64/0.17.11:
|
||||||
resolution: {integrity: sha512-/2agbUEfmxWHi9ARTX6OQ/KgXnOWfsNlTeLcoV7HSuSTv63E4DqtAc+2XqGw1KHxKMHGZgbVCZge7HXWX9Vn+w==}
|
resolution: {integrity: sha512-pJ950bNKgzhkGNO3Z9TeHzIFtEyC2GDQL3wxkMApDEghYx5Qers84UTNc1bAxWbRkuJOgmOha5V0WUeh8G+YGw==}
|
||||||
engines: {node: '>=12'}
|
engines: {node: '>=12'}
|
||||||
cpu: [arm64]
|
cpu: [arm64]
|
||||||
os: [darwin]
|
os: [darwin]
|
||||||
@@ -1567,8 +1571,8 @@ packages:
|
|||||||
dev: true
|
dev: true
|
||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
/@esbuild/darwin-x64/0.16.17:
|
/@esbuild/darwin-x64/0.17.11:
|
||||||
resolution: {integrity: sha512-2By45OBHulkd9Svy5IOCZt376Aa2oOkiE9QWUK9fe6Tb+WDr8hXL3dpqi+DeLiMed8tVXspzsTAvd0jUl96wmg==}
|
resolution: {integrity: sha512-iB0dQkIHXyczK3BZtzw1tqegf0F0Ab5texX2TvMQjiJIWXAfM4FQl7D909YfXWnB92OQz4ivBYQ2RlxBJrMJOw==}
|
||||||
engines: {node: '>=12'}
|
engines: {node: '>=12'}
|
||||||
cpu: [x64]
|
cpu: [x64]
|
||||||
os: [darwin]
|
os: [darwin]
|
||||||
@@ -1576,8 +1580,8 @@ packages:
|
|||||||
dev: true
|
dev: true
|
||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
/@esbuild/freebsd-arm64/0.16.17:
|
/@esbuild/freebsd-arm64/0.17.11:
|
||||||
resolution: {integrity: sha512-mt+cxZe1tVx489VTb4mBAOo2aKSnJ33L9fr25JXpqQqzbUIw/yzIzi+NHwAXK2qYV1lEFp4OoVeThGjUbmWmdw==}
|
resolution: {integrity: sha512-7EFzUADmI1jCHeDRGKgbnF5sDIceZsQGapoO6dmw7r/ZBEKX7CCDnIz8m9yEclzr7mFsd+DyasHzpjfJnmBB1Q==}
|
||||||
engines: {node: '>=12'}
|
engines: {node: '>=12'}
|
||||||
cpu: [arm64]
|
cpu: [arm64]
|
||||||
os: [freebsd]
|
os: [freebsd]
|
||||||
@@ -1585,8 +1589,8 @@ packages:
|
|||||||
dev: true
|
dev: true
|
||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
/@esbuild/freebsd-x64/0.16.17:
|
/@esbuild/freebsd-x64/0.17.11:
|
||||||
resolution: {integrity: sha512-8ScTdNJl5idAKjH8zGAsN7RuWcyHG3BAvMNpKOBaqqR7EbUhhVHOqXRdL7oZvz8WNHL2pr5+eIT5c65kA6NHug==}
|
resolution: {integrity: sha512-iPgenptC8i8pdvkHQvXJFzc1eVMR7W2lBPrTE6GbhR54sLcF42mk3zBOjKPOodezzuAz/KSu8CPyFSjcBMkE9g==}
|
||||||
engines: {node: '>=12'}
|
engines: {node: '>=12'}
|
||||||
cpu: [x64]
|
cpu: [x64]
|
||||||
os: [freebsd]
|
os: [freebsd]
|
||||||
@@ -1594,8 +1598,8 @@ packages:
|
|||||||
dev: true
|
dev: true
|
||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
/@esbuild/linux-arm/0.16.17:
|
/@esbuild/linux-arm/0.17.11:
|
||||||
resolution: {integrity: sha512-iihzrWbD4gIT7j3caMzKb/RsFFHCwqqbrbH9SqUSRrdXkXaygSZCZg1FybsZz57Ju7N/SHEgPyaR0LZ8Zbe9gQ==}
|
resolution: {integrity: sha512-M9iK/d4lgZH0U5M1R2p2gqhPV/7JPJcRz+8O8GBKVgqndTzydQ7B2XGDbxtbvFkvIs53uXTobOhv+RyaqhUiMg==}
|
||||||
engines: {node: '>=12'}
|
engines: {node: '>=12'}
|
||||||
cpu: [arm]
|
cpu: [arm]
|
||||||
os: [linux]
|
os: [linux]
|
||||||
@@ -1603,8 +1607,8 @@ packages:
|
|||||||
dev: true
|
dev: true
|
||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
/@esbuild/linux-arm64/0.16.17:
|
/@esbuild/linux-arm64/0.17.11:
|
||||||
resolution: {integrity: sha512-7S8gJnSlqKGVJunnMCrXHU9Q8Q/tQIxk/xL8BqAP64wchPCTzuM6W3Ra8cIa1HIflAvDnNOt2jaL17vaW+1V0g==}
|
resolution: {integrity: sha512-Qxth3gsWWGKz2/qG2d5DsW/57SeA2AmpSMhdg9TSB5Svn2KDob3qxfQSkdnWjSd42kqoxIPy3EJFs+6w1+6Qjg==}
|
||||||
engines: {node: '>=12'}
|
engines: {node: '>=12'}
|
||||||
cpu: [arm64]
|
cpu: [arm64]
|
||||||
os: [linux]
|
os: [linux]
|
||||||
@@ -1612,8 +1616,8 @@ packages:
|
|||||||
dev: true
|
dev: true
|
||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
/@esbuild/linux-ia32/0.16.17:
|
/@esbuild/linux-ia32/0.17.11:
|
||||||
resolution: {integrity: sha512-kiX69+wcPAdgl3Lonh1VI7MBr16nktEvOfViszBSxygRQqSpzv7BffMKRPMFwzeJGPxcio0pdD3kYQGpqQ2SSg==}
|
resolution: {integrity: sha512-dB1nGaVWtUlb/rRDHmuDQhfqazWE0LMro/AIbT2lWM3CDMHJNpLckH+gCddQyhhcLac2OYw69ikUMO34JLt3wA==}
|
||||||
engines: {node: '>=12'}
|
engines: {node: '>=12'}
|
||||||
cpu: [ia32]
|
cpu: [ia32]
|
||||||
os: [linux]
|
os: [linux]
|
||||||
@@ -1621,8 +1625,8 @@ packages:
|
|||||||
dev: true
|
dev: true
|
||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
/@esbuild/linux-loong64/0.16.17:
|
/@esbuild/linux-loong64/0.17.11:
|
||||||
resolution: {integrity: sha512-dTzNnQwembNDhd654cA4QhbS9uDdXC3TKqMJjgOWsC0yNCbpzfWoXdZvp0mY7HU6nzk5E0zpRGGx3qoQg8T2DQ==}
|
resolution: {integrity: sha512-aCWlq70Q7Nc9WDnormntGS1ar6ZFvUpqr8gXtO+HRejRYPweAFQN615PcgaSJkZjhHp61+MNLhzyVALSF2/Q0g==}
|
||||||
engines: {node: '>=12'}
|
engines: {node: '>=12'}
|
||||||
cpu: [loong64]
|
cpu: [loong64]
|
||||||
os: [linux]
|
os: [linux]
|
||||||
@@ -1630,8 +1634,8 @@ packages:
|
|||||||
dev: true
|
dev: true
|
||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
/@esbuild/linux-mips64el/0.16.17:
|
/@esbuild/linux-mips64el/0.17.11:
|
||||||
resolution: {integrity: sha512-ezbDkp2nDl0PfIUn0CsQ30kxfcLTlcx4Foz2kYv8qdC6ia2oX5Q3E/8m6lq84Dj/6b0FrkgD582fJMIfHhJfSw==}
|
resolution: {integrity: sha512-cGeGNdQxqY8qJwlYH1BP6rjIIiEcrM05H7k3tR7WxOLmD1ZxRMd6/QIOWMb8mD2s2YJFNRuNQ+wjMhgEL2oCEw==}
|
||||||
engines: {node: '>=12'}
|
engines: {node: '>=12'}
|
||||||
cpu: [mips64el]
|
cpu: [mips64el]
|
||||||
os: [linux]
|
os: [linux]
|
||||||
@@ -1639,8 +1643,8 @@ packages:
|
|||||||
dev: true
|
dev: true
|
||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
/@esbuild/linux-ppc64/0.16.17:
|
/@esbuild/linux-ppc64/0.17.11:
|
||||||
resolution: {integrity: sha512-dzS678gYD1lJsW73zrFhDApLVdM3cUF2MvAa1D8K8KtcSKdLBPP4zZSLy6LFZ0jYqQdQ29bjAHJDgz0rVbLB3g==}
|
resolution: {integrity: sha512-BdlziJQPW/bNe0E8eYsHB40mYOluS+jULPCjlWiHzDgr+ZBRXPtgMV1nkLEGdpjrwgmtkZHEGEPaKdS/8faLDA==}
|
||||||
engines: {node: '>=12'}
|
engines: {node: '>=12'}
|
||||||
cpu: [ppc64]
|
cpu: [ppc64]
|
||||||
os: [linux]
|
os: [linux]
|
||||||
@@ -1648,8 +1652,8 @@ packages:
|
|||||||
dev: true
|
dev: true
|
||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
/@esbuild/linux-riscv64/0.16.17:
|
/@esbuild/linux-riscv64/0.17.11:
|
||||||
resolution: {integrity: sha512-ylNlVsxuFjZK8DQtNUwiMskh6nT0vI7kYl/4fZgV1llP5d6+HIeL/vmmm3jpuoo8+NuXjQVZxmKuhDApK0/cKw==}
|
resolution: {integrity: sha512-MDLwQbtF+83oJCI1Cixn68Et/ME6gelmhssPebC40RdJaect+IM+l7o/CuG0ZlDs6tZTEIoxUe53H3GmMn8oMA==}
|
||||||
engines: {node: '>=12'}
|
engines: {node: '>=12'}
|
||||||
cpu: [riscv64]
|
cpu: [riscv64]
|
||||||
os: [linux]
|
os: [linux]
|
||||||
@@ -1657,8 +1661,8 @@ packages:
|
|||||||
dev: true
|
dev: true
|
||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
/@esbuild/linux-s390x/0.16.17:
|
/@esbuild/linux-s390x/0.17.11:
|
||||||
resolution: {integrity: sha512-gzy7nUTO4UA4oZ2wAMXPNBGTzZFP7mss3aKR2hH+/4UUkCOyqmjXiKpzGrY2TlEUhbbejzXVKKGazYcQTZWA/w==}
|
resolution: {integrity: sha512-4N5EMESvws0Ozr2J94VoUD8HIRi7X0uvUv4c0wpTHZyZY9qpaaN7THjosdiW56irQ4qnJ6Lsc+i+5zGWnyqWqQ==}
|
||||||
engines: {node: '>=12'}
|
engines: {node: '>=12'}
|
||||||
cpu: [s390x]
|
cpu: [s390x]
|
||||||
os: [linux]
|
os: [linux]
|
||||||
@@ -1666,8 +1670,8 @@ packages:
|
|||||||
dev: true
|
dev: true
|
||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
/@esbuild/linux-x64/0.16.17:
|
/@esbuild/linux-x64/0.17.11:
|
||||||
resolution: {integrity: sha512-mdPjPxfnmoqhgpiEArqi4egmBAMYvaObgn4poorpUaqmvzzbvqbowRllQ+ZgzGVMGKaPkqUmPDOOFQRUFDmeUw==}
|
resolution: {integrity: sha512-rM/v8UlluxpytFSmVdbCe1yyKQd/e+FmIJE2oPJvbBo+D0XVWi1y/NQ4iTNx+436WmDHQBjVLrbnAQLQ6U7wlw==}
|
||||||
engines: {node: '>=12'}
|
engines: {node: '>=12'}
|
||||||
cpu: [x64]
|
cpu: [x64]
|
||||||
os: [linux]
|
os: [linux]
|
||||||
@@ -1675,8 +1679,8 @@ packages:
|
|||||||
dev: true
|
dev: true
|
||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
/@esbuild/netbsd-x64/0.16.17:
|
/@esbuild/netbsd-x64/0.17.11:
|
||||||
resolution: {integrity: sha512-/PzmzD/zyAeTUsduZa32bn0ORug+Jd1EGGAUJvqfeixoEISYpGnAezN6lnJoskauoai0Jrs+XSyvDhppCPoKOA==}
|
resolution: {integrity: sha512-4WaAhuz5f91h3/g43VBGdto1Q+X7VEZfpcWGtOFXnggEuLvjV+cP6DyLRU15IjiU9fKLLk41OoJfBFN5DhPvag==}
|
||||||
engines: {node: '>=12'}
|
engines: {node: '>=12'}
|
||||||
cpu: [x64]
|
cpu: [x64]
|
||||||
os: [netbsd]
|
os: [netbsd]
|
||||||
@@ -1684,8 +1688,8 @@ packages:
|
|||||||
dev: true
|
dev: true
|
||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
/@esbuild/openbsd-x64/0.16.17:
|
/@esbuild/openbsd-x64/0.17.11:
|
||||||
resolution: {integrity: sha512-2yaWJhvxGEz2RiftSk0UObqJa/b+rIAjnODJgv2GbGGpRwAfpgzyrg1WLK8rqA24mfZa9GvpjLcBBg8JHkoodg==}
|
resolution: {integrity: sha512-UBj135Nx4FpnvtE+C8TWGp98oUgBcmNmdYgl5ToKc0mBHxVVqVE7FUS5/ELMImOp205qDAittL6Ezhasc2Ev/w==}
|
||||||
engines: {node: '>=12'}
|
engines: {node: '>=12'}
|
||||||
cpu: [x64]
|
cpu: [x64]
|
||||||
os: [openbsd]
|
os: [openbsd]
|
||||||
@@ -1693,8 +1697,8 @@ packages:
|
|||||||
dev: true
|
dev: true
|
||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
/@esbuild/sunos-x64/0.16.17:
|
/@esbuild/sunos-x64/0.17.11:
|
||||||
resolution: {integrity: sha512-xtVUiev38tN0R3g8VhRfN7Zl42YCJvyBhRKw1RJjwE1d2emWTVToPLNEQj/5Qxc6lVFATDiy6LjVHYhIPrLxzw==}
|
resolution: {integrity: sha512-1/gxTifDC9aXbV2xOfCbOceh5AlIidUrPsMpivgzo8P8zUtczlq1ncFpeN1ZyQJ9lVs2hILy1PG5KPp+w8QPPg==}
|
||||||
engines: {node: '>=12'}
|
engines: {node: '>=12'}
|
||||||
cpu: [x64]
|
cpu: [x64]
|
||||||
os: [sunos]
|
os: [sunos]
|
||||||
@@ -1702,8 +1706,8 @@ packages:
|
|||||||
dev: true
|
dev: true
|
||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
/@esbuild/win32-arm64/0.16.17:
|
/@esbuild/win32-arm64/0.17.11:
|
||||||
resolution: {integrity: sha512-ga8+JqBDHY4b6fQAmOgtJJue36scANy4l/rL97W+0wYmijhxKetzZdKOJI7olaBaMhWt8Pac2McJdZLxXWUEQw==}
|
resolution: {integrity: sha512-vtSfyx5yRdpiOW9yp6Ax0zyNOv9HjOAw8WaZg3dF5djEHKKm3UnoohftVvIJtRh0Ec7Hso0RIdTqZvPXJ7FdvQ==}
|
||||||
engines: {node: '>=12'}
|
engines: {node: '>=12'}
|
||||||
cpu: [arm64]
|
cpu: [arm64]
|
||||||
os: [win32]
|
os: [win32]
|
||||||
@@ -1711,8 +1715,8 @@ packages:
|
|||||||
dev: true
|
dev: true
|
||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
/@esbuild/win32-ia32/0.16.17:
|
/@esbuild/win32-ia32/0.17.11:
|
||||||
resolution: {integrity: sha512-WnsKaf46uSSF/sZhwnqE4L/F89AYNMiD4YtEcYekBt9Q7nj0DiId2XH2Ng2PHM54qi5oPrQ8luuzGszqi/veig==}
|
resolution: {integrity: sha512-GFPSLEGQr4wHFTiIUJQrnJKZhZjjq4Sphf+mM76nQR6WkQn73vm7IsacmBRPkALfpOCHsopSvLgqdd4iUW2mYw==}
|
||||||
engines: {node: '>=12'}
|
engines: {node: '>=12'}
|
||||||
cpu: [ia32]
|
cpu: [ia32]
|
||||||
os: [win32]
|
os: [win32]
|
||||||
@@ -1720,8 +1724,8 @@ packages:
|
|||||||
dev: true
|
dev: true
|
||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
/@esbuild/win32-x64/0.16.17:
|
/@esbuild/win32-x64/0.17.11:
|
||||||
resolution: {integrity: sha512-y+EHuSchhL7FjHgvQL/0fnnFmO4T1bhvWANX6gcnqTjtnKWbTvUMCpGnv2+t+31d7RzyEAYAd4u2fnIhHL6N/Q==}
|
resolution: {integrity: sha512-N9vXqLP3eRL8BqSy8yn4Y98cZI2pZ8fyuHx6lKjiG2WABpT2l01TXdzq5Ma2ZUBzfB7tx5dXVhge8X9u0S70ZQ==}
|
||||||
engines: {node: '>=12'}
|
engines: {node: '>=12'}
|
||||||
cpu: [x64]
|
cpu: [x64]
|
||||||
os: [win32]
|
os: [win32]
|
||||||
@@ -2065,6 +2069,12 @@ packages:
|
|||||||
resolution: {integrity: sha512-BdZ5BCCvho3EIXw6wUCXHe7rS53AIDPLE+JzwgT+OsJk53oBfbSmZZ7CX4VaRoN78N+TJpFi9QPlfIVNmJYWxQ==}
|
resolution: {integrity: sha512-BdZ5BCCvho3EIXw6wUCXHe7rS53AIDPLE+JzwgT+OsJk53oBfbSmZZ7CX4VaRoN78N+TJpFi9QPlfIVNmJYWxQ==}
|
||||||
dev: false
|
dev: false
|
||||||
|
|
||||||
|
/@types/markdown-it-link-attributes/3.0.1:
|
||||||
|
resolution: {integrity: sha512-K8RnNb1q8j7rDOJbMF7AnlhCC/45BjrQ8z3WZWOrvkBIl8u9RXvmBdG/hfpnmK1JhhEZcmFEKWt+ilW1Mly+2Q==}
|
||||||
|
dependencies:
|
||||||
|
'@types/markdown-it': 12.2.3
|
||||||
|
dev: true
|
||||||
|
|
||||||
/@types/markdown-it/12.2.3:
|
/@types/markdown-it/12.2.3:
|
||||||
resolution: {integrity: sha512-GKMHFfv3458yYy+v/N8gjufHO6MSZKCOXpZc5GXIWWy8uldwfmPn98vp81gZ5f9SVw8YYBctgfJ22a2d7AOMeQ==}
|
resolution: {integrity: sha512-GKMHFfv3458yYy+v/N8gjufHO6MSZKCOXpZc5GXIWWy8uldwfmPn98vp81gZ5f9SVw8YYBctgfJ22a2d7AOMeQ==}
|
||||||
dependencies:
|
dependencies:
|
||||||
@@ -2246,14 +2256,14 @@ packages:
|
|||||||
eslint-visitor-keys: 3.3.0
|
eslint-visitor-keys: 3.3.0
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
/@vitejs/plugin-vue/4.0.0_vite@4.1.4+vue@3.2.47:
|
/@vitejs/plugin-vue/4.0.0_vite@4.2.0+vue@3.2.47:
|
||||||
resolution: {integrity: sha512-e0X4jErIxAB5oLtDqbHvHpJe/uWNkdpYV83AOG2xo2tEVSzCzewgJMtREZM30wXnM5ls90hxiOtAuVU6H5JgbA==}
|
resolution: {integrity: sha512-e0X4jErIxAB5oLtDqbHvHpJe/uWNkdpYV83AOG2xo2tEVSzCzewgJMtREZM30wXnM5ls90hxiOtAuVU6H5JgbA==}
|
||||||
engines: {node: ^14.18.0 || >=16.0.0}
|
engines: {node: ^14.18.0 || >=16.0.0}
|
||||||
peerDependencies:
|
peerDependencies:
|
||||||
vite: ^4.0.0
|
vite: ^4.0.0
|
||||||
vue: ^3.2.25
|
vue: ^3.2.25
|
||||||
dependencies:
|
dependencies:
|
||||||
vite: 4.1.4_4l5pdn5ozbjpiwj3fcgseihr44
|
vite: 4.2.0_4l5pdn5ozbjpiwj3fcgseihr44
|
||||||
vue: 3.2.47
|
vue: 3.2.47
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
@@ -3317,34 +3327,34 @@ packages:
|
|||||||
is-symbol: 1.0.4
|
is-symbol: 1.0.4
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
/esbuild/0.16.17:
|
/esbuild/0.17.11:
|
||||||
resolution: {integrity: sha512-G8LEkV0XzDMNwXKgM0Jwu3nY3lSTwSGY6XbxM9cr9+s0T/qSV1q1JVPBGzm3dcjhCic9+emZDmMffkwgPeOeLg==}
|
resolution: {integrity: sha512-pAMImyokbWDtnA/ufPxjQg0fYo2DDuzAlqwnDvbXqHLphe+m80eF++perYKVm8LeTuj2zUuFXC+xgSVxyoHUdg==}
|
||||||
engines: {node: '>=12'}
|
engines: {node: '>=12'}
|
||||||
hasBin: true
|
hasBin: true
|
||||||
requiresBuild: true
|
requiresBuild: true
|
||||||
optionalDependencies:
|
optionalDependencies:
|
||||||
'@esbuild/android-arm': 0.16.17
|
'@esbuild/android-arm': 0.17.11
|
||||||
'@esbuild/android-arm64': 0.16.17
|
'@esbuild/android-arm64': 0.17.11
|
||||||
'@esbuild/android-x64': 0.16.17
|
'@esbuild/android-x64': 0.17.11
|
||||||
'@esbuild/darwin-arm64': 0.16.17
|
'@esbuild/darwin-arm64': 0.17.11
|
||||||
'@esbuild/darwin-x64': 0.16.17
|
'@esbuild/darwin-x64': 0.17.11
|
||||||
'@esbuild/freebsd-arm64': 0.16.17
|
'@esbuild/freebsd-arm64': 0.17.11
|
||||||
'@esbuild/freebsd-x64': 0.16.17
|
'@esbuild/freebsd-x64': 0.17.11
|
||||||
'@esbuild/linux-arm': 0.16.17
|
'@esbuild/linux-arm': 0.17.11
|
||||||
'@esbuild/linux-arm64': 0.16.17
|
'@esbuild/linux-arm64': 0.17.11
|
||||||
'@esbuild/linux-ia32': 0.16.17
|
'@esbuild/linux-ia32': 0.17.11
|
||||||
'@esbuild/linux-loong64': 0.16.17
|
'@esbuild/linux-loong64': 0.17.11
|
||||||
'@esbuild/linux-mips64el': 0.16.17
|
'@esbuild/linux-mips64el': 0.17.11
|
||||||
'@esbuild/linux-ppc64': 0.16.17
|
'@esbuild/linux-ppc64': 0.17.11
|
||||||
'@esbuild/linux-riscv64': 0.16.17
|
'@esbuild/linux-riscv64': 0.17.11
|
||||||
'@esbuild/linux-s390x': 0.16.17
|
'@esbuild/linux-s390x': 0.17.11
|
||||||
'@esbuild/linux-x64': 0.16.17
|
'@esbuild/linux-x64': 0.17.11
|
||||||
'@esbuild/netbsd-x64': 0.16.17
|
'@esbuild/netbsd-x64': 0.17.11
|
||||||
'@esbuild/openbsd-x64': 0.16.17
|
'@esbuild/openbsd-x64': 0.17.11
|
||||||
'@esbuild/sunos-x64': 0.16.17
|
'@esbuild/sunos-x64': 0.17.11
|
||||||
'@esbuild/win32-arm64': 0.16.17
|
'@esbuild/win32-arm64': 0.17.11
|
||||||
'@esbuild/win32-ia32': 0.16.17
|
'@esbuild/win32-ia32': 0.17.11
|
||||||
'@esbuild/win32-x64': 0.16.17
|
'@esbuild/win32-x64': 0.17.11
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
/escalade/3.1.1:
|
/escalade/3.1.1:
|
||||||
@@ -3912,7 +3922,7 @@ packages:
|
|||||||
resolution: {integrity: sha512-0rcTq621PD5jM/e0a3EJoGC/1TC5ZBCERW82LQuwfGnCa1V8w7dpYH1yNu+SLb6E5dkeCBzKEyLGlFrnr+dUyw==}
|
resolution: {integrity: sha512-0rcTq621PD5jM/e0a3EJoGC/1TC5ZBCERW82LQuwfGnCa1V8w7dpYH1yNu+SLb6E5dkeCBzKEyLGlFrnr+dUyw==}
|
||||||
engines: {node: '>=14.14'}
|
engines: {node: '>=14.14'}
|
||||||
dependencies:
|
dependencies:
|
||||||
graceful-fs: 4.2.10
|
graceful-fs: 4.2.11
|
||||||
jsonfile: 6.1.0
|
jsonfile: 6.1.0
|
||||||
universalify: 2.0.0
|
universalify: 2.0.0
|
||||||
dev: true
|
dev: true
|
||||||
@@ -3922,7 +3932,7 @@ packages:
|
|||||||
engines: {node: '>=10'}
|
engines: {node: '>=10'}
|
||||||
dependencies:
|
dependencies:
|
||||||
at-least-node: 1.0.0
|
at-least-node: 1.0.0
|
||||||
graceful-fs: 4.2.10
|
graceful-fs: 4.2.11
|
||||||
jsonfile: 6.1.0
|
jsonfile: 6.1.0
|
||||||
universalify: 2.0.0
|
universalify: 2.0.0
|
||||||
dev: true
|
dev: true
|
||||||
@@ -4083,8 +4093,8 @@ packages:
|
|||||||
get-intrinsic: 1.2.0
|
get-intrinsic: 1.2.0
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
/graceful-fs/4.2.10:
|
/graceful-fs/4.2.11:
|
||||||
resolution: {integrity: sha512-9ByhssR2fPVsNZj478qUUbKfmL0+t5BDVyjShtyZZLiK7ZDAArFFfopyOTj0M05wE2tJPisA4iTnnXl2YoPvOA==}
|
resolution: {integrity: sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ==}
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
/grapheme-splitter/1.0.4:
|
/grapheme-splitter/1.0.4:
|
||||||
@@ -4580,7 +4590,7 @@ packages:
|
|||||||
dependencies:
|
dependencies:
|
||||||
universalify: 2.0.0
|
universalify: 2.0.0
|
||||||
optionalDependencies:
|
optionalDependencies:
|
||||||
graceful-fs: 4.2.10
|
graceful-fs: 4.2.11
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
/jsonparse/1.3.1:
|
/jsonparse/1.3.1:
|
||||||
@@ -4615,7 +4625,7 @@ packages:
|
|||||||
tslib: 2.5.0
|
tslib: 2.5.0
|
||||||
optionalDependencies:
|
optionalDependencies:
|
||||||
errno: 0.1.8
|
errno: 0.1.8
|
||||||
graceful-fs: 4.2.10
|
graceful-fs: 4.2.11
|
||||||
image-size: 0.5.5
|
image-size: 0.5.5
|
||||||
make-dir: 2.1.0
|
make-dir: 2.1.0
|
||||||
mime: 1.6.0
|
mime: 1.6.0
|
||||||
@@ -4704,7 +4714,7 @@ packages:
|
|||||||
resolution: {integrity: sha512-Kx8hMakjX03tiGTLAIdJ+lL0htKnXjEZN6hk/tozf/WOuYGdZBJrZ+rCJRbVCugsjB3jMLn9746NsQIf5VjBMw==}
|
resolution: {integrity: sha512-Kx8hMakjX03tiGTLAIdJ+lL0htKnXjEZN6hk/tozf/WOuYGdZBJrZ+rCJRbVCugsjB3jMLn9746NsQIf5VjBMw==}
|
||||||
engines: {node: '>=4'}
|
engines: {node: '>=4'}
|
||||||
dependencies:
|
dependencies:
|
||||||
graceful-fs: 4.2.10
|
graceful-fs: 4.2.11
|
||||||
parse-json: 4.0.0
|
parse-json: 4.0.0
|
||||||
pify: 3.0.0
|
pify: 3.0.0
|
||||||
strip-bom: 3.0.0
|
strip-bom: 3.0.0
|
||||||
@@ -4848,6 +4858,10 @@ packages:
|
|||||||
engines: {node: '>=8'}
|
engines: {node: '>=8'}
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
|
/markdown-it-link-attributes/4.0.1:
|
||||||
|
resolution: {integrity: sha512-pg5OK0jPLg62H4k7M9mRJLT61gUp9nvG0XveKYHMOOluASo9OEF13WlXrpAp2aj35LbedAy3QOCgQCw0tkLKAQ==}
|
||||||
|
dev: true
|
||||||
|
|
||||||
/markdown-it/13.0.1:
|
/markdown-it/13.0.1:
|
||||||
resolution: {integrity: sha512-lTlxriVoy2criHP0JKRhO2VDG9c2ypWCsT237eDiLqi09rmbKoUetyGHq2uOIRoRS//kfoJckS0eUzzkDR+k2Q==}
|
resolution: {integrity: sha512-lTlxriVoy2criHP0JKRhO2VDG9c2ypWCsT237eDiLqi09rmbKoUetyGHq2uOIRoRS//kfoJckS0eUzzkDR+k2Q==}
|
||||||
hasBin: true
|
hasBin: true
|
||||||
@@ -6395,7 +6409,7 @@ packages:
|
|||||||
vue: 3.2.47
|
vue: 3.2.47
|
||||||
dev: false
|
dev: false
|
||||||
|
|
||||||
/vite-plugin-pwa/0.14.4_vite@4.1.4:
|
/vite-plugin-pwa/0.14.4_vite@4.2.0:
|
||||||
resolution: {integrity: sha512-M7Ct0so8OlouMkTWgXnl8W1xU95glITSKIe7qswZf1tniAstO2idElGCnsrTJ5NPNSx1XqfTCOUj8j94S6FD7Q==}
|
resolution: {integrity: sha512-M7Ct0so8OlouMkTWgXnl8W1xU95glITSKIe7qswZf1tniAstO2idElGCnsrTJ5NPNSx1XqfTCOUj8j94S6FD7Q==}
|
||||||
peerDependencies:
|
peerDependencies:
|
||||||
vite: ^3.1.0 || ^4.0.0
|
vite: ^3.1.0 || ^4.0.0
|
||||||
@@ -6405,7 +6419,7 @@ packages:
|
|||||||
fast-glob: 3.2.12
|
fast-glob: 3.2.12
|
||||||
pretty-bytes: 6.1.0
|
pretty-bytes: 6.1.0
|
||||||
rollup: 3.18.0
|
rollup: 3.18.0
|
||||||
vite: 4.1.4_4l5pdn5ozbjpiwj3fcgseihr44
|
vite: 4.2.0_4l5pdn5ozbjpiwj3fcgseihr44
|
||||||
workbox-build: 6.5.4
|
workbox-build: 6.5.4
|
||||||
workbox-window: 6.5.4
|
workbox-window: 6.5.4
|
||||||
transitivePeerDependencies:
|
transitivePeerDependencies:
|
||||||
@@ -6413,8 +6427,8 @@ packages:
|
|||||||
- supports-color
|
- supports-color
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
/vite/4.1.4_4l5pdn5ozbjpiwj3fcgseihr44:
|
/vite/4.2.0_4l5pdn5ozbjpiwj3fcgseihr44:
|
||||||
resolution: {integrity: sha512-3knk/HsbSTKEin43zHu7jTwYWv81f8kgAL99G5NWBcA1LKvtvcVAC4JjBH1arBunO9kQka+1oGbrMKOjk4ZrBg==}
|
resolution: {integrity: sha512-AbDTyzzwuKoRtMIRLGNxhLRuv1FpRgdIw+1y6AQG73Q5+vtecmvzKo/yk8X/vrHDpETRTx01ABijqUHIzBXi0g==}
|
||||||
engines: {node: ^14.18.0 || >=16.0.0}
|
engines: {node: ^14.18.0 || >=16.0.0}
|
||||||
hasBin: true
|
hasBin: true
|
||||||
peerDependencies:
|
peerDependencies:
|
||||||
@@ -6439,7 +6453,7 @@ packages:
|
|||||||
optional: true
|
optional: true
|
||||||
dependencies:
|
dependencies:
|
||||||
'@types/node': 18.14.6
|
'@types/node': 18.14.6
|
||||||
esbuild: 0.16.17
|
esbuild: 0.17.11
|
||||||
less: 4.1.3
|
less: 4.1.3
|
||||||
postcss: 8.4.21
|
postcss: 8.4.21
|
||||||
resolve: 1.22.1
|
resolve: 1.22.1
|
||||||
|
|||||||
@@ -16,6 +16,9 @@ API_REVERSE_PROXY=
|
|||||||
# timeout
|
# timeout
|
||||||
TIMEOUT_MS=100000
|
TIMEOUT_MS=100000
|
||||||
|
|
||||||
|
# Rate Limit
|
||||||
|
MAX_REQUEST_PER_HOUR=
|
||||||
|
|
||||||
# Secret key
|
# Secret key
|
||||||
AUTH_SECRET_KEY=
|
AUTH_SECRET_KEY=
|
||||||
|
|
||||||
@@ -24,3 +27,7 @@ SOCKS_PROXY_HOST=
|
|||||||
|
|
||||||
# Socks Proxy Port
|
# Socks Proxy Port
|
||||||
SOCKS_PROXY_PORT=
|
SOCKS_PROXY_PORT=
|
||||||
|
|
||||||
|
# HTTPS PROXY
|
||||||
|
HTTPS_PROXY=
|
||||||
|
|
||||||
|
|||||||
@@ -11,7 +11,7 @@
|
|||||||
"express"
|
"express"
|
||||||
],
|
],
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": "^16 || ^18"
|
"node": "^16 || ^18 || ^19"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "esno ./src/index.ts",
|
"start": "esno ./src/index.ts",
|
||||||
@@ -24,10 +24,13 @@
|
|||||||
"common:cleanup": "rimraf node_modules && rimraf pnpm-lock.yaml"
|
"common:cleanup": "rimraf node_modules && rimraf pnpm-lock.yaml"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"chatgpt": "^5.0.9",
|
"axios": "^1.3.4",
|
||||||
|
"chatgpt": "^5.1.2",
|
||||||
"dotenv": "^16.0.3",
|
"dotenv": "^16.0.3",
|
||||||
"esno": "^0.16.3",
|
"esno": "^0.16.3",
|
||||||
"express": "^4.18.2",
|
"express": "^4.18.2",
|
||||||
|
"express-rate-limit": "^6.7.0",
|
||||||
|
"https-proxy-agent": "^5.0.1",
|
||||||
"isomorphic-fetch": "^3.0.0",
|
"isomorphic-fetch": "^3.0.0",
|
||||||
"node-fetch": "^3.3.0",
|
"node-fetch": "^3.3.0",
|
||||||
"socks-proxy-agent": "^7.0.0"
|
"socks-proxy-agent": "^7.0.0"
|
||||||
|
|||||||
88
service/pnpm-lock.yaml
generated
88
service/pnpm-lock.yaml
generated
@@ -4,11 +4,14 @@ specifiers:
|
|||||||
'@antfu/eslint-config': ^0.35.3
|
'@antfu/eslint-config': ^0.35.3
|
||||||
'@types/express': ^4.17.17
|
'@types/express': ^4.17.17
|
||||||
'@types/node': ^18.14.6
|
'@types/node': ^18.14.6
|
||||||
chatgpt: ^5.0.9
|
axios: ^1.3.4
|
||||||
|
chatgpt: ^5.1.2
|
||||||
dotenv: ^16.0.3
|
dotenv: ^16.0.3
|
||||||
eslint: ^8.35.0
|
eslint: ^8.35.0
|
||||||
esno: ^0.16.3
|
esno: ^0.16.3
|
||||||
express: ^4.18.2
|
express: ^4.18.2
|
||||||
|
express-rate-limit: ^6.7.0
|
||||||
|
https-proxy-agent: ^5.0.1
|
||||||
isomorphic-fetch: ^3.0.0
|
isomorphic-fetch: ^3.0.0
|
||||||
node-fetch: ^3.3.0
|
node-fetch: ^3.3.0
|
||||||
rimraf: ^4.3.0
|
rimraf: ^4.3.0
|
||||||
@@ -17,10 +20,13 @@ specifiers:
|
|||||||
typescript: ^4.9.5
|
typescript: ^4.9.5
|
||||||
|
|
||||||
dependencies:
|
dependencies:
|
||||||
chatgpt: 5.0.9
|
axios: 1.3.4
|
||||||
|
chatgpt: 5.1.2
|
||||||
dotenv: 16.0.3
|
dotenv: 16.0.3
|
||||||
esno: 0.16.3
|
esno: 0.16.3
|
||||||
express: 4.18.2
|
express: 4.18.2
|
||||||
|
express-rate-limit: 6.7.0_express@4.18.2
|
||||||
|
https-proxy-agent: 5.0.1
|
||||||
isomorphic-fetch: 3.0.0
|
isomorphic-fetch: 3.0.0
|
||||||
node-fetch: 3.3.0
|
node-fetch: 3.3.0
|
||||||
socks-proxy-agent: 7.0.0
|
socks-proxy-agent: 7.0.0
|
||||||
@@ -150,8 +156,8 @@ packages:
|
|||||||
chalk: 2.4.2
|
chalk: 2.4.2
|
||||||
js-tokens: 4.0.0
|
js-tokens: 4.0.0
|
||||||
|
|
||||||
/@dqbd/tiktoken/0.4.0:
|
/@dqbd/tiktoken/1.0.2:
|
||||||
resolution: {integrity: sha512-iaHgmwKAOqowBFZKxelyszoeGLoNw62eOULcmyme1aA1Ymr3JgYl0V7jwpuUm7fksalycZajx3loFn9TRUaviw==}
|
resolution: {integrity: sha512-AjGTBRWsMoVmVeN55NLyupyM8TNamOUBl6tj5t/leLDVup3CFGO9tVagNL1jf3GyZLkWZSTmYVbPQ/M2LEcNzw==}
|
||||||
dev: false
|
dev: false
|
||||||
|
|
||||||
/@esbuild-kit/cjs-loader/2.4.2:
|
/@esbuild-kit/cjs-loader/2.4.2:
|
||||||
@@ -764,6 +770,10 @@ packages:
|
|||||||
es-shim-unscopables: 1.0.0
|
es-shim-unscopables: 1.0.0
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
|
/asynckit/0.4.0:
|
||||||
|
resolution: {integrity: sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==}
|
||||||
|
dev: false
|
||||||
|
|
||||||
/atomically/2.0.1:
|
/atomically/2.0.1:
|
||||||
resolution: {integrity: sha512-sxBhVZUFBFhqSAsYMM3X2oaUi2NVDJ8U026FsIusM8gYXls9AYs/eXzgGrufs1Qjpkxi9zunds+75QUFz+m7UQ==}
|
resolution: {integrity: sha512-sxBhVZUFBFhqSAsYMM3X2oaUi2NVDJ8U026FsIusM8gYXls9AYs/eXzgGrufs1Qjpkxi9zunds+75QUFz+m7UQ==}
|
||||||
dependencies:
|
dependencies:
|
||||||
@@ -776,6 +786,16 @@ packages:
|
|||||||
engines: {node: '>= 0.4'}
|
engines: {node: '>= 0.4'}
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
|
/axios/1.3.4:
|
||||||
|
resolution: {integrity: sha512-toYm+Bsyl6VC5wSkfkbbNB6ROv7KY93PEBBL6xyDczaIHasAiv4wPqQ/c4RjoQzipxRD2W5g21cOqQulZ7rHwQ==}
|
||||||
|
dependencies:
|
||||||
|
follow-redirects: 1.15.2
|
||||||
|
form-data: 4.0.0
|
||||||
|
proxy-from-env: 1.1.0
|
||||||
|
transitivePeerDependencies:
|
||||||
|
- debug
|
||||||
|
dev: false
|
||||||
|
|
||||||
/balanced-match/1.0.2:
|
/balanced-match/1.0.2:
|
||||||
resolution: {integrity: sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==}
|
resolution: {integrity: sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==}
|
||||||
dev: true
|
dev: true
|
||||||
@@ -902,12 +922,12 @@ packages:
|
|||||||
resolution: {integrity: sha512-mKKUkUbhPpQlCOfIuZkvSEgktjPFIsZKRRbC6KWVEMvlzblj3i3asQv5ODsrwt0N3pHAEvjP8KTQPHkp0+6jOg==}
|
resolution: {integrity: sha512-mKKUkUbhPpQlCOfIuZkvSEgktjPFIsZKRRbC6KWVEMvlzblj3i3asQv5ODsrwt0N3pHAEvjP8KTQPHkp0+6jOg==}
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
/chatgpt/5.0.9:
|
/chatgpt/5.1.2:
|
||||||
resolution: {integrity: sha512-H0MMegLKcYyYh3LeFO4ubIdJSiSAl4rRjTeXf3KjHfGXDM7QZ1EkiTH9RuIoaNzOm8rJTn4QEhrwBbOIpbalxw==}
|
resolution: {integrity: sha512-b/NnDQHDOpouK+gmhUCKcKuvnKEh+DotwXlP6Qgw1mqmkcfVl9Wt3/3noT8jbGJpMEpFOfzexXn5Rehpea1N0w==}
|
||||||
engines: {node: '>=14'}
|
engines: {node: '>=14'}
|
||||||
hasBin: true
|
hasBin: true
|
||||||
dependencies:
|
dependencies:
|
||||||
'@dqbd/tiktoken': 0.4.0
|
'@dqbd/tiktoken': 1.0.2
|
||||||
cac: 6.7.14
|
cac: 6.7.14
|
||||||
conf: 11.0.1
|
conf: 11.0.1
|
||||||
eventsource-parser: 0.0.5
|
eventsource-parser: 0.0.5
|
||||||
@@ -964,6 +984,13 @@ packages:
|
|||||||
resolution: {integrity: sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==}
|
resolution: {integrity: sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==}
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
|
/combined-stream/1.0.8:
|
||||||
|
resolution: {integrity: sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==}
|
||||||
|
engines: {node: '>= 0.8'}
|
||||||
|
dependencies:
|
||||||
|
delayed-stream: 1.0.0
|
||||||
|
dev: false
|
||||||
|
|
||||||
/commander/4.1.1:
|
/commander/4.1.1:
|
||||||
resolution: {integrity: sha512-NOKm8xhkzAjzFx8B2v5OAHT+u5pRQc2UCa2Vq9jYL/31o2wi9mxBA7LIFs3sV5VSC49z6pEhfbMULvShKj26WA==}
|
resolution: {integrity: sha512-NOKm8xhkzAjzFx8B2v5OAHT+u5pRQc2UCa2Vq9jYL/31o2wi9mxBA7LIFs3sV5VSC49z6pEhfbMULvShKj26WA==}
|
||||||
engines: {node: '>= 6'}
|
engines: {node: '>= 6'}
|
||||||
@@ -1080,6 +1107,11 @@ packages:
|
|||||||
object-keys: 1.1.1
|
object-keys: 1.1.1
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
|
/delayed-stream/1.0.0:
|
||||||
|
resolution: {integrity: sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==}
|
||||||
|
engines: {node: '>=0.4.0'}
|
||||||
|
dev: false
|
||||||
|
|
||||||
/depd/2.0.0:
|
/depd/2.0.0:
|
||||||
resolution: {integrity: sha512-g7nH6P6dyDioJogAAGprGpCtVImJhpPk/roCzdb3fIh61/s/nPsfR6onyMwkCAR/OlC3yBC0lESvUoQEAssIrw==}
|
resolution: {integrity: sha512-g7nH6P6dyDioJogAAGprGpCtVImJhpPk/roCzdb3fIh61/s/nPsfR6onyMwkCAR/OlC3yBC0lESvUoQEAssIrw==}
|
||||||
engines: {node: '>= 0.8'}
|
engines: {node: '>= 0.8'}
|
||||||
@@ -1710,6 +1742,15 @@ packages:
|
|||||||
strip-final-newline: 2.0.0
|
strip-final-newline: 2.0.0
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
|
/express-rate-limit/6.7.0_express@4.18.2:
|
||||||
|
resolution: {integrity: sha512-vhwIdRoqcYB/72TK3tRZI+0ttS8Ytrk24GfmsxDXK9o9IhHNO5bXRiXQSExPQ4GbaE5tvIS7j1SGrxsuWs+sGA==}
|
||||||
|
engines: {node: '>= 12.9.0'}
|
||||||
|
peerDependencies:
|
||||||
|
express: ^4 || ^5
|
||||||
|
dependencies:
|
||||||
|
express: 4.18.2
|
||||||
|
dev: false
|
||||||
|
|
||||||
/express/4.18.2:
|
/express/4.18.2:
|
||||||
resolution: {integrity: sha512-5/PsL6iGPdfQ/lKM1UuielYgv3BUoJfz1aUwU9vHZ+J7gyvwdQXFEBIEIaxeGf0GIcreATNyBExtalisDbuMqQ==}
|
resolution: {integrity: sha512-5/PsL6iGPdfQ/lKM1UuielYgv3BUoJfz1aUwU9vHZ+J7gyvwdQXFEBIEIaxeGf0GIcreATNyBExtalisDbuMqQ==}
|
||||||
engines: {node: '>= 0.10.0'}
|
engines: {node: '>= 0.10.0'}
|
||||||
@@ -1850,12 +1891,31 @@ packages:
|
|||||||
resolution: {integrity: sha512-5nqDSxl8nn5BSNxyR3n4I6eDmbolI6WT+QqR547RwxQapgjQBmtktdP+HTBb/a/zLsbzERTONyUB5pefh5TtjQ==}
|
resolution: {integrity: sha512-5nqDSxl8nn5BSNxyR3n4I6eDmbolI6WT+QqR547RwxQapgjQBmtktdP+HTBb/a/zLsbzERTONyUB5pefh5TtjQ==}
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
|
/follow-redirects/1.15.2:
|
||||||
|
resolution: {integrity: sha512-VQLG33o04KaQ8uYi2tVNbdrWp1QWxNNea+nmIB4EVM28v0hmP17z7aG1+wAkNzVq4KeXTq3221ye5qTJP91JwA==}
|
||||||
|
engines: {node: '>=4.0'}
|
||||||
|
peerDependencies:
|
||||||
|
debug: '*'
|
||||||
|
peerDependenciesMeta:
|
||||||
|
debug:
|
||||||
|
optional: true
|
||||||
|
dev: false
|
||||||
|
|
||||||
/for-each/0.3.3:
|
/for-each/0.3.3:
|
||||||
resolution: {integrity: sha512-jqYfLp7mo9vIyQf8ykW2v7A+2N4QjeCeI5+Dz9XraiO1ign81wjiH7Fb9vSOWvQfNtmSa4H2RoQTrrXivdUZmw==}
|
resolution: {integrity: sha512-jqYfLp7mo9vIyQf8ykW2v7A+2N4QjeCeI5+Dz9XraiO1ign81wjiH7Fb9vSOWvQfNtmSa4H2RoQTrrXivdUZmw==}
|
||||||
dependencies:
|
dependencies:
|
||||||
is-callable: 1.2.7
|
is-callable: 1.2.7
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
|
/form-data/4.0.0:
|
||||||
|
resolution: {integrity: sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==}
|
||||||
|
engines: {node: '>= 6'}
|
||||||
|
dependencies:
|
||||||
|
asynckit: 0.4.0
|
||||||
|
combined-stream: 1.0.8
|
||||||
|
mime-types: 2.1.35
|
||||||
|
dev: false
|
||||||
|
|
||||||
/formdata-polyfill/4.0.10:
|
/formdata-polyfill/4.0.10:
|
||||||
resolution: {integrity: sha512-buewHzMvYL29jdeQTVILecSaZKnt/RJWjoZCF5OW60Z67/GmSLBkOFM7qh1PI3zFNtJbaZL5eQu1vLfazOwj4g==}
|
resolution: {integrity: sha512-buewHzMvYL29jdeQTVILecSaZKnt/RJWjoZCF5OW60Z67/GmSLBkOFM7qh1PI3zFNtJbaZL5eQu1vLfazOwj4g==}
|
||||||
engines: {node: '>=12.20.0'}
|
engines: {node: '>=12.20.0'}
|
||||||
@@ -2079,6 +2139,16 @@ packages:
|
|||||||
toidentifier: 1.0.1
|
toidentifier: 1.0.1
|
||||||
dev: false
|
dev: false
|
||||||
|
|
||||||
|
/https-proxy-agent/5.0.1:
|
||||||
|
resolution: {integrity: sha512-dFcAjpTQFgoLMzC2VwU+C/CbS7uRL0lWmxDITmqm7C+7F0Odmj6s9l6alZc6AELXhrnggM2CeWSXHGOdX2YtwA==}
|
||||||
|
engines: {node: '>= 6'}
|
||||||
|
dependencies:
|
||||||
|
agent-base: 6.0.2
|
||||||
|
debug: 4.3.4
|
||||||
|
transitivePeerDependencies:
|
||||||
|
- supports-color
|
||||||
|
dev: false
|
||||||
|
|
||||||
/human-signals/2.1.0:
|
/human-signals/2.1.0:
|
||||||
resolution: {integrity: sha512-B4FFZ6q/T2jhhksgkbEW3HBvWIfDW85snkQgawt07S7J5QXTk6BkNV+0yAeZrM5QpMAdYlocGoljn0sJ/WQkFw==}
|
resolution: {integrity: sha512-B4FFZ6q/T2jhhksgkbEW3HBvWIfDW85snkQgawt07S7J5QXTk6BkNV+0yAeZrM5QpMAdYlocGoljn0sJ/WQkFw==}
|
||||||
engines: {node: '>=10.17.0'}
|
engines: {node: '>=10.17.0'}
|
||||||
@@ -2906,6 +2976,10 @@ packages:
|
|||||||
ipaddr.js: 1.9.1
|
ipaddr.js: 1.9.1
|
||||||
dev: false
|
dev: false
|
||||||
|
|
||||||
|
/proxy-from-env/1.1.0:
|
||||||
|
resolution: {integrity: sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==}
|
||||||
|
dev: false
|
||||||
|
|
||||||
/punycode/2.3.0:
|
/punycode/2.3.0:
|
||||||
resolution: {integrity: sha512-rRV+zQD8tVFys26lAGR9WUuS4iUAngJScM+ZRSKtvl5tKeZ2t5bvdNFdNHBW9FWR4guGHlgmsZ1G7BSm2wTbuA==}
|
resolution: {integrity: sha512-rRV+zQD8tVFys26lAGR9WUuS4iUAngJScM+ZRSKtvl5tKeZ2t5bvdNFdNHBW9FWR4guGHlgmsZ1G7BSm2wTbuA==}
|
||||||
engines: {node: '>=6'}
|
engines: {node: '>=6'}
|
||||||
|
|||||||
@@ -3,9 +3,15 @@ import 'isomorphic-fetch'
|
|||||||
import type { ChatGPTAPIOptions, ChatMessage, SendMessageOptions } from 'chatgpt'
|
import type { ChatGPTAPIOptions, ChatMessage, SendMessageOptions } from 'chatgpt'
|
||||||
import { ChatGPTAPI, ChatGPTUnofficialProxyAPI } from 'chatgpt'
|
import { ChatGPTAPI, ChatGPTUnofficialProxyAPI } from 'chatgpt'
|
||||||
import { SocksProxyAgent } from 'socks-proxy-agent'
|
import { SocksProxyAgent } from 'socks-proxy-agent'
|
||||||
|
import { HttpsProxyAgent } from 'https-proxy-agent'
|
||||||
import fetch from 'node-fetch'
|
import fetch from 'node-fetch'
|
||||||
|
import axios from 'axios'
|
||||||
import { sendResponse } from '../utils'
|
import { sendResponse } from '../utils'
|
||||||
|
import { isNotEmptyString } from '../utils/is'
|
||||||
import type { ApiModel, ChatContext, ChatGPTUnofficialProxyAPIOptions, ModelConfig } from '../types'
|
import type { ApiModel, ChatContext, ChatGPTUnofficialProxyAPIOptions, ModelConfig } from '../types'
|
||||||
|
import type { RequestOptions } from './types'
|
||||||
|
|
||||||
|
dotenv.config()
|
||||||
|
|
||||||
const ErrorCodeMessage: Record<string, string> = {
|
const ErrorCodeMessage: Record<string, string> = {
|
||||||
401: '[OpenAI] 提供错误的API密钥 | Incorrect API key provided',
|
401: '[OpenAI] 提供错误的API密钥 | Incorrect API key provided',
|
||||||
@@ -16,13 +22,11 @@ const ErrorCodeMessage: Record<string, string> = {
|
|||||||
500: '[OpenAI] 服务器繁忙,请稍后再试 | Internal Server Error',
|
500: '[OpenAI] 服务器繁忙,请稍后再试 | Internal Server Error',
|
||||||
}
|
}
|
||||||
|
|
||||||
dotenv.config()
|
|
||||||
|
|
||||||
const timeoutMs: number = !isNaN(+process.env.TIMEOUT_MS) ? +process.env.TIMEOUT_MS : 30 * 1000
|
const timeoutMs: number = !isNaN(+process.env.TIMEOUT_MS) ? +process.env.TIMEOUT_MS : 30 * 1000
|
||||||
|
|
||||||
let apiModel: ApiModel
|
let apiModel: ApiModel
|
||||||
|
|
||||||
if (!process.env.OPENAI_API_KEY && !process.env.OPENAI_ACCESS_TOKEN)
|
if (!isNotEmptyString(process.env.OPENAI_API_KEY) && !isNotEmptyString(process.env.OPENAI_ACCESS_TOKEN))
|
||||||
throw new Error('Missing OPENAI_API_KEY or OPENAI_ACCESS_TOKEN environment variable')
|
throw new Error('Missing OPENAI_API_KEY or OPENAI_ACCESS_TOKEN environment variable')
|
||||||
|
|
||||||
let api: ChatGPTAPI | ChatGPTUnofficialProxyAPI
|
let api: ChatGPTAPI | ChatGPTUnofficialProxyAPI
|
||||||
@@ -30,72 +34,70 @@ let api: ChatGPTAPI | ChatGPTUnofficialProxyAPI
|
|||||||
(async () => {
|
(async () => {
|
||||||
// More Info: https://github.com/transitive-bullshit/chatgpt-api
|
// More Info: https://github.com/transitive-bullshit/chatgpt-api
|
||||||
|
|
||||||
if (process.env.OPENAI_API_KEY) {
|
if (isNotEmptyString(process.env.OPENAI_API_KEY)) {
|
||||||
|
const OPENAI_API_BASE_URL = process.env.OPENAI_API_BASE_URL
|
||||||
const OPENAI_API_MODEL = process.env.OPENAI_API_MODEL
|
const OPENAI_API_MODEL = process.env.OPENAI_API_MODEL
|
||||||
const model = (typeof OPENAI_API_MODEL === 'string' && OPENAI_API_MODEL.length > 0)
|
const model = isNotEmptyString(OPENAI_API_MODEL) ? OPENAI_API_MODEL : 'gpt-3.5-turbo'
|
||||||
? OPENAI_API_MODEL
|
|
||||||
: 'gpt-3.5-turbo'
|
|
||||||
|
|
||||||
const options: ChatGPTAPIOptions = {
|
const options: ChatGPTAPIOptions = {
|
||||||
apiKey: process.env.OPENAI_API_KEY,
|
apiKey: process.env.OPENAI_API_KEY,
|
||||||
completionParams: { model },
|
completionParams: { model },
|
||||||
debug: false,
|
debug: true,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (process.env.OPENAI_API_BASE_URL && process.env.OPENAI_API_BASE_URL.trim().length > 0)
|
// increase max token limit if use gpt-4
|
||||||
options.apiBaseUrl = process.env.OPENAI_API_BASE_URL
|
if (model.toLowerCase().includes('gpt-4')) {
|
||||||
|
// if use 32k model
|
||||||
if (process.env.SOCKS_PROXY_HOST && process.env.SOCKS_PROXY_PORT) {
|
if (model.toLowerCase().includes('32k')) {
|
||||||
const agent = new SocksProxyAgent({
|
options.maxModelTokens = 32768
|
||||||
hostname: process.env.SOCKS_PROXY_HOST,
|
options.maxResponseTokens = 8192
|
||||||
port: process.env.SOCKS_PROXY_PORT,
|
}
|
||||||
})
|
else {
|
||||||
options.fetch = (url, options) => {
|
options.maxModelTokens = 8192
|
||||||
return fetch(url, { agent, ...options })
|
options.maxResponseTokens = 2048
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isNotEmptyString(OPENAI_API_BASE_URL))
|
||||||
|
options.apiBaseUrl = `${OPENAI_API_BASE_URL}/v1`
|
||||||
|
|
||||||
|
setupProxy(options)
|
||||||
|
|
||||||
api = new ChatGPTAPI({ ...options })
|
api = new ChatGPTAPI({ ...options })
|
||||||
apiModel = 'ChatGPTAPI'
|
apiModel = 'ChatGPTAPI'
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
const OPENAI_API_MODEL = process.env.OPENAI_API_MODEL
|
||||||
const options: ChatGPTUnofficialProxyAPIOptions = {
|
const options: ChatGPTUnofficialProxyAPIOptions = {
|
||||||
accessToken: process.env.OPENAI_ACCESS_TOKEN,
|
accessToken: process.env.OPENAI_ACCESS_TOKEN,
|
||||||
debug: false,
|
debug: true,
|
||||||
}
|
}
|
||||||
|
if (isNotEmptyString(OPENAI_API_MODEL))
|
||||||
|
options.model = OPENAI_API_MODEL
|
||||||
|
|
||||||
if (process.env.SOCKS_PROXY_HOST && process.env.SOCKS_PROXY_PORT) {
|
if (isNotEmptyString(process.env.API_REVERSE_PROXY))
|
||||||
const agent = new SocksProxyAgent({
|
|
||||||
hostname: process.env.SOCKS_PROXY_HOST,
|
|
||||||
port: process.env.SOCKS_PROXY_PORT,
|
|
||||||
})
|
|
||||||
options.fetch = (url, options) => {
|
|
||||||
return fetch(url, { agent, ...options })
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (process.env.API_REVERSE_PROXY)
|
|
||||||
options.apiReverseProxyUrl = process.env.API_REVERSE_PROXY
|
options.apiReverseProxyUrl = process.env.API_REVERSE_PROXY
|
||||||
|
|
||||||
|
setupProxy(options)
|
||||||
|
|
||||||
api = new ChatGPTUnofficialProxyAPI({ ...options })
|
api = new ChatGPTUnofficialProxyAPI({ ...options })
|
||||||
apiModel = 'ChatGPTUnofficialProxyAPI'
|
apiModel = 'ChatGPTUnofficialProxyAPI'
|
||||||
}
|
}
|
||||||
})()
|
})()
|
||||||
|
|
||||||
async function chatReplyProcess(
|
async function chatReplyProcess(options: RequestOptions) {
|
||||||
message: string,
|
const { message, lastContext, process, systemMessage } = options
|
||||||
lastContext?: { conversationId?: string; parentMessageId?: string },
|
|
||||||
process?: (chat: ChatMessage) => void,
|
|
||||||
) {
|
|
||||||
// if (!message)
|
|
||||||
// return sendResponse({ type: 'Fail', message: 'Message is empty' })
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
let options: SendMessageOptions = { timeoutMs }
|
let options: SendMessageOptions = { timeoutMs }
|
||||||
|
|
||||||
if (lastContext) {
|
if (apiModel === 'ChatGPTAPI') {
|
||||||
|
if (isNotEmptyString(systemMessage))
|
||||||
|
options.systemMessage = systemMessage
|
||||||
|
}
|
||||||
|
|
||||||
|
if (lastContext != null) {
|
||||||
if (apiModel === 'ChatGPTAPI')
|
if (apiModel === 'ChatGPTAPI')
|
||||||
options = { parentMessageId: lastContext.parentMessageId }
|
options.parentMessageId = lastContext.parentMessageId
|
||||||
else
|
else
|
||||||
options = { ...lastContext }
|
options = { ...lastContext }
|
||||||
}
|
}
|
||||||
@@ -118,18 +120,68 @@ async function chatReplyProcess(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function fetchBalance() {
|
||||||
|
const OPENAI_API_KEY = process.env.OPENAI_API_KEY
|
||||||
|
const OPENAI_API_BASE_URL = process.env.OPENAI_API_BASE_URL
|
||||||
|
|
||||||
|
if (!isNotEmptyString(OPENAI_API_KEY))
|
||||||
|
return Promise.resolve('-')
|
||||||
|
|
||||||
|
const API_BASE_URL = isNotEmptyString(OPENAI_API_BASE_URL)
|
||||||
|
? OPENAI_API_BASE_URL
|
||||||
|
: 'https://api.openai.com'
|
||||||
|
|
||||||
|
try {
|
||||||
|
const headers = { 'Content-Type': 'application/json', 'Authorization': `Bearer ${OPENAI_API_KEY}` }
|
||||||
|
const response = await axios.get(`${API_BASE_URL}/dashboard/billing/credit_grants`, { headers })
|
||||||
|
const balance = response.data.total_available ?? 0
|
||||||
|
return Promise.resolve(balance.toFixed(3))
|
||||||
|
}
|
||||||
|
catch {
|
||||||
|
return Promise.resolve('-')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async function chatConfig() {
|
async function chatConfig() {
|
||||||
return sendResponse({
|
const balance = await fetchBalance()
|
||||||
|
const reverseProxy = process.env.API_REVERSE_PROXY ?? '-'
|
||||||
|
const httpsProxy = (process.env.HTTPS_PROXY || process.env.ALL_PROXY) ?? '-'
|
||||||
|
const socksProxy = (process.env.SOCKS_PROXY_HOST && process.env.SOCKS_PROXY_PORT)
|
||||||
|
? (`${process.env.SOCKS_PROXY_HOST}:${process.env.SOCKS_PROXY_PORT}`)
|
||||||
|
: '-'
|
||||||
|
return sendResponse<ModelConfig>({
|
||||||
type: 'Success',
|
type: 'Success',
|
||||||
data: {
|
data: { apiModel, reverseProxy, timeoutMs, socksProxy, httpsProxy, balance },
|
||||||
apiModel,
|
|
||||||
reverseProxy: process.env.API_REVERSE_PROXY,
|
|
||||||
timeoutMs,
|
|
||||||
socksProxy: (process.env.SOCKS_PROXY_HOST && process.env.SOCKS_PROXY_PORT) ? (`${process.env.SOCKS_PROXY_HOST}:${process.env.SOCKS_PROXY_PORT}`) : '-',
|
|
||||||
} as ModelConfig,
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function setupProxy(options: ChatGPTAPIOptions | ChatGPTUnofficialProxyAPIOptions) {
|
||||||
|
if (process.env.SOCKS_PROXY_HOST && process.env.SOCKS_PROXY_PORT) {
|
||||||
|
const agent = new SocksProxyAgent({
|
||||||
|
hostname: process.env.SOCKS_PROXY_HOST,
|
||||||
|
port: process.env.SOCKS_PROXY_PORT,
|
||||||
|
})
|
||||||
|
options.fetch = (url, options) => {
|
||||||
|
return fetch(url, { agent, ...options })
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (process.env.HTTPS_PROXY || process.env.ALL_PROXY) {
|
||||||
|
const httpsProxy = process.env.HTTPS_PROXY || process.env.ALL_PROXY
|
||||||
|
if (httpsProxy) {
|
||||||
|
const agent = new HttpsProxyAgent(httpsProxy)
|
||||||
|
options.fetch = (url, options) => {
|
||||||
|
return fetch(url, { agent, ...options })
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function currentModel(): ApiModel {
|
||||||
|
return apiModel
|
||||||
|
}
|
||||||
|
|
||||||
export type { ChatContext, ChatMessage }
|
export type { ChatContext, ChatMessage }
|
||||||
|
|
||||||
export { chatReplyProcess, chatConfig }
|
export { chatReplyProcess, chatConfig, currentModel }
|
||||||
|
|||||||
8
service/src/chatgpt/types.ts
Normal file
8
service/src/chatgpt/types.ts
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
import type { ChatMessage } from 'chatgpt'
|
||||||
|
|
||||||
|
export interface RequestOptions {
|
||||||
|
message: string
|
||||||
|
lastContext?: { conversationId?: string; parentMessageId?: string }
|
||||||
|
process?: (chat: ChatMessage) => void
|
||||||
|
systemMessage?: string
|
||||||
|
}
|
||||||
@@ -1,7 +1,10 @@
|
|||||||
import express from 'express'
|
import express from 'express'
|
||||||
import type { ChatContext, ChatMessage } from './chatgpt'
|
import type { RequestProps } from './types'
|
||||||
import { chatConfig, chatReplyProcess } from './chatgpt'
|
import type { ChatMessage } from './chatgpt'
|
||||||
|
import { chatConfig, chatReplyProcess, currentModel } from './chatgpt'
|
||||||
import { auth } from './middleware/auth'
|
import { auth } from './middleware/auth'
|
||||||
|
import { limiter } from './middleware/limiter'
|
||||||
|
import { isNotEmptyString } from './utils/is'
|
||||||
|
|
||||||
const app = express()
|
const app = express()
|
||||||
const router = express.Router()
|
const router = express.Router()
|
||||||
@@ -11,20 +14,25 @@ app.use(express.json())
|
|||||||
|
|
||||||
app.all('*', (_, res, next) => {
|
app.all('*', (_, res, next) => {
|
||||||
res.header('Access-Control-Allow-Origin', '*')
|
res.header('Access-Control-Allow-Origin', '*')
|
||||||
res.header('Access-Control-Allow-Headers', 'Content-Type')
|
res.header('Access-Control-Allow-Headers', 'authorization, Content-Type')
|
||||||
res.header('Access-Control-Allow-Methods', '*')
|
res.header('Access-Control-Allow-Methods', '*')
|
||||||
next()
|
next()
|
||||||
})
|
})
|
||||||
|
|
||||||
router.post('/chat-process', auth, async (req, res) => {
|
router.post('/chat-process', [auth, limiter], async (req, res) => {
|
||||||
res.setHeader('Content-type', 'application/octet-stream')
|
res.setHeader('Content-type', 'application/octet-stream')
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const { prompt, options = {} } = req.body as { prompt: string; options?: ChatContext }
|
const { prompt, options = {}, systemMessage } = req.body as RequestProps
|
||||||
let firstChunk = true
|
let firstChunk = true
|
||||||
await chatReplyProcess(prompt, options, (chat: ChatMessage) => {
|
await chatReplyProcess({
|
||||||
res.write(firstChunk ? JSON.stringify(chat) : `\n${JSON.stringify(chat)}`)
|
message: prompt,
|
||||||
firstChunk = false
|
lastContext: options,
|
||||||
|
process: (chat: ChatMessage) => {
|
||||||
|
res.write(firstChunk ? JSON.stringify(chat) : `\n${JSON.stringify(chat)}`)
|
||||||
|
firstChunk = false
|
||||||
|
},
|
||||||
|
systemMessage,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
catch (error) {
|
catch (error) {
|
||||||
@@ -35,7 +43,7 @@ router.post('/chat-process', auth, async (req, res) => {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
router.post('/config', async (req, res) => {
|
router.post('/config', auth, async (req, res) => {
|
||||||
try {
|
try {
|
||||||
const response = await chatConfig()
|
const response = await chatConfig()
|
||||||
res.send(response)
|
res.send(response)
|
||||||
@@ -48,8 +56,8 @@ router.post('/config', async (req, res) => {
|
|||||||
router.post('/session', async (req, res) => {
|
router.post('/session', async (req, res) => {
|
||||||
try {
|
try {
|
||||||
const AUTH_SECRET_KEY = process.env.AUTH_SECRET_KEY
|
const AUTH_SECRET_KEY = process.env.AUTH_SECRET_KEY
|
||||||
const hasAuth = typeof AUTH_SECRET_KEY === 'string' && AUTH_SECRET_KEY.length > 0
|
const hasAuth = isNotEmptyString(AUTH_SECRET_KEY)
|
||||||
res.send({ status: 'Success', message: '', data: { auth: hasAuth } })
|
res.send({ status: 'Success', message: '', data: { auth: hasAuth, model: currentModel() } })
|
||||||
}
|
}
|
||||||
catch (error) {
|
catch (error) {
|
||||||
res.send({ status: 'Fail', message: error.message, data: null })
|
res.send({ status: 'Fail', message: error.message, data: null })
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
|
import { isNotEmptyString } from '../utils/is'
|
||||||
|
|
||||||
const auth = async (req, res, next) => {
|
const auth = async (req, res, next) => {
|
||||||
const AUTH_SECRET_KEY = process.env.AUTH_SECRET_KEY
|
const AUTH_SECRET_KEY = process.env.AUTH_SECRET_KEY
|
||||||
if (typeof AUTH_SECRET_KEY === 'string' && AUTH_SECRET_KEY.length > 0) {
|
if (isNotEmptyString(AUTH_SECRET_KEY)) {
|
||||||
try {
|
try {
|
||||||
const Authorization = req.header('Authorization')
|
const Authorization = req.header('Authorization')
|
||||||
if (!Authorization || Authorization.replace('Bearer ', '').trim() !== AUTH_SECRET_KEY.trim())
|
if (!Authorization || Authorization.replace('Bearer ', '').trim() !== AUTH_SECRET_KEY.trim())
|
||||||
|
|||||||
19
service/src/middleware/limiter.ts
Normal file
19
service/src/middleware/limiter.ts
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
import { rateLimit } from 'express-rate-limit'
|
||||||
|
import { isNotEmptyString } from '../utils/is'
|
||||||
|
|
||||||
|
const MAX_REQUEST_PER_HOUR = process.env.MAX_REQUEST_PER_HOUR
|
||||||
|
|
||||||
|
const maxCount = (isNotEmptyString(MAX_REQUEST_PER_HOUR) && !isNaN(Number(MAX_REQUEST_PER_HOUR)))
|
||||||
|
? parseInt(MAX_REQUEST_PER_HOUR)
|
||||||
|
: 0 // 0 means unlimited
|
||||||
|
|
||||||
|
const limiter = rateLimit({
|
||||||
|
windowMs: 60 * 60 * 1000, // Maximum number of accesses within an hour
|
||||||
|
max: maxCount,
|
||||||
|
statusCode: 200, // 200 means success,but the message is 'Too many request from this IP in 1 hour'
|
||||||
|
message: async (req, res) => {
|
||||||
|
res.send({ status: 'Fail', message: 'Too many request from this IP in 1 hour', data: null })
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
export { limiter }
|
||||||
@@ -1,5 +1,11 @@
|
|||||||
import type { FetchFn } from 'chatgpt'
|
import type { FetchFn } from 'chatgpt'
|
||||||
|
|
||||||
|
export interface RequestProps {
|
||||||
|
prompt: string
|
||||||
|
options?: ChatContext
|
||||||
|
systemMessage: string
|
||||||
|
}
|
||||||
|
|
||||||
export interface ChatContext {
|
export interface ChatContext {
|
||||||
conversationId?: string
|
conversationId?: string
|
||||||
parentMessageId?: string
|
parentMessageId?: string
|
||||||
@@ -19,6 +25,8 @@ export interface ModelConfig {
|
|||||||
reverseProxy?: string
|
reverseProxy?: string
|
||||||
timeoutMs?: number
|
timeoutMs?: number
|
||||||
socksProxy?: string
|
socksProxy?: string
|
||||||
|
httpsProxy?: string
|
||||||
|
balance?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
export type ApiModel = 'ChatGPTAPI' | 'ChatGPTUnofficialProxyAPI' | undefined
|
export type ApiModel = 'ChatGPTAPI' | 'ChatGPTUnofficialProxyAPI' | undefined
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
interface SendResponseOptions {
|
interface SendResponseOptions<T = any> {
|
||||||
type: 'Success' | 'Fail'
|
type: 'Success' | 'Fail'
|
||||||
message?: string
|
message?: string
|
||||||
data?: any
|
data?: T
|
||||||
}
|
}
|
||||||
|
|
||||||
export function sendResponse(options: SendResponseOptions) {
|
export function sendResponse<T>(options: SendResponseOptions<T>) {
|
||||||
if (options.type === 'Success') {
|
if (options.type === 'Success') {
|
||||||
return Promise.resolve({
|
return Promise.resolve({
|
||||||
message: options.message ?? null,
|
message: options.message ?? null,
|
||||||
|
|||||||
19
service/src/utils/is.ts
Normal file
19
service/src/utils/is.ts
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
export function isNumber<T extends number>(value: T | unknown): value is number {
|
||||||
|
return Object.prototype.toString.call(value) === '[object Number]'
|
||||||
|
}
|
||||||
|
|
||||||
|
export function isString<T extends string>(value: T | unknown): value is string {
|
||||||
|
return Object.prototype.toString.call(value) === '[object String]'
|
||||||
|
}
|
||||||
|
|
||||||
|
export function isNotEmptyString(value: any): boolean {
|
||||||
|
return typeof value === 'string' && value.length > 0
|
||||||
|
}
|
||||||
|
|
||||||
|
export function isBoolean<T extends boolean>(value: T | unknown): value is boolean {
|
||||||
|
return Object.prototype.toString.call(value) === '[object Boolean]'
|
||||||
|
}
|
||||||
|
|
||||||
|
export function isFunction<T extends (...args: any[]) => any | void | never>(value: T | unknown): value is T {
|
||||||
|
return Object.prototype.toString.call(value) === '[object Function]'
|
||||||
|
}
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
import type { AxiosProgressEvent, GenericAbortSignal } from 'axios'
|
import type { AxiosProgressEvent, GenericAbortSignal } from 'axios'
|
||||||
import { post } from '@/utils/request'
|
import { post } from '@/utils/request'
|
||||||
|
import { useSettingStore } from '@/store'
|
||||||
|
|
||||||
export function fetchChatAPI<T = any>(
|
export function fetchChatAPI<T = any>(
|
||||||
prompt: string,
|
prompt: string,
|
||||||
@@ -26,9 +27,11 @@ export function fetchChatAPIProcess<T = any>(
|
|||||||
signal?: GenericAbortSignal
|
signal?: GenericAbortSignal
|
||||||
onDownloadProgress?: (progressEvent: AxiosProgressEvent) => void },
|
onDownloadProgress?: (progressEvent: AxiosProgressEvent) => void },
|
||||||
) {
|
) {
|
||||||
|
const settingStore = useSettingStore()
|
||||||
|
|
||||||
return post<T>({
|
return post<T>({
|
||||||
url: '/chat-process',
|
url: '/chat-process',
|
||||||
data: { prompt: params.prompt, options: params.options },
|
data: { prompt: params.prompt, options: params.options, systemMessage: settingStore.systemMessage },
|
||||||
signal: params.signal,
|
signal: params.signal,
|
||||||
onDownloadProgress: params.onDownloadProgress,
|
onDownloadProgress: params.onDownloadProgress,
|
||||||
})
|
})
|
||||||
|
|||||||
14
src/assets/recommend.json
Normal file
14
src/assets/recommend.json
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
[
|
||||||
|
{
|
||||||
|
"key": "awesome-chatgpt-prompts-zh",
|
||||||
|
"desc": "ChatGPT 中文调教指南",
|
||||||
|
"downloadUrl": "https://raw.githubusercontent.com/PlexPt/awesome-chatgpt-prompts-zh/main/prompts-zh.json",
|
||||||
|
"url": "https://github.com/PlexPt/awesome-chatgpt-prompts-zh"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "awesome-chatgpt-prompts-zh-TW",
|
||||||
|
"desc": "ChatGPT 中文調教指南 (透過 OpenAI / OpenCC 協助,從簡體中文轉換為繁體中文的版本)",
|
||||||
|
"downloadUrl": "https://raw.githubusercontent.com/PlexPt/awesome-chatgpt-prompts-zh/main/prompts-zh-TW.json",
|
||||||
|
"url": "https://github.com/PlexPt/awesome-chatgpt-prompts-zh"
|
||||||
|
}
|
||||||
|
]
|
||||||
478
src/components/common/PromptStore/index.vue
Normal file
478
src/components/common/PromptStore/index.vue
Normal file
@@ -0,0 +1,478 @@
|
|||||||
|
<script setup lang='ts'>
|
||||||
|
import type { DataTableColumns } from 'naive-ui'
|
||||||
|
import { computed, h, ref, watch } from 'vue'
|
||||||
|
import { NButton, NCard, NDataTable, NDivider, NInput, NList, NListItem, NModal, NPopconfirm, NSpace, NTabPane, NTabs, NThing, useMessage } from 'naive-ui'
|
||||||
|
import PromptRecommend from '../../../assets/recommend.json'
|
||||||
|
import { SvgIcon } from '..'
|
||||||
|
import { usePromptStore } from '@/store'
|
||||||
|
import { useBasicLayout } from '@/hooks/useBasicLayout'
|
||||||
|
import { t } from '@/locales'
|
||||||
|
|
||||||
|
interface DataProps {
|
||||||
|
renderKey: string
|
||||||
|
renderValue: string
|
||||||
|
key: string
|
||||||
|
value: string
|
||||||
|
}
|
||||||
|
|
||||||
|
interface Props {
|
||||||
|
visible: boolean
|
||||||
|
}
|
||||||
|
|
||||||
|
interface Emit {
|
||||||
|
(e: 'update:visible', visible: boolean): void
|
||||||
|
}
|
||||||
|
|
||||||
|
const props = defineProps<Props>()
|
||||||
|
|
||||||
|
const emit = defineEmits<Emit>()
|
||||||
|
|
||||||
|
const message = useMessage()
|
||||||
|
|
||||||
|
const show = computed({
|
||||||
|
get: () => props.visible,
|
||||||
|
set: (visible: boolean) => emit('update:visible', visible),
|
||||||
|
})
|
||||||
|
|
||||||
|
const showModal = ref(false)
|
||||||
|
|
||||||
|
const importLoading = ref(false)
|
||||||
|
const exportLoading = ref(false)
|
||||||
|
|
||||||
|
const searchValue = ref<string>('')
|
||||||
|
|
||||||
|
// 移动端自适应相关
|
||||||
|
const { isMobile } = useBasicLayout()
|
||||||
|
|
||||||
|
const promptStore = usePromptStore()
|
||||||
|
|
||||||
|
// Prompt在线导入推荐List,根据部署者喜好进行修改(assets/recommend.json)
|
||||||
|
const promptRecommendList = PromptRecommend
|
||||||
|
const promptList = ref<any>(promptStore.promptList)
|
||||||
|
|
||||||
|
// 用于添加修改的临时prompt参数
|
||||||
|
const tempPromptKey = ref('')
|
||||||
|
const tempPromptValue = ref('')
|
||||||
|
|
||||||
|
// Modal模式,根据不同模式渲染不同的Modal内容
|
||||||
|
const modalMode = ref('')
|
||||||
|
|
||||||
|
// 这个是为了后期的修改Prompt内容考虑,因为要针对无uuid的list进行修改,且考虑到不能出现标题和内容的冲突,所以就需要一个临时item来记录一下
|
||||||
|
const tempModifiedItem = ref<any>({})
|
||||||
|
|
||||||
|
// 添加修改导入都使用一个Modal, 临时修改内容占用tempPromptKey,切换状态前先将内容都清楚
|
||||||
|
const changeShowModal = (mode: 'add' | 'modify' | 'local_import', selected = { key: '', value: '' }) => {
|
||||||
|
if (mode === 'add') {
|
||||||
|
tempPromptKey.value = ''
|
||||||
|
tempPromptValue.value = ''
|
||||||
|
}
|
||||||
|
else if (mode === 'modify') {
|
||||||
|
tempModifiedItem.value = { ...selected }
|
||||||
|
tempPromptKey.value = selected.key
|
||||||
|
tempPromptValue.value = selected.value
|
||||||
|
}
|
||||||
|
else if (mode === 'local_import') {
|
||||||
|
tempPromptKey.value = 'local_import'
|
||||||
|
tempPromptValue.value = ''
|
||||||
|
}
|
||||||
|
showModal.value = !showModal.value
|
||||||
|
modalMode.value = mode
|
||||||
|
}
|
||||||
|
|
||||||
|
// 在线导入相关
|
||||||
|
const downloadURL = ref('')
|
||||||
|
const downloadDisabled = computed(() => downloadURL.value.trim().length < 1)
|
||||||
|
const setDownloadURL = (url: string) => {
|
||||||
|
downloadURL.value = url
|
||||||
|
}
|
||||||
|
|
||||||
|
// 控制 input 按钮
|
||||||
|
const inputStatus = computed (() => tempPromptKey.value.trim().length < 1 || tempPromptValue.value.trim().length < 1)
|
||||||
|
|
||||||
|
// Prompt模板相关操作
|
||||||
|
const addPromptTemplate = () => {
|
||||||
|
for (const i of promptList.value) {
|
||||||
|
if (i.key === tempPromptKey.value) {
|
||||||
|
message.error(t('store.addRepeatTitleTips'))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if (i.value === tempPromptValue.value) {
|
||||||
|
message.error(t('store.addRepeatContentTips', { msg: tempPromptKey.value }))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
promptList.value.unshift({ key: tempPromptKey.value, value: tempPromptValue.value } as never)
|
||||||
|
message.success(t('common.addSuccess'))
|
||||||
|
changeShowModal('add')
|
||||||
|
}
|
||||||
|
|
||||||
|
const modifyPromptTemplate = () => {
|
||||||
|
let index = 0
|
||||||
|
|
||||||
|
// 通过临时索引把待修改项摘出来
|
||||||
|
for (const i of promptList.value) {
|
||||||
|
if (i.key === tempModifiedItem.value.key && i.value === tempModifiedItem.value.value)
|
||||||
|
break
|
||||||
|
index = index + 1
|
||||||
|
}
|
||||||
|
|
||||||
|
const tempList = promptList.value.filter((_: any, i: number) => i !== index)
|
||||||
|
|
||||||
|
// 搜索有冲突的部分
|
||||||
|
for (const i of tempList) {
|
||||||
|
if (i.key === tempPromptKey.value) {
|
||||||
|
message.error(t('store.editRepeatTitleTips'))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if (i.value === tempPromptValue.value) {
|
||||||
|
message.error(t('store.editRepeatContentTips', { msg: i.key }))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
promptList.value = [{ key: tempPromptKey.value, value: tempPromptValue.value }, ...tempList] as never
|
||||||
|
message.success(t('common.editSuccess'))
|
||||||
|
changeShowModal('modify')
|
||||||
|
}
|
||||||
|
|
||||||
|
const deletePromptTemplate = (row: { key: string; value: string }) => {
|
||||||
|
promptList.value = [
|
||||||
|
...promptList.value.filter((item: { key: string; value: string }) => item.key !== row.key),
|
||||||
|
] as never
|
||||||
|
message.success(t('common.deleteSuccess'))
|
||||||
|
}
|
||||||
|
|
||||||
|
const clearPromptTemplate = () => {
|
||||||
|
promptList.value = []
|
||||||
|
message.success(t('common.clearSuccess'))
|
||||||
|
}
|
||||||
|
|
||||||
|
const importPromptTemplate = () => {
|
||||||
|
try {
|
||||||
|
const jsonData = JSON.parse(tempPromptValue.value)
|
||||||
|
let key = ''
|
||||||
|
let value = ''
|
||||||
|
// 可以扩展加入更多模板字典的key
|
||||||
|
if ('key' in jsonData[0]) {
|
||||||
|
key = 'key'
|
||||||
|
value = 'value'
|
||||||
|
}
|
||||||
|
else if ('act' in jsonData[0]) {
|
||||||
|
key = 'act'
|
||||||
|
value = 'prompt'
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// 不支持的字典的key防止导入 以免破坏prompt商店打开
|
||||||
|
message.warning('prompt key not supported.')
|
||||||
|
throw new Error('prompt key not supported.')
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const i of jsonData) {
|
||||||
|
if (!('key' in i) || !('value' in i))
|
||||||
|
throw new Error(t('store.importError'))
|
||||||
|
let safe = true
|
||||||
|
for (const j of promptList.value) {
|
||||||
|
if (j.key === i[key]) {
|
||||||
|
message.warning(t('store.importRepeatTitle', { msg: i[key] }))
|
||||||
|
safe = false
|
||||||
|
break
|
||||||
|
}
|
||||||
|
if (j.value === i[value]) {
|
||||||
|
message.warning(t('store.importRepeatContent', { msg: i[key] }))
|
||||||
|
safe = false
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (safe)
|
||||||
|
promptList.value.unshift({ key: i[key], value: i[value] } as never)
|
||||||
|
}
|
||||||
|
message.success(t('common.importSuccess'))
|
||||||
|
}
|
||||||
|
catch {
|
||||||
|
message.error('JSON 格式错误,请检查 JSON 格式')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 模板导出
|
||||||
|
const exportPromptTemplate = () => {
|
||||||
|
exportLoading.value = true
|
||||||
|
const jsonDataStr = JSON.stringify(promptList.value)
|
||||||
|
const blob = new Blob([jsonDataStr], { type: 'application/json' })
|
||||||
|
const url = URL.createObjectURL(blob)
|
||||||
|
const link = document.createElement('a')
|
||||||
|
link.href = url
|
||||||
|
link.download = 'ChatGPTPromptTemplate.json'
|
||||||
|
link.click()
|
||||||
|
URL.revokeObjectURL(url)
|
||||||
|
exportLoading.value = false
|
||||||
|
}
|
||||||
|
|
||||||
|
// 模板在线导入
|
||||||
|
const downloadPromptTemplate = async () => {
|
||||||
|
try {
|
||||||
|
importLoading.value = true
|
||||||
|
const response = await fetch(downloadURL.value)
|
||||||
|
const jsonData = await response.json()
|
||||||
|
if ('key' in jsonData[0] && 'value' in jsonData[0])
|
||||||
|
tempPromptValue.value = JSON.stringify(jsonData)
|
||||||
|
if ('act' in jsonData[0] && 'prompt' in jsonData[0]) {
|
||||||
|
const newJsonData = jsonData.map((item: { act: string; prompt: string }) => {
|
||||||
|
return {
|
||||||
|
key: item.act,
|
||||||
|
value: item.prompt,
|
||||||
|
}
|
||||||
|
})
|
||||||
|
tempPromptValue.value = JSON.stringify(newJsonData)
|
||||||
|
}
|
||||||
|
importPromptTemplate()
|
||||||
|
downloadURL.value = ''
|
||||||
|
}
|
||||||
|
catch {
|
||||||
|
message.error(t('store.downloadError'))
|
||||||
|
downloadURL.value = ''
|
||||||
|
}
|
||||||
|
finally {
|
||||||
|
importLoading.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 移动端自适应相关
|
||||||
|
const renderTemplate = () => {
|
||||||
|
const [keyLimit, valueLimit] = isMobile.value ? [10, 30] : [15, 50]
|
||||||
|
|
||||||
|
return promptList.value.map((item: { key: string; value: string }) => {
|
||||||
|
return {
|
||||||
|
renderKey: item.key.length <= keyLimit ? item.key : `${item.key.substring(0, keyLimit)}...`,
|
||||||
|
renderValue: item.value.length <= valueLimit ? item.value : `${item.value.substring(0, valueLimit)}...`,
|
||||||
|
key: item.key,
|
||||||
|
value: item.value,
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
const pagination = computed(() => {
|
||||||
|
const [pageSize, pageSlot] = isMobile.value ? [6, 5] : [7, 15]
|
||||||
|
return {
|
||||||
|
pageSize, pageSlot,
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
// table相关
|
||||||
|
const createColumns = (): DataTableColumns<DataProps> => {
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
title: t('store.title'),
|
||||||
|
key: 'renderKey',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: t('store.description'),
|
||||||
|
key: 'renderValue',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: t('common.action'),
|
||||||
|
key: 'actions',
|
||||||
|
width: 100,
|
||||||
|
align: 'center',
|
||||||
|
render(row) {
|
||||||
|
return h('div', { class: 'flex items-center flex-col gap-2' }, {
|
||||||
|
default: () => [h(
|
||||||
|
NButton,
|
||||||
|
{
|
||||||
|
tertiary: true,
|
||||||
|
size: 'small',
|
||||||
|
type: 'info',
|
||||||
|
onClick: () => changeShowModal('modify', row),
|
||||||
|
},
|
||||||
|
{ default: () => t('common.edit') },
|
||||||
|
),
|
||||||
|
h(
|
||||||
|
NButton,
|
||||||
|
{
|
||||||
|
tertiary: true,
|
||||||
|
size: 'small',
|
||||||
|
type: 'error',
|
||||||
|
onClick: () => deletePromptTemplate(row),
|
||||||
|
},
|
||||||
|
{ default: () => t('common.delete') },
|
||||||
|
),
|
||||||
|
],
|
||||||
|
})
|
||||||
|
},
|
||||||
|
},
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
const columns = createColumns()
|
||||||
|
|
||||||
|
watch(
|
||||||
|
() => promptList,
|
||||||
|
() => {
|
||||||
|
promptStore.updatePromptList(promptList.value)
|
||||||
|
},
|
||||||
|
{ deep: true },
|
||||||
|
)
|
||||||
|
|
||||||
|
const dataSource = computed(() => {
|
||||||
|
const data = renderTemplate()
|
||||||
|
const value = searchValue.value
|
||||||
|
if (value && value !== '') {
|
||||||
|
return data.filter((item: DataProps) => {
|
||||||
|
return item.renderKey.includes(value) || item.renderValue.includes(value)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
return data
|
||||||
|
})
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<NModal v-model:show="show" style="width: 90%; max-width: 900px;" preset="card">
|
||||||
|
<div class="space-y-4">
|
||||||
|
<NTabs type="segment">
|
||||||
|
<NTabPane name="local" :tab="$t('store.local')">
|
||||||
|
<div
|
||||||
|
class="flex gap-3 mb-4"
|
||||||
|
:class="[isMobile ? 'flex-col' : 'flex-row justify-between']"
|
||||||
|
>
|
||||||
|
<div class="flex items-center space-x-4">
|
||||||
|
<NButton
|
||||||
|
type="primary"
|
||||||
|
size="small"
|
||||||
|
@click="changeShowModal('add')"
|
||||||
|
>
|
||||||
|
{{ $t('common.add') }}
|
||||||
|
</NButton>
|
||||||
|
<NButton
|
||||||
|
size="small"
|
||||||
|
@click="changeShowModal('local_import')"
|
||||||
|
>
|
||||||
|
{{ $t('common.import') }}
|
||||||
|
</NButton>
|
||||||
|
<NButton
|
||||||
|
size="small"
|
||||||
|
:loading="exportLoading"
|
||||||
|
@click="exportPromptTemplate()"
|
||||||
|
>
|
||||||
|
{{ $t('common.export') }}
|
||||||
|
</NButton>
|
||||||
|
<NPopconfirm @positive-click="clearPromptTemplate">
|
||||||
|
<template #trigger>
|
||||||
|
<NButton size="small">
|
||||||
|
{{ $t('common.clear') }}
|
||||||
|
</NButton>
|
||||||
|
</template>
|
||||||
|
{{ $t('store.clearStoreConfirm') }}
|
||||||
|
</NPopconfirm>
|
||||||
|
</div>
|
||||||
|
<div class="flex items-center">
|
||||||
|
<NInput v-model:value="searchValue" style="width: 100%" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<NDataTable
|
||||||
|
v-if="!isMobile"
|
||||||
|
:max-height="400"
|
||||||
|
:columns="columns"
|
||||||
|
:data="dataSource"
|
||||||
|
:pagination="pagination"
|
||||||
|
:bordered="false"
|
||||||
|
/>
|
||||||
|
<NList v-if="isMobile" style="max-height: 400px; overflow-y: auto;">
|
||||||
|
<NListItem v-for="(item, index) of dataSource" :key="index">
|
||||||
|
<NThing :title="item.renderKey" :description="item.renderValue" />
|
||||||
|
<template #suffix>
|
||||||
|
<div class="flex flex-col items-center gap-2">
|
||||||
|
<NButton tertiary size="small" type="info" @click="changeShowModal('modify', item)">
|
||||||
|
{{ t('common.edit') }}
|
||||||
|
</NButton>
|
||||||
|
<NButton tertiary size="small" type="error" @click="deletePromptTemplate(item)">
|
||||||
|
{{ t('common.delete') }}
|
||||||
|
</NButton>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
</NListItem>
|
||||||
|
</NList>
|
||||||
|
</NTabPane>
|
||||||
|
<NTabPane name="download" :tab="$t('store.online')">
|
||||||
|
<p class="mb-4">
|
||||||
|
{{ $t('store.onlineImportWarning') }}
|
||||||
|
</p>
|
||||||
|
<div class="flex items-center gap-4">
|
||||||
|
<NInput v-model:value="downloadURL" placeholder="" />
|
||||||
|
<NButton
|
||||||
|
strong
|
||||||
|
secondary
|
||||||
|
:disabled="downloadDisabled"
|
||||||
|
:loading="importLoading"
|
||||||
|
@click="downloadPromptTemplate()"
|
||||||
|
>
|
||||||
|
{{ $t('common.download') }}
|
||||||
|
</NButton>
|
||||||
|
</div>
|
||||||
|
<NDivider />
|
||||||
|
<div class="max-h-[360px] overflow-y-auto space-y-4">
|
||||||
|
<NCard
|
||||||
|
v-for="info in promptRecommendList"
|
||||||
|
:key="info.key" :title="info.key"
|
||||||
|
:bordered="true"
|
||||||
|
embedded
|
||||||
|
>
|
||||||
|
<p
|
||||||
|
class="overflow-hidden text-ellipsis whitespace-nowrap"
|
||||||
|
:title="info.desc"
|
||||||
|
>
|
||||||
|
{{ info.desc }}
|
||||||
|
</p>
|
||||||
|
<template #footer>
|
||||||
|
<div class="flex items-center justify-end space-x-4">
|
||||||
|
<NButton text>
|
||||||
|
<a
|
||||||
|
:href="info.url"
|
||||||
|
target="_blank"
|
||||||
|
>
|
||||||
|
<SvgIcon class="text-xl" icon="ri:link" />
|
||||||
|
</a>
|
||||||
|
</NButton>
|
||||||
|
<NButton text @click="setDownloadURL(info.downloadUrl) ">
|
||||||
|
<SvgIcon class="text-xl" icon="ri:add-fill" />
|
||||||
|
</NButton>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
</NCard>
|
||||||
|
</div>
|
||||||
|
</NTabPane>
|
||||||
|
</NTabs>
|
||||||
|
</div>
|
||||||
|
</NModal>
|
||||||
|
|
||||||
|
<NModal v-model:show="showModal" style="width: 90%; max-width: 600px;" preset="card">
|
||||||
|
<NSpace v-if="modalMode === 'add' || modalMode === 'modify'" vertical>
|
||||||
|
{{ t('store.title') }}
|
||||||
|
<NInput v-model:value="tempPromptKey" />
|
||||||
|
{{ t('store.description') }}
|
||||||
|
<NInput v-model:value="tempPromptValue" type="textarea" />
|
||||||
|
<NButton
|
||||||
|
block
|
||||||
|
type="primary"
|
||||||
|
:disabled="inputStatus"
|
||||||
|
@click="() => { modalMode === 'add' ? addPromptTemplate() : modifyPromptTemplate() }"
|
||||||
|
>
|
||||||
|
{{ t('common.confirm') }}
|
||||||
|
</NButton>
|
||||||
|
</NSpace>
|
||||||
|
<NSpace v-if="modalMode === 'local_import'" vertical>
|
||||||
|
<NInput
|
||||||
|
v-model:value="tempPromptValue"
|
||||||
|
:placeholder="t('store.importPlaceholder')"
|
||||||
|
:autosize="{ minRows: 3, maxRows: 15 }"
|
||||||
|
type="textarea"
|
||||||
|
/>
|
||||||
|
<NButton
|
||||||
|
block
|
||||||
|
type="primary"
|
||||||
|
:disabled="inputStatus"
|
||||||
|
@click="() => { importPromptTemplate() }"
|
||||||
|
>
|
||||||
|
{{ t('common.import') }}
|
||||||
|
</NButton>
|
||||||
|
</NSpace>
|
||||||
|
</NModal>
|
||||||
|
</template>
|
||||||
@@ -1,20 +1,27 @@
|
|||||||
<script setup lang='ts'>
|
<script setup lang='ts'>
|
||||||
import { onMounted, ref } from 'vue'
|
import { computed, onMounted, ref } from 'vue'
|
||||||
import { NSpin } from 'naive-ui'
|
import { NSpin } from 'naive-ui'
|
||||||
import { fetchChatConfig } from '@/api'
|
import { fetchChatConfig } from '@/api'
|
||||||
import pkg from '@/../package.json'
|
import pkg from '@/../package.json'
|
||||||
|
import { useAuthStore } from '@/store'
|
||||||
|
|
||||||
interface ConfigState {
|
interface ConfigState {
|
||||||
timeoutMs?: number
|
timeoutMs?: number
|
||||||
reverseProxy?: string
|
reverseProxy?: string
|
||||||
apiModel?: string
|
apiModel?: string
|
||||||
socksProxy?: string
|
socksProxy?: string
|
||||||
|
httpsProxy?: string
|
||||||
|
balance?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const authStore = useAuthStore()
|
||||||
|
|
||||||
const loading = ref(false)
|
const loading = ref(false)
|
||||||
|
|
||||||
const config = ref<ConfigState>()
|
const config = ref<ConfigState>()
|
||||||
|
|
||||||
|
const isChatGPTAPI = computed<boolean>(() => !!authStore.isChatGPTAPI)
|
||||||
|
|
||||||
async function fetchConfig() {
|
async function fetchConfig() {
|
||||||
try {
|
try {
|
||||||
loading.value = true
|
loading.value = true
|
||||||
@@ -54,9 +61,15 @@ onMounted(() => {
|
|||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<p>{{ $t("setting.api") }}:{{ config?.apiModel ?? '-' }}</p>
|
<p>{{ $t("setting.api") }}:{{ config?.apiModel ?? '-' }}</p>
|
||||||
<p>{{ $t("setting.reverseProxy") }}:{{ config?.reverseProxy ?? '-' }}</p>
|
<p v-if="isChatGPTAPI">
|
||||||
|
{{ $t("setting.balance") }}:{{ config?.balance ?? '-' }}
|
||||||
|
</p>
|
||||||
|
<p v-if="!isChatGPTAPI">
|
||||||
|
{{ $t("setting.reverseProxy") }}:{{ config?.reverseProxy ?? '-' }}
|
||||||
|
</p>
|
||||||
<p>{{ $t("setting.timeout") }}:{{ config?.timeoutMs ?? '-' }}</p>
|
<p>{{ $t("setting.timeout") }}:{{ config?.timeoutMs ?? '-' }}</p>
|
||||||
<p>{{ $t("setting.socks") }}:{{ config?.socksProxy ?? '-' }}</p>
|
<p>{{ $t("setting.socks") }}:{{ config?.socksProxy ?? '-' }}</p>
|
||||||
|
<p>{{ $t("setting.httpsProxy") }}:{{ config?.httpsProxy ?? '-' }}</p>
|
||||||
</div>
|
</div>
|
||||||
</NSpin>
|
</NSpin>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
46
src/components/common/Setting/Advanced.vue
Normal file
46
src/components/common/Setting/Advanced.vue
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
<script lang="ts" setup>
|
||||||
|
import { ref } from 'vue'
|
||||||
|
import { NButton, NInput, useMessage } from 'naive-ui'
|
||||||
|
import { useSettingStore } from '@/store'
|
||||||
|
import type { SettingsState } from '@/store/modules/settings/helper'
|
||||||
|
import { t } from '@/locales'
|
||||||
|
|
||||||
|
const settingStore = useSettingStore()
|
||||||
|
|
||||||
|
const ms = useMessage()
|
||||||
|
|
||||||
|
const systemMessage = ref(settingStore.systemMessage ?? '')
|
||||||
|
|
||||||
|
function updateSettings(options: Partial<SettingsState>) {
|
||||||
|
settingStore.updateSetting(options)
|
||||||
|
ms.success(t('common.success'))
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleReset() {
|
||||||
|
settingStore.resetSetting()
|
||||||
|
ms.success(t('common.success'))
|
||||||
|
window.location.reload()
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<div class="p-4 space-y-5 min-h-[200px]">
|
||||||
|
<div class="space-y-6">
|
||||||
|
<div class="flex items-center space-x-4">
|
||||||
|
<span class="flex-shrink-0 w-[100px]">{{ $t('setting.role') }}</span>
|
||||||
|
<div class="flex-1">
|
||||||
|
<NInput v-model:value="systemMessage" placeholder="" />
|
||||||
|
</div>
|
||||||
|
<NButton size="tiny" text type="primary" @click="updateSettings({ systemMessage })">
|
||||||
|
{{ $t('common.save') }}
|
||||||
|
</NButton>
|
||||||
|
</div>
|
||||||
|
<div class="flex items-center space-x-4">
|
||||||
|
<span class="flex-shrink-0 w-[100px]"> </span>
|
||||||
|
<NButton size="small" @click="handleReset">
|
||||||
|
{{ $t('common.reset') }}
|
||||||
|
</NButton>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
@@ -1,16 +1,19 @@
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { computed, ref } from 'vue'
|
import { computed, ref } from 'vue'
|
||||||
import { NButton, NInput, NPopconfirm, useMessage } from 'naive-ui'
|
import { NButton, NInput, NPopconfirm, NSelect, useMessage } from 'naive-ui'
|
||||||
import type { Language, Theme } from '@/store/modules/app/helper'
|
import type { Language, Theme } from '@/store/modules/app/helper'
|
||||||
import { SvgIcon } from '@/components/common'
|
import { SvgIcon } from '@/components/common'
|
||||||
import { useAppStore, useUserStore } from '@/store'
|
import { useAppStore, useUserStore } from '@/store'
|
||||||
import type { UserInfo } from '@/store/modules/user/helper'
|
import type { UserInfo } from '@/store/modules/user/helper'
|
||||||
import { getCurrentDate } from '@/utils/functions'
|
import { getCurrentDate } from '@/utils/functions'
|
||||||
|
import { useBasicLayout } from '@/hooks/useBasicLayout'
|
||||||
import { t } from '@/locales'
|
import { t } from '@/locales'
|
||||||
|
|
||||||
const appStore = useAppStore()
|
const appStore = useAppStore()
|
||||||
const userStore = useUserStore()
|
const userStore = useUserStore()
|
||||||
|
|
||||||
|
const { isMobile } = useBasicLayout()
|
||||||
|
|
||||||
const ms = useMessage()
|
const ms = useMessage()
|
||||||
|
|
||||||
const theme = computed(() => appStore.theme)
|
const theme = computed(() => appStore.theme)
|
||||||
@@ -147,8 +150,10 @@ function handleImportButtonClick(): void {
|
|||||||
{{ $t('common.save') }}
|
{{ $t('common.save') }}
|
||||||
</NButton>
|
</NButton>
|
||||||
</div>
|
</div>
|
||||||
|
<div
|
||||||
<div class="flex items-center space-x-4">
|
class="flex items-center space-x-4"
|
||||||
|
:class="isMobile && 'items-start'"
|
||||||
|
>
|
||||||
<span class="flex-shrink-0 w-[100px]">{{ $t('setting.chatHistory') }}</span>
|
<span class="flex-shrink-0 w-[100px]">{{ $t('setting.chatHistory') }}</span>
|
||||||
|
|
||||||
<div class="flex flex-wrap items-center gap-4">
|
<div class="flex flex-wrap items-center gap-4">
|
||||||
@@ -199,15 +204,12 @@ function handleImportButtonClick(): void {
|
|||||||
<div class="flex items-center space-x-4">
|
<div class="flex items-center space-x-4">
|
||||||
<span class="flex-shrink-0 w-[100px]">{{ $t('setting.language') }}</span>
|
<span class="flex-shrink-0 w-[100px]">{{ $t('setting.language') }}</span>
|
||||||
<div class="flex flex-wrap items-center gap-4">
|
<div class="flex flex-wrap items-center gap-4">
|
||||||
<template v-for="item of languageOptions" :key="item.key">
|
<NSelect
|
||||||
<NButton
|
style="width: 140px"
|
||||||
size="small"
|
:value="language"
|
||||||
:type="item.key === language ? 'primary' : undefined"
|
:options="languageOptions"
|
||||||
@click="appStore.setLanguage(item.key)"
|
@update-value="value => appStore.setLanguage(value)"
|
||||||
>
|
/>
|
||||||
{{ item.label }}
|
|
||||||
</NButton>
|
|
||||||
</template>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="flex items-center space-x-4">
|
<div class="flex items-center space-x-4">
|
||||||
|
|||||||
@@ -1,14 +1,12 @@
|
|||||||
<script setup lang='ts'>
|
<script setup lang='ts'>
|
||||||
import { computed, ref } from 'vue'
|
import { computed, ref } from 'vue'
|
||||||
import { NCard, NModal, NTabPane, NTabs } from 'naive-ui'
|
import { NModal, NTabPane, NTabs } from 'naive-ui'
|
||||||
import General from './General.vue'
|
import General from './General.vue'
|
||||||
|
import Advanced from './Advanced.vue'
|
||||||
import About from './About.vue'
|
import About from './About.vue'
|
||||||
|
import { useAuthStore } from '@/store'
|
||||||
import { SvgIcon } from '@/components/common'
|
import { SvgIcon } from '@/components/common'
|
||||||
|
|
||||||
const props = defineProps<Props>()
|
|
||||||
|
|
||||||
const emit = defineEmits<Emit>()
|
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
visible: boolean
|
visible: boolean
|
||||||
}
|
}
|
||||||
@@ -17,6 +15,14 @@ interface Emit {
|
|||||||
(e: 'update:visible', visible: boolean): void
|
(e: 'update:visible', visible: boolean): void
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const props = defineProps<Props>()
|
||||||
|
|
||||||
|
const emit = defineEmits<Emit>()
|
||||||
|
|
||||||
|
const authStore = useAuthStore()
|
||||||
|
|
||||||
|
const isChatGPTAPI = computed<boolean>(() => !!authStore.isChatGPTAPI)
|
||||||
|
|
||||||
const active = ref('General')
|
const active = ref('General')
|
||||||
|
|
||||||
const show = computed({
|
const show = computed({
|
||||||
@@ -30,8 +36,8 @@ const show = computed({
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<NModal v-model:show="show" :auto-focus="false">
|
<NModal v-model:show="show" :auto-focus="false" preset="card" style="width: 95%; max-width: 640px">
|
||||||
<NCard role="dialog" aria-modal="true" :bordered="false" style="width: 95%; max-width: 640px">
|
<div>
|
||||||
<NTabs v-model:value="active" type="line" animated>
|
<NTabs v-model:value="active" type="line" animated>
|
||||||
<NTabPane name="General" tab="General">
|
<NTabPane name="General" tab="General">
|
||||||
<template #tab>
|
<template #tab>
|
||||||
@@ -42,6 +48,15 @@ const show = computed({
|
|||||||
<General />
|
<General />
|
||||||
</div>
|
</div>
|
||||||
</NTabPane>
|
</NTabPane>
|
||||||
|
<NTabPane v-if="isChatGPTAPI" name="Advanced" tab="Advanced">
|
||||||
|
<template #tab>
|
||||||
|
<SvgIcon class="text-lg" icon="ri:equalizer-line" />
|
||||||
|
<span class="ml-2">{{ $t('setting.advanced') }}</span>
|
||||||
|
</template>
|
||||||
|
<div class="min-h-[100px]">
|
||||||
|
<Advanced />
|
||||||
|
</div>
|
||||||
|
</NTabPane>
|
||||||
<NTabPane name="Config" tab="Config">
|
<NTabPane name="Config" tab="Config">
|
||||||
<template #tab>
|
<template #tab>
|
||||||
<SvgIcon class="text-lg" icon="ri:list-settings-line" />
|
<SvgIcon class="text-lg" icon="ri:list-settings-line" />
|
||||||
@@ -50,6 +65,6 @@ const show = computed({
|
|||||||
<About />
|
<About />
|
||||||
</NTabPane>
|
</NTabPane>
|
||||||
</NTabs>
|
</NTabs>
|
||||||
</NCard>
|
</div>
|
||||||
</NModal>
|
</NModal>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@@ -3,5 +3,6 @@ import NaiveProvider from './NaiveProvider/index.vue'
|
|||||||
import SvgIcon from './SvgIcon/index.vue'
|
import SvgIcon from './SvgIcon/index.vue'
|
||||||
import UserAvatar from './UserAvatar/index.vue'
|
import UserAvatar from './UserAvatar/index.vue'
|
||||||
import Setting from './Setting/index.vue'
|
import Setting from './Setting/index.vue'
|
||||||
|
import PromptStore from './PromptStore/index.vue'
|
||||||
|
|
||||||
export { HoverButton, NaiveProvider, SvgIcon, UserAvatar, Setting }
|
export { HoverButton, NaiveProvider, SvgIcon, UserAvatar, Setting, PromptStore }
|
||||||
|
|||||||
@@ -1,13 +1,25 @@
|
|||||||
export default {
|
export default {
|
||||||
common: {
|
common: {
|
||||||
|
add: 'Add',
|
||||||
|
addSuccess: 'Add Success',
|
||||||
|
edit: 'Edit',
|
||||||
|
editSuccess: 'Edit Success',
|
||||||
delete: 'Delete',
|
delete: 'Delete',
|
||||||
|
deleteSuccess: 'Delete Success',
|
||||||
save: 'Save',
|
save: 'Save',
|
||||||
|
saveSuccess: 'Save Success',
|
||||||
reset: 'Reset',
|
reset: 'Reset',
|
||||||
|
action: 'Action',
|
||||||
export: 'Export',
|
export: 'Export',
|
||||||
|
exportSuccess: 'Export Success',
|
||||||
import: 'Import',
|
import: 'Import',
|
||||||
|
importSuccess: 'Import Success',
|
||||||
clear: 'Clear',
|
clear: 'Clear',
|
||||||
|
clearSuccess: 'Clear Success',
|
||||||
yes: 'Yes',
|
yes: 'Yes',
|
||||||
no: 'No',
|
no: 'No',
|
||||||
|
confirm: 'Confirm',
|
||||||
|
download: 'Download',
|
||||||
noData: 'No Data',
|
noData: 'No Data',
|
||||||
wrong: 'Something went wrong, please try again later.',
|
wrong: 'Something went wrong, please try again later.',
|
||||||
success: 'Success',
|
success: 'Success',
|
||||||
@@ -34,14 +46,18 @@ export default {
|
|||||||
deleteMessageConfirm: 'Are you sure to delete this message?',
|
deleteMessageConfirm: 'Are you sure to delete this message?',
|
||||||
deleteHistoryConfirm: 'Are you sure to clear this history?',
|
deleteHistoryConfirm: 'Are you sure to clear this history?',
|
||||||
clearHistoryConfirm: 'Are you sure to clear chat history?',
|
clearHistoryConfirm: 'Are you sure to clear chat history?',
|
||||||
|
preview: 'Preview',
|
||||||
|
showRawText: 'Show as raw text',
|
||||||
},
|
},
|
||||||
setting: {
|
setting: {
|
||||||
setting: 'Setting',
|
setting: 'Setting',
|
||||||
general: 'General',
|
general: 'General',
|
||||||
|
advanced: 'Advanced',
|
||||||
config: 'Config',
|
config: 'Config',
|
||||||
avatarLink: 'Avatar Link',
|
avatarLink: 'Avatar Link',
|
||||||
name: 'Name',
|
name: 'Name',
|
||||||
description: 'Description',
|
description: 'Description',
|
||||||
|
role: 'Role',
|
||||||
resetUserInfo: 'Reset UserInfo',
|
resetUserInfo: 'Reset UserInfo',
|
||||||
chatHistory: 'ChatHistory',
|
chatHistory: 'ChatHistory',
|
||||||
theme: 'Theme',
|
theme: 'Theme',
|
||||||
@@ -50,6 +66,24 @@ export default {
|
|||||||
reverseProxy: 'Reverse Proxy',
|
reverseProxy: 'Reverse Proxy',
|
||||||
timeout: 'Timeout',
|
timeout: 'Timeout',
|
||||||
socks: 'Socks',
|
socks: 'Socks',
|
||||||
|
httpsProxy: 'HTTPS Proxy',
|
||||||
|
balance: 'API Balance',
|
||||||
|
},
|
||||||
|
store: {
|
||||||
|
local: 'Local',
|
||||||
|
online: 'Online',
|
||||||
|
title: 'Title',
|
||||||
|
description: 'Description',
|
||||||
|
clearStoreConfirm: 'Whether to clear the data?',
|
||||||
|
importPlaceholder: 'Please paste the JSON data here',
|
||||||
|
addRepeatTitleTips: 'Title duplicate, please re-enter',
|
||||||
|
addRepeatContentTips: 'Content duplicate: {msg}, please re-enter',
|
||||||
|
editRepeatTitleTips: 'Title conflict, please revise',
|
||||||
|
editRepeatContentTips: 'Content conflict {msg} , please re-modify',
|
||||||
|
importError: 'Key value mismatch',
|
||||||
|
importRepeatTitle: 'Title repeatedly skipped: {msg}',
|
||||||
|
importRepeatContent: 'Content is repeatedly skipped: {msg}',
|
||||||
|
onlineImportWarning: 'Note: Please check the JSON file source!',
|
||||||
|
downloadError: 'Please check the network status and JSON file validity',
|
||||||
},
|
},
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,9 +21,7 @@ const i18n = createI18n({
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
export function t(key: string) {
|
export const t = i18n.global.t
|
||||||
return i18n.global.t(key)
|
|
||||||
}
|
|
||||||
|
|
||||||
export function setLocale(locale: Language) {
|
export function setLocale(locale: Language) {
|
||||||
i18n.global.locale = locale
|
i18n.global.locale = locale
|
||||||
|
|||||||
@@ -1,13 +1,25 @@
|
|||||||
export default {
|
export default {
|
||||||
common: {
|
common: {
|
||||||
|
add: '添加',
|
||||||
|
addSuccess: '添加成功',
|
||||||
|
edit: '编辑',
|
||||||
|
editSuccess: '编辑成功',
|
||||||
delete: '删除',
|
delete: '删除',
|
||||||
|
deleteSuccess: '删除成功',
|
||||||
save: '保存',
|
save: '保存',
|
||||||
|
saveSuccess: '保存成功',
|
||||||
reset: '重置',
|
reset: '重置',
|
||||||
|
action: '操作',
|
||||||
export: '导出',
|
export: '导出',
|
||||||
|
exportSuccess: '导出成功',
|
||||||
import: '导入',
|
import: '导入',
|
||||||
|
importSuccess: '导入成功',
|
||||||
clear: '清空',
|
clear: '清空',
|
||||||
|
clearSuccess: '清空成功',
|
||||||
yes: '是',
|
yes: '是',
|
||||||
no: '否',
|
no: '否',
|
||||||
|
confirm: '确定',
|
||||||
|
download: '下载',
|
||||||
noData: '暂无数据',
|
noData: '暂无数据',
|
||||||
wrong: '好像出错了,请稍后再试。',
|
wrong: '好像出错了,请稍后再试。',
|
||||||
success: '操作成功',
|
success: '操作成功',
|
||||||
@@ -34,14 +46,18 @@ export default {
|
|||||||
deleteMessageConfirm: '是否删除此消息?',
|
deleteMessageConfirm: '是否删除此消息?',
|
||||||
deleteHistoryConfirm: '确定删除此记录?',
|
deleteHistoryConfirm: '确定删除此记录?',
|
||||||
clearHistoryConfirm: '确定清空聊天记录?',
|
clearHistoryConfirm: '确定清空聊天记录?',
|
||||||
|
preview: '预览',
|
||||||
|
showRawText: '显示原文',
|
||||||
},
|
},
|
||||||
setting: {
|
setting: {
|
||||||
setting: '设置',
|
setting: '设置',
|
||||||
general: '总览',
|
general: '总览',
|
||||||
|
advanced: '高级',
|
||||||
config: '配置',
|
config: '配置',
|
||||||
avatarLink: '头像链接',
|
avatarLink: '头像链接',
|
||||||
name: '名称',
|
name: '名称',
|
||||||
description: '描述',
|
description: '描述',
|
||||||
|
role: '角色设定',
|
||||||
resetUserInfo: '重置用户信息',
|
resetUserInfo: '重置用户信息',
|
||||||
chatHistory: '聊天记录',
|
chatHistory: '聊天记录',
|
||||||
theme: '主题',
|
theme: '主题',
|
||||||
@@ -50,6 +66,24 @@ export default {
|
|||||||
reverseProxy: '反向代理',
|
reverseProxy: '反向代理',
|
||||||
timeout: '超时',
|
timeout: '超时',
|
||||||
socks: 'Socks',
|
socks: 'Socks',
|
||||||
|
httpsProxy: 'HTTPS Proxy',
|
||||||
|
balance: 'API余额',
|
||||||
|
},
|
||||||
|
store: {
|
||||||
|
local: '本地',
|
||||||
|
online: '在线',
|
||||||
|
title: '标题',
|
||||||
|
description: '描述',
|
||||||
|
clearStoreConfirm: '是否清空数据?',
|
||||||
|
importPlaceholder: '请粘贴 JSON 数据到此处',
|
||||||
|
addRepeatTitleTips: '标题重复,请重新输入',
|
||||||
|
addRepeatContentTips: '内容重复:{msg},请重新输入',
|
||||||
|
editRepeatTitleTips: '标题冲突,请重新修改',
|
||||||
|
editRepeatContentTips: '内容冲突{msg} ,请重新修改',
|
||||||
|
importError: '键值不匹配',
|
||||||
|
importRepeatTitle: '标题重复跳过:{msg}',
|
||||||
|
importRepeatContent: '内容重复跳过:{msg}',
|
||||||
|
onlineImportWarning: '注意:请检查 JSON 文件来源!',
|
||||||
|
downloadError: '请检查网络状态与 JSON 文件有效性',
|
||||||
},
|
},
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,15 +1,27 @@
|
|||||||
export default {
|
export default {
|
||||||
common: {
|
common: {
|
||||||
|
add: '新增',
|
||||||
|
addSuccess: '新增成功',
|
||||||
|
edit: '編輯',
|
||||||
|
editSuccess: '編輯成功',
|
||||||
delete: '刪除',
|
delete: '刪除',
|
||||||
|
deleteSuccess: '刪除成功',
|
||||||
save: '儲存',
|
save: '儲存',
|
||||||
|
saveSuccess: '儲存成功',
|
||||||
reset: '重設',
|
reset: '重設',
|
||||||
|
action: '操作',
|
||||||
export: '匯出',
|
export: '匯出',
|
||||||
|
exportSuccess: '匯出成功',
|
||||||
import: '匯入',
|
import: '匯入',
|
||||||
|
importSuccess: '匯入成功',
|
||||||
clear: '清除',
|
clear: '清除',
|
||||||
|
clearSuccess: '清除成功',
|
||||||
yes: '是',
|
yes: '是',
|
||||||
no: '否',
|
no: '否',
|
||||||
noData: '暫無資料',
|
confirm: '確認',
|
||||||
wrong: '好像出錯了,請稍後再試。',
|
download: '下載',
|
||||||
|
noData: '目前無資料',
|
||||||
|
wrong: '發生錯誤,請稍後再試。',
|
||||||
success: '操作成功',
|
success: '操作成功',
|
||||||
failed: '操作失敗',
|
failed: '操作失敗',
|
||||||
verify: '驗證',
|
verify: '驗證',
|
||||||
@@ -28,19 +40,24 @@ export default {
|
|||||||
exportSuccess: '儲存成功',
|
exportSuccess: '儲存成功',
|
||||||
exportFailed: '儲存失敗',
|
exportFailed: '儲存失敗',
|
||||||
usingContext: '上下文模式',
|
usingContext: '上下文模式',
|
||||||
turnOnContext: '在當前模式下, 發送訊息會攜帶之前的聊天記錄。',
|
turnOnContext: '啟用上下文模式,在此模式下,發送訊息會包含之前的聊天記錄。',
|
||||||
turnOffContext: '在當前模式下, 發送訊息不會攜帶之前的聊天記錄。',
|
turnOffContext: '關閉上下文模式,在此模式下,發送訊息不會包含之前的聊天記錄。',
|
||||||
deleteMessage: '刪除訊息',
|
deleteMessage: '刪除訊息',
|
||||||
deleteMessageConfirm: '是否刪除此訊息?',
|
deleteMessageConfirm: '是否刪除此訊息?',
|
||||||
deleteHistoryConfirm: '確定刪除此紀錄?',
|
deleteHistoryConfirm: '確定刪除此紀錄?',
|
||||||
|
clearHistoryConfirm: '確定清除紀錄?',
|
||||||
|
preview: '預覽',
|
||||||
|
showRawText: '顯示原文',
|
||||||
},
|
},
|
||||||
setting: {
|
setting: {
|
||||||
setting: '設定',
|
setting: '設定',
|
||||||
general: '總覽',
|
general: '總覽',
|
||||||
|
advanced: '高級',
|
||||||
config: '設定',
|
config: '設定',
|
||||||
avatarLink: '頭貼連結',
|
avatarLink: '頭貼連結',
|
||||||
name: '名稱',
|
name: '名稱',
|
||||||
description: '描述',
|
description: '描述',
|
||||||
|
role: '角色設定',
|
||||||
resetUserInfo: '重設使用者資訊',
|
resetUserInfo: '重設使用者資訊',
|
||||||
chatHistory: '紀錄',
|
chatHistory: '紀錄',
|
||||||
theme: '主題',
|
theme: '主題',
|
||||||
@@ -49,5 +66,24 @@ export default {
|
|||||||
reverseProxy: '反向代理',
|
reverseProxy: '反向代理',
|
||||||
timeout: '逾時',
|
timeout: '逾時',
|
||||||
socks: 'Socks',
|
socks: 'Socks',
|
||||||
|
httpsProxy: 'HTTPS Proxy',
|
||||||
|
balance: 'API余額',
|
||||||
|
},
|
||||||
|
store: {
|
||||||
|
local: '本機',
|
||||||
|
online: '線上',
|
||||||
|
title: '標題',
|
||||||
|
description: '描述',
|
||||||
|
clearStoreConfirm: '是否清除資料?',
|
||||||
|
importPlaceholder: '請將 JSON 資料貼在此處',
|
||||||
|
addRepeatTitleTips: '標題重複,請重新輸入',
|
||||||
|
addRepeatContentTips: '內容重複:{msg},請重新輸入',
|
||||||
|
editRepeatTitleTips: '標題衝突,請重新修改',
|
||||||
|
editRepeatContentTips: '內容衝突{msg} ,請重新修改',
|
||||||
|
importError: '鍵值不符合',
|
||||||
|
importRepeatTitle: '因標題重複跳過:{msg}',
|
||||||
|
importRepeatContent: '因內容重複跳過:{msg}',
|
||||||
|
onlineImportWarning: '注意:請檢查 JSON 檔案來源!',
|
||||||
|
downloadError: '請檢查網路狀態與 JSON 檔案有效性',
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { createApp } from 'vue'
|
import { createApp } from 'vue'
|
||||||
import App from './App.vue'
|
import App from './App.vue'
|
||||||
import { setupI18n } from './locales'
|
import { setupI18n } from './locales'
|
||||||
import { setupAssets } from './plugins'
|
import { setupAssets, setupScrollbarStyle } from './plugins'
|
||||||
import { setupStore } from './store'
|
import { setupStore } from './store'
|
||||||
import { setupRouter } from './router'
|
import { setupRouter } from './router'
|
||||||
|
|
||||||
@@ -9,6 +9,8 @@ async function bootstrap() {
|
|||||||
const app = createApp(App)
|
const app = createApp(App)
|
||||||
setupAssets()
|
setupAssets()
|
||||||
|
|
||||||
|
setupScrollbarStyle()
|
||||||
|
|
||||||
setupStore(app)
|
setupStore(app)
|
||||||
|
|
||||||
setupI18n(app)
|
setupI18n(app)
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
import setupAssets from './assets'
|
import setupAssets from './assets'
|
||||||
|
import setupScrollbarStyle from './scrollbarStyle'
|
||||||
|
|
||||||
export { setupAssets }
|
export { setupAssets, setupScrollbarStyle }
|
||||||
|
|||||||
28
src/plugins/scrollbarStyle.ts
Normal file
28
src/plugins/scrollbarStyle.ts
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
import { darkTheme, lightTheme } from 'naive-ui'
|
||||||
|
|
||||||
|
const setupScrollbarStyle = () => {
|
||||||
|
const style = document.createElement('style')
|
||||||
|
const styleContent = `
|
||||||
|
::-webkit-scrollbar {
|
||||||
|
background-color: transparent;
|
||||||
|
width: ${lightTheme.Scrollbar.common?.scrollbarWidth};
|
||||||
|
}
|
||||||
|
::-webkit-scrollbar-thumb {
|
||||||
|
background-color: ${lightTheme.Scrollbar.common?.scrollbarColor};
|
||||||
|
border-radius: ${lightTheme.Scrollbar.common?.scrollbarBorderRadius};
|
||||||
|
}
|
||||||
|
html.dark ::-webkit-scrollbar {
|
||||||
|
background-color: transparent;
|
||||||
|
width: ${darkTheme.Scrollbar.common?.scrollbarWidth};
|
||||||
|
}
|
||||||
|
html.dark ::-webkit-scrollbar-thumb {
|
||||||
|
background-color: ${darkTheme.Scrollbar.common?.scrollbarColor};
|
||||||
|
border-radius: ${darkTheme.Scrollbar.common?.scrollbarBorderRadius};
|
||||||
|
}
|
||||||
|
`
|
||||||
|
|
||||||
|
style.innerHTML = styleContent
|
||||||
|
document.head.appendChild(style)
|
||||||
|
}
|
||||||
|
|
||||||
|
export default setupScrollbarStyle
|
||||||
@@ -2,17 +2,20 @@ import type { Router } from 'vue-router'
|
|||||||
import { useAuthStoreWithout } from '@/store/modules/auth'
|
import { useAuthStoreWithout } from '@/store/modules/auth'
|
||||||
|
|
||||||
export function setupPageGuard(router: Router) {
|
export function setupPageGuard(router: Router) {
|
||||||
router.beforeEach(async (from, to, next) => {
|
router.beforeEach(async (to, from, next) => {
|
||||||
const authStore = useAuthStoreWithout()
|
const authStore = useAuthStoreWithout()
|
||||||
if (!authStore.session) {
|
if (!authStore.session) {
|
||||||
try {
|
try {
|
||||||
const data = await authStore.getSession()
|
const data = await authStore.getSession()
|
||||||
if (String(data.auth) === 'false' && authStore.token)
|
if (String(data.auth) === 'false' && authStore.token)
|
||||||
authStore.removeToken()
|
authStore.removeToken()
|
||||||
next()
|
if (to.path === '/500')
|
||||||
|
next({ name: 'Root' })
|
||||||
|
else
|
||||||
|
next()
|
||||||
}
|
}
|
||||||
catch (error) {
|
catch (error) {
|
||||||
if (from.path !== '/500')
|
if (to.path !== '/500')
|
||||||
next({ name: '500' })
|
next({ name: '500' })
|
||||||
else
|
else
|
||||||
next()
|
next()
|
||||||
|
|||||||
@@ -3,9 +3,14 @@ import { getToken, removeToken, setToken } from './helper'
|
|||||||
import { store } from '@/store'
|
import { store } from '@/store'
|
||||||
import { fetchSession } from '@/api'
|
import { fetchSession } from '@/api'
|
||||||
|
|
||||||
|
interface SessionResponse {
|
||||||
|
auth: boolean
|
||||||
|
model: 'ChatGPTAPI' | 'ChatGPTUnofficialProxyAPI'
|
||||||
|
}
|
||||||
|
|
||||||
export interface AuthState {
|
export interface AuthState {
|
||||||
token: string | undefined
|
token: string | undefined
|
||||||
session: { auth: boolean } | null
|
session: SessionResponse | null
|
||||||
}
|
}
|
||||||
|
|
||||||
export const useAuthStore = defineStore('auth-store', {
|
export const useAuthStore = defineStore('auth-store', {
|
||||||
@@ -14,10 +19,16 @@ export const useAuthStore = defineStore('auth-store', {
|
|||||||
session: null,
|
session: null,
|
||||||
}),
|
}),
|
||||||
|
|
||||||
|
getters: {
|
||||||
|
isChatGPTAPI(state): boolean {
|
||||||
|
return state.session?.model === 'ChatGPTAPI'
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
actions: {
|
actions: {
|
||||||
async getSession() {
|
async getSession() {
|
||||||
try {
|
try {
|
||||||
const { data } = await fetchSession<{ auth: boolean }>()
|
const { data } = await fetchSession<SessionResponse>()
|
||||||
this.session = { ...data }
|
this.session = { ...data }
|
||||||
return Promise.resolve(data)
|
return Promise.resolve(data)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,12 +4,17 @@ const LOCAL_NAME = 'chatStorage'
|
|||||||
|
|
||||||
export function defaultState(): Chat.ChatState {
|
export function defaultState(): Chat.ChatState {
|
||||||
const uuid = 1002
|
const uuid = 1002
|
||||||
return { active: uuid, history: [{ uuid, title: 'New Chat', isEdit: false }], chat: [{ uuid, data: [] }] }
|
return {
|
||||||
|
active: uuid,
|
||||||
|
usingContext: true,
|
||||||
|
history: [{ uuid, title: 'New Chat', isEdit: false }],
|
||||||
|
chat: [{ uuid, data: [] }],
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getLocalState(): Chat.ChatState {
|
export function getLocalState(): Chat.ChatState {
|
||||||
const localState = ss.get(LOCAL_NAME)
|
const localState = ss.get(LOCAL_NAME)
|
||||||
return localState ?? defaultState()
|
return { ...defaultState(), ...localState }
|
||||||
}
|
}
|
||||||
|
|
||||||
export function setLocalState(state: Chat.ChatState) {
|
export function setLocalState(state: Chat.ChatState) {
|
||||||
|
|||||||
@@ -23,6 +23,11 @@ export const useChatStore = defineStore('chat-store', {
|
|||||||
},
|
},
|
||||||
|
|
||||||
actions: {
|
actions: {
|
||||||
|
setUsingContext(context: boolean) {
|
||||||
|
this.usingContext = context
|
||||||
|
this.recordState()
|
||||||
|
},
|
||||||
|
|
||||||
addHistory(history: Chat.History, chatData: Chat.Chat[] = []) {
|
addHistory(history: Chat.History, chatData: Chat.Chat[] = []) {
|
||||||
this.history.unshift(history)
|
this.history.unshift(history)
|
||||||
this.chat.unshift({ uuid: history.uuid, data: chatData })
|
this.chat.unshift({ uuid: history.uuid, data: chatData })
|
||||||
@@ -165,7 +170,6 @@ export const useChatStore = defineStore('chat-store', {
|
|||||||
if (!uuid || uuid === 0) {
|
if (!uuid || uuid === 0) {
|
||||||
if (this.chat.length) {
|
if (this.chat.length) {
|
||||||
this.chat[0].data = []
|
this.chat[0].data = []
|
||||||
this.history[0].title = 'New Chat'
|
|
||||||
this.recordState()
|
this.recordState()
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
@@ -174,7 +178,6 @@ export const useChatStore = defineStore('chat-store', {
|
|||||||
const index = this.chat.findIndex(item => item.uuid === uuid)
|
const index = this.chat.findIndex(item => item.uuid === uuid)
|
||||||
if (index !== -1) {
|
if (index !== -1) {
|
||||||
this.chat[index].data = []
|
this.chat[index].data = []
|
||||||
this.history[index].title = 'New Chat'
|
|
||||||
this.recordState()
|
this.recordState()
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
export * from './app'
|
export * from './app'
|
||||||
export * from './chat'
|
export * from './chat'
|
||||||
export * from './user'
|
export * from './user'
|
||||||
|
export * from './prompt'
|
||||||
|
export * from './settings'
|
||||||
export * from './auth'
|
export * from './auth'
|
||||||
|
|||||||
18
src/store/modules/prompt/helper.ts
Normal file
18
src/store/modules/prompt/helper.ts
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
import { ss } from '@/utils/storage'
|
||||||
|
|
||||||
|
const LOCAL_NAME = 'promptStore'
|
||||||
|
|
||||||
|
export type PromptList = []
|
||||||
|
|
||||||
|
export interface PromptStore {
|
||||||
|
promptList: PromptList
|
||||||
|
}
|
||||||
|
|
||||||
|
export function getLocalPromptList(): PromptStore {
|
||||||
|
const promptStore: PromptStore | undefined = ss.get(LOCAL_NAME)
|
||||||
|
return promptStore ?? { promptList: [] }
|
||||||
|
}
|
||||||
|
|
||||||
|
export function setLocalPromptList(promptStore: PromptStore): void {
|
||||||
|
ss.set(LOCAL_NAME, promptStore)
|
||||||
|
}
|
||||||
17
src/store/modules/prompt/index.ts
Normal file
17
src/store/modules/prompt/index.ts
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
import { defineStore } from 'pinia'
|
||||||
|
import type { PromptStore } from './helper'
|
||||||
|
import { getLocalPromptList, setLocalPromptList } from './helper'
|
||||||
|
|
||||||
|
export const usePromptStore = defineStore('prompt-store', {
|
||||||
|
state: (): PromptStore => getLocalPromptList(),
|
||||||
|
|
||||||
|
actions: {
|
||||||
|
updatePromptList(promptList: []) {
|
||||||
|
this.$patch({ promptList })
|
||||||
|
setLocalPromptList({ promptList })
|
||||||
|
},
|
||||||
|
getPromptList() {
|
||||||
|
return this.$state
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
27
src/store/modules/settings/helper.ts
Normal file
27
src/store/modules/settings/helper.ts
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
import { ss } from '@/utils/storage'
|
||||||
|
|
||||||
|
const LOCAL_NAME = 'settingsStorage'
|
||||||
|
|
||||||
|
export interface SettingsState {
|
||||||
|
systemMessage: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export function defaultSetting(): SettingsState {
|
||||||
|
const currentDate = new Date().toISOString().split('T')[0]
|
||||||
|
return {
|
||||||
|
systemMessage: `You are ChatGPT, a large language model trained by OpenAI. Answer as concisely as possible.\nKnowledge cutoff: 2021-09-01\nCurrent date: ${currentDate}`,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export function getLocalState(): SettingsState {
|
||||||
|
const localSetting: SettingsState | undefined = ss.get(LOCAL_NAME)
|
||||||
|
return { ...defaultSetting(), ...localSetting }
|
||||||
|
}
|
||||||
|
|
||||||
|
export function setLocalState(setting: SettingsState): void {
|
||||||
|
ss.set(LOCAL_NAME, setting)
|
||||||
|
}
|
||||||
|
|
||||||
|
export function removeLocalState() {
|
||||||
|
ss.remove(LOCAL_NAME)
|
||||||
|
}
|
||||||
22
src/store/modules/settings/index.ts
Normal file
22
src/store/modules/settings/index.ts
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
import { defineStore } from 'pinia'
|
||||||
|
import type { SettingsState } from './helper'
|
||||||
|
import { defaultSetting, getLocalState, removeLocalState, setLocalState } from './helper'
|
||||||
|
|
||||||
|
export const useSettingStore = defineStore('setting-store', {
|
||||||
|
state: (): SettingsState => getLocalState(),
|
||||||
|
actions: {
|
||||||
|
updateSetting(settings: Partial<SettingsState>) {
|
||||||
|
this.$state = { ...this.$state, ...settings }
|
||||||
|
this.recordState()
|
||||||
|
},
|
||||||
|
|
||||||
|
resetSetting() {
|
||||||
|
this.$state = defaultSetting()
|
||||||
|
removeLocalState()
|
||||||
|
},
|
||||||
|
|
||||||
|
recordState() {
|
||||||
|
setLocalState(this.$state)
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
1
src/typings/chat.d.ts
vendored
1
src/typings/chat.d.ts
vendored
@@ -18,6 +18,7 @@ declare namespace Chat {
|
|||||||
|
|
||||||
interface ChatState {
|
interface ChatState {
|
||||||
active: number | null
|
active: number | null
|
||||||
|
usingContext: boolean;
|
||||||
history: History[]
|
history: History[]
|
||||||
chat: { uuid: number; data: Chat[] }[]
|
chat: { uuid: number; data: Chat[] }[]
|
||||||
}
|
}
|
||||||
|
|||||||
3
src/typings/env.d.ts
vendored
3
src/typings/env.d.ts
vendored
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
interface ImportMetaEnv {
|
interface ImportMetaEnv {
|
||||||
readonly VITE_GLOB_API_URL: string;
|
readonly VITE_GLOB_API_URL: string;
|
||||||
readonly VITE_GLOB_API_TIMEOUT: string;
|
|
||||||
readonly VITE_APP_API_BASE_URL: string;
|
readonly VITE_APP_API_BASE_URL: string;
|
||||||
|
readonly VITE_GLOB_OPEN_LONG_REPLY: string;
|
||||||
|
readonly VITE_GLOB_APP_PWA: string;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
import { computed, ref } from 'vue'
|
import { computed, ref } from 'vue'
|
||||||
import MarkdownIt from 'markdown-it'
|
import MarkdownIt from 'markdown-it'
|
||||||
import mdKatex from '@traptitech/markdown-it-katex'
|
import mdKatex from '@traptitech/markdown-it-katex'
|
||||||
|
import mila from 'markdown-it-link-attributes'
|
||||||
import hljs from 'highlight.js'
|
import hljs from 'highlight.js'
|
||||||
import { useBasicLayout } from '@/hooks/useBasicLayout'
|
import { useBasicLayout } from '@/hooks/useBasicLayout'
|
||||||
import { t } from '@/locales'
|
import { t } from '@/locales'
|
||||||
@@ -11,6 +12,7 @@ interface Props {
|
|||||||
error?: boolean
|
error?: boolean
|
||||||
text?: string
|
text?: string
|
||||||
loading?: boolean
|
loading?: boolean
|
||||||
|
asRawText?: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
const props = defineProps<Props>()
|
const props = defineProps<Props>()
|
||||||
@@ -25,12 +27,13 @@ const mdi = new MarkdownIt({
|
|||||||
const validLang = !!(language && hljs.getLanguage(language))
|
const validLang = !!(language && hljs.getLanguage(language))
|
||||||
if (validLang) {
|
if (validLang) {
|
||||||
const lang = language ?? ''
|
const lang = language ?? ''
|
||||||
return highlightBlock(hljs.highlight(lang, code, true).value, lang)
|
return highlightBlock(hljs.highlight(code, { language: lang }).value, lang)
|
||||||
}
|
}
|
||||||
return highlightBlock(hljs.highlightAuto(code).value, '')
|
return highlightBlock(hljs.highlightAuto(code).value, '')
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
|
mdi.use(mila, { attrs: { target: '_blank', rel: 'noopener' } })
|
||||||
mdi.use(mdKatex, { blockClass: 'katexmath-block rounded-md p-[10px]', errorColor: ' #cc0000' })
|
mdi.use(mdKatex, { blockClass: 'katexmath-block rounded-md p-[10px]', errorColor: ' #cc0000' })
|
||||||
|
|
||||||
const wrapClass = computed(() => {
|
const wrapClass = computed(() => {
|
||||||
@@ -41,13 +44,14 @@ const wrapClass = computed(() => {
|
|||||||
isMobile.value ? 'p-2' : 'px-3 py-2',
|
isMobile.value ? 'p-2' : 'px-3 py-2',
|
||||||
props.inversion ? 'bg-[#d2f9d1]' : 'bg-[#f4f6f8]',
|
props.inversion ? 'bg-[#d2f9d1]' : 'bg-[#f4f6f8]',
|
||||||
props.inversion ? 'dark:bg-[#a1dc95]' : 'dark:bg-[#1e1e20]',
|
props.inversion ? 'dark:bg-[#a1dc95]' : 'dark:bg-[#1e1e20]',
|
||||||
|
props.inversion ? 'message-request' : 'message-reply',
|
||||||
{ 'text-red-500': props.error },
|
{ 'text-red-500': props.error },
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
|
|
||||||
const text = computed(() => {
|
const text = computed(() => {
|
||||||
const value = props.text ?? ''
|
const value = props.text ?? ''
|
||||||
if (!props.inversion)
|
if (!props.asRawText)
|
||||||
return mdi.render(value)
|
return mdi.render(value)
|
||||||
return value
|
return value
|
||||||
})
|
})
|
||||||
@@ -66,7 +70,10 @@ defineExpose({ textRef })
|
|||||||
</template>
|
</template>
|
||||||
<template v-else>
|
<template v-else>
|
||||||
<div ref="textRef" class="leading-relaxed break-words">
|
<div ref="textRef" class="leading-relaxed break-words">
|
||||||
<div v-if="!inversion" class="markdown-body" v-html="text" />
|
<div v-if="!inversion">
|
||||||
|
<div v-if="!asRawText" class="markdown-body" v-html="text" />
|
||||||
|
<div v-else class="whitespace-pre-wrap" v-text="text" />
|
||||||
|
</div>
|
||||||
<div v-else class="whitespace-pre-wrap" v-text="text" />
|
<div v-else class="whitespace-pre-wrap" v-text="text" />
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<script setup lang='ts'>
|
<script setup lang='ts'>
|
||||||
import { ref } from 'vue'
|
import { computed, ref } from 'vue'
|
||||||
import { NDropdown } from 'naive-ui'
|
import { NDropdown } from 'naive-ui'
|
||||||
import AvatarComponent from './Avatar.vue'
|
import AvatarComponent from './Avatar.vue'
|
||||||
import TextComponent from './Text.vue'
|
import TextComponent from './Text.vue'
|
||||||
@@ -29,36 +29,60 @@ const { iconRender } = useIconRender()
|
|||||||
|
|
||||||
const textRef = ref<HTMLElement>()
|
const textRef = ref<HTMLElement>()
|
||||||
|
|
||||||
const options = [
|
const asRawText = ref(props.inversion)
|
||||||
{
|
|
||||||
label: t('chat.copy'),
|
|
||||||
key: 'copyText',
|
|
||||||
icon: iconRender({ icon: 'ri:file-copy-2-line' }),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: t('common.delete'),
|
|
||||||
key: 'delete',
|
|
||||||
icon: iconRender({ icon: 'ri:delete-bin-line' }),
|
|
||||||
},
|
|
||||||
]
|
|
||||||
|
|
||||||
function handleSelect(key: 'copyRaw' | 'copyText' | 'delete') {
|
const messageRef = ref<HTMLElement>()
|
||||||
|
|
||||||
|
const options = computed(() => {
|
||||||
|
const common = [
|
||||||
|
{
|
||||||
|
label: t('chat.copy'),
|
||||||
|
key: 'copyText',
|
||||||
|
icon: iconRender({ icon: 'ri:file-copy-2-line' }),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: t('common.delete'),
|
||||||
|
key: 'delete',
|
||||||
|
icon: iconRender({ icon: 'ri:delete-bin-line' }),
|
||||||
|
},
|
||||||
|
]
|
||||||
|
|
||||||
|
if (!props.inversion) {
|
||||||
|
common.unshift({
|
||||||
|
label: asRawText.value ? t('chat.preview') : t('chat.showRawText'),
|
||||||
|
key: 'toggleRenderType',
|
||||||
|
icon: iconRender({ icon: asRawText.value ? 'ic:outline-code-off' : 'ic:outline-code' }),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
return common
|
||||||
|
})
|
||||||
|
|
||||||
|
function handleSelect(key: 'copyText' | 'delete' | 'toggleRenderType') {
|
||||||
switch (key) {
|
switch (key) {
|
||||||
case 'copyText':
|
case 'copyText':
|
||||||
copyText({ text: props.text ?? '' })
|
copyText({ text: props.text ?? '' })
|
||||||
return
|
return
|
||||||
|
case 'toggleRenderType':
|
||||||
|
asRawText.value = !asRawText.value
|
||||||
|
return
|
||||||
case 'delete':
|
case 'delete':
|
||||||
emit('delete')
|
emit('delete')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleRegenerate() {
|
function handleRegenerate() {
|
||||||
|
messageRef.value?.scrollIntoView()
|
||||||
emit('regenerate')
|
emit('regenerate')
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div class="flex w-full mb-6 overflow-hidden" :class="[{ 'flex-row-reverse': inversion }]">
|
<div
|
||||||
|
ref="messageRef"
|
||||||
|
class="flex w-full mb-6 overflow-hidden"
|
||||||
|
:class="[{ 'flex-row-reverse': inversion }]"
|
||||||
|
>
|
||||||
<div
|
<div
|
||||||
class="flex items-center justify-center flex-shrink-0 h-8 overflow-hidden rounded-full basis-8"
|
class="flex items-center justify-center flex-shrink-0 h-8 overflow-hidden rounded-full basis-8"
|
||||||
:class="[inversion ? 'ml-2' : 'mr-2']"
|
:class="[inversion ? 'ml-2' : 'mr-2']"
|
||||||
@@ -79,6 +103,7 @@ function handleRegenerate() {
|
|||||||
:error="error"
|
:error="error"
|
||||||
:text="text"
|
:text="text"
|
||||||
:loading="loading"
|
:loading="loading"
|
||||||
|
:as-raw-text="asRawText"
|
||||||
/>
|
/>
|
||||||
<div class="flex flex-col">
|
<div class="flex flex-col">
|
||||||
<button
|
<button
|
||||||
|
|||||||
@@ -45,20 +45,29 @@
|
|||||||
align-items: center;
|
align-items: center;
|
||||||
color: #b3b3b3;
|
color: #b3b3b3;
|
||||||
|
|
||||||
&__copy{
|
&__copy {
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
margin-left: 0.5rem;
|
margin-left: 0.5rem;
|
||||||
user-select: none;
|
user-select: none;
|
||||||
|
|
||||||
&:hover {
|
&:hover {
|
||||||
color: #65a665;
|
color: #65a665;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
html.dark {
|
html.dark {
|
||||||
|
|
||||||
|
.message-reply {
|
||||||
|
.whitespace-pre-wrap {
|
||||||
|
white-space: pre-wrap;
|
||||||
|
color: var(--n-text-color);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
.highlight pre,
|
.highlight pre,
|
||||||
pre {
|
pre {
|
||||||
background-color: #282c34;
|
background-color: #282c34;
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ export function useScroll(): ScrollReturn {
|
|||||||
const scrollToBottomIfAtBottom = async () => {
|
const scrollToBottomIfAtBottom = async () => {
|
||||||
await nextTick()
|
await nextTick()
|
||||||
if (scrollRef.value) {
|
if (scrollRef.value) {
|
||||||
const threshold = 50 // 阈值,表示滚动条到底部的距离阈值
|
const threshold = 100 // 阈值,表示滚动条到底部的距离阈值
|
||||||
const distanceToBottom = scrollRef.value.scrollHeight - scrollRef.value.scrollTop - scrollRef.value.clientHeight
|
const distanceToBottom = scrollRef.value.scrollHeight - scrollRef.value.scrollTop - scrollRef.value.clientHeight
|
||||||
if (distanceToBottom <= threshold)
|
if (distanceToBottom <= threshold)
|
||||||
scrollRef.value.scrollTop = scrollRef.value.scrollHeight
|
scrollRef.value.scrollTop = scrollRef.value.scrollHeight
|
||||||
|
|||||||
@@ -1,13 +1,15 @@
|
|||||||
import { ref } from 'vue'
|
import { computed } from 'vue'
|
||||||
import { useMessage } from 'naive-ui'
|
import { useMessage } from 'naive-ui'
|
||||||
import { t } from '@/locales'
|
import { t } from '@/locales'
|
||||||
|
import { useChatStore } from '@/store'
|
||||||
|
|
||||||
export function useUsingContext() {
|
export function useUsingContext() {
|
||||||
const ms = useMessage()
|
const ms = useMessage()
|
||||||
const usingContext = ref<boolean>(true)
|
const chatStore = useChatStore()
|
||||||
|
const usingContext = computed<boolean>(() => chatStore.usingContext)
|
||||||
|
|
||||||
function toggleUsingContext() {
|
function toggleUsingContext() {
|
||||||
usingContext.value = !usingContext.value
|
chatStore.setUsingContext(!usingContext.value)
|
||||||
if (usingContext.value)
|
if (usingContext.value)
|
||||||
ms.success(t('chat.turnOnContext'))
|
ms.success(t('chat.turnOnContext'))
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
<script setup lang='ts'>
|
<script setup lang='ts'>
|
||||||
|
import type { Ref } from 'vue'
|
||||||
import { computed, onMounted, onUnmounted, ref } from 'vue'
|
import { computed, onMounted, onUnmounted, ref } from 'vue'
|
||||||
import { useRoute } from 'vue-router'
|
import { useRoute } from 'vue-router'
|
||||||
import { NButton, NInput, useDialog, useMessage } from 'naive-ui'
|
import { storeToRefs } from 'pinia'
|
||||||
|
import { NAutoComplete, NButton, NInput, useDialog, useMessage } from 'naive-ui'
|
||||||
import html2canvas from 'html2canvas'
|
import html2canvas from 'html2canvas'
|
||||||
import { Message } from './components'
|
import { Message } from './components'
|
||||||
import { useScroll } from './hooks/useScroll'
|
import { useScroll } from './hooks/useScroll'
|
||||||
@@ -11,7 +13,7 @@ import { useUsingContext } from './hooks/useUsingContext'
|
|||||||
import HeaderComponent from './components/Header/index.vue'
|
import HeaderComponent from './components/Header/index.vue'
|
||||||
import { HoverButton, SvgIcon } from '@/components/common'
|
import { HoverButton, SvgIcon } from '@/components/common'
|
||||||
import { useBasicLayout } from '@/hooks/useBasicLayout'
|
import { useBasicLayout } from '@/hooks/useBasicLayout'
|
||||||
import { useChatStore } from '@/store'
|
import { useChatStore, usePromptStore } from '@/store'
|
||||||
import { fetchChatAPIProcess } from '@/api'
|
import { fetchChatAPIProcess } from '@/api'
|
||||||
import { t } from '@/locales'
|
import { t } from '@/locales'
|
||||||
|
|
||||||
@@ -29,7 +31,7 @@ useCopyCode()
|
|||||||
|
|
||||||
const { isMobile } = useBasicLayout()
|
const { isMobile } = useBasicLayout()
|
||||||
const { addChat, updateChat, updateChatSome, getChatByUuidAndIndex } = useChat()
|
const { addChat, updateChat, updateChatSome, getChatByUuidAndIndex } = useChat()
|
||||||
const { scrollRef, scrollToBottom } = useScroll()
|
const { scrollRef, scrollToBottom, scrollToBottomIfAtBottom } = useScroll()
|
||||||
const { usingContext, toggleUsingContext } = useUsingContext()
|
const { usingContext, toggleUsingContext } = useUsingContext()
|
||||||
|
|
||||||
const { uuid } = route.params as { uuid: string }
|
const { uuid } = route.params as { uuid: string }
|
||||||
@@ -39,6 +41,19 @@ const conversationList = computed(() => dataSources.value.filter(item => (!item.
|
|||||||
|
|
||||||
const prompt = ref<string>('')
|
const prompt = ref<string>('')
|
||||||
const loading = ref<boolean>(false)
|
const loading = ref<boolean>(false)
|
||||||
|
const inputRef = ref<Ref | null>(null)
|
||||||
|
|
||||||
|
// 添加PromptStore
|
||||||
|
const promptStore = usePromptStore()
|
||||||
|
|
||||||
|
// 使用storeToRefs,保证store修改后,联想部分能够重新渲染
|
||||||
|
const { promptList: promptTemplate } = storeToRefs<any>(promptStore)
|
||||||
|
|
||||||
|
// 未知原因刷新页面,loading 状态不会重置,手动重置
|
||||||
|
dataSources.value.forEach((item, index) => {
|
||||||
|
if (item.loading)
|
||||||
|
updateChatSome(+uuid, index, { loading: false })
|
||||||
|
})
|
||||||
|
|
||||||
function handleSubmit() {
|
function handleSubmit() {
|
||||||
onConversation()
|
onConversation()
|
||||||
@@ -102,7 +117,7 @@ async function onConversation() {
|
|||||||
const xhr = event.target
|
const xhr = event.target
|
||||||
const { responseText } = xhr
|
const { responseText } = xhr
|
||||||
// Always process the final line
|
// Always process the final line
|
||||||
const lastIndex = responseText.lastIndexOf('\n')
|
const lastIndex = responseText.lastIndexOf('\n', responseText.length - 2)
|
||||||
let chunk = responseText
|
let chunk = responseText
|
||||||
if (lastIndex !== -1)
|
if (lastIndex !== -1)
|
||||||
chunk = responseText.substring(lastIndex)
|
chunk = responseText.substring(lastIndex)
|
||||||
@@ -129,7 +144,7 @@ async function onConversation() {
|
|||||||
return fetchChatAPIOnce()
|
return fetchChatAPIOnce()
|
||||||
}
|
}
|
||||||
|
|
||||||
scrollToBottom()
|
scrollToBottomIfAtBottom()
|
||||||
}
|
}
|
||||||
catch (error) {
|
catch (error) {
|
||||||
//
|
//
|
||||||
@@ -151,7 +166,7 @@ async function onConversation() {
|
|||||||
loading: false,
|
loading: false,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
scrollToBottom()
|
scrollToBottomIfAtBottom()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -183,7 +198,7 @@ async function onConversation() {
|
|||||||
requestOptions: { prompt: message, options: { ...options } },
|
requestOptions: { prompt: message, options: { ...options } },
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
scrollToBottom()
|
scrollToBottomIfAtBottom()
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
loading.value = false
|
loading.value = false
|
||||||
@@ -232,7 +247,7 @@ async function onRegenerate(index: number) {
|
|||||||
const xhr = event.target
|
const xhr = event.target
|
||||||
const { responseText } = xhr
|
const { responseText } = xhr
|
||||||
// Always process the final line
|
// Always process the final line
|
||||||
const lastIndex = responseText.lastIndexOf('\n')
|
const lastIndex = responseText.lastIndexOf('\n', responseText.length - 2)
|
||||||
let chunk = responseText
|
let chunk = responseText
|
||||||
if (lastIndex !== -1)
|
if (lastIndex !== -1)
|
||||||
chunk = responseText.substring(lastIndex)
|
chunk = responseText.substring(lastIndex)
|
||||||
@@ -394,6 +409,32 @@ function handleStop() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 可优化部分
|
||||||
|
// 搜索选项计算,这里使用value作为索引项,所以当出现重复value时渲染异常(多项同时出现选中效果)
|
||||||
|
// 理想状态下其实应该是key作为索引项,但官方的renderOption会出现问题,所以就需要value反renderLabel实现
|
||||||
|
const searchOptions = computed(() => {
|
||||||
|
if (prompt.value.startsWith('/')) {
|
||||||
|
return promptTemplate.value.filter((item: { key: string }) => item.key.toLowerCase().includes(prompt.value.substring(1).toLowerCase())).map((obj: { value: any }) => {
|
||||||
|
return {
|
||||||
|
label: obj.value,
|
||||||
|
value: obj.value,
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return []
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
// value反渲染key
|
||||||
|
const renderOption = (option: { label: string }) => {
|
||||||
|
for (const i of promptTemplate.value) {
|
||||||
|
if (i.value === option.label)
|
||||||
|
return [i.key]
|
||||||
|
}
|
||||||
|
return []
|
||||||
|
}
|
||||||
|
|
||||||
const placeholder = computed(() => {
|
const placeholder = computed(() => {
|
||||||
if (isMobile.value)
|
if (isMobile.value)
|
||||||
return t('chat.placeholderMobile')
|
return t('chat.placeholderMobile')
|
||||||
@@ -413,6 +454,8 @@ const footerClass = computed(() => {
|
|||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
scrollToBottom()
|
scrollToBottom()
|
||||||
|
if (inputRef.value)
|
||||||
|
inputRef.value?.focus()
|
||||||
})
|
})
|
||||||
|
|
||||||
onUnmounted(() => {
|
onUnmounted(() => {
|
||||||
@@ -490,13 +533,21 @@ onUnmounted(() => {
|
|||||||
<SvgIcon icon="ri:chat-history-line" />
|
<SvgIcon icon="ri:chat-history-line" />
|
||||||
</span>
|
</span>
|
||||||
</HoverButton>
|
</HoverButton>
|
||||||
<NInput
|
<NAutoComplete v-model:value="prompt" :options="searchOptions" :render-label="renderOption">
|
||||||
v-model:value="prompt"
|
<template #default="{ handleInput, handleBlur, handleFocus }">
|
||||||
type="textarea"
|
<NInput
|
||||||
:autosize="{ minRows: 1, maxRows: 2 }"
|
ref="inputRef"
|
||||||
:placeholder="placeholder"
|
v-model:value="prompt"
|
||||||
@keypress="handleEnter"
|
type="textarea"
|
||||||
/>
|
:placeholder="placeholder"
|
||||||
|
:autosize="{ minRows: 1, maxRows: isMobile ? 4 : 8 }"
|
||||||
|
@input="handleInput"
|
||||||
|
@focus="handleFocus"
|
||||||
|
@blur="handleBlur"
|
||||||
|
@keypress="handleEnter"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
|
</NAutoComplete>
|
||||||
<NButton type="primary" :disabled="buttonDisabled" @click="handleSubmit">
|
<NButton type="primary" :disabled="buttonDisabled" @click="handleSubmit">
|
||||||
<template #icon>
|
<template #icon>
|
||||||
<span class="dark:text-black">
|
<span class="dark:text-black">
|
||||||
|
|||||||
@@ -64,8 +64,7 @@ function handlePress(event: KeyboardEvent) {
|
|||||||
</p>
|
</p>
|
||||||
<Icon403 class="w-[200px] m-auto" />
|
<Icon403 class="w-[200px] m-auto" />
|
||||||
</header>
|
</header>
|
||||||
<NInput v-model:value="token" type="text" placeholder="" @keypress="handlePress" />
|
<NInput v-model:value="token" type="password" placeholder="" @keypress="handlePress" />
|
||||||
|
|
||||||
<NButton
|
<NButton
|
||||||
block
|
block
|
||||||
type="primary"
|
type="primary"
|
||||||
|
|||||||
@@ -12,7 +12,8 @@ const show = ref(false)
|
|||||||
<div class="flex-1 flex-shrink-0 overflow-hidden">
|
<div class="flex-1 flex-shrink-0 overflow-hidden">
|
||||||
<UserAvatar />
|
<UserAvatar />
|
||||||
</div>
|
</div>
|
||||||
<HoverButton :tooltip="$t('setting.setting')" @click="show = true">
|
|
||||||
|
<HoverButton @click="show = true">
|
||||||
<span class="text-xl text-[#4f555e] dark:text-white">
|
<span class="text-xl text-[#4f555e] dark:text-white">
|
||||||
<SvgIcon icon="ri:settings-4-line" />
|
<SvgIcon icon="ri:settings-4-line" />
|
||||||
</span>
|
</span>
|
||||||
|
|||||||
@@ -1,21 +1,25 @@
|
|||||||
<script setup lang='ts'>
|
<script setup lang='ts'>
|
||||||
import type { CSSProperties } from 'vue'
|
import type { CSSProperties } from 'vue'
|
||||||
import { computed, watch } from 'vue'
|
import { computed, ref, watch } from 'vue'
|
||||||
import { NButton, NLayoutSider } from 'naive-ui'
|
import { NButton, NLayoutSider } from 'naive-ui'
|
||||||
import List from './List.vue'
|
import List from './List.vue'
|
||||||
import Footer from './Footer.vue'
|
import Footer from './Footer.vue'
|
||||||
import { useAppStore, useChatStore } from '@/store'
|
import { useAppStore, useChatStore } from '@/store'
|
||||||
import { useBasicLayout } from '@/hooks/useBasicLayout'
|
import { useBasicLayout } from '@/hooks/useBasicLayout'
|
||||||
|
import { PromptStore } from '@/components/common'
|
||||||
|
|
||||||
const appStore = useAppStore()
|
const appStore = useAppStore()
|
||||||
const chatStore = useChatStore()
|
const chatStore = useChatStore()
|
||||||
|
|
||||||
const { isMobile } = useBasicLayout()
|
const { isMobile } = useBasicLayout()
|
||||||
|
const show = ref(false)
|
||||||
|
|
||||||
const collapsed = computed(() => appStore.siderCollapsed)
|
const collapsed = computed(() => appStore.siderCollapsed)
|
||||||
|
|
||||||
function handleAdd() {
|
function handleAdd() {
|
||||||
chatStore.addHistory({ title: 'New Chat', uuid: Date.now(), isEdit: false })
|
chatStore.addHistory({ title: 'New Chat', uuid: Date.now(), isEdit: false })
|
||||||
|
if (isMobile.value)
|
||||||
|
appStore.setSiderCollapsed(true)
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleUpdateCollapsed() {
|
function handleUpdateCollapsed() {
|
||||||
@@ -75,6 +79,11 @@ watch(
|
|||||||
<div class="flex-1 min-h-0 pb-4 overflow-hidden">
|
<div class="flex-1 min-h-0 pb-4 overflow-hidden">
|
||||||
<List />
|
<List />
|
||||||
</div>
|
</div>
|
||||||
|
<div class="p-4">
|
||||||
|
<NButton block @click="show = true">
|
||||||
|
Prompt Store
|
||||||
|
</NButton>
|
||||||
|
</div>
|
||||||
</main>
|
</main>
|
||||||
<Footer />
|
<Footer />
|
||||||
</div>
|
</div>
|
||||||
@@ -82,4 +91,5 @@ watch(
|
|||||||
<template v-if="isMobile">
|
<template v-if="isMobile">
|
||||||
<div v-show="!collapsed" class="fixed inset-0 z-40 bg-black/40" @click="handleUpdateCollapsed" />
|
<div v-show="!collapsed" class="fixed inset-0 z-40 bg-black/40" @click="handleUpdateCollapsed" />
|
||||||
</template>
|
</template>
|
||||||
|
<PromptStore v-model:visible="show" />
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
9
start.cmd
Normal file
9
start.cmd
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
cd ./service
|
||||||
|
start pnpm start > service.log &
|
||||||
|
echo "Start service complete!"
|
||||||
|
|
||||||
|
|
||||||
|
cd ..
|
||||||
|
echo "" > front.log
|
||||||
|
start pnpm dev > front.log &
|
||||||
|
echo "Start front complete!"
|
||||||
@@ -1,8 +1,26 @@
|
|||||||
import path from 'path'
|
import path from 'path'
|
||||||
|
import type { PluginOption } from 'vite'
|
||||||
import { defineConfig, loadEnv } from 'vite'
|
import { defineConfig, loadEnv } from 'vite'
|
||||||
import vue from '@vitejs/plugin-vue'
|
import vue from '@vitejs/plugin-vue'
|
||||||
import { VitePWA } from 'vite-plugin-pwa'
|
import { VitePWA } from 'vite-plugin-pwa'
|
||||||
|
|
||||||
|
function setupPlugins(env: ImportMetaEnv): PluginOption[] {
|
||||||
|
return [
|
||||||
|
vue(),
|
||||||
|
env.VITE_GLOB_APP_PWA === 'true' && VitePWA({
|
||||||
|
injectRegister: 'auto',
|
||||||
|
manifest: {
|
||||||
|
name: 'chatGPT',
|
||||||
|
short_name: 'chatGPT',
|
||||||
|
icons: [
|
||||||
|
{ src: 'pwa-192x192.png', sizes: '192x192', type: 'image/png' },
|
||||||
|
{ src: 'pwa-512x512.png', sizes: '512x512', type: 'image/png' },
|
||||||
|
],
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
export default defineConfig((env) => {
|
export default defineConfig((env) => {
|
||||||
const viteEnv = loadEnv(env.mode, process.cwd()) as unknown as ImportMetaEnv
|
const viteEnv = loadEnv(env.mode, process.cwd()) as unknown as ImportMetaEnv
|
||||||
|
|
||||||
@@ -12,20 +30,7 @@ export default defineConfig((env) => {
|
|||||||
'@': path.resolve(process.cwd(), 'src'),
|
'@': path.resolve(process.cwd(), 'src'),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
plugins: [
|
plugins: setupPlugins(viteEnv),
|
||||||
vue(),
|
|
||||||
VitePWA({
|
|
||||||
injectRegister: 'auto',
|
|
||||||
manifest: {
|
|
||||||
name: 'chatGPT',
|
|
||||||
short_name: 'chatGPT',
|
|
||||||
icons: [
|
|
||||||
{ src: 'pwa-192x192.png', sizes: '192x192', type: 'image/png' },
|
|
||||||
{ src: 'pwa-512x512.png', sizes: '512x512', type: 'image/png' },
|
|
||||||
],
|
|
||||||
},
|
|
||||||
}),
|
|
||||||
],
|
|
||||||
server: {
|
server: {
|
||||||
host: '0.0.0.0',
|
host: '0.0.0.0',
|
||||||
port: 1002,
|
port: 1002,
|
||||||
|
|||||||
Reference in New Issue
Block a user