luoluoluo22 commited on
Commit
987f2a6
·
1 Parent(s): 9536fa0

直接在服务器提供静态页面,绕过构建问题

Browse files
Files changed (1) hide show
  1. server.js +130 -8
server.js CHANGED
@@ -600,14 +600,136 @@ app.get("/", (req, res) => {
600
  console.log("接收到根路径请求");
601
  console.log("请求头:", req.headers);
602
 
603
- const indexPath = path.join(__dirname, "dist", "index.html");
604
- if (fs.existsSync(indexPath)) {
605
- console.log(`提供 index.html 文件: ${indexPath}`);
606
- res.sendFile(indexPath);
607
- } else {
608
- console.error(`错误: index.html 文件不存在: ${indexPath}`);
609
- res.status(404).send("找不到主页文件");
610
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
611
  });
612
 
613
  // 将 /debug 路由放到开头部分(在其他路由之前)
 
600
  console.log("接收到根路径请求");
601
  console.log("请求头:", req.headers);
602
 
603
+ // 直接提供简单的页面而不是依赖构建的应用
604
+ res.send(`
605
+ <!DOCTYPE html>
606
+ <html lang="zh-CN">
607
+ <head>
608
+ <meta charset="UTF-8">
609
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
610
+ <title>DeepSite - AI驱动的前端助手</title>
611
+ <style>
612
+ html, body {
613
+ height: 100%;
614
+ margin: 0;
615
+ padding: 0;
616
+ font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
617
+ }
618
+ body {
619
+ display: flex;
620
+ flex-direction: column;
621
+ align-items: center;
622
+ justify-content: center;
623
+ background: #f0f2f5;
624
+ color: #333;
625
+ text-align: center;
626
+ padding: 20px;
627
+ }
628
+ .container {
629
+ background: white;
630
+ border-radius: 10px;
631
+ box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
632
+ padding: 40px;
633
+ max-width: 700px;
634
+ width: 100%;
635
+ }
636
+ h1 {
637
+ margin-top: 0;
638
+ color: #0066cc;
639
+ font-size: 32px;
640
+ }
641
+ p {
642
+ line-height: 1.6;
643
+ font-size: 16px;
644
+ }
645
+ .features {
646
+ display: flex;
647
+ flex-wrap: wrap;
648
+ justify-content: center;
649
+ gap: 20px;
650
+ margin: 30px 0;
651
+ }
652
+ .feature {
653
+ background: #f8f9fa;
654
+ border-radius: 8px;
655
+ padding: 15px;
656
+ width: 180px;
657
+ }
658
+ .feature h3 {
659
+ margin-top: 0;
660
+ color: #0066cc;
661
+ }
662
+ .buttons {
663
+ display: flex;
664
+ gap: 15px;
665
+ justify-content: center;
666
+ margin-top: 30px;
667
+ }
668
+ .button {
669
+ display: inline-block;
670
+ background-color: #0066cc;
671
+ color: white;
672
+ padding: 12px 24px;
673
+ border-radius: 6px;
674
+ text-decoration: none;
675
+ font-weight: bold;
676
+ transition: background-color 0.3s;
677
+ }
678
+ .button:hover {
679
+ background-color: #0052a3;
680
+ }
681
+ .button.secondary {
682
+ background-color: #f0f2f5;
683
+ color: #333;
684
+ }
685
+ .button.secondary:hover {
686
+ background-color: #e0e2e5;
687
+ }
688
+ .footer {
689
+ margin-top: 40px;
690
+ font-size: 14px;
691
+ color: #666;
692
+ }
693
+ </style>
694
+ </head>
695
+ <body>
696
+ <div class="container">
697
+ <h1>DeepSite</h1>
698
+ <p>一个强大的 AI 驱动的前端开发助手,帮助你快速创建和优化网页。现在支持自定义模型和 OpenAI 兼容 API。</p>
699
+
700
+ <div class="features">
701
+ <div class="feature">
702
+ <h3>🎨 智能UI生成</h3>
703
+ <p>快速生成美观的用户界面</p>
704
+ </div>
705
+ <div class="feature">
706
+ <h3>🔧 代码优化</h3>
707
+ <p>智能优化和改进代码</p>
708
+ </div>
709
+ <div class="feature">
710
+ <h3>🚀 实时预览</h3>
711
+ <p>即时查看设计效果</p>
712
+ </div>
713
+ <div class="feature">
714
+ <h3>🔄 自定义模型</h3>
715
+ <p>支持接入自定义AI模型</p>
716
+ </div>
717
+ </div>
718
+
719
+ <div class="buttons">
720
+ <a href="/api/login" class="button">登录使用</a>
721
+ <a href="https://github.com/luoluoluo22/deepsite-space" class="button secondary">查看源码</a>
722
+ </div>
723
+
724
+ <div class="footer">
725
+ <p>当前服务器时间: ${new Date().toLocaleString('zh-CN')}</p>
726
+ <p>服务器状态: 正常运行中</p>
727
+ <p>系统版本: DeepSite 1.0.0</p>
728
+ </div>
729
+ </div>
730
+ </body>
731
+ </html>
732
+ `);
733
  });
734
 
735
  // 将 /debug 路由放到开头部分(在其他路由之前)