├── .env.example ├── .gitattributes ├── .gitignore ├── README.md ├── app ├── Console │ └── Kernel.php ├── Exceptions │ ├── Error.php │ └── Handler.php ├── Extensions │ └── JWTManager.php ├── Http │ ├── Controllers │ │ ├── Admin │ │ │ ├── AdminController.php │ │ │ ├── AuthController.php │ │ │ ├── CommonController.php │ │ │ ├── Controller.php │ │ │ └── PostController.php │ │ ├── Blog │ │ │ └── PostController.php │ │ └── Controller.php │ ├── Kernel.php │ ├── Middleware │ │ ├── EncryptCookies.php │ │ ├── RedirectIfAuthenticated.php │ │ ├── TrimStrings.php │ │ └── VerifyCsrfToken.php │ └── Traits │ │ └── QueryTrait.php ├── Jobs │ └── InvalidateToken.php ├── Models │ ├── Admin │ │ └── Admin.php │ ├── Model.php │ └── Post.php ├── Providers │ ├── AppServiceProvider.php │ ├── AuthServiceProvider.php │ ├── BroadcastServiceProvider.php │ ├── EventServiceProvider.php │ └── RouteServiceProvider.php └── User.php ├── artisan ├── bootstrap ├── app.php ├── autoload.php └── cache │ └── .gitignore ├── composer.json ├── composer.lock ├── config ├── app.php ├── auth.php ├── broadcasting.php ├── cache.php ├── database.php ├── errorCode.php ├── filesystems.php ├── jwt.php ├── mail.php ├── queue.php ├── services.php ├── session.php └── view.php ├── database ├── .gitignore ├── factories │ ├── ModelFactory.php │ └── PostsFactory.php ├── migrations │ ├── 2016_10_13_172709_create_admins.php │ ├── 2016_10_13_172801_create_roles.php │ ├── 2016_10_13_172824_create_menus.php │ ├── 2016_10_13_172844_create_role_menu_relations.php │ ├── 2016_10_13_172903_create_admin_role_relations.php │ ├── 2017_02_27_080116_create_posts.php │ ├── 2017_02_27_093221_create_jobs_table.php │ ├── 2017_02_27_093510_create_failed_jobs_table.php │ └── 2017_03_09_021536_create_user_behaviors.php └── seeds │ ├── AdminsSeeder.php │ └── PostsSeeder.php ├── index.php ├── phpunit.xml ├── public ├── .htaccess ├── admin.html ├── css │ └── app.css ├── favicon.ico ├── images │ ├── avatar_404.png │ └── test1.jpg ├── index.html ├── index.php ├── js │ └── app.js ├── login.html ├── robots.txt ├── static │ ├── css │ │ ├── admin.5e90173802334ee7c3d0f9ecf30dd497.css │ │ ├── admin.5e90173802334ee7c3d0f9ecf30dd497.css.map │ │ ├── admin_login.d8d7a059deb29d8e86f74eea90f75a49.css │ │ ├── admin_login.d8d7a059deb29d8e86f74eea90f75a49.css.map │ │ ├── front.9a4b796def8faef7451dc3e3ce60b9e2.css │ │ └── front.9a4b796def8faef7451dc3e3ce60b9e2.css.map │ ├── img │ │ ├── icomoon.0a74426.eot │ │ ├── icomoon.7d4ac7d.woff │ │ ├── icomoon.9f5fd7b.ttf │ │ ├── icomoon.f558046.svg │ │ ├── ionicons.05acfdb.woff │ │ ├── ionicons.24712f6.ttf │ │ ├── ionicons.2c2ae06.eot │ │ └── ionicons.621bd38.svg │ └── js │ │ ├── 0.c83c4ee40c7c12dc500f.js │ │ ├── 0.c83c4ee40c7c12dc500f.js.map │ │ ├── 1.edeb8ba5a3fa0487ef46.js │ │ ├── 1.edeb8ba5a3fa0487ef46.js.map │ │ ├── vendor.0542271462c018e7c54d.js │ │ └── vendor.0542271462c018e7c54d.js.map └── web.config ├── resources ├── assets │ ├── js │ │ ├── app.js │ │ ├── bootstrap.js │ │ └── components │ │ │ └── Example.vue │ └── sass │ │ ├── _variables.scss │ │ └── app.scss ├── lang │ ├── en │ │ ├── auth.php │ │ ├── pagination.php │ │ ├── passwords.php │ │ └── validation.php │ └── zh-cn │ │ ├── auth.php │ │ ├── pagination.php │ │ ├── passwords.php │ │ └── validation.php └── views │ ├── admin │ ├── index.blade.php │ └── login.blade.php │ └── welcome.blade.php ├── routes ├── api.php ├── channels.php ├── console.php └── web.php ├── server.php ├── storage ├── app │ └── .gitignore ├── framework │ └── cache │ │ └── data │ │ ├── 50 │ │ └── 36 │ │ │ └── 5036f31d66a92dda927d18a5af911026e8abf099 │ │ └── ff │ │ └── c9 │ │ └── ffc91e236ff46ac59b2756eb2649f1a6b98d209b └── logs │ └── .gitignore ├── tests ├── CreatesApplication.php ├── Feature │ └── ExampleTest.php ├── TestCase.php └── Unit │ └── ExampleTest.php └── views-src ├── .babelrc ├── build ├── build.js ├── check-versions.js ├── dev-client.js ├── dev-server.js ├── utils.js ├── vue-loader.conf.js ├── webpack.base.conf.js ├── webpack.dev.conf.js └── webpack.prod.conf.js ├── config ├── dev.env.js ├── index.js └── prod.env.js ├── index.html ├── package-lock.json ├── package.json └── src ├── admin.js ├── assets └── logo.png ├── components ├── Hello.vue ├── async-table.vue └── login-form.vue ├── config ├── admin-config.js ├── config.js └── front-config.js ├── front.js ├── login.js ├── router ├── admin-router.js ├── front-router.js └── index.js ├── templates ├── admin.ejs ├── front.ejs └── login.ejs └── views ├── admin ├── App.vue └── post │ ├── form.vue │ └── index.vue ├── front ├── App.vue └── post │ ├── index.vue │ └── show.vue └── login.js /.env.example: -------------------------------------------------------------------------------- 1 | APP_ENV=local 2 | APP_KEY= 3 | APP_DEBUG=true 4 | APP_LOG_LEVEL=debug 5 | APP_URL=http://localhost 6 | 7 | DB_CONNECTION=mysql 8 | DB_HOST=127.0.0.1 9 | DB_PORT=3306 10 | DB_DATABASE=homestead 11 | DB_USERNAME=homestead 12 | DB_PASSWORD=secret 13 | 14 | BROADCAST_DRIVER=log 15 | CACHE_DRIVER=file 16 | SESSION_DRIVER=file 17 | QUEUE_DRIVER=sync 18 | 19 | REDIS_HOST=127.0.0.1 20 | REDIS_PASSWORD=null 21 | REDIS_PORT=6379 22 | 23 | MAIL_DRIVER=smtp 24 | MAIL_HOST=mailtrap.io 25 | MAIL_PORT=2525 26 | MAIL_USERNAME=null 27 | MAIL_PASSWORD=null 28 | MAIL_ENCRYPTION=null 29 | 30 | PUSHER_APP_ID= 31 | PUSHER_APP_KEY= 32 | PUSHER_APP_SECRET= 33 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto 2 | *.css linguist-vendored 3 | *.scss linguist-vendored 4 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /public/storage 2 | /public/hot 3 | /storage/*.key 4 | /storage/framework/cache 5 | /storage/framework/sessions 6 | /vendor 7 | /.idea 8 | Homestead.json 9 | Homestead.yaml 10 | .env 11 | /views-src/node_modules 12 | /public/*.html 13 | /public/static 14 | /public/pics/* -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # spa demo 2 | _一个简单的前后端分离单页blog应用,后端接口使用laravel5.4,前端使用webpack vuejs实现单页应用,后台使用iview2UI组件库_ 3 | 4 | > 技术栈 laravel5.4 + webpack2 + Vuejs2 + vue-router + vue-resource + iview2 5 | 6 | ## 安装composer包 7 | ``` bash 8 | composer install 9 | ``` 10 | 11 | ## 运行迁移文件 12 | ``` bash 13 | php artisan migrate 14 | ``` 15 | 16 | ## 如果需要测试数据可以运行seeder文件,会生成后台账号[admin admin]和测试数据 17 | ```bash 18 |    php artisan db:seed --class=AdminsSeeder 19 | php artisan db:seed --class=PostsSeeder 20 | ``` 21 | 22 | ## 进入views-src目录安装前端资源 23 | *修改src/config/config.js 配置文件,设置api_domain cdn* 24 | 25 | ``` bash 26 | # install dependencies 27 | npm install 28 | 29 | # serve with hot reload at localhost:8080 30 | npm run dev 31 | 32 | # build for production with minification 33 | npm run build 34 | 35 | # build for production and view the bundle analyzer report 36 | npm run build --report 37 | ``` 38 | ## 安装完成 39 | * /index.html 首页地址 40 | * /login.html 后台登录地址 41 | * /admin.html 后台首页地址 42 | -------------------------------------------------------------------------------- /app/Console/Kernel.php: -------------------------------------------------------------------------------- 1 | command('inspire') 28 | // ->hourly(); 29 | } 30 | 31 | /** 32 | * Register the Closure based commands for the application. 33 | * 34 | * @return void 35 | */ 36 | protected function commands() 37 | { 38 | require base_path('routes/console.php'); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /app/Exceptions/Error.php: -------------------------------------------------------------------------------- 1 | code = isset($config['code']) ? $config['code'] : 1; 15 | $this->message = empty($message) && isset($config['msg']) ? $config['msg'] : $message; 16 | $this->statusCode = $statusCode; 17 | } 18 | 19 | 20 | public function setData($data) 21 | { 22 | $this->_data = $data; 23 | return $this; 24 | } 25 | 26 | 27 | public function getData() 28 | { 29 | return $this->_data; 30 | } 31 | 32 | 33 | public function getStatusCode() 34 | { 35 | return $this->statusCode; 36 | } 37 | } -------------------------------------------------------------------------------- /app/Exceptions/Handler.php: -------------------------------------------------------------------------------- 1 | getMessage(); 55 | $data = []; 56 | $code = 1; 57 | $statusCode = 500; 58 | switch ($e) { 59 | case $e instanceof TokenMismatchException: 60 | $msg = '登录超时,请重新登录'; 61 | 62 | case ($e instanceof AuthenticationException) || ($e instanceof JWTException): 63 | $statusCode = 401; 64 | $code = 1004; 65 | break; 66 | 67 | case $e instanceof ValidationException: 68 | $msg = '填写数据有误'; 69 | $data = $e->validator->errors(); 70 | $statusCode = 422; 71 | break; 72 | 73 | case $e instanceof Error: 74 | $data = $e->getData(); 75 | $code = $e->getCode(); 76 | break; 77 | 78 | case $e instanceof ModelNotFoundException: 79 | $msg = '找不到对象'; 80 | $statusCode = 404; 81 | break; 82 | 83 | default: 84 | } 85 | 86 | $statusCode = method_exists($e, 'getStatusCode') ? $e->getStatusCode() : $statusCode; 87 | $msg = empty($msg) ? Response::$statusTexts[$statusCode] : $msg; 88 | 89 | return response(json_encode([ 90 | 'code' => $code, 91 | 'msg' => $msg, 92 | 'data' => $data, 93 | 'status_code' => $statusCode, 94 | ], JSON_UNESCAPED_UNICODE))->header('Content-Type', 'application/json'); 95 | } 96 | 97 | /** 98 | * @param $request 99 | * @param AuthenticationException $exception 100 | * @return \Illuminate\Http\RedirectResponse 101 | * @throws AuthenticationException 102 | */ 103 | protected function unauthenticated($request, AuthenticationException $exception) 104 | { 105 | if ($request->expectsJson()) { 106 | throw $exception; 107 | } 108 | 109 | return redirect()->guest('login'); 110 | } 111 | } 112 | -------------------------------------------------------------------------------- /app/Extensions/JWTManager.php: -------------------------------------------------------------------------------- 1 | setRefreshFlow()->decode($token); 19 | 20 | if ($this->blacklistEnabled) { 21 | // 延时一分钟失效旧token,避免客户端并行请求时后面的请求的token不可用 22 | dispatch((new InvalidateToken())->delay(Carbon::now()->addMinute(1))); 23 | } 24 | 25 | // return the new token 26 | return $this->encode( 27 | $this->payloadFactory->make([ 28 | 'sub' => $payload['sub'], 29 | 'iat' => $payload['iat'], 30 | ]) 31 | ); 32 | } 33 | } -------------------------------------------------------------------------------- /app/Http/Controllers/Admin/AdminController.php: -------------------------------------------------------------------------------- 1 | response(['Hello World!']); 10 | } 11 | } -------------------------------------------------------------------------------- /app/Http/Controllers/Admin/AuthController.php: -------------------------------------------------------------------------------- 1 | session()->regenerate(); 16 | 17 | $this->clearLoginAttempts($request); 18 | 19 | return $this->response(); 20 | } 21 | 22 | protected function sendFailedLoginResponse(Request $request) 23 | { 24 | throw new Error(401, 'LOGIN_FAIL'); 25 | } 26 | 27 | public function username() 28 | { 29 | return 'username'; 30 | } 31 | 32 | public function user() 33 | { 34 | return $this->response($this->guard()->user()); 35 | } 36 | 37 | public function logout(Request $request) 38 | { 39 | $this->guard()->logout(); 40 | 41 | $request->session()->flush(); 42 | 43 | $request->session()->regenerate(); 44 | 45 | return $this->response(); 46 | } 47 | } -------------------------------------------------------------------------------- /app/Http/Controllers/Admin/CommonController.php: -------------------------------------------------------------------------------- 1 | request->file('file'); 12 | if ($PictureFile->isValid()) { 13 | $extension = $PictureFile->extension(); 14 | if (! in_array($extension, ['jpg', 'jpeg', 'png'])) { 15 | throw new Error(400, 'PICTURE_EXTENSION_ERROR'); 16 | } 17 | if ($PictureFile->getClientSize() > 10 * 1024 * 1024) { 18 | throw new Error(400, 'PICTURE_SIZE_OVER'); 19 | } 20 | 21 | $path = $PictureFile->store('pics/post', 'upload'); 22 | 23 | return $this->response(['path' => $path]); 24 | } else { 25 | throw new Error(400, 'INVALID_PICTURE'); 26 | } 27 | } 28 | } -------------------------------------------------------------------------------- /app/Http/Controllers/Admin/Controller.php: -------------------------------------------------------------------------------- 1 | getModelQuery(); 16 | } 17 | 18 | public function display($id) 19 | { 20 | $this->getModelQuery()->where('id', $id)->update(['is_show' => Post::YES]); 21 | 22 | return $this->response(); 23 | } 24 | 25 | public function hide($id) 26 | { 27 | $this->getModelQuery()->where('id', $id)->update(['is_show' => Post::NO]); 28 | 29 | return $this->response(); 30 | } 31 | } -------------------------------------------------------------------------------- /app/Http/Controllers/Blog/PostController.php: -------------------------------------------------------------------------------- 1 | 'required|max:150', 13 | 'desc' => 'max:300', 14 | 'content' => 'required' 15 | ]; 16 | protected $attributes = [ 17 | 'title' => '标题', 18 | 'desc' => '简介', 19 | 'content' => '内容' 20 | ]; 21 | 22 | protected function beforeIndex() 23 | { 24 | $this->getModelQuery()->show(); 25 | } 26 | 27 | protected function beforeShow($id) 28 | { 29 | $this->getModelQuery()->show(); 30 | } 31 | } -------------------------------------------------------------------------------- /app/Http/Controllers/Controller.php: -------------------------------------------------------------------------------- 1 | request = $request; 23 | } 24 | 25 | public function index() 26 | { 27 | if (method_exists($this, 'beforeIndex')) { 28 | $this->beforeIndex(); 29 | } 30 | $Query = $this->getModelQuery(); 31 | $this->prepareFilter($Query); 32 | $this->prepareSort($Query); 33 | $Models = $Query->paginate($this->getPageSize()); 34 | if (method_exists($this, 'afterIndex')) { 35 | $this->afterIndex($Models); 36 | } 37 | 38 | return $this->response($Models); 39 | } 40 | 41 | public function store() 42 | { 43 | $this->validate($this->request, $this->rules, $this->messages, $this->attributes); 44 | 45 | $Model = $this->getModelQuery()->getModel()->create($this->request->all()); 46 | 47 | return $this->response($Model); 48 | } 49 | 50 | public function update($id) 51 | { 52 | $this->validate($this->request, $this->rules, $this->messages, $this->attributes); 53 | 54 | $Model = $this->getModelQuery()->findOrFail($id); 55 | $Model->fill($this->request->all()); 56 | $Model->save(); 57 | 58 | return $this->response($Model); 59 | } 60 | 61 | public function show($id) 62 | { 63 | if (method_exists($this, 'beforeShow')) { 64 | $this->beforeShow($id); 65 | } 66 | $Model = $this->getModelQuery()->findOrFail($id); 67 | if (method_exists($this, 'afterShow')) { 68 | $this->afterShow($Model); 69 | } 70 | 71 | return $this->response($Model); 72 | } 73 | 74 | public function destroy($id) 75 | { 76 | $this->getModelQuery()->where('id', $id)->delete(); 77 | 78 | return $this->response(); 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /app/Http/Kernel.php: -------------------------------------------------------------------------------- 1 | [ 31 | \App\Http\Middleware\EncryptCookies::class, 32 | \Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class, 33 | \Illuminate\Session\Middleware\StartSession::class, 34 | // \Illuminate\Session\Middleware\AuthenticateSession::class, 35 | \Illuminate\View\Middleware\ShareErrorsFromSession::class, 36 | // \App\Http\Middleware\VerifyCsrfToken::class, 37 | \Illuminate\Routing\Middleware\SubstituteBindings::class, 38 | ], 39 | 40 | 'api' => [ 41 | 'throttle:60,1', 42 | 'bindings', 43 | ], 44 | ]; 45 | 46 | /** 47 | * The application's route middleware. 48 | * 49 | * These middleware may be assigned to groups or used individually. 50 | * 51 | * @var array 52 | */ 53 | protected $routeMiddleware = [ 54 | 'auth' => \Illuminate\Auth\Middleware\Authenticate::class, 55 | 'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class, 56 | 'bindings' => \Illuminate\Routing\Middleware\SubstituteBindings::class, 57 | 'can' => \Illuminate\Auth\Middleware\Authorize::class, 58 | 'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class, 59 | 'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class, 60 | ]; 61 | } 62 | -------------------------------------------------------------------------------- /app/Http/Middleware/EncryptCookies.php: -------------------------------------------------------------------------------- 1 | check()) { 21 | return redirect('/home'); 22 | } 23 | 24 | return $next($request); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /app/Http/Middleware/TrimStrings.php: -------------------------------------------------------------------------------- 1 | model) && empty($model)) { 19 | throw new Error(500, 1, 'model设置有误'); 20 | } 21 | 22 | $model = empty($model) ? $this->model : $model; 23 | if ($forceCreate) { 24 | return app($this->model)->query(); 25 | } 26 | 27 | if (isset(self::$modelCache[$model])) { 28 | return self::$modelCache[$model]; 29 | } 30 | 31 | self::$modelCache[$model] = app($this->model)->query(); 32 | return self::$modelCache[$model]; 33 | } 34 | 35 | protected function prepareFilter(Builder $Query) 36 | { 37 | $filters = json_decode($this->request->input('filter'), true); 38 | if (empty($filters)) { 39 | return; 40 | } 41 | 42 | foreach ($filters as $field => $filter) { 43 | if (! $filter) { 44 | continue; 45 | } 46 | $Query->where(function ($query) use ($field, $filter) { 47 | if (in_array($field, $this->equalFields)) { 48 | if (is_array($filter) && count($filter) === 2) { 49 | if ($filter[0] && $filter[1]) { 50 | $query->whereBetween($field, $filter); 51 | } 52 | } else if (is_string($filter) || is_numeric($filter)) { 53 | $query->where($field, $filter); 54 | } 55 | } else if (in_array($field, $this->timeFields) && is_array($filter)) { 56 | if ($filter[0] && $filter[1]) { 57 | $filter = array_map(function ($value) { 58 | return strtotime($value); 59 | }, $filter); 60 | $query->whereBetween($field, $filter); 61 | } 62 | } else if (in_array($field, $this->likeFields) && (is_string($filter) || is_numeric($filter))) { 63 | $query->where($field, 'like', '%'. $filter .'%'); 64 | } 65 | }); 66 | } 67 | } 68 | 69 | protected function prepareSort(Builder $Query) 70 | { 71 | $sortBy = $this->request->input('sort'); 72 | $sortBy = $sortBy ? json_decode($sortBy, true) : []; 73 | foreach ($sortBy as $field => $order) { 74 | $Query->orderBy($field, $order); 75 | } 76 | 77 | $Query->orderBy('id', 'asc'); 78 | } 79 | 80 | protected function getPageSize() 81 | { 82 | return $this->request->get('pageSize', $this->pageSize); 83 | } 84 | 85 | protected function response($data = [], $msg = 'success', $code = 0, $statusCode = 200) 86 | { 87 | return response(json_encode([ 88 | 'data' => empty($data) ? [] : $data, 89 | 'msg' => $msg, 90 | 'code' => $code, 91 | 'status_code' => $statusCode, 92 | ], JSON_UNESCAPED_UNICODE), $statusCode)->header('Content-Type', 'application/json'); 93 | } 94 | } -------------------------------------------------------------------------------- /app/Jobs/InvalidateToken.php: -------------------------------------------------------------------------------- 1 | where('is_show', self::YES); 17 | } 18 | } -------------------------------------------------------------------------------- /app/Providers/AppServiceProvider.php: -------------------------------------------------------------------------------- 1 | [ 17 | 'App\Listeners\EventListener', 18 | ], 19 | ]; 20 | 21 | /** 22 | * Register any events for your application. 23 | * 24 | * @return void 25 | */ 26 | public function boot() 27 | { 28 | parent::boot(); 29 | 30 | // 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /app/Providers/RouteServiceProvider.php: -------------------------------------------------------------------------------- 1 | mapApiRoutes(); 39 | 40 | $this->mapWebRoutes(); 41 | 42 | // 43 | } 44 | 45 | /** 46 | * Define the "web" routes for the application. 47 | * 48 | * These routes all receive session state, CSRF protection, etc. 49 | * 50 | * @return void 51 | */ 52 | protected function mapWebRoutes() 53 | { 54 | Route::middleware('web') 55 | ->namespace($this->namespace) 56 | ->group(base_path('routes/web.php')); 57 | } 58 | 59 | /** 60 | * Define the "api" routes for the application. 61 | * 62 | * These routes are typically stateless. 63 | * 64 | * @return void 65 | */ 66 | protected function mapApiRoutes() 67 | { 68 | Route::prefix('api') 69 | ->middleware('api') 70 | ->namespace($this->namespace) 71 | ->group(base_path('routes/api.php')); 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /app/User.php: -------------------------------------------------------------------------------- 1 | make(Illuminate\Contracts\Console\Kernel::class); 32 | 33 | $status = $kernel->handle( 34 | $input = new Symfony\Component\Console\Input\ArgvInput, 35 | new Symfony\Component\Console\Output\ConsoleOutput 36 | ); 37 | 38 | /* 39 | |-------------------------------------------------------------------------- 40 | | Shutdown The Application 41 | |-------------------------------------------------------------------------- 42 | | 43 | | Once Artisan has finished running. We will fire off the shutdown events 44 | | so that any final work may be done by the application before we shut 45 | | down the process. This is the last thing to happen to the request. 46 | | 47 | */ 48 | 49 | $kernel->terminate($input, $status); 50 | 51 | exit($status); 52 | -------------------------------------------------------------------------------- /bootstrap/app.php: -------------------------------------------------------------------------------- 1 | singleton( 30 | Illuminate\Contracts\Http\Kernel::class, 31 | App\Http\Kernel::class 32 | ); 33 | 34 | $app->singleton( 35 | Illuminate\Contracts\Console\Kernel::class, 36 | App\Console\Kernel::class 37 | ); 38 | 39 | $app->singleton( 40 | Illuminate\Contracts\Debug\ExceptionHandler::class, 41 | App\Exceptions\Handler::class 42 | ); 43 | 44 | /* 45 | |-------------------------------------------------------------------------- 46 | | Return The Application 47 | |-------------------------------------------------------------------------- 48 | | 49 | | This script returns the application instance. The instance is given to 50 | | the calling script so we can separate the building of the instances 51 | | from the actual running of the application and sending responses. 52 | | 53 | */ 54 | 55 | return $app; 56 | -------------------------------------------------------------------------------- /bootstrap/autoload.php: -------------------------------------------------------------------------------- 1 | =5.6.4", 9 | "laravel/framework": "5.4.*", 10 | "laravel/tinker": "~1.0", 11 | "predis/predis": "^1.1" 12 | }, 13 | "require-dev": { 14 | "fzaninotto/faker": "~1.4", 15 | "mockery/mockery": "0.9.*", 16 | "phpunit/phpunit": "~5.7" 17 | }, 18 | "autoload": { 19 | "classmap": [ 20 | "database" 21 | ], 22 | "psr-4": { 23 | "App\\": "app/" 24 | } 25 | }, 26 | "autoload-dev": { 27 | "psr-4": { 28 | "Tests\\": "tests/" 29 | } 30 | }, 31 | "scripts": { 32 | "post-root-package-install": [ 33 | "php -r \"file_exists('.env') || copy('.env.example', '.env');\"" 34 | ], 35 | "post-create-project-cmd": [ 36 | "php artisan key:generate" 37 | ], 38 | "post-install-cmd": [ 39 | "Illuminate\\Foundation\\ComposerScripts::postInstall", 40 | "php artisan optimize" 41 | ], 42 | "post-update-cmd": [ 43 | "Illuminate\\Foundation\\ComposerScripts::postUpdate", 44 | "php artisan optimize" 45 | ] 46 | }, 47 | "config": { 48 | "preferred-install": "dist", 49 | "sort-packages": true 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /config/app.php: -------------------------------------------------------------------------------- 1 | 'Laravel', 16 | 17 | /* 18 | |-------------------------------------------------------------------------- 19 | | Application Environment 20 | |-------------------------------------------------------------------------- 21 | | 22 | | This value determines the "environment" your application is currently 23 | | running in. This may determine how you prefer to configure various 24 | | services your application utilizes. Set this in your ".env" file. 25 | | 26 | */ 27 | 28 | 'env' => env('APP_ENV', 'production'), 29 | 30 | /* 31 | |-------------------------------------------------------------------------- 32 | | Application Debug Mode 33 | |-------------------------------------------------------------------------- 34 | | 35 | | When your application is in debug mode, detailed error messages with 36 | | stack traces will be shown on every error that occurs within your 37 | | application. If disabled, a simple generic error page is shown. 38 | | 39 | */ 40 | 41 | 'debug' => env('APP_DEBUG', false), 42 | 43 | /* 44 | |-------------------------------------------------------------------------- 45 | | Application URL 46 | |-------------------------------------------------------------------------- 47 | | 48 | | This URL is used by the console to properly generate URLs when using 49 | | the Artisan command line tool. You should set this to the root of 50 | | your application so that it is used when running Artisan tasks. 51 | | 52 | */ 53 | 54 | 'url' => env('APP_URL', 'http://localhost'), 55 | 56 | /* 57 | |-------------------------------------------------------------------------- 58 | | Application Timezone 59 | |-------------------------------------------------------------------------- 60 | | 61 | | Here you may specify the default timezone for your application, which 62 | | will be used by the PHP date and date-time functions. We have gone 63 | | ahead and set this to a sensible default for you out of the box. 64 | | 65 | */ 66 | 67 | 'timezone' => 'UTC', 68 | 69 | /* 70 | |-------------------------------------------------------------------------- 71 | | Application Locale Configuration 72 | |-------------------------------------------------------------------------- 73 | | 74 | | The application locale determines the default locale that will be used 75 | | by the translation service provider. You are free to set this value 76 | | to any of the locales which will be supported by the application. 77 | | 78 | */ 79 | 80 | 'locale' => 'zh-cn', 81 | 82 | /* 83 | |-------------------------------------------------------------------------- 84 | | Application Fallback Locale 85 | |-------------------------------------------------------------------------- 86 | | 87 | | The fallback locale determines the locale to use when the current one 88 | | is not available. You may change the value to correspond to any of 89 | | the language folders that are provided through your application. 90 | | 91 | */ 92 | 93 | 'fallback_locale' => 'zh-cn', 94 | 95 | /* 96 | |-------------------------------------------------------------------------- 97 | | Encryption Key 98 | |-------------------------------------------------------------------------- 99 | | 100 | | This key is used by the Illuminate encrypter service and should be set 101 | | to a random, 32 character string, otherwise these encrypted strings 102 | | will not be safe. Please do this before deploying an application! 103 | | 104 | */ 105 | 106 | 'key' => env('APP_KEY'), 107 | 108 | 'cipher' => 'AES-256-CBC', 109 | 110 | /* 111 | |-------------------------------------------------------------------------- 112 | | Logging Configuration 113 | |-------------------------------------------------------------------------- 114 | | 115 | | Here you may configure the log settings for your application. Out of 116 | | the box, Laravel uses the Monolog PHP logging library. This gives 117 | | you a variety of powerful log handlers / formatters to utilize. 118 | | 119 | | Available Settings: "single", "daily", "syslog", "errorlog" 120 | | 121 | */ 122 | 123 | 'log' => env('APP_LOG', 'single'), 124 | 125 | 'log_level' => env('APP_LOG_LEVEL', 'debug'), 126 | 127 | /* 128 | |-------------------------------------------------------------------------- 129 | | Autoloaded Service Providers 130 | |-------------------------------------------------------------------------- 131 | | 132 | | The service providers listed here will be automatically loaded on the 133 | | request to your application. Feel free to add your own services to 134 | | this array to grant expanded functionality to your applications. 135 | | 136 | */ 137 | 138 | 'providers' => [ 139 | 140 | /* 141 | * Laravel Framework Service Providers... 142 | */ 143 | Illuminate\Auth\AuthServiceProvider::class, 144 | Illuminate\Broadcasting\BroadcastServiceProvider::class, 145 | Illuminate\Bus\BusServiceProvider::class, 146 | Illuminate\Cache\CacheServiceProvider::class, 147 | Illuminate\Foundation\Providers\ConsoleSupportServiceProvider::class, 148 | Illuminate\Cookie\CookieServiceProvider::class, 149 | Illuminate\Database\DatabaseServiceProvider::class, 150 | Illuminate\Encryption\EncryptionServiceProvider::class, 151 | Illuminate\Filesystem\FilesystemServiceProvider::class, 152 | Illuminate\Foundation\Providers\FoundationServiceProvider::class, 153 | Illuminate\Hashing\HashServiceProvider::class, 154 | Illuminate\Mail\MailServiceProvider::class, 155 | Illuminate\Notifications\NotificationServiceProvider::class, 156 | Illuminate\Pagination\PaginationServiceProvider::class, 157 | Illuminate\Pipeline\PipelineServiceProvider::class, 158 | Illuminate\Queue\QueueServiceProvider::class, 159 | Illuminate\Redis\RedisServiceProvider::class, 160 | Illuminate\Auth\Passwords\PasswordResetServiceProvider::class, 161 | Illuminate\Session\SessionServiceProvider::class, 162 | Illuminate\Translation\TranslationServiceProvider::class, 163 | Illuminate\Validation\ValidationServiceProvider::class, 164 | Illuminate\View\ViewServiceProvider::class, 165 | 166 | /* 167 | * Package Service Providers... 168 | */ 169 | Laravel\Tinker\TinkerServiceProvider::class, 170 | 171 | /* 172 | * Application Service Providers... 173 | */ 174 | App\Providers\AppServiceProvider::class, 175 | App\Providers\AuthServiceProvider::class, 176 | // App\Providers\BroadcastServiceProvider::class, 177 | App\Providers\EventServiceProvider::class, 178 | App\Providers\RouteServiceProvider::class, 179 | ], 180 | 181 | /* 182 | |-------------------------------------------------------------------------- 183 | | Class Aliases 184 | |-------------------------------------------------------------------------- 185 | | 186 | | This array of class aliases will be registered when this application 187 | | is started. However, feel free to register as many as you wish as 188 | | the aliases are "lazy" loaded so they don't hinder performance. 189 | | 190 | */ 191 | 192 | 'aliases' => [ 193 | 194 | 'App' => Illuminate\Support\Facades\App::class, 195 | 'Artisan' => Illuminate\Support\Facades\Artisan::class, 196 | 'Auth' => Illuminate\Support\Facades\Auth::class, 197 | 'Blade' => Illuminate\Support\Facades\Blade::class, 198 | 'Broadcast' => Illuminate\Support\Facades\Broadcast::class, 199 | 'Bus' => Illuminate\Support\Facades\Bus::class, 200 | 'Cache' => Illuminate\Support\Facades\Cache::class, 201 | 'Config' => Illuminate\Support\Facades\Config::class, 202 | 'Cookie' => Illuminate\Support\Facades\Cookie::class, 203 | 'Crypt' => Illuminate\Support\Facades\Crypt::class, 204 | 'DB' => Illuminate\Support\Facades\DB::class, 205 | 'Eloquent' => Illuminate\Database\Eloquent\Model::class, 206 | 'Event' => Illuminate\Support\Facades\Event::class, 207 | 'File' => Illuminate\Support\Facades\File::class, 208 | 'Gate' => Illuminate\Support\Facades\Gate::class, 209 | 'Hash' => Illuminate\Support\Facades\Hash::class, 210 | 'Lang' => Illuminate\Support\Facades\Lang::class, 211 | 'Log' => Illuminate\Support\Facades\Log::class, 212 | 'Mail' => Illuminate\Support\Facades\Mail::class, 213 | 'Notification' => Illuminate\Support\Facades\Notification::class, 214 | 'Password' => Illuminate\Support\Facades\Password::class, 215 | 'Queue' => Illuminate\Support\Facades\Queue::class, 216 | 'Redirect' => Illuminate\Support\Facades\Redirect::class, 217 | 'Redis' => Illuminate\Support\Facades\Redis::class, 218 | 'Request' => Illuminate\Support\Facades\Request::class, 219 | 'Response' => Illuminate\Support\Facades\Response::class, 220 | 'Route' => Illuminate\Support\Facades\Route::class, 221 | 'Schema' => Illuminate\Support\Facades\Schema::class, 222 | 'Session' => Illuminate\Support\Facades\Session::class, 223 | 'Storage' => Illuminate\Support\Facades\Storage::class, 224 | 'URL' => Illuminate\Support\Facades\URL::class, 225 | 'Validator' => Illuminate\Support\Facades\Validator::class, 226 | 'View' => Illuminate\Support\Facades\View::class, 227 | ], 228 | 229 | ]; 230 | -------------------------------------------------------------------------------- /config/auth.php: -------------------------------------------------------------------------------- 1 | [ 17 | 'guard' => 'admin', 18 | 'passwords' => 'admins', 19 | ], 20 | 21 | /* 22 | |-------------------------------------------------------------------------- 23 | | Authentication Guards 24 | |-------------------------------------------------------------------------- 25 | | 26 | | Next, you may define every authentication guard for your application. 27 | | Of course, a great default configuration has been defined for you 28 | | here which uses session storage and the Eloquent user provider. 29 | | 30 | | All authentication drivers have a user provider. This defines how the 31 | | users are actually retrieved out of your database or other storage 32 | | mechanisms used by this application to persist your user's data. 33 | | 34 | | Supported: "session", "token" 35 | | 36 | */ 37 | 38 | 'guards' => [ 39 | 'admin' => [ 40 | 'driver' => 'session', 41 | 'provider' => 'admins', 42 | ], 43 | 44 | 'api' => [ 45 | 'driver' => 'token', 46 | 'provider' => 'users', 47 | ], 48 | ], 49 | 50 | /* 51 | |-------------------------------------------------------------------------- 52 | | User Providers 53 | |-------------------------------------------------------------------------- 54 | | 55 | | All authentication drivers have a user provider. This defines how the 56 | | users are actually retrieved out of your database or other storage 57 | | mechanisms used by this application to persist your user's data. 58 | | 59 | | If you have multiple user tables or models you may configure multiple 60 | | sources which represent each model / table. These sources may then 61 | | be assigned to any extra authentication guards you have defined. 62 | | 63 | | Supported: "database", "eloquent" 64 | | 65 | */ 66 | 67 | 'providers' => [ 68 | 'admins' => [ 69 | 'driver' => 'eloquent', 70 | 'model' => App\Models\Admin\Admin::class, 71 | ], 72 | 73 | // 'users' => [ 74 | // 'driver' => 'database', 75 | // 'table' => 'users', 76 | // ], 77 | ], 78 | 79 | /* 80 | |-------------------------------------------------------------------------- 81 | | Resetting Passwords 82 | |-------------------------------------------------------------------------- 83 | | 84 | | You may specify multiple password reset configurations if you have more 85 | | than one user table or model in the application and you want to have 86 | | separate password reset settings based on the specific user types. 87 | | 88 | | The expire time is the number of minutes that the reset token should be 89 | | considered valid. This security feature keeps tokens short-lived so 90 | | they have less time to be guessed. You may change this as needed. 91 | | 92 | */ 93 | 94 | 'passwords' => [ 95 | 'users' => [ 96 | 'provider' => 'users', 97 | 'table' => 'password_resets', 98 | 'expire' => 60, 99 | ], 100 | ], 101 | 102 | ]; 103 | -------------------------------------------------------------------------------- /config/broadcasting.php: -------------------------------------------------------------------------------- 1 | env('BROADCAST_DRIVER', 'null'), 19 | 20 | /* 21 | |-------------------------------------------------------------------------- 22 | | Broadcast Connections 23 | |-------------------------------------------------------------------------- 24 | | 25 | | Here you may define all of the broadcast connections that will be used 26 | | to broadcast events to other systems or over websockets. Samples of 27 | | each available type of connection are provided inside this array. 28 | | 29 | */ 30 | 31 | 'connections' => [ 32 | 33 | 'pusher' => [ 34 | 'driver' => 'pusher', 35 | 'key' => env('PUSHER_APP_KEY'), 36 | 'secret' => env('PUSHER_APP_SECRET'), 37 | 'app_id' => env('PUSHER_APP_ID'), 38 | 'options' => [ 39 | // 40 | ], 41 | ], 42 | 43 | 'redis' => [ 44 | 'driver' => 'redis', 45 | 'connection' => 'default', 46 | ], 47 | 48 | 'log' => [ 49 | 'driver' => 'log', 50 | ], 51 | 52 | 'null' => [ 53 | 'driver' => 'null', 54 | ], 55 | 56 | ], 57 | 58 | ]; 59 | -------------------------------------------------------------------------------- /config/cache.php: -------------------------------------------------------------------------------- 1 | env('CACHE_DRIVER', 'file'), 19 | 20 | /* 21 | |-------------------------------------------------------------------------- 22 | | Cache Stores 23 | |-------------------------------------------------------------------------- 24 | | 25 | | Here you may define all of the cache "stores" for your application as 26 | | well as their drivers. You may even define multiple stores for the 27 | | same cache driver to group types of items stored in your caches. 28 | | 29 | */ 30 | 31 | 'stores' => [ 32 | 33 | 'apc' => [ 34 | 'driver' => 'apc', 35 | ], 36 | 37 | 'array' => [ 38 | 'driver' => 'array', 39 | ], 40 | 41 | 'database' => [ 42 | 'driver' => 'database', 43 | 'table' => 'cache', 44 | 'connection' => null, 45 | ], 46 | 47 | 'file' => [ 48 | 'driver' => 'file', 49 | 'path' => storage_path('framework/cache/data'), 50 | ], 51 | 52 | 'memcached' => [ 53 | 'driver' => 'memcached', 54 | 'persistent_id' => env('MEMCACHED_PERSISTENT_ID'), 55 | 'sasl' => [ 56 | env('MEMCACHED_USERNAME'), 57 | env('MEMCACHED_PASSWORD'), 58 | ], 59 | 'options' => [ 60 | // Memcached::OPT_CONNECT_TIMEOUT => 2000, 61 | ], 62 | 'servers' => [ 63 | [ 64 | 'host' => env('MEMCACHED_HOST', '127.0.0.1'), 65 | 'port' => env('MEMCACHED_PORT', 11211), 66 | 'weight' => 100, 67 | ], 68 | ], 69 | ], 70 | 71 | 'redis' => [ 72 | 'driver' => 'redis', 73 | 'connection' => 'default', 74 | ], 75 | 76 | ], 77 | 78 | /* 79 | |-------------------------------------------------------------------------- 80 | | Cache Key Prefix 81 | |-------------------------------------------------------------------------- 82 | | 83 | | When utilizing a RAM based store such as APC or Memcached, there might 84 | | be other applications utilizing the same cache. So, we'll specify a 85 | | value to get prefixed to all our keys so we can avoid collisions. 86 | | 87 | */ 88 | 89 | 'prefix' => 'laravel', 90 | 91 | ]; 92 | -------------------------------------------------------------------------------- /config/database.php: -------------------------------------------------------------------------------- 1 | env('DB_CONNECTION', 'mysql'), 17 | 18 | /* 19 | |-------------------------------------------------------------------------- 20 | | Database Connections 21 | |-------------------------------------------------------------------------- 22 | | 23 | | Here are each of the database connections setup for your application. 24 | | Of course, examples of configuring each database platform that is 25 | | supported by Laravel is shown below to make development simple. 26 | | 27 | | 28 | | All database work in Laravel is done through the PHP PDO facilities 29 | | so make sure you have the driver for your particular database of 30 | | choice installed on your machine before you begin development. 31 | | 32 | */ 33 | 34 | 'connections' => [ 35 | 36 | 'sqlite' => [ 37 | 'driver' => 'sqlite', 38 | 'database' => env('DB_DATABASE', database_path('database.sqlite')), 39 | 'prefix' => '', 40 | ], 41 | 42 | 'mysql' => [ 43 | 'driver' => 'mysql', 44 | 'host' => env('DB_HOST', '127.0.0.1'), 45 | 'port' => env('DB_PORT', '3306'), 46 | 'database' => env('DB_DATABASE', 'forge'), 47 | 'username' => env('DB_USERNAME', 'forge'), 48 | 'password' => env('DB_PASSWORD', ''), 49 | 'charset' => 'utf8mb4', 50 | 'collation' => 'utf8mb4_unicode_ci', 51 | 'prefix' => '', 52 | 'strict' => true, 53 | 'engine' => null, 54 | ], 55 | 56 | 'pgsql' => [ 57 | 'driver' => 'pgsql', 58 | 'host' => env('DB_HOST', '127.0.0.1'), 59 | 'port' => env('DB_PORT', '5432'), 60 | 'database' => env('DB_DATABASE', 'forge'), 61 | 'username' => env('DB_USERNAME', 'forge'), 62 | 'password' => env('DB_PASSWORD', ''), 63 | 'charset' => 'utf8', 64 | 'prefix' => '', 65 | 'schema' => 'public', 66 | 'sslmode' => 'prefer', 67 | ], 68 | 69 | ], 70 | 71 | /* 72 | |-------------------------------------------------------------------------- 73 | | Migration Repository Table 74 | |-------------------------------------------------------------------------- 75 | | 76 | | This table keeps track of all the migrations that have already run for 77 | | your application. Using this information, we can determine which of 78 | | the migrations on disk haven't actually been run in the database. 79 | | 80 | */ 81 | 82 | 'migrations' => 'migrations', 83 | 84 | /* 85 | |-------------------------------------------------------------------------- 86 | | Redis Databases 87 | |-------------------------------------------------------------------------- 88 | | 89 | | Redis is an open source, fast, and advanced key-value store that also 90 | | provides a richer set of commands than a typical key-value systems 91 | | such as APC or Memcached. Laravel makes it easy to dig right in. 92 | | 93 | */ 94 | 95 | 'redis' => [ 96 | 97 | 'client' => 'predis', 98 | 99 | 'default' => [ 100 | 'host' => env('REDIS_HOST', '127.0.0.1'), 101 | 'password' => env('REDIS_PASSWORD', null), 102 | 'port' => env('REDIS_PORT', 6379), 103 | 'database' => 0, 104 | ], 105 | 106 | ], 107 | 108 | ]; 109 | -------------------------------------------------------------------------------- /config/errorCode.php: -------------------------------------------------------------------------------- 1 | [ 4 | 'msg' => '系统内部错误' 5 | ], 6 | 'LOGIN_FAIL' => [ 7 | 'code' => 4010, 8 | 'msg' => '登录失败,用户名或密码错误' 9 | ] 10 | ]; -------------------------------------------------------------------------------- /config/filesystems.php: -------------------------------------------------------------------------------- 1 | 'local', 17 | 18 | /* 19 | |-------------------------------------------------------------------------- 20 | | Default Cloud Filesystem Disk 21 | |-------------------------------------------------------------------------- 22 | | 23 | | Many applications store files both locally and in the cloud. For this 24 | | reason, you may specify a default "cloud" driver here. This driver 25 | | will be bound as the Cloud disk implementation in the container. 26 | | 27 | */ 28 | 29 | 'cloud' => 's3', 30 | 31 | /* 32 | |-------------------------------------------------------------------------- 33 | | Filesystem Disks 34 | |-------------------------------------------------------------------------- 35 | | 36 | | Here you may configure as many filesystem "disks" as you wish, and you 37 | | may even configure multiple disks of the same driver. Defaults have 38 | | been setup for each driver as an example of the required options. 39 | | 40 | | Supported Drivers: "local", "ftp", "s3", "rackspace" 41 | | 42 | */ 43 | 44 | 'disks' => [ 45 | 46 | 'local' => [ 47 | 'driver' => 'local', 48 | 'root' => storage_path('app'), 49 | ], 50 | 51 | 'public' => [ 52 | 'driver' => 'local', 53 | 'root' => storage_path('app/public'), 54 | 'url' => env('APP_URL').'/storage', 55 | 'visibility' => 'public', 56 | ], 57 | 58 | 'upload' => [ 59 | 'driver' => 'local', 60 | 'root' => base_path('public'), 61 | 'url' => env('APP_URL') 62 | ], 63 | 64 | 's3' => [ 65 | 'driver' => 's3', 66 | 'key' => env('AWS_KEY'), 67 | 'secret' => env('AWS_SECRET'), 68 | 'region' => env('AWS_REGION'), 69 | 'bucket' => env('AWS_BUCKET'), 70 | ], 71 | 72 | ], 73 | 74 | ]; 75 | -------------------------------------------------------------------------------- /config/jwt.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * For the full copyright and license information, please view the LICENSE 9 | * file that was distributed with this source code. 10 | */ 11 | 12 | return [ 13 | 14 | /* 15 | |-------------------------------------------------------------------------- 16 | | JWT Authentication Secret 17 | |-------------------------------------------------------------------------- 18 | | 19 | | Don't forget to set this, as it will be used to sign your tokens. 20 | | A helper command is provided for this: `php artisan jwt:generate` 21 | | 22 | */ 23 | 24 | 'secret' => env('JWT_SECRET', 'm2t2m6FAwjo8YvLmUS2Mm3jxwoo0FUCR'), 25 | 26 | /* 27 | |-------------------------------------------------------------------------- 28 | | JWT time to live 29 | |-------------------------------------------------------------------------- 30 | | 31 | | Specify the length of time (in minutes) that the token will be valid for. 32 | | Defaults to 1 hour 33 | | 34 | */ 35 | 36 | 'ttl' => 60, 37 | 38 | /* 39 | |-------------------------------------------------------------------------- 40 | | Refresh time to live 41 | |-------------------------------------------------------------------------- 42 | | 43 | | Specify the length of time (in minutes) that the token can be refreshed 44 | | within. I.E. The user can refresh their token within a 2 week window of 45 | | the original token being created until they must re-authenticate. 46 | | Defaults to 2 weeks 47 | | 48 | */ 49 | 50 | 'refresh_ttl' => 20160, 51 | 52 | /* 53 | |-------------------------------------------------------------------------- 54 | | JWT hashing algorithm 55 | |-------------------------------------------------------------------------- 56 | | 57 | | Specify the hashing algorithm that will be used to sign the token. 58 | | 59 | | See here: https://github.com/namshi/jose/tree/2.2.0/src/Namshi/JOSE/Signer 60 | | for possible values 61 | | 62 | */ 63 | 64 | 'algo' => 'HS256', 65 | 66 | /* 67 | |-------------------------------------------------------------------------- 68 | | User Model namespace 69 | |-------------------------------------------------------------------------- 70 | | 71 | | Specify the full namespace to your User model. 72 | | e.g. 'Acme\Entities\User' 73 | | 74 | */ 75 | 76 | 'user' => 'App\User', 77 | 78 | /* 79 | |-------------------------------------------------------------------------- 80 | | User identifier 81 | |-------------------------------------------------------------------------- 82 | | 83 | | Specify a unique property of the user that will be added as the 'sub' 84 | | claim of the token payload. 85 | | 86 | */ 87 | 88 | 'identifier' => 'id', 89 | 90 | /* 91 | |-------------------------------------------------------------------------- 92 | | Required Claims 93 | |-------------------------------------------------------------------------- 94 | | 95 | | Specify the required claims that must exist in any token. 96 | | A TokenInvalidException will be thrown if any of these claims are not 97 | | present in the payload. 98 | | 99 | */ 100 | 101 | 'required_claims' => ['iss', 'iat', 'exp', 'nbf', 'sub', 'jti'], 102 | 103 | /* 104 | |-------------------------------------------------------------------------- 105 | | Blacklist Enabled 106 | |-------------------------------------------------------------------------- 107 | | 108 | | In order to invalidate tokens, you must have the blacklist enabled. 109 | | If you do not want or need this functionality, then set this to false. 110 | | 111 | */ 112 | 113 | 'blacklist_enabled' => env('JWT_BLACKLIST_ENABLED', true), 114 | 115 | /* 116 | |-------------------------------------------------------------------------- 117 | | Providers 118 | |-------------------------------------------------------------------------- 119 | | 120 | | Specify the various providers used throughout the package. 121 | | 122 | */ 123 | 124 | 'providers' => [ 125 | 126 | /* 127 | |-------------------------------------------------------------------------- 128 | | User Provider 129 | |-------------------------------------------------------------------------- 130 | | 131 | | Specify the provider that is used to find the user based 132 | | on the subject claim 133 | | 134 | */ 135 | 136 | 'user' => 'Tymon\JWTAuth\Providers\User\EloquentUserAdapter', 137 | 138 | /* 139 | |-------------------------------------------------------------------------- 140 | | JWT Provider 141 | |-------------------------------------------------------------------------- 142 | | 143 | | Specify the provider that is used to create and decode the tokens. 144 | | 145 | */ 146 | 147 | 'jwt' => 'Tymon\JWTAuth\Providers\JWT\NamshiAdapter', 148 | 149 | /* 150 | |-------------------------------------------------------------------------- 151 | | Authentication Provider 152 | |-------------------------------------------------------------------------- 153 | | 154 | | Specify the provider that is used to authenticate users. 155 | | 156 | */ 157 | 158 | 'auth' => 'Tymon\JWTAuth\Providers\Auth\IlluminateAuthAdapter', 159 | 160 | /* 161 | |-------------------------------------------------------------------------- 162 | | Storage Provider 163 | |-------------------------------------------------------------------------- 164 | | 165 | | Specify the provider that is used to store tokens in the blacklist 166 | | 167 | */ 168 | 169 | 'storage' => 'Tymon\JWTAuth\Providers\Storage\IlluminateCacheAdapter', 170 | 171 | ], 172 | 173 | ]; 174 | -------------------------------------------------------------------------------- /config/mail.php: -------------------------------------------------------------------------------- 1 | env('MAIL_DRIVER', 'smtp'), 20 | 21 | /* 22 | |-------------------------------------------------------------------------- 23 | | SMTP Host Address 24 | |-------------------------------------------------------------------------- 25 | | 26 | | Here you may provide the host address of the SMTP server used by your 27 | | applications. A default option is provided that is compatible with 28 | | the Mailgun mail service which will provide reliable deliveries. 29 | | 30 | */ 31 | 32 | 'host' => env('MAIL_HOST', 'smtp.mailgun.org'), 33 | 34 | /* 35 | |-------------------------------------------------------------------------- 36 | | SMTP Host Port 37 | |-------------------------------------------------------------------------- 38 | | 39 | | This is the SMTP port used by your application to deliver e-mails to 40 | | users of the application. Like the host we have set this value to 41 | | stay compatible with the Mailgun e-mail application by default. 42 | | 43 | */ 44 | 45 | 'port' => env('MAIL_PORT', 587), 46 | 47 | /* 48 | |-------------------------------------------------------------------------- 49 | | Global "From" Address 50 | |-------------------------------------------------------------------------- 51 | | 52 | | You may wish for all e-mails sent by your application to be sent from 53 | | the same address. Here, you may specify a name and address that is 54 | | used globally for all e-mails that are sent by your application. 55 | | 56 | */ 57 | 58 | 'from' => [ 59 | 'address' => env('MAIL_FROM_ADDRESS', 'hello@example.com'), 60 | 'name' => env('MAIL_FROM_NAME', 'Example'), 61 | ], 62 | 63 | /* 64 | |-------------------------------------------------------------------------- 65 | | E-Mail Encryption Protocol 66 | |-------------------------------------------------------------------------- 67 | | 68 | | Here you may specify the encryption protocol that should be used when 69 | | the application send e-mail messages. A sensible default using the 70 | | transport layer security protocol should provide great security. 71 | | 72 | */ 73 | 74 | 'encryption' => env('MAIL_ENCRYPTION', 'tls'), 75 | 76 | /* 77 | |-------------------------------------------------------------------------- 78 | | SMTP Server Username 79 | |-------------------------------------------------------------------------- 80 | | 81 | | If your SMTP server requires a username for authentication, you should 82 | | set it here. This will get used to authenticate with your server on 83 | | connection. You may also set the "password" value below this one. 84 | | 85 | */ 86 | 87 | 'username' => env('MAIL_USERNAME'), 88 | 89 | 'password' => env('MAIL_PASSWORD'), 90 | 91 | /* 92 | |-------------------------------------------------------------------------- 93 | | Sendmail System Path 94 | |-------------------------------------------------------------------------- 95 | | 96 | | When using the "sendmail" driver to send e-mails, we will need to know 97 | | the path to where Sendmail lives on this server. A default path has 98 | | been provided here, which will work well on most of your systems. 99 | | 100 | */ 101 | 102 | 'sendmail' => '/usr/sbin/sendmail -bs', 103 | 104 | /* 105 | |-------------------------------------------------------------------------- 106 | | Markdown Mail Settings 107 | |-------------------------------------------------------------------------- 108 | | 109 | | If you are using Markdown based email rendering, you may configure your 110 | | theme and component paths here, allowing you to customize the design 111 | | of the emails. Or, you may simply stick with the Laravel defaults! 112 | | 113 | */ 114 | 115 | 'markdown' => [ 116 | 'theme' => 'default', 117 | 118 | 'paths' => [ 119 | resource_path('views/vendor/mail'), 120 | ], 121 | ], 122 | 123 | ]; 124 | -------------------------------------------------------------------------------- /config/queue.php: -------------------------------------------------------------------------------- 1 | env('QUEUE_DRIVER', 'sync'), 19 | 20 | /* 21 | |-------------------------------------------------------------------------- 22 | | Queue Connections 23 | |-------------------------------------------------------------------------- 24 | | 25 | | Here you may configure the connection information for each server that 26 | | is used by your application. A default configuration has been added 27 | | for each back-end shipped with Laravel. You are free to add more. 28 | | 29 | */ 30 | 31 | 'connections' => [ 32 | 33 | 'sync' => [ 34 | 'driver' => 'sync', 35 | ], 36 | 37 | 'database' => [ 38 | 'connection' => 'mysql', 39 | 'driver' => 'database', 40 | 'table' => 'jobs', 41 | 'queue' => 'default', 42 | 'retry_after' => 90, 43 | ], 44 | 45 | 'beanstalkd' => [ 46 | 'driver' => 'beanstalkd', 47 | 'host' => 'localhost', 48 | 'queue' => 'default', 49 | 'retry_after' => 90, 50 | ], 51 | 52 | 'sqs' => [ 53 | 'driver' => 'sqs', 54 | 'key' => 'your-public-key', 55 | 'secret' => 'your-secret-key', 56 | 'prefix' => 'https://sqs.us-east-1.amazonaws.com/your-account-id', 57 | 'queue' => 'your-queue-name', 58 | 'region' => 'us-east-1', 59 | ], 60 | 61 | 'redis' => [ 62 | 'driver' => 'redis', 63 | 'connection' => 'default', 64 | 'queue' => 'default', 65 | 'retry_after' => 90, 66 | ], 67 | 68 | ], 69 | 70 | /* 71 | |-------------------------------------------------------------------------- 72 | | Failed Queue Jobs 73 | |-------------------------------------------------------------------------- 74 | | 75 | | These options configure the behavior of failed queue job logging so you 76 | | can control which database and table are used to store the jobs that 77 | | have failed. You may change them to any database / table you wish. 78 | | 79 | */ 80 | 81 | 'failed' => [ 82 | 'database' => env('DB_CONNECTION', 'mysql'), 83 | 'table' => 'failed_jobs', 84 | ], 85 | 86 | ]; 87 | -------------------------------------------------------------------------------- /config/services.php: -------------------------------------------------------------------------------- 1 | [ 18 | 'domain' => env('MAILGUN_DOMAIN'), 19 | 'secret' => env('MAILGUN_SECRET'), 20 | ], 21 | 22 | 'ses' => [ 23 | 'key' => env('SES_KEY'), 24 | 'secret' => env('SES_SECRET'), 25 | 'region' => 'us-east-1', 26 | ], 27 | 28 | 'sparkpost' => [ 29 | 'secret' => env('SPARKPOST_SECRET'), 30 | ], 31 | 32 | 'stripe' => [ 33 | 'model' => App\User::class, 34 | 'key' => env('STRIPE_KEY'), 35 | 'secret' => env('STRIPE_SECRET'), 36 | ], 37 | 38 | ]; 39 | -------------------------------------------------------------------------------- /config/session.php: -------------------------------------------------------------------------------- 1 | env('SESSION_DRIVER', 'file'), 20 | 21 | /* 22 | |-------------------------------------------------------------------------- 23 | | Session Lifetime 24 | |-------------------------------------------------------------------------- 25 | | 26 | | Here you may specify the number of minutes that you wish the session 27 | | to be allowed to remain idle before it expires. If you want them 28 | | to immediately expire on the browser closing, set that option. 29 | | 30 | */ 31 | 32 | 'lifetime' => 120, 33 | 34 | 'expire_on_close' => false, 35 | 36 | /* 37 | |-------------------------------------------------------------------------- 38 | | Session Encryption 39 | |-------------------------------------------------------------------------- 40 | | 41 | | This option allows you to easily specify that all of your session data 42 | | should be encrypted before it is stored. All encryption will be run 43 | | automatically by Laravel and you can use the Session like normal. 44 | | 45 | */ 46 | 47 | 'encrypt' => false, 48 | 49 | /* 50 | |-------------------------------------------------------------------------- 51 | | Session File Location 52 | |-------------------------------------------------------------------------- 53 | | 54 | | When using the native session driver, we need a location where session 55 | | files may be stored. A default has been set for you but a different 56 | | location may be specified. This is only needed for file sessions. 57 | | 58 | */ 59 | 60 | 'files' => storage_path('framework/sessions'), 61 | 62 | /* 63 | |-------------------------------------------------------------------------- 64 | | Session Database Connection 65 | |-------------------------------------------------------------------------- 66 | | 67 | | When using the "database" or "redis" session drivers, you may specify a 68 | | connection that should be used to manage these sessions. This should 69 | | correspond to a connection in your database configuration options. 70 | | 71 | */ 72 | 73 | 'connection' => null, 74 | 75 | /* 76 | |-------------------------------------------------------------------------- 77 | | Session Database Table 78 | |-------------------------------------------------------------------------- 79 | | 80 | | When using the "database" session driver, you may specify the table we 81 | | should use to manage the sessions. Of course, a sensible default is 82 | | provided for you; however, you are free to change this as needed. 83 | | 84 | */ 85 | 86 | 'table' => 'sessions', 87 | 88 | /* 89 | |-------------------------------------------------------------------------- 90 | | Session Cache Store 91 | |-------------------------------------------------------------------------- 92 | | 93 | | When using the "apc" or "memcached" session drivers, you may specify a 94 | | cache store that should be used for these sessions. This value must 95 | | correspond with one of the application's configured cache stores. 96 | | 97 | */ 98 | 99 | 'store' => null, 100 | 101 | /* 102 | |-------------------------------------------------------------------------- 103 | | Session Sweeping Lottery 104 | |-------------------------------------------------------------------------- 105 | | 106 | | Some session drivers must manually sweep their storage location to get 107 | | rid of old sessions from storage. Here are the chances that it will 108 | | happen on a given request. By default, the odds are 2 out of 100. 109 | | 110 | */ 111 | 112 | 'lottery' => [2, 100], 113 | 114 | /* 115 | |-------------------------------------------------------------------------- 116 | | Session Cookie Name 117 | |-------------------------------------------------------------------------- 118 | | 119 | | Here you may change the name of the cookie used to identify a session 120 | | instance by ID. The name specified here will get used every time a 121 | | new session cookie is created by the framework for every driver. 122 | | 123 | */ 124 | 125 | 'cookie' => '_session', 126 | 127 | /* 128 | |-------------------------------------------------------------------------- 129 | | Session Cookie Path 130 | |-------------------------------------------------------------------------- 131 | | 132 | | The session cookie path determines the path for which the cookie will 133 | | be regarded as available. Typically, this will be the root path of 134 | | your application but you are free to change this when necessary. 135 | | 136 | */ 137 | 138 | 'path' => '/', 139 | 140 | /* 141 | |-------------------------------------------------------------------------- 142 | | Session Cookie Domain 143 | |-------------------------------------------------------------------------- 144 | | 145 | | Here you may change the domain of the cookie used to identify a session 146 | | in your application. This will determine which domains the cookie is 147 | | available to in your application. A sensible default has been set. 148 | | 149 | */ 150 | 151 | 'domain' => env('SESSION_DOMAIN', null), 152 | 153 | /* 154 | |-------------------------------------------------------------------------- 155 | | HTTPS Only Cookies 156 | |-------------------------------------------------------------------------- 157 | | 158 | | By setting this option to true, session cookies will only be sent back 159 | | to the server if the browser has a HTTPS connection. This will keep 160 | | the cookie from being sent to you if it can not be done securely. 161 | | 162 | */ 163 | 164 | 'secure' => env('SESSION_SECURE_COOKIE', false), 165 | 166 | /* 167 | |-------------------------------------------------------------------------- 168 | | HTTP Access Only 169 | |-------------------------------------------------------------------------- 170 | | 171 | | Setting this value to true will prevent JavaScript from accessing the 172 | | value of the cookie and the cookie will only be accessible through 173 | | the HTTP protocol. You are free to modify this option if needed. 174 | | 175 | */ 176 | 177 | 'http_only' => true, 178 | 179 | ]; 180 | -------------------------------------------------------------------------------- /config/view.php: -------------------------------------------------------------------------------- 1 | [ 17 | realpath(base_path('resources/views')), 18 | ], 19 | 20 | /* 21 | |-------------------------------------------------------------------------- 22 | | Compiled View Path 23 | |-------------------------------------------------------------------------- 24 | | 25 | | This option determines where all the compiled Blade templates will be 26 | | stored for your application. Typically, this is within the storage 27 | | directory. However, as usual, you are free to change this value. 28 | | 29 | */ 30 | 31 | 'compiled' => realpath(storage_path('framework/views')), 32 | 33 | ]; 34 | -------------------------------------------------------------------------------- /database/.gitignore: -------------------------------------------------------------------------------- 1 | *.sqlite 2 | -------------------------------------------------------------------------------- /database/factories/ModelFactory.php: -------------------------------------------------------------------------------- 1 | define(App\User::class, function (Faker\Generator $faker) { 16 | static $password; 17 | 18 | return [ 19 | 'name' => $faker->name, 20 | 'email' => $faker->unique()->safeEmail, 21 | 'password' => $password ?: $password = bcrypt('secret'), 22 | 'remember_token' => str_random(10), 23 | ]; 24 | }); 25 | -------------------------------------------------------------------------------- /database/factories/PostsFactory.php: -------------------------------------------------------------------------------- 1 | define(App\Models\Post::class, function (Faker\Generator $faker) { 4 | return [ 5 | 'title' => $faker->text(30), 6 | 'desc' => $faker->text(), 7 | 'content' => $faker->text(1000), 8 | 'click_num' => $faker->numberBetween(), 9 | 'is_show' => random_int(0, 1) 10 | ]; 11 | }); 12 | -------------------------------------------------------------------------------- /database/migrations/2016_10_13_172709_create_admins.php: -------------------------------------------------------------------------------- 1 | increments('id'); 17 | $table->string('name', 60); 18 | $table->string('username', 30)->unique(); 19 | $table->string('password', 60); 20 | $table->tinyInteger('is_super')->default(0)->comment('是否超级管理员'); 21 | $table->rememberToken(); 22 | $table->timestamp('created_at')->default(DB::raw('CURRENT_TIMESTAMP')); 23 | $table->timestamp('updated_at')->default(DB::raw('CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP')); 24 | }); 25 | } 26 | 27 | /** 28 | * Reverse the migrations. 29 | * 30 | * @return void 31 | */ 32 | public function down() 33 | { 34 | Schema::drop('admins'); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /database/migrations/2016_10_13_172801_create_roles.php: -------------------------------------------------------------------------------- 1 | increments('id'); 17 | $table->string('name')->unique(); 18 | $table->string('display_name')->nullable(); 19 | $table->string('description')->nullable(); 20 | $table->timestamp('created_at')->default(DB::raw('CURRENT_TIMESTAMP')); 21 | $table->timestamp('updated_at')->default(DB::raw('CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP')); 22 | }); 23 | } 24 | 25 | /** 26 | * Reverse the migrations. 27 | * 28 | * @return void 29 | */ 30 | public function down() 31 | { 32 | Schema::drop('roles'); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /database/migrations/2016_10_13_172824_create_menus.php: -------------------------------------------------------------------------------- 1 | increments('id'); 17 | $table->unsignedInteger('fid')->comment('菜单父ID'); 18 | $table->string('icon')->nullable()->comment('图标class'); 19 | $table->string('name')->unique(); 20 | $table->string('display_name')->nullable(); 21 | $table->string('description')->nullable(); 22 | $table->unsignedTinyInteger('is_menu')->comment('是否作为菜单显示,[1|0]'); 23 | $table->unsignedTinyInteger('sort')->comment('排序'); 24 | $table->timestamp('created_at')->default(DB::raw('CURRENT_TIMESTAMP')); 25 | $table->timestamp('updated_at')->default(DB::raw('CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP')); 26 | 27 | $table->index('fid'); 28 | }); 29 | } 30 | 31 | /** 32 | * Reverse the migrations. 33 | * 34 | * @return void 35 | */ 36 | public function down() 37 | { 38 | Schema::drop('menus'); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /database/migrations/2016_10_13_172844_create_role_menu_relations.php: -------------------------------------------------------------------------------- 1 | unsignedInteger('menu_id'); 17 | $table->unsignedInteger('role_id'); 18 | 19 | $table->primary(['menu_id', 'role_id']); 20 | }); 21 | } 22 | 23 | /** 24 | * Reverse the migrations. 25 | * 26 | * @return void 27 | */ 28 | public function down() 29 | { 30 | Schema::drop('role_menu_relations'); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /database/migrations/2016_10_13_172903_create_admin_role_relations.php: -------------------------------------------------------------------------------- 1 | unsignedInteger('admin_id'); 17 | $table->unsignedInteger('role_id'); 18 | 19 | $table->primary(['admin_id', 'role_id']); 20 | }); 21 | } 22 | 23 | /** 24 | * Reverse the migrations. 25 | * 26 | * @return void 27 | */ 28 | public function down() 29 | { 30 | Schema::drop('admin_role_relations'); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /database/migrations/2017_02_27_080116_create_posts.php: -------------------------------------------------------------------------------- 1 | increments('id'); 18 | $table->string('title', 150); 19 | $table->string('front_cover', 100)->default(''); 20 | $table->string('desc', 1000); 21 | $table->text('content'); 22 | $table->unsignedTinyInteger('is_show')->comment('是否显示,1=是 0=否'); 23 | $table->unsignedInteger('click_num')->comment('点击数')->default(0); 24 | 25 | $table->timestamp('created_at')->default(DB::raw('CURRENT_TIMESTAMP')); 26 | $table->timestamp('updated_at')->default(DB::raw('CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP')); 27 | $table->softDeletes(); 28 | }); 29 | } 30 | 31 | /** 32 | * Reverse the migrations. 33 | * 34 | * @return void 35 | */ 36 | public function down() 37 | { 38 | Schema::dropIfExists('posts'); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /database/migrations/2017_02_27_093221_create_jobs_table.php: -------------------------------------------------------------------------------- 1 | bigIncrements('id'); 18 | $table->string('queue'); 19 | $table->longText('payload'); 20 | $table->tinyInteger('attempts')->unsigned(); 21 | $table->unsignedInteger('reserved_at')->nullable(); 22 | $table->unsignedInteger('available_at'); 23 | $table->unsignedInteger('created_at'); 24 | 25 | $table->index(['queue', 'reserved_at']); 26 | }); 27 | } 28 | 29 | /** 30 | * Reverse the migrations. 31 | * 32 | * @return void 33 | */ 34 | public function down() 35 | { 36 | Schema::dropIfExists('jobs'); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /database/migrations/2017_02_27_093510_create_failed_jobs_table.php: -------------------------------------------------------------------------------- 1 | increments('id'); 18 | $table->text('connection'); 19 | $table->text('queue'); 20 | $table->longText('payload'); 21 | $table->longText('exception'); 22 | $table->timestamp('failed_at')->useCurrent(); 23 | }); 24 | } 25 | 26 | /** 27 | * Reverse the migrations. 28 | * 29 | * @return void 30 | */ 31 | public function down() 32 | { 33 | Schema::dropIfExists('failed_jobs'); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /database/migrations/2017_03_09_021536_create_user_behaviors.php: -------------------------------------------------------------------------------- 1 | unsignedInteger('user_id'); 18 | $table->string('like_ids', 3000)->comment(); 19 | $table->string('comment_ids', 3000)->comment(); 20 | $table->string('collect_ids', 3000)->comment(); 21 | $table->string('share_ids', 3000)->comment(); 22 | 23 | $table->primary('user_id'); 24 | }); 25 | } 26 | 27 | /** 28 | * Reverse the migrations. 29 | * 30 | * @return void 31 | */ 32 | public function down() 33 | { 34 | Schema::dropIfExists('user_behaviors'); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /database/seeds/AdminsSeeder.php: -------------------------------------------------------------------------------- 1 | '管理员', 16 | 'username' => 'admin', 17 | 'password' => \Illuminate\Support\Facades\Hash::make('admin'), 18 | 'is_super' => 1 19 | ]); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /database/seeds/PostsSeeder.php: -------------------------------------------------------------------------------- 1 | create(); 16 | }); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /index.php: -------------------------------------------------------------------------------- 1 | 2 | 11 | 12 | 13 | ./tests/Feature 14 | 15 | 16 | 17 | ./tests/Unit 18 | 19 | 20 | 21 | 22 | ./app 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /public/.htaccess: -------------------------------------------------------------------------------- 1 | 2 | 3 | Options -MultiViews 4 | 5 | 6 | RewriteEngine On 7 | 8 | # Redirect Trailing Slashes If Not A Folder... 9 | RewriteCond %{REQUEST_FILENAME} !-d 10 | RewriteRule ^(.*)/$ /$1 [L,R=301] 11 | 12 | # Handle Front Controller... 13 | RewriteCond %{REQUEST_FILENAME} !-d 14 | RewriteCond %{REQUEST_FILENAME} !-f 15 | RewriteRule ^ index.php [L] 16 | 17 | # Handle Authorization Header 18 | RewriteCond %{HTTP:Authorization} . 19 | RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}] 20 | 21 | -------------------------------------------------------------------------------- /public/admin.html: -------------------------------------------------------------------------------- 1 | 后台管理系统
-------------------------------------------------------------------------------- /public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lzjcoding/laravel5.4-webpack2-Vuejs2-iview2-spa-demo/a169dbc66f7e0a8172eee6f9b60b25ee60f850bc/public/favicon.ico -------------------------------------------------------------------------------- /public/images/avatar_404.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lzjcoding/laravel5.4-webpack2-Vuejs2-iview2-spa-demo/a169dbc66f7e0a8172eee6f9b60b25ee60f850bc/public/images/avatar_404.png -------------------------------------------------------------------------------- /public/images/test1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lzjcoding/laravel5.4-webpack2-Vuejs2-iview2-spa-demo/a169dbc66f7e0a8172eee6f9b60b25ee60f850bc/public/images/test1.jpg -------------------------------------------------------------------------------- /public/index.html: -------------------------------------------------------------------------------- 1 | spa-blog
-------------------------------------------------------------------------------- /public/index.php: -------------------------------------------------------------------------------- 1 | 8 | */ 9 | 10 | /* 11 | |-------------------------------------------------------------------------- 12 | | Register The Auto Loader 13 | |-------------------------------------------------------------------------- 14 | | 15 | | Composer provides a convenient, automatically generated class loader for 16 | | our application. We just need to utilize it! We'll simply require it 17 | | into the script here so that we don't have to worry about manual 18 | | loading any of our classes later on. It feels nice to relax. 19 | | 20 | */ 21 | 22 | require __DIR__.'/../bootstrap/autoload.php'; 23 | 24 | /* 25 | |-------------------------------------------------------------------------- 26 | | Turn On The Lights 27 | |-------------------------------------------------------------------------- 28 | | 29 | | We need to illuminate PHP development, so let us turn on the lights. 30 | | This bootstraps the framework and gets it ready for use, then it 31 | | will load up this application so that we can run it and send 32 | | the responses back to the browser and delight our users. 33 | | 34 | */ 35 | 36 | $app = require_once __DIR__.'/../bootstrap/app.php'; 37 | 38 | /* 39 | |-------------------------------------------------------------------------- 40 | | Run The Application 41 | |-------------------------------------------------------------------------- 42 | | 43 | | Once we have the application, we can handle the incoming request 44 | | through the kernel, and send the associated response back to 45 | | the client's browser allowing them to enjoy the creative 46 | | and wonderful application we have prepared for them. 47 | | 48 | */ 49 | 50 | $kernel = $app->make(Illuminate\Contracts\Http\Kernel::class); 51 | 52 | $response = $kernel->handle( 53 | $request = Illuminate\Http\Request::capture() 54 | ); 55 | 56 | $response->send(); 57 | 58 | $kernel->terminate($request, $response); 59 | -------------------------------------------------------------------------------- /public/login.html: -------------------------------------------------------------------------------- 1 | 登录后台管理系统
-------------------------------------------------------------------------------- /public/robots.txt: -------------------------------------------------------------------------------- 1 | User-agent: * 2 | Disallow: 3 | -------------------------------------------------------------------------------- /public/static/img/icomoon.0a74426.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lzjcoding/laravel5.4-webpack2-Vuejs2-iview2-spa-demo/a169dbc66f7e0a8172eee6f9b60b25ee60f850bc/public/static/img/icomoon.0a74426.eot -------------------------------------------------------------------------------- /public/static/img/icomoon.7d4ac7d.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lzjcoding/laravel5.4-webpack2-Vuejs2-iview2-spa-demo/a169dbc66f7e0a8172eee6f9b60b25ee60f850bc/public/static/img/icomoon.7d4ac7d.woff -------------------------------------------------------------------------------- /public/static/img/icomoon.9f5fd7b.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lzjcoding/laravel5.4-webpack2-Vuejs2-iview2-spa-demo/a169dbc66f7e0a8172eee6f9b60b25ee60f850bc/public/static/img/icomoon.9f5fd7b.ttf -------------------------------------------------------------------------------- /public/static/img/ionicons.05acfdb.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lzjcoding/laravel5.4-webpack2-Vuejs2-iview2-spa-demo/a169dbc66f7e0a8172eee6f9b60b25ee60f850bc/public/static/img/ionicons.05acfdb.woff -------------------------------------------------------------------------------- /public/static/img/ionicons.24712f6.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lzjcoding/laravel5.4-webpack2-Vuejs2-iview2-spa-demo/a169dbc66f7e0a8172eee6f9b60b25ee60f850bc/public/static/img/ionicons.24712f6.ttf -------------------------------------------------------------------------------- /public/static/img/ionicons.2c2ae06.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lzjcoding/laravel5.4-webpack2-Vuejs2-iview2-spa-demo/a169dbc66f7e0a8172eee6f9b60b25ee60f850bc/public/static/img/ionicons.2c2ae06.eot -------------------------------------------------------------------------------- /public/static/js/1.edeb8ba5a3fa0487ef46.js: -------------------------------------------------------------------------------- 1 | webpackJsonp([1],{42:function(t,e,a){a(57);var i=a(2)(a(50),a(62),"data-v-59cdb9c7",null);t.exports=i.exports},48:function(t,e,a){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.default={data:function(){return{loading:!1,tableData:[],pageTotal:0,page:1,pageSize:10,sortBy:{}}},props:{dataUrl:{type:String},columns:{type:Array,default:function(){return[]}},size:{},width:{type:[Number,String]},height:{type:[Number,String]},stripe:{type:Boolean,default:!1},border:{type:Boolean,default:!1},showHeader:{type:Boolean,default:!0},highlightRow:{type:Boolean,default:!1},rowClassName:{type:Function},content:{type:Object},noDataText:{type:String},filter:{type:Object},noFilteredDataText:{type:String}},created:function(){this.fetchData()},methods:{fetchData:function(t,e,a,i){var n=this;t=t||this.page,e=e||this.pageSize;var o=JSON.stringify(a||this.sortBy),r=JSON.stringify(i||this.filter),s=this.dataUrl+"?page="+t+"&pageSize="+e+"&sort="+o+"&filter="+r;s=encodeURI(s),this.$http.get(s).then(function(t){var e=t.body.data;n.pageTotal=e.total,n.tableData=e.data})},sort:function(t){if("normal"===t.order)this.sortBy={};else{var e=t.key;this.sortBy[e]=t.order}this.fetchData()},changePage:function(t){this.page=t,this.fetchData()},changePageSize:function(t){this.pageSize=t,this.fetchData()},btnClick:function(t,e,a){this.$parent[t](e,a)}}}},50:function(t,e,a){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var i=a(60),n=a.n(i);e.default={components:{asyncTable:n.a},data:function(){return{loading:!1,dataUrl:config.getApi(config.api.post.list),columns:[{title:"编号",key:"id",width:80,sortable:!0},{title:"标题",key:"title",width:200},{title:"点击数",key:"click_num",width:120,sortable:!0},{title:"点赞数",key:"like_num",width:120,sortable:!0},{title:"评论数",key:"comment_num",width:120,sortable:!0},{title:"收藏数",key:"collect_num",width:120,sortable:!0},{title:"分享数",key:"share_num",width:120,sortable:!0},{title:"创建时间",key:"created_at",width:150,sortable:!0},{title:"最近更新时间",key:"updated_at",width:150,sortable:!0},{title:"是否显示",key:"is_show",width:100,sortable:!0,fixed:"right",render:function(t,e,a){return 1==t.is_show?"显示":"隐藏"}},{title:"操作",key:"operations",width:170,fixed:"right",render:function(t,e,a){var i="";return i+=' 编辑 ',1==t.is_show?i+=' 隐藏':i+=' 显示 ',i+=' 删除'}}],formSearch:{id:"",title:"",created_at:"",updated_at:""},userList:{}}},created:function(){},methods:{refreshData:function(){this.$refs.asyncTable.fetchData()},handleSearch:function(t){this.refreshData()},handleReset:function(t){this.$refs[t].resetFields(),this.refreshData()},showItem:function(t){var e=this;this.$Modal.confirm({title:"确认操作",content:"你确认要显示这条记录?",onOk:function(){e.loading=!0,e.$http.post(config.getApi(config.api.post.display(t))).then(function(t){e.$Message.success("操作成功"),e.refreshData(),e.loading=!1},function(t){e.loading=!1})}})},hideItem:function(t){var e=this;this.$Modal.confirm({title:"确认操作",content:"你确认要隐藏这条记录?",onOk:function(){e.loading=!0,e.$http.post(config.getApi(config.api.post.hide(t))).then(function(t){e.$Message.success("操作成功"),e.refreshData(),e.loading=!1},function(t){e.loading=!1})}})},delItem:function(t){var e=this;this.$Modal.confirm({title:"确认操作",content:"你确认要删除这条记录?",onOk:function(){e.loading=!0,e.$http.delete(config.getApi(config.api.post.delete(t))).then(function(t){e.$Message.success("操作成功"),e.refreshData(),e.loading=!1},function(t){e.loading=!1})}})},goEdit:function(t){this.$router.push({name:"post-edit",params:{id:t}})}}}},51:function(t,e,a){e=t.exports=a(40)(),e.push([t.i,"","",{version:3,sources:[],names:[],mappings:"",file:"index.vue",sourceRoot:""}])},57:function(t,e,a){var i=a(51);"string"==typeof i&&(i=[[t.i,i,""]]),i.locals&&(t.exports=i.locals);a(41)("4c855cac",i,!0)},60:function(t,e,a){var i=a(2)(a(48),a(61),null,null);t.exports=i.exports},61:function(t,e){t.exports={render:function(){var t=this,e=t.$createElement,a=t._self._c||e;return a("div",[a("i-table",{ref:"table",attrs:{columns:t.columns,data:t.tableData,size:t.size,width:t.width,height:t.height,stripe:t.stripe,border:t.border,"show-header":t.showHeader,"highlight-row":t.highlightRow,"row-class-name":t.rowClassName,content:t.content,"no-data-text":t.noDataText,"no-filtered-data-text":t.noFilteredDataText},on:{"on-sort-change":t.sort}}),t._v(" "),a("div",{staticClass:"layout-page"},[a("Page",{attrs:{total:t.pageTotal,current:t.page,"page-size":t.pageSize,size:"small","show-elevator":"","show-sizer":"","show-total":""},on:{"on-change":t.changePage,"on-page-size-change":t.changePageSize}})],1)],1)},staticRenderFns:[]}},62:function(t,e){t.exports={render:function(){var t=this,e=t.$createElement,a=t._self._c||e;return a("div",[a("div",{staticClass:"layout-breadcrumb"},[a("Breadcrumb",[a("Breadcrumb-item",[t._v("首页")]),t._v(" "),a("Breadcrumb-item",[t._v("文章管理")])],1)],1),t._v(" "),a("div",{staticClass:"layout-btn-group"},[a("router-link",{attrs:{to:"/post/create"}},[a("i-button",{attrs:{type:"primary",size:"small"}},[t._v(" 添加文章 ")])],1)],1),t._v(" "),a("div",{staticClass:"layout-content"},[a("div",{staticClass:"layout-table"},[a("async-table",{ref:"asyncTable",attrs:{columns:t.columns,"data-url":t.dataUrl,filter:t.formSearch,size:"small"}})],1),t._v(" "),a("div",{staticClass:"layout-search"},[a("Card",{attrs:{bordered:!1,"dis-hover":""}},[a("p",{slot:"title"},[t._v(" 搜索条件 ")]),t._v(" "),a("i-form",{ref:"formSearch",attrs:{model:t.formSearch,"label-position":"top"}},[a("Form-item",{attrs:{label:"编号",prop:"id"}},[a("i-input",{model:{value:t.formSearch.id,callback:function(e){t.formSearch.id=e},expression:"formSearch.id"}})],1),t._v(" "),a("Form-item",{attrs:{label:"标题",prop:"title"}},[a("i-input",{model:{value:t.formSearch.title,callback:function(e){t.formSearch.title=e},expression:"formSearch.title"}})],1),t._v(" "),a("Form-item",{attrs:{label:"创建时间",prop:"created_at"}},[a("Date-picker",{attrs:{type:"datetimerange",placement:"left-start",format:"yyyy-MM-dd HH:mm",placeholder:"选择日期和时间"},model:{value:t.formSearch.created_at,callback:function(e){t.formSearch.created_at=e},expression:"formSearch.created_at"}})],1),t._v(" "),a("Form-item",{attrs:{label:"更新时间",prop:"updated_at"}},[a("Date-picker",{attrs:{type:"datetimerange",placement:"left-start",format:"yyyy-MM-dd HH:mm",placeholder:"选择日期和时间"},model:{value:t.formSearch.updated_at,callback:function(e){t.formSearch.updated_at=e},expression:"formSearch.updated_at"}})],1),t._v(" "),a("Form-item",{staticStyle:{"text-align":"center"}},[a("i-button",{attrs:{type:"primary"},on:{click:function(e){t.handleSearch("formSearch")}}},[t._v(" 搜索 ")]),t._v(" "),a("i-button",{staticStyle:{"margin-left":"8px"},attrs:{type:"ghost"},on:{click:function(e){t.handleReset("formSearch")}}},[t._v(" 重置 ")])],1)],1)],1)],1)])])},staticRenderFns:[]}}}); 2 | //# sourceMappingURL=1.edeb8ba5a3fa0487ef46.js.map -------------------------------------------------------------------------------- /public/web.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /resources/assets/js/app.js: -------------------------------------------------------------------------------- 1 | 2 | /** 3 | * First we will load all of this project's JavaScript dependencies which 4 | * includes Vue and other libraries. It is a great starting point when 5 | * building robust, powerful web applications using Vue and Laravel. 6 | */ 7 | 8 | require('./bootstrap'); 9 | 10 | /** 11 | * Next, we will create a fresh Vue application instance and attach it to 12 | * the page. Then, you may begin adding components to this application 13 | * or customize the JavaScript scaffolding to fit your unique needs. 14 | */ 15 | 16 | Vue.component('example', require('./components/Example.vue')); 17 | 18 | const app = new Vue({ 19 | el: '#app' 20 | }); 21 | -------------------------------------------------------------------------------- /resources/assets/js/bootstrap.js: -------------------------------------------------------------------------------- 1 | 2 | window._ = require('lodash'); 3 | 4 | /** 5 | * We'll load jQuery and the Bootstrap jQuery plugin which provides support 6 | * for JavaScript based Bootstrap features such as modals and tabs. This 7 | * code may be modified to fit the specific needs of your application. 8 | */ 9 | 10 | window.$ = window.jQuery = require('jquery'); 11 | 12 | require('bootstrap-sass'); 13 | 14 | /** 15 | * Vue is a modern JavaScript library for building interactive web interfaces 16 | * using reactive data binding and reusable components. Vue's API is clean 17 | * and simple, leaving you to focus on building your next great project. 18 | */ 19 | 20 | window.Vue = require('vue'); 21 | 22 | /** 23 | * We'll load the axios HTTP library which allows us to easily issue requests 24 | * to our Laravel back-end. This library automatically handles sending the 25 | * CSRF token as a header based on the value of the "XSRF" token cookie. 26 | */ 27 | 28 | window.axios = require('axios'); 29 | 30 | window.axios.defaults.headers.common = { 31 | 'X-CSRF-TOKEN': window.Laravel.csrfToken, 32 | 'X-Requested-With': 'XMLHttpRequest' 33 | }; 34 | 35 | /** 36 | * Echo exposes an expressive API for subscribing to channels and listening 37 | * for events that are broadcast by Laravel. Echo and event broadcasting 38 | * allows your team to easily build robust real-time web applications. 39 | */ 40 | 41 | // import Echo from "laravel-echo" 42 | 43 | // window.Echo = new Echo({ 44 | // broadcaster: 'pusher', 45 | // key: 'your-pusher-key' 46 | // }); 47 | -------------------------------------------------------------------------------- /resources/assets/js/components/Example.vue: -------------------------------------------------------------------------------- 1 | 16 | 17 | 24 | -------------------------------------------------------------------------------- /resources/assets/sass/_variables.scss: -------------------------------------------------------------------------------- 1 | 2 | // Body 3 | $body-bg: #f5f8fa; 4 | 5 | // Borders 6 | $laravel-border-color: darken($body-bg, 10%); 7 | $list-group-border: $laravel-border-color; 8 | $navbar-default-border: $laravel-border-color; 9 | $panel-default-border: $laravel-border-color; 10 | $panel-inner-border: $laravel-border-color; 11 | 12 | // Brands 13 | $brand-primary: #3097D1; 14 | $brand-info: #8eb4cb; 15 | $brand-success: #2ab27b; 16 | $brand-warning: #cbb956; 17 | $brand-danger: #bf5329; 18 | 19 | // Typography 20 | $icon-font-path: "~bootstrap-sass/assets/fonts/bootstrap/"; 21 | $font-family-sans-serif: "Raleway", sans-serif; 22 | $font-size-base: 14px; 23 | $line-height-base: 1.6; 24 | $text-color: #636b6f; 25 | 26 | // Navbar 27 | $navbar-default-bg: #fff; 28 | 29 | // Buttons 30 | $btn-default-color: $text-color; 31 | 32 | // Inputs 33 | $input-border: lighten($text-color, 40%); 34 | $input-border-focus: lighten($brand-primary, 25%); 35 | $input-color-placeholder: lighten($text-color, 30%); 36 | 37 | // Panels 38 | $panel-default-heading-bg: #fff; 39 | -------------------------------------------------------------------------------- /resources/assets/sass/app.scss: -------------------------------------------------------------------------------- 1 | 2 | // Fonts 3 | @import url(https://fonts.googleapis.com/css?family=Raleway:300,400,600); 4 | 5 | // Variables 6 | @import "variables"; 7 | 8 | // Bootstrap 9 | @import "node_modules/bootstrap-sass/assets/stylesheets/bootstrap"; 10 | -------------------------------------------------------------------------------- /resources/lang/en/auth.php: -------------------------------------------------------------------------------- 1 | 'These credentials do not match our records.', 17 | 'throttle' => 'Too many login attempts. Please try again in :seconds seconds.', 18 | 19 | ]; 20 | -------------------------------------------------------------------------------- /resources/lang/en/pagination.php: -------------------------------------------------------------------------------- 1 | '« Previous', 17 | 'next' => 'Next »', 18 | 19 | ]; 20 | -------------------------------------------------------------------------------- /resources/lang/en/passwords.php: -------------------------------------------------------------------------------- 1 | 'Passwords must be at least six characters and match the confirmation.', 17 | 'reset' => 'Your password has been reset!', 18 | 'sent' => 'We have e-mailed your password reset link!', 19 | 'token' => 'This password reset token is invalid.', 20 | 'user' => "We can't find a user with that e-mail address.", 21 | 22 | ]; 23 | -------------------------------------------------------------------------------- /resources/lang/en/validation.php: -------------------------------------------------------------------------------- 1 | 'The :attribute must be accepted.', 17 | 'active_url' => 'The :attribute is not a valid URL.', 18 | 'after' => 'The :attribute must be a date after :date.', 19 | 'after_or_equal' => 'The :attribute must be a date after or equal to :date.', 20 | 'alpha' => 'The :attribute may only contain letters.', 21 | 'alpha_dash' => 'The :attribute may only contain letters, numbers, and dashes.', 22 | 'alpha_num' => 'The :attribute may only contain letters and numbers.', 23 | 'array' => 'The :attribute must be an array.', 24 | 'before' => 'The :attribute must be a date before :date.', 25 | 'before_or_equal' => 'The :attribute must be a date before or equal to :date.', 26 | 'between' => [ 27 | 'numeric' => 'The :attribute must be between :min and :max.', 28 | 'file' => 'The :attribute must be between :min and :max kilobytes.', 29 | 'string' => 'The :attribute must be between :min and :max characters.', 30 | 'array' => 'The :attribute must have between :min and :max items.', 31 | ], 32 | 'boolean' => 'The :attribute field must be true or false.', 33 | 'confirmed' => 'The :attribute confirmation does not match.', 34 | 'date' => 'The :attribute is not a valid date.', 35 | 'date_format' => 'The :attribute does not match the format :format.', 36 | 'different' => 'The :attribute and :other must be different.', 37 | 'digits' => 'The :attribute must be :digits digits.', 38 | 'digits_between' => 'The :attribute must be between :min and :max digits.', 39 | 'dimensions' => 'The :attribute has invalid image dimensions.', 40 | 'distinct' => 'The :attribute field has a duplicate value.', 41 | 'email' => 'The :attribute must be a valid email address.', 42 | 'exists' => 'The selected :attribute is invalid.', 43 | 'file' => 'The :attribute must be a file.', 44 | 'filled' => 'The :attribute field is required.', 45 | 'image' => 'The :attribute must be an image.', 46 | 'in' => 'The selected :attribute is invalid.', 47 | 'in_array' => 'The :attribute field does not exist in :other.', 48 | 'integer' => 'The :attribute must be an integer.', 49 | 'ip' => 'The :attribute must be a valid IP address.', 50 | 'json' => 'The :attribute must be a valid JSON string.', 51 | 'max' => [ 52 | 'numeric' => 'The :attribute may not be greater than :max.', 53 | 'file' => 'The :attribute may not be greater than :max kilobytes.', 54 | 'string' => 'The :attribute may not be greater than :max characters.', 55 | 'array' => 'The :attribute may not have more than :max items.', 56 | ], 57 | 'mimes' => 'The :attribute must be a file of type: :values.', 58 | 'mimetypes' => 'The :attribute must be a file of type: :values.', 59 | 'min' => [ 60 | 'numeric' => 'The :attribute must be at least :min.', 61 | 'file' => 'The :attribute must be at least :min kilobytes.', 62 | 'string' => 'The :attribute must be at least :min characters.', 63 | 'array' => 'The :attribute must have at least :min items.', 64 | ], 65 | 'not_in' => 'The selected :attribute is invalid.', 66 | 'numeric' => 'The :attribute must be a number.', 67 | 'present' => 'The :attribute field must be present.', 68 | 'regex' => 'The :attribute format is invalid.', 69 | 'required' => 'The :attribute field is required.', 70 | 'required_if' => 'The :attribute field is required when :other is :value.', 71 | 'required_unless' => 'The :attribute field is required unless :other is in :values.', 72 | 'required_with' => 'The :attribute field is required when :values is present.', 73 | 'required_with_all' => 'The :attribute field is required when :values is present.', 74 | 'required_without' => 'The :attribute field is required when :values is not present.', 75 | 'required_without_all' => 'The :attribute field is required when none of :values are present.', 76 | 'same' => 'The :attribute and :other must match.', 77 | 'size' => [ 78 | 'numeric' => 'The :attribute must be :size.', 79 | 'file' => 'The :attribute must be :size kilobytes.', 80 | 'string' => 'The :attribute must be :size characters.', 81 | 'array' => 'The :attribute must contain :size items.', 82 | ], 83 | 'string' => 'The :attribute must be a string.', 84 | 'timezone' => 'The :attribute must be a valid zone.', 85 | 'unique' => 'The :attribute has already been taken.', 86 | 'uploaded' => 'The :attribute failed to upload.', 87 | 'url' => 'The :attribute format is invalid.', 88 | 89 | /* 90 | |-------------------------------------------------------------------------- 91 | | Custom Validation Language Lines 92 | |-------------------------------------------------------------------------- 93 | | 94 | | Here you may specify custom validation messages for attributes using the 95 | | convention "attribute.rule" to name the lines. This makes it quick to 96 | | specify a specific custom language line for a given attribute rule. 97 | | 98 | */ 99 | 100 | 'custom' => [ 101 | 'attribute-name' => [ 102 | 'rule-name' => 'custom-message', 103 | ], 104 | ], 105 | 106 | /* 107 | |-------------------------------------------------------------------------- 108 | | Custom Validation Attributes 109 | |-------------------------------------------------------------------------- 110 | | 111 | | The following language lines are used to swap attribute place-holders 112 | | with something more reader friendly such as E-Mail Address instead 113 | | of "email". This simply helps us make messages a little cleaner. 114 | | 115 | */ 116 | 117 | 'attributes' => [], 118 | 119 | ]; 120 | -------------------------------------------------------------------------------- /resources/lang/zh-cn/auth.php: -------------------------------------------------------------------------------- 1 | 'These credentials do not match our records.', 17 | 'throttle' => 'Too many login attempts. Please try again in :seconds seconds.', 18 | 19 | ]; 20 | -------------------------------------------------------------------------------- /resources/lang/zh-cn/pagination.php: -------------------------------------------------------------------------------- 1 | '« 上一页', 17 | 'next' => '下一页 »', 18 | 19 | ]; 20 | -------------------------------------------------------------------------------- /resources/lang/zh-cn/passwords.php: -------------------------------------------------------------------------------- 1 | 'Passwords must be at least six characters and match the confirmation.', 17 | 'reset' => 'Your password has been reset!', 18 | 'sent' => 'We have e-mailed your password reset link!', 19 | 'token' => 'This password reset token is invalid.', 20 | 'user' => "We can't find a user with that e-mail address.", 21 | 22 | ]; 23 | -------------------------------------------------------------------------------- /resources/lang/zh-cn/validation.php: -------------------------------------------------------------------------------- 1 | ":attribute 必须接受。", 15 | "active_url" => ":attribute 不是一个有效的网址。", 16 | "after" => ":attribute 必须是一个在 :date 之后的日期。", 17 | "alpha" => ":attribute 只能由中英文组成。", 18 | "alpha_dash" => ":attribute 只能由中英文、数字和斜杠组成。", 19 | "alpha_num" => ":attribute 只能由中英文和数字组成。", 20 | "array" => ":attribute 必须是一个数组。", 21 | "before" => ":attribute 必须是一个在 :date 之前的日期。", 22 | "between" => [ 23 | "numeric" => ":attribute 必须介于 :min - :max 之间。", 24 | "file" => ":attribute 必须介于 :min - :max kb 之间。", 25 | "string" => ":attribute 必须介于 :min - :max 个字符之间。", 26 | "array" => ":attribute 必须只有 :min - :max 个单元。", 27 | ], 28 | "boolean" => ":attribute 必须为布尔值。", 29 | "confirmed" => ":attribute 两次输入不一致。", 30 | "date" => ":attribute 不是一个有效的日期。", 31 | "date_format" => ":attribute 的格式必须为 :format。", 32 | "different" => ":attribute 和 :other 必须不同。", 33 | "digits" => ":attribute 必须是 :digits 位的数字。", 34 | "digits_between" => ":attribute 必须是介于 :min 和 :max 位的数字。", 35 | "email" => ":attribute 不是一个合法的邮箱。", 36 | "exists" => ":attribute 不存在。", 37 | "filled" => ":attribute 不能为空。", 38 | "image" => ":attribute 必须是图片。", 39 | "in" => "已选的属性 :attribute 非法。", 40 | "integer" => ":attribute 必须是整数。", 41 | "ip" => ":attribute 必须是有效的 IP 地址。", 42 | "max" => [ 43 | "numeric" => ":attribute 不能大于 :max。", 44 | "file" => ":attribute 不能大于 :max kb。", 45 | "string" => ":attribute 不能大于 :max 个字符。", 46 | "array" => ":attribute 最多只有 :max 个单元。", 47 | ], 48 | "mimes" => ":attribute 必须是一个 :values 类型的文件。", 49 | "min" => [ 50 | "numeric" => ":attribute 必须大于等于 :min。", 51 | "file" => ":attribute 大小不能小于 :min kb。", 52 | "string" => ":attribute 至少为 :min 个字符。", 53 | "array" => ":attribute 至少有 :min 个单元。", 54 | ], 55 | "not_in" => "已选的属性 :attribute 非法。", 56 | "numeric" => ":attribute 必须是一个数字。", 57 | "regex" => ":attribute 格式不正确。", 58 | "required" => ":attribute 不能为空。", 59 | "required_if" => "当 :other 为 :value 时 :attribute 不能为空。", 60 | "required_with" => "当 :values 存在时 :attribute 不能为空。", 61 | "required_with_all" => "当 :values 存在时 :attribute 不能为空。", 62 | "required_without" => "当 :values 不存在时 :attribute 不能为空。", 63 | "required_without_all" => "当 :values 都不存在时 :attribute 不能为空。", 64 | "same" => ":attribute 和 :other 必须相同。", 65 | "size" => [ 66 | "numeric" => ":attribute 大小必须为 :size。", 67 | "file" => ":attribute 大小必须为 :size kb。", 68 | "string" => ":attribute 必须是 :size 个字符。", 69 | "array" => ":attribute 必须为 :size 个单元。", 70 | ], 71 | "string" => ":attribute 必须是一个字符串。", 72 | "timezone" => ":attribute 必须是一个合法的时区值。", 73 | "unique" => "该:attribute已被注册了。", 74 | "url" => ":attribute 格式不正确。", 75 | "phone_exist" => "手机号不存在", 76 | "greater_than" => ":attribute 必须大于 :field", 77 | "after_time" => ":attribute 时间不能太早", 78 | "captcha" => "验证码错误", 79 | "verify_code" => "短信验证码错误", 80 | 'array_size_between' => ':attribute 没填或者太多了', 81 | "is_null" => ':attribute 不能传', 82 | "is_json" => ':attribute 不是一个合法的JSON值', 83 | "greater_than_equal" => ':attribute 必须大于等于 :field', 84 | "date_greater_than" => ":attribute 必须大于 :field", 85 | 'without_emoji' => ':attribute 不能包含特殊字符', 86 | 87 | /* 88 | |-------------------------------------------------------------------------- 89 | | Custom Validation Language Lines 90 | |-------------------------------------------------------------------------- 91 | | 92 | | Here you may specify custom validation messages for attributes using the 93 | | convention "attribute.rule" to name the lines. This makes it quick to 94 | | specify a specific custom language line for a given attribute rule. 95 | | 96 | */ 97 | 98 | /* 99 | |-------------------------------------------------------------------------- 100 | | Custom Validation Attributes 101 | |-------------------------------------------------------------------------- 102 | | 103 | | The following language lines are used to swap attribute place-holders 104 | | with something more reader friendly such as E-Mail Address instead 105 | | of "email". This simply helps us make messages a little cleaner. 106 | | 107 | */ 108 | 'attributes' => [ 109 | 'username' => '用户名', 110 | 'password' => '密码', 111 | ], 112 | ]; 113 | -------------------------------------------------------------------------------- /resources/views/admin/index.blade.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 后台管理系统 5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 | 13 | 14 | -------------------------------------------------------------------------------- /resources/views/admin/login.blade.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 登录 5 | 6 | 7 | 8 | 9 | 10 |
11 | 12 |
13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /resources/views/welcome.blade.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Laravel 9 | 10 | 11 | 12 | 13 | 14 | 66 | 67 | 68 |
69 | @if (Route::has('login')) 70 | 78 | @endif 79 | 80 |
81 |
82 | Laravel 83 |
84 | 85 | 92 |
93 |
94 | 95 | 96 | -------------------------------------------------------------------------------- /routes/api.php: -------------------------------------------------------------------------------- 1 | id === (int) $id; 16 | }); 17 | -------------------------------------------------------------------------------- /routes/console.php: -------------------------------------------------------------------------------- 1 | comment(Inspiring::quote()); 18 | })->describe('Display an inspiring quote'); 19 | -------------------------------------------------------------------------------- /routes/web.php: -------------------------------------------------------------------------------- 1 | 'blog-api.cn', 'prefix' => 'api'], function () { 15 | Route::group(['namespace' => 'Admin', 'prefix' => 'admin'], function () { 16 | Route::get('/', 'AdminController@index'); 17 | 18 | Route::post('/login', 'AuthController@login'); 19 | Route::post('/logout', 'AuthController@logout'); 20 | 21 | Route::group(['middleware' => ['auth:admin']], function () { 22 | Route::group(['prefix' => 'common'], function () { 23 | Route::post('upload_pic', 'CommonController@uploadPic'); 24 | }); 25 | 26 | Route::get('/userInfo', 'AuthController@user'); 27 | 28 | Route::post('post/{id}/show', 'PostController@display'); 29 | Route::post('post/{id}/hide', 'PostController@hide'); 30 | Route::resource('post', 'PostController'); 31 | 32 | Route::post('user/{id}/recover', 'UserController@recover'); 33 | Route::post('user/{id}/forbidden', 'UserController@forbidden'); 34 | Route::resource('user', 'UserController'); 35 | }); 36 | }); 37 | 38 | Route::group(['namespace' => 'Blog', 'prefix' => 'blog'], function () { 39 | Route::resource('post', 'PostController'); 40 | }); 41 | }); -------------------------------------------------------------------------------- /server.php: -------------------------------------------------------------------------------- 1 | 8 | */ 9 | 10 | $uri = urldecode( 11 | parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH) 12 | ); 13 | 14 | // This file allows us to emulate Apache's "mod_rewrite" functionality from the 15 | // built-in PHP web server. This provides a convenient way to test a Laravel 16 | // application without having installed a "real" web server software here. 17 | if ($uri !== '/' && file_exists(__DIR__.'/public'.$uri)) { 18 | return false; 19 | } 20 | 21 | require_once __DIR__.'/public/index.php'; 22 | -------------------------------------------------------------------------------- /storage/app/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !public/ 3 | !.gitignore 4 | -------------------------------------------------------------------------------- /storage/framework/cache/data/50/36/5036f31d66a92dda927d18a5af911026e8abf099: -------------------------------------------------------------------------------- 1 | 1490060385i:2; -------------------------------------------------------------------------------- /storage/framework/cache/data/ff/c9/ffc91e236ff46ac59b2756eb2649f1a6b98d209b: -------------------------------------------------------------------------------- 1 | 1490060710i:3; -------------------------------------------------------------------------------- /storage/logs/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /tests/CreatesApplication.php: -------------------------------------------------------------------------------- 1 | make(Kernel::class)->bootstrap(); 19 | 20 | return $app; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /tests/Feature/ExampleTest.php: -------------------------------------------------------------------------------- 1 | get('/'); 20 | 21 | $response->assertStatus(200); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /tests/TestCase.php: -------------------------------------------------------------------------------- 1 | assertTrue(true); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /views-src/.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": [ 3 | ["es2015", { "modules": false }] 4 | ] 5 | } -------------------------------------------------------------------------------- /views-src/build/build.js: -------------------------------------------------------------------------------- 1 | require('./check-versions')() 2 | 3 | process.env.NODE_ENV = 'production' 4 | 5 | var ora = require('ora') 6 | var rm = require('rimraf') 7 | var path = require('path') 8 | var chalk = require('chalk') 9 | var webpack = require('webpack') 10 | var config = require('../config') 11 | var webpackConfig = require('./webpack.prod.conf') 12 | 13 | var spinner = ora('building for production...') 14 | spinner.start() 15 | 16 | rm(path.join(config.build.assetsRoot, config.build.assetsSubDirectory), err => { 17 | if (err) throw err 18 | webpack(webpackConfig, function (err, stats) { 19 | spinner.stop() 20 | if (err) throw err 21 | process.stdout.write(stats.toString({ 22 | colors: true, 23 | modules: false, 24 | children: false, 25 | chunks: false, 26 | chunkModules: false 27 | }) + '\n\n') 28 | 29 | console.log(chalk.cyan(' Build complete.\n')) 30 | console.log(chalk.yellow( 31 | ' Tip: built files are meant to be served over an HTTP server.\n' + 32 | ' Opening index.html over file:// won\'t work.\n' 33 | )) 34 | }) 35 | }) 36 | -------------------------------------------------------------------------------- /views-src/build/check-versions.js: -------------------------------------------------------------------------------- 1 | var chalk = require('chalk') 2 | var semver = require('semver') 3 | var packageConfig = require('../package.json') 4 | 5 | function exec (cmd) { 6 | return require('child_process').execSync(cmd).toString().trim() 7 | } 8 | 9 | var versionRequirements = [ 10 | { 11 | name: 'node', 12 | currentVersion: semver.clean(process.version), 13 | versionRequirement: packageConfig.engines.node 14 | }, 15 | { 16 | name: 'npm', 17 | currentVersion: exec('npm --version'), 18 | versionRequirement: packageConfig.engines.npm 19 | } 20 | ] 21 | 22 | module.exports = function () { 23 | var warnings = [] 24 | for (var i = 0; i < versionRequirements.length; i++) { 25 | var mod = versionRequirements[i] 26 | if (!semver.satisfies(mod.currentVersion, mod.versionRequirement)) { 27 | warnings.push(mod.name + ': ' + 28 | chalk.red(mod.currentVersion) + ' should be ' + 29 | chalk.green(mod.versionRequirement) 30 | ) 31 | } 32 | } 33 | 34 | if (warnings.length) { 35 | console.log('') 36 | console.log(chalk.yellow('To use this template, you must update following to modules:')) 37 | console.log() 38 | for (var i = 0; i < warnings.length; i++) { 39 | var warning = warnings[i] 40 | console.log(' ' + warning) 41 | } 42 | console.log() 43 | process.exit(1) 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /views-src/build/dev-client.js: -------------------------------------------------------------------------------- 1 | /* eslint-disable */ 2 | require('eventsource-polyfill') 3 | var hotClient = require('webpack-hot-middleware/client?noInfo=true&reload=true') 4 | 5 | hotClient.subscribe(function (event) { 6 | if (event.action === 'reload') { 7 | window.location.reload() 8 | } 9 | }) 10 | -------------------------------------------------------------------------------- /views-src/build/dev-server.js: -------------------------------------------------------------------------------- 1 | require('./check-versions')() 2 | 3 | var config = require('../config') 4 | if (!process.env.NODE_ENV) { 5 | process.env.NODE_ENV = JSON.parse(config.dev.env.NODE_ENV) 6 | } 7 | 8 | var opn = require('opn') 9 | var path = require('path') 10 | var express = require('express') 11 | var webpack = require('webpack') 12 | var proxyMiddleware = require('http-proxy-middleware') 13 | var webpackConfig = require('./webpack.dev.conf') 14 | 15 | // default port where dev server listens for incoming traffic 16 | var port = process.env.PORT || config.dev.port 17 | // automatically open browser, if not set will be false 18 | var autoOpenBrowser = !!config.dev.autoOpenBrowser 19 | // Define HTTP proxies to your custom API backend 20 | // https://github.com/chimurai/http-proxy-middleware 21 | var proxyTable = config.dev.proxyTable 22 | 23 | var app = express() 24 | var compiler = webpack(webpackConfig) 25 | 26 | var devMiddleware = require('webpack-dev-middleware')(compiler, { 27 | publicPath: webpackConfig.output.publicPath, 28 | stats: { 29 | colors: true, 30 | chunks: false 31 | } 32 | }) 33 | 34 | var hotMiddleware = require('webpack-hot-middleware')(compiler, { 35 | log: () => {} 36 | }) 37 | // force page reload when html-webpack-plugin template changes 38 | compiler.plugin('compilation', function (compilation) { 39 | compilation.plugin('html-webpack-plugin-after-emit', function (data, cb) { 40 | hotMiddleware.publish({ action: 'reload' }) 41 | cb() 42 | }) 43 | }) 44 | 45 | // proxy api requests 46 | Object.keys(proxyTable).forEach(function (context) { 47 | var options = proxyTable[context] 48 | if (typeof options === 'string') { 49 | options = { target: options } 50 | } 51 | app.use(proxyMiddleware(options.filter || context, options)) 52 | }) 53 | 54 | // handle fallback for HTML5 history API 55 | app.use(require('connect-history-api-fallback')()) 56 | 57 | // serve webpack bundle output 58 | app.use(devMiddleware) 59 | 60 | // enable hot-reload and state-preserving 61 | // compilation error display 62 | app.use(hotMiddleware) 63 | 64 | // serve pure static assets 65 | var staticPath = path.posix.join(config.dev.assetsPublicPath, config.dev.assetsSubDirectory) 66 | app.use(staticPath, express.static('./static')) 67 | 68 | var uri = 'http://localhost:' + port 69 | 70 | devMiddleware.waitUntilValid(function () { 71 | console.log('> Listening at ' + uri + '\n') 72 | }) 73 | 74 | module.exports = app.listen(port, function (err) { 75 | if (err) { 76 | console.log(err) 77 | return 78 | } 79 | 80 | // when env is testing, don't need open it 81 | if (autoOpenBrowser && process.env.NODE_ENV !== 'testing') { 82 | opn(uri) 83 | } 84 | }) 85 | -------------------------------------------------------------------------------- /views-src/build/utils.js: -------------------------------------------------------------------------------- 1 | var path = require('path') 2 | var config = require('../config') 3 | var ExtractTextPlugin = require('extract-text-webpack-plugin') 4 | 5 | exports.assetsPath = function (_path) { 6 | var assetsSubDirectory = process.env.NODE_ENV === 'production' 7 | ? config.build.assetsSubDirectory 8 | : config.dev.assetsSubDirectory 9 | return path.posix.join(assetsSubDirectory, _path) 10 | } 11 | 12 | exports.cssLoaders = function (options) { 13 | options = options || {} 14 | 15 | var cssLoader = { 16 | loader: 'css-loader', 17 | options: { 18 | minimize: process.env.NODE_ENV === 'production', 19 | sourceMap: options.sourceMap 20 | } 21 | } 22 | 23 | // generate loader string to be used with extract text plugin 24 | function generateLoaders (loader, loaderOptions) { 25 | var loaders = [cssLoader] 26 | if (loader) { 27 | loaders.push({ 28 | loader: loader + '-loader', 29 | options: Object.assign({}, loaderOptions, { 30 | sourceMap: options.sourceMap 31 | }) 32 | }) 33 | } 34 | 35 | // Extract CSS when that option is specified 36 | // (which is the case during production build) 37 | if (options.extract) { 38 | return ExtractTextPlugin.extract({ 39 | use: loaders, 40 | fallback: 'vue-style-loader' 41 | }) 42 | } else { 43 | return ['vue-style-loader'].concat(loaders) 44 | } 45 | } 46 | 47 | // http://vuejs.github.io/vue-loader/en/configurations/extract-css.html 48 | return { 49 | css: generateLoaders(), 50 | postcss: generateLoaders(), 51 | less: generateLoaders('less'), 52 | sass: generateLoaders('sass', { indentedSyntax: true }), 53 | scss: generateLoaders('sass'), 54 | stylus: generateLoaders('stylus'), 55 | styl: generateLoaders('stylus') 56 | } 57 | } 58 | 59 | // Generate loaders for standalone style files (outside of .vue) 60 | exports.styleLoaders = function (options) { 61 | var output = [] 62 | var loaders = exports.cssLoaders(options) 63 | for (var extension in loaders) { 64 | var loader = loaders[extension] 65 | output.push({ 66 | test: new RegExp('\\.' + extension + '$'), 67 | use: loader 68 | }) 69 | } 70 | return output 71 | } 72 | -------------------------------------------------------------------------------- /views-src/build/vue-loader.conf.js: -------------------------------------------------------------------------------- 1 | var utils = require('./utils') 2 | var config = require('../config') 3 | var isProduction = process.env.NODE_ENV === 'production' 4 | 5 | module.exports = { 6 | loaders: utils.cssLoaders({ 7 | sourceMap: isProduction 8 | ? config.build.productionSourceMap 9 | : config.dev.cssSourceMap, 10 | extract: isProduction 11 | }) 12 | } 13 | -------------------------------------------------------------------------------- /views-src/build/webpack.base.conf.js: -------------------------------------------------------------------------------- 1 | var path = require('path') 2 | var utils = require('./utils') 3 | var config = require('../config') 4 | var vueLoaderConfig = require('./vue-loader.conf') 5 | 6 | function resolve (dir) { 7 | return path.join(__dirname, '..', dir) 8 | } 9 | 10 | module.exports = { 11 | entry: { 12 | front: ['./src/front.js', 'webpack-hot-middleware/client?name=front'], 13 | admin_login: ['./src/login.js', 'webpack-hot-middleware/client?name=admin-login'], 14 | admin: ['./src/admin.js', 'webpack-hot-middleware/client?name=admin'] 15 | }, 16 | output: { 17 | path: config.build.assetsRoot, 18 | filename: '[name].js', 19 | publicPath: process.env.NODE_ENV === 'production' 20 | ? config.build.assetsPublicPath 21 | : config.dev.assetsPublicPath 22 | }, 23 | resolve: { 24 | extensions: ['.js', '.vue', '.json'], 25 | alias: { 26 | 'vue$': 'vue/dist/vue.esm.js', 27 | '@': resolve('src'), 28 | } 29 | }, 30 | module: { 31 | rules: [ 32 | { 33 | test: /\.vue$/, 34 | loader: 'vue-loader', 35 | options: vueLoaderConfig 36 | }, 37 | { 38 | test: /\.js$/, 39 | loader: 'babel-loader', 40 | exclude: [path.resolve(__dirname, '../node_modules')] 41 | }, 42 | { 43 | test: /\.(png|jpe?g|gif|svg|woff2?|eot|ttf|otf)(\?.*)?$/, 44 | loader: 'url-loader', 45 | query: { 46 | limit: 10000, 47 | name: utils.assetsPath('img/[name].[hash:7].[ext]') 48 | } 49 | } 50 | ] 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /views-src/build/webpack.dev.conf.js: -------------------------------------------------------------------------------- 1 | var utils = require('./utils') 2 | var webpack = require('webpack') 3 | var config = require('../config') 4 | var merge = require('webpack-merge') 5 | var baseWebpackConfig = require('./webpack.base.conf') 6 | var HtmlWebpackPlugin = require('html-webpack-plugin') 7 | var FriendlyErrorsPlugin = require('friendly-errors-webpack-plugin') 8 | 9 | // add hot-reload related code to entry chunks 10 | Object.keys(baseWebpackConfig.entry).forEach(function (name) { 11 | baseWebpackConfig.entry[name] = ['./build/dev-client'].concat(baseWebpackConfig.entry[name]) 12 | }) 13 | 14 | module.exports = merge(baseWebpackConfig, { 15 | module: { 16 | rules: utils.styleLoaders({sourceMap: config.dev.cssSourceMap}) 17 | }, 18 | // cheap-module-eval-source-map is faster for development 19 | devtool: '#cheap-module-eval-source-map', 20 | plugins: [ 21 | new webpack.DefinePlugin({ 22 | 'process.env': config.dev.env 23 | }), 24 | // https://github.com/glenjamin/webpack-hot-middleware#installation--usage 25 | new webpack.HotModuleReplacementPlugin(), 26 | new webpack.NoEmitOnErrorsPlugin(), 27 | // https://github.com/ampedandwired/html-webpack-plugin 28 | new HtmlWebpackPlugin({ 29 | title: 'spa-blog', 30 | filename: 'index.html', 31 | template: './src/templates/front.ejs', 32 | inject: true, 33 | chunks: ["manifest", 'vendor', 'front'], 34 | }), 35 | new HtmlWebpackPlugin({ 36 | title: '登录后台管理系统', 37 | filename: 'login.html', 38 | template: './src/templates/login.ejs', 39 | inject: true, 40 | chunks: ["manifest", 'vendor', 'admin_login'], 41 | }), 42 | new HtmlWebpackPlugin({ 43 | title: '后台管理系统', 44 | filename: 'admin.html', 45 | template: './src/templates/admin.ejs', 46 | inject: true, 47 | chunks: ["manifest", 'vendor', 'admin'], 48 | }), 49 | new FriendlyErrorsPlugin() 50 | ] 51 | }) 52 | -------------------------------------------------------------------------------- /views-src/build/webpack.prod.conf.js: -------------------------------------------------------------------------------- 1 | var path = require('path') 2 | var utils = require('./utils') 3 | var webpack = require('webpack') 4 | var config = require('../config') 5 | var merge = require('webpack-merge') 6 | var baseWebpackConfig = require('./webpack.base.conf') 7 | var CopyWebpackPlugin = require('copy-webpack-plugin') 8 | var HtmlWebpackPlugin = require('html-webpack-plugin') 9 | var ExtractTextPlugin = require('extract-text-webpack-plugin') 10 | var OptimizeCSSPlugin = require('optimize-css-assets-webpack-plugin') 11 | 12 | var env = config.build.env 13 | 14 | var webpackConfig = merge(baseWebpackConfig, { 15 | module: { 16 | rules: utils.styleLoaders({ 17 | sourceMap: config.build.productionSourceMap, 18 | extract: true 19 | }) 20 | }, 21 | devtool: config.build.productionSourceMap ? '#source-map' : false, 22 | entry: { 23 | front: './src/front.js', 24 | admin_login: './src/login.js', 25 | admin: './src/admin.js' 26 | }, 27 | output: { 28 | path: config.build.assetsRoot, 29 | filename: utils.assetsPath('js/[name].[chunkhash].js'), 30 | chunkFilename: utils.assetsPath('js/[id].[chunkhash].js') 31 | }, 32 | plugins: [ 33 | // http://vuejs.github.io/vue-loader/en/workflow/production.html 34 | new webpack.DefinePlugin({ 35 | 'process.env': env 36 | }), 37 | new webpack.optimize.UglifyJsPlugin({ 38 | compress: { 39 | warnings: false 40 | }, 41 | sourceMap: true 42 | }), 43 | // extract css into its own file 44 | new ExtractTextPlugin({ 45 | filename: utils.assetsPath('css/[name].[contenthash].css') 46 | }), 47 | // Compress extracted CSS. We are using this plugin so that possible 48 | // duplicated CSS from different components can be deduped. 49 | new OptimizeCSSPlugin(), 50 | // generate dist index.html with correct asset hash for caching. 51 | // you can customize output by editing /index.html 52 | // see https://github.com/ampedandwired/html-webpack-plugin 53 | new HtmlWebpackPlugin({ 54 | title: 'spa-blog', 55 | filename: 'index.html', 56 | template: './src/templates/front.ejs', 57 | inject: true, 58 | chunks: ["manifest", 'vendor', 'front'], 59 | minify: { 60 | removeComments: true, 61 | collapseWhitespace: true, 62 | removeAttributeQuotes: true 63 | // more options: 64 | // https://github.com/kangax/html-minifier#options-quick-reference 65 | }, 66 | // necessary to consistently work with multiple chunks via CommonsChunkPlugin 67 | chunksSortMode: 'dependency' 68 | }), 69 | new HtmlWebpackPlugin({ 70 | title: '登录后台管理系统', 71 | filename: 'login.html', 72 | template: './src/templates/login.ejs', 73 | inject: true, 74 | chunks: ["manifest", 'vendor', 'admin_login'], 75 | minify: { 76 | removeComments: true, 77 | collapseWhitespace: true, 78 | removeAttributeQuotes: true 79 | // more options: 80 | // https://github.com/kangax/html-minifier#options-quick-reference 81 | }, 82 | // necessary to consistently work with multiple chunks via CommonsChunkPlugin 83 | chunksSortMode: 'dependency' 84 | }), 85 | new HtmlWebpackPlugin({ 86 | title: '后台管理系统', 87 | filename: 'admin.html', 88 | template: './src/templates/admin.ejs', 89 | inject: true, 90 | chunks: ["manifest", 'vendor', 'admin'], 91 | minify: { 92 | removeComments: true, 93 | collapseWhitespace: true, 94 | removeAttributeQuotes: true 95 | // more options: 96 | // https://github.com/kangax/html-minifier#options-quick-reference 97 | }, 98 | // necessary to consistently work with multiple chunks via CommonsChunkPlugin 99 | chunksSortMode: 'dependency' 100 | }), 101 | // split vendor js into its own file 102 | new webpack.optimize.CommonsChunkPlugin({ 103 | name: 'vendor', 104 | minChunks: function (module, count) { 105 | // any required modules inside node_modules are extracted to vendor 106 | return ( 107 | module.resource && 108 | /\.js$/.test(module.resource) && 109 | module.resource.indexOf( 110 | path.join(__dirname, '../node_modules') 111 | ) === 0 112 | ) 113 | } 114 | }), 115 | // extract webpack runtime and module manifest to its own file in order to 116 | // prevent vendor hash from being updated whenever app bundle is updated 117 | new webpack.optimize.CommonsChunkPlugin({ 118 | name: 'manifest', 119 | chunks: ['vendor'] 120 | }), 121 | ] 122 | }) 123 | 124 | if (config.build.productionGzip) { 125 | var CompressionWebpackPlugin = require('compression-webpack-plugin') 126 | 127 | webpackConfig.plugins.push( 128 | new CompressionWebpackPlugin({ 129 | asset: '[path].gz[query]', 130 | algorithm: 'gzip', 131 | test: new RegExp( 132 | '\\.(' + 133 | config.build.productionGzipExtensions.join('|') + 134 | ')$' 135 | ), 136 | threshold: 10240, 137 | minRatio: 0.8 138 | }) 139 | ) 140 | } 141 | 142 | if (config.build.bundleAnalyzerReport) { 143 | var BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin 144 | webpackConfig.plugins.push(new BundleAnalyzerPlugin()) 145 | } 146 | 147 | module.exports = webpackConfig 148 | -------------------------------------------------------------------------------- /views-src/config/dev.env.js: -------------------------------------------------------------------------------- 1 | var merge = require('webpack-merge') 2 | var prodEnv = require('./prod.env') 3 | 4 | module.exports = merge(prodEnv, { 5 | NODE_ENV: '"development"' 6 | }) 7 | -------------------------------------------------------------------------------- /views-src/config/index.js: -------------------------------------------------------------------------------- 1 | // see http://vuejs-templates.github.io/webpack for documentation. 2 | var path = require('path') 3 | 4 | module.exports = { 5 | build: { 6 | env: require('./prod.env'), 7 | index: path.resolve(__dirname, '../dist/index.html'), 8 | assetsRoot: path.resolve(__dirname, '../../public'), 9 | assetsSubDirectory: 'static', 10 | assetsPublicPath: '/', 11 | productionSourceMap: true, 12 | // Gzip off by default as many popular static hosts such as 13 | // Surge or Netlify already gzip all static assets for you. 14 | // Before setting to `true`, make sure to: 15 | // npm install --save-dev compression-webpack-plugin 16 | productionGzip: false, 17 | productionGzipExtensions: ['js', 'css'], 18 | // Run the build command with an extra argument to 19 | // View the bundle analyzer report after build finishes: 20 | // `npm run build --report` 21 | // Set to `true` or `false` to always turn it on or off 22 | bundleAnalyzerReport: process.env.npm_config_report 23 | }, 24 | dev: { 25 | env: require('./dev.env'), 26 | port: 8080, 27 | autoOpenBrowser: true, 28 | assetsSubDirectory: 'static', 29 | assetsPublicPath: '/', 30 | proxyTable: {}, 31 | // CSS Sourcemaps off by default because relative paths are "buggy" 32 | // with this option, according to the CSS-Loader README 33 | // (https://github.com/webpack/css-loader#sourcemaps) 34 | // In our experience, they generally work as expected, 35 | // just be aware of this issue when enabling this option. 36 | cssSourceMap: false 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /views-src/config/prod.env.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | NODE_ENV: '"production"' 3 | } 4 | -------------------------------------------------------------------------------- /views-src/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | <%= htmlWebpackPlugin.options.title %> 6 | 7 | 8 |
9 | 10 | 11 | -------------------------------------------------------------------------------- /views-src/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "spa-demo", 3 | "version": "1.0.0", 4 | "description": "laravel5.4 webpack2 Vuejs2 iview2 spa demo", 5 | "author": "lzj <954121868@qq.com>", 6 | "private": true, 7 | "scripts": { 8 | "dev": "node build/dev-server.js", 9 | "build": "node build/build.js", 10 | "lint": "eslint --ext .js,.vue src" 11 | }, 12 | "dependencies": { 13 | "iview": "2.0.0-rc.5", 14 | "vue": "^2.2.2", 15 | "vue-resource": "^1.2.1", 16 | "vue-router": "^2.2.0", 17 | "wangeditor": "^2.1.23" 18 | }, 19 | "devDependencies": { 20 | "autoprefixer": "^6.7.2", 21 | "babel-core": "^6.22.1", 22 | "babel-eslint": "^7.1.1", 23 | "babel-loader": "^6.2.10", 24 | "babel-plugin-transform-runtime": "^6.22.0", 25 | "babel-preset-env": "^1.2.1", 26 | "babel-preset-es2015": "^6.24.1", 27 | "babel-preset-stage-2": "^6.22.0", 28 | "babel-register": "^6.22.0", 29 | "chalk": "^1.1.3", 30 | "connect-history-api-fallback": "^1.3.0", 31 | "copy-webpack-plugin": "^4.0.1", 32 | "css-loader": "^0.26.1", 33 | "eslint": "^3.14.1", 34 | "eslint-config-standard": "^6.2.1", 35 | "eslint-friendly-formatter": "^2.0.7", 36 | "eslint-loader": "^1.6.1", 37 | "eslint-plugin-html": "^2.0.0", 38 | "eslint-plugin-promise": "^3.4.0", 39 | "eslint-plugin-standard": "^2.0.1", 40 | "eventsource-polyfill": "^0.9.6", 41 | "express": "^4.14.1", 42 | "extract-text-webpack-plugin": "^2.0.0", 43 | "file-loader": "^0.10.0", 44 | "friendly-errors-webpack-plugin": "^1.1.3", 45 | "function-bind": "^1.1.0", 46 | "html-loader": "^0.4.5", 47 | "html-webpack-plugin": "^2.28.0", 48 | "http-proxy-middleware": "^0.17.3", 49 | "opn": "^4.0.2", 50 | "optimize-css-assets-webpack-plugin": "^1.3.0", 51 | "ora": "^1.1.0", 52 | "rimraf": "^2.6.0", 53 | "semver": "^5.3.0", 54 | "url-loader": "^0.5.7", 55 | "vue-html5-editor": "^1.0.2", 56 | "vue-loader": "^11.1.4", 57 | "vue-style-loader": "^2.0.0", 58 | "vue-template-compiler": "^2.2.4", 59 | "webpack": "^2.2.1", 60 | "webpack-bundle-analyzer": "^2.2.1", 61 | "webpack-dev-middleware": "^1.10.0", 62 | "webpack-hot-middleware": "^2.16.1", 63 | "webpack-merge": "^2.6.1" 64 | }, 65 | "engines": { 66 | "node": ">= 4.0.0", 67 | "npm": ">= 3.0.0" 68 | }, 69 | "browserslist": [ 70 | "> 1%", 71 | "last 2 versions", 72 | "not ie <= 8" 73 | ] 74 | } 75 | -------------------------------------------------------------------------------- /views-src/src/admin.js: -------------------------------------------------------------------------------- 1 | import Vue from "vue"; 2 | import vueResource from 'vue-resource'; 3 | import VueRouter from "vue-router"; 4 | import iview from 'iview'; 5 | import App from "./views/admin/App.vue"; 6 | import routes from "../src/router/admin-router"; 7 | import 'iview/dist/styles/iview.css'; 8 | import config from '../src/config/admin-config'; 9 | 10 | Vue.use(vueResource); 11 | Vue.use(VueRouter); 12 | Vue.use(iview); 13 | window.config = config; 14 | Vue.config.productionTip = config.productionTip; 15 | // 开启debug模式 16 | Vue.config.debug = config.debug; 17 | 18 | Vue.http.interceptors.push(function (request, next) { 19 | // 跨域提交cookie 20 | request.withCredentials = true; 21 | 22 | this.$Loading.start(); 23 | 24 | next(function (response) { 25 | // 全局错误处理 26 | if (response.status === 200) { 27 | if (response.body.status_code === 401 && response.body.code !== 4010) { 28 | window.location.href = config.login_url; 29 | } else if (response.body.status_code === 422) { 30 | this.$Loading.error(); 31 | var errorObj = response.body.data; 32 | for (var field in errorObj) { 33 | for (var key in errorObj[field]) { 34 | this.$Notice.error({title: errorObj[field][key]}) 35 | } 36 | } 37 | } else if (response.body.status_code !== 200) { 38 | this.$Loading.error(); 39 | this.$Message.error(response.data.msg); 40 | } else { 41 | this.$Loading.finish(); 42 | } 43 | } else { 44 | this.$Loading.error(); 45 | this.$Message.error("发生了未知错误") 46 | } 47 | }); 48 | }); 49 | 50 | // 路由配置 51 | let router = new VueRouter({ 52 | routes: routes, 53 | scrollBehavior (to, from, savedPosition) { 54 | return {"x": 0, "y": 0}; 55 | } 56 | }); 57 | router.beforeEach((to, from, next) => { 58 | iview.LoadingBar.start(); 59 | next(); 60 | }); 61 | router.afterEach((to, from, next) => { 62 | iview.LoadingBar.finish(); 63 | }); 64 | 65 | new Vue({ 66 | el: '#app', //vue实例的根元素 67 | router, //在vue实例中,引入定义的路由 68 | render: h => h(App) //渲染App组件 69 | }); 70 | -------------------------------------------------------------------------------- /views-src/src/assets/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lzjcoding/laravel5.4-webpack2-Vuejs2-iview2-spa-demo/a169dbc66f7e0a8172eee6f9b60b25ee60f850bc/views-src/src/assets/logo.png -------------------------------------------------------------------------------- /views-src/src/components/Hello.vue: -------------------------------------------------------------------------------- 1 | 4 | 5 | 7 | 8 | -------------------------------------------------------------------------------- /views-src/src/components/async-table.vue: -------------------------------------------------------------------------------- 1 | 23 | 24 | -------------------------------------------------------------------------------- /views-src/src/components/login-form.vue: -------------------------------------------------------------------------------- 1 | 40 | 41 | 64 | 65 | -------------------------------------------------------------------------------- /views-src/src/config/admin-config.js: -------------------------------------------------------------------------------- 1 | import baseConfig from './config'; 2 | 3 | let config = { 4 | login_url: '/login.html', 5 | api: { 6 | user_info: '/api/admin/userInfo', 7 | login: '/api/admin/login', 8 | logout: '/api/admin/logout', 9 | upload_pic: '/api/admin/common/upload_pic', 10 | post: { 11 | list: '/api/admin/post', 12 | create: '/api/admin/post', 13 | update: function (id) { 14 | return '/api/admin/post/' + id; 15 | }, 16 | show: function (id) { 17 | return '/api/admin/post/' + id; 18 | }, 19 | display: function (id) { 20 | return '/api/admin/post/' + id + '/show'; 21 | }, 22 | hide: function (id) { 23 | return '/api/admin/post/' + id + '/hide'; 24 | }, 25 | delete: function (id) { 26 | return '/api/admin/post/' + id; 27 | } 28 | } 29 | }, 30 | getApi (apiUri) { 31 | return baseConfig.api_domain + apiUri; 32 | } 33 | }; 34 | 35 | config = Object.assign(baseConfig, config); 36 | 37 | export default config; 38 | -------------------------------------------------------------------------------- /views-src/src/config/config.js: -------------------------------------------------------------------------------- 1 | let config = { 2 | productionTip: false, 3 | debug: true, 4 | avatar_404: '/images/avatar_404.png', 5 | cdn: 'http://blog-api.cn/', 6 | api_domain: 'http://blog-api.cn', 7 | img_url: function (path) { 8 | return this.cdn + path; 9 | } 10 | }; 11 | 12 | export default config; -------------------------------------------------------------------------------- /views-src/src/config/front-config.js: -------------------------------------------------------------------------------- 1 | import baseConfig from './config'; 2 | 3 | let config = { 4 | api: { 5 | post: { 6 | list: '/api/blog/post', 7 | show: function (id) { 8 | return '/api/blog/post/' + id 9 | } 10 | } 11 | }, 12 | getApi (apiUri) { 13 | return baseConfig.api_domain + apiUri; 14 | } 15 | }; 16 | 17 | Object.assign(config, baseConfig); 18 | 19 | export default config; -------------------------------------------------------------------------------- /views-src/src/front.js: -------------------------------------------------------------------------------- 1 | import Vue from "vue"; 2 | import vueResource from 'vue-resource'; 3 | import VueRouter from "vue-router"; 4 | import iview from 'iview'; 5 | import App from "./views/front/App.vue"; 6 | import routes from "../src/router/front-router"; 7 | import 'iview/dist/styles/iview.css'; 8 | import config from '../src/config/front-config'; 9 | 10 | Vue.use(vueResource); 11 | Vue.use(VueRouter); 12 | Vue.use(iview); 13 | window.config = config; 14 | Vue.config.productionTip = config.productionTip; 15 | // 开启debug模式 16 | Vue.config.debug = config.debug; 17 | 18 | // vue-reource 公共设置 19 | Vue.http.interceptors.push(function (request, next) { 20 | this.$Loading.start(); 21 | 22 | next(function (response) { 23 | // 全局错误处理 24 | if (response.status !== 200) { 25 | this.$Loading.error(); 26 | this.$Message.error(response.data.msg); 27 | } else { 28 | this.$Loading.finish(); 29 | } 30 | }); 31 | }); 32 | 33 | // 路由配置 34 | let router = new VueRouter({ 35 | routes: routes, 36 | scrollBehavior (to, from, savedPosition) { 37 | return false 38 | } 39 | }); 40 | router.beforeEach((to, from, next) => { 41 | iview.LoadingBar.start(); 42 | next(); 43 | }); 44 | router.afterEach((to, from, next) => { 45 | iview.LoadingBar.finish(); 46 | }); 47 | 48 | new Vue({ 49 | el: '#app', //vue实例的根元素 50 | router, //在vue实例中,引入定义的路由 51 | render: h => h(App) //渲染App组件 52 | }); 53 | -------------------------------------------------------------------------------- /views-src/src/login.js: -------------------------------------------------------------------------------- 1 | import Vue from 'vue'; 2 | import vueResource from 'vue-resource'; 3 | import iView from 'iview'; 4 | import LoginForm from './components/login-form.vue'; 5 | import 'iview/dist/styles/iview.css'; 6 | import config from '../src/config/admin-config'; 7 | 8 | Vue.use(vueResource); 9 | Vue.use(iView); 10 | window.config = config; 11 | Vue.config.productionTip = config.productionTip; 12 | // 开启debug模式 13 | Vue.config.debug = config.debug; 14 | 15 | Vue.http.interceptors.push((request, next) => { 16 | // 跨域提交cookie 17 | request.withCredentials = true; 18 | next(); 19 | }); 20 | 21 | window.onload = function () { 22 | new Vue({ 23 | el: '#app', 24 | components: { 25 | 'login-form': LoginForm 26 | } 27 | }); 28 | } -------------------------------------------------------------------------------- /views-src/src/router/admin-router.js: -------------------------------------------------------------------------------- 1 | import Hello from '@/components/Hello' 2 | 3 | let routes = [ 4 | { 5 | path: '/', 6 | name: 'Hello', 7 | component: Hello 8 | }, 9 | { 10 | path: '/post', 11 | name: 'post-index', 12 | component (resolve) { 13 | require(['@/views/admin/post/index.vue'], resolve); 14 | } 15 | }, 16 | { 17 | path: '/post/create', 18 | name: 'post-create', 19 | component (resolve) { 20 | require(['@/views/admin/post/form.vue'], resolve); 21 | } 22 | }, 23 | { 24 | path: '/post/:id', 25 | name: 'post-edit', 26 | component (resolve) { 27 | require(['@/views/admin/post/form.vue'], resolve); 28 | } 29 | }, 30 | ]; 31 | 32 | export default routes; 33 | -------------------------------------------------------------------------------- /views-src/src/router/front-router.js: -------------------------------------------------------------------------------- 1 | let routes = [ 2 | {path: '/index', name: 'post-index', component: require('../views/front/post/index.vue')}, 3 | {path: '/post/:id', name: 'post-show', component: require('../views/front/post/show.vue')}, 4 | {path: '/', redirect: '/index'} 5 | ]; 6 | 7 | export default routes; -------------------------------------------------------------------------------- /views-src/src/router/index.js: -------------------------------------------------------------------------------- 1 | import Vue from 'vue' 2 | import Router from 'vue-router' 3 | import Hello from '@/components/Hello' 4 | 5 | Vue.use(Router) 6 | 7 | export default new Router({ 8 | routes: [ 9 | { 10 | path: '/', 11 | name: 'Hello', 12 | component: Hello 13 | } 14 | ] 15 | }) 16 | -------------------------------------------------------------------------------- /views-src/src/templates/admin.ejs: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | <%= htmlWebpackPlugin.options.title %> 5 | 6 | 7 | 8 | 9 |
10 | 11 | -------------------------------------------------------------------------------- /views-src/src/templates/front.ejs: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | <%= htmlWebpackPlugin.options.title %> 5 | 6 | 7 | 8 | 9 |
10 | 11 | 12 | -------------------------------------------------------------------------------- /views-src/src/templates/login.ejs: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | <%= htmlWebpackPlugin.options.title %> 5 | 6 | 7 | 16 | 17 | 18 |
19 | 20 |
21 | 22 | -------------------------------------------------------------------------------- /views-src/src/views/admin/App.vue: -------------------------------------------------------------------------------- 1 | 123 | 124 | 156 | 157 | 197 | -------------------------------------------------------------------------------- /views-src/src/views/admin/post/index.vue: -------------------------------------------------------------------------------- 1 | 3 | 46 | 165 | -------------------------------------------------------------------------------- /views-src/src/views/front/App.vue: -------------------------------------------------------------------------------- 1 | 16 | -------------------------------------------------------------------------------- /views-src/src/views/front/post/index.vue: -------------------------------------------------------------------------------- 1 | 31 | 62 | 63 | 109 | -------------------------------------------------------------------------------- /views-src/src/views/front/post/show.vue: -------------------------------------------------------------------------------- 1 | 16 | 17 | 36 | 37 | 63 | -------------------------------------------------------------------------------- /views-src/src/views/login.js: -------------------------------------------------------------------------------- 1 | import Vue from 'vue'; 2 | import vueResource from 'vue-resource'; 3 | import iView from 'iview'; 4 | import LoginForm from './components/login-form.vue'; 5 | import 'iview/dist/styles/iview.css'; 6 | 7 | Vue.use(vueResource); 8 | Vue.use(iView); 9 | 10 | window.onload = function () { 11 | new Vue({ 12 | el: '#app', 13 | components: { 14 | 'login-form': LoginForm 15 | } 16 | }); 17 | } --------------------------------------------------------------------------------