Skip to content

Conversation

@eviIIt
Copy link
Contributor

@eviIIt eviIIt commented Aug 8, 2019

cd

Why

用户需求

image

Docs

新增的 keep-alive.md

@auto-badge auto-badge bot added the enhancement New feature or request label Aug 8, 2019
@eviIIt eviIIt marked this pull request as ready for review August 8, 2019 11:38
mounted() {
if (this.autoplay) this.start()
window.addEventListener('unload', this.setSession)
if (sessionStorage.getItem(this.keepInSession)) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isAlive

mounted() {
if (this.autoplay) this.start()
window.addEventListener('unload', this.setSession)
let session = sessionStorage.getItem(this.keepInSession)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

先判断this.keepInSession为true再去getItem吧

session = JSON.parse(session)
const mountTime = session.rafId
? Number(new Date()) - session.unloadTime
: 0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

记rafId有啥用

const mountTime = session.rafId
? Number(new Date()) - session.unloadTime
: 0
this.elapsed = this.time - (session.countdown - mountTime)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

直接记startTime不就行了?不用又记unloadTime又记countdown吧

beforeDestroy() {
cancelAnimationFrame(this.rafId)
this.setSession()
window.removeEventListener('unload', this.setSession)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

直接在beforeDestroy里setSession就行了吧,为啥要listen unload呢?

@netlify
Copy link

netlify bot commented Aug 9, 2019

Deploy preview for femessage-count-down ready!

Built with commit 0810503

https://deploy-preview-4--femessage-count-down.netlify.com

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants