7 Commits

Author SHA1 Message Date
wolfcode
70ec12f406 feat(admin): 新增搜索表单多选功能 add xmSelect plugin support for multiple selection
- Add xmSelect case handling in AdminController for 'in' operation
- Include xmSelect.js in admin layout
- Update easy-admin.js to support xmSelect initialization and data binding
- Modify goods.js to demonstrate xmSelect usage with simulated data
- Adjust public.css for better styling of xmSelect elements

Signed-off-by: wolfcode <37436228+wolf-leo@users.noreply.github.com>
2024-10-25 11:44:19 +08:00
wolfcode
e15b56ecc9 Update composer.json 2024-10-24 09:37:09 +08:00
wolfcode
af275e1c6a fix(install): check for .env file existence before installation
- Add a check for the presence of the .env file in the root directory
- Update the index method to redirect to the admin page with a default value

Signed-off-by: wolfcode <37436228+wolf-leo@users.noreply.github.com>
2024-10-23 10:27:06 +08:00
wolfcode
20d4038159 Update public.css 2024-10-22 16:08:23 +08:00
wolfcode
475a1ef84d refactor(admin): update login.js to include jQuery dependency
- Add jQuery as a dependency in the define function
- Update the function parameters to include jQuery ($)

Signed-off-by: wolfcode <37436228+wolf-leo@users.noreply.github.com>
2024-10-22 14:43:50 +08:00
wolfcode
9307e724a9 refactor(SystemLogService): optimize detectTable method and improve code quality
- Remove unnecessary return type annotation in instance method
- Add type hint for SystemLogService instance
- Use variable for cache key to improve code readability
- Update cache key name for consistency

Signed-off-by: wolfcode <37436228+wolf-leo@users.noreply.github.com>
2024-10-22 11:54:59 +08:00
wolfcode
6616e96724 perf(middleware): optimize system log middleware for performance
- Remove redundant code for checking ignoreLog property
- Consolidate logic to check ignoreLog property in a single location
- Improve readability and maintainability of the code

Signed-off-by: wolfcode <37436228+wolf-leo@users.noreply.github.com>
2024-10-22 11:31:06 +08:00
12 changed files with 2648 additions and 19 deletions

View File

@@ -48,15 +48,6 @@ class SystemLog
if ($request->isAjax()) {
if (in_array($method, ['post', 'put', 'delete'])) {
$controller = $request->controller();
if (str_contains($controller, '.')) $controller = str_replace('.', '\\', $controller);
$action = $request->action();
$controllerClass = 'app\\admin\\controller\\' . $controller;
$classObj = new ReflectionClass($controllerClass);
$properties = $classObj->getDefaultProperties();
$ignoreLog = $properties['ignoreLog'] ?? [];
if (in_array($action, $ignoreLog)) return $response;
$title = '';
try {
$pathInfo = $request->pathinfo();
@@ -68,7 +59,10 @@ class SystemLog
if ($_name && $_controller && $_action) {
$className = "app\admin\controller\\{$_name}\\{$_controller}";
$reflectionClass = new \ReflectionClass($className);
$parser = new DocParser();
$properties = $reflectionClass->getDefaultProperties();
$ignoreLog = $properties['ignoreLog'] ?? [];
if (in_array($_action, $ignoreLog)) return $response;
$parser = new DocParser();
$parser->setIgnoreNotImportedAnnotations(true);
$reader = new AnnotationReader($parser);
$controllerAnnotation = $reader->getClassAnnotation($reflectionClass, ControllerAnnotation::class);

View File

@@ -44,14 +44,13 @@ class SystemLogService
$this->tablePrefix = Config::get('database.connections.mysql.prefix');
$this->tableSuffix = date('Ym', time());
$this->tableName = "{$this->tablePrefix}system_log_{$this->tableSuffix}";
return $this;
}
/**
* 获取实例对象
* @return SystemLogService|object
* @return SystemLogService
*/
public static function instance()
public static function instance(): SystemLogService
{
if (is_null(self::$instance)) {
self::$instance = new static();
@@ -85,15 +84,16 @@ class SystemLogService
*/
public function detectTable(): bool
{
$_key = "system_log_{$this->tableName}_table";
// 手动删除日志表时候 记得清除缓存
$isset = Cache::get("systemLog{$this->tableName}Table");
$isset = Cache::get($_key);
if ($isset) return true;
$check = Db::query("show tables like '{$this->tableName}'");
if (empty($check)) {
$sql = $this->getCreateSql();
Db::execute($sql);
}
Cache::set("system_log_{$this->tableName}_table", !empty($check));
Cache::set($_key, !empty($check));
return true;
}

View File

@@ -26,6 +26,7 @@
EDITOR_TYPE: "{$adminEditor|default='wangEditor'}",
};
</script>
<script src="/static/plugs/xmSelect/xm-select.js" charset="utf-8"></script>
<script src="/static/plugs/layui-v2.x/layui.js" charset="utf-8"></script>
<script src="/static/plugs/require-2.3.6/require.js" charset="utf-8"></script>
<script src="/static/config-admin.js?v={$version}" charset="utf-8"></script>

View File

@@ -190,6 +190,9 @@ class AdminController extends BaseController
case '%*':
$where[] = [$key, 'LIKE', "%{$val}"];
break;
case 'in':
$where[] = [$key, 'IN', $val];
break;
case 'range':
[$beginTime, $endTime] = explode(' - ', $val);
$where[] = [$key, '>=', strtotime($beginTime)];

View File

@@ -14,6 +14,6 @@ class Index extends BaseController
public function index(): Redirect
{
// 这是项目首页 系统默认跳转后台页面
return redirect('/' . Env::get('EASYADMIN.ADMIN', false));
return redirect('/' . Env::get('EASYADMIN.ADMIN', 'admin'));
}
}

View File

@@ -27,6 +27,9 @@ class Install extends BaseController
}elseif (!extension_loaded("PDO")) {
$errorInfo = '当前未开启PDO无法进行安装';
}
if (!is_file(root_path() . '.env')) {
$errorInfo = '.env 文件不存在,请先配置 .env 文件';
}
if (!$request->isAjax()) {
$currentHost = '://';
$result = compact('errorInfo', 'currentHost', 'isInstall');

View File

@@ -37,7 +37,7 @@
"qiniu/php-sdk": "v7.11.0",
"ext-mysqli": "*",
"ext-pdo": "*",
"wolf-leo/phplogviewer": "^0.10.0"
"wolf-leo/phplogviewer": "^0.11.1"
},
"require-dev": {
"symfony/var-dumper": ">=4.2",

View File

@@ -134,6 +134,12 @@ html.dark, body {
color: #a29c9c;
}
.layui-form-item xm-select {
min-height: 30px !important;
line-height: 30px !important;
margin: 0 !important;
}
/** 按钮背景色 */
.layuimini-container .layuimini-btn-primary {
color: #fff;
@@ -475,6 +481,18 @@ table样式
.form-search .layui-input-inline input, .form-search .layui-input-inline select {
width: 100% !important;
}
.tableSelect {
margin: 5px !important;
min-width: auto !important;
left: 1px !important;
right: 1px !important;
}
.tableSelect img {
object-fit: cover;
height: 100%;
}
}
/**

View File

@@ -1,4 +1,4 @@
define(["easy-admin"], function (ea) {
define(["jquery", "easy-admin"], function ($, ea) {
return {
index: function () {

View File

@@ -42,6 +42,14 @@ define(["jquery", "easy-admin"], function ($, ea) {
{field: 'virtual_sales', width: 100, title: '虚拟销量'},
{field: 'sales', width: 80, title: '销量'},
{field: 'status', title: '状态', width: 85, selectList: {0: '禁用', 1: '启用'}, templet: ea.table.switch},
// 演示多选,实际数据库并无 status2 字段,搜索后会报错
{
field: 'status2', title: '演示多选', width: 105, search: 'xmSelect', selectList: {1: '模拟选项1', 2: '模拟选项2', 3: '模拟选项3', 4: '模拟选项4', 5: '模拟选项5'},
searchOp: 'in', templet: function (res) {
// 根据自己实际项目进行输出
return res?.status2 || '模拟数据'
}
},
{field: 'create_time', minWidth: 80, title: '创建时间', search: 'range'},
{
width: 250,

View File

@@ -20,7 +20,9 @@ define(["jquery", "tableSelect"], function ($, tableSelect) {
upload_url: 'ajax/upload',
upload_exts: 'doc|gif|ico|icon|jpg|mp3|mp4|p12|pem|png|rar',
csrf_token: window.CONFIG.CSRF_TOKEN,
wait_submit: false
wait_submit: false,
xmSelectList: {},
xmSelectModel: {},
};
@@ -370,6 +372,15 @@ define(["jquery", "tableSelect"], function ($, tableSelect) {
'</div>\n' +
'</div>';
break;
case 'xmSelect':
formHtml += '\t<div class="layui-form-item layui-inline">\n' +
'<label class="layui-form-label">' + d.title + '</label>\n' +
'<div class="layui-input-inline">\n' +
'<div id="c-' + d.fieldAlias + '" class="tableSearch-xmSelect xmSelect-' + d.fieldAlias + '" name="' + d.fieldAlias + '" data-search-op="' + d.searchOp + '"></div>\n' +
'</div>\n' +
'</div>';
init.xmSelectList[d.fieldAlias] = d.selectList
break;
case 'range':
d.searchOp = 'range';
formHtml += '\t<div class="layui-form-item layui-inline">\n' +
@@ -823,6 +834,17 @@ define(["jquery", "tableSelect"], function ($, tableSelect) {
return value;
},
listenTableSearch: function (tableId) {
if (Object.keys(init.xmSelectList).length > 0) {
$.each(init.xmSelectList, function (index, value) {
const keysArray = Object.keys(value).map((key) => {
return {name: value[key], value: key}
})
init.xmSelectModel[index] = xmSelect.render({
el: '.xmSelect-' + index, language: 'zn', data: keysArray, name: index,
filterable: true, paging: true, pageSize: 10, theme: {color: '#16b777'}, toolbar: {show: true},
})
})
}
form.on('submit(' + tableId + '_filter)', function (data) {
var dataField = data.field;
var formatFilter = {},
@@ -1155,6 +1177,11 @@ define(["jquery", "tableSelect"], function ($, tableSelect) {
if (tableId === undefined || tableId === '' || tableId == null) {
tableId = init.table_render_id;
}
if (Object.keys(init.xmSelectModel).length > 0) {
$.each(init.xmSelectModel, function (index, value) {
init.xmSelectModel[index].setValue([])
})
}
table.reload(tableId, {
page: {
curr: 1

File diff suppressed because one or more lines are too long