Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 1076359

Browse filesBrowse files
committed
增加文档和集成websocket服务,实现消息推送
1 parent c1aebc3 commit 1076359
Copy full SHA for 1076359

File tree

Expand file treeCollapse file tree

1,625 files changed

+314293
-711
lines changed
Filter options

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Dismiss banner
Expand file treeCollapse file tree

1,625 files changed

+314293
-711
lines changed

‎README.md

Copy file name to clipboardExpand all lines: README.md
+9-5Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,20 @@
1010
> 2. 数据表部分字段的调整,取消permissions中不常用的method和route_match字段,修改users表中的role字段为roles, roles表中的permission为permissions,使数据表更加规范化
1111
> 3. 代码层面,资源控制器的功能复用,让代码更简洁和实用,父类Controller中编写好了数据的增删改查和数据表的导入和导出功能,用户可以根据TempController的方式来编写相关代码,可以参考OrderController(订单控制),开箱即用,节省业务的编写时间
1212
> 4. 完善日志管理的API
13+
> 5. 利用showdoc完成文档构建
14+
> 6. 利用laravel-echo-server,集成websocket,当同一个用户多次登陆,前次登陆的页面,将自动退出。利用webasocket的消息推送来实现
15+
1316
#### 前端:
1417
> 1. 前端element ui 更新到了2.7.2版本,请参照开发
1518
> 2. 集成了同时打开多个页面的功能,多标签功能
1619
> 3. 集成了全屏操作的功能
1720
> 4. 增加了日志管理功能
1821
> 5. 增加了前端开发示列,商品订单管理,代码层面利用mixin功能优化书写
22+
> 6. 接收后端推送的消息,强制下线多次登陆的用户,保证同一个用户在什么时间与地点只能登陆一次。
1923
2024
#### ToDo:
21-
> 1. 集成swagger到后端,进行API文档的编写
22-
> 2. 前端增加用户多角色动态切换功能
23-
> 3. 利用laravel广播功能,编写IM示列
24-
> 4. 系统增加成员管理功能、增加成员注册和使用第三方用户登录的功能
25+
> 1. 前端增加用户多角色动态切换功能
26+
> 2. 系统增加成员管理功能、增加成员注册和使用第三方用户登录的功能
2527
2628
## 2、系统概述
2729
项目依托laravel5.5与vue.js,采用了主流的前后端分离方式来构建,作为程序的起点,你可以在此基础上进行自身业务的扩展。
@@ -37,6 +39,8 @@
3739
3840
### 项目截图
3941

42+
#### 文档
43+
![系统文档](https://github.com/wmhello/laravel_template_with_vue/raw/master/Screenshots/doc.png)
4044

4145
#### 管理员面板
4246
![管理员面板](https://github.com/wmhello/laravel_template_with_vue/raw/master/Screenshots/v2-admin-dashboard.png)
@@ -124,7 +128,7 @@
124128
>- [laravel](https://laravel.com/)
125129
>- [后端excel插件](https://github.com/rap2hpoutre/fast-excel)
126130
>- [后端跨域](https://github.com/barryvdh/laravel-cors)
127-
>- [API接口文档书写](http://apidocjs.com/)
131+
>- [API接口文档](https://github.com/star7th/showdoc)
128132
>- [vue.js](https://cn.vuejs.org/index.html)
129133
>- [element ui](http://element.eleme.io/#/zh-CN)
130134
>- [vue-router](https://router.vuejs.org/)

‎Screenshots/doc.jpg

Copy file name to clipboard
54 KB
Loading

‎Screenshots/doc.png

Copy file name to clipboard
64.3 KB
Loading

‎back.md

Copy file name to clipboardExpand all lines: back.md
+7-4Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,12 @@ npm run build
6161
~~~
6262

6363
## 查看API文档地址
64-
假设后端的域名为back.test 则文档地址为http://back.test/apidoc/
6564

66-
## 编译API文档
67-
由于文档使用了apidoc 请使用前预先安装apidoc
65+
API文档使用了[showdoc](https://github.com/star7th/showdoc)
66+
如果系统部署于Windows服务器,为了保证showdoc的运行,请先检查下列条件:
67+
68+
在php.ini里面把”extension=php_sqlite.dll”和”extension=php_pdo_sqlite.dll”启用以便开启对SQlite的支持;也启用php_mbstring.dll;Linux服务器则不需要此操作。
69+
70+
71+
假设后端的域名为back.test 则文档地址为http://back.test/showdoc/
6872

69-
编译命令为apidoc -i ./ -o public/apidoc/

‎backend/app/Events/UserLogin.php

Copy file name to clipboardExpand all lines: backend/app/Events/UserLogin.php
+6-3Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace App\Events;
44

5+
use App\Models\User;
56
use Illuminate\Broadcasting\Channel;
67
use Illuminate\Queue\SerializesModels;
78
use Illuminate\Broadcasting\PrivateChannel;
@@ -10,7 +11,7 @@
1011
use Illuminate\Broadcasting\InteractsWithSockets;
1112
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
1213

13-
class UserLogin
14+
class UserLogin implements ShouldBroadcast
1415
{
1516
use Dispatchable, InteractsWithSockets, SerializesModels;
1617

@@ -19,9 +20,11 @@ class UserLogin
1920
*
2021
* @return void
2122
*/
22-
public function __construct()
23+
public $user;
24+
public function __construct(User $user)
2325
{
2426
//
27+
$this->user = $user;
2528
}
2629

2730
/**
@@ -31,6 +34,6 @@ public function __construct()
3134
*/
3235
public function broadcastOn()
3336
{
34-
return new PrivateChannel('channel-name');
37+
return new PrivateChannel('leave.'.$this->user->name);
3538
}
3639
}

‎backend/app/Http/Controllers/Auth/LoginController.php

Copy file name to clipboardExpand all lines: backend/app/Http/Controllers/Auth/LoginController.php
+5-2Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,10 @@ public function login(Request $request)
5454
// 2. 尝试使用用户名和密码进行登录
5555
if (Auth::attempt(['email' => $email, 'password'=> $password ])){
5656
// 3. 登录成功后,进行令牌发送
57-
event( new UserLogin());
57+
$user = Auth::user();
58+
event( new UserLogin($user));
59+
DB::table('oauth_access_tokens')->where('user_id', $user->id)->update(['revoked' => 1]);
60+
5861
return $this->proxy($email, $password);
5962

6063
} else {
@@ -119,10 +122,10 @@ protected function token($data = []){
119122
$http = new Client();
120123
$web = $_SERVER['HTTP_HOST'];
121124
$url = 'http://'.$web.'/oauth/token';
125+
122126
$result = $http->post($url, [
123127
'form_params' => $data
124128
]);
125-
126129
$result = json_decode((string) $result->getBody(), true);
127130
return response()->json([
128131
'token' => $result['access_token'],

‎backend/app/Providers/BroadcastServiceProvider.php

Copy file name to clipboardExpand all lines: backend/app/Providers/BroadcastServiceProvider.php
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ class BroadcastServiceProvider extends ServiceProvider
1414
*/
1515
public function boot()
1616
{
17-
Broadcast::routes();
18-
17+
// Broadcast::routes();
18+
Broadcast::routes(["prefix" => "api", "middleware" => "auth:api"]);
1919
require base_path('routes/channels.php');
2020
}
2121
}

‎backend/composer.json

Copy file name to clipboardExpand all lines: backend/composer.json
+1-2Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@
1212
"laravel/framework": "5.5.*",
1313
"laravel/passport": "^4.0",
1414
"laravel/tinker": "~1.0",
15-
"predis/predis": "^1.0",
16-
"pusher/pusher-php-server": "^3.4",
15+
"predis/predis": "^1.1",
1716
"rap2hpoutre/fast-excel": "^1.2"
1817
},
1918
"require-dev": {

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.