Skip to content

Commit 17f642f

Browse files
committed
添加面板首页
1 parent 4b5af7e commit 17f642f

File tree

17 files changed

+546
-57
lines changed

17 files changed

+546
-57
lines changed

application/index/controller/Auth.php

Lines changed: 4 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -8,68 +8,20 @@
88

99
namespace app\index\controller;
1010

11-
use app\index\service\ServiceResult;
12-
use think\captcha\Captcha;
13-
use app\index\service\Auth as AuthService;
1411

1512
class Auth extends Base
1613
{
17-
protected $user_id = 0;
18-
protected $username = '';
1914

2015
protected function initialize()
2116
{
2217
parent::initialize();
23-
$auth = AuthService::getAuth();
2418

25-
$this->user_id = $auth['id'];
26-
$this->username = $auth['username'];
2719

28-
}
29-
30-
public function verify()
31-
{
32-
$config = [
33-
'length' => 4,
34-
// 验证码字体大小
35-
'fontSize' => 30,
36-
// 验证码字体大小(px)
37-
'useCurve' => false,
38-
39-
'codeSet'=>'1234567890',
40-
];
41-
$captcha = new Captcha($config);
42-
43-
$id = $this->request->param('id','');
44-
return $captcha->entry($id);
45-
}
46-
47-
48-
public function login()
49-
{
50-
51-
$login = AuthService::login($this->request->param('username'),
52-
$this->request->param('password')
53-
);
54-
55-
return $login;
56-
}
57-
58-
public function register()
59-
{
60-
if(!captcha_check($this->request->param('code')))
20+
if(!$this->isLogin())
6121
{
62-
return ServiceResult::Error('验证码错误');
22+
header('Location:'.$this->request->domain());
23+
exit;
6324
}
64-
65-
66-
67-
$register = AuthService::register(
68-
$this->request->param('username'),
69-
$this->request->param('password'),
70-
$this->request->param('email')
71-
);
72-
73-
return $register;
7425
}
26+
7527
}

application/index/controller/Base.php

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,78 @@
88

99
namespace app\index\controller;
1010

11+
use app\index\service\ServiceResult;
12+
use think\captcha\Captcha;
1113
use Lang;
14+
use app\index\service\Auth as AuthService;
1215

1316
class Base extends Error
1417
{
18+
19+
protected $user_id = 0;
20+
protected $username = '';
21+
22+
1523
protected function initialize()
1624
{
1725
Lang::setAllowLangList(['zh-cn','en-us']);
26+
27+
$auth = AuthService::getAuth();
28+
29+
$this->user_id = $auth['id'];
30+
$this->username = $auth['username'];
31+
32+
33+
}
34+
35+
public function verify()
36+
{
37+
$config = [
38+
'length' => 4,
39+
// 验证码字体大小
40+
'fontSize' => 30,
41+
// 验证码字体大小(px)
42+
'useCurve' => false,
43+
44+
'codeSet'=>'1234567890',
45+
];
46+
$captcha = new Captcha($config);
47+
48+
$id = $this->request->param('id','');
49+
return $captcha->entry($id);
50+
}
51+
52+
53+
public function login()
54+
{
55+
56+
$login = AuthService::login($this->request->param('username'),
57+
$this->request->param('password')
58+
);
59+
60+
return $login;
61+
}
62+
63+
public function register()
64+
{
65+
if(!captcha_check($this->request->param('code')))
66+
{
67+
return ServiceResult::Error('验证码错误');
68+
}
69+
70+
71+
72+
$register = AuthService::register(
73+
$this->request->param('username'),
74+
$this->request->param('password'),
75+
$this->request->param('email')
76+
);
77+
78+
return $register;
79+
}
80+
81+
protected function isLogin()
82+
{
83+
return $this->user_id > 0;
1884
}
1985
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?php
2+
/**
3+
* Created by PhpStorm.
4+
* User: zhangcheng
5+
* Date: 2017/12/17 0017
6+
* Time: 22:27
7+
*/
8+
9+
namespace app\index\controller;
10+
11+
12+
class Dashboard extends Auth
13+
{
14+
public function index()
15+
{
16+
17+
return view('dashboard/index');
18+
}
19+
}

application/index/controller/User.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
namespace app\index\controller;
1010

11-
class User extends Auth
11+
class User extends Base
1212
{
1313
public function login()
1414
{

application/index/model/Bug.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?php
2+
/**
3+
* Created by PhpStorm.
4+
* User: zhangcheng
5+
* Date: 2017/12/17 0017
6+
* Time: 22:22
7+
*/
8+
9+
namespace app\index\model;
10+
11+
12+
class Bug extends BaseModel
13+
{
14+
15+
}

application/index/model/BugLog.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
2+
<?php
3+
/**
4+
* Created by PhpStorm.
5+
* User: zhangcheng
6+
* Date: 2017/12/17 0017
7+
* Time: 22:23
8+
*/
9+
10+
namespace app\index\model;
11+
12+
13+
class BugLog extends BaseModel
14+
{
15+
16+
}

application/index/model/Project.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?php
2+
/**
3+
* Created by PhpStorm.
4+
* User: zhangcheng
5+
* Date: 2017/12/17 0017
6+
* Time: 22:17
7+
*/
8+
9+
namespace app\index\model;
10+
11+
12+
class Project extends BaseModel
13+
{
14+
15+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?php
2+
/**
3+
* Created by PhpStorm.
4+
* User: zhangcheng
5+
* Date: 2017/12/17 0017
6+
* Time: 22:22
7+
*/
8+
9+
namespace app\index\model;
10+
11+
12+
class ProjectModule extends BaseModel
13+
{
14+
15+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?php
2+
/**
3+
* Created by PhpStorm.
4+
* User: zhangcheng
5+
* Date: 2017/12/17 0017
6+
* Time: 22:22
7+
*/
8+
9+
namespace app\index\model;
10+
11+
12+
class ProjectUser extends BaseModel
13+
{
14+
15+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?php
2+
/**
3+
* Created by PhpStorm.
4+
* User: zhangcheng
5+
* Date: 2017/12/17 0017
6+
* Time: 22:22
7+
*/
8+
9+
namespace app\index\model;
10+
11+
12+
class ProjectVersion extends BaseModel
13+
{
14+
15+
}

application/index/model/UserLog.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?php
2+
/**
3+
* Created by PhpStorm.
4+
* User: zhangcheng
5+
* Date: 2017/12/17 0017
6+
* Time: 22:23
7+
*/
8+
9+
namespace app\index\model;
10+
11+
12+
class UserLog extends BaseModel
13+
{
14+
15+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{extend name="extend/main" /}
2+
{block name="content"}
3+
4+
{/block}

0 commit comments

Comments
 (0)