Skip to content

Commit 1142017

Browse files
committed
新增:后台管理菜单增加拖拽,优化显示
1 parent 12e62cf commit 1142017

255 files changed

Lines changed: 2449 additions & 512 deletions

File tree

Some content is hidden

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

app/Constant/AppConstant.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@ class AppConstant
66
{
77
const APP = 'cms9';
88
const APP_NAME = 'ModStartCMS9';
9-
const VERSION = '8.2.0';
9+
const VERSION = '8.3.0';
1010
}

module/AdminManager/Core/ModuleServiceProvider.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,21 +24,21 @@ public function boot(Dispatcher $events)
2424
'sort' => 500,
2525
'children' => [
2626
[
27-
'title' => L('Admin Role'),
28-
'url' => '\ModStart\Admin\Controller\AdminRoleController@index',
27+
'title' => L('Admin User'),
28+
'url' => '\ModStart\Admin\Controller\AdminUserController@index',
2929
],
3030
[
31-
'title' => L('Admin Role Manage'),
32-
'rule' => 'AdminRoleManage',
31+
'title' => L('Admin User Manage'),
32+
'rule' => 'AdminUserManage',
3333
'hide' => true,
3434
],
3535
[
36-
'title' => L('Admin User'),
37-
'url' => '\ModStart\Admin\Controller\AdminUserController@index',
36+
'title' => L('Admin Role'),
37+
'url' => '\ModStart\Admin\Controller\AdminRoleController@index',
3838
],
3939
[
40-
'title' => L('Admin User Manage'),
41-
'rule' => 'AdminUserManage',
40+
'title' => L('Admin Role Manage'),
41+
'rule' => 'AdminRoleManage',
4242
'hide' => true,
4343
],
4444
[

module/AdminManager/Traits/AdminDashboardTrait.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,15 @@
1616
*/
1717
trait AdminDashboardTrait
1818
{
19-
public function dashboard()
19+
public function dashboard($callback = null)
2020
{
2121
/** @var AdminPage $page */
2222
$page = app(AdminPage::class);
2323
$page->pageTitle(L('Dashboard'));
2424
$page->row(new SecurityTooltipBox());
25+
if ($callback) {
26+
call_user_func($callback, $page);
27+
}
2528
$page->append(new Row(function (Row $row) {
2629
AdminWidgetDashboard::callIcon($row);
2730
}));

module/Member/Admin/Controller/MemberController.php

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
namespace Module\Member\Admin\Controller;
55

66
use Illuminate\Routing\Controller;
7+
use Illuminate\Support\Facades\Session;
78
use ModStart\Admin\Auth\AdminPermission;
89
use ModStart\Admin\Concern\HasAdminQuickCRUD;
910
use ModStart\Admin\Layout\AdminConfigBuilder;
@@ -35,6 +36,7 @@
3536
use ModStart\Support\Concern\HasFields;
3637
use ModStart\Widget\Box;
3738
use ModStart\Widget\TextDialogRequest;
39+
use ModStart\Widget\TextLink;
3840
use Module\Member\Config\MemberAdminList;
3941
use Module\Member\Config\MemberOauth;
4042
use Module\Member\Events\MemberUserRegisteredEvent;
@@ -172,8 +174,17 @@ protected function crud(AdminCRUDBuilder $builder)
172174
'primary',
173175
'查看',
174176
modstart_admin_url('member/show', ['_id' => $item->id])
175-
)->width('90%')->height('90%')->render()
177+
)->width('90%')->height('90%')
176178
);
179+
if (ModuleManager::getModuleConfig('Member', 'adminLoginEnable', false)) {
180+
$itemOperate->prepend(
181+
TextLink::make(
182+
'primary',
183+
'登录',
184+
modstart_admin_url('member/login', ['_id' => $item->id])
185+
)->attr('target="_blank"')
186+
);
187+
}
177188
})
178189
->title('用户管理')
179190
->canShow(false)
@@ -182,6 +193,16 @@ protected function crud(AdminCRUDBuilder $builder)
182193
->canExport(ModuleManager::getModuleConfig('Member', 'exportEnable', false));
183194
}
184195

196+
public function login()
197+
{
198+
BizException::throwsIf('后台一键登录 未开启', !ModuleManager::getModuleConfig('Member', 'adminLoginEnable', false));
199+
AdminPermission::demoCheck();
200+
$record = MemberUtil::get(CRUDUtil::id());
201+
BizException::throwsIfEmpty('用户不存在', $record);
202+
Session::put('memberUserId', $record['id']);
203+
return Response::redirect(modstart_web_url(''));
204+
}
205+
185206
public function selectRemote()
186207
{
187208
return Select::optionRemoteHandleModel('member_user', 'id', 'username');

module/Member/Admin/Controller/MemberDashboardController.php

Lines changed: 142 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -6,56 +6,160 @@
66

77
use Illuminate\Routing\Controller;
88
use ModStart\Admin\Layout\AdminPage;
9-
use ModStart\Admin\Widget\DashboardItemA;
9+
use ModStart\Admin\Widget\DashboardItem;
1010
use ModStart\Core\Dao\ModelUtil;
11-
use ModStart\Core\Util\ColorUtil;
11+
use ModStart\Core\Input\InputPackage;
12+
use ModStart\Core\Util\CRUDUtil;
1213
use ModStart\Core\Util\TimeUtil;
1314
use ModStart\Layout\Row;
1415
use ModStart\Widget\Box;
1516
use ModStart\Widget\Chart\Line;
17+
use ModStart\Widget\Nav;
18+
use Module\Member\Admin\Widget\DashboardDaily;
19+
use Module\Member\Model\MemberLoginLog;
20+
use Module\Member\Model\MemberUser;
1621

1722
class MemberDashboardController extends Controller
1823
{
1924
public function index(AdminPage $page)
2025
{
21-
$page->pageTitle('用户统计');
22-
$report = [];
23-
$report['yesterdayCount'] = ModelUtil::model('member_user')
24-
->where('created_at', '>=', TimeUtil::yesterdayStart())
25-
->where('created_at', '<=', TimeUtil::yesterdayEnd())
26-
->where(['isDeleted' => false])
27-
->count();
28-
29-
$w = date('w');
30-
if ($w == 0) {
31-
$w = 7;
32-
}
33-
$lastWeek = time() - TimeUtil::PERIOD_DAY * 7 - TimeUtil::PERIOD_DAY * ($w - 1);
34-
$report['lastWeekCount'] = ModelUtil::model('member_user')
35-
->where('created_at', '>=', date('Y-m-d 00:00:00', $lastWeek))
36-
->where('created_at', '<=', date('Y-m-d 23:59:59', $lastWeek + TimeUtil::PERIOD_DAY * 7))
37-
->where(['isDeleted' => false])
38-
->count();
39-
$page->row(function (Row $row) use ($report) {
40-
$row->column(4, DashboardItemA::makeIconNumberTitle(
41-
'iconfont icon-user', ModelUtil::count('member_user'), '用户总数',
42-
modstart_admin_url('member'), ColorUtil::randomColor()
43-
));
44-
$row->column(4, DashboardItemA::makeIconNumberTitle(
45-
'iconfont icon-user', $report['yesterdayCount'], '昨日增长',
46-
modstart_admin_url('member'), ColorUtil::randomColor()
47-
));
48-
$row->column(4, DashboardItemA::makeIconNumberTitle(
49-
'iconfont icon-user', $report['lastWeekCount'], '上周增长',
50-
modstart_admin_url('member'), ColorUtil::randomColor()
51-
));
52-
});
53-
$page->append(Box::make(Line::make()->tableDailyCountLatest(
26+
$input = InputPackage::buildFromInput();
27+
$type = $input->getTrimString('type', 'report');
28+
$page->pageTitle('用户数据');
29+
$page->append(Nav::make([
5430
[
55-
['title' => '总数', 'table' => 'member_user', 'where' => ['isDeleted' => false]],
31+
'title' => '统计报表',
32+
'url' => CRUDUtil::adminUrlWithTab('member/dashboard', ['type' => 'report']),
33+
'active' => $type == 'report',
5634
],
57-
30
58-
), '会员增长趋势'));
35+
[
36+
'title' => '每日明细',
37+
'url' => CRUDUtil::adminUrlWithTab('member/dashboard', ['type' => 'daily']),
38+
'active' => $type == 'daily',
39+
]
40+
], 'margin-bottom'));
41+
42+
switch ($type) {
43+
case 'daily':
44+
$page->append(new DashboardDaily());
45+
break;
46+
default:
47+
$report = [];
48+
$report['todayCount'] = MemberUser::query()
49+
->where('created_at', '>=', TimeUtil::todayStart())
50+
->where('created_at', '<=', TimeUtil::todayEnd())
51+
->where(['isDeleted' => false])
52+
->count();
53+
$report['yesterdayCount'] = MemberUser::query()
54+
->where('created_at', '>=', TimeUtil::yesterdayStart())
55+
->where('created_at', '<=', TimeUtil::yesterdayEnd())
56+
->where(['isDeleted' => false])
57+
->count();
58+
$report['todayLoginCount'] = MemberLoginLog::query()
59+
->where('created_at', '>=', TimeUtil::todayStart())
60+
->where('created_at', '<=', TimeUtil::todayEnd())
61+
->count();
62+
$report['yesterdayLoginCount'] = MemberLoginLog::query()
63+
->where('created_at', '>=', TimeUtil::yesterdayStart())
64+
->where('created_at', '<=', TimeUtil::yesterdayEnd())
65+
->count();
66+
$w = date('w');
67+
if ($w == 0) {
68+
$w = 7;
69+
}
70+
$thisWeek = time() - TimeUtil::PERIOD_DAY * ($w - 1);
71+
$lastWeek = time() - TimeUtil::PERIOD_DAY * 7 - TimeUtil::PERIOD_DAY * ($w - 1);
72+
$report['thisWeekCount'] = MemberUser::query()
73+
->where('created_at', '>=', date('Y-m-d 00:00:00', $thisWeek))
74+
->where(['isDeleted' => false])
75+
->count();
76+
$report['lastWeekCount'] = MemberUser::query()
77+
->where('created_at', '>=', date('Y-m-d 00:00:00', $lastWeek))
78+
->where('created_at', '<=', date('Y-m-d 23:59:59', $lastWeek + TimeUtil::PERIOD_DAY * 7))
79+
->where(['isDeleted' => false])
80+
->count();
81+
$report['thisWeekLoginCount'] = MemberLoginLog::query()
82+
->where('created_at', '>=', date('Y-m-d 00:00:00', $thisWeek))
83+
->count();
84+
$report['lastWeekLoginCount'] = MemberLoginLog::query()
85+
->where('created_at', '>=', date('Y-m-d 00:00:00', $lastWeek))
86+
->where('created_at', '<=', date('Y-m-d 23:59:59', $lastWeek + TimeUtil::PERIOD_DAY * 7))
87+
->count();
88+
89+
$page->row(function (Row $row) use ($report) {
90+
$row->flexColumn(DashboardItem::makeTitleDataList(
91+
'iconfont icon-users',
92+
'概况',
93+
[
94+
[
95+
'title' => '用户总数',
96+
'value' => ModelUtil::count('member_user'),
97+
'url' => modstart_admin_url('member'),
98+
],
99+
]
100+
));
101+
$row->flexColumn(DashboardItem::makeTitleDataList(
102+
'iconfont icon-users',
103+
'注册人数',
104+
[
105+
[
106+
'title' => '今日',
107+
'value' => $report['todayCount'],
108+
'url' => modstart_admin_url('member'),
109+
],
110+
[
111+
'title' => '昨日',
112+
'value' => $report['yesterdayCount'],
113+
'url' => modstart_admin_url('member'),
114+
],
115+
[
116+
'title' => '本周',
117+
'value' => $report['thisWeekCount'],
118+
'url' => modstart_admin_url('member'),
119+
],
120+
[
121+
'title' => '上周',
122+
'value' => $report['lastWeekCount'],
123+
'url' => modstart_admin_url('member'),
124+
],
125+
]
126+
));
127+
$row->flexColumn(DashboardItem::makeTitleDataList(
128+
'iconfont icon-users',
129+
'登录人次',
130+
[
131+
[
132+
'title' => '今日',
133+
'value' => $report['todayLoginCount'],
134+
'url' => modstart_admin_url('member'),
135+
],
136+
[
137+
'title' => '昨日',
138+
'value' => $report['yesterdayLoginCount'],
139+
'url' => modstart_admin_url('member'),
140+
],
141+
[
142+
'title' => '本周',
143+
'value' => $report['thisWeekLoginCount'],
144+
'url' => modstart_admin_url('member'),
145+
],
146+
[
147+
'title' => '上周',
148+
'value' => $report['lastWeekLoginCount'],
149+
'url' => modstart_admin_url('member'),
150+
],
151+
]
152+
));
153+
});
154+
$page->append(Box::make(Line::make()->tableDailyCountLatest(
155+
[
156+
['title' => '总数', 'table' => 'member_user', 'where' => ['isDeleted' => false]],
157+
],
158+
30
159+
), '会员增长趋势'));
160+
break;
161+
}
162+
59163
return $page;
60164
}
61165
}

0 commit comments

Comments
 (0)