From c9c0ecd37f43d7a8cf023e95413131391c4f1059 Mon Sep 17 00:00:00 2001 From: Dreamacro <305009791@qq.com> Date: Sun, 23 Sep 2018 20:36:23 +0800 Subject: [PATCH] Chore: cleanup code --- src/components/Switch/index.tsx | 3 +- src/{views => containers}/App.scss | 0 src/{views => containers}/App.tsx | 11 +++-- src/{views => containers}/Logs/index.tsx | 0 src/{views => containers}/Overview/index.tsx | 0 src/containers/Proxies/index.tsx | 44 ++++++++++++-------- src/containers/ProxyGroup/index.tsx | 10 ----- src/containers/ProxyGroup/style.scss | 1 - src/{views => containers}/Rules/index.tsx | 0 src/{views => containers}/Settings/index.tsx | 0 src/render.tsx | 6 +-- src/views/Proxies/index.tsx | 14 ------- tsconfig.json | 2 - 13 files changed, 36 insertions(+), 55 deletions(-) rename src/{views => containers}/App.scss (100%) rename src/{views => containers}/App.tsx (84%) rename src/{views => containers}/Logs/index.tsx (100%) rename src/{views => containers}/Overview/index.tsx (100%) delete mode 100644 src/containers/ProxyGroup/index.tsx delete mode 100644 src/containers/ProxyGroup/style.scss rename src/{views => containers}/Rules/index.tsx (100%) rename src/{views => containers}/Settings/index.tsx (100%) delete mode 100644 src/views/Proxies/index.tsx diff --git a/src/components/Switch/index.tsx b/src/components/Switch/index.tsx index a0be627..dcec38f 100644 --- a/src/components/Switch/index.tsx +++ b/src/components/Switch/index.tsx @@ -17,8 +17,7 @@ export class Switch extends React.Component { onChange: () => {} } - handleClick = (e: React.MouseEvent) => { - e.stopPropagation() + handleClick = () => { if (!this.props.disabled) { this.props.onChange(!this.props.checked) } diff --git a/src/views/App.scss b/src/containers/App.scss similarity index 100% rename from src/views/App.scss rename to src/containers/App.scss diff --git a/src/views/App.tsx b/src/containers/App.tsx similarity index 84% rename from src/views/App.tsx rename to src/containers/App.tsx index 4a55f72..aa5e7f3 100644 --- a/src/views/App.tsx +++ b/src/containers/App.tsx @@ -3,12 +3,11 @@ import { Route } from 'react-router-dom' import { I18nProps } from '@i18n' import './App.scss' -import Overview from '@views/Overview' -import Proxies from '@views/Proxies' -import Logs from '@views/Logs' -import Rules from '@views/Rules' -import Settings from '@views/Settings' - +import Overview from '@containers/Overview' +import Proxies from '@containers/Proxies' +import Logs from '@containers/Logs' +import Rules from '@containers/Rules' +import Settings from '@containers/Settings' import SlideBar from '@containers/Sidebar' export interface AppProps extends I18nProps { diff --git a/src/views/Logs/index.tsx b/src/containers/Logs/index.tsx similarity index 100% rename from src/views/Logs/index.tsx rename to src/containers/Logs/index.tsx diff --git a/src/views/Overview/index.tsx b/src/containers/Overview/index.tsx similarity index 100% rename from src/views/Overview/index.tsx rename to src/containers/Overview/index.tsx diff --git a/src/containers/Proxies/index.tsx b/src/containers/Proxies/index.tsx index f11036a..5cec9b6 100644 --- a/src/containers/Proxies/index.tsx +++ b/src/containers/Proxies/index.tsx @@ -1,30 +1,40 @@ import * as React from 'react' import { Header, Icon, Proxy } from '@components' import { ProxyType } from '@models' + import './style.scss' -export default class Proxies extends React.Component<{}, {}> { +export class Proxies extends React.Component<{}, {}> { render () { const proxies: { type: ProxyType, name: string }[] = [ { type: ProxyType.Shadowsocks, name: 'shadowsocks' }, { type: ProxyType.Vmess, name: 'vmess' } ] - return
-
- -
-
    - { - proxies.map( - proxy => ( -
  • - -
  • - ) - ) - } -
-
+ return ( +
+
+
+ +
+
    + { + proxies.map( + proxy => ( +
  • + +
  • + ) + ) + } +
+
+
+
+
+
+ ) } } + +export default Proxies diff --git a/src/containers/ProxyGroup/index.tsx b/src/containers/ProxyGroup/index.tsx deleted file mode 100644 index 13aa01a..0000000 --- a/src/containers/ProxyGroup/index.tsx +++ /dev/null @@ -1,10 +0,0 @@ -import * as React from 'react' -import { Header } from '@components' - -export default class ProxyGroup extends React.Component<{}, {}> { - render () { - return
-
-
- } -} diff --git a/src/containers/ProxyGroup/style.scss b/src/containers/ProxyGroup/style.scss deleted file mode 100644 index c764641..0000000 --- a/src/containers/ProxyGroup/style.scss +++ /dev/null @@ -1 +0,0 @@ -@import '~@styles/variables'; diff --git a/src/views/Rules/index.tsx b/src/containers/Rules/index.tsx similarity index 100% rename from src/views/Rules/index.tsx rename to src/containers/Rules/index.tsx diff --git a/src/views/Settings/index.tsx b/src/containers/Settings/index.tsx similarity index 100% rename from src/views/Settings/index.tsx rename to src/containers/Settings/index.tsx diff --git a/src/render.tsx b/src/render.tsx index 22b8fe8..c7e6593 100644 --- a/src/render.tsx +++ b/src/render.tsx @@ -5,7 +5,7 @@ import { HashRouter } from 'react-router-dom' import { I18nextProvider } from 'react-i18next' import { AppContainer } from 'react-hot-loader' import { rootStores } from '@lib/createStore' -import App from '@views/App' +import App from '@containers/App' import i18n from '@i18n' const rootEl = document.getElementById('root') @@ -28,8 +28,8 @@ export default function renderApp () { ) if (module.hot) { - module.hot.accept('./views/App', () => { - const NewApp = require('./views/App').default + module.hot.accept('./containers/App', () => { + const NewApp = require('./containers/App').default render( diff --git a/src/views/Proxies/index.tsx b/src/views/Proxies/index.tsx deleted file mode 100644 index c943363..0000000 --- a/src/views/Proxies/index.tsx +++ /dev/null @@ -1,14 +0,0 @@ -import * as React from 'react' - -// containers -import ProxiesContainer from '@containers/Proxies' -import ProxyGroupContainer from '@containers/ProxyGroup' - -const Proxies: React.SFC = () => ( -
- - -
-) - -export default Proxies diff --git a/tsconfig.json b/tsconfig.json index f4924d2..5d24d92 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -19,8 +19,6 @@ "@components/*": ["src/components/*"], "@containers": ["src/containers"], "@containers/*": ["src/containers/*"], - "@views": ["src/views"], - "@views/*": ["src/views/*"], "@i18n": ["src/i18n"], "@i18n/*": ["src/i18n/*"], "@stores": ["src/stores"],