redirect-mobile.js 939 B

12345678910111213141516171819202122232425262728293031
  1. export default ({ route, store, params }) => {
  2. if (typeof window !== 'undefined') {
  3. let host = window.location.host
  4. if (true || host === 'bbs.hoolihome.com') {
  5. if (
  6. /Android|iPhone|Windows Phone|BlackBerry|iPod|Kindle/i.test(
  7. window.navigator.userAgent
  8. )
  9. ) {
  10. if (route.fullPath.indexOf('/article/') !== -1) {
  11. if (host === 'bbs.hoolihome.com') {
  12. window.location.replace(
  13. `//m.hoolihome.com/${store.state.locale}/article/${
  14. params.articleId
  15. }`
  16. )
  17. } else {
  18. window.location.replace(
  19. `//testm.hoolihome.com/${store.state.locale}/article/${
  20. params.articleId
  21. }`
  22. )
  23. }
  24. } else {
  25. let redirectUrl = `//m.hoolihome.com${route.fullPath}`
  26. window.location.replace(redirectUrl)
  27. }
  28. }
  29. }
  30. }
  31. }