├── .gitignore ├── wxmenu.jpg ├── routes └── web.php ├── src ├── WXMenu.php ├── WXMenuFormField.php ├── WXMenuServiceProvider.php └── Http │ └── Controllers │ └── WXMenuController.php ├── composer.json ├── LICENSE ├── README.md └── resources ├── assets ├── css │ └── style.min.css └── js │ └── index.min.js └── views └── index.blade.php /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | -------------------------------------------------------------------------------- /wxmenu.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yisonli/wxmenu/HEAD/wxmenu.jpg -------------------------------------------------------------------------------- /routes/web.php: -------------------------------------------------------------------------------- 1 | 'WeChatMenu', 17 | 'path' => 'wxmenu', 18 | 'icon' => 'fa-gears', 19 | ]; 20 | } -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "yisonli/wxmenu", 3 | "description": "An editor for wechat menu.", 4 | "type": "library", 5 | "keywords": ["laravel-admin", "extension"], 6 | "homepage": "https://github.com/yisonli/wxmenu", 7 | "license": "MIT", 8 | "authors": [ 9 | { 10 | "name": "yisonli", 11 | "email": "yisonli@vip.qq.com" 12 | } 13 | ], 14 | "require": { 15 | "php": ">=7.0.0", 16 | "encore/laravel-admin": "~1.6" 17 | }, 18 | "require-dev": { 19 | "phpunit/phpunit": "~6.0" 20 | }, 21 | "autoload": { 22 | "psr-4": { 23 | "Yisonli\\WXMenu\\": "src/" 24 | } 25 | }, 26 | "extra": { 27 | "laravel": { 28 | "providers": [ 29 | "Yisonli\\WXMenu\\WXMenuServiceProvider" 30 | ] 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/WXMenuFormField.php: -------------------------------------------------------------------------------- 1 | value)) { 22 | $this->value = !empty($this->default) ? $this->default : [ 23 | "button" => [], 24 | ]; 25 | } 26 | if (!is_string($this->value)) { 27 | $this->value = json_encode($this->value); 28 | }else { 29 | $this->value = json_encode(json_decode($this->value)); //兼容json里有类似

格式,首次初始化显示会丢失的问题 30 | } 31 | 32 | return parent::render(); 33 | } 34 | } -------------------------------------------------------------------------------- /src/WXMenuServiceProvider.php: -------------------------------------------------------------------------------- 1 | views()) { 21 | $this->loadViewsFrom($views, 'wxmenu'); 22 | } 23 | 24 | if ($this->app->runningInConsole() && $assets = $extension->assets()) { 25 | $this->publishes( 26 | [$assets => public_path('vendor/laravel-admin-ext/wxmenu')], 27 | 'wxmenu' 28 | ); 29 | } 30 | 31 | Admin::booting(function () { 32 | Form::extend('wxmenu', WXMenuFormField::class); 33 | }); 34 | 35 | $this->app->booted(function () { 36 | WXMenu::routes(__DIR__.'/../routes/web.php'); 37 | }); 38 | } 39 | } -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2019 yisonli(yyeer.com) 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | this software and associated documentation files (the "Software"), to deal in 7 | the Software without restriction, including without limitation the rights to 8 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 9 | the Software, and to permit persons to whom the Software is furnished to do so, 10 | subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 19 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 20 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # An editor for WeChat Menu. 2 | 3 | This is a `laravel-admin` extension that integrates [wx_menu](http://www.jq22.com/jquery-info21835) into `laravel-admin`. 4 | 5 | 6 | ## Screenshot 7 | 8 | 9 | 10 | ## Installation 11 | 12 | First, install dependencies: 13 | 14 | ```bash 15 | composer require yisonli/wxmenu 16 | ``` 17 | 18 | Then, publish the resource directory: 19 | 20 | ```bash 21 | php artisan vendor:publish --tag=wxmenu --force 22 | ``` 23 | 24 | ## Configuration 25 | 26 | In the `extensions` section of the `config/admin.php` file, add some configuration that belongs to this extension. 27 | 28 | ```php 29 | 'extensions' => [ 30 | 'wxmenu' => [ 31 | // set to false if you want to disable this extension 32 | 'enable' => true, 33 | ] 34 | ] 35 | ``` 36 | 37 | 38 | ## Usage 39 | 40 | Use it in the form form: 41 | 42 | ```php 43 | $form->wxmenu('content'); 44 | 45 | // Also you can set default value like this 46 | $form->wxmenu('content')->default($default_value); 47 | ``` 48 | 49 | ## License 50 | 51 | Licensed under [The MIT License](LICENSE). 52 | 53 | ## About Me 54 | name: yison.li 55 | blog: [http://yyeer.com](http://yyeer.com) 56 | github: [https://github.com/yisonli](https://github.com/yisonli) 57 | 58 | ![](http://yyeer.com/assets/img/YisonWechat.png) -------------------------------------------------------------------------------- /src/Http/Controllers/WXMenuController.php: -------------------------------------------------------------------------------- 1 | [ 15 | [ 16 | "name" => "菜单1", 17 | "sub_button" => [ 18 | [ 19 | "name" => "子菜单5", 20 | "type" => "view", 21 | ], 22 | [ 23 | "name" => "子菜单4", 24 | "type" => "view", 25 | ], 26 | ], 27 | ], 28 | [ 29 | "name" => "菜单名称", 30 | "type" => "click", 31 | "url" => "http://yyeer.com/", 32 | ], 33 | [ 34 | "name" => "菜单名称", 35 | "type" => "view", 36 | "url" => "http://yyeer.com/", 37 | ], 38 | ], 39 | ]; 40 | } 41 | return $content 42 | ->title('Title') 43 | ->description('Description') 44 | ->body(view('wxmenu::index', ['value'=>json_encode($value, JSON_UNESCAPED_UNICODE)])); 45 | } 46 | } -------------------------------------------------------------------------------- /resources/assets/css/style.min.css: -------------------------------------------------------------------------------- 1 | .editor-handler-tips{position:absolute;left:50%;top:50%;margin:-10px 0 0 -10px;color:#07a4ef}.custom-menu-wraper{padding:20px 25px}.custom-menu-wraper h2,.custom-menu-wraper p,.custom-menu-wraper ul,.custom-menu-wraper h3{margin:0;padding:0}.custom-phone-box{min-width:320px;max-width:320px;background:#fff;height:565px;box-shadow:2px 3px 5px #e7e7eb;border-radius:2px;border:1px solid #e7e7eb;text-align:center}.custom-nav-title{line-height:55px;background:#333;border-radius:2px 2px 0 0;color:#fff;font-size:15px;margin:0}.custom-phone-body{line-height:457px;margin:0;color:#999}.custom-phone-footer{border-top:1px solid #e7e7eb;line-height:50px;background:#fbfbfb}.custom-a-button{display:block;line-height:50px;text-align:center}.custom-a-button:hover{text-decoration:none}.custom-svg-size{display:inline-block;width:25px;height:25px;margin:0;padding:0;vertical-align:top;position:relative}.custom-svg-size:after,.custom-svg-size::before{content:"";position:absolute;left:50%;top:50%;transform:translate(-50%,-50%);width:23px;height:3px;border-radius:10px;background:#666}.custom-svg-size::before{height:23px;width:3px}.custom-a-button .custom-svg-size{vertical-align:-9px}.custom-a-button:hover .custom-svg-size::before,.custom-a-button:hover .custom-svg-size::after{background:#1b8bf5}.custom-edit-menu{background-color:#f4f5f9;border:1px solid #e7e7eb;padding:0 20px 5px;min-height:565px;position:relative;border-radius:2px}.custom-editor_arrow_wrp{position:absolute;left:-13px;bottom:40px}.custom-editor_arrow_wrp .editor_arrow{display:inline-block;width:0;height:0;border-width:12px;border-style:dashed;border-color:transparent;border-left-width:0;border-right-color:#e7e7eb;border-right-style:solid;left:0;position:absolute}.custom-editor_arrow_wrp .editor_arrow_in{left:1px;border-right-color:#f4f5f9}.custom-editor-title{padding-top:10px;border-bottom:1px solid #e6e6e6;margin:0;line-height:40px}.custom-edit-menu h2{font-size:15px;line-height:40px;font-weight:normal}.form-horizontal{padding-top:20px}.form-horizontal .control-label{font-weight:normal;padding-right:0}.menu-type-select{margin-right:10px;display:inline-block}.custom-panel-default{background:#fff;border-radius:3px;padding:25px 5px;border:1px solid #e6e6e6}.form-horizontal .submit-button{margin-top:40px}.custom-menu-wraper .submit-menu-handler{padding:20px 0}.pre_menu_list{display:box;display:-webkit-box;display:flex;display:-webkit-flex;margin:0;padding:0}.pre_menu_list li{list-style:none;flex:1;border:1px solid #fbfbfb;transition:all .3s;position:relative}.pre_menu_item+.pre_menu_item{border-left:1px solid #e7e7eb;font-size:12px}.pre_menu_item a{color:#444}.pre_menu_item.active{border-color:#07a4ef}.pre_menu_item.active a.pre_menu_link{color:#07a4ef}.pre_menu_item.selected .sub_pre_menu_box{display:block}.sub_pre_menu_box{display:none;position:absolute;bottom:63px;left:2.5%;width:95%;border:1px solid #e7e7eb;background-color:#fff}.sub_pre_menu_box .arrow{position:absolute;left:50%;margin-left:-6px;display:inline-block;width:0;height:0;border-style:dashed;border-color:transparent;border-bottom-width:0;border-top-style:solid;border-width:6px}.sub_pre_menu_box .arrow_out{border-top-color:#e7e7eb;bottom:-13px}.sub_pre_menu_box .arrow_in{bottom:-12px;border-top-color:#fff}.sub_pre_menu_box a{line-height: 22px;color: #444;font-size: 13px;padding: 8px 2px;}.sub_pre_menu_item+.sub_pre_menu_item{border-top:1px solid #e7e7eb}.sub_pre_menu_item .custom-a-button:hover{background:#fbfbfb;border-color:#fbfbfb}.sub_pre_menu_item.active .custom-a-button{background:#07a4ef;color:#fff}.custom-toast{margin-top:20px;color:#fb000b;font-weight:bold} -------------------------------------------------------------------------------- /resources/assets/js/index.min.js: -------------------------------------------------------------------------------- 1 | var time=null;function jsonFormat(options){if(!options){return{}};var array=options.button||[];for(var i=0;i 3 |
4 |
5 |
6 |

{{$label}}

7 |

内容区域

8 | 46 |
47 |
48 |
49 |
50 | 51 | 52 | 53 | 54 |
55 |
56 |

编辑菜单

57 | 删除菜单 58 |
59 |
60 |
61 | 62 |
63 | 64 |
65 |
66 |
67 |
68 | 69 |
70 | 77 |
78 |
79 | 80 |
81 | 82 |
83 |
84 |
85 | 86 |

87 | 88 |

89 |
90 |
91 | 92 |

93 | 94 |

95 |
96 |
97 | 98 |

99 | 100 |

101 |
102 |
103 |
104 |
105 | 106 |

107 | 108 |

109 |
110 |
111 |
112 |
113 | 114 |

115 | 117 |

118 |
119 |
120 |
121 |
122 |
123 | 124 |
125 | 126 |
127 | 130 |
131 | 132 |
133 |
134 |
135 |
136 |
137 |

请选择左侧菜单

138 |
139 |
140 |
141 | 142 | 143 | 144 | 145 | 146 | 154 | --------------------------------------------------------------------------------