From 0d135563809ba85295c9104d89aa54970eb109d5 Mon Sep 17 00:00:00 2001 From: xman <1946321327@qq.com> Date: Tue, 4 Mar 2025 10:02:58 +0800 Subject: [PATCH] css --- addons/betterform/.addonrc | 1 + addons/betterform/Betterform.php | 113 +++++++++++++++++++++++++ addons/betterform/bootstrap.js | 27 ++++++ addons/betterform/config.php | 102 ++++++++++++++++++++++ addons/betterform/controller/Index.php | 15 ++++ addons/betterform/info.ini | 10 +++ 6 files changed, 268 insertions(+) create mode 100644 addons/betterform/.addonrc create mode 100644 addons/betterform/Betterform.php create mode 100644 addons/betterform/bootstrap.js create mode 100644 addons/betterform/config.php create mode 100644 addons/betterform/controller/Index.php create mode 100644 addons/betterform/info.ini diff --git a/addons/betterform/.addonrc b/addons/betterform/.addonrc new file mode 100644 index 0000000..8a78127 --- /dev/null +++ b/addons/betterform/.addonrc @@ -0,0 +1 @@ +{"files":["public\/assets\/addons\/betterform\/css\/common.css"],"license":"regular","licenseto":"15976","licensekey":"jonIxu8gCamyBzi5 N6Q6iqNNuNQoEV\/fV4rCvlZqQvDJEBrF+sYTD7HeULs=","domains":["fast.cc"],"licensecodes":[],"validations":["043c5318e9fc4870124f0d65db900fc1"]} \ No newline at end of file diff --git a/addons/betterform/Betterform.php b/addons/betterform/Betterform.php new file mode 100644 index 0000000..0dc5b90 --- /dev/null +++ b/addons/betterform/Betterform.php @@ -0,0 +1,113 @@ +dispatch(); + if (!$dispatch) { + return; + } + + if (!$request->module() || $request->module() !== 'admin') { + return; + } + + $config = get_addon_config('betterform'); + + //在head前引入CSS + $content = preg_replace("/<\/head>/i", "" . "\n\$0", $content); + + //如果不存在表单 + if (!preg_match('/
标签 + $regex = '/]*class\s*=\s*"[^"]*\bform-group\b[^"]*"[^>]*>(?:(?!]*class\s*=\s*"[^"]*\bform-group\b[^"]*").)*?data-rule="[^"]*?(required|checked)[^"]*?"[^>]*>/si'; + $result = preg_replace_callback($regex, function ($matches) use ($config) { + return str_replace("form-group", "form-group required-{$config['asteriskposition']}", $matches[0]); + }, $content); + + $content = is_null($result) ? $content : $result; + + // 匹配 + $pattern = '/(]*>)\s*]*>(.*?)<\/td>\s*]*>.*?]*data-rule="[^"]*required[^"]*"[^>]*>.*?<\/td>\s*<\/tr>/si'; + $result = preg_replace_callback($pattern, function ($matches) use ($config) { + if (preg_match('/(]*)class\s*=\s*"[^"]*"/i', $matches[1])) { + return preg_replace('/(]*)class\s*=\s*"([^"]*)"/i', '$1class="$2 required-' . $config['asteriskposition'] . '"', $matches[0]); + } else { + return str_replace("getConfig(); + + $config['area'] = preg_match("/\[(.*?)\]/i", $config['area']) ? array_slice(array_values((array)json_decode($config['area'], true)), 0, 2) : $config['area']; + $config['shade'] = floatval($config['shade']); + $config['shadeClose'] = boolval($config['shadeClose']); + $params['betterform'] = $config; + } + +} diff --git a/addons/betterform/bootstrap.js b/addons/betterform/bootstrap.js new file mode 100644 index 0000000..aeec7da --- /dev/null +++ b/addons/betterform/bootstrap.js @@ -0,0 +1,27 @@ +require(['fast', 'layer'], function (Fast, Layer) { + var _fastOpen = Fast.api.open; + Fast.api.open = function (url, title, options) { + options = options || {}; + options.area = Config.betterform.area; + options.offset = Config.betterform.offset; + options.anim = Config.betterform.anim; + options.shadeClose = Config.betterform.shadeClose; + options.shade = Config.betterform.shade; + return _fastOpen(url, title, options); + }; + if (isNaN(Config.betterform.anim)) { + var _layerOpen = Layer.open; + Layer.open = function (options) { + var classNameArr = {slideDown: "layer-anim-slide-down", slideLeft: "layer-anim-slide-left", slideUp: "layer-anim-slide-up", slideRight: "layer-anim-slide-right"}; + var animClass = "layer-anim " + classNameArr[options.anim] || "layer-anim-fadein"; + var index = _layerOpen(options); + var layero = $('#layui-layer' + index); + + layero.addClass(classNameArr[options.anim] + "-custom"); + layero.addClass(animClass).one('webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend', function () { + $(this).removeClass(animClass); + }); + return index; + } + } +}); \ No newline at end of file diff --git a/addons/betterform/config.php b/addons/betterform/config.php new file mode 100644 index 0000000..225d557 --- /dev/null +++ b/addons/betterform/config.php @@ -0,0 +1,102 @@ + 'asteriskposition', + 'title' => '*号位置', + 'type' => 'radio', + 'group' => '', + 'visible' => '', + 'content' => [ + 'before' => '位于文本前', + 'after' => '位于文本后', + ], + 'value' => 'before', + 'rule' => 'required', + 'msg' => '', + 'tip' => '', + 'ok' => '', + 'extend' => '', + ], + [ + 'name' => 'offset', + 'title' => '弹窗位置', + 'type' => 'radio', + 'content' => [ + 'auto' => '居中', + 't' => '顶部', + 'b' => '底部', + 'l' => '左部', + 'r' => '右部', + ], + 'value' => 'r', + 'rule' => 'required', + 'msg' => '', + 'tip' => '', + 'ok' => '', + 'extend' => '', + ], + [ + 'name' => 'anim', + 'title' => '打开动画', + 'type' => 'select', + 'content' => [ + '平滑放大', + '从上掉落', + '从最底部往上滑入', + '从左滑入', + '从左翻滚', + '渐显', + '抖动', + 'slideDown' => '从上边缘往下', + 'slideLeft' => '从右边缘往左', + 'slideUp' => '从下边缘往上', + 'slideRight' => '从左边缘往右', + ], + 'value' => 'slideLeft', + 'rule' => 'required', + 'msg' => '', + 'tip' => '', + 'ok' => '', + 'extend' => '', + ], + [ + 'name' => 'area', + 'title' => '弹窗宽高', + 'type' => 'string', + 'content' => [], + 'value' => '["80%", "100%"]', + 'rule' => 'required', + 'msg' => '', + 'tip' => '', + 'ok' => '', + 'extend' => '', + ], + [ + 'name' => 'shade', + 'title' => '阴影透明度', + 'type' => 'number', + 'content' => [], + 'value' => '0.3', + 'rule' => 'required', + 'msg' => '', + 'tip' => '', + 'ok' => '', + 'extend' => '', + ], + [ + 'name' => 'shadeClose', + 'title' => '点击阴影关闭弹窗', + 'type' => 'bool', + 'content' => [ + 1 => '开启', + 0 => '关闭', + ], + 'value' => '1', + 'rule' => 'required', + 'msg' => '', + 'tip' => '', + 'ok' => '', + 'extend' => '', + ], +]; diff --git a/addons/betterform/controller/Index.php b/addons/betterform/controller/Index.php new file mode 100644 index 0000000..c8a19d2 --- /dev/null +++ b/addons/betterform/controller/Index.php @@ -0,0 +1,15 @@ +error("当前插件暂无前台页面"); + } + +} diff --git a/addons/betterform/info.ini b/addons/betterform/info.ini new file mode 100644 index 0000000..71e8dfa --- /dev/null +++ b/addons/betterform/info.ini @@ -0,0 +1,10 @@ +name = betterform +title = FastAdmin表单弹窗优化插件 +intro = 优化FastAdmin表单弹窗 +author = FastAdmin +website = https://www.fastadmin.net +version = 1.0.3 +state = 1 +url = http://fast.cc:8088/addons/betterform +license = regular +licenseto = 15976