index.html 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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. // 判断是 TikTok 还是 Zalo 回调(TikTok 的 state 以 tiktok_ 开头)
  23. if (state && state.indexOf('tiktok_') === 0) {
  24. sessionStorage.setItem('tiktok_oauth_code', code);
  25. sessionStorage.setItem('tiktok_oauth_state', state);
  26. console.log('TikTok OAuth code saved:', code);
  27. } else {
  28. // 保存 Zalo 回调的 code 到 sessionStorage
  29. sessionStorage.setItem('zalo_oauth_code', code);
  30. if (state) {
  31. sessionStorage.setItem('zalo_oauth_state', state);
  32. }
  33. console.log('Zalo OAuth code saved:', code);
  34. }
  35. // 重定向到 hash 路由的登录页,去掉 URL 中的参数
  36. window.location.href = window.location.origin + '/#/login';
  37. }
  38. })();
  39. </script>
  40. <script type="module" src="/src/main.ts"></script>
  41. </body>
  42. </html>