@ -0,0 +1,3 @@
|
||||
{
|
||||
"extends": ["@commitlint/config-conventional"]
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
|
||||
// README at: https://github.com/devcontainers/templates/tree/main/src/typescript-node
|
||||
{
|
||||
"name": "Node.js & TypeScript",
|
||||
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
|
||||
"image": "mcr.microsoft.com/devcontainers/typescript-node:1-20-bullseye"
|
||||
|
||||
// Features to add to the dev container. More info: https://containers.dev/features.
|
||||
// "features": {},
|
||||
|
||||
// Use 'forwardPorts' to make a list of ports inside the container available locally.
|
||||
// "forwardPorts": [],
|
||||
|
||||
// Use 'postCreateCommand' to run commands after the container is created.
|
||||
// "postCreateCommand": "yarn install",
|
||||
|
||||
// Configure tool-specific properties.
|
||||
// "customizations": {},
|
||||
|
||||
// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
|
||||
// "remoteUser": "root"
|
||||
}
|
@ -0,0 +1,7 @@
|
||||
**/node_modules
|
||||
*/node_modules
|
||||
node_modules
|
||||
Dockerfile
|
||||
.*
|
||||
*/.*
|
||||
!.env
|
@ -0,0 +1,11 @@
|
||||
# Editor configuration, see http://editorconfig.org
|
||||
|
||||
root = true
|
||||
|
||||
[*]
|
||||
charset = utf-8
|
||||
indent_style = tab
|
||||
indent_size = 2
|
||||
end_of_line = lf
|
||||
trim_trailing_whitespace = true
|
||||
insert_final_newline = true
|
@ -0,0 +1,17 @@
|
||||
"*.vue" eol=lf
|
||||
"*.js" eol=lf
|
||||
"*.ts" eol=lf
|
||||
"*.jsx" eol=lf
|
||||
"*.tsx" eol=lf
|
||||
"*.cjs" eol=lf
|
||||
"*.cts" eol=lf
|
||||
"*.mjs" eol=lf
|
||||
"*.mts" eol=lf
|
||||
"*.json" eol=lf
|
||||
"*.html" eol=lf
|
||||
"*.css" eol=lf
|
||||
"*.less" eol=lf
|
||||
"*.scss" eol=lf
|
||||
"*.sass" eol=lf
|
||||
"*.styl" eol=lf
|
||||
"*.md" eol=lf
|
@ -0,0 +1,41 @@
|
||||
name: build_docker
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [main]
|
||||
release:
|
||||
types: [created] # 表示在创建新的 Release 时触发
|
||||
|
||||
jobs:
|
||||
build_docker:
|
||||
name: Build docker
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- run: |
|
||||
echo "本次构建的版本为:${GITHUB_REF_NAME} (但是这个变量目前上下文中无法获取到)"
|
||||
echo 本次构建的版本为:${{ github.ref_name }}
|
||||
env
|
||||
|
||||
- name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v2
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v2
|
||||
- name: Login to DockerHub
|
||||
uses: docker/login-action@v2
|
||||
with:
|
||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||
- name: Build and push
|
||||
id: docker_build
|
||||
uses: docker/build-push-action@v4
|
||||
with:
|
||||
context: .
|
||||
push: true
|
||||
labels: ${{ steps.meta.outputs.labels }}
|
||||
platforms: linux/amd64,linux/arm64
|
||||
tags: |
|
||||
${{ secrets.DOCKERHUB_USERNAME }}/chatgpt-web:${{ github.ref_name }}
|
||||
${{ secrets.DOCKERHUB_USERNAME }}/chatgpt-web:latest
|
@ -0,0 +1,47 @@
|
||||
name: CI
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
|
||||
pull_request:
|
||||
branches:
|
||||
- main
|
||||
|
||||
jobs:
|
||||
lint:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: Set node
|
||||
uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: 18.x
|
||||
|
||||
- name: Setup
|
||||
run: npm i -g @antfu/ni
|
||||
|
||||
- name: Install
|
||||
run: nci
|
||||
|
||||
- name: Lint
|
||||
run: nr lint:fix
|
||||
|
||||
typecheck:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: Set node
|
||||
uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: 18.x
|
||||
|
||||
- name: Setup
|
||||
run: npm i -g @antfu/ni
|
||||
|
||||
- name: Install
|
||||
run: nci
|
||||
|
||||
- name: Typecheck
|
||||
run: nr type-check
|
@ -0,0 +1,22 @@
|
||||
name: Close inactive issues
|
||||
on:
|
||||
schedule:
|
||||
- cron: '30 1 * * *'
|
||||
|
||||
jobs:
|
||||
close-issues:
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
issues: write
|
||||
pull-requests: write
|
||||
steps:
|
||||
- uses: actions/stale@v5
|
||||
with:
|
||||
days-before-issue-stale: 10
|
||||
days-before-issue-close: 2
|
||||
stale-issue-label: stale
|
||||
stale-issue-message: This issue is stale because it has been open for 10 days with no activity.
|
||||
close-issue-message: This issue was closed because it has been inactive for 2 days since being marked as stale.
|
||||
days-before-pr-stale: -1
|
||||
days-before-pr-close: -1
|
||||
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
@ -0,0 +1,32 @@
|
||||
# Logs
|
||||
logs
|
||||
*.log
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
pnpm-debug.log*
|
||||
lerna-debug.log*
|
||||
|
||||
node_modules
|
||||
.DS_Store
|
||||
dist
|
||||
dist-ssr
|
||||
coverage
|
||||
*.local
|
||||
|
||||
/cypress/videos/
|
||||
/cypress/screenshots/
|
||||
|
||||
# Editor directories and files
|
||||
.vscode/*
|
||||
!.vscode/settings.json
|
||||
!.vscode/extensions.json
|
||||
.idea
|
||||
*.suo
|
||||
*.ntvs*
|
||||
*.njsproj
|
||||
*.sln
|
||||
*.sw?
|
||||
|
||||
# Environment variables files
|
||||
/service/.env
|
@ -0,0 +1,4 @@
|
||||
#!/usr/bin/env sh
|
||||
. "$(dirname -- "$0")/_/husky.sh"
|
||||
|
||||
npx --no -- commitlint --edit
|
@ -0,0 +1,4 @@
|
||||
#!/usr/bin/env sh
|
||||
. "$(dirname -- "$0")/_/husky.sh"
|
||||
|
||||
npx lint-staged
|
@ -0,0 +1,3 @@
|
||||
{
|
||||
"recommendations": ["Vue.volar", "dbaeumer.vscode-eslint"]
|
||||
}
|
@ -0,0 +1,65 @@
|
||||
{
|
||||
"prettier.enable": false,
|
||||
"editor.formatOnSave": false,
|
||||
"editor.codeActionsOnSave": {
|
||||
"source.fixAll.eslint": true
|
||||
},
|
||||
"eslint.validate": [
|
||||
"javascript",
|
||||
"javascriptreact",
|
||||
"typescript",
|
||||
"typescriptreact",
|
||||
"vue",
|
||||
"html",
|
||||
"json",
|
||||
"jsonc",
|
||||
"json5",
|
||||
"yaml",
|
||||
"yml",
|
||||
"markdown"
|
||||
],
|
||||
"cSpell.words": [
|
||||
"antfu",
|
||||
"axios",
|
||||
"bumpp",
|
||||
"chatgpt",
|
||||
"chenzhaoyu",
|
||||
"commitlint",
|
||||
"davinci",
|
||||
"dockerhub",
|
||||
"esno",
|
||||
"GPTAPI",
|
||||
"highlightjs",
|
||||
"hljs",
|
||||
"iconify",
|
||||
"katex",
|
||||
"katexmath",
|
||||
"linkify",
|
||||
"logprobs",
|
||||
"mdhljs",
|
||||
"mila",
|
||||
"nodata",
|
||||
"OPENAI",
|
||||
"pinia",
|
||||
"Popconfirm",
|
||||
"rushstack",
|
||||
"Sider",
|
||||
"tailwindcss",
|
||||
"traptitech",
|
||||
"tsup",
|
||||
"Typecheck",
|
||||
"unplugin",
|
||||
"VITE",
|
||||
"vueuse",
|
||||
"Zhao"
|
||||
],
|
||||
"i18n-ally.enabledParsers": [
|
||||
"ts"
|
||||
],
|
||||
"i18n-ally.sortKeys": true,
|
||||
"i18n-ally.keepFulfilled": true,
|
||||
"i18n-ally.localesPaths": [
|
||||
"src/locales"
|
||||
],
|
||||
"i18n-ally.keystyle": "nested"
|
||||
}
|
@ -0,0 +1,49 @@
|
||||
# Contribution Guide
|
||||
Thank you for your valuable time. Your contributions will make this project better! Before submitting a contribution, please take some time to read the getting started guide below.
|
||||
|
||||
## Semantic Versioning
|
||||
This project follows semantic versioning. We release patch versions for important bug fixes, minor versions for new features or non-important changes, and major versions for significant and incompatible changes.
|
||||
|
||||
Each major change will be recorded in the `changelog`.
|
||||
|
||||
## Submitting Pull Request
|
||||
1. Fork [this repository](https://github.com/Chanzhaoyu/chatgpt-web) and create a branch from `main`. For new feature implementations, submit a pull request to the `feature` branch. For other changes, submit to the `main` branch.
|
||||
2. Install the `pnpm` tool using `npm install pnpm -g`.
|
||||
3. Install the `Eslint` plugin for `VSCode`, or enable `eslint` functionality for other editors such as `WebStorm`.
|
||||
4. Execute `pnpm bootstrap` in the root directory.
|
||||
5. Execute `pnpm install` in the `/service/` directory.
|
||||
6. Make changes to the codebase. If applicable, ensure that appropriate testing has been done.
|
||||
7. Execute `pnpm lint:fix` in the root directory to perform a code formatting check.
|
||||
8. Execute `pnpm type-check` in the root directory to perform a type check.
|
||||
9. Submit a git commit, following the [Commit Guidelines](#commit-guidelines).
|
||||
10. Submit a `pull request`. If there is a corresponding `issue`, please link it using the [linking-a-pull-request-to-an-issue keyword](https://docs.github.com/en/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue#linking-a-pull-request-to-an-issue-using-a-keyword).
|
||||
|
||||
## Commit Guidelines
|
||||
|
||||
Commit messages should follow the [conventional-changelog standard](https://www.conventionalcommits.org/en/v1.0.0/):
|
||||
|
||||
```bash
|
||||
<type>[optional scope]: <description>
|
||||
|
||||
[optional body]
|
||||
|
||||
[optional footer]
|
||||
```
|
||||
|
||||
### Commit Types
|
||||
|
||||
The following is a list of commit types:
|
||||
|
||||
- feat: New feature or functionality
|
||||
- fix: Bug fix
|
||||
- docs: Documentation update
|
||||
- style: Code style or component style update
|
||||
- refactor: Code refactoring, no new features or bug fixes introduced
|
||||
- perf: Performance optimization
|
||||
- test: Unit test
|
||||
- chore: Other commits that do not modify src or test files
|
||||
|
||||
|
||||
## License
|
||||
|
||||
[MIT](./license)
|
@ -0,0 +1,56 @@
|
||||
# build front-end
|
||||
FROM node:lts-alpine AS frontend
|
||||
|
||||
RUN npm install pnpm -g
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
COPY ./package.json /app
|
||||
|
||||
COPY ./pnpm-lock.yaml /app
|
||||
|
||||
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
|
||||
FROM node:lts-alpine
|
||||
|
||||
RUN npm install pnpm -g
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
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
|
||||
|
||||
CMD ["pnpm", "run", "prod"]
|
@ -0,0 +1,359 @@
|
||||
# ChatGPT Web
|
||||
|
||||
> Disclaimer: This project is only published on GitHub, based on the MIT license, free and for open source learning usage. And there will be no any form of account selling, paid service, discussion group, discussion group and other behaviors. Beware of being deceived.
|
||||
|
||||
[中文](README.zh.md)
|
||||
|
||||
![cover](./docs/c1.png)
|
||||
![cover2](./docs/c2.png)
|
||||
|
||||
- [ChatGPT Web](#chatgpt-web)
|
||||
- [Introduction](#introduction)
|
||||
- [To-Do List](#to-do-list)
|
||||
- [Prerequisites](#prerequisites)
|
||||
- [Node](#node)
|
||||
- [PNPM](#pnpm)
|
||||
- [Fill in Keys](#fill-in-keys)
|
||||
- [Install Dependencies](#install-dependencies)
|
||||
- [Backend](#backend)
|
||||
- [Frontend](#frontend)
|
||||
- [Run in Test Environment](#run-in-test-environment)
|
||||
- [Backend Service](#backend-service)
|
||||
- [Frontend Webpage](#frontend-webpage)
|
||||
- [Environment Variables](#environment-variables)
|
||||
- [Packaging](#packaging)
|
||||
- [Use Docker](#use-docker)
|
||||
- [Docker Parameter Examples](#docker-parameter-examples)
|
||||
- [Docker Build & Run](#docker-build--run)
|
||||
- [Docker Compose](#docker-compose)
|
||||
- [Prevent Crawlers](#prevent-crawlers)
|
||||
- [Deploy with Railway](#deploy-with-railway)
|
||||
- [Railway Environment Variables](#railway-environment-variables)
|
||||
- [Deploy with Sealos](#deploy-with-sealos)
|
||||
- [Package Manually](#package-manually)
|
||||
- [Backend Service](#backend-service-1)
|
||||
- [Frontend Webpage](#frontend-webpage-1)
|
||||
- [FAQ](#faq)
|
||||
- [Contributing](#contributing)
|
||||
- [Sponsors](#sponsors)
|
||||
- [License](#license)
|
||||
## Introduction
|
||||
|
||||
Supports dual models and provides two unofficial `ChatGPT API` methods
|
||||
|
||||
| Method | Free? | Reliability | Quality |
|
||||
| ---------------------------------- | ----- | ----------- | ------- |
|
||||
| `ChatGPTAPI(gpt-3.5-turbo-0301)` | No | Reliable | Relatively stupid |
|
||||
| `ChatGPTUnofficialProxyAPI(web accessToken)` | Yes | Relatively unreliable | Smart |
|
||||
|
||||
Comparison:
|
||||
1. `ChatGPTAPI` uses `gpt-3.5-turbo` through `OpenAI` official `API` to call `ChatGPT`
|
||||
2. `ChatGPTUnofficialProxyAPI` uses unofficial proxy server to access `ChatGPT`'s backend `API`, bypass `Cloudflare` (dependent on third-party servers, and has rate limits)
|
||||
|
||||
Warnings:
|
||||
1. You should first use the `API` method
|
||||
2. When using the `API`, if the network is not working, it is blocked in China, you need to build your own proxy, never use someone else's public proxy, which is dangerous.
|
||||
3. When using the `accessToken` method, the reverse proxy will expose your access token to third parties. This should not have any adverse effects, but please consider the risks before using this method.
|
||||
4. When using `accessToken`, whether you are a domestic or foreign machine, proxies will be used. The default proxy is [pengzhile](https://github.com/pengzhile)'s `https://ai.fakeopen.com/api/conversation`. This is not a backdoor or monitoring unless you have the ability to flip over `CF` verification yourself. Use beforehand acknowledge. [Community Proxy](https://github.com/transitive-bullshit/chatgpt-api#reverse-proxy) (Note: Only these two are recommended, other third-party sources, please identify for yourself)
|
||||
5. When publishing the project to public network, you should set the `AUTH_SECRET_KEY` variable to add your password access, you should also modify the `title` in `index. html` to prevent it from being searched by keywords.
|
||||
|
||||
Switching methods:
|
||||
1. Enter the `service/.env.example` file, copy the contents to the `service/.env` file
|
||||
2. To use `OpenAI API Key`, fill in the `OPENAI_API_KEY` field [(get apiKey)](https://platform.openai.com/overview)
|
||||
3. To use `Web API`, fill in the `OPENAI_ACCESS_TOKEN` field [(get accessToken)](https://chat.openai.com/api/auth/session)
|
||||
4. `OpenAI API Key` takes precedence when both exist
|
||||
|
||||
Environment variables:
|
||||
|
||||
See all parameter variables [here](#environment-variables)
|
||||
|
||||
## Roadmap
|
||||
[✓] Dual models
|
||||
|
||||
[✓] Multi-session storage and context logic
|
||||
|
||||
[✓] Formatting and beautification of code and other message types
|
||||
|
||||
[✓] Access control
|
||||
|
||||
[✓] Data import/export
|
||||
|
||||
[✓] Save messages as local images
|
||||
|
||||
[✓] Multilingual interface
|
||||
|
||||
[✓] Interface themes
|
||||
|
||||
[✗] More...
|
||||
|
||||
## Prerequisites
|
||||
|
||||
### Node
|
||||
|
||||
`node` requires version `^16 || ^18 || ^19` (`node >= 14` needs [fetch polyfill](https://github.com/developit/unfetch#usage-as-a-polyfill) installation), use [nvm](https://github.com/nvm-sh/nvm) to manage multiple local `node` versions
|
||||
|
||||
```shell
|
||||
node -v
|
||||
```
|
||||
|
||||
### PNPM
|
||||
If you haven't installed `pnpm`
|
||||
```shell
|
||||
npm install pnpm -g
|
||||
```
|
||||
|
||||
### Filling in the Key
|
||||
Get `Openai Api Key` or `accessToken` and fill in the local environment variables [Go to Introduction](#introduction)
|
||||
|
||||
```
|
||||
# service/.env file
|
||||
|
||||
# OpenAI API Key - https://platform.openai.com/overview
|
||||
OPENAI_API_KEY=
|
||||
|
||||
# change this to an `accessToken` extracted from the ChatGPT site's `https://chat.openai.com/api/auth/session` response
|
||||
OPENAI_ACCESS_TOKEN=
|
||||
```
|
||||
|
||||
## Install Dependencies
|
||||
|
||||
> For the convenience of "backend developers" to understand the burden, the front-end "workspace" mode is not adopted, but separate folders are used to store them. If you only need to do secondary development of the front-end page, delete the `service` folder.
|
||||
|
||||
### Backend
|
||||
|
||||
Enter the folder `/service` and run the following commands
|
||||
|
||||
```shell
|
||||
pnpm install
|
||||
```
|
||||
|
||||
### Frontend
|
||||
Run the following commands at the root directory
|
||||
```shell
|
||||
pnpm bootstrap
|
||||
```
|
||||
|
||||
## Run in Test Environment
|
||||
### Backend Service
|
||||
|
||||
Enter the folder `/service` and run the following commands
|
||||
|
||||
```shell
|
||||
pnpm start
|
||||
```
|
||||
|
||||
### Frontend Webpage
|
||||
Run the following commands at the root directory
|
||||
```shell
|
||||
pnpm dev
|
||||
```
|
||||
|
||||
## Environment Variables
|
||||
|
||||
`API` available:
|
||||
|
||||
- `OPENAI_API_KEY` and `OPENAI_ACCESS_TOKEN` choose one
|
||||
- `OPENAI_API_MODEL` Set model, optional, default: `gpt-3.5-turbo`
|
||||
- `OPENAI_API_BASE_URL` Set interface address, optional, default: `https://api.openai.com`
|
||||
- `OPENAI_API_DISABLE_DEBUG` Set interface to close debug logs, optional, default: empty does not close
|
||||
|
||||
`ACCESS_TOKEN` available:
|
||||
|
||||
- `OPENAI_ACCESS_TOKEN` and `OPENAI_API_KEY` choose one, `OPENAI_API_KEY` takes precedence when both exist
|
||||
- `API_REVERSE_PROXY` Set reverse proxy, optional, default: `https://ai.fakeopen.com/api/conversation`, [Community](https://github.com/transitive-bullshit/chatgpt-api#reverse-proxy) (Note: Only these two are recommended, other third party sources, please identify for yourself)
|
||||
|
||||
Common:
|
||||
|
||||
- `AUTH_SECRET_KEY` Access permission key, optional
|
||||
- `MAX_REQUEST_PER_HOUR` Maximum number of requests per hour, optional, unlimited by default
|
||||
- `TIMEOUT_MS` Timeout, unit milliseconds, optional
|
||||
- `SOCKS_PROXY_HOST` and `SOCKS_PROXY_PORT` take effect together, optional
|
||||
- `SOCKS_PROXY_PORT` and `SOCKS_PROXY_HOST` take effect together, optional
|
||||
- `HTTPS_PROXY` Support `http`, `https`, `socks5`, optional
|
||||
- `ALL_PROXY` Support `http`, `https`, `socks5`, optional
|
||||
|
||||
## Packaging
|
||||
|
||||
### Use Docker
|
||||
|
||||
#### Docker Parameter Examples
|
||||
|
||||
![docker](./docs/docker.png)
|
||||
|
||||
#### Docker build & Run
|
||||
|
||||
```bash
|
||||
docker build -t chatgpt-web .
|
||||
|
||||
# Foreground running
|
||||
docker run --name chatgpt-web --rm -it -p 127.0.0.1:3002:3002 --env OPENAI_API_KEY=your_api_key chatgpt-web
|
||||
|
||||
# Background running
|
||||
docker run --name chatgpt-web -d -p 127.0.0.1:3002:3002 --env OPENAI_API_KEY=your_api_key chatgpt-web
|
||||
|
||||
# Run address
|
||||
http://localhost:3002/
|
||||
```
|
||||
|
||||
#### Docker compose
|
||||
|
||||
[Hub address](https://hub.docker.com/repository/docker/chenzhaoyu94/chatgpt-web/general)
|
||||
|
||||
```yml
|
||||
version: '3'
|
||||
|
||||
services:
|
||||
app:
|
||||
image: chenzhaoyu94/chatgpt-web # always use latest, pull the tag image again to update
|
||||
ports:
|
||||
- 127.0.0.1:3002:3002
|
||||
environment:
|
||||
# choose one
|
||||
OPENAI_API_KEY: sk-xxx
|
||||
# choose one
|
||||
OPENAI_ACCESS_TOKEN: xxx
|
||||
# API interface address, optional, available when OPENAI_API_KEY is set
|
||||
OPENAI_API_BASE_URL: xxx
|
||||
# API model, optional, available when OPENAI_API_KEY is set, https://platform.openai.com/docs/models
|
||||
# gpt-4, gpt-4-1106-preview, gpt-4-0314, gpt-4-0613, gpt-4-32k, gpt-4-32k-0314, gpt-4-32k-0613, gpt-3.5-turbo-16k, gpt-3.5-turbo-16k-0613, gpt-3.5-turbo, gpt-3.5-turbo-0301, gpt-3.5-turbo-0613, text-davinci-003, text-davinci-002, code-davinci-002
|
||||
OPENAI_API_MODEL: xxx
|
||||
# reverse proxy, optional
|
||||
API_REVERSE_PROXY: xxx
|
||||
# access permission key, optional
|
||||
AUTH_SECRET_KEY: xxx
|
||||
# maximum number of requests per hour, optional, unlimited by default
|
||||
MAX_REQUEST_PER_HOUR: 0
|
||||
# timeout, unit milliseconds, optional
|
||||
TIMEOUT_MS: 60000
|
||||
# Socks proxy, optional, take effect with SOCKS_PROXY_PORT
|
||||
SOCKS_PROXY_HOST: xxx
|
||||
# Socks proxy port, optional, take effect with SOCKS_PROXY_HOST
|
||||
SOCKS_PROXY_PORT: xxx
|
||||
# HTTPS proxy, optional, support http,https,socks5
|
||||
HTTPS_PROXY: http://xxx:7890
|
||||
```
|
||||
|
||||
- `OPENAI_API_BASE_URL` Optional, available when `OPENAI_API_KEY` is set
|
||||
- `OPENAI_API_MODEL` Optional, available when `OPENAI_API_KEY` is set
|
||||
|
||||
#### Prevent Crawlers
|
||||
|
||||
**nginx**
|
||||
|
||||
Fill in the following configuration in the nginx configuration file to prevent crawlers. You can refer to the `docker-compose/nginx/nginx.conf` file to add anti-crawler methods
|
||||
|
||||
```
|
||||
# Prevent crawlers
|
||||
if ($http_user_agent ~* "360Spider|JikeSpider|Spider|spider|bot|Bot|2345Explorer|curl|wget|webZIP|qihoobot|Baiduspider|Googlebot|Googlebot-Mobile|Googlebot-Image|Mediapartners-Google|Adsbot-Google|Feedfetcher-Google|Yahoo! Slurp|Yahoo! Slurp China|YoudaoBot|Sosospider|Sogou spider|Sogou web spider|MSNBot|ia_archiver|Tomato Bot|NSPlayer|bingbot")
|
||||
{
|
||||
return 403;
|
||||
}
|
||||
```
|
||||
|
||||
### Deploy with Railway
|
||||
|
||||
[![Deploy on Railway](https://railway.app/button.svg)](https://railway.app/new/template/yytmgc)
|
||||
|
||||
#### Railway Environment Variables
|
||||
|
||||
| Environment variable name | Required | Remarks |
|
||||
| --------------------- | ---------------------- | -------------------------------------------------------------------------------------------------- |
|
||||
| `PORT` | Required | Default `3002` |
|
||||
| `AUTH_SECRET_KEY` | Optional | Access permission key |
|
||||
| `MAX_REQUEST_PER_HOUR` | Optional | Maximum number of requests per hour, optional, unlimited by default |
|
||||
| `TIMEOUT_MS` | Optional | Timeout, unit milliseconds |
|
||||
| `OPENAI_API_KEY` | `OpenAI API` choose one | `apiKey` required for `OpenAI API` [(get apiKey)](https://platform.openai.com/overview) |
|
||||
| `OPENAI_ACCESS_TOKEN` | `Web API` choose one | `accessToken` required for `Web API` [(get accessToken)](https://chat.openai.com/api/auth/session) |
|
||||
| `OPENAI_API_BASE_URL` | Optional, available when `OpenAI API` | `API` interface address |
|
||||
| `OPENAI_API_MODEL` | Optional, available when `OpenAI API` | `API` model |
|
||||
| `API_REVERSE_PROXY` | Optional, available when `Web API` | `Web API` reverse proxy address [Details](https://github.com/transitive-bullshit/chatgpt-api#reverse-proxy) |
|
||||
| `SOCKS_PROXY_HOST` | Optional, take effect with `SOCKS_PROXY_PORT` | Socks proxy |
|
||||
| `SOCKS_PROXY_PORT` | Optional, take effect with `SOCKS_PROXY_HOST` | Socks proxy port |
|
||||
| `SOCKS_PROXY_USERNAME` | Optional, take effect with `SOCKS_PROXY_HOST` | Socks proxy username |
|
||||
| `SOCKS_PROXY_PASSWORD` | Optional, take effect with `SOCKS_PROXY_HOST` | Socks proxy password |
|
||||
| `HTTPS_PROXY` | Optional | HTTPS proxy, support http,https, socks5 |
|
||||
| `ALL_PROXY` | Optional | All proxies, support http,https, socks5 |
|
||||
|
||||
> Note: Modifying environment variables on `Railway` will re-`Deploy`
|
||||
|
||||
### Deploy with Sealos
|
||||
|
||||
[![](https://raw.githubusercontent.com/labring-actions/templates/main/Deploy-on-Sealos.svg)](https://cloud.sealos.io/?openapp=system-fastdeploy%3FtemplateName%3Dchatgpt-web)
|
||||
|
||||
> Environment variables are consistent with Docker environment variables
|
||||
|
||||
### Package Manually
|
||||
#### Backend Service
|
||||
> If you don't need the `node` interface of this project, you can omit the following operations
|
||||
|
||||
Copy the `service` folder to the server where you have the `node` service environment.
|
||||
|
||||
```shell
|
||||
# Install
|
||||
pnpm install
|
||||
|
||||
# Pack
|
||||
pnpm build
|
||||
|
||||
# Run
|
||||
pnpm prod
|
||||
```
|
||||
|
||||
PS: It is also okay to run `pnpm start` directly on the server without packing
|
||||
|
||||
#### Frontend Webpage
|
||||
|
||||
1. Modify the `VITE_GLOB_API_URL` field in the `.env` file at the root directory to your actual backend interface address
|
||||
|
||||
2. Run the following commands at the root directory, then copy the files in the `dist` folder to the root directory of your website service
|
||||
|
||||
[Reference](https://cn.vitejs.dev/guide/static -deploy.html#building-the-app)
|
||||
|
||||
```shell
|
||||
pnpm build
|
||||
```
|
||||
|
||||
## FAQ
|
||||
Q: Why does `Git` commit always report errors?
|
||||
|
||||
A: Because there is a commit message verification, please follow the [Commit Guide](./CONTRIBUTING.md)
|
||||
|
||||
Q: Where to change the request interface if only the front-end page is used?
|
||||
|
||||
A: The `VITE_GLOB_API_URL` field in the `.env` file at the root directory.
|
||||
|
||||
Q: All files explode red when saving?
|
||||
|
||||
A: `vscode` please install the recommended plug-ins for the project, or manually install the `Eslint` plug-in.
|
||||
|
||||
Q: No typewriter effect on the front end?
|
||||
|
||||
A: One possible reason is that after Nginx reverse proxy, buffer is turned on, then Nginx will try to buffer some data from the backend before sending it to the browser. Please try adding `proxy_buffering off; ` after the reverse proxy parameter, then reload Nginx. Other web server configurations are similar.
|
||||
|
||||
## Contributing
|
||||
|
||||
Please read the [Contributing Guide](./CONTRIBUTING.md) before contributing
|
||||
|
||||
Thanks to everyone who has contributed!
|
||||
|
||||
<a href="https://github.com/Chanzhaoyu/chatgpt-web/graphs/contributors">
|
||||
<img src="https://contrib.rocks/image?repo=Chanzhaoyu/chatgpt-web" />
|
||||
</a>
|
||||
|
||||
## Sponsors
|
||||
|
||||
If you find this project helpful and can afford it, you can give me a little support. Anyway, thanks for your support~
|
||||
|
||||
<div style="display: flex; gap: 20px;">
|
||||
<div style="text-align: center">
|
||||
<img style="max-width: 100%" src="./docs/wechat.png" alt="WeChat" />
|
||||
<p>WeChat Pay</p>
|
||||
</div>
|
||||
<div style="text-align: center">
|
||||
<img style="max-width: 100%" src="./docs/alipay.png" alt="Alipay" />
|
||||
<p>Alipay</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
## License
|
||||
MIT © [ChenZhaoYu]
|
@ -0,0 +1,14 @@
|
||||
### docker-compose Deployment Tutorial
|
||||
-Put the packaged front-end files in the `nginx/html` directory
|
||||
- ```shell
|
||||
# start up
|
||||
docker-compose up -d
|
||||
```
|
||||
- ```shell
|
||||
# Check the running status
|
||||
docker ps
|
||||
```
|
||||
- ```shell
|
||||
# end run
|
||||
docker-compose down
|
||||
```
|
@ -0,0 +1,47 @@
|
||||
version: '3'
|
||||
|
||||
services:
|
||||
app:
|
||||
container_name: chatgpt-web
|
||||
image: chenzhaoyu94/chatgpt-web # Always use latest, just pull the tag image again when updating
|
||||
ports:
|
||||
- 3002:3002
|
||||
environment:
|
||||
# pick one of two
|
||||
OPENAI_API_KEY:
|
||||
# pick one of two
|
||||
OPENAI_ACCESS_TOKEN:
|
||||
# API interface address, optional, available when OPENAI_API_KEY is set
|
||||
OPENAI_API_BASE_URL:
|
||||
# API model, optional, available when OPENAI_API_KEY is set
|
||||
OPENAI_API_MODEL:
|
||||
# reverse proxy, optional
|
||||
API_REVERSE_PROXY:
|
||||
# Access permission key, optional
|
||||
AUTH_SECRET_KEY:
|
||||
# The maximum number of requests per hour, optional, default unlimited
|
||||
MAX_REQUEST_PER_HOUR: 0
|
||||
# timeout in milliseconds, optional
|
||||
TIMEOUT_MS: 60000
|
||||
# Socks proxy, optional, works with SOCKS_PROXY_PORT
|
||||
SOCKS_PROXY_HOST:
|
||||
# Socks proxy port, optional, effective when combined with SOCKS_PROXY_HOST
|
||||
SOCKS_PROXY_PORT:
|
||||
# Socks proxy username, optional, effective when combined with SOCKS_PROXY_HOST & SOCKS_PROXY_PORT
|
||||
SOCKS_PROXY_USERNAME:
|
||||
# Socks proxy password, optional, effective when combined with SOCKS_PROXY_HOST & SOCKS_PROXY_PORT
|
||||
SOCKS_PROXY_PASSWORD:
|
||||
# HTTPS_PROXY proxy, optional
|
||||
HTTPS_PROXY:
|
||||
nginx:
|
||||
container_name: nginx
|
||||
image: nginx:alpine
|
||||
ports:
|
||||
- '80:80'
|
||||
expose:
|
||||
- '80'
|
||||
volumes:
|
||||
- ./nginx/html:/usr/share/nginx/html
|
||||
- ./nginx/nginx.conf:/etc/nginx/conf.d/default.conf
|
||||
links:
|
||||
- app
|
@ -0,0 +1,27 @@
|
||||
server {
|
||||
listen 80;
|
||||
server_name localhost;
|
||||
charset utf-8;
|
||||
error_page 500 502 503 504 /50x.html;
|
||||
|
||||
# Prevent crawlers from crawling
|
||||
if ($http_user_agent ~* "360Spider|JikeSpider|Spider|spider|bot|Bot|2345Explorer|curl|wget|webZIP|qihoobot|Baiduspider|Googlebot|Googlebot-Mobile|Googlebot-Image|Mediapartners-Google|Adsbot-Google|Feedfetcher-Google|Yahoo! Slurp|Yahoo! Slurp China|YoudaoBot|Sosospider|Sogou spider|Sogou web spider|MSNBot|ia_archiver|Tomato Bot|NSPlayer|bingbot")
|
||||
{
|
||||
return 403;
|
||||
}
|
||||
|
||||
location / {
|
||||
root /usr/share/nginx/html;
|
||||
try_files $uri /index.html;
|
||||
}
|
||||
|
||||
location /api {
|
||||
proxy_set_header X-Real-IP $remote_addr; #Forward user IP
|
||||
proxy_pass http://app:3002;
|
||||
}
|
||||
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header REMOTE-HOST $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
}
|
After Width: | Height: | Size: 61 KiB |
After Width: | Height: | Size: 123 KiB |
After Width: | Height: | Size: 282 KiB |
After Width: | Height: | Size: 96 KiB |
After Width: | Height: | Size: 396 KiB |
After Width: | Height: | Size: 128 KiB |
After Width: | Height: | Size: 78 KiB |
After Width: | Height: | Size: 108 KiB |
After Width: | Height: | Size: 80 KiB |
@ -0,0 +1,83 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<link rel="icon" type="image/svg+xml" href="/favicon.svg">
|
||||
<meta content="yes" name="apple-mobile-web-app-capable"/>
|
||||
<link rel="apple-touch-icon" href="/favicon.ico">
|
||||
<meta name="viewport"
|
||||
content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, viewport-fit=cover" />
|
||||
<title>ChatGPT Web</title>
|
||||
</head>
|
||||
|
||||
<body class="dark:bg-black">
|
||||
<div id="app">
|
||||
<style>
|
||||
.loading-wrap {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
height: 100vh;
|
||||
}
|
||||
|
||||
.balls {
|
||||
width: 4em;
|
||||
display: flex;
|
||||
flex-flow: row nowrap;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
}
|
||||
|
||||
.balls div {
|
||||
width: 0.8em;
|
||||
height: 0.8em;
|
||||
border-radius: 50%;
|
||||
background-color: #4b9e5f;
|
||||
}
|
||||
|
||||
.balls div:nth-of-type(1) {
|
||||
transform: translateX(-100%);
|
||||
animation: left-swing 0.5s ease-in alternate infinite;
|
||||
}
|
||||
|
||||
.balls div:nth-of-type(3) {
|
||||
transform: translateX(-95%);
|
||||
animation: right-swing 0.5s ease-out alternate infinite;
|
||||
}
|
||||
|
||||
@keyframes left-swing {
|
||||
|
||||
50%,
|
||||
100% {
|
||||
transform: translateX(95%);
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes right-swing {
|
||||
50% {
|
||||
transform: translateX(-95%);
|
||||
}
|
||||
|
||||
100% {
|
||||
transform: translateX(100%);
|
||||
}
|
||||
}
|
||||
|
||||
@media (prefers-color-scheme: dark) {
|
||||
body {
|
||||
background: #121212;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
<div class="loading-wrap">
|
||||
<div class="balls">
|
||||
<div></div>
|
||||
<div></div>
|
||||
<div></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script type="module" src="/src/main.ts"></script>
|
||||
</body>
|
||||
|
||||
</html>
|
@ -0,0 +1,9 @@
|
||||
## 增加一个Kubernetes的部署方式
|
||||
```
|
||||
kubectl apply -f deploy.yaml
|
||||
```
|
||||
|
||||
### 如果需要Ingress域名接入
|
||||
```
|
||||
kubectl apply -f ingress.yaml
|
||||
```
|
@ -0,0 +1,66 @@
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: chatgpt-web
|
||||
labels:
|
||||
app: chatgpt-web
|
||||
spec:
|
||||
replicas: 1
|
||||
selector:
|
||||
matchLabels:
|
||||
app: chatgpt-web
|
||||
strategy:
|
||||
type: RollingUpdate
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: chatgpt-web
|
||||
spec:
|
||||
containers:
|
||||
- image: chenzhaoyu94/chatgpt-web
|
||||
name: chatgpt-web
|
||||
imagePullPolicy: Always
|
||||
ports:
|
||||
- containerPort: 3002
|
||||
env:
|
||||
- name: OPENAI_API_KEY
|
||||
value: sk-xxx
|
||||
- name: OPENAI_API_BASE_URL
|
||||
value: 'https://api.openai.com'
|
||||
- name: OPENAI_API_MODEL
|
||||
value: gpt-3.5-turbo
|
||||
- name: API_REVERSE_PROXY
|
||||
value: https://ai.fakeopen.com/api/conversation
|
||||
- name: AUTH_SECRET_KEY
|
||||
value: '123456'
|
||||
- name: TIMEOUT_MS
|
||||
value: '60000'
|
||||
- name: SOCKS_PROXY_HOST
|
||||
value: ''
|
||||
- name: SOCKS_PROXY_PORT
|
||||
value: ''
|
||||
- name: HTTPS_PROXY
|
||||
value: ''
|
||||
resources:
|
||||
limits:
|
||||
cpu: 500m
|
||||
memory: 500Mi
|
||||
requests:
|
||||
cpu: 300m
|
||||
memory: 300Mi
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
labels:
|
||||
app: chatgpt-web
|
||||
name: chatgpt-web
|
||||
spec:
|
||||
ports:
|
||||
- name: chatgpt-web
|
||||
port: 3002
|
||||
protocol: TCP
|
||||
targetPort: 3002
|
||||
selector:
|
||||
app: chatgpt-web
|
||||
type: ClusterIP
|
@ -0,0 +1,21 @@
|
||||
apiVersion: networking.k8s.io/v1
|
||||
kind: Ingress
|
||||
metadata:
|
||||
annotations:
|
||||
kubernetes.io/ingress.class: nginx
|
||||
nginx.ingress.kubernetes.io/proxy-connect-timeout: '5'
|
||||
name: chatgpt-web
|
||||
spec:
|
||||
rules:
|
||||
- host: chatgpt.example.com
|
||||
http:
|
||||
paths:
|
||||
- backend:
|
||||
service:
|
||||
name: chatgpt-web
|
||||
port:
|
||||
number: 3002
|
||||
path: /
|
||||
pathType: ImplementationSpecific
|
||||
tls:
|
||||
- secretName: chatgpt-web-tls
|
@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2023 ChenZhaoYu
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
@ -0,0 +1,6 @@
|
||||
module.exports = {
|
||||
plugins: {
|
||||
tailwindcss: {},
|
||||
autoprefixer: {},
|
||||
},
|
||||
}
|
After Width: | Height: | Size: 41 KiB |
@ -0,0 +1 @@
|
||||
<svg id="openai-symbol" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32"><path d="M29.71,13.09A8.09,8.09,0,0,0,20.34,2.68a8.08,8.08,0,0,0-13.7,2.9A8.08,8.08,0,0,0,2.3,18.9,8,8,0,0,0,3,25.45a8.08,8.08,0,0,0,8.69,3.87,8,8,0,0,0,6,2.68,8.09,8.09,0,0,0,7.7-5.61,8,8,0,0,0,5.33-3.86A8.09,8.09,0,0,0,29.71,13.09Zm-12,16.82a6,6,0,0,1-3.84-1.39l.19-.11,6.37-3.68a1,1,0,0,0,.53-.91v-9l2.69,1.56a.08.08,0,0,1,.05.07v7.44A6,6,0,0,1,17.68,29.91ZM4.8,24.41a6,6,0,0,1-.71-4l.19.11,6.37,3.68a1,1,0,0,0,1,0l7.79-4.49V22.8a.09.09,0,0,1,0,.08L13,26.6A6,6,0,0,1,4.8,24.41ZM3.12,10.53A6,6,0,0,1,6.28,7.9v7.57a1,1,0,0,0,.51.9l7.75,4.47L11.85,22.4a.14.14,0,0,1-.09,0L5.32,18.68a6,6,0,0,1-2.2-8.18Zm22.13,5.14-7.78-4.52L20.16,9.6a.08.08,0,0,1,.09,0l6.44,3.72a6,6,0,0,1-.9,10.81V16.56A1.06,1.06,0,0,0,25.25,15.67Zm2.68-4-.19-.12-6.36-3.7a1,1,0,0,0-1.05,0l-7.78,4.49V9.2a.09.09,0,0,1,0-.09L19,5.4a6,6,0,0,1,8.91,6.21ZM11.08,17.15,8.38,15.6a.14.14,0,0,1-.05-.08V8.1a6,6,0,0,1,9.84-4.61L18,3.6,11.61,7.28a1,1,0,0,0-.53.91ZM12.54,14,16,12l3.47,2v4L16,20l-3.47-2Z"/></svg>
|
After Width: | Height: | Size: 1.0 KiB |
After Width: | Height: | Size: 7.2 KiB |
After Width: | Height: | Size: 34 KiB |
@ -0,0 +1,22 @@
|
||||
<script setup lang="ts">
|
||||
import { NConfigProvider } from 'naive-ui'
|
||||
import { NaiveProvider } from '@/components/common'
|
||||
import { useTheme } from '@/hooks/useTheme'
|
||||
import { useLanguage } from '@/hooks/useLanguage'
|
||||
|
||||
const { theme, themeOverrides } = useTheme()
|
||||
const { language } = useLanguage()
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<NConfigProvider
|
||||
class="h-full"
|
||||
:theme="theme"
|
||||
:theme-overrides="themeOverrides"
|
||||
:locale="language"
|
||||
>
|
||||
<NaiveProvider>
|
||||
<RouterView />
|
||||
</NaiveProvider>
|
||||
</NConfigProvider>
|
||||
</template>
|
After Width: | Height: | Size: 5.0 KiB |
@ -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"
|
||||
}
|
||||
]
|
@ -0,0 +1,20 @@
|
||||
<script setup lang='ts'>
|
||||
interface Emit {
|
||||
(e: 'click'): void
|
||||
}
|
||||
|
||||
const emit = defineEmits<Emit>()
|
||||
|
||||
function handleClick() {
|
||||
emit('click')
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<button
|
||||
class="flex items-center justify-center w-10 h-10 transition rounded-full hover:bg-neutral-100 dark:hover:bg-[#414755]"
|
||||
@click="handleClick"
|
||||
>
|
||||
<slot />
|
||||
</button>
|
||||
</template>
|
@ -0,0 +1,46 @@
|
||||
<script setup lang='ts'>
|
||||
import { computed } from 'vue'
|
||||
import type { PopoverPlacement } from 'naive-ui'
|
||||
import { NTooltip } from 'naive-ui'
|
||||
import Button from './Button.vue'
|
||||
|
||||
interface Props {
|
||||
tooltip?: string
|
||||
placement?: PopoverPlacement
|
||||
}
|
||||
|
||||
interface Emit {
|
||||
(e: 'click'): void
|
||||
}
|
||||
|
||||
const props = withDefaults(defineProps<Props>(), {
|
||||
tooltip: '',
|
||||
placement: 'bottom',
|
||||
})
|
||||
|
||||
const emit = defineEmits<Emit>()
|
||||
|
||||
const showTooltip = computed(() => Boolean(props.tooltip))
|
||||
|
||||
function handleClick() {
|
||||
emit('click')
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div v-if="showTooltip">
|
||||
<NTooltip :placement="placement" trigger="hover">
|
||||
<template #trigger>
|
||||
<Button @click="handleClick">
|
||||
<slot />
|
||||
</Button>
|
||||
</template>
|
||||
{{ tooltip }}
|
||||
</NTooltip>
|
||||
</div>
|
||||
<div v-else>
|
||||
<Button @click="handleClick">
|
||||
<slot />
|
||||
</Button>
|
||||
</div>
|
||||
</template>
|
@ -0,0 +1,43 @@
|
||||
<script setup lang="ts">
|
||||
import { defineComponent, h } from 'vue'
|
||||
import {
|
||||
NDialogProvider,
|
||||
NLoadingBarProvider,
|
||||
NMessageProvider,
|
||||
NNotificationProvider,
|
||||
useDialog,
|
||||
useLoadingBar,
|
||||
useMessage,
|
||||
useNotification,
|
||||
} from 'naive-ui'
|
||||
|
||||
function registerNaiveTools() {
|
||||
window.$loadingBar = useLoadingBar()
|
||||
window.$dialog = useDialog()
|
||||
window.$message = useMessage()
|
||||
window.$notification = useNotification()
|
||||
}
|
||||
|
||||
const NaiveProviderContent = defineComponent({
|
||||
name: 'NaiveProviderContent',
|
||||
setup() {
|
||||
registerNaiveTools()
|
||||
},
|
||||
render() {
|
||||
return h('div')
|
||||
},
|
||||
})
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<NLoadingBarProvider>
|
||||
<NDialogProvider>
|
||||
<NNotificationProvider>
|
||||
<NMessageProvider>
|
||||
<slot />
|
||||
<NaiveProviderContent />
|
||||
</NMessageProvider>
|
||||
</NNotificationProvider>
|
||||
</NDialogProvider>
|
||||
</NLoadingBarProvider>
|
||||
</template>
|
@ -0,0 +1,70 @@
|
||||
<script lang="ts" setup>
|
||||
import { ref } from 'vue'
|
||||
import { NButton, NInput, NSlider, 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 ?? '')
|
||||
|
||||
const temperature = ref(settingStore.temperature ?? 0.5)
|
||||
|
||||
const top_p = ref(settingStore.top_p ?? 1)
|
||||
|
||||
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-[120px]">{{ $t('setting.role') }}</span>
|
||||
<div class="flex-1">
|
||||
<NInput v-model:value="systemMessage" type="textarea" :autosize="{ minRows: 1, maxRows: 4 }" />
|
||||
</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-[120px]">{{ $t('setting.temperature') }} </span>
|
||||
<div class="flex-1">
|
||||
<NSlider v-model:value="temperature" :max="2" :min="0" :step="0.1" />
|
||||
</div>
|
||||
<span>{{ temperature }}</span>
|
||||
<NButton size="tiny" text type="primary" @click="updateSettings({ temperature })">
|
||||
{{ $t('common.save') }}
|
||||
</NButton>
|
||||
</div>
|
||||
<div class="flex items-center space-x-4">
|
||||
<span class="flex-shrink-0 w-[120px]">{{ $t('setting.top_p') }} </span>
|
||||
<div class="flex-1">
|
||||
<NSlider v-model:value="top_p" :max="1" :min="0" :step="0.1" />
|
||||
</div>
|
||||
<span>{{ top_p }}</span>
|
||||
<NButton size="tiny" text type="primary" @click="updateSettings({ top_p })">
|
||||
{{ $t('common.save') }}
|
||||
</NButton>
|
||||
</div>
|
||||
<div class="flex items-center space-x-4">
|
||||
<span class="flex-shrink-0 w-[120px]"> </span>
|
||||
<NButton size="small" @click="handleReset">
|
||||
{{ $t('common.reset') }}
|
||||
</NButton>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
@ -0,0 +1,227 @@
|
||||
<script lang="ts" setup>
|
||||
import { computed, ref } from 'vue'
|
||||
import { NButton, NInput, NPopconfirm, NSelect, useMessage } from 'naive-ui'
|
||||
import type { Language, Theme } from '@/store/modules/app/helper'
|
||||
import { SvgIcon } from '@/components/common'
|
||||
import { useAppStore, useUserStore } from '@/store'
|
||||
import type { UserInfo } from '@/store/modules/user/helper'
|
||||
import { getCurrentDate } from '@/utils/functions'
|
||||
import { useBasicLayout } from '@/hooks/useBasicLayout'
|
||||
import { t } from '@/locales'
|
||||
|
||||
const appStore = useAppStore()
|
||||
const userStore = useUserStore()
|
||||
|
||||
const { isMobile } = useBasicLayout()
|
||||
|
||||
const ms = useMessage()
|
||||
|
||||
const theme = computed(() => appStore.theme)
|
||||
|
||||
const userInfo = computed(() => userStore.userInfo)
|
||||
|
||||
const avatar = ref(userInfo.value.avatar ?? '')
|
||||
|
||||
const name = ref(userInfo.value.name ?? '')
|
||||
|
||||
const description = ref(userInfo.value.description ?? '')
|
||||
|
||||
const language = computed({
|
||||
get() {
|
||||
return appStore.language
|
||||
},
|
||||
set(value: Language) {
|
||||
appStore.setLanguage(value)
|
||||
},
|
||||
})
|
||||
|
||||
const themeOptions: { label: string; key: Theme; icon: string }[] = [
|
||||
{
|
||||
label: 'Auto',
|
||||
key: 'auto',
|
||||
icon: 'ri:contrast-line',
|
||||
},
|
||||
{
|
||||
label: 'Light',
|
||||
key: 'light',
|
||||
icon: 'ri:sun-foggy-line',
|
||||
},
|
||||
{
|
||||
label: 'Dark',
|
||||
key: 'dark',
|
||||
icon: 'ri:moon-foggy-line',
|
||||
},
|
||||
]
|
||||
|
||||
const languageOptions: { label: string; key: Language; value: Language }[] = [
|
||||
{ label: 'English', key: 'en-US', value: 'en-US' },
|
||||
{ label: 'Español', key: 'es-ES', value: 'es-ES' },
|
||||
{ label: '한국어', key: 'ko-KR', value: 'ko-KR' },
|
||||
{ label: 'Русский язык', key: 'ru-RU', value: 'ru-RU' },
|
||||
{ label: 'Tiếng Việt', key: 'vi-VN', value: 'vi-VN' },
|
||||
{ label: '简体中文', key: 'zh-CN', value: 'zh-CN' },
|
||||
{ label: '繁體中文', key: 'zh-TW', value: 'zh-TW' },
|
||||
]
|
||||
|
||||
function updateUserInfo(options: Partial<UserInfo>) {
|
||||
userStore.updateUserInfo(options)
|
||||
ms.success(t('common.success'))
|
||||
}
|
||||
|
||||
function handleReset() {
|
||||
userStore.resetUserInfo()
|
||||
ms.success(t('common.success'))
|
||||
window.location.reload()
|
||||
}
|
||||
|
||||
function exportData(): void {
|
||||
const date = getCurrentDate()
|
||||
const data: string = localStorage.getItem('chatStorage') || '{}'
|
||||
const jsonString: string = JSON.stringify(JSON.parse(data), null, 2)
|
||||
const blob: Blob = new Blob([jsonString], { type: 'application/json' })
|
||||
const url: string = URL.createObjectURL(blob)
|
||||
const link: HTMLAnchorElement = document.createElement('a')
|
||||
link.href = url
|
||||
link.download = `chat-store_${date}.json`
|
||||
document.body.appendChild(link)
|
||||
link.click()
|
||||
document.body.removeChild(link)
|
||||
}
|
||||
|
||||
function importData(event: Event): void {
|
||||
const target = event.target as HTMLInputElement
|
||||
if (!target || !target.files)
|
||||
return
|
||||
|
||||
const file: File = target.files[0]
|
||||
if (!file)
|
||||
return
|
||||
|
||||
const reader: FileReader = new FileReader()
|
||||
reader.onload = () => {
|
||||
try {
|
||||
const data = JSON.parse(reader.result as string)
|
||||
localStorage.setItem('chatStorage', JSON.stringify(data))
|
||||
ms.success(t('common.success'))
|
||||
location.reload()
|
||||
}
|
||||
catch (error) {
|
||||
ms.error(t('common.invalidFileFormat'))
|
||||
}
|
||||
}
|
||||
reader.readAsText(file)
|
||||
}
|
||||
|
||||
function clearData(): void {
|
||||
localStorage.removeItem('chatStorage')
|
||||
location.reload()
|
||||
}
|
||||
|
||||
function handleImportButtonClick(): void {
|
||||
const fileInput = document.getElementById('fileInput') as HTMLElement
|
||||
if (fileInput)
|
||||
fileInput.click()
|
||||
}
|
||||
</script>
|
||||
|
||||
<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.avatarLink') }}</span>
|
||||
<div class="flex-1">
|
||||
<NInput v-model:value="avatar" placeholder="" />
|
||||
</div>
|
||||
<NButton size="tiny" text type="primary" @click="updateUserInfo({ avatar })">
|
||||
{{ $t('common.save') }}
|
||||
</NButton>
|
||||
</div>
|
||||
<div class="flex items-center space-x-4">
|
||||
<span class="flex-shrink-0 w-[100px]">{{ $t('setting.name') }}</span>
|
||||
<div class="w-[200px]">
|
||||
<NInput v-model:value="name" placeholder="" />
|
||||
</div>
|
||||
<NButton size="tiny" text type="primary" @click="updateUserInfo({ name })">
|
||||
{{ $t('common.save') }}
|
||||
</NButton>
|
||||
</div>
|
||||
<div class="flex items-center space-x-4">
|
||||
<span class="flex-shrink-0 w-[100px]">{{ $t('setting.description') }}</span>
|
||||
<div class="flex-1">
|
||||
<NInput v-model:value="description" placeholder="" />
|
||||
</div>
|
||||
<NButton size="tiny" text type="primary" @click="updateUserInfo({ description })">
|
||||
{{ $t('common.save') }}
|
||||
</NButton>
|
||||
</div>
|
||||
<div
|
||||
class="flex items-center space-x-4"
|
||||
:class="isMobile && 'items-start'"
|
||||
>
|
||||
<span class="flex-shrink-0 w-[100px]">{{ $t('setting.chatHistory') }}</span>
|
||||
|
||||
<div class="flex flex-wrap items-center gap-4">
|
||||
<NButton size="small" @click="exportData">
|
||||
<template #icon>
|
||||
<SvgIcon icon="ri:download-2-fill" />
|
||||
</template>
|
||||
{{ $t('common.export') }}
|
||||
</NButton>
|
||||
|
||||
<input id="fileInput" type="file" style="display:none" @change="importData">
|
||||
<NButton size="small" @click="handleImportButtonClick">
|
||||
<template #icon>
|
||||
<SvgIcon icon="ri:upload-2-fill" />
|
||||
</template>
|
||||
{{ $t('common.import') }}
|
||||
</NButton>
|
||||
|
||||
<NPopconfirm placement="bottom" @positive-click="clearData">
|
||||
<template #trigger>
|
||||
<NButton size="small">
|
||||
<template #icon>
|
||||
<SvgIcon icon="ri:close-circle-line" />
|
||||
</template>
|
||||
{{ $t('common.clear') }}
|
||||
</NButton>
|
||||
</template>
|
||||
{{ $t('chat.clearHistoryConfirm') }}
|
||||
</NPopconfirm>
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex items-center space-x-4">
|
||||
<span class="flex-shrink-0 w-[100px]">{{ $t('setting.theme') }}</span>
|
||||
<div class="flex flex-wrap items-center gap-4">
|
||||
<template v-for="item of themeOptions" :key="item.key">
|
||||
<NButton
|
||||
size="small"
|
||||
:type="item.key === theme ? 'primary' : undefined"
|
||||
@click="appStore.setTheme(item.key)"
|
||||
>
|
||||
<template #icon>
|
||||
<SvgIcon :icon="item.icon" />
|
||||
</template>
|
||||
</NButton>
|
||||
</template>
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex items-center space-x-4">
|
||||
<span class="flex-shrink-0 w-[100px]">{{ $t('setting.language') }}</span>
|
||||
<div class="flex flex-wrap items-center gap-4">
|
||||
<NSelect
|
||||
style="width: 140px"
|
||||
:value="language"
|
||||
:options="languageOptions"
|
||||
@update-value="value => appStore.setLanguage(value)"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex items-center space-x-4">
|
||||
<span class="flex-shrink-0 w-[100px]">{{ $t('setting.resetUserInfo') }}</span>
|
||||
<NButton size="small" @click="handleReset">
|
||||
{{ $t('common.reset') }}
|
||||
</NButton>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
@ -0,0 +1,70 @@
|
||||
<script setup lang='ts'>
|
||||
import { computed, ref } from 'vue'
|
||||
import { NModal, NTabPane, NTabs } from 'naive-ui'
|
||||
import General from './General.vue'
|
||||
import Advanced from './Advanced.vue'
|
||||
import About from './About.vue'
|
||||
import { useAuthStore } from '@/store'
|
||||
import { SvgIcon } from '@/components/common'
|
||||
|
||||
interface Props {
|
||||
visible: boolean
|
||||
}
|
||||
|
||||
interface Emit {
|
||||
(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 show = computed({
|
||||
get() {
|
||||
return props.visible
|
||||
},
|
||||
set(visible: boolean) {
|
||||
emit('update:visible', visible)
|
||||
},
|
||||
})
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<NModal v-model:show="show" :auto-focus="false" preset="card" style="width: 95%; max-width: 640px">
|
||||
<div>
|
||||
<NTabs v-model:value="active" type="line" animated>
|
||||
<NTabPane name="General" tab="General">
|
||||
<template #tab>
|
||||
<SvgIcon class="text-lg" icon="ri:file-user-line" />
|
||||
<span class="ml-2">{{ $t('setting.general') }}</span>
|
||||
</template>
|
||||
<div class="min-h-[100px]">
|
||||
<General />
|
||||
</div>
|
||||
</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">
|
||||
<template #tab>
|
||||
<SvgIcon class="text-lg" icon="ri:list-settings-line" />
|
||||
<span class="ml-2">{{ $t('setting.config') }}</span>
|
||||
</template>
|
||||
<About />
|
||||
</NTabPane>
|
||||
</NTabs>
|
||||
</div>
|
||||
</NModal>
|
||||
</template>
|
@ -0,0 +1,21 @@
|
||||
<script setup lang='ts'>
|
||||
import { computed, useAttrs } from 'vue'
|
||||
import { Icon } from '@iconify/vue'
|
||||
|
||||
interface Props {
|
||||
icon?: string
|
||||
}
|
||||
|
||||
defineProps<Props>()
|
||||
|
||||
const attrs = useAttrs()
|
||||
|
||||
const bindAttrs = computed<{ class: string; style: string }>(() => ({
|
||||
class: (attrs.class as string) || '',
|
||||
style: (attrs.style as string) || '',
|
||||
}))
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Icon :icon="icon || ''" v-bind="bindAttrs" />
|
||||
</template>
|
@ -0,0 +1,40 @@
|
||||
<script setup lang='ts'>
|
||||
import { computed } from 'vue'
|
||||
import { NAvatar } from 'naive-ui'
|
||||
import { useUserStore } from '@/store'
|
||||
import defaultAvatar from '@/assets/avatar.jpg'
|
||||
import { isString } from '@/utils/is'
|
||||
|
||||
const userStore = useUserStore()
|
||||
|
||||
const userInfo = computed(() => userStore.userInfo)
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="flex items-center overflow-hidden">
|
||||
<div class="w-10 h-10 overflow-hidden rounded-full shrink-0">
|
||||
<template v-if="isString(userInfo.avatar) && userInfo.avatar.length > 0">
|
||||
<NAvatar
|
||||
size="large"
|
||||
round
|
||||
:src="userInfo.avatar"
|
||||
:fallback-src="defaultAvatar"
|
||||
/>
|
||||
</template>
|
||||
<template v-else>
|
||||
<NAvatar size="large" round :src="defaultAvatar" />
|
||||
</template>
|
||||
</div>
|
||||
<div class="flex-1 min-w-0 ml-2">
|
||||
<h2 class="overflow-hidden font-bold text-md text-ellipsis whitespace-nowrap">
|
||||
{{ userInfo.name ?? 'ChenZhaoYu' }}
|
||||
</h2>
|
||||
<p class="overflow-hidden text-xs text-gray-500 text-ellipsis whitespace-nowrap">
|
||||
<span
|
||||
v-if="isString(userInfo.description) && userInfo.description !== ''"
|
||||
v-html="userInfo.description"
|
||||
/>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
@ -0,0 +1,8 @@
|
||||
import HoverButton from './HoverButton/index.vue'
|
||||
import NaiveProvider from './NaiveProvider/index.vue'
|
||||
import SvgIcon from './SvgIcon/index.vue'
|
||||
import UserAvatar from './UserAvatar/index.vue'
|
||||
import Setting from './Setting/index.vue'
|
||||
import PromptStore from './PromptStore/index.vue'
|
||||
|
||||
export { HoverButton, NaiveProvider, SvgIcon, UserAvatar, Setting, PromptStore }
|
@ -0,0 +1,8 @@
|
||||
<template>
|
||||
<div class="text-neutral-400">
|
||||
<span>Star on</span>
|
||||
<a href="https://github.com/Chanzhaoyu/chatgpt-bot" target="_blank" class="text-blue-500">
|
||||
GitHub
|
||||
</a>
|
||||
</div>
|
||||
</template>
|
@ -0,0 +1,3 @@
|
||||
import GithubSite from './GithubSite.vue'
|
||||
|
||||
export { GithubSite }
|
@ -0,0 +1,8 @@
|
||||
import { breakpointsTailwind, useBreakpoints } from '@vueuse/core'
|
||||
|
||||
export function useBasicLayout() {
|
||||
const breakpoints = useBreakpoints(breakpointsTailwind)
|
||||
const isMobile = breakpoints.smaller('sm')
|
||||
|
||||
return { isMobile }
|
||||
}
|
@ -0,0 +1,36 @@
|
||||
import { h } from 'vue'
|
||||
import { SvgIcon } from '@/components/common'
|
||||
|
||||
export const useIconRender = () => {
|
||||
interface IconConfig {
|
||||
icon?: string
|
||||
color?: string
|
||||
fontSize?: number
|
||||
}
|
||||
|
||||
interface IconStyle {
|
||||
color?: string
|
||||
fontSize?: string
|
||||
}
|
||||
|
||||
const iconRender = (config: IconConfig) => {
|
||||
const { color, fontSize, icon } = config
|
||||
|
||||
const style: IconStyle = {}
|
||||
|
||||
if (color)
|
||||
style.color = color
|
||||
|
||||
if (fontSize)
|
||||
style.fontSize = `${fontSize}px`
|
||||
|
||||
if (!icon)
|
||||
window.console.warn('iconRender: icon is required')
|
||||
|
||||
return () => h(SvgIcon, { icon, style })
|
||||
}
|
||||
|
||||
return {
|
||||
iconRender,
|
||||
}
|
||||
}
|
@ -0,0 +1,32 @@
|
||||
import { computed } from 'vue'
|
||||
import { enUS, esAR, koKR, ruRU, viVN, zhCN, zhTW } from 'naive-ui'
|
||||
import { useAppStore } from '@/store'
|
||||
import { setLocale } from '@/locales'
|
||||
|
||||
export function useLanguage() {
|
||||
const appStore = useAppStore()
|
||||
|
||||
const language = computed(() => {
|
||||
setLocale(appStore.language)
|
||||
switch (appStore.language) {
|
||||
case 'en-US':
|
||||
return enUS
|
||||
case 'es-ES':
|
||||
return esAR
|
||||
case 'ko-KR':
|
||||
return koKR
|
||||
case 'vi-VN':
|
||||
return viVN
|
||||
case 'ru-RU':
|
||||
return ruRU
|
||||
case 'zh-CN':
|
||||
return zhCN
|
||||
case 'zh-TW':
|
||||
return zhTW
|
||||
default:
|
||||
return enUS
|
||||
}
|
||||
})
|
||||
|
||||
return { language }
|
||||
}
|
@ -0,0 +1,43 @@
|
||||
import type { GlobalThemeOverrides } from 'naive-ui'
|
||||
import { computed, watch } from 'vue'
|
||||
import { darkTheme, useOsTheme } from 'naive-ui'
|
||||
import { useAppStore } from '@/store'
|
||||
|
||||
export function useTheme() {
|
||||
const appStore = useAppStore()
|
||||
|
||||
const OsTheme = useOsTheme()
|
||||
|
||||
const isDark = computed(() => {
|
||||
if (appStore.theme === 'auto')
|
||||
return OsTheme.value === 'dark'
|
||||
else
|
||||
return appStore.theme === 'dark'
|
||||
})
|
||||
|
||||
const theme = computed(() => {
|
||||
return isDark.value ? darkTheme : undefined
|
||||
})
|
||||
|
||||
const themeOverrides = computed<GlobalThemeOverrides>(() => {
|
||||
if (isDark.value) {
|
||||
return {
|
||||
common: {},
|
||||
}
|
||||
}
|
||||
return {}
|
||||
})
|
||||
|
||||
watch(
|
||||
() => isDark.value,
|
||||
(dark) => {
|
||||
if (dark)
|
||||
document.documentElement.classList.add('dark')
|
||||
else
|
||||
document.documentElement.classList.remove('dark')
|
||||
},
|
||||
{ immediate: true },
|
||||
)
|
||||
|
||||
return { theme, themeOverrides }
|
||||
}
|
After Width: | Height: | Size: 28 KiB |
@ -0,0 +1,101 @@
|
||||
export default {
|
||||
common: {
|
||||
add: 'Add',
|
||||
addSuccess: 'Add Success',
|
||||
edit: 'Edit',
|
||||
editSuccess: 'Edit Success',
|
||||
delete: 'Delete',
|
||||
deleteSuccess: 'Delete Success',
|
||||
save: 'Save',
|
||||
saveSuccess: 'Save Success',
|
||||
reset: 'Reset',
|
||||
action: 'Action',
|
||||
export: 'Export',
|
||||
exportSuccess: 'Export Success',
|
||||
import: 'Import',
|
||||
importSuccess: 'Import Success',
|
||||
clear: 'Clear',
|
||||
clearSuccess: 'Clear Success',
|
||||
yes: 'Yes',
|
||||
no: 'No',
|
||||
confirm: 'Confirm',
|
||||
download: 'Download',
|
||||
noData: 'No Data',
|
||||
wrong: 'Something went wrong, please try again later.',
|
||||
success: 'Success',
|
||||
failed: 'Failed',
|
||||
verify: 'Verify',
|
||||
unauthorizedTips: 'Unauthorized, please verify first.',
|
||||
stopResponding: 'Stop Responding',
|
||||
},
|
||||
chat: {
|
||||
newChatButton: 'New Chat',
|
||||
newChatTitle: 'New Chat',
|
||||
placeholder: 'Ask me anything...(Shift + Enter = line break, "/" to trigger prompts)',
|
||||
placeholderMobile: 'Ask me anything...',
|
||||
copy: 'Copy',
|
||||
copied: 'Copied',
|
||||
copyCode: 'Copy Code',
|
||||
copyFailed: 'Copy Failed',
|
||||
clearChat: 'Clear Chat',
|
||||
clearChatConfirm: 'Are you sure to clear this chat?',
|
||||
exportImage: 'Export Image',
|
||||
exportImageConfirm: 'Are you sure to export this chat to png?',
|
||||
exportSuccess: 'Export Success',
|
||||
exportFailed: 'Export Failed',
|
||||
usingContext: 'Context Mode',
|
||||
turnOnContext: 'In the current mode, sending messages will carry previous chat records.',
|
||||
turnOffContext: 'In the current mode, sending messages will not carry previous chat records.',
|
||||
deleteMessage: 'Delete Message',
|
||||
deleteMessageConfirm: 'Are you sure to delete this message?',
|
||||
deleteHistoryConfirm: 'Are you sure to clear this history?',
|
||||
clearHistoryConfirm: 'Are you sure to clear chat history?',
|
||||
preview: 'Preview',
|
||||
showRawText: 'Show as raw text',
|
||||
thinking: 'Thinking...',
|
||||
},
|
||||
setting: {
|
||||
setting: 'Setting',
|
||||
general: 'General',
|
||||
advanced: 'Advanced',
|
||||
config: 'Config',
|
||||
avatarLink: 'Avatar Link',
|
||||
name: 'Name',
|
||||
description: 'Description',
|
||||
role: 'Role',
|
||||
temperature: 'Temperature',
|
||||
top_p: 'Top_p',
|
||||
resetUserInfo: 'Reset UserInfo',
|
||||
chatHistory: 'ChatHistory',
|
||||
theme: 'Theme',
|
||||
language: 'Language',
|
||||
api: 'API',
|
||||
reverseProxy: 'Reverse Proxy',
|
||||
timeout: 'Timeout',
|
||||
socks: 'Socks',
|
||||
httpsProxy: 'HTTPS Proxy',
|
||||
balance: 'API Balance',
|
||||
monthlyUsage: 'Monthly Usage',
|
||||
openSource: 'This project is open sourced at',
|
||||
freeMIT: 'free and based on the MIT license, without any form of paid behavior!',
|
||||
stars: 'If you find this project helpful, please give me a Star on GitHub or give a little sponsorship, thank you!',
|
||||
},
|
||||
store: {
|
||||
siderButton: 'Prompt 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',
|
||||
},
|
||||
}
|
@ -0,0 +1,100 @@
|
||||
export default {
|
||||
common: {
|
||||
add: 'Agregar',
|
||||
addSuccess: 'Agregado con éxito',
|
||||
edit: 'Editar',
|
||||
editSuccess: 'Edición exitosa',
|
||||
delete: 'Borrar',
|
||||
deleteSuccess: 'Borrado con éxito',
|
||||
save: 'Guardar',
|
||||
saveSuccess: 'Guardado con éxito',
|
||||
reset: 'Reiniciar',
|
||||
action: 'Acción',
|
||||
export: 'Exportar',
|
||||
exportSuccess: 'Exportación exitosa',
|
||||
import: 'Importar',
|
||||
importSuccess: 'Importación exitosa',
|
||||
clear: 'Limpiar',
|
||||
clearSuccess: 'Limpieza exitosa',
|
||||
yes: 'Sí',
|
||||
no: 'No',
|
||||
confirm: 'Confirmar',
|
||||
download: 'Descargar',
|
||||
noData: 'Sin datos',
|
||||
wrong: 'Algo salió mal, inténtalo de nuevo más tarde.',
|
||||
success: 'Exitoso',
|
||||
failed: 'Fallido',
|
||||
verify: 'Verificar',
|
||||
unauthorizedTips: 'No autorizado, por favor verifique primero.',
|
||||
stopResponding: 'No responde',
|
||||
},
|
||||
chat: {
|
||||
newChatButton: 'Nueva conversación',
|
||||
newChatTitle: 'Nueva conversación',
|
||||
placeholder: 'Pregúntame lo que sea...(Shift + Enter = salto de línea, "/" para activar avisos)',
|
||||
placeholderMobile: 'Pregúntame lo que sea...',
|
||||
copy: 'Copiar',
|
||||
copied: 'Copiado',
|
||||
copyCode: 'Copiar código',
|
||||
copyFailed: 'Copia fallida',
|
||||
clearChat: 'Limpiar chat',
|
||||
clearChatConfirm: '¿Estás seguro de borrar este chat?',
|
||||
exportImage: 'Exportar imagen',
|
||||
exportImageConfirm: '¿Estás seguro de exportar este chat a png?',
|
||||
exportSuccess: 'Exportación exitosa',
|
||||
exportFailed: 'Exportación fallida',
|
||||
usingContext: 'Modo de contexto',
|
||||
turnOnContext: 'En el modo actual, el envío de mensajes llevará registros de chat anteriores.',
|
||||
turnOffContext: 'En el modo actual, el envío de mensajes no incluirá registros de conversaciones anteriores.',
|
||||
deleteMessage: 'Borrar mensaje',
|
||||
deleteMessageConfirm: '¿Estás seguro de eliminar este mensaje?',
|
||||
deleteHistoryConfirm: '¿Estás seguro de borrar esta historia?',
|
||||
clearHistoryConfirm: '¿Estás seguro de borrar el historial de chat?',
|
||||
preview: 'Avance',
|
||||
showRawText: 'Mostrar como texto sin formato',
|
||||
},
|
||||
setting: {
|
||||
setting: 'Configuración',
|
||||
general: 'General',
|
||||
advanced: 'Avanzado',
|
||||
config: 'Configurar',
|
||||
avatarLink: 'Enlace de avatar',
|
||||
name: 'Nombre',
|
||||
description: 'Descripción',
|
||||
role: 'Rol',
|
||||
temperature: 'Temperatura',
|
||||
top_p: 'Top_p',
|
||||
resetUserInfo: 'Restablecer información de usuario',
|
||||
chatHistory: 'Historial de chat',
|
||||
theme: 'Tema',
|
||||
language: 'Idioma',
|
||||
api: 'API',
|
||||
reverseProxy: 'Reverse Proxy',
|
||||
timeout: 'Tiempo de espera',
|
||||
socks: 'Socks',
|
||||
httpsProxy: 'HTTPS Proxy',
|
||||
balance: 'Saldo de API',
|
||||
monthlyUsage: 'Uso mensual de API',
|
||||
openSource: 'Este proyecto es de código abierto en',
|
||||
freeMIT: 'gratis y basado en la licencia MIT, ¡sin ningún tipo de comportamiento de pago!',
|
||||
stars: 'Si encuentras este proyecto útil, por favor dame una Estrella en GitHub o da un pequeño patrocinio, ¡gracias!',
|
||||
},
|
||||
store: {
|
||||
siderButton: 'Tienda rápida',
|
||||
local: 'Local',
|
||||
online: 'En línea',
|
||||
title: 'Título',
|
||||
description: 'Descripción',
|
||||
clearStoreConfirm: '¿Estás seguro de borrar los datos?',
|
||||
importPlaceholder: 'Pegue los datos JSON aquí',
|
||||
addRepeatTitleTips: 'Título duplicado, vuelva a ingresar',
|
||||
addRepeatContentTips: 'Contenido duplicado: {msg}, por favor vuelva a entrar',
|
||||
editRepeatTitleTips: 'Conflicto de título, revíselo',
|
||||
editRepeatContentTips: 'Conflicto de contenido {msg} , por favor vuelva a modificar',
|
||||
importError: 'Discrepancia de valor clave',
|
||||
importRepeatTitle: 'Título saltado repetidamente: {msg}',
|
||||
importRepeatContent: 'El contenido se salta repetidamente: {msg}',
|
||||
onlineImportWarning: 'Nota: ¡Compruebe la fuente del archivo JSON!',
|
||||
downloadError: 'Verifique el estado de la red y la validez del archivo JSON',
|
||||
},
|
||||
}
|
@ -0,0 +1,42 @@
|
||||
import type { App } from 'vue'
|
||||
import { createI18n } from 'vue-i18n'
|
||||
import enUS from './en-US'
|
||||
import esES from './es-ES'
|
||||
import koKR from './ko-KR'
|
||||
import ruRU from './ru-RU'
|
||||
import viVN from './vi-VN'
|
||||
import zhCN from './zh-CN'
|
||||
import zhTW from './zh-TW'
|
||||
import { useAppStoreWithOut } from '@/store/modules/app'
|
||||
import type { Language } from '@/store/modules/app/helper'
|
||||
|
||||
const appStore = useAppStoreWithOut()
|
||||
|
||||
const defaultLocale = appStore.language || 'zh-CN'
|
||||
|
||||
const i18n = createI18n({
|
||||
locale: defaultLocale,
|
||||
fallbackLocale: 'en-US',
|
||||
allowComposition: true,
|
||||
messages: {
|
||||
'en-US': enUS,
|
||||
'es-ES': esES,
|
||||
'ko-KR': koKR,
|
||||
'ru-RU': ruRU,
|
||||
'vi-VN': viVN,
|
||||
'zh-CN': zhCN,
|
||||
'zh-TW': zhTW,
|
||||
},
|
||||
})
|
||||
|
||||
export const t = i18n.global.t
|
||||
|
||||
export function setLocale(locale: Language) {
|
||||
i18n.global.locale = locale
|
||||
}
|
||||
|
||||
export function setupI18n(app: App) {
|
||||
app.use(i18n)
|
||||
}
|
||||
|
||||
export default i18n
|
@ -0,0 +1,100 @@
|
||||
export default {
|
||||
common: {
|
||||
add: '추가',
|
||||
addSuccess: '추가 성공',
|
||||
edit: '편집',
|
||||
editSuccess: '편집 성공',
|
||||
delete: '삭제',
|
||||
deleteSuccess: '삭제 성공',
|
||||
save: '저장',
|
||||
saveSuccess: '저장 성공',
|
||||
reset: '초기화',
|
||||
action: '액션',
|
||||
export: '내보내기',
|
||||
exportSuccess: '내보내기 성공',
|
||||
import: '가져오기',
|
||||
importSuccess: '가져오기 성공',
|
||||
clear: '비우기',
|
||||
clearSuccess: '비우기 성공',
|
||||
yes: '예',
|
||||
no: '아니오',
|
||||
confirm: '확인',
|
||||
download: '다운로드',
|
||||
noData: '데이터 없음',
|
||||
wrong: '문제가 발생했습니다. 나중에 다시 시도하십시오.',
|
||||
success: '성공',
|
||||
failed: '실패',
|
||||
verify: '검증',
|
||||
unauthorizedTips: '인증되지 않았습니다. 먼저 확인하십시오.',
|
||||
stopResponding: '응답 중지',
|
||||
},
|
||||
chat: {
|
||||
newChatButton: '새로운 채팅',
|
||||
newChatTitle: '새로운 채팅',
|
||||
placeholder: '무엇이든 물어보세요...(Shift + Enter = 줄바꿈, "/"를 눌러서 힌트를 보세요)',
|
||||
placeholderMobile: '무엇이든 물어보세요...',
|
||||
copy: '복사',
|
||||
copied: '복사됨',
|
||||
copyCode: '코드 복사',
|
||||
copyFailed: '복사 실패',
|
||||
clearChat: '채팅 비우기',
|
||||
clearChatConfirm: '이 채팅을 비우시겠습니까?',
|
||||
exportImage: '이미지 내보내기',
|
||||
exportImageConfirm: '이 채팅을 png로 내보내시겠습니까?',
|
||||
exportSuccess: '내보내기 성공',
|
||||
exportFailed: '내보내기 실패',
|
||||
usingContext: '컨텍스트 모드',
|
||||
turnOnContext: '현재 모드에서는 이전 대화 기록을 포함하여 메시지를 보낼 수 있습니다.',
|
||||
turnOffContext: '현재 모드에서는 이전 대화 기록을 포함하지 않고 메시지를 보낼 수 있습니다.',
|
||||
deleteMessage: '메시지 삭제',
|
||||
deleteMessageConfirm: '이 메시지를 삭제하시겠습니까?',
|
||||
deleteHistoryConfirm: '이 기록을 삭제하시겠습니까?',
|
||||
clearHistoryConfirm: '채팅 기록을 삭제하시겠습니까?',
|
||||
preview: '미리보기',
|
||||
showRawText: '원본 텍스트로 보기',
|
||||
thinking: '생각 중...',
|
||||
},
|
||||
setting: {
|
||||
setting: '설정',
|
||||
general: '일반',
|
||||
advanced: '고급',
|
||||
config: '설정',
|
||||
avatarLink: '아바타 링크',
|
||||
name: '이름',
|
||||
description: '설명',
|
||||
role: '역할',
|
||||
temperature: '온도',
|
||||
top_p: 'Top_p',
|
||||
resetUserInfo: '사용자 정보 초기화',
|
||||
chatHistory: '채팅 기록',
|
||||
theme: '테마',
|
||||
language: '언어',
|
||||
api: 'API',
|
||||
reverseProxy: '리버스 프록시',
|
||||
timeout: '타임아웃',
|
||||
socks: 'Socks',
|
||||
httpsProxy: 'HTTPS 프록시',
|
||||
balance: 'API 잔액',
|
||||
monthlyUsage: '월 사용량',
|
||||
openSource: '이 프로젝트는 다음에서 오픈 소스로 제공됩니다:',
|
||||
freeMIT: '무료이며 MIT 라이선스에 기반하며, 어떠한 형태의 유료 행동도 없습니다!',
|
||||
stars: '이 프로젝트가 도움이 되었다면, GitHub에서 별을 주거나 조금의 후원을 해주시면 감사하겠습니다!',
|
||||
},
|
||||
store: {
|
||||
siderButton: '프롬프트 저장소',
|
||||
local: '로컬',
|
||||
online: '온라인',
|
||||
title: '제목',
|
||||
description: '설명',
|
||||
clearStoreConfirm: '데이터를 삭제하시겠습니까?',
|
||||
importPlaceholder: '여기에 JSON 데이터를 붙여넣으십시오',
|
||||
addRepeatTitleTips: '제목 중복됨, 다시 입력하십시오',
|
||||
addRepeatContentTips: '내용 중복됨: {msg}, 다시 입력하십시오',
|
||||
editRepeatTitleTips: '제목 충돌, 수정하십시오',
|
||||
editRepeatContentTips: '내용 충돌 {msg} , 수정하십시오',
|
||||
importError: '키 값 불일치',
|
||||
importRepeatTitle: '제목이 반복되어 건너뜀: {msg}',
|
||||
importRepeatContent: '내용이 반복되어 건너뜀: {msg}',
|
||||
onlineImportWarning: '참고: JSON 파일 소스를 확인하십시오!',
|
||||
},
|
||||
}
|
@ -0,0 +1,100 @@
|
||||
export default {
|
||||
common: {
|
||||
add: 'Thêm',
|
||||
addSuccess: 'Thêm thành công',
|
||||
edit: 'Sửa',
|
||||
editSuccess: 'Sửa thành công',
|
||||
delete: 'Xóa',
|
||||
deleteSuccess: 'Xóa thành công',
|
||||
save: 'Lưu',
|
||||
saveSuccess: 'Lưu thành công',
|
||||
reset: 'Đặt lại',
|
||||
action: 'Hành động',
|
||||
export: 'Xuất',
|
||||
exportSuccess: 'Xuất thành công',
|
||||
import: 'Nhập',
|
||||
importSuccess: 'Nhập thành công',
|
||||
clear: 'Dọn dẹp',
|
||||
clearSuccess: 'Dọn dẹp thành công',
|
||||
yes: 'Có',
|
||||
no: 'Không',
|
||||
confirm: 'Xác nhận',
|
||||
download: 'Tải xuống',
|
||||
noData: 'Không có dữ liệu',
|
||||
wrong: 'Đã xảy ra lỗi, vui lòng thử lại sau.',
|
||||
success: 'Thành công',
|
||||
failed: 'Thất bại',
|
||||
verify: 'Xác minh',
|
||||
unauthorizedTips: 'Không được ủy quyền, vui lòng xác minh trước.',
|
||||
},
|
||||
chat: {
|
||||
newChatButton: 'Tạo hội thoại',
|
||||
newChatTitle: 'Tạo hội thoại',
|
||||
placeholder: 'Hỏi tôi bất cứ điều gì...(Shift + Enter = ngắt dòng, "/" to trigger prompts)',
|
||||
placeholderMobile: 'Hỏi tôi bất cứ điều gì...',
|
||||
copy: 'Sao chép',
|
||||
copied: 'Đã sao chép',
|
||||
copyCode: 'Sao chép Code',
|
||||
copyFailed: 'Sao chép thất bại',
|
||||
clearChat: 'Clear Chat',
|
||||
clearChatConfirm: 'Bạn có chắc chắn xóa cuộc trò chuyện này?',
|
||||
exportImage: 'Xuất hình ảnh',
|
||||
exportImageConfirm: 'Bạn có chắc chắn xuất cuộc trò chuyện này sang png không?',
|
||||
exportSuccess: 'Xuất thành công',
|
||||
exportFailed: 'Xuất thất bại',
|
||||
usingContext: 'Context Mode',
|
||||
turnOnContext: 'Ở chế độ hiện tại, việc gửi tin nhắn sẽ mang theo các bản ghi trò chuyện trước đó.',
|
||||
turnOffContext: 'Ở chế độ hiện tại, việc gửi tin nhắn sẽ không mang theo các bản ghi trò chuyện trước đó.',
|
||||
deleteMessage: 'Xóa tin nhắn',
|
||||
deleteMessageConfirm: 'Bạn có chắc chắn xóa tin nhắn này?',
|
||||
deleteHistoryConfirm: 'Bạn có chắc chắn để xóa lịch sử này?',
|
||||
clearHistoryConfirm: 'Bạn có chắc chắn để xóa lịch sử trò chuyện?',
|
||||
preview: 'Xem trước',
|
||||
showRawText: 'Hiển thị dưới dạng văn bản thô',
|
||||
thinking: 'Đang suy nghĩ...',
|
||||
},
|
||||
setting: {
|
||||
setting: 'Cài đặt',
|
||||
general: 'Chung',
|
||||
advanced: 'Nâng cao',
|
||||
config: 'Cấu hình',
|
||||
avatarLink: 'Avatar Link',
|
||||
name: 'Tên',
|
||||
description: 'Miêu tả',
|
||||
role: 'Vai trò',
|
||||
temperature: 'Nhiệt độ',
|
||||
top_p: 'Top_p',
|
||||
resetUserInfo: 'Đặt lại thông tin người dùng',
|
||||
chatHistory: 'Lịch sử trò chuyện',
|
||||
theme: 'Giao diện',
|
||||
language: 'Ngôn ngữ',
|
||||
api: 'API',
|
||||
reverseProxy: 'Reverse Proxy',
|
||||
timeout: 'Timeout',
|
||||
socks: 'Socks',
|
||||
httpsProxy: 'HTTPS Proxy',
|
||||
balance: 'API Balance',
|
||||
monthlyUsage: 'Sử dụng hàng tháng',
|
||||
openSource: 'Dự án này được mở nguồn tại',
|
||||
freeMIT: 'miễn phí và dựa trên giấy phép MIT, không có bất kỳ hình thức hành vi trả phí nào!',
|
||||
stars: 'Nếu bạn thấy dự án này hữu ích, vui lòng cho tôi một Star trên GitHub hoặc tài trợ một chút, cảm ơn bạn!',
|
||||
},
|
||||
store: {
|
||||
siderButton: 'Prompt Store',
|
||||
local: 'Local',
|
||||
online: 'Online',
|
||||
title: 'Tiêu đề',
|
||||
description: 'Miêu tả',
|
||||
clearStoreConfirm: 'Cho dù để xóa dữ liệu?',
|
||||
importPlaceholder: 'Vui lòng dán dữ liệu JSON vào đây',
|
||||
addRepeatTitleTips: 'Tiêu đề trùng lặp, vui lòng nhập lại',
|
||||
addRepeatContentTips: 'Nội dung trùng lặp: {msg}, vui lòng nhập lại',
|
||||
editRepeatTitleTips: 'Xung đột tiêu đề, vui lòng sửa lại',
|
||||
editRepeatContentTips: 'Xung đột nội dung {msg} , vui lòng sửa đổi lại',
|
||||
importError: 'Key value mismatch',
|
||||
importRepeatTitle: 'Tiêu đề liên tục bị bỏ qua: {msg}',
|
||||
importRepeatContent: 'Nội dung liên tục bị bỏ qua: {msg}',
|
||||
onlineImportWarning: 'Lưu ý: Vui lòng kiểm tra nguồn tệp JSON!',
|
||||
downloadError: 'Vui lòng kiểm tra trạng thái mạng và tính hợp lệ của tệp JSON',
|
||||
},
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
import { createApp } from 'vue'
|
||||
import App from './App.vue'
|
||||
import { setupI18n } from './locales'
|
||||
import { setupAssets, setupScrollbarStyle } from './plugins'
|
||||
import { setupStore } from './store'
|
||||
import { setupRouter } from './router'
|
||||
|
||||
async function bootstrap() {
|
||||
const app = createApp(App)
|
||||
setupAssets()
|
||||
|
||||
setupScrollbarStyle()
|
||||
|
||||
setupStore(app)
|
||||
|
||||
setupI18n(app)
|
||||
|
||||
await setupRouter(app)
|
||||
|
||||
app.mount('#app')
|
||||
}
|
||||
|
||||
bootstrap()
|
@ -0,0 +1,18 @@
|
||||
import 'katex/dist/katex.min.css'
|
||||
import '@/styles/lib/tailwind.css'
|
||||
import '@/styles/lib/highlight.less'
|
||||
import '@/styles/lib/github-markdown.less'
|
||||
import '@/styles/global.less'
|
||||
|
||||
/** Tailwind's Preflight Style Override */
|
||||
function naiveStyleOverride() {
|
||||
const meta = document.createElement('meta')
|
||||
meta.name = 'naive-ui-style'
|
||||
document.head.appendChild(meta)
|
||||
}
|
||||
|
||||
function setupAssets() {
|
||||
naiveStyleOverride()
|
||||
}
|
||||
|
||||
export default setupAssets
|
@ -0,0 +1,4 @@
|
||||
import setupAssets from './assets'
|
||||
import setupScrollbarStyle from './scrollbarStyle'
|
||||
|
||||
export { setupAssets, setupScrollbarStyle }
|
@ -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
|
@ -0,0 +1,52 @@
|
||||
import type { App } from 'vue'
|
||||
import type { RouteRecordRaw } from 'vue-router'
|
||||
import { createRouter, createWebHashHistory } from 'vue-router'
|
||||
import { setupPageGuard } from './permission'
|
||||
import { ChatLayout } from '@/views/chat/layout'
|
||||
|
||||
const routes: RouteRecordRaw[] = [
|
||||
{
|
||||
path: '/',
|
||||
name: 'Root',
|
||||
component: ChatLayout,
|
||||
redirect: '/chat',
|
||||
children: [
|
||||
{
|
||||
path: '/chat/:uuid?',
|
||||
name: 'Chat',
|
||||
component: () => import('@/views/chat/index.vue'),
|
||||
},
|
||||
],
|
||||
},
|
||||
|
||||
{
|
||||
path: '/404',
|
||||
name: '404',
|
||||
component: () => import('@/views/exception/404/index.vue'),
|
||||
},
|
||||
|
||||
{
|
||||
path: '/500',
|
||||
name: '500',
|
||||
component: () => import('@/views/exception/500/index.vue'),
|
||||
},
|
||||
|
||||
{
|
||||
path: '/:pathMatch(.*)*',
|
||||
name: 'notFound',
|
||||
redirect: '/404',
|
||||
},
|
||||
]
|
||||
|
||||
export const router = createRouter({
|
||||
history: createWebHashHistory(),
|
||||
routes,
|
||||
scrollBehavior: () => ({ left: 0, top: 0 }),
|
||||
})
|
||||
|
||||
setupPageGuard(router)
|
||||
|
||||
export async function setupRouter(app: App) {
|
||||
app.use(router)
|
||||
await router.isReady()
|
||||
}
|
@ -0,0 +1,3 @@
|
||||
import { createPinia } from 'pinia'
|
||||
|
||||
export const store = createPinia()
|
@ -0,0 +1,8 @@
|
||||
import type { App } from 'vue'
|
||||
import { store } from './helper'
|
||||
|
||||
export function setupStore(app: App) {
|
||||
app.use(store)
|
||||
}
|
||||
|
||||
export * from './modules'
|
@ -0,0 +1,43 @@
|
||||
import { ss } from '@/utils/storage'
|
||||
|
||||
const LOCAL_NAME = 'appSetting'
|
||||
|
||||
export type Theme = 'light' | 'dark' | 'auto'
|
||||
|
||||
export type Language = 'en-US' | 'es-ES' | 'ko-KR' | 'ru-RU' | 'vi-VN' | 'zh-CN' | 'zh-TW'
|
||||
|
||||
const languageMap: { [key: string]: Language } = {
|
||||
'en': 'en-US',
|
||||
'en-US': 'en-US',
|
||||
'es': 'es-ES',
|
||||
'es-ES': 'es-ES',
|
||||
'ko': 'ko-KR',
|
||||
'ko-KR': 'ko-KR',
|
||||
'ru': 'ru-RU',
|
||||
'ru-RU': 'ru-RU',
|
||||
'vi': 'vi-VN',
|
||||
'vi-VN': 'vi-VN',
|
||||
'zh': 'zh-CN',
|
||||
'zh-CN': 'zh-CN',
|
||||
'zh-TW': 'zh-TW',
|
||||
}
|
||||
|
||||
export interface AppState {
|
||||
siderCollapsed: boolean
|
||||
theme: Theme
|
||||
language: Language
|
||||
}
|
||||
|
||||
export function defaultSetting(): AppState {
|
||||
const language = languageMap[navigator.language]
|
||||
return { siderCollapsed: false, theme: 'light', language }
|
||||
}
|
||||
|
||||
export function getLocalSetting(): AppState {
|
||||
const localSetting: AppState | undefined = ss.get(LOCAL_NAME)
|
||||
return { ...defaultSetting(), ...localSetting }
|
||||
}
|
||||
|
||||
export function setLocalSetting(setting: AppState): void {
|
||||
ss.set(LOCAL_NAME, setting)
|
||||
}
|
@ -0,0 +1,34 @@
|
||||
import { defineStore } from 'pinia'
|
||||
import type { AppState, Language, Theme } from './helper'
|
||||
import { getLocalSetting, setLocalSetting } from './helper'
|
||||
import { store } from '@/store/helper'
|
||||
|
||||
export const useAppStore = defineStore('app-store', {
|
||||
state: (): AppState => getLocalSetting(),
|
||||
actions: {
|
||||
setSiderCollapsed(collapsed: boolean) {
|
||||
this.siderCollapsed = collapsed
|
||||
this.recordState()
|
||||
},
|
||||
|
||||
setTheme(theme: Theme) {
|
||||
this.theme = theme
|
||||
this.recordState()
|
||||
},
|
||||
|
||||
setLanguage(language: Language) {
|
||||
if (this.language !== language) {
|
||||
this.language = language
|
||||
this.recordState()
|
||||
}
|
||||
},
|
||||
|
||||
recordState() {
|
||||
setLocalSetting(this.$state)
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
export function useAppStoreWithOut() {
|
||||
return useAppStore(store)
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
import { ss } from '@/utils/storage'
|
||||
|
||||
const LOCAL_NAME = 'SECRET_TOKEN'
|
||||
|
||||
export function getToken() {
|
||||
return ss.get(LOCAL_NAME)
|
||||
}
|
||||
|
||||
export function setToken(token: string) {
|
||||
return ss.set(LOCAL_NAME, token)
|
||||
}
|
||||
|
||||
export function removeToken() {
|
||||
return ss.remove(LOCAL_NAME)
|
||||
}
|
@ -0,0 +1,54 @@
|
||||
import { defineStore } from 'pinia'
|
||||
import { getToken, removeToken, setToken } from './helper'
|
||||
import { store } from '@/store/helper'
|
||||
import { fetchSession } from '@/api'
|
||||
|
||||
interface SessionResponse {
|
||||
auth: boolean
|
||||
model: 'ChatGPTAPI' | 'ChatGPTUnofficialProxyAPI'
|
||||
}
|
||||
|
||||
export interface AuthState {
|
||||
token: string | undefined
|
||||
session: SessionResponse | null
|
||||
}
|
||||
|
||||
export const useAuthStore = defineStore('auth-store', {
|
||||
state: (): AuthState => ({
|
||||
token: getToken(),
|
||||
session: null,
|
||||
}),
|
||||
|
||||
getters: {
|
||||
isChatGPTAPI(state): boolean {
|
||||
return state.session?.model === 'ChatGPTAPI'
|
||||
},
|
||||
},
|
||||
|
||||
actions: {
|
||||
async getSession() {
|
||||
try {
|
||||
const { data } = await fetchSession<SessionResponse>()
|
||||
this.session = { ...data }
|
||||
return Promise.resolve(data)
|
||||
}
|
||||
catch (error) {
|
||||
return Promise.reject(error)
|
||||
}
|
||||
},
|
||||
|
||||
setToken(token: string) {
|
||||
this.token = token
|
||||
setToken(token)
|
||||
},
|
||||
|
||||
removeToken() {
|
||||
this.token = undefined
|
||||
removeToken()
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
export function useAuthStoreWithout() {
|
||||
return useAuthStore(store)
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
import { ss } from '@/utils/storage'
|
||||
import { t } from '@/locales'
|
||||
|
||||
const LOCAL_NAME = 'chatStorage'
|
||||
|
||||
export function defaultState(): Chat.ChatState {
|
||||
const uuid = 1002
|
||||
return {
|
||||
active: uuid,
|
||||
usingContext: true,
|
||||
history: [{ uuid, title: t('chat.newChatTitle'), isEdit: false }],
|
||||
chat: [{ uuid, data: [] }],
|
||||
}
|
||||
}
|
||||
|
||||
export function getLocalState(): Chat.ChatState {
|
||||
const localState = ss.get(LOCAL_NAME)
|
||||
return { ...defaultState(), ...localState }
|
||||
}
|
||||
|
||||
export function setLocalState(state: Chat.ChatState) {
|
||||
ss.set(LOCAL_NAME, state)
|
||||
}
|
@ -0,0 +1,200 @@
|
||||
import { defineStore } from 'pinia'
|
||||
import { defaultState, getLocalState, setLocalState } from './helper'
|
||||
import { router } from '@/router'
|
||||
import { t } from '@/locales'
|
||||
|
||||
export const useChatStore = defineStore('chat-store', {
|
||||
state: (): Chat.ChatState => getLocalState(),
|
||||
|
||||
getters: {
|
||||
getChatHistoryByCurrentActive(state: Chat.ChatState) {
|
||||
const index = state.history.findIndex(item => item.uuid === state.active)
|
||||
if (index !== -1)
|
||||
return state.history[index]
|
||||
return null
|
||||
},
|
||||
|
||||
getChatByUuid(state: Chat.ChatState) {
|
||||
return (uuid?: number) => {
|
||||
if (uuid)
|
||||
return state.chat.find(item => item.uuid === uuid)?.data ?? []
|
||||
return state.chat.find(item => item.uuid === state.active)?.data ?? []
|
||||
}
|
||||
},
|
||||
},
|
||||
|
||||
actions: {
|
||||
setUsingContext(context: boolean) {
|
||||
this.usingContext = context
|
||||
this.recordState()
|
||||
},
|
||||
|
||||
addHistory(history: Chat.History, chatData: Chat.Chat[] = []) {
|
||||
this.history.unshift(history)
|
||||
this.chat.unshift({ uuid: history.uuid, data: chatData })
|
||||
this.active = history.uuid
|
||||
this.reloadRoute(history.uuid)
|
||||
},
|
||||
|
||||
updateHistory(uuid: number, edit: Partial<Chat.History>) {
|
||||
const index = this.history.findIndex(item => item.uuid === uuid)
|
||||
if (index !== -1) {
|
||||
this.history[index] = { ...this.history[index], ...edit }
|
||||
this.recordState()
|
||||
}
|
||||
},
|
||||
|
||||
async deleteHistory(index: number) {
|
||||
this.history.splice(index, 1)
|
||||
this.chat.splice(index, 1)
|
||||
|
||||
if (this.history.length === 0) {
|
||||
this.active = null
|
||||
this.reloadRoute()
|
||||
return
|
||||
}
|
||||
|
||||
if (index > 0 && index <= this.history.length) {
|
||||
const uuid = this.history[index - 1].uuid
|
||||
this.active = uuid
|
||||
this.reloadRoute(uuid)
|
||||
return
|
||||
}
|
||||
|
||||
if (index === 0) {
|
||||
if (this.history.length > 0) {
|
||||
const uuid = this.history[0].uuid
|
||||
this.active = uuid
|
||||
this.reloadRoute(uuid)
|
||||
}
|
||||
}
|
||||
|
||||
if (index > this.history.length) {
|
||||
const uuid = this.history[this.history.length - 1].uuid
|
||||
this.active = uuid
|
||||
this.reloadRoute(uuid)
|
||||
}
|
||||
},
|
||||
|
||||
async setActive(uuid: number) {
|
||||
this.active = uuid
|
||||
return await this.reloadRoute(uuid)
|
||||
},
|
||||
|
||||
getChatByUuidAndIndex(uuid: number, index: number) {
|
||||
if (!uuid || uuid === 0) {
|
||||
if (this.chat.length)
|
||||
return this.chat[0].data[index]
|
||||
return null
|
||||
}
|
||||
const chatIndex = this.chat.findIndex(item => item.uuid === uuid)
|
||||
if (chatIndex !== -1)
|
||||
return this.chat[chatIndex].data[index]
|
||||
return null
|
||||
},
|
||||
|
||||
addChatByUuid(uuid: number, chat: Chat.Chat) {
|
||||
if (!uuid || uuid === 0) {
|
||||
if (this.history.length === 0) {
|
||||
const uuid = Date.now()
|
||||
this.history.push({ uuid, title: chat.text, isEdit: false })
|
||||
this.chat.push({ uuid, data: [chat] })
|
||||
this.active = uuid
|
||||
this.recordState()
|
||||
}
|
||||
else {
|
||||
this.chat[0].data.push(chat)
|
||||
if (this.history[0].title === t('chat.newChatTitle'))
|
||||
this.history[0].title = chat.text
|
||||
this.recordState()
|
||||
}
|
||||
}
|
||||
|
||||
const index = this.chat.findIndex(item => item.uuid === uuid)
|
||||
if (index !== -1) {
|
||||
this.chat[index].data.push(chat)
|
||||
if (this.history[index].title === t('chat.newChatTitle'))
|
||||
this.history[index].title = chat.text
|
||||
this.recordState()
|
||||
}
|
||||
},
|
||||
|
||||
updateChatByUuid(uuid: number, index: number, chat: Chat.Chat) {
|
||||
if (!uuid || uuid === 0) {
|
||||
if (this.chat.length) {
|
||||
this.chat[0].data[index] = chat
|
||||
this.recordState()
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
const chatIndex = this.chat.findIndex(item => item.uuid === uuid)
|
||||
if (chatIndex !== -1) {
|
||||
this.chat[chatIndex].data[index] = chat
|
||||
this.recordState()
|
||||
}
|
||||
},
|
||||
|
||||
updateChatSomeByUuid(uuid: number, index: number, chat: Partial<Chat.Chat>) {
|
||||
if (!uuid || uuid === 0) {
|
||||
if (this.chat.length) {
|
||||
this.chat[0].data[index] = { ...this.chat[0].data[index], ...chat }
|
||||
this.recordState()
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
const chatIndex = this.chat.findIndex(item => item.uuid === uuid)
|
||||
if (chatIndex !== -1) {
|
||||
this.chat[chatIndex].data[index] = { ...this.chat[chatIndex].data[index], ...chat }
|
||||
this.recordState()
|
||||
}
|
||||
},
|
||||
|
||||
deleteChatByUuid(uuid: number, index: number) {
|
||||
if (!uuid || uuid === 0) {
|
||||
if (this.chat.length) {
|
||||
this.chat[0].data.splice(index, 1)
|
||||
this.recordState()
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
const chatIndex = this.chat.findIndex(item => item.uuid === uuid)
|
||||
if (chatIndex !== -1) {
|
||||
this.chat[chatIndex].data.splice(index, 1)
|
||||
this.recordState()
|
||||
}
|
||||
},
|
||||
|
||||
clearChatByUuid(uuid: number) {
|
||||
if (!uuid || uuid === 0) {
|
||||
if (this.chat.length) {
|
||||
this.chat[0].data = []
|
||||
this.recordState()
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
const index = this.chat.findIndex(item => item.uuid === uuid)
|
||||
if (index !== -1) {
|
||||
this.chat[index].data = []
|
||||
this.recordState()
|
||||
}
|
||||
},
|
||||
|
||||
clearHistory() {
|
||||
this.$state = { ...defaultState() }
|
||||
this.recordState()
|
||||
},
|
||||
|
||||
async reloadRoute(uuid?: number) {
|
||||
this.recordState()
|
||||
await router.push({ name: 'Chat', params: { uuid } })
|
||||
},
|
||||
|
||||
recordState() {
|
||||
setLocalState(this.$state)
|
||||
},
|
||||
},
|
||||
})
|
@ -0,0 +1,6 @@
|
||||
export * from './app'
|
||||
export * from './chat'
|
||||
export * from './user'
|
||||
export * from './prompt'
|
||||
export * from './settings'
|
||||
export * from './auth'
|
@ -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)
|
||||
}
|
@ -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
|
||||
},
|
||||
},
|
||||
})
|
@ -0,0 +1,30 @@
|
||||
import { ss } from '@/utils/storage'
|
||||
|
||||
const LOCAL_NAME = 'settingsStorage'
|
||||
|
||||
export interface SettingsState {
|
||||
systemMessage: string
|
||||
temperature: number
|
||||
top_p: number
|
||||
}
|
||||
|
||||
export function defaultSetting(): SettingsState {
|
||||
return {
|
||||
systemMessage: 'You are ChatGPT, a large language model trained by OpenAI. Follow the user\'s instructions carefully. Respond using markdown.',
|
||||
temperature: 0.8,
|
||||
top_p: 1,
|
||||
}
|
||||
}
|
||||
|
||||
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)
|
||||
}
|
@ -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)
|
||||
},
|
||||
},
|
||||
})
|
@ -0,0 +1,32 @@
|
||||
import { ss } from '@/utils/storage'
|
||||
|
||||
const LOCAL_NAME = 'userStorage'
|
||||
|
||||
export interface UserInfo {
|
||||
avatar: string
|
||||
name: string
|
||||
description: string
|
||||
}
|
||||
|
||||
export interface UserState {
|
||||
userInfo: UserInfo
|
||||
}
|
||||
|
||||
export function defaultSetting(): UserState {
|
||||
return {
|
||||
userInfo: {
|
||||
avatar: 'https://raw.githubusercontent.com/Chanzhaoyu/chatgpt-web/main/src/assets/avatar.jpg',
|
||||
name: 'ChenZhaoYu',
|
||||
description: 'Star on <a href="https://github.com/Chanzhaoyu/chatgpt-bot" class="text-blue-500" target="_blank" >GitHub</a>',
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
export function getLocalState(): UserState {
|
||||
const localSetting: UserState | undefined = ss.get(LOCAL_NAME)
|
||||
return { ...defaultSetting(), ...localSetting }
|
||||
}
|
||||
|
||||
export function setLocalState(setting: UserState): void {
|
||||
ss.set(LOCAL_NAME, setting)
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
import { defineStore } from 'pinia'
|
||||
import type { UserInfo, UserState } from './helper'
|
||||
import { defaultSetting, getLocalState, setLocalState } from './helper'
|
||||
|
||||
export const useUserStore = defineStore('user-store', {
|
||||
state: (): UserState => getLocalState(),
|
||||
actions: {
|
||||
updateUserInfo(userInfo: Partial<UserInfo>) {
|
||||
this.userInfo = { ...this.userInfo, ...userInfo }
|
||||
this.recordState()
|
||||
},
|
||||
|
||||
resetUserInfo() {
|
||||
this.userInfo = { ...defaultSetting().userInfo }
|
||||
this.recordState()
|
||||
},
|
||||
|
||||
recordState() {
|
||||
setLocalState(this.$state)
|
||||
},
|
||||
},
|
||||
})
|
@ -0,0 +1,10 @@
|
||||
html,
|
||||
body,
|
||||
#app {
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
body {
|
||||
padding-bottom: constant(safe-area-inset-bottom);
|
||||
padding-bottom: env(safe-area-inset-bottom);
|
||||
}
|
@ -0,0 +1,206 @@
|
||||
html.dark {
|
||||
pre code.hljs {
|
||||
display: block;
|
||||
overflow-x: auto;
|
||||
padding: 1em
|
||||
}
|
||||
|
||||
code.hljs {
|
||||
padding: 3px 5px
|
||||
}
|
||||
|
||||
.hljs {
|
||||
color: #abb2bf;
|
||||
background: #282c34
|
||||
}
|
||||
|
||||
.hljs-keyword,
|
||||
.hljs-operator,
|
||||
.hljs-pattern-match {
|
||||
color: #f92672
|
||||
}
|
||||
|
||||
.hljs-function,
|
||||
.hljs-pattern-match .hljs-constructor {
|
||||
color: #61aeee
|
||||
}
|
||||
|
||||
.hljs-function .hljs-params {
|
||||
color: #a6e22e
|
||||
}
|
||||
|
||||
.hljs-function .hljs-params .hljs-typing {
|
||||
color: #fd971f
|
||||
}
|
||||
|
||||
.hljs-module-access .hljs-module {
|
||||
color: #7e57c2
|
||||
}
|
||||
|
||||
.hljs-constructor {
|
||||
color: #e2b93d
|
||||
}
|
||||
|
||||
.hljs-constructor .hljs-string {
|
||||
color: #9ccc65
|
||||
}
|
||||
|
||||
.hljs-comment,
|
||||
.hljs-quote {
|
||||
color: #b18eb1;
|
||||
font-style: italic
|
||||
}
|
||||
|
||||
.hljs-doctag,
|
||||
.hljs-formula {
|
||||
color: #c678dd
|
||||
}
|
||||
|
||||
.hljs-deletion,
|
||||
.hljs-name,
|
||||
.hljs-section,
|
||||
.hljs-selector-tag,
|
||||
.hljs-subst {
|
||||
color: #e06c75
|
||||
}
|
||||
|
||||
.hljs-literal {
|
||||
color: #56b6c2
|
||||
}
|
||||
|
||||
.hljs-addition,
|
||||
.hljs-attribute,
|
||||
.hljs-meta .hljs-string,
|
||||
.hljs-regexp,
|
||||
.hljs-string {
|
||||
color: #98c379
|
||||
}
|
||||
|
||||
.hljs-built_in,
|
||||
.hljs-class .hljs-title,
|
||||
.hljs-title.class_ {
|
||||
color: #e6c07b
|
||||
}
|
||||
|
||||
.hljs-attr,
|
||||
.hljs-number,
|
||||
.hljs-selector-attr,
|
||||
.hljs-selector-class,
|
||||
.hljs-selector-pseudo,
|
||||
.hljs-template-variable,
|
||||
.hljs-type,
|
||||
.hljs-variable {
|
||||
color: #d19a66
|
||||
}
|
||||
|
||||
.hljs-bullet,
|
||||
.hljs-link,
|
||||
.hljs-meta,
|
||||
.hljs-selector-id,
|
||||
.hljs-symbol,
|
||||
.hljs-title {
|
||||
color: #61aeee
|
||||
}
|
||||
|
||||
.hljs-emphasis {
|
||||
font-style: italic
|
||||
}
|
||||
|
||||
.hljs-strong {
|
||||
font-weight: 700
|
||||
}
|
||||
|
||||
.hljs-link {
|
||||
text-decoration: underline
|
||||
}
|
||||
}
|
||||
|
||||
html {
|
||||
pre code.hljs {
|
||||
display: block;
|
||||
overflow-x: auto;
|
||||
padding: 1em
|
||||
}
|
||||
|
||||
code.hljs {
|
||||
padding: 3px 5px;
|
||||
&::-webkit-scrollbar {
|
||||
height: 4px;
|
||||
}
|
||||
}
|
||||
|
||||
.hljs {
|
||||
color: #383a42;
|
||||
background: #fafafa
|
||||
}
|
||||
|
||||
.hljs-comment,
|
||||
.hljs-quote {
|
||||
color: #a0a1a7;
|
||||
font-style: italic
|
||||
}
|
||||
|
||||
.hljs-doctag,
|
||||
.hljs-formula,
|
||||
.hljs-keyword {
|
||||
color: #a626a4
|
||||
}
|
||||
|
||||
.hljs-deletion,
|
||||
.hljs-name,
|
||||
.hljs-section,
|
||||
.hljs-selector-tag,
|
||||
.hljs-subst {
|
||||
color: #e45649
|
||||
}
|
||||
|
||||
.hljs-literal {
|
||||
color: #0184bb
|
||||
}
|
||||
|
||||
.hljs-addition,
|
||||
.hljs-attribute,
|
||||
.hljs-meta .hljs-string,
|
||||
.hljs-regexp,
|
||||
.hljs-string {
|
||||
color: #50a14f
|
||||
}
|
||||
|
||||
.hljs-attr,
|
||||
.hljs-number,
|
||||
.hljs-selector-attr,
|
||||
.hljs-selector-class,
|
||||
.hljs-selector-pseudo,
|
||||
.hljs-template-variable,
|
||||
.hljs-type,
|
||||
.hljs-variable {
|
||||
color: #986801
|
||||
}
|
||||
|
||||
.hljs-bullet,
|
||||
.hljs-link,
|
||||
.hljs-meta,
|
||||
.hljs-selector-id,
|
||||
.hljs-symbol,
|
||||
.hljs-title {
|
||||
color: #4078f2
|
||||
}
|
||||
|
||||
.hljs-built_in,
|
||||
.hljs-class .hljs-title,
|
||||
.hljs-title.class_ {
|
||||
color: #c18401
|
||||
}
|
||||
|
||||
.hljs-emphasis {
|
||||
font-style: italic
|
||||
}
|
||||
|
||||
.hljs-strong {
|
||||
font-weight: 700
|
||||
}
|
||||
|
||||
.hljs-link {
|
||||
text-decoration: underline
|
||||
}
|
||||
}
|
@ -0,0 +1,3 @@
|
||||
@tailwind base;
|
||||
@tailwind components;
|
||||
@tailwind utilities;
|
@ -0,0 +1,46 @@
|
||||
declare namespace Chat {
|
||||
|
||||
interface Chat {
|
||||
dateTime: string
|
||||
text: string
|
||||
inversion?: boolean
|
||||
error?: boolean
|
||||
loading?: boolean
|
||||
conversationOptions?: ConversationRequest | null
|
||||
requestOptions: { prompt: string; options?: ConversationRequest | null }
|
||||
}
|
||||
|
||||
interface History {
|
||||
title: string
|
||||
isEdit: boolean
|
||||
uuid: number
|
||||
}
|
||||
|
||||
interface ChatState {
|
||||
active: number | null
|
||||
usingContext: boolean;
|
||||
history: History[]
|
||||
chat: { uuid: number; data: Chat[] }[]
|
||||
}
|
||||
|
||||
interface ConversationRequest {
|
||||
conversationId?: string
|
||||
parentMessageId?: string
|
||||
}
|
||||
|
||||
interface ConversationResponse {
|
||||
conversationId: string
|
||||
detail: {
|
||||
choices: { finish_reason: string; index: number; logprobs: any; text: string }[]
|
||||
created: number
|
||||
id: string
|
||||
model: string
|
||||
object: string
|
||||
usage: { completion_tokens: number; prompt_tokens: number; total_tokens: number }
|
||||
}
|
||||
id: string
|
||||
parentMessageId: string
|
||||
role: string
|
||||
text: string
|
||||
}
|
||||
}
|
@ -0,0 +1,8 @@
|
||||
/// <reference types="vite/client" />
|
||||
|
||||
interface ImportMetaEnv {
|
||||
readonly VITE_GLOB_API_URL: string;
|
||||
readonly VITE_APP_API_BASE_URL: string;
|
||||
readonly VITE_GLOB_OPEN_LONG_REPLY: string;
|
||||
readonly VITE_GLOB_APP_PWA: string;
|
||||
}
|