Skip to content

Commit

Permalink
Merge branch 'release/v1.0.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
Darmody committed Mar 29, 2016
2 parents 3cf68cd + d86de65 commit ad3e825
Show file tree
Hide file tree
Showing 10 changed files with 224 additions and 58 deletions.
82 changes: 28 additions & 54 deletions npm-shrinkwrap.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
@@ -1,7 +1,7 @@
{
"name": "DoubanFMac",
"productName": "DoubanFMac",
"version": "1.0.0",
"version": "1.0.1",
"description": "豆瓣FM for mac",
"main": "main.js",
"scripts": {
Expand Down Expand Up @@ -147,6 +147,7 @@
"redux-thunk": "^1.0.2",
"sass-flex-mixin": "^1.0.0",
"seamless-immutable": "^5.1.0",
"semver": "^5.1.0",
"url-loader": "^0.5.7"
},
"devEngines": {
Expand Down
52 changes: 50 additions & 2 deletions src/containers/HomePage/HomePage.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,20 @@ import { show } from 'redux-modal';
import { connect } from 'react-redux';
import { logout, verify } from 'reducers/auth';
import { fetch as fetchCaptcha } from 'reducers/captcha';
import { check } from 'reducers/updater';
import { shell } from 'electron';
import Navbar from './Navbar/Navbar';
import styles from './HomePage.scss';
import updaterIcon from './updater.gif';

@connect(
state => ({
currentUser: state.auth.user,
song: state.channel.song,
outdated: state.updater.outdated,
}),
dispatch => ({
...bindActionCreators({ show, fetchCaptcha, logout, verify }, dispatch)
...bindActionCreators({ show, fetchCaptcha, logout, verify, check }, dispatch)
})
)
export default class HomePage extends Component {
Expand All @@ -21,8 +26,10 @@ export default class HomePage extends Component {
location: PropTypes.object.isRequired,
currentUser: PropTypes.object,
song: PropTypes.object,
outdated: PropTypes.bool.isRequired,
show: PropTypes.func.isRequired,
logout: PropTypes.func.isRequired,
check: PropTypes.func.isRequired,
verify: PropTypes.func.isRequired,
fetchCaptcha: PropTypes.func.isRequired,
}
Expand All @@ -31,8 +38,19 @@ export default class HomePage extends Component {
router: React.PropTypes.object
}

constructor(props) {
super(props);

const updaterInterval = setInterval(() => {
props.check();
}, 1000 * 60 * 60 * 24 * 7);

this.state = { updaterInterval };
}

componentDidMount() {
this.props.verify();
this.props.check();
}

componentWillReceiveProps(nextProps) {
Expand All @@ -41,6 +59,14 @@ export default class HomePage extends Component {
}
}

componentWillUnmount() {
const { updaterInterval } = this.state;

if (updaterInterval) {
clearInterval(updaterInterval);
}
}

notice = (song) => {
if (document.hasFocus()) return;

Expand All @@ -60,8 +86,24 @@ export default class HomePage extends Component {
this.props.logout();
}

downloadLatestVersion = () => {
shell.openExternal(
'http://doubanfmac.oss-cn-hangzhou.aliyuncs.com/DoubanFMac.dmg'
);
}

renderUpdateBar = () => {
return (
<div className={styles.updaterBar} >
<button title="有新版本可以更新" onClick={this.downloadLatestVersion} >
<img src={updaterIcon} className="icon" />
</button>
</div>
);
}

render() {
const { children, currentUser, location } = this.props;
const { children, currentUser, location, outdated } = this.props;

return (
<div>
Expand All @@ -72,6 +114,12 @@ export default class HomePage extends Component {
logoutUser={this.logoutUser}
/>
{children}
<div className={styles.footer} >
{ outdated && this.renderUpdateBar() }
<div className={styles.contactBar} >
<a href="mailto:eterlf41@gmail.com" className={styles.link} >问题反馈</a>
</div>
</div>
</div>
);
}
Expand Down
38 changes: 38 additions & 0 deletions src/containers/HomePage/HomePage.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
@import '~sass-flex-mixin/flex';

.footer {
@extend %flexbox;
@include justify-content(flex-end);

position: absolute;
bottom: 0;
left: 0;
width: 100%;
padding: 0.5rem;
}

.updaterBar {
@extend %flexbox;
@include flex-grow(1);
@include align-items(center);

:global {
.icon {
width: 1.5rem;
margin-left: 1rem;
}
}
}

.contactBar {
width: 4rem;
}

.link {
font-size: 0.5rem;
color: #fff;
background: #ceecd2;
padding: 0.2rem;
margin-right: 1rem;
text-decoration: none;
}
2 changes: 1 addition & 1 deletion src/containers/HomePage/Navbar/Navbar.scss
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
@mixin navItem($fontSize: 0.8rem) {
color: grey;
font-size: $fontSize;
font-weight: thin;
font-weight: 300;
text-decoration: none;
}

Expand Down
Binary file added src/containers/HomePage/updater.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/containers/HomePage/updater.gif.old.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit ad3e825

Please sign in to comment.