修复(hook): 修改hook
This commit is contained in:
parent
cd2e8824e0
commit
9d6340c83e
3
.commitlint.js
Normal file
3
.commitlint.js
Normal file
@ -0,0 +1,3 @@
|
||||
module.exports = {
|
||||
extends: ["@nicecode/commit-lint"],
|
||||
};
|
3
.eslintignore
Normal file
3
.eslintignore
Normal file
@ -0,0 +1,3 @@
|
||||
build/
|
||||
dist/
|
||||
.umi
|
36
.eslintrc.js
36
.eslintrc.js
@ -1,4 +1,36 @@
|
||||
module.exports = {
|
||||
extends: [require.resolve('uniubi-lint/typescript/react')],
|
||||
rules: {},
|
||||
extends: [
|
||||
"alloy",
|
||||
"alloy/react",
|
||||
"alloy/typescript"
|
||||
],
|
||||
plugins: [
|
||||
"@typescript-eslint/eslint-plugin"
|
||||
],
|
||||
parser: "@typescript-eslint/parser",
|
||||
parserOptions: {
|
||||
ecmaVersion: 2020,
|
||||
},
|
||||
"env": {
|
||||
// 您的环境变量(包含多个预定义的全局变量)
|
||||
// Your environments (which contains several predefined global variables)
|
||||
//
|
||||
// browser: true,
|
||||
// node: true,
|
||||
// mocha: true,
|
||||
// jest: true,
|
||||
// jquery: true
|
||||
},
|
||||
"globals": {
|
||||
// 您的全局变量(设置为 false 表示它不允许被重新赋值)
|
||||
// Your global variables (setting to false means it's not allowed to be reassigned)
|
||||
//
|
||||
// myGlobal: false
|
||||
},
|
||||
"rules": {
|
||||
// 自定义您的规则
|
||||
// Customize your rules
|
||||
"react/jsx-no-useless-fragment": 0,
|
||||
"@typescript-eslint/no-require-imports": 0
|
||||
}
|
||||
};
|
||||
|
37
.prettierrc.js
Normal file
37
.prettierrc.js
Normal file
@ -0,0 +1,37 @@
|
||||
module.exports = {
|
||||
// 一行最多 100 字符
|
||||
printWidth: 100,
|
||||
// 使用 4 个空格缩进
|
||||
tabWidth: 4,
|
||||
// 不使用缩进符,而使用空格
|
||||
useTabs: false,
|
||||
// 行尾需要有分号
|
||||
semi: true,
|
||||
// 使用单引号
|
||||
singleQuote: true,
|
||||
// 对象的 key 仅在必要时用引号
|
||||
quoteProps: 'as-needed',
|
||||
// jsx 不使用单引号,而使用双引号
|
||||
jsxSingleQuote: false,
|
||||
// 末尾不需要逗号
|
||||
trailingComma: 'none',
|
||||
// 大括号内的首尾需要空格
|
||||
bracketSpacing: true,
|
||||
// jsx 标签的反尖括号需要换行
|
||||
jsxBracketSameLine: false,
|
||||
// 箭头函数,只有一个参数的时候,也需要括号
|
||||
arrowParens: 'always',
|
||||
// 每个文件格式化的范围是文件的全部内容
|
||||
rangeStart: 0,
|
||||
rangeEnd: Infinity,
|
||||
// 不需要写文件开头的 @prettier
|
||||
requirePragma: false,
|
||||
// 不需要自动在文件开头插入 @prettier
|
||||
insertPragma: false,
|
||||
// 使用默认的折行标准
|
||||
proseWrap: 'preserve',
|
||||
// 根据显示样式决定 html 要不要折行
|
||||
htmlWhitespaceSensitivity: 'css',
|
||||
// 换行符使用 lf
|
||||
endOfLine: 'lf'
|
||||
};
|
@ -1,14 +1,14 @@
|
||||
import { defineConfig } from 'umi';
|
||||
import Icon from './public/favicon.ico'
|
||||
|
||||
export default defineConfig({
|
||||
favicon: Icon,
|
||||
favicon: '#',
|
||||
hash: true,
|
||||
dva: {
|
||||
immer: true,
|
||||
hmr: false,
|
||||
},
|
||||
webpack5: {},
|
||||
mfsu: {},
|
||||
dynamicImport: {
|
||||
loading: '@/components/PageLoading/index',
|
||||
},
|
||||
|
9
.vscode/settings.json
vendored
9
.vscode/settings.json
vendored
@ -2,14 +2,9 @@
|
||||
"editor.codeActionsOnSave": {
|
||||
"source.fixAll.eslint": true
|
||||
},
|
||||
"eslint.validate": [
|
||||
"javascript",
|
||||
"react",
|
||||
"typescript",
|
||||
"typescriptreact",
|
||||
"vue"
|
||||
],
|
||||
"editor.formatOnSave": true,
|
||||
"editor.defaultFormatter": "esbenp.prettier-vscode",
|
||||
"eslint.validate": ["javascript", "react", "typescript", "typescriptreact", "vue"],
|
||||
"[typescriptreact]": {
|
||||
"editor.defaultFormatter": null
|
||||
},
|
||||
|
27
package.json
27
package.json
@ -11,7 +11,18 @@
|
||||
"lint:fix": "eslint 'src/**/*.{js,jsx,tsx,ts}' --fix",
|
||||
"prettier": "prettier --write '**/*.{less,css,md,json}'",
|
||||
"test": "umi-test",
|
||||
"test:coverage": "umi-test --coverage"
|
||||
"test:coverage": "umi-test --coverage",
|
||||
"cz": "git add . && git cz"
|
||||
},
|
||||
"config": {
|
||||
"commitizen": {
|
||||
"path": "@nicecode/commit"
|
||||
}
|
||||
},
|
||||
"husky": {
|
||||
"hooks": {
|
||||
"commit-msg": "commitlint -E HUSKY_GIT_PARAMS"
|
||||
}
|
||||
},
|
||||
"gitHooks": {
|
||||
"pre-commit": "tsc --noEmit && lint-staged"
|
||||
@ -27,26 +38,30 @@
|
||||
]
|
||||
},
|
||||
"dependencies": {
|
||||
"@ant-design/icons": "^4.7.0",
|
||||
"@ant-design/pro-layout": "^6.15.4",
|
||||
"@materials/user-avatar": "^1.0.1",
|
||||
"@ant-design/icons-react": "^2.0.10",
|
||||
"antd": "^100.0.1",
|
||||
"antd": "^4.20.6",
|
||||
"axios": "^0.19.2",
|
||||
"classnames": "^2.2.6",
|
||||
"js-cookie": "^2.2.1",
|
||||
"poseidon-web-monitoring": "^1.1.3",
|
||||
"react": "^17.0.1",
|
||||
"react-dom": "^17.0.1",
|
||||
"umi": "^3.5.15"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@nicecode/commit-lint": "^0.1.2",
|
||||
"@types/classnames": "^2.2.10",
|
||||
"@typescript-eslint/eslint-plugin": "^5.26.0",
|
||||
"@typescript-eslint/parser": "^5.26.0",
|
||||
"@umijs/preset-react": "1.x",
|
||||
"@umijs/test": "^3.0.16",
|
||||
"babel-plugin-transform-remove-console": "^6.9.4",
|
||||
"commitlint": "^17.0.1",
|
||||
"cross-env": "^7.0.2",
|
||||
"end-type-to-front-type": "^1.2.1",
|
||||
"eslint": "^7.16.0",
|
||||
"eslint-config-alloy": "^4.5.1",
|
||||
"eslint-plugin-react": "^7.30.0",
|
||||
"husky": "^8.0.1",
|
||||
"lint-staged": "^10.0.7",
|
||||
"prettier": "^1.19.1",
|
||||
"typescript": "^4.1.3",
|
||||
|
@ -1,5 +1,2 @@
|
||||
import { enableES5 } from 'immer';
|
||||
import '@/styles/index.less';
|
||||
import '@/styles/reset.less';
|
||||
|
||||
enableES5();
|
@ -1,12 +1,10 @@
|
||||
import UserAvatar from '@materials/user-avatar';
|
||||
|
||||
const User = () => {
|
||||
function User() {
|
||||
return (
|
||||
<UserAvatar name="admin">
|
||||
<>
|
||||
<div>个人中心</div>
|
||||
<div>退出登录</div>
|
||||
</UserAvatar>
|
||||
</>
|
||||
);
|
||||
};
|
||||
}
|
||||
|
||||
export default User;
|
||||
|
@ -1,3 +1,5 @@
|
||||
import React from 'react';
|
||||
|
||||
export interface BaseProps {
|
||||
className?: string;
|
||||
style?: React.CSSProperties;
|
||||
|
@ -2,7 +2,7 @@ import React from 'react';
|
||||
import { history } from 'umi';
|
||||
import { Button } from 'antd';
|
||||
import { ButtonProps } from 'antd/lib/button';
|
||||
import { HomeFilled } from '@ant-design/icons-react';
|
||||
import { HomeOutlined } from '@ant-design/icons';
|
||||
import classnames from 'classnames';
|
||||
import './index.less';
|
||||
|
||||
@ -15,7 +15,7 @@ const BreadcrumbItem = ({
|
||||
children,
|
||||
className,
|
||||
...rest
|
||||
}: BreadcrumbItemProps): JSX.Element => {
|
||||
}: BreadcrumbItemProps) => {
|
||||
return (
|
||||
<Button
|
||||
className={classnames('g-basic-layout-header-breadcrumb-item', className)}
|
||||
@ -39,7 +39,7 @@ const RootItem: React.FC<ButtonProps> = ({ className, ...rest }) => (
|
||||
onClick={() => history.push('/')}
|
||||
{...rest}
|
||||
>
|
||||
<HomeFilled />
|
||||
<HomeOutlined />
|
||||
</Button>
|
||||
);
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
@import "../../styles/var.less";
|
||||
@import '../../styles/var.less';
|
||||
|
||||
.g-basic-layout {
|
||||
&-header {
|
||||
|
@ -1,15 +1,20 @@
|
||||
import React from 'react';
|
||||
import { history, Link } from 'umi';
|
||||
import { EntranceOutlined } from '@ant-design/icons-react';
|
||||
import { EnterOutlined } from '@ant-design/icons';
|
||||
import ProLayout, { MenuDataItem } from '@ant-design/pro-layout';
|
||||
import { HeaderViewProps } from '@ant-design/pro-layout/lib/Header';
|
||||
import User from '@/components/User';
|
||||
// import User from '@/components/User';
|
||||
import Breadcrumb from './Breadcrumb';
|
||||
import './index.less';
|
||||
|
||||
const BasicLayout: React.FC = ({ children, ...rest }) => {
|
||||
|
||||
interface IBasicLayout {
|
||||
children: React.ReactNode
|
||||
}
|
||||
|
||||
const BasicLayout: React.FC<IBasicLayout> = ({ children, ...rest }: any) => {
|
||||
const iconMap = {
|
||||
EntranceOutlined: <EntranceOutlined />,
|
||||
EnterOutlined: <EnterOutlined />,
|
||||
};
|
||||
|
||||
// 带子菜单的一级导航
|
||||
@ -52,13 +57,13 @@ const BasicLayout: React.FC = ({ children, ...rest }) => {
|
||||
};
|
||||
|
||||
// 用户信息
|
||||
const renderUserAvatar = () => <User />;
|
||||
// const renderUserAvatar = () => <User />;
|
||||
|
||||
return (
|
||||
<ProLayout
|
||||
className="g-basic-layout"
|
||||
logo="https://fe-cloud.uni-ubi.com/image/1625038486292-logo-r.png?x-oss-process=img/q/80"
|
||||
title="Uni-Ubi"
|
||||
logo="http://jzx-h5.oss-cn-hangzhou.aliyuncs.com/static/pill.png?x-oss-process=img/q/80"
|
||||
title="nicecode"
|
||||
siderWidth={180}
|
||||
fixedHeader
|
||||
fixSiderbar
|
||||
@ -66,7 +71,7 @@ const BasicLayout: React.FC = ({ children, ...rest }) => {
|
||||
subMenuItemRender={renderSubMenuItem}
|
||||
menuItemRender={renderMenuItem}
|
||||
headerContentRender={renderHeaderContent}
|
||||
rightContentRender={renderUserAvatar}
|
||||
// rightContentRender={renderUserAvatar}
|
||||
{...rest}
|
||||
>
|
||||
{children}
|
||||
|
@ -1,5 +1,9 @@
|
||||
import React from 'react';
|
||||
|
||||
const BlankLayout: React.FC = ({ children }) => <>{children}</>;
|
||||
interface IBlankLayout {
|
||||
children: React.ReactNode
|
||||
}
|
||||
|
||||
const BlankLayout: React.FC<IBlankLayout> = ({ children }) => (<>{children}</>);
|
||||
|
||||
export default BlankLayout;
|
||||
|
@ -3,7 +3,7 @@ import { Image, Divider } from 'antd';
|
||||
import User from '@/components/User';
|
||||
import './index.less';
|
||||
|
||||
const Header = () => {
|
||||
function Header() {
|
||||
return (
|
||||
<div className="g-window-layout-header">
|
||||
<div
|
||||
@ -28,6 +28,6 @@ const Header = () => {
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
}
|
||||
|
||||
export default Header;
|
||||
|
@ -1,4 +1,4 @@
|
||||
@import "../../styles/var.less";
|
||||
@import '../../styles/var.less';
|
||||
|
||||
@headerHeader: 64px;
|
||||
|
||||
|
@ -2,7 +2,11 @@ import React from 'react';
|
||||
import Header from './Header';
|
||||
import './index.less';
|
||||
|
||||
const WindowLayout: React.FC = ({ children }) => {
|
||||
interface IWindowLayout {
|
||||
children: React.ReactNode
|
||||
}
|
||||
|
||||
const WindowLayout: React.FC<IWindowLayout> = ({ children }) => {
|
||||
return (
|
||||
<div className="g-window-layout">
|
||||
<div className="g-window-layout-header-wrapper">
|
||||
|
@ -1,3 +1,5 @@
|
||||
.title {
|
||||
background: rgb(121, 242, 157);
|
||||
margin: 100px auto;
|
||||
text-align: center;
|
||||
// background: rgb(121, 242, 157);
|
||||
}
|
||||
|
@ -1,9 +1,9 @@
|
||||
import styles from './index.less';
|
||||
|
||||
export default () => {
|
||||
export default function () {
|
||||
return (
|
||||
<div>
|
||||
<h1 className={styles.title}>index</h1>
|
||||
<h1 className={styles.title}>welcome! there is nicecode!</h1>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
}
|
||||
|
@ -1 +1 @@
|
||||
@import "./var.less";
|
||||
@import './var.less';
|
||||
|
@ -1,4 +1,4 @@
|
||||
@import "var.less";
|
||||
@import 'var.less';
|
||||
|
||||
.ant-picker {
|
||||
width: 100%;
|
||||
|
@ -5,6 +5,7 @@ import { ConnectState } from '@/models/connect';
|
||||
export interface SecurityWrapperProps {
|
||||
token: string;
|
||||
dispatch: Dispatch;
|
||||
children: React.ReactNode
|
||||
}
|
||||
|
||||
const SecurityWrapper: React.FC<SecurityWrapperProps> = ({
|
||||
|
@ -22,13 +22,5 @@
|
||||
"@@/*": ["./src/.umi/*"]
|
||||
}
|
||||
},
|
||||
"exclude": [
|
||||
"node_modules",
|
||||
"build",
|
||||
"dist",
|
||||
"scripts",
|
||||
"src/.umi/*",
|
||||
"webpack",
|
||||
"jest"
|
||||
]
|
||||
"exclude": ["node_modules", "build", "dist", "scripts", "src/.umi/*", "webpack", "jest"]
|
||||
}
|
||||
|
1
typings.d.ts
vendored
1
typings.d.ts
vendored
@ -3,3 +3,4 @@ declare module '*.less';
|
||||
declare module '*.png';
|
||||
declare module '*.jpeg';
|
||||
declare module '*.jpg';
|
||||
declare module 'immer'
|
||||
|
Loading…
Reference in New Issue
Block a user