renderer.tsx 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. import { GlobalConfig } from '@/share/types'
  2. // import { Script, Link } from 'hono-vite-react-stack-node/components'
  3. import process from 'node:process'
  4. // 全局配置常量
  5. const GLOBAL_CONFIG: GlobalConfig = {
  6. OSS_BASE_URL: process.env.OSS_BASE_URL || 'https://oss.d8d.fun',
  7. APP_NAME: process.env.APP_NAME || '多八多Aider',
  8. }
  9. // export const renderer = reactRenderer(({ children }) => {
  10. // return (
  11. // <html>
  12. // <head>
  13. // <meta charSet="UTF-8" />
  14. // <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  15. // <script src="https://ai-oss.d8d.fun/umd/vconsole.3.15.1.min.js"></script>
  16. // <script dangerouslySetInnerHTML={{ __html: `
  17. // const init = () => {
  18. // const urlParams = new URLSearchParams(window.location.search);
  19. // if (${import.meta.env?.PROD ? "true":"false"} && !urlParams.has('vconsole')) return;
  20. // var vConsole = new VConsole({
  21. // theme: urlParams.get('vconsole_theme') || 'light',
  22. // onReady: function() {
  23. // console.log('vConsole is ready');
  24. // }
  25. // });
  26. // }
  27. // init();
  28. // `}} />
  29. // {/* 注入全局配置 */}
  30. // <script dangerouslySetInnerHTML={{ __html: `window.CONFIG = ${JSON.stringify(GLOBAL_CONFIG)};` }} />
  31. // </head>
  32. // <body>
  33. // {children}
  34. // <script type="module" src="/src/client/index.tsx"></script>
  35. // </body>
  36. // </html>
  37. // )
  38. // })
  39. export const Rooter = () => {
  40. return (
  41. <html>
  42. <head>
  43. <meta charSet="UTF-8" />
  44. <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  45. <link href='/src/style.css' rel="stylesheet" />
  46. <script src="https://ai-oss.d8d.fun/umd/vconsole.3.15.1.min.js"></script>
  47. <script dangerouslySetInnerHTML={{ __html: `
  48. const init = () => {
  49. const urlParams = new URLSearchParams(window.location.search);
  50. if (${import.meta.env?.PROD ? "true":"false"} && !urlParams.has('vconsole')) return;
  51. var vConsole = new VConsole({
  52. theme: urlParams.get('vconsole_theme') || 'light',
  53. onReady: function() {
  54. console.log('vConsole is ready');
  55. }
  56. });
  57. }
  58. init();
  59. `}} />
  60. {/* 注入全局配置 */}
  61. <script dangerouslySetInnerHTML={{ __html: `window.CONFIG = ${JSON.stringify(GLOBAL_CONFIG)};` }} />
  62. </head>
  63. <body>
  64. <div id='root' dangerouslySetInnerHTML={{ __html: '<!--app-html-->'}}></div>
  65. <script type="module" src="/src/client/index.tsx"></script>
  66. </body>
  67. </html>
  68. )
  69. }