ctf0/simple-menu

此包已被废弃,不再维护。未建议替代包。

创建支持页面(多语言'title/ url/ prefix',嵌套,模板,静态/动态,角色 & 权限)的菜单。

资助包维护!
ctf0

安装: 99

依赖者: 0

建议者: 0

安全: 0

星级: 19

关注者: 3

分支: 2

开放问题: 0

语言:Blade


README

创建支持(多语言"title, url, body, ...",嵌套,模板,静态 & 动态数据,角色 & 权限)的菜单和页面。

  • 此包需要Laravel v5.5+
  • 包高度依赖缓存,请确保安装一个启用了标签的驱动程序 Memcached / Redis

安装

  • composer require ctf0/simple-menu

  • 安装后,运行 php artisan sm:setup 以添加

    • 包路由到 routes/web.php
    • 包资源编译到 webpack.mix.js
  • 使用 php artisan vendor:publish 发布包资源

  • 安装JS依赖

    yarn add vue axios vue-tippy@v2 vuedraggable vue-notif vue-multi-ref vue-awesome@v2 list.js
  • 将以下一行代码添加到您的主js文件中,并运行 npm run watch 以编译您的 js/css 文件。

    • 如果您遇到问题 检查
    // app.js
    
    window.Vue = require('vue')
    
    require('../vendor/SimpleMenu/js/manager')
    
    new Vue({
        el: '#app'
    })

配置

config/simpleMenu.php

return [
    /*
     * the menu list classes to be used for "render()"
     */
    'listClasses' => [
        'ul' => 'menu-list',
        'li' => 'list-item',
        'a' => 'is-active',
    ],

    /*
     * the path where we will save the routes list
     */
    'routeListPath' => storage_path('logs/simpleMenu.php'),

    /*
     * where to redirect when a route is available in one locale "en" but not in another "fr" ?
     */
    'unFoundLocalizedRoute' => 'root',

    /*
     * package models
     */
    'models'=> [
        'user' => App\User::class,
        'page' => \ctf0\SimpleMenu\Models\Page::class,
        'menu' => \ctf0\SimpleMenu\Models\Menu::class,
    ],

    /*
     * when adding a page which is a nest of a nother to a menu, ex.
     *
     * root
     *   | child 1
     *     | child 2 "add this along with its childrens to another menu"
     *       | child 3
     *
     * do you want to clear its parent and make it a root ?
     */
    'clearPartialyNestedParent' => true,

    /*
     * when removing a root page from a menu, ex.
     *
     * root "remove"
     *   | child 1
     *     | child 2
     *       | child 3
     *
     * do you want clear all of its 'Descendants' ?
     */
    'clearRootDescendants' => false,

    /*
     * when removing a nest from a list, ex.
     *
     * root
     *   | child 1
     *     | child 2 "remove"
     *       | child 3
     *
     * do you want to reset its hierarchy ?
     */
    'clearNestDescendants'=> false,

    /*
     * when deleting a page "from the db", ex.
     *
     * page "delete/destroy"
     *   | nested child 1
     *     | nested child 2
     *       | nested child 3
     *
     * do you also want to delete all of its children ?
     */
    'deletePageAndNests' => false,

    /*
     * package routes url & route name prefix
     */
    'crud_prefix' => 'admin',

    /*
     * all the package controllers
     *
     * if you need to change anything, just create new controller
     * and extend from the below original
     * ex. "class ExampleController extends PagesController"
     */
    'controllers'=> [
        'permissions' => '\ctf0\SimpleMenu\Controllers\Admin\PermissionsController',
        'admin' => '\ctf0\SimpleMenu\Controllers\Admin\AdminController@index',
        'users' => '\ctf0\SimpleMenu\Controllers\Admin\UsersController',
        'pages' => '\ctf0\SimpleMenu\Controllers\Admin\PagesController',
        'roles' => '\ctf0\SimpleMenu\Controllers\Admin\RolesController',
        'menus' => '\ctf0\SimpleMenu\Controllers\Admin\MenusController',
    ],
];

使用

演示
使用
视图

  • SMUsers 特性添加到您的 用户模型

    use ctf0\SimpleMenu\Models\Traits\SMUsers;
    
    // ...
    
    class User extends Authenticatable
    {
        use Notifiable, SMUsers;
    }
  • 访问 localhost:8000/admin