util.js 652 B

123456789101112131415161718192021
  1. export function timeFix() {
  2. const time = new Date()
  3. const hour = time.getHours()
  4. return hour < 9 ? '早上好' : (hour <= 11 ? '上午好' : (hour <= 13 ? '中午好' : (hour < 20 ? '下午好' : '晚上好')))
  5. }
  6. export function welcome() {
  7. const arr = ['休息一会儿吧', '准备吃什么呢?', '要不要打一把 DOTA', '我猜你可能累了']
  8. let index = Math.floor((Math.random()*arr.length))
  9. return arr[index]
  10. }
  11. /**
  12. * 触发 window.resize
  13. */
  14. export function triggerResize() {
  15. let event = document.createEvent('HTMLEvents')
  16. event.initEvent('resize', true, true)
  17. event.eventType = 'message'
  18. window.dispatchEvent(event)
  19. }