Browse Source

fix:修复完毕,开始生成页面

景好勇 4 months ago
parent
commit
5faf5873f2

+ 11 - 0
README.md

@@ -18,3 +18,14 @@
         ```php artisan admin:install```
     - 8.开启serve服务
         ```php artisan serve```
+## 宝塔需要的配置
+    - 1.安装redis 7.2.4
+    - 2.安装nginx 1.24.0
+    - 3.安装php 8.2.24
+    - 4.mysql 8.0.36
+    - 5.composer 1.0
+
+## 文档
+后台:http://127.0.0.1/admin#/login
+宝塔:http://localhost:2122/btwest
+

+ 17 - 0
app/Http/Middleware/VerifyCsrfToken.php

@@ -0,0 +1,17 @@
+<?php
+
+namespace App\Http\Middleware;
+
+use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken as Middleware;
+
+class VerifyCsrfToken extends Middleware
+{
+    /**
+     * The URIs that should be excluded from CSRF verification.
+     *
+     * @var array<int, string>
+     */
+    protected $except = [
+        'api/*'
+    ];
+} 

+ 1 - 1
composer.json

@@ -7,7 +7,7 @@
     "require": {
         "php": "^8.2",
         "iwzh/owl-scheduling": "^1.0",
-        "knuckleswtf/scribe": "^4.38",
+        "knuckleswtf/scribe": "^4.0",
         "laravel/framework": "v11.30.0",
         "laravel/sanctum": "^4.0",
         "laravel/tinker": "^2.9",

+ 54 - 0
config/cors.php

@@ -0,0 +1,54 @@
+<?php
+
+return [
+    // 指定哪些路由需要 CORS
+    'paths' => [
+        '*',                    // 所有路由
+        'api/*',                 // API 路由
+        'sanctum/csrf-cookie',   // Sanctum 认证
+        'login',                 // 登录路由
+        'register',              // 注册路由
+    ],
+
+    // 允许的请求方法
+    'allowed_methods' => ['*', 'GET', 'POST', 'PUT', 'PATCH', 'DELETE', 'OPTIONS'],
+
+    // 允许的来源域名
+    'allowed_origins' => [
+        '*',
+        'http://127.0.0.1',
+        'http://localhost',
+        env('APP_ENV') === 'local'
+            ? ['http://localhost:3000', 'http://localhost:8080', 'http://127.0.0.1:8000', '*']
+            : [env('FRONTEND_URL'), '*'],
+    ],
+
+    // 允许的域名模式(支持通配符)
+    'allowed_origins_patterns' => [
+        // 'https://*.your-domain.com',
+    ],
+
+    // 允许的请求头
+    'allowed_headers' => [
+        '*',
+        'Accept',
+        'Authorization',
+        'Content-Type',
+        'X-Requested-With',
+        'X-CSRF-TOKEN',
+        'X-Custom-Header',
+        env('APP_ENV') === 'local' ? 'X-Debug-Token' : null,
+    ],
+
+    // 暴露给客户端的响应头
+    'exposed_headers' => [
+        '*',
+        'X-Custom-Response-Header',
+    ],
+
+    // 预检请求缓存时间(秒)
+    'max_age' => 86400,
+
+    // 是否允许携带认证信息(cookies等)
+    'supports_credentials' => env('CORS_SUPPORTS_CREDENTIALS', true),
+];

+ 39 - 0
index.html

@@ -0,0 +1,39 @@
+<!doctype html>
+<html>
+<head>
+    <meta charset="utf-8">
+    <title>恭喜,站点创建成功!</title>
+    <style>
+        .container {
+            width: 60%;
+            margin: 10% auto 0;
+            background-color: #f0f0f0;
+            padding: 2% 5%;
+            border-radius: 10px
+        }
+
+        ul {
+            padding-left: 20px;
+        }
+
+            ul li {
+                line-height: 2.3
+            }
+
+        a {
+            color: #20a53a
+        }
+    </style>
+</head>
+<body>
+    <div class="container">
+        <h1>恭喜, 站点创建成功!</h1>
+        <h3>这是默认index.html,本页面由系统自动生成</h3>
+        <ul>
+            <li>本页面在FTP根目录下的index.html</li>
+            <li>您可以修改、删除或覆盖本页面</li>
+            <li>FTP相关信息,请到“面板系统后台 > FTP” 查看</li>
+        </ul>
+    </div>
+</body>
+</html>

+ 8 - 31
resources/views/vendor/scribe/themes/elements/index.blade.php

@@ -116,40 +116,17 @@
                     delete headers['Content-Type'];
                 }
 
-                return preflightPromise.then(() => makeAPICall(method, path, body, query, headers, endpointId))
-                    .then(([responseStatus, statusText, responseContent, responseHeaders]) => {
-                        responsePanel.hidden = false;
-                        responsePanel.querySelector(`.response-status`).textContent = responseStatus + " " + statusText ;
-
-                        let contentEl = responsePanel.querySelector(`.response-content`);
-                        if (responseContent === '') {
-                            contentEl.textContent = contentEl.dataset.emptyResponseText;
-                            return;
-                        }
-
-                        // Prettify it if it's JSON
-                        let isJson = false;
-                        try {
-                            const jsonParsed = JSON.parse(responseContent);
-                            if (jsonParsed !== null) {
-                                isJson = true;
-                                responseContent = JSON.stringify(jsonParsed, null, 4);
-                            }
-                        } catch (e) {}
-
-                        // Replace HTML entities
-                        responseContent = responseContent.replace(/[<>&]/g, (i) => '&#' + i.charCodeAt(0) + ';');
-
-                        contentEl.innerHTML = responseContent;
-                        isJson && window.hljs.highlightElement(contentEl);
-                    })
+                return preflightPromise
+                    .then(() => makeAPICall(method, path, body, query, headers, endpointId))
                     .catch(err => {
-                        console.log(err);
-                        let errorMessage = err.message || err;
+                        console.error('API调用失败:', err);
                         errorPanel.hidden = false;
-                        errorPanel.querySelector(`.error-message`).textContent = errorMessage;
+                        errorPanel.querySelector('.error-message').textContent = 
+                            `请求失败: ${err.message}\n请确保服务器正在运行且配置正确`;
                     })
-                    .finally(() => { btnElement.disabled = false } );
+                    .finally(() => {
+                        btnElement.disabled = false;
+                    });
             }
 
             window.addEventListener('DOMContentLoaded', () => {