Skip to content

Commit

Permalink
modify project structure
Browse files Browse the repository at this point in the history
  • Loading branch information
onfuns committed Jun 18, 2019
1 parent ac0abcd commit a24003e
Show file tree
Hide file tree
Showing 13 changed files with 276 additions and 125 deletions.
2 changes: 1 addition & 1 deletion main/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ module.exports = {
rendererDevPath: '../dist',
devtools: {
open: false,
mode: 'bottom', // //detach right bottom
mode: 'bottom' // //detach right bottom
}
}
8 changes: 7 additions & 1 deletion main/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,13 @@ __DEV__ && require('electron-reload')(path.join(__dirname, rendererDevPath))
/** init window begin */
const initWindow = () => {
win = createWindow({ title: app.getName(), width: 800, height: 500 })
win.loadURL('file://' + path.resolve(__dirname, `${__DEV__ ? rendererDevPath : rendererPath}/index.html`))
win.loadURL(
'file://' +
path.resolve(
__dirname,
`${__DEV__ ? rendererDevPath : rendererPath}/index.html`
)
)
devtools.open && win.webContents.openDevTools({ mode: devtools.mode })
//set tray
tray = setTray(win)
Expand Down
4 changes: 1 addition & 3 deletions main/menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,7 @@ export const defaultMenu = [
{
label: '关于',
click() {
shell.openExternal(
'https://github.com/onfuns/LightHosts'
)
shell.openExternal('https://github.com/onfuns/LightHosts')
}
}
]
Expand Down
130 changes: 130 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"prettier": "@frontend-cli/prettier-config",
"husky": {
"hooks": {
"pre-commit": "npm run pretty"
"pre-commit": "pretty-quick --staged"
}
},
"keywords": [
Expand Down Expand Up @@ -69,6 +69,7 @@
"mobx": "^5.6.0",
"mobx-react": "^5.4.2",
"prettier": "^1.18.2",
"pretty-quick": "^1.11.1",
"react": "^16.6.3",
"react-dom": "^16.6.3",
"react-loadable": "^5.5.0",
Expand Down
2 changes: 1 addition & 1 deletion scripts/theme.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ module.exports = {
'font-size-base': '12px',
'primary-color': '#13C2C2',
'border-radius-base': '2px'
}
}
25 changes: 13 additions & 12 deletions src/components/AddMenuModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,27 +35,28 @@ const Add = observer(({ onClose, form, hostStore, detail = {} }) => {
const { getFieldDecorator } = form
return (
<Modal
title="host方案"
title='host方案'
visible={true}
width={450}
onCancel={onClose}
onOk={handleSubmit}
>
onOk={handleSubmit}>
<Form>
<FormItem
label="方案名称"
{...formItemLayout}
>
<FormItem label='方案名称' {...formItemLayout}>
{getFieldDecorator('name', {
initialValue: detail.name || '',
rules: [{ required: true, min: 2, max: 10, message: '名称由2 ~ 10个字符组成' }]
})(
<Input placeholder="名称由2 ~ 10个字符组成" />
)}
rules: [
{
required: true,
min: 2,
max: 10,
message: '名称由2 ~ 10个字符组成'
}
]
})(<Input placeholder='名称由2 ~ 10个字符组成' />)}
</FormItem>
</Form>
</Modal>
)
})

export default inject('hostStore')(Form.create()(Add))
export default inject('hostStore')(Form.create()(Add))
24 changes: 13 additions & 11 deletions src/components/Hosts.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import './hosts.less'

@inject('hostStore')
@observer

class Hosts extends Component {
constructor(props) {
super(props)
Expand All @@ -22,12 +21,12 @@ class Hosts extends Component {
this.codeMirrorEditor = CodeMirror.fromTextArea(this.editor, {
className: 'custom-editor',
lineNumbers: true,
mode: "shell",
mode: 'shell',
theme: 'idea'
})
this.codeMirrorEditor.on('change', (editor) => {
this.codeMirrorEditor.on('change', editor => {
const value = editor.getValue()
this.store.update({ data: value, type: "host" })
this.store.update({ data: value, type: 'host' })
})

this.codeMirrorEditor.on('gutterClick', (cm, n) => {
Expand All @@ -38,11 +37,14 @@ class Hosts extends Component {
let ln = info.text
if (/^\s*$/.test(ln)) return
let new_ln = /^#/.test(ln) ? ln.replace(/^#\s*/, '') : '# ' + ln
this.codeMirrorEditor.getDoc()
.replaceRange(new_ln, { line: info.line, ch: 0 }, {
this.codeMirrorEditor.getDoc().replaceRange(
new_ln,
{ line: info.line, ch: 0 },
{
line: info.line,
ch: ln.length
})
}
)
})
}

Expand All @@ -67,12 +69,12 @@ class Hosts extends Component {
render() {
const { readOnly = false } = this.getRecord()
return (
<div className="lay-host">
{readOnly && <Icon type="lock" className="host-readonly" />}
<textarea ref={(ref => this.editor = ref)}></textarea>
<div className='lay-host'>
{readOnly && <Icon type='lock' className='host-readonly' />}
<textarea ref={ref => (this.editor = ref)}></textarea>
</div>
)
}
}

export default Hosts
export default Hosts
Loading

0 comments on commit a24003e

Please sign in to comment.