├── .dockerignore ├── .eslintrc.json ├── src-tauri ├── build.rs ├── app-icon.png ├── icons │ ├── 32x32.png │ ├── icon.icns │ ├── icon.ico │ ├── icon.png │ ├── 128x128.png │ ├── 128x128@2x.png │ ├── StoreLogo.png │ ├── Square30x30Logo.png │ ├── Square44x44Logo.png │ ├── Square71x71Logo.png │ ├── Square89x89Logo.png │ ├── Square107x107Logo.png │ ├── Square142x142Logo.png │ ├── Square150x150Logo.png │ ├── Square284x284Logo.png │ └── Square310x310Logo.png ├── .gitignore ├── src │ └── main.rs ├── Cargo.toml └── tauri.conf.json ├── service ├── .dockerignore ├── .prettierrc ├── src │ ├── middleware │ │ ├── error.middleware.ts │ │ ├── logger.middleware.ts │ │ ├── index.ts │ │ ├── auth.middleware.ts │ │ └── ratelimit.middleware.ts │ ├── config │ │ └── configuration.ts │ ├── modules │ │ ├── app │ │ │ ├── app.service.ts │ │ │ ├── index.ts │ │ │ └── app.controller.ts │ │ └── chatgpt │ │ │ ├── index.ts │ │ │ ├── chatgpt.controller.ts │ │ │ └── chatgpt.service.ts │ ├── main.ts │ ├── utils │ │ └── index.ts │ └── app.module.ts ├── tsconfig.build.json ├── test │ ├── jest-e2e.json │ └── app.e2e-spec.ts ├── vercel.json ├── tsconfig.json ├── webpack.config.js ├── .eslintrc.js ├── README.md ├── .env.example └── package.json ├── public ├── logo.png ├── logo_w.png ├── app-icon.png ├── chatgpt.png ├── favicon.ico ├── vercel.svg ├── favicon.svg ├── thirteen.svg ├── next.svg └── logo.svg ├── docs ├── screen_dark.png └── screen_light.png ├── src ├── assets │ ├── avatar.jpg │ ├── chatgpt.png │ ├── openai.png │ ├── images │ │ └── empty_box.png │ └── icons │ │ ├── dark.svg │ │ └── light.svg ├── utils │ ├── tool │ │ ├── index.less │ │ └── index.md │ ├── index.ts │ ├── uuid │ │ └── index.ts │ ├── request │ │ ├── axios.ts │ │ └── index.ts │ └── storage │ │ └── index.ts ├── components │ ├── pages │ │ ├── setting │ │ │ ├── Box.tsx │ │ │ ├── Common.tsx │ │ │ ├── Network.tsx │ │ │ └── Surface.tsx │ │ ├── chat │ │ │ ├── Setting.tsx │ │ │ ├── Empty.tsx │ │ │ ├── Box.tsx │ │ │ ├── InputArea.tsx │ │ │ ├── Markdown.tsx │ │ │ ├── Option.tsx │ │ │ └── List.tsx │ │ ├── prompt │ │ │ ├── Item.tsx │ │ │ └── Export.tsx │ │ └── plugin │ │ │ ├── Info.tsx │ │ │ └── Item.tsx │ ├── Icon │ │ └── index.tsx │ └── EmojiPicker │ │ ├── Button.tsx │ │ └── index.tsx ├── types │ ├── next-auth.d.ts │ ├── prompt.d.ts │ ├── plugin.d.ts │ └── chat.d.ts ├── themes │ └── index.tsx ├── contexts │ ├── index.tsx │ ├── setting.tsx │ ├── plugin.tsx │ ├── site.tsx │ ├── prompt.tsx │ └── chat.tsx ├── pages │ ├── index.tsx │ ├── share │ │ └── index.tsx │ ├── _document.tsx │ ├── store │ │ └── index.tsx │ ├── readme │ │ └── index.tsx │ ├── plugin │ │ └── index.tsx │ ├── prompt │ │ └── index.tsx │ ├── setting │ │ └── index.tsx │ ├── _app.tsx │ └── chat │ │ └── index.tsx ├── data │ ├── prompt.ts │ └── plugin.ts ├── locales │ ├── index.ts │ ├── zh_TW.json │ ├── zh_CN.json │ └── en_US.json ├── api │ └── index.ts ├── hooks │ └── useChat.ts ├── styles │ └── globals.css └── config │ └── constant.ts ├── .husky ├── pre-commit └── commit-msg ├── commitlint.config.js ├── start.sh ├── docker-start.sh ├── docker-compose ├── readme.md ├── nginx │ └── nginx.conf └── docker-compose.yml ├── start.cmd ├── .env.example ├── .gitignore ├── tsconfig.json ├── .github └── workflows │ ├── ci.yml │ └── build_docker.yml ├── LICENSE ├── .release-it.json ├── next.config.js ├── Dockerfile └── package.json /.dockerignore: -------------------------------------------------------------------------------- 1 | Dockerfile 2 | node_modules 3 | *.log 4 | .DS_Store -------------------------------------------------------------------------------- /.eslintrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "next/core-web-vitals" 3 | } 4 | -------------------------------------------------------------------------------- /src-tauri/build.rs: -------------------------------------------------------------------------------- 1 | fn main() { 2 | tauri_build::build() 3 | } 4 | -------------------------------------------------------------------------------- /service/.dockerignore: -------------------------------------------------------------------------------- 1 | Dockerfile 2 | node_modules 3 | *.log 4 | .DS_Store -------------------------------------------------------------------------------- /public/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhpd/chatgpt-plus/HEAD/public/logo.png -------------------------------------------------------------------------------- /public/logo_w.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhpd/chatgpt-plus/HEAD/public/logo_w.png -------------------------------------------------------------------------------- /service/.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "singleQuote": true, 3 | "trailingComma": "all" 4 | } 5 | -------------------------------------------------------------------------------- /docs/screen_dark.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhpd/chatgpt-plus/HEAD/docs/screen_dark.png -------------------------------------------------------------------------------- /public/app-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhpd/chatgpt-plus/HEAD/public/app-icon.png -------------------------------------------------------------------------------- /public/chatgpt.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhpd/chatgpt-plus/HEAD/public/chatgpt.png -------------------------------------------------------------------------------- /public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhpd/chatgpt-plus/HEAD/public/favicon.ico -------------------------------------------------------------------------------- /docs/screen_light.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhpd/chatgpt-plus/HEAD/docs/screen_light.png -------------------------------------------------------------------------------- /src-tauri/app-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhpd/chatgpt-plus/HEAD/src-tauri/app-icon.png -------------------------------------------------------------------------------- /src/assets/avatar.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhpd/chatgpt-plus/HEAD/src/assets/avatar.jpg -------------------------------------------------------------------------------- /src/assets/chatgpt.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhpd/chatgpt-plus/HEAD/src/assets/chatgpt.png -------------------------------------------------------------------------------- /src/assets/openai.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhpd/chatgpt-plus/HEAD/src/assets/openai.png -------------------------------------------------------------------------------- /.husky/pre-commit: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | . "$(dirname -- "$0")/_/husky.sh" 3 | 4 | npm run lint 5 | -------------------------------------------------------------------------------- /commitlint.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | extends: ['@commitlint/config-conventional'], 3 | } 4 | -------------------------------------------------------------------------------- /src-tauri/icons/32x32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhpd/chatgpt-plus/HEAD/src-tauri/icons/32x32.png -------------------------------------------------------------------------------- /src-tauri/icons/icon.icns: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhpd/chatgpt-plus/HEAD/src-tauri/icons/icon.icns -------------------------------------------------------------------------------- /src-tauri/icons/icon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhpd/chatgpt-plus/HEAD/src-tauri/icons/icon.ico -------------------------------------------------------------------------------- /src-tauri/icons/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhpd/chatgpt-plus/HEAD/src-tauri/icons/icon.png -------------------------------------------------------------------------------- /service/src/middleware/error.middleware.ts: -------------------------------------------------------------------------------- 1 | export function error(req, res, next) { 2 | next(); 3 | } 4 | -------------------------------------------------------------------------------- /src-tauri/.gitignore: -------------------------------------------------------------------------------- 1 | # Generated by Cargo 2 | # will have compiled files and executables 3 | /target/ 4 | -------------------------------------------------------------------------------- /src-tauri/icons/128x128.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhpd/chatgpt-plus/HEAD/src-tauri/icons/128x128.png -------------------------------------------------------------------------------- /src-tauri/icons/128x128@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhpd/chatgpt-plus/HEAD/src-tauri/icons/128x128@2x.png -------------------------------------------------------------------------------- /src-tauri/icons/StoreLogo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhpd/chatgpt-plus/HEAD/src-tauri/icons/StoreLogo.png -------------------------------------------------------------------------------- /.husky/commit-msg: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | . "$(dirname -- "$0")/_/husky.sh" 3 | 4 | npx --no -- commitlint --edit ${1} -------------------------------------------------------------------------------- /src/assets/images/empty_box.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhpd/chatgpt-plus/HEAD/src/assets/images/empty_box.png -------------------------------------------------------------------------------- /src-tauri/icons/Square30x30Logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhpd/chatgpt-plus/HEAD/src-tauri/icons/Square30x30Logo.png -------------------------------------------------------------------------------- /src-tauri/icons/Square44x44Logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhpd/chatgpt-plus/HEAD/src-tauri/icons/Square44x44Logo.png -------------------------------------------------------------------------------- /src-tauri/icons/Square71x71Logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhpd/chatgpt-plus/HEAD/src-tauri/icons/Square71x71Logo.png -------------------------------------------------------------------------------- /src-tauri/icons/Square89x89Logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhpd/chatgpt-plus/HEAD/src-tauri/icons/Square89x89Logo.png -------------------------------------------------------------------------------- /src-tauri/icons/Square107x107Logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhpd/chatgpt-plus/HEAD/src-tauri/icons/Square107x107Logo.png -------------------------------------------------------------------------------- /src-tauri/icons/Square142x142Logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhpd/chatgpt-plus/HEAD/src-tauri/icons/Square142x142Logo.png -------------------------------------------------------------------------------- /src-tauri/icons/Square150x150Logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhpd/chatgpt-plus/HEAD/src-tauri/icons/Square150x150Logo.png -------------------------------------------------------------------------------- /src-tauri/icons/Square284x284Logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhpd/chatgpt-plus/HEAD/src-tauri/icons/Square284x284Logo.png -------------------------------------------------------------------------------- /src-tauri/icons/Square310x310Logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhpd/chatgpt-plus/HEAD/src-tauri/icons/Square310x310Logo.png -------------------------------------------------------------------------------- /service/tsconfig.build.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.json", 3 | "exclude": ["node_modules", "dist", "test", "**/*spec.ts"] 4 | } 5 | -------------------------------------------------------------------------------- /service/src/config/configuration.ts: -------------------------------------------------------------------------------- 1 | export default () => ({ 2 | port: parseInt(process.env.PORT, 10) || 3002, 3 | ...process.env, 4 | }); 5 | -------------------------------------------------------------------------------- /service/src/middleware/logger.middleware.ts: -------------------------------------------------------------------------------- 1 | export function logger(req, res, next) { 2 | console.log(`Request...`, req, res); 3 | next(); 4 | } 5 | -------------------------------------------------------------------------------- /src/utils/tool/index.less: -------------------------------------------------------------------------------- 1 | .ant-drawer-footer { 2 | .drawerFooterBtn { 3 | .ant-btn + .ant-btn:not(.ant-dropdown-trigger) { 4 | margin-bottom: 0; 5 | margin-left: 8px; 6 | } 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /service/src/modules/app/app.service.ts: -------------------------------------------------------------------------------- 1 | import { Injectable } from '@nestjs/common'; 2 | 3 | @Injectable() 4 | export class AppService { 5 | getHello(): string { 6 | return 'Hello ChatGPT!'; 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /src/utils/index.ts: -------------------------------------------------------------------------------- 1 | // @ts-ignore 2 | import tool from './tool' 3 | import request from './request' 4 | import storage from './storage' 5 | import { uuidv4, nanoid } from './uuid' 6 | export { tool, request, uuidv4, nanoid } 7 | -------------------------------------------------------------------------------- /start.sh: -------------------------------------------------------------------------------- 1 | 2 | cd ./service 3 | nohup npm run dev > service.log & 4 | echo "Start service complete!" 5 | 6 | 7 | cd .. 8 | nohup npm run dev > front.log & 9 | echo "Start front complete!" 10 | tail -f front.log 11 | -------------------------------------------------------------------------------- /service/test/jest-e2e.json: -------------------------------------------------------------------------------- 1 | { 2 | "moduleFileExtensions": ["js", "json", "ts"], 3 | "rootDir": ".", 4 | "testEnvironment": "node", 5 | "testRegex": ".e2e-spec.ts$", 6 | "transform": { 7 | "^.+\\.(t|j)s$": "ts-jest" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /service/src/middleware/index.ts: -------------------------------------------------------------------------------- 1 | import { logger } from './logger.middleware'; 2 | import { error } from './error.middleware'; 3 | import { auth } from './auth.middleware'; 4 | // import { ratelimit } from './ratelimit.middleware'; 5 | export { logger, error, auth }; 6 | -------------------------------------------------------------------------------- /docker-start.sh: -------------------------------------------------------------------------------- 1 | 2 | 3 | cd /app/service 4 | nohup node dist/main.js > /app/log/service.log & 5 | echo "Start service complete!" 6 | 7 | 8 | cd /app/web 9 | nohup node server.js > /app/log/front.log & 10 | echo "Start front complete!" 11 | tail -f /app/log/front.log 12 | -------------------------------------------------------------------------------- /src-tauri/src/main.rs: -------------------------------------------------------------------------------- 1 | // Prevents additional console window on Windows in release, DO NOT REMOVE!! 2 | #![cfg_attr(not(debug_assertions), windows_subsystem = "windows")] 3 | 4 | fn main() { 5 | tauri::Builder::default() 6 | .run(tauri::generate_context!()) 7 | .expect("error while running tauri application"); 8 | } 9 | -------------------------------------------------------------------------------- /docker-compose/readme.md: -------------------------------------------------------------------------------- 1 | ### docker-compose 部署教程 2 | - 将打包好的前端文件放到 `nginx/html` 目录下 3 | - ```shell 4 | # 拉取新镜像 5 | docker-compose pull 6 | ``` 7 | - ```shell 8 | # 启动 9 | docker-compose up -d 10 | ``` 11 | - ```shell 12 | # 查看运行状态 13 | docker ps 14 | ``` 15 | - ```shell 16 | # 结束运行 17 | docker-compose down 18 | ``` 19 | -------------------------------------------------------------------------------- /service/src/modules/app/index.ts: -------------------------------------------------------------------------------- 1 | import { Module } from '@nestjs/common'; 2 | import { AppController } from './app.controller'; 3 | import { AppService } from './app.service'; 4 | 5 | export { AppController, AppService }; 6 | 7 | @Module({ 8 | controllers: [AppController], 9 | providers: [AppService], 10 | }) 11 | export class AppModule {} 12 | -------------------------------------------------------------------------------- /start.cmd: -------------------------------------------------------------------------------- 1 | cd ./service 2 | @echo on 3 | start cmd /k "echo start service... & echo open service/service.log view log & npm run dev > service.log &" 4 | echo "Start service complete!" 5 | 6 | 7 | cd .. 8 | @echo on 9 | start cmd /k "echo start front... & echo open front.log view log & npm run dev > front.log &" 10 | echo "Start front complete!" 11 | -------------------------------------------------------------------------------- /service/src/modules/app/app.controller.ts: -------------------------------------------------------------------------------- 1 | import { Controller, Get } from '@nestjs/common'; 2 | import { AppService } from './app.service'; 3 | 4 | @Controller() 5 | export class AppController { 6 | constructor(private readonly appService: AppService) {} 7 | 8 | @Get() 9 | getHello(): string { 10 | return this.appService.getHello(); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/components/pages/setting/Box.tsx: -------------------------------------------------------------------------------- 1 | import { useTranslation } from '@/locales' 2 | 3 | function Box(props: { children?: React.ReactElement; style?: React.CSSProperties }) { 4 | const { t } = useTranslation() 5 | 6 | return ( 7 |
8 | {props?.children} 9 |
10 | ) 11 | } 12 | 13 | export default Box 14 | -------------------------------------------------------------------------------- /src/types/next-auth.d.ts: -------------------------------------------------------------------------------- 1 | import NextAuth from 'next-auth' 2 | 3 | declare module 'next-auth' { 4 | /** 5 | * Returned by `useSession`, `getSession` and received as a prop on the `SessionProvider` React Context 6 | */ 7 | interface Session { 8 | user: { 9 | /** The user's postal country. */ 10 | country: string 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/utils/uuid/index.ts: -------------------------------------------------------------------------------- 1 | // javascript 2 | import { nanoid } from 'nanoid' 3 | 4 | // 将nanoid转换为uuidv4格式 5 | const uuidv4 = () => { 6 | // 生成长度为 32 的随机字符串 7 | const randomString = nanoid(); 8 | // 将随机字符串转换为 UUID 格式 9 | const uuid = `${randomString.slice(0, 8)}-${randomString.slice(8, 12)}-${randomString.slice(12, 16)}-${randomString.slice(16, 20)}-${randomString.slice(20)}`; 10 | return uuid 11 | } 12 | 13 | export { uuidv4, nanoid } 14 | -------------------------------------------------------------------------------- /service/src/modules/chatgpt/index.ts: -------------------------------------------------------------------------------- 1 | import { Module } from '@nestjs/common'; 2 | import { ConfigModule } from '@nestjs/config'; 3 | import { ChatgptController } from './chatgpt.controller'; 4 | import { ChatgptService } from './chatgpt.service'; 5 | 6 | export { ChatgptController, ChatgptService }; 7 | 8 | @Module({ 9 | imports: [ConfigModule], 10 | controllers: [ChatgptController], 11 | providers: [ChatgptService], 12 | }) 13 | export class ChatgptModule {} 14 | -------------------------------------------------------------------------------- /service/src/main.ts: -------------------------------------------------------------------------------- 1 | import { ConfigService } from '@nestjs/config'; 2 | import { NestFactory } from '@nestjs/core'; 3 | import { AppModule } from './app.module'; 4 | 5 | async function bootstrap() { 6 | const app = await NestFactory.create(AppModule, { 7 | cors: true, 8 | }); 9 | app.setGlobalPrefix('api'); 10 | const configService = app.get(ConfigService); 11 | const port = configService.get('PORT', 3002); 12 | await app.listen(port); 13 | } 14 | bootstrap(); 15 | -------------------------------------------------------------------------------- /src/themes/index.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react' 2 | import { ConfigProvider } from 'antd' 3 | 4 | export const colorPrimary = '#1677ff' 5 | // export const colorPrimary = '#00B96B' 6 | 7 | const withTheme = (node: JSX.Element) => ( 8 | <> 9 | 16 | {node} 17 | 18 | 19 | ) 20 | 21 | export default withTheme 22 | -------------------------------------------------------------------------------- /src/contexts/index.tsx: -------------------------------------------------------------------------------- 1 | import { ChatProvider, useChatContext } from './chat' 2 | import { SiteProvider, useSiteContext } from './site' 3 | import { PromptProvider, usePromptContext } from './prompt' 4 | import { PluginProvider, usePluginContext } from './plugin' 5 | import { SettingProvider, useSettingContext } from './setting' 6 | export { ChatProvider, SiteProvider, PromptProvider, useChatContext, useSiteContext, usePromptContext, SettingProvider, useSettingContext, PluginProvider, usePluginContext } 7 | -------------------------------------------------------------------------------- /src/components/Icon/index.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import * as icons from '@ant-design/icons'; 3 | import { IconProps } from '@ant-design/icons/lib/components/IconBase'; 4 | 5 | export interface BaseIconProps extends Omit { 6 | name: string; 7 | } 8 | const Icon = (props: BaseIconProps) => { 9 | const { name } = props; 10 | const antIcon: Record = icons; 11 | return React.createElement(antIcon[name], props); 12 | }; 13 | 14 | export default Icon; 15 | -------------------------------------------------------------------------------- /.env.example: -------------------------------------------------------------------------------- 1 | # ------------------------------------------------------------------------------ 2 | # This is an example .env file. 3 | # 4 | # All of these environment vars must be defined either in your environment or in 5 | # a local .env file in order to run the demo for this project. 6 | # ------------------------------------------------------------------------------ 7 | 8 | # port 9 | PORT=3000 10 | 11 | # api url 12 | NEXT_PUBLIC_API_URL=http://localhost:3002 13 | 14 | # google analytics 15 | GOOGLE_GA_ID= -------------------------------------------------------------------------------- /service/src/utils/index.ts: -------------------------------------------------------------------------------- 1 | export interface OutputOptions { 2 | code: 0 | number; 3 | message?: string; 4 | data?: T; 5 | } 6 | 7 | export function output(options: OutputOptions) { 8 | if (options.code === 0) { 9 | return Promise.resolve({ 10 | code: options.code, 11 | message: options.message ?? null, 12 | data: options.data ?? null, 13 | }); 14 | } 15 | 16 | return Promise.reject({ 17 | code: options.code, 18 | message: options.message ?? 'Failed', 19 | data: options.data ?? null, 20 | }); 21 | } 22 | -------------------------------------------------------------------------------- /src/pages/index.tsx: -------------------------------------------------------------------------------- 1 | import React, { useState } from 'react' 2 | // import ChatPage from './chat' 3 | 4 | import dynamic from 'next/dynamic' 5 | import { Spin } from 'antd' 6 | 7 | const ChatPage = dynamic(() => import('./chat'), { 8 | loading: () => ( 9 |
10 | 11 |
12 | ), 13 | }) 14 | 15 | const App: React.FC = () => { 16 | return ( 17 | <> 18 | 19 | 20 | ) 21 | } 22 | 23 | export default App 24 | -------------------------------------------------------------------------------- /src/pages/share/index.tsx: -------------------------------------------------------------------------------- 1 | import Head from 'next/head' 2 | import { useTranslation } from '@/locales' 3 | import { useSiteContext } from '@/contexts/site' 4 | import { useEffect } from 'react' 5 | function IndexPage() { 6 | const { setTitle } = useSiteContext() 7 | const { t } = useTranslation() 8 | useEffect(() => { 9 | const title = t('window.title', { title: t('c.share') }) 10 | setTitle(title) 11 | }, [setTitle, t]) 12 | return ( 13 |
14 |

Hello world! Share

15 |
16 | ) 17 | } 18 | 19 | export default IndexPage 20 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | 3 | # dependencies 4 | /node_modules 5 | /.pnp 6 | .pnp.js 7 | 8 | # testing 9 | /coverage 10 | 11 | # next.js 12 | /.next/ 13 | /out/ 14 | /dist/ 15 | 16 | # production 17 | /build 18 | 19 | # misc 20 | .DS_Store 21 | *.pem 22 | 23 | # debug 24 | npm-debug.log* 25 | yarn-debug.log* 26 | yarn-error.log* 27 | .pnpm-debug.log* 28 | 29 | # local env files 30 | .env 31 | .env.local 32 | .env*.local 33 | 34 | # vercel 35 | .vercel 36 | 37 | # typescript 38 | *.tsbuildinfo 39 | next-env.d.ts 40 | 41 | # log 42 | *.log -------------------------------------------------------------------------------- /public/vercel.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docker-compose/nginx/nginx.conf: -------------------------------------------------------------------------------- 1 | server { 2 | listen 80; 3 | server_name localhost; 4 | charset utf-8; 5 | error_page 500 502 503 504 /50x.html; 6 | location / { 7 | # root /usr/share/nginx/html; 8 | # try_files $uri /index.html; 9 | proxy_pass http://app:3000; 10 | } 11 | 12 | location /api { 13 | proxy_buffering off; 14 | proxy_set_header X-Real-IP $remote_addr; #转发用户IP 15 | proxy_pass http://app:3002; 16 | } 17 | 18 | proxy_set_header Host $host; 19 | proxy_set_header X-Real-IP $remote_addr; 20 | proxy_set_header REMOTE-HOST $remote_addr; 21 | proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 22 | } 23 | -------------------------------------------------------------------------------- /service/vercel.json: -------------------------------------------------------------------------------- 1 | { 2 | "devCommand": "npm run dev", 3 | "outputDirectory": "./dist/", 4 | "routes": [ 5 | { 6 | "src": "/(.*)", 7 | "dest": "main.js", 8 | "methods": ["GET", "POST", "PUT", "DELETE", "PATCH"], 9 | "headers": { 10 | "Access-Control-Allow-Credentials": "true", 11 | "Access-Control-Allow-Origin": "*", 12 | "Access-Control-Allow-Methods": "GET,OPTIONS,PATCH,DELETE,POST,PUT", 13 | "Access-Control-Allow-Headers": "X-CSRF-Token, X-Requested-With, Accept, Accept-Version, Content-Length, Content-MD5, Content-Type, Date, X-Api-Version" 14 | } 15 | } 16 | ] 17 | } 18 | -------------------------------------------------------------------------------- /service/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "esnext", 4 | "lib": ["esnext"], 5 | "esModuleInterop": true, 6 | "module": "commonjs", 7 | "moduleResolution": "node", 8 | "resolveJsonModule": true, 9 | "isolatedModules": true, 10 | "declaration": true, 11 | "removeComments": true, 12 | "emitDecoratorMetadata": true, 13 | "experimentalDecorators": true, 14 | "allowSyntheticDefaultImports": true, 15 | "sourceMap": true, 16 | "outDir": "./dist", 17 | "baseUrl": "./", 18 | "incremental": true, 19 | "skipLibCheck": true 20 | }, 21 | "include": ["**/*.ts"], 22 | "exclude": ["node_modules", "dist"] 23 | } -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es5", 4 | "lib": ["dom", "dom.iterable", "esnext"], 5 | "allowJs": true, 6 | "skipLibCheck": true, 7 | "strict": true, 8 | "forceConsistentCasingInFileNames": true, 9 | "noEmit": true, 10 | "esModuleInterop": true, 11 | "module": "esnext", 12 | "moduleResolution": "node", 13 | "resolveJsonModule": true, 14 | "isolatedModules": true, 15 | "jsx": "preserve", 16 | "incremental": true, 17 | "paths": { 18 | "@/*": ["./src/*"] 19 | } 20 | }, 21 | "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"], 22 | "exclude": ["node_modules", "service", "out", "src-tauri"] 23 | } 24 | -------------------------------------------------------------------------------- /service/webpack.config.js: -------------------------------------------------------------------------------- 1 | module.exports = (options, webpack) => { 2 | const lazyImports = [ 3 | '@nestjs/microservices/microservices-module', 4 | '@nestjs/websockets/socket-module', 5 | ]; 6 | 7 | return { 8 | ...options, 9 | externals: [/node_modules/], 10 | plugins: [ 11 | ...options.plugins, 12 | new webpack.IgnorePlugin({ 13 | checkResource(resource) { 14 | if (lazyImports.includes(resource)) { 15 | try { 16 | require.resolve(resource); 17 | } catch (err) { 18 | return true; 19 | } 20 | } 21 | return false; 22 | }, 23 | }), 24 | ], 25 | }; 26 | }; 27 | 28 | -------------------------------------------------------------------------------- /service/src/middleware/auth.middleware.ts: -------------------------------------------------------------------------------- 1 | export function auth(req, res, next) { 2 | const AUTH_SECRET_KEY = process.env.AUTH_SECRET_KEY; 3 | if (!AUTH_SECRET_KEY) { 4 | try { 5 | const Authorization = req.header('Authorization'); 6 | if ( 7 | !Authorization || 8 | Authorization.replace('Bearer ', '').trim() !== AUTH_SECRET_KEY.trim() 9 | ) { 10 | throw new Error('Error: 无访问权限 | No access rights'); 11 | } 12 | next(); 13 | } catch (error) { 14 | res.send({ 15 | status: 'Unauthorized', 16 | message: error.message ?? 'Please authenticate.', 17 | data: null, 18 | }); 19 | } 20 | } else { 21 | next(); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/pages/_document.tsx: -------------------------------------------------------------------------------- 1 | import { Html, Head, Main, NextScript } from 'next/document' 2 | 3 | 4 | 5 | export default function Document() { 6 | return ( 7 | 8 | 9 |