Mojito 是一个基于 Laravel, Vue, Element 构建的后台管理系统。
https://github.com/moell-peng/mojito 欢迎使用和 star
首先安装 laravel,并且确保你配置了正确的数据库连接。
composer require moell/mojito
然后运行下面的命令来发布资源:
php artisan mojito:install
命令执行成功会生成配置文件,数据迁移和构建 SPA 的文件。
在config/auth.php
中添加相应的 guards 和 providers,如下:
'guards' => [
...
'admin' => [
'driver' => 'passport',
'provider' => 'admin'
]
],
'providers' => [
...
'admin' => [
'driver' => 'eloquent',
'model' => \Moell\Mojito\Models\AdminUser::class,
]
],
在 app/Http/Kernel.php
中 $routeMiddleware 属性添加路由中间 oauth.providers
和 mojito.permission
,并将auth
中间件替换为如下:
class Kernel extends HttpKernel
{
protected $routeMiddleware = [
// 'auth' => \Illuminate\Auth\Middleware\Authenticate::class,
'auth' => \SMartins\PassportMultiauth\Http\Middleware\MultiAuthenticate::class,
'oauth.providers' => \SMartins\PassportMultiauth\Http\Middleware\AddCustomProvider::class,
'mojito.permission' => \Moell\Mojito\Http\Middleware\Authenticate::class,
];
}
执行数据迁移,数据填充
php artisan migrate
php artisan db:seed --class="Moell\Mojito\Database\MojitoTableSeeder"
Passport 安装和配置
php artisan passport:install
执行成功后获取到相应的密码授予客户端的 ID 和 secret 并且配置到相对应的 resources/config/index.js
:
export default {
admin: {
authorize: {
clientId: ID,
clientSecret: secret
}
}
安装 Javscript 依赖
npm install
npm install -D vuex@^3.0.1 vue-router@^3.0.1 vue-i18n@^8.1.0 localforage@^1.7.2 element-ui@^2.4.6
Mix 引入 admin.js
mix.js('resources/assets/js/app.js', 'public/js')
.sass('resources/assets/sass/app.scss', 'public/css')
//.js('resources/js/admin.js', 'public/js') laravel5.7+
.js('resources/assets/js/admin.js', 'public/js')
运行 Mix
#npm run watch
npm run production
登录
url: http://localhost/mojito#/admin/login
email: [email protected]
password: secret
Apache License Version 2.0 see http://www.apache.org/licenses/LICENSE-2.0.html
1
nosay 2018-10-10 10:12:09 +08:00
非常感谢。
|