Skip to content

Commit 2f57308

Browse files
committed
fix
1 parent e31adc2 commit 2f57308

22 files changed

+305
-63
lines changed

Diff for: .eslintrc.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ module.exports = {
4545
'default-case': 2,
4646
'no-spaced-func': 2,
4747
'no-case-declarations': 0,
48+
'no-sparse-arrays': 0,
4849
// react jsx
4950
'react/display-name': 0,
5051
'react/jsx-filename-extension': 'off',
@@ -61,15 +62,14 @@ module.exports = {
6162
'@typescript-eslint/no-use-before-define': 0,
6263
'@typescript-eslint/member-delimiter-style': 0,
6364
'@typescript-eslint/no-unused-vars': 0,
64-
'@typescript-eslint/no-use-before-define': 0,
6565
'@typescript-eslint/no-explicit-any': 0,
6666
'@typescript-eslint/explicit-member-accessibility': 0,
6767
'@typescript-eslint/no-angle-bracket-type-assertion': 0,
6868
'@typescript-eslint/interface-name-prefix': 0,
6969
'@typescript-eslint/no-empty-function': 1,
7070
'@typescript-eslint/semi': 0,
7171
'@typescript-eslint/no-inferrable-types': 0,
72-
'@typescript-eslint/no-empty-interface': 1,
72+
'@typescript-eslint/no-empty-interface': 0,
7373
'@typescript-eslint/class-name-casing': 0,
7474
}
7575
};

Diff for: build/donePlugin.js

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
2+
class DonePlugin {
3+
apply(compiler) {
4+
compiler.hooks.done.tap('DonePlugin', (stats) => {
5+
console.log('编译完成....')
6+
// console.log(stats)
7+
})
8+
}
9+
}
10+
11+
module.exports = DonePlugin

Diff for: build/px2rem-loader.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
const loaderUtils = require('loader-utils')
22

3-
const pxReg = /\b(\d+(\.\d+)?)PX\b/g
3+
const pxReg = /\b(\d+(\.\d+)?)px\b/g
44

55
module.exports = function(content) {
66

Diff for: build/webpack.base.conf.js

+12-9
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ const path = require('path'),
66
ManifestPlugin = require('webpack-manifest-plugin'),
77
SWPrecacheWebpackPlugin = require('sw-precache-webpack-plugin');
88

9+
const DonePlugin = require('./donePlugin')
910
const _PROD_ = process.env.NODE_ENV === 'production';
1011

1112
const resolve = (dir) => {
@@ -42,14 +43,14 @@ module.exports = {
4243
// transpileOnly: true
4344
// }
4445
// },
45-
{
46-
test: /\.(j|t)sx?$/,
47-
loader: 'px2rem-loader',
48-
options: {
49-
remRoot: 40,
50-
fixed: 6
51-
}
52-
},
46+
// {
47+
// test: /\.(j|t)sx?$/,
48+
// loader: 'px2rem-loader',
49+
// options: {
50+
// remRoot: 40,
51+
// fixed: 6
52+
// }
53+
// },
5354
{
5455
test: /\.(j|t)sx?$/,
5556
include: [
@@ -67,7 +68,7 @@ module.exports = {
6768
exclude: ['transform-typeof-symbol'],
6869
}],
6970
["@babel/preset-react", {
70-
"targets": "last 2 versions, ie 11", "modules": false
71+
targets: "last 2 versions, ie 11", modules: false
7172
}],
7273
["@babel/preset-typescript"]
7374
],
@@ -181,6 +182,8 @@ module.exports = {
181182
},
182183

183184
plugins: [
185+
// new webpack.ContextReplacementPlugin(/moment[\/\\]locale$/, /zh-cn/),
186+
new DonePlugin(),
184187
// new webpack.DefinePlugin({
185188
// "process.env": {
186189
// NODE_ENV: JSON.stringify(_PROD_ ? "development" : "production")

Diff for: build/webpack.prod.conf.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ const webpackConfig = merge(baseWebpackConfig, {
2121
new UglifyJsPlugin({
2222
uglifyOptions: {
2323
compress: {
24-
warnings: false,
24+
// warnings: false,
2525
drop_console: _PROD_ ? true : false,
2626
},
2727
output: {

Diff for: package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@
2525
"echarts": "^4.2.0-rc.2",
2626
"mobx": "^5.15.0",
2727
"mobx-react": "^6.1.4",
28-
"quill": "^1.3.6",
28+
"quill": "^1.3.7",
29+
"quill-image-resize-module": "^3.0.0",
2930
"react": "^16.11.0",
3031
"react-dom": "^16.11.0",
3132
"react-router-dom": "^5.1.2"

Diff for: src/@types/global.d.ts

+29-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import { MessageApi } from 'antd/lib/message'
22
import { NotificationApi } from 'antd/lib/notification'
33
import { RouteComponentProps } from 'react-router-dom'
4-
import { AxiosInstance } from 'axios'
4+
import { AxiosStatic } from 'axios'
5+
56

67
declare global {
7-
export const $http: AxiosInstance
88

99
export const $msg: MessageApi
1010

@@ -13,4 +13,31 @@ declare global {
1313
export interface IProps extends RouteComponentProps {
1414
[key: string]: any
1515
}
16+
17+
interface IResponseData<T = any> {
18+
data: T
19+
msg: string
20+
status: number
21+
}
22+
23+
interface IPageData<T = any> {
24+
data: T[]
25+
meta: {
26+
count?: number
27+
page: number
28+
pageSize: number
29+
total?: number
30+
totalPage?: number
31+
showTotal?: (total: number) => React.ReactNode
32+
}
33+
msg?: string
34+
status?: number
35+
}
36+
37+
type IPageParams = Pick<IPageData['meta'], 'page' | 'pageSize'>
38+
39+
interface IOption<V = any, L = string> {
40+
label: L
41+
value: V
42+
}
1643
}

Diff for: src/components/editor/index.tsx

+12-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,16 @@
11
import * as React from 'react'
22
import { QuillOptionsStatic } from 'quill'
33
import * as Q from 'quill'
4+
// const ImageResize = require('quill-image-resize-module/src/ImageResize.js');
5+
// console.log(ImageResize, 'imageresize')
6+
interface IQuillOptions extends QuillOptionsStatic {
7+
// imageResize: {
8+
// displaySize: boolean
9+
// }
10+
}
411

512
const Quill: any = Q
13+
// Quill.register('modules/imageResize', ImageResize)
614

715
const toolbarOptions = [
816
['bold', 'italic', 'underline', 'strike'], // toggled buttons
@@ -37,8 +45,11 @@ export default class QuillEditorComponent extends React.Component<IEditor> {
3745
oldVal: string = ''
3846

3947
quillEditor: any = null
40-
quillOptions: QuillOptionsStatic = {
48+
quillOptions: IQuillOptions = {
4149
// debug: false,
50+
imageResize: {
51+
displaySize: true // default false
52+
},
4253
modules: {
4354
toolbar: toolbarOptions,
4455
},

Diff for: src/pages/dashboard/dashboard.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export default class Dashboard extends React.Component {
55
return <div>
66
<p>Welcome to Dashboard!</p>
77
<div>GraphQL Application. </div>
8-
<p style={{width: '400PX', height: 40, fontSize: '24px'}}>测试rem</p>
8+
{/* <p style={{width: '400px', height: '40PX', fontSize: '24px'}}>测试rem</p> */}
99
<div>66px</div>
1010
</div>
1111
}

Diff for: src/pages/demo/demoRedux.tsx

-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import * as React from 'react'
22
import { Row, Col, Button, Badge, Icon, Form, Input, Select } from 'antd'
33
import { ReduxProvider, connect } from '../../plugins/react-redux'
44
import { store, countActions } from './reducer'
5-
import { HookButton } from './demoHooks'
65

76
console.log(store.getState(), '---store')
87

@@ -62,7 +61,6 @@ class DemoRedux extends React.Component<any> {
6261
<Button onClick={ADD}>
6362
<Icon type="plus" />
6463
</Button>
65-
<HookButton></HookButton>
6664
</Col>
6765
</Row>
6866
</section>

Diff for: src/pages/home/components/sider.tsx

+17-8
Original file line numberDiff line numberDiff line change
@@ -44,16 +44,25 @@ const MenuList = [{
4444
},{
4545
key: '5-2', title: '统计图', path: '/home/lottery-chart', icon: 'bar-chart'
4646
}]
47-
},{
48-
key:'99', title:'Demo', icon:'bulb',
49-
children: [{
50-
key: '99-0', title: '示例', path: '/home/demos', icon:'experiment'
51-
},{
52-
key: '99-1', title: '示例mobx', path: '/home/demo-mobx', icon:'experiment'
47+
},,{
48+
key:'6', title:'Stocks', icon:'stock',
49+
children: [{
50+
key: '6-0', title: 'Stock', path: '/home/stocks', icon: 'dollar'
51+
},{
52+
key: '6-1', title: 'Stock History', path: '/home/stocks-history', icon: 'fund'
53+
}]
5354
},{
54-
key: '99-2', title: '示例redux', path: '/home/demo-redux', icon:'experiment'
55+
key:'99', title:'Demo', icon:'bulb',
56+
children: [{
57+
key: '99-0', title: '示例', path: '/home/demos', icon:'experiment'
58+
},{
59+
key: '99-1', title: '示例mobx', path: '/home/demo-mobx', icon:'experiment'
60+
},{
61+
key: '99-2', title: '示例redux', path: '/home/demo-redux', icon:'experiment'
62+
},{
63+
key: '99-3', title: '示例hooks', path: '/home/demo-hooks', icon:'experiment'
64+
}]
5565
}]
56-
}]
5766

5867
class SiderComponent extends React.Component<ISiderProps> {
5968

Diff for: src/pages/stocks/history.tsx

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import React, { useState, useEffect } from 'react'
2+
3+
const ShareHistories: React.FC = () => {
4+
return <div></div>
5+
}
6+
7+
export default ShareHistories

Diff for: src/pages/stocks/index.tsx

+70
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
import React, { useState, useEffect } from 'react'
2+
import { Row, Col, Form, Table, Input, Button, Spin, Select } from 'antd'
3+
import { listColumns } from './util'
4+
import { stockPageList, IStockQuery } from '../../services/stock'
5+
import { data2PageData, pageData2Params } from '../../utils/tools'
6+
import { marketOpts, blockOpts } from '../../types/stock'
7+
8+
const ShareList: React.FC = () => {
9+
10+
const [code, setCode] = useState('')
11+
const [name, setName] = useState('')
12+
const [loading, setLoading] = useState(false)
13+
const [pageData, setPageData] = useState(data2PageData())
14+
15+
const onQuery = (params: Partial<IStockQuery> = pageData2Params(pageData.meta)) => {
16+
setLoading(true)
17+
stockPageList({...params, code, name}).then(res => {
18+
const data = data2PageData(res)
19+
setPageData(data)
20+
}).finally(() => setLoading(false))
21+
}
22+
23+
useEffect(() => {
24+
onQuery()
25+
}, [])
26+
27+
28+
return <Spin spinning={loading}>
29+
<Form>
30+
<Row gutter={16}>
31+
<Col span={6}>
32+
<Form.Item>
33+
<Input placeholder="代码" onChange={({target: {value}}) => setCode(value)}/>
34+
</Form.Item>
35+
</Col>
36+
<Col span={6}>
37+
<Form.Item>
38+
<Input placeholder="名称" onChange={({target: {value}}) => setName(value)}/>
39+
</Form.Item>
40+
</Col>
41+
<Col span={6}>
42+
<Form.Item>
43+
<Select placeholder="请选择市场"/>
44+
</Form.Item>
45+
</Col>
46+
<Col span={6}>
47+
<Form.Item>
48+
<Select placeholder="请选择板块"/>
49+
</Form.Item>
50+
</Col>
51+
</Row>
52+
<Row>
53+
<Col span={6} offset={18}>
54+
<Button onClick={() => onQuery()}>查询</Button>
55+
</Col>
56+
</Row>
57+
</Form>
58+
<Table
59+
columns={listColumns()}
60+
dataSource={pageData.data}
61+
pagination={{
62+
...pageData.meta,
63+
onChange: (page, pageSize) => onQuery({page, pageSize})
64+
}}
65+
/>
66+
</Spin>
67+
}
68+
69+
70+
export default ShareList

Diff for: src/pages/stocks/util.tsx

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import React, { useState, useEffect } from 'react'
2+
import { ColumnProps } from 'antd/lib/table'
3+
import { Stock, EMarket, EBlock } from '../../types/stock'
4+
import { Button } from 'antd'
5+
6+
export const listColumns = (): ColumnProps<Stock>[] => {
7+
return [{
8+
title: 'ID',
9+
dataIndex: 'id',
10+
}, {
11+
title: '名称',
12+
dataIndex: 'name',
13+
width: '120px',
14+
}, {
15+
title: '代码',
16+
dataIndex: 'code'
17+
}, {
18+
title: '市场',
19+
dataIndex: 'market',
20+
render: (v, data) => EMarket[data.market]
21+
}, {
22+
title: '板块',
23+
dataIndex: 'block',
24+
render: (v, data) => EBlock[data.block]
25+
}, {
26+
title: '操作',
27+
dataIndex: '',
28+
width: '30px',
29+
render: (v, data) => <Button type="link">查看</Button>
30+
}]
31+
}

Diff for: src/pages/user/userEditStore.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { observable, action, autorun, runInAction, computed } from 'mobx'
22
import { GRAPHQL_API } from '@constants/index'
33

44
const getUser = `
5-
query getUser($id: String!){
5+
{
66
user(id: $id){
77
id
88
username

0 commit comments

Comments
 (0)