index.html 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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. <link rel="apple-touch-icon" href="/apple-touch-icon.png" />
  9. <link rel="manifest" href="/manifest.json" />
  10. <meta name="theme-color" content="#E3AC00" />
  11. <meta name="apple-mobile-web-app-capable" content="yes" />
  12. <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
  13. <meta name="apple-mobile-web-app-title" content="Vitiens" />
  14. <title>Vitiens</title>
  15. </head>
  16. <body>
  17. <div id="app"></div>
  18. <script>
  19. // 在 Vue 加载前处理 Zalo OAuth 回调参数
  20. // 因为使用 hash 路由,当 Zalo 回调到 /login?code=xxx 时
  21. // 页面会重定向到 /#/login,导致 query 参数丢失
  22. // 所以需要在页面加载时立即保存这些参数
  23. (function() {
  24. var urlParams = new URLSearchParams(window.location.search);
  25. var code = urlParams.get('code');
  26. var state = urlParams.get('state');
  27. if (code) {
  28. // 判断是 TikTok 还是 Zalo 回调(TikTok 的 state 以 tiktok_ 开头)
  29. if (state && state.indexOf('tiktok_') === 0) {
  30. sessionStorage.setItem('tiktok_oauth_code', code);
  31. sessionStorage.setItem('tiktok_oauth_state', state);
  32. console.log('TikTok OAuth code saved:', code);
  33. } else {
  34. // 保存 Zalo 回调的 code 到 sessionStorage
  35. sessionStorage.setItem('zalo_oauth_code', code);
  36. if (state) {
  37. sessionStorage.setItem('zalo_oauth_state', state);
  38. }
  39. console.log('Zalo OAuth code saved:', code);
  40. }
  41. // 重定向到 hash 路由的登录页,去掉 URL 中的参数
  42. window.location.href = window.location.origin + '/#/login';
  43. }
  44. })();
  45. </script>
  46. <script type="module" src="/src/main.ts"></script>
  47. </body>
  48. </html>