Skip to content

Commit

Permalink
Merge pull request #1 from zmh-program/v2
Browse files Browse the repository at this point in the history
v2
  • Loading branch information
zmh-program authored Sep 6, 2023
2 parents 49cb43f + 1f432f9 commit bd1bf4b
Show file tree
Hide file tree
Showing 109 changed files with 9,681 additions and 3,534 deletions.
6 changes: 1 addition & 5 deletions api/chat.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,11 +143,7 @@ func ChatAPI(c *gin.Context) {
// load conversation
instance = conversation.LoadConversation(db, user.GetID(db), form.Id)
if instance == nil {
SendSegmentMessage(conn, types.ChatGPTSegmentResponse{
Message: "Conversation not found.",
End: true,
})
return
instance = conversation.NewConversation(db, user.GetID(db))
}
}

Expand Down
18 changes: 18 additions & 0 deletions app/.eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
module.exports = {
root: true,
env: { browser: true, es2020: true },
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'plugin:react-hooks/recommended',
],
ignorePatterns: ['dist', '.eslintrc.cjs'],
parser: '@typescript-eslint/parser',
plugins: ['react-refresh'],
rules: {
'react-refresh/only-export-components': [
'warn',
{ allowConstantExport: true },
],
},
}
1 change: 1 addition & 0 deletions app/.prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
31 changes: 20 additions & 11 deletions app/README.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,27 @@
# Vue 3 + TypeScript + Vite
# React + TypeScript + Vite

This template should help get you started developing with Vue 3 and TypeScript in Vite. The template uses Vue 3 `<script setup>` SFCs, check out the [script setup docs](https://v3.vuejs.org/api/sfc-script-setup.html#sfc-script-setup) to learn more.
This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules.

## Recommended IDE Setup
Currently, two official plugins are available:

- [VS Code](https://code.visualstudio.com/) + [Volar](https://marketplace.visualstudio.com/items?itemName=Vue.volar) (and disable Vetur) + [TypeScript Vue Plugin (Volar)](https://marketplace.visualstudio.com/items?itemName=Vue.vscode-typescript-vue-plugin).
- [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react/README.md) uses [Babel](https://babeljs.io/) for Fast Refresh
- [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react-swc) uses [SWC](https://swc.rs/) for Fast Refresh

## Type Support For `.vue` Imports in TS
## Expanding the ESLint configuration

TypeScript cannot handle type information for `.vue` imports by default, so we replace the `tsc` CLI with `vue-tsc` for type checking. In editors, we need [TypeScript Vue Plugin (Volar)](https://marketplace.visualstudio.com/items?itemName=Vue.vscode-typescript-vue-plugin) to make the TypeScript language service aware of `.vue` types.
If you are developing a production application, we recommend updating the configuration to enable type aware lint rules:

If the standalone TypeScript plugin doesn't feel fast enough to you, Volar has also implemented a [Take Over Mode](https://github.com/johnsoncodehk/volar/discussions/471#discussioncomment-1361669) that is more performant. You can enable it by the following steps:
- Configure the top-level `parserOptions` property like this:

1. Disable the built-in TypeScript Extension
1. Run `Extensions: Show Built-in Extensions` from VSCode's command palette
2. Find `TypeScript and JavaScript Language Features`, right click and select `Disable (Workspace)`
2. Reload the VSCode window by running `Developer: Reload Window` from the command palette.
```js
parserOptions: {
ecmaVersion: 'latest',
sourceType: 'module',
project: ['./tsconfig.json', './tsconfig.node.json'],
tsconfigRootDir: __dirname,
},
```

- Replace `plugin:@typescript-eslint/recommended` to `plugin:@typescript-eslint/recommended-type-checked` or `plugin:@typescript-eslint/strict-type-checked`
- Optionally add `plugin:@typescript-eslint/stylistic-type-checked`
- Install [eslint-plugin-react](https://github.com/jsx-eslint/eslint-plugin-react) and add `plugin:react/recommended` & `plugin:react/jsx-runtime` to the `extends` list
16 changes: 16 additions & 0 deletions app/components.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"$schema": "https://ui.shadcn.com/schema.json",
"style": "default",
"rsc": false,
"tsx": true,
"tailwind": {
"config": "tailwind.config.js",
"css": "app/globals.css",
"baseColor": "slate",
"cssVariables": true
},
"aliases": {
"components": "src/components",
"utils": "src/components/ui/lib/utils"
}
}
13 changes: 7 additions & 6 deletions app/index.html
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
<!DOCTYPE html>
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" href="/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Chat Nio</title>
<meta name="keywords" content="Chat, ChatGPT, AI聊天">
<meta name="description" content="👋Chat Nio, lightweight ChatGPT chat site ">
<meta name="keywords" content="Chat, ChatGPT, AI聊天, Web ChatGPT">
<meta name="description" content="👋 Chat Nio, lightweight Web ChatGPT chat site 👋 Chat Nio, 一个轻量级的联网版 ChatGPT AI 聊天网站">
<meta name="author" content="zmh-program">
<meta name="theme-color" content="#000000">
<meta itemprop="image" content="https://nio.fystart.cn/favicon.ico">
<link href="https://fonts.googlefonts.cn/css?family=Source+Sans+Pro" rel="stylesheet">
<meta name="baidu-site-verification" content="codeva-TJkbi40ZBi" />
<link href="https://fonts.googlefonts.cn/css?family=Andika" rel="stylesheet">
<link href="https://cdn.zmh-program.site/fonts/jetbrains-mono.css" rel="stylesheet">
</head>
<body>
<div id="app"></div>
<script type="module" src="/src/main.ts"></script>
<div id="root"></div>
<script type="module" src="/src/main.tsx"></script>
</body>
</html>
Binary file removed app/logo.png
Binary file not shown.
68 changes: 56 additions & 12 deletions app/package.json
Original file line number Diff line number Diff line change
@@ -1,23 +1,67 @@
{
"name": "app",
"private": true,
"version": "0.0.0",
"name": "chatnio",
"private": false,
"version": "2.0.0",
"type": "module",
"scripts": {
"dev": "vite",
"build": "vue-tsc && vite build",
"build": "tsc && vite build",
"lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
"prettier": "prettier --write \"src/**/*.tsx\" \"src/**/*.ts\"",
"preview": "vite preview"
},
"dependencies": {
"axios": "^1.4.0",
"md-editor-v3": "^4.2.2",
"vue": "^3.2.45",
"vue-router": "^4.2.4"
"@radix-ui/react-alert-dialog": "^1.0.4",
"@radix-ui/react-context-menu": "^2.1.4",
"@radix-ui/react-dialog": "^1.0.4",
"@radix-ui/react-dropdown-menu": "^2.0.5",
"@radix-ui/react-label": "^2.0.2",
"@radix-ui/react-slot": "^1.0.2",
"@radix-ui/react-switch": "^1.0.3",
"@radix-ui/react-toast": "^1.1.4",
"@radix-ui/react-toggle": "^1.0.3",
"@radix-ui/react-tooltip": "^1.0.6",
"@reduxjs/toolkit": "^1.9.5",
"axios": "^1.5.0",
"class-variance-authority": "^0.7.0",
"clsx": "^2.0.0",
"i18next": "^23.4.6",
"localforage": "^1.10.0",
"lucide-react": "^0.274.0",
"match-sorter": "^6.3.1",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-i18next": "^13.2.2",
"react-markdown": "^8.0.7",
"react-redux": "^8.1.2",
"react-router-dom": "^6.15.0",
"react-syntax-highlighter": "^15.5.0",
"sort-by": "^1.2.0",
"tailwind-merge": "^1.14.0",
"tailwindcss-animate": "^1.0.7"
},
"devDependencies": {
"@vitejs/plugin-vue": "^4.0.0",
"typescript": "^4.9.3",
"vite": "4.1.0-beta.0",
"vue-tsc": "^1.0.24"
"@rollup/plugin-terser": "^0.4.3",
"@types/node": "^20.5.9",
"@types/react": "^18.2.15",
"@types/react-dom": "^18.2.7",
"@types/react-syntax-highlighter": "^15.5.7",
"@typescript-eslint/eslint-plugin": "^6.0.0",
"@typescript-eslint/parser": "^6.0.0",
"@vitejs/plugin-react-swc": "^3.3.2",
"autoprefixer": "^10.4.15",
"eslint": "^8.45.0",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-react-refresh": "^0.4.3",
"less": "^4.2.0",
"less-loader": "^11.1.3",
"postcss": "^8.4.29",
"prettier": "^3.0.3",
"tailwindcss": "^3.3.3",
"terser": "^5.19.4",
"typescript": "^5.0.2",
"vite": "^4.4.5",
"vite-plugin-externals": "^0.6.2",
"vite-plugin-html": "^3.2.0"
}
}
Loading

0 comments on commit bd1bf4b

Please sign in to comment.