Skip to content

Commit b1035d7

Browse files
committed
1.项目初始化
0 parents  commit b1035d7

File tree

130 files changed

+7490
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

130 files changed

+7490
-0
lines changed

.editorconfig

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
root = true
2+
3+
[*]
4+
charset = utf-8
5+
end_of_line = lf
6+
insert_final_newline = true
7+
indent_style = space
8+
indent_size = 4
9+
trim_trailing_whitespace = true
10+
11+
[*.md]
12+
trim_trailing_whitespace = false
13+
14+
[*.yml]
15+
indent_size = 2

.env.example

+65
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
APP_NAME=LaravelStyle
2+
APP_ENV=local
3+
APP_KEY=base64:rqWGQkrluTKigzh63PiQoA/4czCvILLJ3wwcJst8Pwg=
4+
APP_DEBUG=true
5+
APP_URL=http://localhost
6+
APP_ENVIRONMENT=false
7+
8+
LOG_CHANNEL=stack
9+
10+
DB_CONNECTION=mysql
11+
DB_HOST=127.0.0.1
12+
DB_PORT=3306
13+
DB_DATABASE=demo
14+
DB_USERNAME=root
15+
DB_PASSWORD=
16+
17+
OSS_KEY=
18+
OSS_SECRET=
19+
OSS_BUCKET=
20+
OSS_ENDPOINT=
21+
OSS_GATEWAY=
22+
23+
SMS_KEY=
24+
SMS_SECRET=
25+
SMS_SIGN=
26+
27+
MongoDB_HOST=127.0.0.1
28+
MongoDB_PORT=27017
29+
MongoDB_USERNAME=
30+
MongoDB_PASSWORD=
31+
MongoDB_DATABASE=
32+
33+
BROADCAST_DRIVER=log
34+
CACHE_DRIVER=file
35+
QUEUE_CONNECTION=redis
36+
SESSION_DRIVER=file
37+
SESSION_LIFETIME=120
38+
39+
REDIS_HOST=127.0.0.1
40+
REDIS_PASSWORD=null
41+
REDIS_PORT=6379
42+
REDIS_DB=0
43+
44+
MAIL_DRIVER=smtp
45+
MAIL_HOST=smtp.mailtrap.io
46+
MAIL_PORT=2525
47+
MAIL_USERNAME=null
48+
MAIL_PASSWORD=null
49+
MAIL_ENCRYPTION=null
50+
51+
AWS_ACCESS_KEY_ID=
52+
AWS_SECRET_ACCESS_KEY=
53+
AWS_DEFAULT_REGION=us-east-1
54+
AWS_BUCKET=
55+
56+
PUSHER_APP_ID=
57+
PUSHER_APP_KEY=
58+
PUSHER_APP_SECRET=
59+
PUSHER_APP_CLUSTER=mt1
60+
61+
MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
62+
MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"
63+
64+
65+
TOKEN_SECRET=UVX0mop7tvyABCDG3bdefTghijI8KMQR

.gitattributes

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
* text=auto
2+
*.css linguist-vendored
3+
*.scss linguist-vendored
4+
*.js linguist-vendored
5+
CHANGELOG.md export-ignore

.gitignore

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/node_modules
2+
/public/hot
3+
/public/storage
4+
/storage/*.key
5+
/vendor
6+
.env
7+
.env.backup
8+
.phpunit.result.cache
9+
Homestead.json
10+
Homestead.yaml
11+
npm-debug.log
12+
yarn-error.log
13+
/.idea
14+
composer.lock

.styleci.yml

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
php:
2+
preset: laravel
3+
disabled:
4+
- unused_use
5+
finder:
6+
not-name:
7+
- index.php
8+
- server.php
9+
js:
10+
finder:
11+
not-name:
12+
- webpack.mix.js
13+
css: true

README.md

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
## 项目简介
2+
LaravelAdmin是基于PHP开发的基础管理后台系统,做到开箱即用,为新项目开发省去了基础功能开发的步骤;此系统采用前后端分离模式,后端使用Laravel,前端使用vue;主要包含:登录、注销、可视化数据大屏、管理员、角色管理、菜单管理、权限管理、错误日志、登录日志、访问日志等功能。后端主要使用Artisan命令行、Jobs消息队列、 Rules验证规则、Restful API、Composer扩展包、Redis秒杀、Extend自定义扩展类:钉钉告警推送、MongoDB、阿里云OSS、php-jwt TOKEN、Phpoffice等技术。
3+
4+
## 项目截图
5+
##### 登录界面
6+
![](https://sobj.oss-cn-beijing.aliyuncs.com/image/20201022/login.png)
7+
##### 数据大屏
8+
![](https://sobj.oss-cn-beijing.aliyuncs.com/image/20201022/dataV.png)
9+
##### 权限管理
10+
![](https://sobj.oss-cn-beijing.aliyuncs.com/image/20201022/menu.png)
11+
12+
13+
## 后端安装步骤
14+
- git clone https://github.com/wdjisn/laravel-admin.git
15+
- 复制 .env.example 配置文件为 .env 并修改为自己的配置
16+
- composer update
17+
- 数据表初始化 php artisan createTable
18+
- 管理员初始化 php artisan adminInitialize admin(账号) --password=123456(密码)
19+
20+
21+
## 后端目录简介
22+
```
23+
├── app
24+
│ ├── Console
25+
│ ├── ├── Commands 命令行
26+
│ ├── ├── ├── CreateTable.php 初始化数据表
27+
│ ├── ├── ├── AdminInitialize.php 初始化超管员
28+
│ ├── Exceptions
29+
│ ├── ├── Handler.php 捕获异常并推送至钉钉
30+
│ ├── Extend 自定义扩展类
31+
│ ├── Helpers
32+
│ ├── ├── function.php 自定义常用函数
33+
│ ├── Http 控制器层
34+
│ ├── Jobs 消息队列
35+
│ ├── Model 模型层
36+
│ ├── Rules 验证规则
37+
│ ├── Service 服务层
38+
├── docs 自定义文档
39+
├── routes
40+
│ ├── admin.php 管理后台路由
41+
├── .env 配置文件
42+
├── composer.json
43+
├── README.md
44+
```
45+
46+
## 前端仓库地址
47+
- https://github.com/wdjisn/vue-admin.git
+117
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
<?php
2+
3+
namespace App\Console\Commands;
4+
5+
use App\Model\Role;
6+
use App\Model\Menu;
7+
use App\Model\Admin;
8+
use App\Service\AdminService;
9+
use Illuminate\Console\Command;
10+
use Illuminate\Support\Facades\DB;
11+
12+
class AdminInitialize extends Command
13+
{
14+
15+
# 运行命令示例:php artisan adminInitialize admin --password=123456
16+
17+
/**
18+
* The name and signature of the console command.
19+
*
20+
* @var string
21+
*/
22+
protected $signature = 'adminInitialize {username} {--password=}';
23+
24+
/**
25+
* The console command description.
26+
*
27+
* @var string
28+
*/
29+
protected $description = 'background management system initialization';
30+
31+
/**
32+
* Create a new command instance.
33+
*
34+
* @return void
35+
*/
36+
public function __construct()
37+
{
38+
parent::__construct();
39+
}
40+
41+
/**
42+
* Execute the console command.
43+
*
44+
* @return mixed
45+
*/
46+
public function handle()
47+
{
48+
$username = $this->argument('username');
49+
$password = $this->option('password');
50+
if (empty($username) || empty($password)) {
51+
$this->info('参数错误');
52+
return false;
53+
}
54+
55+
# 验证是否有管理员
56+
$count = Admin::getCount();
57+
if ($count) {
58+
$this->info('管理员已存在,请勿重复初始化');
59+
return false;
60+
}
61+
62+
DB::beginTransaction();
63+
try {
64+
# 初始化角色
65+
$role['name'] = '超级管理员';
66+
$role['is_admin'] = 1;
67+
$role['created_by'] = 0;
68+
$roleId = Role::addRole($role);
69+
70+
# 初始化超管员
71+
AdminService::addAdmin($username,$password,$roleId);
72+
73+
# 初始化菜单
74+
$permission = [
75+
['name' => '管理员','alias' => 'admin','icon' => ''],
76+
['name' => '角色管理','alias' => 'role','icon' => ''],
77+
['name' => '菜单管理','alias' => 'menus','icon' => '']
78+
];
79+
$log = [
80+
['name' => '错误日志','alias' => 'errorLog','icon' => ''],
81+
['name' => '登录日志','alias' => 'loginLog','icon' => ''],
82+
['name' => '访问日志','alias' => 'requestLog','icon' => '']
83+
];
84+
$menu = [
85+
['name' => '系统首页','alias' => 'dashboard','icon' => 'el-icon-lx-home','children' => []],
86+
['name' => '权限管理','alias' => 'permission','icon' => 'el-icon-setting','children' => $permission],
87+
['name' => '日志管理','alias' => 'log','icon' => 'el-icon-document-remove','children' => $log]
88+
];
89+
foreach ($menu as $val) {
90+
$data['parent_id'] = 0;
91+
$data['name'] = $val['name'];
92+
$data['alias'] = $val['alias'];
93+
$data['icon'] = $val['icon'];
94+
$data['sort'] = 0;
95+
$pid = Menu::addMenu($data);
96+
$children = $val['children'];
97+
if (count($children)) {
98+
foreach ($children as $k=>$v) {
99+
$data['parent_id'] = $pid;
100+
$data['name'] = $v['name'];
101+
$data['alias'] = $v['alias'];
102+
$data['icon'] = $v['icon'];
103+
$data['sort'] = $k;
104+
Menu::addMenu($data);
105+
}
106+
}
107+
}
108+
DB::commit();
109+
$this->info('初始化成功');
110+
return true;
111+
}catch (\Exception $e) {
112+
DB::rollBack();
113+
$this->info('初始化失败:'.$e->getMessage());
114+
return true;
115+
}
116+
}
117+
}

0 commit comments

Comments
 (0)