index.html 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <title>CloudSQL 管理员后台</title>
  5. <meta charset="UTF-8">
  6. <link rel="stylesheet" href="//cdn.bootcss.com/mdui/0.3.0/css/mdui.min.css">
  7. <link href="./css/index.css" rel="stylesheet" type="text/css">
  8. <script src="//cdn.bootcss.com/mdui/0.3.0/js/mdui.min.js"></script>
  9. <script type="text/javascript" src="./scr/index-dev.js"></script>
  10. </head>
  11. <body>
  12. <main id="router-view"></main>
  13. </body>
  14. <script>
  15. let routes = [{
  16. path: '/signin',
  17. fileName: 'src/components/signin.js'
  18. },
  19. {
  20. path: '/signup',
  21. fileName: 'src/components/signup.js'
  22. },
  23. {
  24. path: '/index',
  25. fileName: 'src/components/index.js'
  26. },
  27. ];
  28. const el = document.getElementById('router-view');
  29. let router = new SPARouter(el, routes, 'hash');
  30. router.beforeEach((to, next) => {
  31. Utils.ajaxGet('http://admin.cloudsql.1473.cn/v1/index/signStatus', function (response) {
  32. if (response.status === 'signedin') {
  33. next();
  34. } else {
  35. if (to.path === '/signin' || to.path === '/signup') {
  36. next();
  37. } else {
  38. window.location.hash = '/signin';
  39. }
  40. }
  41. });
  42. });
  43. </script>
  44. </html>