Bladeren bron

修改Readme
增加支持

dongasai 5 maanden geleden
bovenliggende
commit
9f80dd4c85

+ 32 - 10
README.md

@@ -5,18 +5,40 @@
 <br>
 
 <p align="center">
-    <a href="https://github.com/jqhph/dcat-admin/actions">
-        <img src="https://github.com/jqhph/dcat-admin/workflows/Laravel%20Dusk/badge.svg" alt="Build Status">
+    <a href="https://github.com/dongasai/dcat-admin2/actions">
+        <img src="https://github.com/dongasai/dcat-admin2/workflows/Laravel%20Dusk/badge.svg" alt="Build Status">
     </a>
-    <a href="https://styleci.io/repos/182349597">
-        <img src="https://github.styleci.io/repos/182349597/shield" alt="StyleCI">
-    </a>
-    <a href="https://packagist.org/packages/dcat/laravel-admin" ><img src="https://poser.pugx.org/dcat/laravel-admin/v/stable" /></a> 
-    <a href="https://packagist.org/packages/dcat/laravel-admin"><img src="https://img.shields.io/packagist/dt/dcat/laravel-admin.svg?color=" /></a> 
-    <a><img src="https://img.shields.io/badge/php-7.1+-59a9f8.svg?style=flat" /></a> 
-    <a><img src="https://img.shields.io/badge/laravel-5.5+-59a9f8.svg?style=flat" ></a>
+    <a href="https://packagist.org/packages/dongasai/laravel-admin2" ><img src="https://poser.pugx.org/dongasai/laravel-admin2/v/stable" /></a> 
+    <a href="https://packagist.org/packages/dongasai/laravel-admin2"><img src="https://img.shields.io/packagist/dt/dongasai/laravel-admin2.svg?color=" /></a> 
+    <a><img src="https://img.shields.io/badge/php-8.0+-59a9f8.svg?style=flat" /></a> 
+    <a><img src="https://img.shields.io/badge/laravel-10+-59a9f8.svg?style=flat" ></a>
 </p>
 
+
+由于原项目([jqhph/dcat-admin](https://github.com/jqhph/dcat-admin))已维护迟缓,故基于原作者的项目进行二次开发,修复了部分问题,并添加了更多功能。
+
+> 原项目对 `Laravel 9`的支持是没问题的,因此这个仓库从10开始
+
+新增功能如下:
+
+- [支持 Laravel 10](https://learnku.com/docs/laravel/10.x)
+- [支持 Laravel 11](https://learnku.com/docs/laravel/11.x)
+- [计划支持 Laravel 12](https://learnku.com/docs/laravel/12.x) 看对应分支是否有版本发布就好了
+- 新的分支策略,原项目分支的两个分支不删除,2.0作为主分支;新增对应Laravel版本的分支,维护一个支持各种版本的项目麻烦,但是对应每个版本做出微调保持Api一致不难
+
+> [!IMPORTANT]
+> 免责声明:
+> 尽管我已在**多个项目**中使用过该项目,但我无法保证所做的修改和调整绝对无误。因此,在将其应用于你的生产项目环境时,请务必保持谨慎,充分测试后再使用。
+> 
+> 安装方法:
+> `composer require dongasai/laravel-admin2`
+
+---
+
+> [!NOTE]
+> 以下内容是原 repo README.md 介绍并作出了微调
+
+
 <p align=""><code>Dcat Admin</code>是一个基于<a href="https://www.laravel-admin.org/" target="_blank">laravel-admin</a>二次开发而成的后台系统构建工具,只需很少的代码即可快速构建出一个功能完善的高颜值后台系统。内置丰富的后台常用组件,开箱即用,让开发者告别冗杂的HTML代码,对后端开发者非常友好。</p>
 
 
@@ -57,7 +79,7 @@
 - [x] `Section`功能(类似`Wordpress`的`Filter`和`blade`模板的`section`标签)
 - [x] 异步文件上传表单,支持分块多线程上传
 - [x] 多应用
-- [ ] 插件市场,只需在管理页面轻轻点击鼠标即可完成插件的安装、更新和卸载等操作
+
 
 
 ### 环境

+ 19 - 11
composer.json

@@ -1,8 +1,15 @@
 {
-    "name": "dcat/laravel-admin",
-    "description": "dcat admin",
+    "name": "dcat/laravel-admin2",
+    "description": "dcat admin v2 ",
     "type": "library",
-    "keywords": ["dcat", "laravel", "admin", "grid", "form", "laravel admin"],
+    "keywords": [
+        "dcat",
+        "laravel",
+        "admin",
+        "grid",
+        "form",
+        "laravel admin"
+    ],
     "homepage": "https://github.com/jqhph/dcat-admin",
     "license": "MIT",
     "authors": [
@@ -12,17 +19,18 @@
         }
     ],
     "require": {
-        "php": "~7.4|~8.0|~8.1",
-        "laravel/framework": "~8.0|~9.0|~10.0",
+        "php": ">=7.1.0",
+        "laravel/framework": "~5.5|~6.0|~7.0|~8.0|~9.0",
         "spatie/eloquent-sortable": "3.*|4.*",
-        "doctrine/dbal": "^2.6|^3.0"
+        "doctrine/dbal": "^2.6|^3.0|^4.0",
+        "dcat/easy-excel": "*"
     },
     "require-dev": {
-        "laravel/dusk": "~5.9|~6",
-        "phpstan/phpstan": "^0.12.0",
-        "phpunit/phpunit": "^7.5|~9",
-        "fzaninotto/faker": "^1.4",
-        "mockery/mockery": "^1.0"
+        "laravel/dusk": "~5.9|~6|~7.0|~8.0",
+        "phpstan/phpstan": "^0.12.0|~1.0",
+        "phpunit/phpunit": "^7.5|~9|~10|~11",
+        "fakerphp/faker": "^1.23",
+        "mockery/mockery": "^1.6"
     },
     "autoload": {
         "psr-4": {

+ 1 - 1
docs/issue_template.md

@@ -1,6 +1,6 @@
 - Laravel Version: #.#.#
 - PHP Version: #.#.#
-- Dcat Admin Version: #.#.#
+- Dcat Admin 2 Version: #.#.#
 
 ### Description:
 

+ 1 - 1
resources/lang/zh_CN/admin.php

@@ -15,7 +15,7 @@ return [
         'create_model'      => '创建模型',
         'create_repository' => '创建数据仓库',
         'create_controller' => '创建控制器',
-        'run_migrate'       => '创建迁移文件',
+        'run_migrate'       => '执行迁移文件',
         'create_lang'       => '创建翻译文件',
         'field'             => '字段',
         'translation'       => '翻译',

+ 1 - 1
resources/lang/zh_TW/admin.php

@@ -15,7 +15,7 @@ return [
         'create_model'      => '創建模型',
         'create_repository' => '創建數據倉庫',
         'create_controller' => '創建控制器',
-        'run_migrate'       => '創建遷移文件',
+        'run_migrate'       => '執行遷移文件',
         'create_lang'       => '創建翻譯文件',
         'field'             => '欄位',
         'translation'       => '翻譯',

+ 2 - 2
resources/views/partials/breadcrumb.blade.php

@@ -27,10 +27,10 @@
     <div class="breadcrumb-wrapper col-12">
     <ol class="breadcrumb float-right text-capitalize">
         <li class="breadcrumb-item"><a href="{{ admin_url('/') }}"><i class="fa fa-dashboard"></i> {{admin_trans('admin.home')}}</a></li>
-        @for($i = 2; $i <= ($len = count(Request::segments())); $i++)
+        @for($i = 2; $i <= ($len = count(request()->segments())); $i++)
             <li class="breadcrumb-item">
                 @if($i == $len) <a href=""> @endif
-                {{admin_trans_label(Request::segment($i))}}
+                {{admin_trans_label(request()->segment($i))}}
                 @if($i == $len) </a> @endif
             </li>
         @endfor

+ 3 - 3
resources/views/partials/toastr.blade.php

@@ -1,9 +1,9 @@
-@if(Session::has('dcat-admin-toastr'))
+@if(session()->has('dcat-admin-toastr'))
     @php
-        $toastr  = Session::get('dcat-admin-toastr');
+        $toastr  = session('dcat-admin-toastr');
         $type    = $toastr->get('type')[0] ?? 'success';
         $message = $toastr->get('message')[0] ?? '';
         $options = admin_javascript_json($toastr->get('options', []));
     @endphp
     <script>$(function () { toastr.{{$type}}('{!!  $message  !!}', null, {!! $options !!}); })</script>
-@endif
+@endif

+ 18 - 1
src/AdminServiceProvider.php

@@ -19,6 +19,7 @@ use Dcat\Admin\Support\Translator;
 use Dcat\Admin\Support\WebUploader;
 use Illuminate\Support\Arr;
 use Illuminate\Support\Facades\Blade;
+use Illuminate\Support\Facades\URL;
 use Illuminate\Support\ServiceProvider;
 
 class AdminServiceProvider extends ServiceProvider
@@ -106,6 +107,7 @@ class AdminServiceProvider extends ServiceProvider
     {
         $this->registerDefaultSections();
         $this->registerViews();
+        $this->registerTranslations();
         $this->ensureHttps();
         $this->bootApplication();
         $this->registerPublishing();
@@ -126,6 +128,21 @@ class AdminServiceProvider extends ServiceProvider
         $this->loadViewsFrom(__DIR__.'/../resources/views', 'admin');
     }
 
+     protected function registerTranslations()
+    {
+        // For Laravel 11 compatibility, we need to merge translations into the main lang directory
+        // instead of using a namespace, so that __('admin.key') works without admin:: prefix
+        $langPath = $this->app->langPath();
+        $adminLangPath = __DIR__.'/../resources/lang';
+
+        // Check if admin translations are already published
+        if (!file_exists($langPath.'/zh_CN/admin.php') && file_exists($adminLangPath)) {
+            // Load translations from vendor directory without namespace
+            $this->loadTranslationsFrom($adminLangPath);
+        }
+    }
+
+
     /**
      * 是否强制使用https.
      *
@@ -134,7 +151,7 @@ class AdminServiceProvider extends ServiceProvider
     protected function ensureHttps()
     {
         if (config('admin.https') || config('admin.secure')) {
-            \URL::forceScheme('https');
+            URL::forceScheme('https');
             $this->app['request']->server->set('HTTPS', true);
         }
     }

+ 5 - 1
src/Extend/VersionManager.php

@@ -204,7 +204,11 @@ class VersionManager
 
         $position = array_search($version, array_keys($versions));
 
-        return array_slice($versions, ++$position);
+        if ($position === false) {
+            return $versions;
+        }
+
+        return array_slice($versions, $position++);
     }
 
     public function getFileVersions($name)

+ 1 - 1
src/Http/Controllers/UserController.php

@@ -173,7 +173,7 @@ class UserController extends AdminController
                 $form->disableDeleteButton();
             }
         })->saving(function (Form $form) {
-            if ($form->password && $form->model()->get('password') != $form->password) {
+            if ($form->password && $form->model()->password != $form->password) {
                 $form->password = bcrypt($form->password);
             }