<template>
  <div>
    <el-dialog
      title="感谢阅读"
      :visible.sync="dialogVisible"
      width="50%"
      :append-to-body	="true">
      <span>给一个 github star，给一份鼓励！</span>
      <span slot="footer" class="dialog-footer">
        <el-button @click="waitAMoment">一会儿再说</el-button>
        <el-button type="primary" @click="gotoStar">够义气，现在就去！</el-button>
      </span>
    </el-dialog>
  </div>
</template>

<script>
import Vue from 'vue'
import 'element-ui/lib/theme-chalk/index.css';
import { Dialog, Button } from 'element-ui';

Vue.component(Dialog.name, Dialog)
Vue.component(Button.name, Button)

export default {
  data() {
    return {
      dialogVisible: false
    };
  },
  mounted () {
    this.waitAMoment()
  },
  methods: {
    waitAMoment() {
      this.dialogVisible = false
      if (localStorage.getItem('stared') === 'true') {
        return
      }
      let _this = this
      setTimeout(_ => {
        _this.dialogVisible = true
      }, 60000 * 3)
    },
    gotoStar() {
      this.dialogVisible = false
      window.open('https://github.com/eip-work/kuboard-press')
      localStorage.setItem('stared', 'true')
    }
  }
}
</script>

<style>

</style>
