From 7fb76cde0b2b73ee26ed86b6dabcc5863ec27d81 Mon Sep 17 00:00:00 2001 From: Archer <545436317@qq.com> Date: Fri, 10 Mar 2023 20:18:31 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E7=B1=BB=E5=9E=8B=E5=A3=B0=E6=98=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 4 ++-- src/components/Markdown/index.tsx | 5 +++-- src/service/mongo.ts | 2 +- src/types/index.d.ts | 7 ++----- tsconfig.json | 6 +++--- 5 files changed, 11 insertions(+), 13 deletions(-) diff --git a/package.json b/package.json index 2983bcaf5..c81c369d7 100644 --- a/package.json +++ b/package.json @@ -45,7 +45,6 @@ "sass": "^1.58.3", "sharp": "^0.31.3", "tunnel": "^0.0.6", - "typescript": "4.9.5", "uuid": "^9.0.0", "zustand": "^4.3.5" }, @@ -63,7 +62,8 @@ "eslint-config-next": "13.1.6", "husky": "^8.0.3", "lint-staged": "^13.1.2", - "prettier": "^2.8.4" + "prettier": "^2.8.4", + "typescript": "4.9.5" }, "lint-staged": { "./src/**/*.{ts,tsx,scss}": "npm run format" diff --git a/src/components/Markdown/index.tsx b/src/components/Markdown/index.tsx index 299ec0a6e..676281fac 100644 --- a/src/components/Markdown/index.tsx +++ b/src/components/Markdown/index.tsx @@ -25,7 +25,8 @@ const Markdown = ({ source, isChatting }: { source: string; isChatting: boolean pre: 'div', code({ node, inline, className, children, ...props }) { const match = /language-(\w+)/.exec(className || ''); - const code = String(children).replace(/\n$/, ''); + const code = String(children); + return !inline || match ? ( ) : ( - {children} + {code} ); } diff --git a/src/service/mongo.ts b/src/service/mongo.ts index 6e4b81e5a..0255684a0 100644 --- a/src/service/mongo.ts +++ b/src/service/mongo.ts @@ -1,4 +1,4 @@ -import mongoose, { Mongoose } from 'mongoose'; +import mongoose from 'mongoose'; /** * 连接 MongoDB 数据库 diff --git a/src/types/index.d.ts b/src/types/index.d.ts index a0eb4fa85..003a22551 100644 --- a/src/types/index.d.ts +++ b/src/types/index.d.ts @@ -1,9 +1,6 @@ import type { Mongoose } from 'mongoose'; declare global { - namespace NodeJS { - interface Global { - mongodb: Mongoose | string; - } - } + var mongodb: Mongoose | string | null; } +export {}; diff --git a/tsconfig.json b/tsconfig.json index 10d295142..fa4b956b4 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -3,7 +3,6 @@ "target": "es5", "lib": ["dom", "dom.iterable", "esnext"], "allowJs": true, - "noImplicitAny": true, "skipLibCheck": true, "strict": true, "forceConsistentCasingInFileNames": true, @@ -18,8 +17,9 @@ "baseUrl": ".", "paths": { "@/*": ["./src/*"] - } + }, + "declaration": true }, - "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", "**/*.d.ts"], + "include": ["next-env.d.ts", "src/**/*"], "exclude": ["node_modules"] }