18 Commits

Author SHA1 Message Date
wolfcode
62f591045e refactor(admin): enhance delete method to support custom primary keys
- Update delete method in Curd trait to accept Request parameter
- Add support for deleting multiple records using 'id' parameter
- Improve error handling for non-existent data
2024-12-11 17:00:34 +08:00
wolfcode
7470790657 refactor(admin): optimize system log middleware
- Adjust class name construction logic in SystemLog middleware
- Simplify condition for checking controller and action existence
2024-12-09 13:55:24 +08:00
wolfcode
11fa69afaf Merge pull request #13 from Rodots/main
路由配置新增操作方法的参数绑定方式
2024-12-02 16:04:23 +08:00
Rodots
8983705ce4 feat: Parameter Binding Method of New Operation Method for Routing Configuration 2024-12-02 16:01:49 +08:00
wolfcode
95ccd4071b feat(easy-admin): add support for custom template functions in operat column-Implement the ability to use custom template functions in the operat column of easy-admin tables
- Add a new button in the goods list page to demonstrate the usage of custom templates
2024-12-02 11:03:26 +08:00
wolfcode
09f3ea7e54 feat(search): add date type search support
- Implement search functionality for date type fields
- Add new case for 'date' in the search HTML generation logic
- Include date-specific input field with appropriate attributes
2024-11-29 18:50:02 +08:00
wolfcode
9cadb27c9e 🚀Layui v2.9.20 2024-11-29 16:38:46 +08:00
wolfcode
2772034a93 fix(admin): add type attribute to login button
- Add 'type="button"' attribute to the login button in admin login page
- This change prevents the button from being submitted as a form Reset button
2024-11-28 18:19:12 +08:00
wolfcode
08ea79033c feat(admin): add ignoreNode property to skip unnecessary node generation
- Add $ignoreNode property to Goods controller to specify methods to ignore
- Update Node service to check and skip ignored methods during node generation
- This change helps to filter out unnecessary nodes, improving system performance and readability
2024-11-28 10:54:15 +08:00
wolfcode
e7f09d9c68 refactor(install):使用PDO初始化安装 use PDO instead of mysqli for database operations
- Replace mysqli with PDO for database connection and queries
- Create a separate method for generating PDO DSN
- Update error handling to use PDOException
- Remove unnecessary mysqli_set_charset and mysqli_select_db calls
2024-11-27 12:33:04 +08:00
wolfcode
e2effb762c build(deps): update dependency wolfcode/authenticator to v0.0.6
- Updated wolfcode/authenticator from version 0.0.5 to 0.0.6 in composer.json
2024-11-22 16:59:07 +08:00
wolfcode
0e18825808 fix(authenticator): update dependency and adjust QR code generation
- Update wolfcode/authenticator from 0.0.3 to 0.0.5
- Modify QR code generation method in Index controller
2024-11-22 16:51:36 +08:00
wolfcode
c031b09422 build(deps): update topthink/think-multi-app to ^1.1.0
- Replace dev-master with stable version ^1.1.0 for topthink/think-multi-app- This change ensures compatibility and stability in dependency management
2024-11-22 15:16:44 +08:00
wolfcode
231fd48e2f build(deps): update topthink/think-multi-app to dev-master
- Change the version of topthink/think-multi-app from ^1.0 to dev-master in composer.json
2024-11-22 09:32:06 +08:00
wolfcode
53772badd4 Merge pull request #12 from Rodots/main
fix: 修正命名空间,移除无用类的引用
2024-11-14 16:45:09 +08:00
wolfcode
3e329a4ea3 fix(install): update ea_system_admin insert statement
- Add missing column for 'status' in ea_system_admin insert statement
- Set 'status' column to 1 for the admin user
2024-11-13 16:30:15 +08:00
wolfcode
f015a90b89 style(layuimini): remove redundant CSS rules for nav more icons- Removed specific margin-top rules for .layuimini-menu-left and .layuimini-menu-left-zoom classes
- Kept the general rule for .layuimini-menu-left .layui-nav .layui-nav-mored and .layuimini-menu-left .layui-nav-itemed > a .layui-nav-more
2024-11-12 17:21:04 +08:00
Rodots
34354837d5 fix: 修正命名空间,移除无用类的引用 2024-11-06 14:51:15 +08:00
22 changed files with 81 additions and 89 deletions

View File

@@ -141,7 +141,7 @@ class Index extends AdminController
$old_secret = $row->ga_secret; $old_secret = $row->ga_secret;
$secret = $ga->createSecret(32); $secret = $ga->createSecret(32);
$ga_title = $this->isDemo ? 'EasyAdmin8演示环境' : '可自定义修改显示标题'; $ga_title = $this->isDemo ? 'EasyAdmin8演示环境' : '可自定义修改显示标题';
$dataUri = $ga->getQRCode($ga_title, $secret)->getDataUri(); $dataUri = $ga->getQRCode($ga_title, $secret);
$this->assign(compact('row', 'dataUri', 'old_secret', 'secret')); $this->assign(compact('row', 'dataUri', 'old_secret', 'secret'));
return $this->fetch(); return $this->fetch();
} }

View File

@@ -20,6 +20,12 @@ use think\response\Json;
class Goods extends AdminController class Goods extends AdminController
{ {
/**
* 过滤不需要生成的权限节点 默认 CURD 中会自动生成部分节点 可以在此处过滤
* @var array[]
*/
protected array $ignoreNode = ['export'];
public function __construct(App $app) public function __construct(App $app)
{ {
parent::__construct($app); parent::__construct($app);

View File

@@ -150,9 +150,10 @@ class Admin extends AdminController
/** /**
* @NodeAnnotation(title="删除") * @NodeAnnotation(title="删除")
*/ */
public function delete($id): void public function delete(Request $request): void
{ {
$this->checkPostRequest(); $this->checkPostRequest();
$id = $request->post('id');
$row = $this->model->whereIn('id', $id)->select(); $row = $this->model->whereIn('id', $id)->select();
$row->isEmpty() && $this->error('数据不存在'); $row->isEmpty() && $this->error('数据不存在');
$id == AdminConstant::SUPER_ADMIN_ID && $this->error('超级管理员不允许修改'); $id == AdminConstant::SUPER_ADMIN_ID && $this->error('超级管理员不允许修改');

View File

@@ -132,9 +132,10 @@ class Menu extends AdminController
/** /**
* @NodeAnnotation(title="删除") * @NodeAnnotation(title="删除")
*/ */
public function delete($id): void public function delete(Request $request): void
{ {
$this->checkPostRequest(); $this->checkPostRequest();
$id = $request->post('id');
$row = $this->model->whereIn('id', $id)->select(); $row = $this->model->whereIn('id', $id)->select();
empty($row) && $this->error('数据不存在'); empty($row) && $this->error('数据不存在');
try { try {

View File

@@ -56,8 +56,8 @@ class SystemLog
$pathInfoExp = explode('.', $pathInfoExp[0] ?? ''); $pathInfoExp = explode('.', $pathInfoExp[0] ?? '');
$_name = $pathInfoExp[0] ?? ''; $_name = $pathInfoExp[0] ?? '';
$_controller = ucfirst($pathInfoExp[1] ?? ''); $_controller = ucfirst($pathInfoExp[1] ?? '');
if ($_name && $_controller && $_action) { $className = $_controller ? "app\admin\controller\\{$_name}\\{$_controller}" : "app\admin\controller\\{$_name}";
$className = "app\admin\controller\\{$_name}\\{$_controller}"; if ($_name && $_action) {
$reflectionClass = new \ReflectionClass($className); $reflectionClass = new \ReflectionClass($className);
$properties = $reflectionClass->getDefaultProperties(); $properties = $reflectionClass->getDefaultProperties();
$ignoreLog = $properties['ignoreLog'] ?? []; $ignoreLog = $properties['ignoreLog'] ?? [];

View File

@@ -67,6 +67,12 @@ class Node
// 遍历读取所有方法的注释的参数信息 // 遍历读取所有方法的注释的参数信息
foreach ($methods as $method) { foreach ($methods as $method) {
// 忽略的节点
$properties = $reflectionClass->getDefaultProperties();
$ignoreNode = $properties['ignoreNode'] ?? [];
if (!empty($ignoreNode)) if (in_array($method->name, $ignoreNode)) continue;
// 读取NodeAnnotation的注解 // 读取NodeAnnotation的注解
$nodeAnnotation = $reader->getMethodAnnotation($method, NodeAnnotation::class); $nodeAnnotation = $reader->getMethodAnnotation($method, NodeAnnotation::class);
if (!empty($nodeAnnotation)) { if (!empty($nodeAnnotation)) {

View File

@@ -1,8 +1,8 @@
<?php <?php
declare(strict_types = 1);
namespace EasyAdmin\curd\exceptions; namespace app\admin\service\curd\exceptions;
class CurdException extends \Exception class CurdException extends \Exception
{ {
} }

View File

@@ -1,8 +1,8 @@
<?php <?php
declare(strict_types = 1);
namespace EasyAdmin\curd\exceptions; namespace app\admin\service\curd\exceptions;
class FileException extends \Exception class FileException extends \Exception
{ {
} }

View File

@@ -1,8 +1,8 @@
<?php <?php
declare(strict_types = 1);
namespace app\admin\service\curd\exceptions; namespace app\admin\service\curd\exceptions;
class TableException extends \Exception class TableException extends \Exception
{ {
} }

View File

@@ -88,8 +88,10 @@ trait Curd
/** /**
* @NodeAnnotation(title="删除") * @NodeAnnotation(title="删除")
*/ */
public function delete($id): void public function delete(Request $request): void
{ {
// 如果不是id作为主键 请在对应的控制器中覆盖重写
$id = $request->param('id', []);
$this->checkPostRequest(); $this->checkPostRequest();
$row = $this->model->whereIn('id', $id)->select(); $row = $this->model->whereIn('id', $id)->select();
$row->isEmpty() && $this->error('数据不存在'); $row->isEmpty() && $this->error('数据不存在');

View File

@@ -41,7 +41,7 @@
<a href="javascript:" class="forget-password">忘记密码?</a> <a href="javascript:" class="forget-password">忘记密码?</a>
</div> </div>
<div class="layui-form-item" style="text-align:center; width:100%;height:100%;margin:0px;"> <div class="layui-form-item" style="text-align:center; width:100%;height:100%;margin:0px;">
<button class="login-btn" lay-submit>立即登录</button> <button type="button" class="login-btn" lay-submit>立即登录</button>
</div> </div>
</form> </form>
</div> </div>

View File

@@ -1,47 +0,0 @@
<?php
namespace app\common\command;
use EasyAdmin\console\CliEcho;
use EasyAdmin\tool\CommonTool;
use EasyAdmin\upload\driver\alioss\Oss;
use think\console\Command;
use think\console\Input;
use think\console\input\Option;
use think\console\Output;
class OssStatic extends Command
{
protected function configure()
{
$this->setName('OssStatic')
->setDescription('将静态资源上传到oss上');
}
protected function execute(Input $input, Output $output)
{
$output->writeln("========正在上传静态资源到OSS上========" . date('Y-m-d H:i:s'));
$dir = root_path() . 'public' . DIRECTORY_SEPARATOR . 'static';
$list = CommonTool::readDirAllFiles($dir);
$uploadConfig = sysConfig('upload');
$uploadPrefix = config('app.oss_static_prefix', 'oss_static_prefix');
foreach ($list as $key => $val) {
list($objectName, $filePath) = [$uploadPrefix . DIRECTORY_SEPARATOR . $key, $val];
try {
$upload = Oss::instance($uploadConfig)
->save($objectName, $filePath);
} catch (\Exception $e) {
CliEcho::error('文件上传失败:' . $filePath . '。错误信息:' . $e->getMessage());
continue;
}
if ($upload['save'] == true) {
CliEcho::success('文件上传成功:' . $filePath . '。上传地址:' . $upload['url']);
} else {
CliEcho::error('文件上传失败:' . $filePath . '。错误信息:' . $upload['msg']);
}
}
$output->writeln("========已完成静态资源上传到OSS上========" . date('Y-m-d H:i:s'));
}
}

View File

@@ -3,7 +3,6 @@
namespace app\common\service; namespace app\common\service;
use app\common\constants\AdminConstant; use app\common\constants\AdminConstant;
use EasyAdmin\tool\CommonTool;
use think\facade\Db; use think\facade\Db;
/** /**

View File

@@ -91,12 +91,11 @@ class Install extends BaseController
$installPath = config_path() . DIRECTORY_SEPARATOR . 'install' . DIRECTORY_SEPARATOR; $installPath = config_path() . DIRECTORY_SEPARATOR . 'install' . DIRECTORY_SEPARATOR;
$sqlPath = file_get_contents($installPath . 'sql' . DIRECTORY_SEPARATOR . 'install.sql'); $sqlPath = file_get_contents($installPath . 'sql' . DIRECTORY_SEPARATOR . 'install.sql');
$sqlArray = $this->parseSql($sqlPath, $config['prefix'], 'ea_'); $sqlArray = $this->parseSql($sqlPath, $config['prefix'], 'ea_');
$conn = mysqli_connect($config['host'], $config['username'], $config['password'], null, $config['port']); $dsn = $this->pdoDsn($config, true);
try { try {
mysqli_set_charset($conn, $config['charset']); $pdo = new \PDO($dsn, $config['username'] ?? 'root', $config['password'] ?? '');
mysqli_select_db($conn, $config['database']);
foreach ($sqlArray as $sql) { foreach ($sqlArray as $sql) {
mysqli_query($conn, $sql); $pdo->query($sql);
} }
$_password = password($password); $_password = password($password);
$tableName = 'system_admin'; $tableName = 'system_admin';
@@ -108,9 +107,8 @@ class Install extends BaseController
'update_time' => time() 'update_time' => time()
]; ];
foreach ($update as $_k => $_up) { foreach ($update as $_k => $_up) {
mysqli_query($conn, "UPDATE {$config['prefix']}{$tableName} SET {$_k} = '{$_up}' WHERE id = 1"); $pdo->query("UPDATE {$config['prefix']}{$tableName} SET {$_k} = '{$_up}' WHERE id = 1");
} }
mysqli_close($conn);
// 处理安装文件 // 处理安装文件
!is_dir($installPath) && @mkdir($installPath); !is_dir($installPath) && @mkdir($installPath);
!is_dir($installPath . 'lock' . DIRECTORY_SEPARATOR) && @mkdir($installPath . 'lock' . DIRECTORY_SEPARATOR); !is_dir($installPath . 'lock' . DIRECTORY_SEPARATOR) && @mkdir($installPath . 'lock' . DIRECTORY_SEPARATOR);
@@ -161,11 +159,11 @@ class Install extends BaseController
protected function createDatabase($database, $config): bool protected function createDatabase($database, $config): bool
{ {
$dsn = $this->pdoDsn($config);
try { try {
$con = mysqli_connect($config['host'] ?? '127.0.0.1', $config['username'] ?? 'root', $config['password'] ?? '', null, $config['port'] ?? ''); $pdo = new \PDO($dsn, $config['username'] ?? 'root', $config['password'] ?? '');
mysqli_query($con, "CREATE DATABASE IF NOT EXISTS `{$database}` DEFAULT CHARACTER SET {$config['charset']} COLLATE=utf8mb4_general_ci"); $pdo->query("CREATE DATABASE IF NOT EXISTS `{$database}` DEFAULT CHARACTER SET {$config['charset']} COLLATE=utf8mb4_general_ci");
mysqli_close($con); }catch (\PDOException $e) {
}catch (\Throwable $e) {
return false; return false;
} }
return true; return true;
@@ -187,19 +185,32 @@ class Install extends BaseController
protected function checkConnect(array $config): ?bool protected function checkConnect(array $config): ?bool
{ {
$dsn = $this->pdoDsn($config);
try { try {
$con = mysqli_connect($config['host'] ?? '127.0.0.1', $config['username'] ?? 'root', $config['password'] ?? '', null, $config['port'] ?? ''); $pdo = new \PDO($dsn, $config['username'] ?? 'root', $config['password'] ?? '');
$res = mysqli_query($con, 'select VERSION()'); $res = $pdo->query('select VERSION()');
$mysqlVersion = mysqli_fetch_row($res); $_version = $res->fetch()[0] ?? 0;
mysqli_close($con);
$_version = $mysqlVersion[0] ?? 0;
if (version_compare($_version, '5.7.0', '<')) { if (version_compare($_version, '5.7.0', '<')) {
$this->error('mysql版本最低要求 5.7.x'); $this->error('mysql版本最低要求 5.7.x');
} }
}catch (\mysqli_sql_exception $e) { }catch (\PDOException $e) {
$this->error($e->getMessage()); $this->error($e->getMessage());
} }
return true; return true;
} }
/**
* @param array $config
* @param bool $needDatabase
* @return string
*/
protected function pdoDsn(array $config, bool $needDatabase = false): string
{
$host = $config['host'] ?? '127.0.0.1';
$database = $config['database'] ?? '';
$port = $config['port'] ?? '3306';
$charset = $config['charset'] ?? 'utf8mb4';
if ($needDatabase) return "mysql:host=$host;port=$port;dbname=$database;charset=$charset";
return "mysql:host=$host;port=$port;charset=$charset";
}
} }

View File

@@ -23,7 +23,7 @@
"php": ">=8.0.0", "php": ">=8.0.0",
"topthink/framework": "^8.0", "topthink/framework": "^8.0",
"topthink/think-orm": "^3.0", "topthink/think-orm": "^3.0",
"topthink/think-multi-app": "^1.0", "topthink/think-multi-app": "^1.1.0",
"topthink/think-view": "^2.0", "topthink/think-view": "^2.0",
"topthink/think-captcha": "^3.0", "topthink/think-captcha": "^3.0",
"topthink/think-filesystem": "^2.0", "topthink/think-filesystem": "^2.0",
@@ -38,7 +38,7 @@
"ext-mysqli": "*", "ext-mysqli": "*",
"ext-pdo": "*", "ext-pdo": "*",
"wolf-leo/phplogviewer": "^0.11.3", "wolf-leo/phplogviewer": "^0.11.3",
"wolfcode/authenticator": "^0.0.3" "wolfcode/authenticator": "^0.0.6"
}, },
"require-dev": { "require-dev": {
"symfony/var-dumper": ">=4.2", "symfony/var-dumper": ">=4.2",

View File

@@ -108,7 +108,7 @@ CREATE TABLE `ea_system_admin`
-- Records of ea_system_admin -- Records of ea_system_admin
-- ---------------------------- -- ----------------------------
INSERT INTO `ea_system_admin` INSERT INTO `ea_system_admin`
VALUES ('1', null, '/static/admin/images/head.jpg', 'admin', 'a33b679d5581a8692988ec9f92ad2d6a2259eaa7', 'admin', 'admin', '0', '0', '1', '1589454169', '1589476815', null); VALUES ('1', null, '/static/admin/images/head.jpg', 'admin', 'a33b679d5581a8692988ec9f92ad2d6a2259eaa7', 'admin', 'admin', '0', '0', '1', '1589454169', '1589476815', null,1,'');
-- ---------------------------- -- ----------------------------
-- Table structure for ea_system_auth -- Table structure for ea_system_auth

View File

@@ -42,4 +42,6 @@ return [
'default_jsonp_handler' => 'jsonpReturn', 'default_jsonp_handler' => 'jsonpReturn',
// 默认JSONP处理方法 // 默认JSONP处理方法
'var_jsonp_handler' => 'callback', 'var_jsonp_handler' => 'callback',
// 操作方法的参数绑定方式 route get param
'action_bind_param' => 'param',
]; ];

View File

@@ -57,6 +57,10 @@ define(["jquery", "easy-admin"], function ($, ea) {
templet: ea.table.tool, templet: ea.table.tool,
operat: [ operat: [
[{ [{
templet: function (d) {
return `<button type="button" class="layui-btn layui-btn-xs">自定义 ${d.id}</button>`
}
}, {
text: '编辑', text: '编辑',
url: init.edit_url, url: init.edit_url,
method: 'open', method: 'open',

View File

@@ -399,6 +399,15 @@ define(["jquery", "tableSelect"], function ($, tableSelect) {
'</div>\n' + '</div>\n' +
'</div>'; '</div>';
break; break;
case 'date':
d.searchOp = '=';
formHtml += `<div class="layui-form-item layui-inline">
<label class="layui-form-label">${d.title}</label>
<div class="layui-input-inline">
<input data-date data-date-type="date" id="c-${d.fieldAlias}" name="${d.fieldAlias}" data-search-op="${d.searchOp}" value="${d.searchValue}" placeholder="${d.searchTip}" class="layui-input">
</div>
</div>`
break;
} }
newCols.push(d); newCols.push(d);
} }
@@ -663,6 +672,12 @@ define(["jquery", "tableSelect"], function ($, tableSelect) {
$.each(item, function (i, operat) { $.each(item, function (i, operat) {
if (typeof operat !== 'object') return if (typeof operat !== 'object') return
if ('function' === typeof operat.templet) {
html += operat.templet(data);
return true;
}
operat.class = operat.class || ''; operat.class = operat.class || '';
operat.icon = operat.icon || ''; operat.icon = operat.icon || '';
operat.auth = operat.auth || ''; operat.auth = operat.auth || '';

View File

@@ -700,14 +700,6 @@
margin-top: -6px !important; margin-top: -6px !important;
} }
.layuimini-menu-left .layui-nav .layui-nav-mored,.layuimini-menu-left .layui-nav-itemed>a .layui-nav-more{
margin-top: -9px!important;
}
.layuimini-menu-left-zoom.layui-nav .layui-nav-mored,.layuimini-menu-left-zoom.layui-nav-itemed>a .layui-nav-more{
margin-top: -9px!important;
}
.layuimini-menu-left .layui-nav-more:before,.layuimini-menu-left-zoom .layui-nav-more:before { .layuimini-menu-left .layui-nav-more:before,.layuimini-menu-left-zoom .layui-nav-more:before {
content: "\e61a"; content: "\e61a";
} }

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long