-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
276b965
commit 386fa33
Showing
13 changed files
with
170 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import ElectronStore from 'electron-store'; | ||
import _ from 'lodash'; | ||
import { Log } from '../utils'; | ||
|
||
const Store = new ElectronStore(); | ||
const DefaultConfig = { | ||
windowsSize: [375, 650], | ||
playerSize: [375, 210], | ||
opacity: 1, | ||
}; | ||
|
||
const Configs = { | ||
default: DefaultConfig, | ||
store: _.assign(DefaultConfig, Store.store), | ||
restore: () => (Store.store = DefaultConfig), | ||
get: key => { | ||
const config = Store.has(key) ? Store.get(key) : DefaultConfig[key]; | ||
Log(`[app][setting] get ${key}: ${config}`); | ||
return config; | ||
}, | ||
set: (key, value) => { | ||
if (typeof key === 'object') { | ||
Store.set(key); | ||
Log(`[app][setting] set ${key}`); | ||
} else { | ||
if (typeof value === 'object') { | ||
const oldConfig = Store.has(key) ? Store.get(key) : {}; | ||
Store.set(key, _.assign(oldConfig, value)); | ||
} else { | ||
Store.set(key, value); | ||
} | ||
Log(`[app][setting] set ${key}: ${value}`); | ||
} | ||
}, | ||
delete: key => { | ||
Store.delete(key); | ||
Log(`[app][setting] delete ${key}`); | ||
}, | ||
}; | ||
|
||
export default Configs; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,40 @@ | ||
import { Log } from '../utils'; | ||
import Configs from '../configs'; | ||
import { ipcMain as ipc, shell } from 'electron'; | ||
|
||
let size = [375, 210]; | ||
let windowsSize = Configs.get('windowsSize'); | ||
let playerSize = Configs.get('playerSize'); | ||
|
||
export default win => { | ||
// 设置 | ||
ipc.on('config-set', (event, data) => { | ||
Configs.set(data); | ||
}); | ||
|
||
// console 转发 | ||
ipc.on('console-msg', (event, data) => { | ||
Log(`[webview]${data}`); | ||
}); | ||
// 浏览器打开外链 | ||
ipc.on('link', (event, data) => { | ||
shell.openExternal(data); | ||
}); | ||
// 关闭按钮处理 | ||
ipc.on('close-main-window', () => { | ||
win.minimize(); | ||
}); | ||
// 界面尺寸 | ||
ipc.on('video-on', () => { | ||
win.setSize(size[0], size[1], true); | ||
win.setSize(playerSize[0], playerSize[1], true); | ||
win.setResizable(true); | ||
}); | ||
ipc.on('video-off', () => { | ||
win.setSize(375, 650, true); | ||
win.setSize(windowsSize[0], windowsSize[1], true); | ||
win.setResizable(false); | ||
}); | ||
ipc.on('resize', () => { | ||
size = win.getSize(); | ||
Log('[app][resize]', size); | ||
playerSize = win.getSize(); | ||
Log('[app][resize]', playerSize); | ||
}); | ||
Log('[app][ipc] load'); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,59 @@ | ||
import { Component } from 'react'; | ||
import _ from 'lodash'; | ||
import { Configs } from '../../../utils'; | ||
import { Input, Button, message } from 'antd'; | ||
import style from './index.scss'; | ||
|
||
export default () => { | ||
return ( | ||
<div className={style.box}> | ||
Comming Soon{' '} | ||
<span role="img" aria-label="love"> | ||
😘 | ||
</span>{' '} | ||
... | ||
</div> | ||
); | ||
}; | ||
const InputGroup = Input.Group; | ||
|
||
class Basic extends Component { | ||
state = { | ||
configs: Configs.store, | ||
}; | ||
|
||
onClickSave = () => { | ||
message.success('保存成功!'); | ||
}; | ||
onClickRestore = () => { | ||
message.success('重置成功!'); | ||
}; | ||
|
||
render() { | ||
const { configs } = this.state; | ||
const SettingInput = (key, title) => { | ||
const defaultValue = configs[key]; | ||
let InputBox; | ||
if (_.isArray(defaultValue)) { | ||
InputBox = [ | ||
<Input key={1} style={{ width: '50%' }} defaultValue={configs[key][0]} />, | ||
<Input key={2} style={{ width: '50%' }} defaultValue={configs[key][1]} />, | ||
]; | ||
} else { | ||
InputBox = <Input defaultValue={configs[key]} />; | ||
} | ||
return ( | ||
<div className={style.cell}> | ||
<div className={style.title}>{title}:</div> | ||
<InputGroup compact={true}>{InputBox}</InputGroup> | ||
</div> | ||
); | ||
}; | ||
return ( | ||
<div className={style.box}> | ||
{SettingInput('playerSize', '播放器尺寸')} | ||
{SettingInput('windowsSize', '主窗口尺寸')} | ||
{SettingInput('opacity', '透明度')} | ||
<div className={style.btnGroup}> | ||
<Button className={style.btn} type="primary" size="large" onClick={this.onClickSave}> | ||
保存设置 | ||
</Button> | ||
<Button className={style.btn} onClick={this.onClickRestore} size="large"> | ||
还原默认 | ||
</Button> | ||
</div> | ||
</div> | ||
); | ||
} | ||
} | ||
|
||
export default Basic; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,36 @@ | ||
@import 'import'; | ||
|
||
.box { | ||
height: 30rem; | ||
font-size: 1.5rem; | ||
display: flex; | ||
flex-direction: column; | ||
padding: 1rem; | ||
} | ||
|
||
.cell { | ||
display: flex; | ||
margin-bottom: 1rem; | ||
} | ||
|
||
.title { | ||
height: 2rem; | ||
width: 8rem; | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
color: #999; | ||
margin-right: 0.5rem; | ||
} | ||
|
||
.btnGroup { | ||
margin-top: 1rem; | ||
display: flex; | ||
flex-direction: column; | ||
} | ||
|
||
.btn { | ||
border-radius: 3rem; | ||
margin-bottom: 0.8rem; | ||
&:first-child { | ||
border: none; | ||
background: linear-gradient(45deg, $c-primary, lighten($c-primary, 10%)); | ||
box-shadow: 0 4px 8px rgba($c-primary, 0.15); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters