Skip to content

Commit b4220e4

Browse files
author
zhangkang
committed
更改配置
1 parent 32d7afc commit b4220e4

File tree

7 files changed

+120
-142
lines changed

7 files changed

+120
-142
lines changed

.DS_Store

0 Bytes
Binary file not shown.

.eslintrc.js

Lines changed: 0 additions & 118 deletions
This file was deleted.

.eslintrc.json

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
2+
{
3+
  //文件名 .eslintrc.json
4+
  "env": {
5+
    "browser": true,
6+
    "es6": true,
7+
    "node": true,
8+
    "commonjs": true
9+
  },
10+
  "extends": "eslint:recommended",
11+
  "installedESLint": true,
12+
  "parserOptions": {
13+
    "ecmaFeatures": {
14+
      "experimentalObjectRestSpread": true,
15+
      "jsx": true,
16+
      "arrowFunctions": true,
17+
      "classes": true,
18+
      "modules": true,
19+
      "defaultParams": true
20+
    },
21+
    "sourceType": "module"
22+
  },
23+
  "parser": "babel-eslint",
24+
  "plugins": ["react"],
25+
  "rules": {
26+
    "linebreak-style": ["error", "unix"],
27+
    //"semi": ["error", "always"],
28+
    "no-empty": 0,
29+
    "comma-dangle": 0,
30+
    "no-unused-vars": 0,
31+
    "no-console": 0,
32+
    "no-const-assign": 2,
33+
    "no-dupe-class-members": 2,
34+
    "no-duplicate-case": 2,
35+
    "no-extra-parens": [2, "functions"],
36+
    "no-self-compare": 2,
37+
    "accessor-pairs": 2,
38+
    "comma-spacing": [
39+
      2,
40+
      {
41+
        "before": false,
42+
        "after": true
43+
      }
44+
    ],
45+
    "constructor-super": 2,
46+
    "new-cap": [
47+
      2,
48+
      {
49+
        "newIsCap": true,
50+
        "capIsNew": false
51+
      }
52+
    ],
53+
    "new-parens": 2,
54+
    "no-array-constructor": 2,
55+
    "no-class-assign": 2,
56+
    "no-cond-assign": 2
57+
  }
58+
}

src/.DS_Store

4 KB
Binary file not shown.

src/pages/Article/index.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import useInitial from '@/hooks/useInitail';
22
import React, { useRef } from "react";
3-
import { Viewer } from "@bytemd/react";
3+
import { Viewer} from "@bytemd/react";
44
import * as API from './api';
55
import gfm from "@bytemd/plugin-gfm";
66
import highlightssr from "@bytemd/plugin-highlight-ssr";
@@ -47,13 +47,13 @@ const plugins = [
4747

4848
const Article: React.FC = () => {
4949
const {artid} = useParams<any>();
50-
const {data} = useInitial(API.getArticleDetail,{content: ''},{artid: Number(artid)})
50+
const {data} = useInitial(API.getArticleDetail,{content: '测试'},{artid: Number(artid)})
5151
const {data: commentList, setLoading: setCommentLoading} = useInitial(API.findCommentList,[], {artid: Number(artid)})
5252
const [visible,setVisible] = React.useState(false);
5353
const [row, setRow] = React.useState<CommentType>({});
5454
const [form] = Form.useForm();
5555

56-
console.log(commentList)
56+
console.log(data);
5757

5858
const onSave = (values:any) => {
5959
console.log(values)
@@ -80,7 +80,7 @@ const Article: React.FC = () => {
8080
return (
8181
<div className="article-content">
8282
<div className="article-container">
83-
<Viewer value={data.content} plugins={plugins} />
83+
<Viewer value={data.content} plugins={plugins}/>
8484
</div>
8585
<div className="nav-container">
8686
{/* <div style={{color: 'black', fontSize: 20,textAlign: 'center'}}>目录</div> */}

tsconfig.json

Lines changed: 56 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,66 @@
1+
// {
2+
// "compilerOptions": {
3+
// "experimentalDecorators": true,
4+
// "target": "ESNext",
5+
// "useDefineForClassFields": true,
6+
// "lib": ["DOM", "DOM.Iterable", "ESNext"],
7+
// "allowJs": false,
8+
// "skipLibCheck": false,
9+
// "esModuleInterop": false,
10+
// "allowSyntheticDefaultImports": true,
11+
// "strict": true,
12+
// "forceConsistentCasingInFileNames": true,
13+
// "module": "ESNext",
14+
// "moduleResolution": "Node",
15+
// "resolveJsonModule": true,
16+
// "isolatedModules": true,
17+
// "noEmit": true,
18+
// "jsx": "react",
19+
// "baseUrl": ".",
20+
// "paths": {
21+
// "@/*": ["./src/*"]
22+
// },
23+
// },
24+
// "include": [
25+
// "src",
26+
// ],
27+
// "exclude": [
28+
// "node_modules"
29+
// ],
30+
// }
131
{
232
"compilerOptions": {
3-
"experimentalDecorators": true,
4-
"target": "ESNext",
5-
"useDefineForClassFields": true,
6-
"lib": ["DOM", "DOM.Iterable", "ESNext"],
7-
"allowJs": false,
8-
"skipLibCheck": false,
9-
"esModuleInterop": false,
10-
"allowSyntheticDefaultImports": true,
11-
"strict": true,
12-
"forceConsistentCasingInFileNames": true,
13-
"module": "ESNext",
14-
"moduleResolution": "Node",
15-
"resolveJsonModule": true,
16-
"isolatedModules": true,
17-
"noEmit": true,
18-
"jsx": "react",
33+
"target": "es5", // 指定 ECMAScript 版本
34+
"lib": [
35+
"dom",
36+
"dom.iterable",
37+
"esnext"
38+
], // 要包含在编译中的依赖库文件列表
39+
"allowJs": true, // 允许编译 JavaScript 文件
40+
"skipLibCheck": true, // 跳过所有声明文件的类型检查
41+
"esModuleInterop": true, // 禁用命名空间引用 (import * as fs from "fs") 启用 CJS/AMD/UMD 风格引用 (import fs from "fs")
42+
"allowSyntheticDefaultImports": true, // 允许从没有默认导出的模块进行默认导入
43+
"strict": true, // 启用所有严格类型检查选项
44+
"forceConsistentCasingInFileNames": true, // 不允许对同一个文件使用不一致格式的引用
45+
"module": "esnext", // 指定模块代码生成
46+
"moduleResolution": "node", // 使用 Node.js 风格解析模块
47+
"resolveJsonModule": true, // 允许使用 .json 扩展名导入的模块
48+
"noEmit": true, // 不输出(意思是不编译代码,只执行类型检查
49+
"jsx": "react", // 在.tsx文件中支持JSX
50+
"sourceMap": true, // 生成相应的.map文件
51+
"declaration": true, // 生成相应的.d.ts文件
52+
"noUnusedLocals": true, // 报告未使用的本地变量的错误
53+
"noUnusedParameters": true, // 报告未使用参数的错误
54+
"experimentalDecorators": true, // 启用对ES装饰器的实验性支持
55+
"incremental": true, // 通过从以前的编译中读取/写入信息到磁盘上的文件来启用增量编译
56+
"noFallthroughCasesInSwitch": true ,
1957
"baseUrl": ".",
2058
"paths": {
2159
"@/*": ["./src/*"]
2260
},
2361
},
2462
"include": [
25-
"src",
26-
],
27-
"exclude": [
28-
"node_modules"
63+
"src/**/*" // *** TypeScript文件应该进行类型检查 ***
2964
],
65+
"exclude": ["node_modules"] // *** 不进行类型检查的文件 ***}
3066
}

vite.config.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { defineConfig } from 'vite'
22
import react from '@vitejs/plugin-react'
3+
// @ts-ignore
34
import path from 'path'
45
// import typescript from "@rollup/plugin-typescript";
56

@@ -14,6 +15,7 @@ export default defineConfig({
1415
base: './',
1516
resolve:{
1617
alias:{
18+
// @ts-ignore
1719
'@': path.resolve(__dirname,'./src')
1820
},
1921
extensions: [".tsx", ".ts", ".js"],

0 commit comments

Comments
 (0)