mirror of https://gitee.com/karson/fastadmin.git
parent
4135f48547
commit
40c24b7131
|
|
@ -494,25 +494,34 @@ CREATE TABLE `fa_user_rule` (
|
|||
`updatetime` int(10) DEFAULT NULL COMMENT '更新时间',
|
||||
`weigh` int(10) DEFAULT '0' COMMENT '权重',
|
||||
`status` enum('normal','hidden') DEFAULT NULL COMMENT '状态',
|
||||
`icon` char(30) NOT NULL DEFAULT 'fa fa-circle-o' COMMENT '图标',
|
||||
`condition` varchar(255) NOT NULL DEFAULT '' COMMENT '条件',
|
||||
`type` enum('menu','file') NOT NULL DEFAULT 'file' COMMENT 'menu为菜单,file为权限节点',
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=13 DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT COMMENT='会员规则表';
|
||||
|
||||
-- ----------------------------
|
||||
-- Records of fa_user_rule
|
||||
-- ----------------------------
|
||||
#
|
||||
# 修改用户规则表相应记录
|
||||
#
|
||||
BEGIN;
|
||||
INSERT INTO `fa_user_rule` VALUES (1, 0, 'index', '前台', '', 1, 1516168079, 1516168079, 1, 'normal');
|
||||
INSERT INTO `fa_user_rule` VALUES (2, 0, 'api', 'API接口', '', 1, 1516168062, 1516168062, 2, 'normal');
|
||||
INSERT INTO `fa_user_rule` VALUES (3, 1, 'user', '会员模块', '', 1, 1515386221, 1516168103, 12, 'normal');
|
||||
INSERT INTO `fa_user_rule` VALUES (4, 2, 'user', '会员模块', '', 1, 1515386221, 1516168092, 11, 'normal');
|
||||
INSERT INTO `fa_user_rule` VALUES (5, 3, 'index/user/login', '登录', '', 0, 1515386247, 1515386247, 5, 'normal');
|
||||
INSERT INTO `fa_user_rule` VALUES (6, 3, 'index/user/register', '注册', '', 0, 1515386262, 1516015236, 7, 'normal');
|
||||
INSERT INTO `fa_user_rule` VALUES (7, 3, 'index/user/index', '会员中心', '', 0, 1516015012, 1516015012, 9, 'normal');
|
||||
INSERT INTO `fa_user_rule` VALUES (8, 3, 'index/user/profile', '个人资料', '', 0, 1516015012, 1516015012, 4, 'normal');
|
||||
INSERT INTO `fa_user_rule` VALUES (9, 4, 'api/user/login', '登录', '', 0, 1515386247, 1515386247, 6, 'normal');
|
||||
INSERT INTO `fa_user_rule` VALUES (10, 4, 'api/user/register', '注册', '', 0, 1515386262, 1516015236, 8, 'normal');
|
||||
INSERT INTO `fa_user_rule` VALUES (11, 4, 'api/user/index', '会员中心', '', 0, 1516015012, 1516015012, 10, 'normal');
|
||||
INSERT INTO `fa_user_rule` VALUES (12, 4, 'api/user/profile', '个人资料', '', 0, 1516015012, 1516015012, 3, 'normal');
|
||||
INSERT INTO `fa_user_rule` (`id`,`pid`,`name`,`title`,`remark`,`ismenu`,`createtime`,`updatetime`,`weigh`,`status`,`icon`,`condition`,`type`) VALUES
|
||||
(1,0,'dashboard','Dashboard','Dashboard tips',1,1516168079,1516168079,99,'normal','fa fa-dashboard','','file'),
|
||||
(2,0,'api','API接口','',1,1516168062,1537758838,2,'hidden','','','file'),
|
||||
(3,1,'dashboard/index','View','',0,1515386247,1515386247,5,'normal','fa fa-circle-o','','file'),
|
||||
(4,2,'api/user','会员模块','',1,1515386221,1537758859,11,'hidden','','','file'),
|
||||
(5,0,'user','User center','',1,1515386262,1516015236,7,'normal','fa fa-user-o','','file'),
|
||||
(6,5,'user/profile','Profile','',1,1516015012,1516015012,10,'normal','fa fa-circle-o','','file'),
|
||||
(7,6,'user/profile/index','View','',0,1516015012,1516015012,4,'normal','fa fa-circle-o','','file'),
|
||||
(8,6,'user/profile/edit','Edit','',0,1516015012,1516015012,4,'normal','fa fa-circle-o','','file'),
|
||||
(9,4,'api/user/login','登录','',0,1515386247,1537758859,6,'hidden','','','file'),
|
||||
(10,4,'api/user/register','注册','',0,1515386262,1537758859,8,'hidden','','','file'),
|
||||
(11,4,'api/user/index','会员中心','',0,1516015012,1537758859,10,'hidden','','','file'),
|
||||
(12,4,'api/user/profile','个人资料','',0,1516015012,1537758859,3,'hidden','','','file'),
|
||||
(13,5,'user/scorelog','积分日志','',1,1541045799,1541052272,9,'normal','fa fa-circle-o','','file'),
|
||||
(14,13,'user/scorelog/index','查看','',0,1541045799,1541050931,0,'normal','fa fa-circle-o','','file'),
|
||||
(15,5,'user/changepwd','Change password','',1,1541045799,1541056067,8,'normal','fa fa-circle-o','','file'),
|
||||
(16,15,'user/changepwd/index','View',NULL,0,1541045799,1541045799,0,'normal','fa fa-circle-o','','file'),
|
||||
(17,5,'user/log','User log','',1,1516015012,1541043105,7,'normal','fa fa-circle-o','','file'),
|
||||
(18,17,'user/log/index','View','',0,1516015012,1537758859,3,'normal','fa fa-circle-o','','file');
|
||||
COMMIT;
|
||||
|
||||
-- ----------------------------
|
||||
|
|
@ -587,41 +596,6 @@ CREATE TABLE `fa_user_log` (
|
|||
KEY `name` (`username`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=322 DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT COMMENT='用户日志';
|
||||
|
||||
#
|
||||
# 增加用户规则表字段
|
||||
#
|
||||
ALTER TABLE IF EXISTS `fa_user_rule`
|
||||
add `icon` char(30) NOT NULL DEFAULT 'fa fa-circle-o' COMMENT '图标',
|
||||
add `condition` varchar(255) NOT NULL DEFAULT '' COMMENT '条件',
|
||||
add `type` enum('menu','file') NOT NULL DEFAULT 'file' COMMENT 'menu为菜单,file为权限节点';
|
||||
#
|
||||
# 修改用户规则表相应记录
|
||||
#
|
||||
BEGIN;
|
||||
REPLACE INTO `fa_user_rule` (`id`,`pid`,`icon`,`name`,`title`,`condition`,`remark`,`type`,`ismenu`,`createtime`,`updatetime`,`weigh`,`status`) VALUES
|
||||
(1,0,'fa fa-dashboard','dashboard','Dashboard','','Dashboard tips','file',1,1516168079,1516168079,99,'normal'),
|
||||
(2,0,'','api','API接口','','','file',1,1516168062,1537758838,2,'hidden'),
|
||||
(3,1,'fa fa-circle-o','dashboard/index','View','','','file',0,1515386247,1515386247,5,'normal'),
|
||||
(4,2,'','api/user','会员模块','','','file',1,1515386221,1537758859,11,'hidden'),
|
||||
(5,0,'fa fa-user-o','user','User center','','','file',1,1515386262,1516015236,7,'normal'),
|
||||
(6,5,'fa fa-circle-o','user/profile','Profile','','','file',1,1516015012,1516015012,9,'normal'),
|
||||
(7,6,'fa fa-circle-o','user/profile/index','View','','','file',0,1516015012,1516015012,4,'normal'),
|
||||
(8,6,'fa fa-circle-o','user/profile/edit','Edit','','','file',0,1516015012,1516015012,4,'normal'),
|
||||
(9,4,'','api/user/login','登录','','','file',0,1515386247,1537758859,6,'hidden'),
|
||||
(10,4,'','api/user/register','注册','','','file',0,1515386262,1537758859,8,'hidden'),
|
||||
(11,4,'','api/user/index','会员中心','','','file',0,1516015012,1537758859,10,'hidden'),
|
||||
(12,4,'','api/user/profile','个人资料','','','file',0,1516015012,1537758859,3,'hidden');
|
||||
|
||||
INSERT INTO `fa_user_rule` (`id`,`pid`,`icon`,`name`,`title`,`condition`,`remark`,`type`,`ismenu`,`createtime`,`updatetime`,`weigh`,`status`) VALUES
|
||||
(13,5,'user/scorelog','积分日志','',1,1541045799,1541052272,8,'normal','fa fa-circle-o','','file'),
|
||||
(14,13,'user/scorelog/index','查看','',0,1541045799,1541050931,0,'normal','fa fa-circle-o','','file'),
|
||||
(15,5,'user/changepwd','Change password','',1,1541045799,1541056067,7,'normal','fa fa-circle-o','','file'),
|
||||
(16,15,'user/changepwd/index','View',NULL,0,1541045799,1541045799,0,'normal','fa fa-circle-o','','file'),
|
||||
(17,5,'user/log','User log','',1,1516015012,1541043105,6,'normal','fa fa-circle-o','','file'),
|
||||
(18,17,'user/log/index','View','',0,1516015012,1537758859,3,'normal','fa fa-circle-o','','file');
|
||||
|
||||
COMMIT;
|
||||
|
||||
#
|
||||
# 增加用户等级表
|
||||
#
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ class UserAuth
|
|||
//默认配置
|
||||
protected $config = [];
|
||||
protected $options = [];
|
||||
protected $allowFields = ['id', 'username', 'nickname', 'mobile', 'avatar', 'score'];
|
||||
protected $allowFields = ['nickname', 'mobile', 'avatar', 'score', 'bio'];
|
||||
//权限菜单
|
||||
protected $menus = [];
|
||||
//面包屑导航
|
||||
|
|
@ -486,7 +486,9 @@ class UserAuth
|
|||
*/
|
||||
public function addAllowFields($fields)
|
||||
{
|
||||
$this->allowFields .= $fields;
|
||||
$this->allowFields = array_merge(
|
||||
$this->allowFields, array_change_key_case($fields)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -786,44 +788,41 @@ class UserAuth
|
|||
* @access public
|
||||
* @param string|array $name 配置参数名(支持二级配置 . 号分割)
|
||||
* @param mixed $value 配置值
|
||||
* @param string $range 作用域
|
||||
* @return mixed
|
||||
* @return mixed 具有扩展属性的user对象
|
||||
*/
|
||||
public static function set($name, $value = null, $range = '')
|
||||
public function set($name, $value = null)
|
||||
{
|
||||
$range = $range ?: self::$range;
|
||||
|
||||
if (!isset(self::$_user[$range])) self::$_user[$range] = [];
|
||||
if (!isset($this->_user)) $this->_user = [];
|
||||
|
||||
// 字符串则表示单个配置设置
|
||||
if (is_string($name)) {
|
||||
if (!strpos($name, '.')) {
|
||||
self::$_user[$range][strtolower($name)] = $value;
|
||||
$this->_user[strtolower($name)] = $value;
|
||||
} else {
|
||||
// 二维数组
|
||||
$name = explode('.', $name, 2);
|
||||
self::$_user[$range][strtolower($name[0])][$name[1]] = $value;
|
||||
$this->_user[strtolower($name[0])][$name[1]] = $value;
|
||||
}
|
||||
return $value;
|
||||
}
|
||||
|
||||
// 数组则表示批量设置
|
||||
if (is_array($name)) {
|
||||
if (!empty($value)) {
|
||||
self::$_user[$range][$value] = isset(self::$_user[$range][$value]) ?
|
||||
array_merge(self::$_user[$range][$value], $name) :
|
||||
$name;
|
||||
|
||||
return self::$_user[$range][$value];
|
||||
}
|
||||
|
||||
return self::$_user[$range] = array_merge(
|
||||
self::$_user[$range], array_change_key_case($name)
|
||||
);
|
||||
foreach($name as $k=>$v){
|
||||
if (!strpos($k, '.')) {
|
||||
$this->_user[strtolower($k)] = $v;
|
||||
} else {
|
||||
// 二维数组
|
||||
$k = explode('.', $k, 2);
|
||||
$this->_user[strtolower($k[0])][$k[1]] = $v;
|
||||
}
|
||||
}
|
||||
return $this->_user;
|
||||
}
|
||||
|
||||
// 为空直接返回已有配置
|
||||
return self::$_user[$range];
|
||||
return $this->_user;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -837,7 +836,9 @@ class UserAuth
|
|||
if (!$rank) {
|
||||
return false;
|
||||
}
|
||||
return \think\Db::name('user_level')->where('level_id',$rank)->column('level_id,level_name,level_img');
|
||||
$lv = \think\Db::name('user_level')->where('level_id',$rank)->find();//->column('level_id,level_name,level_img');
|
||||
$this->addAllowFields(['level_name','level_img']);
|
||||
return $this->set(['level_name'=>$lv['level_name'],'level_img'=>$lv['level_img']]);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ class Profile extends Userend
|
|||
{
|
||||
//设置过滤方法
|
||||
$this->request->filter(['strip_tags']);
|
||||
$this->assign('level',$this->auth->getLevel());
|
||||
$this->assign('user',$this->auth->getLevel());
|
||||
return $this->view->fetch('user/profile');
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@
|
|||
<button id="plupload-avatar" class="plupload" data-mimetype="png,jpg,jpeg,gif" data-input-id="c-avatar"><i class="fa fa-upload"></i> {:__('Upload')}</button>
|
||||
</div>
|
||||
<h3 class="profile-username text-center">{$user.username}
|
||||
<img width="20" height="20" src="__CDN__{$level[$user['level']]['level_img']}" title="{$level[$user['level']]['level_name']}"/>
|
||||
<img width="20" height="20" src="__CDN__{$user.level_img}" title="{$user.level_name}"/>
|
||||
</h3>
|
||||
<div class="form-group">
|
||||
<label class="control-label">{:__('Nickname')}:</label>
|
||||
|
|
|
|||
Loading…
Reference in New Issue