index.html 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8" />
  5. <meta http-equiv="X-UA-Compatible" content="IE=edge" />
  6. <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
  7. <link rel="icon" href="/logo.svg" type="image/svg+xml" />
  8. <title>Vitiens</title>
  9. </head>
  10. <body>
  11. <div id="app"></div>
  12. <script>
  13. // 在 Vue 加载前处理 Zalo OAuth 回调参数
  14. // 因为使用 hash 路由,当 Zalo 回调到 /login?code=xxx 时
  15. // 页面会重定向到 /#/login,导致 query 参数丢失
  16. // 所以需要在页面加载时立即保存这些参数
  17. (function() {
  18. var urlParams = new URLSearchParams(window.location.search);
  19. var code = urlParams.get('code');
  20. var state = urlParams.get('state');
  21. if (code) {
  22. // 保存 Zalo 回调的 code 到 sessionStorage
  23. sessionStorage.setItem('zalo_oauth_code', code);
  24. if (state) {
  25. sessionStorage.setItem('zalo_oauth_state', state);
  26. }
  27. console.log('Zalo OAuth code saved:', code);
  28. // 重定向到 hash 路由的登录页,去掉 URL 中的参数
  29. window.location.href = window.location.origin + '/#/login';
  30. }
  31. })();
  32. </script>
  33. <script type="module" src="/src/main.ts"></script>
  34. </body>
  35. </html>