Skip to content

Commit c3318ea

Browse files
committed
Merge branch 'feature/tidy' into develop
2 parents 940ed49 + da89ff3 commit c3318ea

37 files changed

Lines changed: 307 additions & 2683 deletions

README.md

Lines changed: 6 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -87,35 +87,20 @@ SwitchHosts! stores data at `~/.SwitchHosts` (Or folder `.SwitchHosts` under the
8787
npm run dev
8888
```
8989

90-
### Package and Zip
90+
### Package
9191

92-
- It is recommended to use [electron-packager](https://github.com/electron-userland/electron-packager) for packaging.
93-
94-
```bash
95-
# install electron-packager for use from cli
96-
npm install electron-packager -g
97-
```
98-
99-
- Go to the `./` folder, run `npm run pack` . The packaged file will be the `./dist` folder.
92+
- It is recommended to use [electron-builder](https://github.com/electron-userland/electron-builder) for packaging.
93+
- Go to the `./` folder, run `npm run make` . The packaged file will be the `./dist` folder.
10094
- This command may take several minutes to finish when you run it the first time, as it needs time to download dependent files. You can download the dependencies manually [here](https://github.com/electron/electron/releases), or [Taobao mirror](https://npm.taobao.org/mirrors/electron/), then save the files to `~/.electron`. You can check the [Electron Docs](http://electron.atom.io/docs/) for more infomation.
10195

10296
```bash
10397
# pack
104-
npm run pack # the packed files will be in ./dist
98+
npm run make # the packed files will be in ./dist
10599
106-
# or pack for a special platform
107-
npm run pack-mac # pack for macOS, the packed files will be in ./dist
108-
npm run pack-win # pack for Windows, the packed files will be in ./dist
100+
# or
101+
npm run build-and-make
109102
```
110103

111-
- After packaging, you can make a zip file by running the following command.
112-
113-
```bash
114-
# zip
115-
npm run zip # the zipped files will be in ./dist
116-
```
117-
118-
119104
## Copyright
120105

121106
SwitchHosts! is a free and open source software, it is released under the MIT license.

README_cn.md

Lines changed: 6 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -87,32 +87,18 @@ SwitchHosts! 的数据文件在 `~/.SwitchHosts` 目录下(Windows 用户为
8787
npm run dev
8888
```
8989

90-
### 打包发布
90+
### 打包
9191

92-
- 建议使用 [electron-packager](https://github.com/electron-userland/electron-packager) 进行打包
93-
94-
```bash
95-
# install electron-packager for use from cli
96-
npm install electron-packager -g
97-
```
98-
99-
- 在 `./` 目录下,运行 `npm run pack` 命令,打包后的文件位于 `./dist` 目录;
92+
- 建议使用 [electron-builder](https://github.com/electron-userland/electron-builder) 进行打包
93+
- 在 `./` 目录下,运行 `npm run make` 命令,打包后的文件位于 `./dist` 目录;
10094
- 首次执行此命令可能需要花费较多时间(需要下载对应的构建文件),也可先手动下载[对应的发布版本](https://github.com/electron/electron/releases)([淘宝镜像](https://npm.taobao.org/mirrors/electron/)),手动保存到 `~/.electron` 目录下。更多信息请参考 [Electron 文档](http://electron.atom.io/docs/)。
10195

10296
```bash
10397
# pack
104-
npm run pack # the packed files will be in ./dist
98+
npm run make # the packed files will be in ./dist
10599
106-
# 也可以只打包特定平台的版本,如
107-
npm run pack-mac # pack for macOS, the packed files will be in ./dist
108-
npm run pack-win # pack for Windows, the packed files will be in ./dist
109-
```
110-
111-
- 打包完成后,可运行以下命令将生成的程序压缩为 zip 文件。
112-
113-
```bash
114-
# zip
115-
npm run zip # the zipped files will be in ./dist
100+
# 或者
101+
npm run build-and-make
116102
```
117103

118104
## 更新历史

app-ui/App.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
import React from 'react'
99
import { notification } from 'antd'
10-
import Panel from './panel/Panel'
10+
import Panel from './Panel'
1111
import Content from './content/Content'
1212
import SudoPrompt from './frame/SudoPrompt'
1313
import EditPrompt from './frame/EditPrompt'
Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -93,31 +93,31 @@ export default class Buttons extends React.Component {
9393
<div id="sh-buttons" className={styles.root}>
9494
<div className={styles.left}>
9595
<a
96-
className={styles["btn-add"]}
96+
className={styles['btn-add']}
9797
href="#"
9898
onClick={() => Buttons.btnAdd()}
9999
>
100-
<Icon type="plus" className="iconfont" />
100+
<Icon type="plus"/>
101101
</a>
102102
</div>
103103

104104
<div className={styles.right}>
105105
<Icon
106106
type="search"
107107
className={classnames({
108-
iconfont: 1,
109108
on: this.state.search_on
110109
})}
111110
onClick={() => this.btnSearch()}
112111
/>
113-
<i
114-
className={classnames({
115-
iconfont: 1,
116-
'icon-switchon': this.state.top_toggle_on,
117-
'icon-switchoff': !this.state.top_toggle_on
118-
})}
119-
onClick={() => this.btnToggle()}
120-
/>
112+
{/*<i*/}
113+
{/* className={classnames({*/}
114+
{/* iconfont: 1,*/}
115+
{/* 'icon-switchon': this.state.top_toggle_on,*/}
116+
{/* 'icon-switchoff': !this.state.top_toggle_on*/}
117+
{/* })}*/}
118+
{/* onClick={() => this.btnToggle()}*/}
119+
{/*/>*/}
120+
<Icon type="setting" onClick={() => Agent.emit('show_preferences')}/>
121121
</div>
122122
</div>
123123
)
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,8 @@ export default class List extends React.Component {
8484
<ListItem
8585
data={this.props.sys_hosts}
8686
{...this.props}
87-
sys="1"/>
87+
sys="1"
88+
/>
8889
<div ref={c => this.el_items = c} className={styles['custom-items']}>
8990
{this.customItems()}
9091
</div>
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,8 @@
99
overflow: auto;
1010
}
1111

12+
:global(.platform-darwin) {
13+
.custom-items {
14+
top: 72px;
15+
}
16+
}
Lines changed: 14 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ import classnames from 'classnames'
1010
import { Icon } from 'antd'
1111
import Agent from '../Agent'
1212
import isInViewport from 'wheel-js/src/browser/isInViewport'
13+
import IconOn from './images/on.svg'
14+
import IconOff from './images/off.svg'
1315
import styles from './ListItem.less'
1416

1517
export default class ListItem extends React.Component {
@@ -93,39 +95,23 @@ export default class ListItem extends React.Component {
9395
>
9496
{sys ? null : (
9597
<div className={styles['item-buttons']}>
96-
<i
97-
className={classnames({
98-
iconfont: 1,
99-
'icon-edit': 1
100-
})}
101-
onClick={this.toEdit.bind(this)}
102-
/>
103-
<i className={classnames({
104-
iconfont: 1,
105-
switch: 1,
106-
'icon-on': data.on,
107-
'icon-off': !data.on
108-
})}
109-
onClick={this.toggle.bind(this)}
98+
{is_selected ? (
99+
<Icon
100+
type="form"
101+
onClick={this.toEdit.bind(this)}
102+
className={styles['icon-edit']}
103+
/>
104+
) : null}
105+
<Icon
106+
className={styles.switcher}
107+
component={data.on ? IconOn : IconOff}
108+
onClick={this.toggle.bind(this)}
110109
/>
111110
</div>
112111
)}
113-
{/*<i className={classnames({*/}
114-
{/*'iconfont': 1*/}
115-
{/*, 'item-icon': 1*/}
116-
{/*, 'icon-warn': !!data.error*/}
117-
{/*, 'icon-file': !sys && !data.error && data.where !== 'group'*/}
118-
{/*, 'icon-files': data.where === 'group'*/}
119-
{/*, 'icon-sysserver': sys && !data.error*/}
120-
{/*})}*/}
121-
{/*title={data.error || ''}*/}
122-
{/*/>*/}
123112
<Icon
124113
type={icon_type}
125-
className={classnames({
126-
iconfont: 1,
127-
'item-icon': 1
128-
})}
114+
className={styles['item-icon']}
129115
title={data.error || ''}
130116
/>
131117
<span>{this.getTitle()}</span>
Lines changed: 19 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,13 @@
22
position: relative;
33
padding: 7px 10px 7px 12px;
44
cursor: pointer;
5+
-webkit-app-region: no-drag;
56

67
&.sys-hosts {
78
font-size: 14px;
89
padding: 8px 10px 8px 10px;
910

10-
i.item-icon {
11+
.item-icon {
1112
width: 22px;
1213
font-size: 12px;
1314
}
@@ -20,47 +21,38 @@
2021
color: #fff;
2122
}
2223

23-
i.item-icon {
24+
.item-icon {
2425
color: #fff;
2526
}
2627

2728
&:hover {
28-
:global(i.icon-edit) {
29+
.icon-edit {
2930
display: inline-block;
3031
color: #fff;
3132
}
3233
}
3334
}
35+
}
3436

35-
:global {
36-
i {
37-
display: inline-block;
38-
width: 20px;
39-
text-align: center;
40-
margin-right: 5px;
41-
42-
&.item-icon {
43-
font-size: 10px;
44-
}
45-
46-
&.switch {
47-
cursor: pointer;
48-
line-height: 23px;
37+
.item-icon {
38+
margin-right: 0.5em;
39+
width: 1.5em;
40+
}
4941

50-
&.icon-on {
51-
color: #af9;
52-
}
53-
}
42+
.icon-edit {
43+
margin-right: 0.5em;
44+
font-size: 1.5em;
45+
transform: scale(0.7);
46+
cursor: pointer;
47+
}
5448

55-
&.icon-edit {
56-
display: none;
57-
}
58-
}
59-
}
49+
.switcher {
50+
cursor: pointer;
51+
font-size: 1.5em;
6052
}
6153

6254
.item-buttons {
6355
position: absolute;
6456
right: 10px;
65-
margin-top: -2px;
57+
margin-top: -1px;
6658
}

app-ui/Panel/images/off.svg

Lines changed: 6 additions & 0 deletions
Loading

0 commit comments

Comments
 (0)