更换后台UI,使用adminlteUI
This commit is contained in:
@@ -13,11 +13,57 @@ use think\facade\Filesystem;
|
||||
|
||||
class Upload extends Base {
|
||||
|
||||
// 使用内置PHP模板引擎渲染模板输出
|
||||
protected $tpl_config = [
|
||||
'view_dir_name' => 'viewlte',
|
||||
'tpl_replace_string' => [
|
||||
'__static__' => '/static',
|
||||
'__img__' => '/static/admin/images',
|
||||
'__css__' => '/static/admin/css',
|
||||
'__js__' => '/static/admin/js',
|
||||
'__plugins__' => '/static/plugins',
|
||||
'__public__' => '/static/admin',
|
||||
],
|
||||
];
|
||||
|
||||
public $data = ['data' => [], 'code' => 0, 'msg' => ''];
|
||||
|
||||
protected function initialize() {
|
||||
}
|
||||
|
||||
public function index(){
|
||||
$param = $this->request->get();
|
||||
|
||||
if (!isset($param['name'])) {
|
||||
return $this->error('非法操作');
|
||||
}
|
||||
$this->data = [
|
||||
'from' => $this->request->param('from'),
|
||||
'param' => $param,
|
||||
'require' => [
|
||||
'jsname' => 'upload',
|
||||
'actionname' => 'index'
|
||||
]
|
||||
];
|
||||
return $this->fetch();
|
||||
}
|
||||
|
||||
public function server(){
|
||||
$param = $this->request->get();
|
||||
if (!isset($param['name'])) {
|
||||
return $this->error('非法操作');
|
||||
}
|
||||
$this->data = [
|
||||
'from' => $this->request->param('from'),
|
||||
'param' => $param,
|
||||
'require' => [
|
||||
'jsname' => 'upload',
|
||||
'actionname' => 'server'
|
||||
]
|
||||
];
|
||||
return $this->fetch();
|
||||
}
|
||||
|
||||
public function upload(){
|
||||
$upload_type = $this->request->get('filename', 'images', 'trim');
|
||||
$config = $this->$upload_type();
|
||||
@@ -26,10 +72,10 @@ class Upload extends Base {
|
||||
try {
|
||||
validate(['file'=>'filesize:10240|fileExt:jpg|image:200,200,jpg'])
|
||||
->check([$file]);
|
||||
$data['status'] = 1;
|
||||
$data['code'] = 1;
|
||||
$data['info'] = $this->save($file, $upload_type);
|
||||
} catch (think\exception\ValidateException $e) {
|
||||
$data['status'] = 0;
|
||||
$data['code'] = 0;
|
||||
$data['info'] = $e->getMessage();
|
||||
}
|
||||
return json($data);
|
||||
|
||||
@@ -21,6 +21,7 @@ class Base extends BaseC {
|
||||
|
||||
// 使用内置PHP模板引擎渲染模板输出
|
||||
protected $tpl_config = [
|
||||
'view_dir_name' => 'view',
|
||||
'tpl_replace_string' => [
|
||||
'__static__' => '/static',
|
||||
'__img__' => '/static/admin/images',
|
||||
@@ -141,6 +142,7 @@ class Base extends BaseC {
|
||||
}
|
||||
|
||||
protected function getMenu() {
|
||||
$addon = $this->request->param('addon', false);
|
||||
$hover_url = str_replace(".", "/", strtolower($this->request->controller()));
|
||||
$controller = str_replace(".", "/", strtolower($this->request->controller()));
|
||||
$menu = array(
|
||||
@@ -161,7 +163,7 @@ class Base extends BaseC {
|
||||
unset($menu['main'][$value['id']]);
|
||||
continue; //继续循环
|
||||
}
|
||||
if ($controller == $value['url']) {
|
||||
if (false !== strripos($controller, $value['url'])) {
|
||||
$value['style'] = "active";
|
||||
}
|
||||
$menu['main'][$value['id']] = $value;
|
||||
@@ -175,6 +177,11 @@ class Base extends BaseC {
|
||||
//内容管理菜单
|
||||
$pid = Menu::where("pid =0 AND url like '%admin/category%'")->value('id');
|
||||
}
|
||||
if ($addon) {
|
||||
//扩展管理菜单
|
||||
$pid = Menu::where("pid =0 AND url like '%admin/addons%'")->value('id');
|
||||
$this->getAddonsMenu();
|
||||
}
|
||||
if ($pid) {
|
||||
$map['pid'] = $pid;
|
||||
$map['hide'] = 0;
|
||||
|
||||
@@ -49,7 +49,8 @@ class Content extends Base {
|
||||
'list' => $list,
|
||||
'page' => $list->render(),
|
||||
'model_name' => $this->modelInfo['name'],
|
||||
'model_id' => $this->modelInfo['id']
|
||||
'model_id' => $this->modelInfo['id'],
|
||||
'meta_title' => $this->modelInfo['title'].'列表'
|
||||
);
|
||||
if ($this->modelInfo['template_list']) {
|
||||
$template = 'admin/content/' . $this->modelInfo['template_list'];
|
||||
@@ -74,11 +75,12 @@ class Content extends Base {
|
||||
} else {
|
||||
$info = [
|
||||
'model_name' => $this->modelInfo['name'],
|
||||
'model_id' => $this->modelInfo['id'],
|
||||
'model_id' => $this->modelInfo['id']
|
||||
];
|
||||
$this->data = [
|
||||
'info' => $info,
|
||||
'fieldGroup' => Attribute::getField($this->modelInfo),
|
||||
'meta_title' => $this->modelInfo['title'].'添加'
|
||||
];
|
||||
|
||||
if ($this->modelInfo['template_add']) {
|
||||
@@ -114,6 +116,7 @@ class Content extends Base {
|
||||
$this->data = array(
|
||||
'info' => $info,
|
||||
'fieldGroup' => Attribute::getField($this->modelInfo, 'edit'),
|
||||
'meta_title' => $this->modelInfo['title'].'修改'
|
||||
);
|
||||
if ($this->modelInfo['template_edit']) {
|
||||
$template = 'admin/content/' . $this->modelInfo['template_edit'];
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
<div class="picker-box">
|
||||
<div id="picker_{$name}" class="btn btn-primary picker_button" data-type="file" data-limit="1"><i class="fa fa-upload"></i> 上传文件</div>
|
||||
{if isset($value) && $value}
|
||||
<input type="hidden" name="{$name}" id="field_{$name}" value="{$value}">
|
||||
{else/}
|
||||
<input type="hidden" name="{$name}" id="field_{$name}" value="">
|
||||
{/if}
|
||||
<div id="fileList_{$name}" class="upload-file-list-info" style="width:280px;">
|
||||
{if $value}
|
||||
{php}
|
||||
$images = get_file($value);
|
||||
{/php}
|
||||
<li class="affix-list-item" id="WU_FILE_0">
|
||||
<div class="upload-file-info">
|
||||
<span class="webuploader-pick-file-close" data-queued-id="WU_FILE_0" data-id="{$value}" data-fileurl="{$images['path']}"><i class="close"></i></span>
|
||||
<span class="fname"></span>
|
||||
<span class="fsize">上传时间:{$images['create_time']}</span>
|
||||
<div class="clearfix"></div>
|
||||
</div>
|
||||
<div class="filebox image">
|
||||
<img src="{:config('config.base_url')}{$images['path']}" class="img-responsive">
|
||||
</div>
|
||||
</li>
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
@@ -1,4 +1,4 @@
|
||||
<select class="form-control" name="{$name}" id="{$name}" style="width:auto;">
|
||||
<select class="form-control" name="{$name}" id="{$name}" style="width:auto;" {if isset($is_must) && $is_must}data-rule="required"{/if}>
|
||||
{volist name="option" id="item"}
|
||||
<option value="{$item['key']}" {if $item['key'] == $value}selected{/if}>{$item['label']|raw}</option>
|
||||
{/volist}
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
<input type="text" name="{$name}" value="{$value|default=date('Y-m-d H:i:s')}" class="form-control datetimepicker" style="width: 200px;">
|
||||
@@ -1,13 +1 @@
|
||||
<textarea name="{$name}" id="{$name}" style="width: 100%">{$value}</textarea>
|
||||
|
||||
<!-- 实例化编辑器代码 -->
|
||||
<script type="text/javascript">
|
||||
load.script('__plugins__/NKeditor/NKeditor-all-min.js', function(){
|
||||
KindEditor.ready(function(K) {
|
||||
K.create('textarea[name="{$name}"]', {
|
||||
uploadJson: "{:url('/admin/upload/editor')}",
|
||||
fileManagerJson: "{:url('/admin/upload/filemanage')}"
|
||||
})
|
||||
})
|
||||
});
|
||||
</script>
|
||||
<textarea name="{$name}" id="{$name}" class="form-editor" style="width: 100%">{$value}</textarea>
|
||||
@@ -1,5 +1,5 @@
|
||||
<div class="picker-box">
|
||||
<div id="picker_{$name}" class="picker_button">上传图片</div>
|
||||
<div id="picker_{$name}" class="btn btn-primary picker_button" data-type="image" data-limit="1"><i class="fa fa-upload"></i> 上传图片</div>
|
||||
{if isset($value) && $value}
|
||||
<input type="hidden" name="{$name}" id="field_{$name}" value="{$value}">
|
||||
{else/}
|
||||
@@ -23,25 +23,4 @@
|
||||
</li>
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
<script type="text/javascript">
|
||||
uploadsize = 2;
|
||||
$(function(){
|
||||
$("#picker_{$name}").SentUploader({
|
||||
compress:false,
|
||||
fileNumLimit:1,
|
||||
uploadEvents: {
|
||||
uploadComplete:function(file){}
|
||||
},
|
||||
listName : 'fileList_{$name}',
|
||||
hiddenName: 'field_{$name}',
|
||||
hiddenValType:1,
|
||||
fileSingleSizeLimit:uploadsize*1024*1024,
|
||||
closeX:true
|
||||
},
|
||||
{
|
||||
fileType: 'service',
|
||||
filename : 'images',
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</div>
|
||||
@@ -1,47 +1,26 @@
|
||||
<div class="picker-box">
|
||||
<div id="picker_{$name}" class="picker_button">上传图片</div>
|
||||
{if isset($value) && $value}
|
||||
<input type="hidden" name="{$name}" id="field_{$name}" value="{$value}">
|
||||
{else/}
|
||||
<input type="hidden" name="{$name}" id="field_{$name}" value="">
|
||||
<div class="picker-box">
|
||||
<div id="picker_{$name}" class="btn btn-primary picker_button" data-type="image" data-limit="0"><i class="fa fa-upload"></i> 上传多图</div>
|
||||
{if isset($value) && $value}
|
||||
<input type="hidden" name="{$name}" id="field_{$name}" value="{$value}">
|
||||
{else/}
|
||||
<input type="hidden" name="{$name}" id="field_{$name}" value="">
|
||||
{/if}
|
||||
<div id="fileList_{$name}" class="upload-file-list-info" style="width:280px;">
|
||||
{if $value}
|
||||
{php}
|
||||
$images = get_cover($value);
|
||||
{/php}
|
||||
<li class="affix-list-item" id="WU_FILE_0">
|
||||
<div class="upload-file-info">
|
||||
<span class="webuploader-pick-file-close" data-queued-id="WU_FILE_0" data-id="{$value}" data-fileurl="{$images['path']}"><i class="close"></i></span>
|
||||
<span class="fname"></span>
|
||||
<span class="fsize">上传时间:{$images['create_time']}</span>
|
||||
<div class="clearfix"></div>
|
||||
</div>
|
||||
<div class="filebox image">
|
||||
<img src="{:config('config.base_url')}{$images['path']}" class="img-responsive">
|
||||
</div>
|
||||
</li>
|
||||
{/if}
|
||||
<div id="fileList_{$name}" class="upload-file-list-info" style="width:280px;">
|
||||
{if $value}
|
||||
{php}
|
||||
$images = get_cover($value);
|
||||
{/php}
|
||||
<li class="affix-list-item" id="WU_FILE_0">
|
||||
<div class="upload-file-info">
|
||||
<span class="webuploader-pick-file-close" data-queued-id="WU_FILE_0" data-id="{$value}" data-fileurl="{$images['path']}"><i class="close"></i></span>
|
||||
<span class="fname"></span>
|
||||
<span class="fsize">上传时间:{$images['create_time']}</span>
|
||||
<div class="clearfix"></div>
|
||||
</div>
|
||||
<div class="filebox image">
|
||||
<img src="{:config('config.base_url')}{$images['path']}" class="img-responsive">
|
||||
</div>
|
||||
</li>
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
<script type="text/javascript">
|
||||
uploadsize = 2;
|
||||
$(function(){
|
||||
$("#picker_{$name}").SentUploader({
|
||||
compress:false,
|
||||
fileNumLimit:1,
|
||||
uploadEvents: {
|
||||
uploadComplete:function(file){}
|
||||
},
|
||||
listName : 'fileList_{$name}',
|
||||
hiddenName: 'field_{$name}',
|
||||
hiddenValType:1,
|
||||
fileSingleSizeLimit:uploadsize*1024*1024,
|
||||
closeX:true
|
||||
},
|
||||
{
|
||||
fileType: 'service',
|
||||
filename : 'images',
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</div>
|
||||
@@ -1,4 +1,4 @@
|
||||
<select class="form-control" name="{$name}" id="{$name}" style="width:auto;">
|
||||
<select class="form-control" name="{$name}" id="{$name}" style="width:auto;" {if isset($is_must) && $is_must}data-rule="required"{/if}>
|
||||
{volist name="option" id="item"}
|
||||
<option value="{$item['key']}" {if $item['key'] == $value}selected{/if}>{$item['label']}</option>
|
||||
{/volist}
|
||||
|
||||
@@ -1 +1 @@
|
||||
<input type="text" class="form-control" name="{$name}" id="{$name}" autocomplete="false" value="{$value}">
|
||||
<input type="text" class="form-control" name="{$name}" id="{$name}" autocomplete="false" value="{$value}" {if isset($is_must) && $is_must}data-rule="required"{/if}>
|
||||
@@ -1 +1 @@
|
||||
<textarea class="form-control" name="{$name}" id="{$name}">{$value}</textarea>
|
||||
<textarea class="form-control" name="{$name}" id="{$name}" {if isset($is_must) && $is_must}data-rule="required"{/if}>{$value}</textarea>
|
||||
@@ -31,7 +31,7 @@ class Validate {
|
||||
$scene = strtolower($controller[0]) . $request->action();
|
||||
$validate = "app\\http\\validate\\" . ucfirst($controller[1]);
|
||||
//仅当验证器存在时 进行校验
|
||||
if (class_exists($validate) && $request->isPost()) {
|
||||
if (class_exists($validate) && (strtolower($controller[0]) == 'admin' && $request->isPost())) {
|
||||
$v = new $validate;
|
||||
//仅当存在验证场景才校验
|
||||
if ($v->hasScene($scene)) {
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | SentCMS [ WE CAN DO IT JUST THINK IT ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2013 http://www.tensent.cn All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
|
||||
// +----------------------------------------------------------------------
|
||||
namespace app\http\validate;
|
||||
|
||||
use think\Validate;
|
||||
use app\model\Member;
|
||||
|
||||
/**
|
||||
* 菜单验证
|
||||
*/
|
||||
class Login extends Validate{
|
||||
protected $rule = [
|
||||
'username' => 'require|alphaDash',
|
||||
'password' => 'require|min:8',
|
||||
];
|
||||
|
||||
protected $message = [
|
||||
'username.require' => '用户名称必须',
|
||||
'username.alphaDash' => '用户名只能使用字母、数字、_、-',
|
||||
'password.min' => '密码不能小于8位',
|
||||
'repassword.require' => '确认密码不能为空'
|
||||
];
|
||||
|
||||
protected $scene = [
|
||||
'apiindex' => ['username', 'password'],
|
||||
];
|
||||
}
|
||||
+2
-2
@@ -19,8 +19,8 @@ class Link extends \think\Model {
|
||||
|
||||
public static $keyList = [
|
||||
['name' => 'id', 'title' => 'ID', 'type' => 'hidden'],
|
||||
['name' => 'title', 'title' => '友链标题', 'type' => 'text', 'help' => ''],
|
||||
['name' => 'url', 'title' => 'URL链接', 'type' => 'text', 'help' => '连接格式如:https://www.tensent.cn'],
|
||||
['name' => 'title', 'title' => '友链标题', 'type' => 'text', 'is_must' => 1, 'help' => ''],
|
||||
['name' => 'url', 'title' => 'URL链接', 'type' => 'text', 'is_must' => 1, 'help' => '连接格式如:https://www.tensent.cn'],
|
||||
['name' => 'ftype', 'title' => '友链类别', 'type' => 'select', 'option' => [
|
||||
['key'=>'1', 'label' => '常用链接'],
|
||||
['key'=>'2', 'label' => '网站导读'],
|
||||
|
||||
Reference in New Issue
Block a user