tools.js 713 B

12345678910111213141516171819202122232425262728293031323334353637
  1. import { Message } from 'element-ui'
  2. let tools = {}
  3. tools.error=function(msg){
  4. Message({
  5. message: msg,
  6. type: 'error',
  7. duration: 2000
  8. })
  9. }
  10. tools.success=function(msg){
  11. Message({
  12. message: msg,
  13. type: 'success',
  14. duration: 2000
  15. })
  16. }
  17. tools.getLang=function(){
  18. return localStorage.getItem('lang') || 'en'
  19. }
  20. export default tools
  21. export function hasMobile() {
  22. let isMobile = false;
  23. if ((navigator.userAgent.match(/(phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone)/i))) {
  24. isMobile = true;
  25. }
  26. if (document.body.clientWidth < 800) {
  27. isMobile = true;
  28. }
  29. return isMobile
  30. }