From b1e919f35134334374d77eeeff361755112ba0f4 Mon Sep 17 00:00:00 2001 From: Dreamacro <305009791@qq.com> Date: Tue, 18 Dec 2018 22:17:10 +0800 Subject: [PATCH] Chore: hidden uncompleted feature --- package-lock.json | 6 ++++ package.json | 1 + src/components/Tags/index.tsx | 32 +++++++++++-------- src/components/Tags/style.scss | 6 +++- src/containers/App.tsx | 9 +++--- .../Proxies/components/Group/index.tsx | 2 ++ src/i18n/en_US.ts | 4 ++- src/i18n/zh_CN.ts | 4 ++- 8 files changed, 44 insertions(+), 20 deletions(-) diff --git a/package-lock.json b/package-lock.json index 8d39025..61466a8 100644 --- a/package-lock.json +++ b/package-lock.json @@ -963,6 +963,12 @@ "integrity": "sha1-mgb08TfuhNffBGDB/bETX/psUP0=", "dev": true }, + "@types/classnames": { + "version": "2.2.6", + "resolved": "http://registry.npm.taobao.org/@types/classnames/download/@types/classnames-2.2.6.tgz", + "integrity": "sha1-2+imZhVtVW7QGOFaTGXwiTfD9ig=", + "dev": true + }, "@types/history": { "version": "4.7.0", "resolved": "https://registry.npmjs.org/@types/history/-/history-4.7.0.tgz", diff --git a/package.json b/package.json index d2630a8..cad36df 100644 --- a/package.json +++ b/package.json @@ -32,6 +32,7 @@ "@babel/core": "^7.2.0", "@babel/preset-env": "^7.2.0", "@babel/preset-react": "^7.0.0", + "@types/classnames": "^2.2.6", "@types/node": "^10.12.12", "@types/react": "^16.7.6", "@types/react-dom": "^16.0.11", diff --git a/src/components/Tags/index.tsx b/src/components/Tags/index.tsx index 2c228f5..e1fdb07 100644 --- a/src/components/Tags/index.tsx +++ b/src/components/Tags/index.tsx @@ -1,30 +1,33 @@ import * as React from 'react' -import { BaseComponentProps } from '@models/BaseProps' +import { translate } from 'react-i18next' +import { BaseComponentProps, I18nProps } from '@models' +import { noop } from '@lib/helper' import classnames from 'classnames' import './style.scss' -interface TagsProps extends BaseComponentProps { +interface TagsProps extends BaseComponentProps, I18nProps { data: Set onClick: (name: string) => void select: string rowHeight: number + canClick: boolean } interface TagsState { - extend: boolean + expand: boolean showExtend: boolean ulRef: React.RefObject } -export class Tags extends React.Component { +class TagsClass extends React.Component { state: TagsState = { - extend: false, + expand: false, showExtend: true, ulRef: React.createRef() } toggleExtend = () => { - this.setState({ extend: !this.state.extend }) + this.setState({ expand: !this.state.expand }) } componentDidMount () { @@ -32,16 +35,17 @@ export class Tags extends React.Component { } render () { - const { className, data, onClick, select } = this.props - const { extend } = this.state - const rowHeight = this.state.extend ? 'auto' : this.props.rowHeight + const { t, className, data, onClick, select, canClick } = this.props + const { expand } = this.state + const rowHeight = this.state.expand ? 'auto' : this.props.rowHeight + const handleClick = canClick ? onClick : noop const tags = [...data] .sort() .map(t => { - const tagClass = classnames({ 'tags-selected': select === t }) + const tagClass = classnames({ 'tags-selected': select === t, 'can-click': canClick }) return ( -
  • onClick(t)}> +
  • handleClick(t)}> { t }
  • ) @@ -49,14 +53,16 @@ export class Tags extends React.Component { return (
    -
      +
        { tags }
      { this.state.showExtend && - { this.state.extend ? '收起' : '展开' } + { this.state.expand ? t('collapseText') : t('expandText') } }
    ) } } + +export const Tags = translate(['Proxies'])(TagsClass) diff --git a/src/components/Tags/style.scss b/src/components/Tags/style.scss index b9e48d7..fb81856 100644 --- a/src/components/Tags/style.scss +++ b/src/components/Tags/style.scss @@ -30,6 +30,10 @@ $delete-height: 22px; padding: 0 6px; margin: 3px 4px; font-size: 10px; + cursor: default; + } + + li.can-click { cursor: pointer; } @@ -39,7 +43,7 @@ $delete-height: 22px; } } -.tags-entend { +.tags-expand { height: 30px; line-height: 30px; padding: 0 10px; diff --git a/src/containers/App.tsx b/src/containers/App.tsx index c08e074..dd54a9c 100644 --- a/src/containers/App.tsx +++ b/src/containers/App.tsx @@ -1,12 +1,12 @@ import * as React from 'react' -import { Route } from 'react-router-dom' +import { Route, Redirect } from 'react-router-dom' import { hot } from 'react-hot-loader' import classnames from 'classnames' import { I18nProps } from '@models' import { isClashX } from '@lib/jsBridge' import './App.scss' -import Overview from '@containers/Overview' +// import Overview from '@containers/Overview' import Proxies from '@containers/Proxies' import Logs from '@containers/Logs' import Rules from '@containers/Rules' @@ -24,7 +24,7 @@ export default class App extends React.Component { } render () { const routes = [ - { path: '/', name: 'Overview', component: Overview, exact: true }, + // { path: '/', name: 'Overview', component: Overview, exact: true }, { path: '/proxies', name: 'Proxies', component: Proxies }, { path: '/logs', name: 'Logs', component: Logs }, { path: '/rules', name: 'Rules', component: Rules }, @@ -35,9 +35,10 @@ export default class App extends React.Component {
    + }/> { routes.map( - route => + route => ) }
    diff --git a/src/containers/Proxies/components/Group/index.tsx b/src/containers/Proxies/components/Group/index.tsx index 9eb00ff..e549054 100644 --- a/src/containers/Proxies/components/Group/index.tsx +++ b/src/containers/Proxies/components/Group/index.tsx @@ -22,6 +22,7 @@ export class Group extends React.Component { render () { const { config } = this.props const proxies = new Set(config.all) + const canClick = config.type === 'Selector' return (
    @@ -34,6 +35,7 @@ export class Group extends React.Component { data={proxies} onClick={this.handleChangeProxySelected} select={config.now} + canClick={canClick} rowHeight={30} />
    diff --git a/src/i18n/en_US.ts b/src/i18n/en_US.ts index e9b8c94..24f0536 100644 --- a/src/i18n/en_US.ts +++ b/src/i18n/en_US.ts @@ -58,6 +58,8 @@ export default { alterId: 'AlterId', tls: 'TLS' }, - groupTitle: 'Policy Group' + groupTitle: 'Policy Group', + expandText: 'Expand', + collapseText: 'Collapse' } } diff --git a/src/i18n/zh_CN.ts b/src/i18n/zh_CN.ts index 12a895c..caa3388 100644 --- a/src/i18n/zh_CN.ts +++ b/src/i18n/zh_CN.ts @@ -58,6 +58,8 @@ export default { alterId: 'AlterId', tls: 'TLS' }, - groupTitle: '策略组' + groupTitle: '策略组', + expandText: '展开', + collapseText: '收起' } }