index.html 2.2 KB

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