index.html 2.3 KB

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