Skip to content

Commit 261b533

Browse files
committed
feat: 系统设置面板里添加对tagsView的设置
1 parent a9354ec commit 261b533

File tree

4 files changed

+34
-4
lines changed

4 files changed

+34
-4
lines changed

src/defaultSettings.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,10 @@ export default {
1818
* @description Whether fix the header
1919
*/
2020
fixedHeader: false,
21+
22+
/**
23+
* @type {boolean} true | false
24+
* @description Whether need tagsView
25+
*/
26+
tagsView: true,
2127
};

src/store/reducers/settings.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
import * as types from "../action-types";
22
import defaultSettings from "@/defaultSettings";
3-
const { showSettings, sidebarLogo ,fixedHeader} = defaultSettings;
3+
const { showSettings, sidebarLogo, fixedHeader, tagsView } = defaultSettings;
44

55
const initState = {
66
showSettings: showSettings,
77
sidebarLogo: sidebarLogo,
88
fixedHeader: fixedHeader,
9+
tagsView: tagsView,
910
};
1011
export default function settings(state = initState, action) {
1112
switch (action.type) {

src/views/layout/RightPanel/index.jsx

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ class RightPanel extends Component {
77
state = {
88
sidebarLogo: true,
99
fixedHeader: true,
10+
tagsView: true,
1011
};
1112
sidebarLogoChange = (checked) => {
1213
this.setState({ sidebarLogo: checked });
@@ -16,12 +17,17 @@ class RightPanel extends Component {
1617
this.setState({ fixedHeader: checked });
1718
this.props.changeSetting({ key: "fixedHeader", value: checked });
1819
};
20+
tagsViewChange = (checked) => {
21+
this.setState({ tagsView: checked });
22+
this.props.changeSetting({ key: "tagsView", value: checked });
23+
};
1924
handleCopy = (e) => {
2025
let config = `
2126
export default {
2227
showSettings: true,
2328
sidebarLogo: ${this.state.sidebarLogo},
2429
fixedHeader: ${this.state.fixedHeader},
30+
tagsView: ${this.state.tagsView},
2531
}
2632
`;
2733
clip(config, e);
@@ -32,6 +38,7 @@ class RightPanel extends Component {
3238
toggleSettingPanel,
3339
sidebarLogo,
3440
fixedHeader,
41+
tagsView,
3542
} = this.props;
3643
return (
3744
<div className="rightSettings">
@@ -70,6 +77,20 @@ class RightPanel extends Component {
7077
</Col>
7178
</Row>
7279
<Divider dashed />
80+
<Row>
81+
<Col span={12}>
82+
<span>开启 Tags-View</span>
83+
</Col>
84+
<Col span={12}>
85+
<Switch
86+
checkedChildren="开"
87+
unCheckedChildren="关"
88+
defaultChecked={tagsView}
89+
onChange={this.tagsViewChange}
90+
/>
91+
</Col>
92+
</Row>
93+
<Divider dashed />
7394
<Row>
7495
<Col span={24}>
7596
<Alert

src/views/layout/index.jsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,23 @@
11
import React from "react";
2+
import { connect } from "react-redux";
23
import Content from "./Content";
34
import Header from "./Header";
45
import RightPanel from "./RightPanel";
56
import Sider from "./Sider";
67
import TagsView from "./TagsView";
78
import { Layout } from "antd";
8-
const Main = () => {
9+
const Main = (props) => {
10+
const { tagsView } = props;
911
return (
1012
<Layout style={{ minHeight: "100vh" }}>
1113
<Sider />
1214
<Layout>
1315
<Header />
14-
<TagsView/>
16+
{tagsView ? <TagsView /> : null}
1517
<Content />
1618
<RightPanel />
1719
</Layout>
1820
</Layout>
1921
);
2022
};
21-
export default Main;
23+
export default connect((state) => state.settings)(Main);

0 commit comments

Comments
 (0)