admin plugin for webman
webman-php / admin Goto Github PK
View Code? Open in Web Editor NEWadmin plugin for webman
License: MIT License
admin plugin for webman
License: MIT License
admin plugin for webman
我看后台源码里面有大量的desc table,好像sqlite没有这个语句,请问admin可以支持sqlite数据库么
希望更新layui版本,新版本修复了蛮多问题。
感谢
安装了一下webman admin的后台 但是验证码 接口报错了一直显示不出来
我的环境 php8.1.7 workman 4.1.3 admin 0.3.1
ErrorException: Implicit conversion from float 21.5 to int loses precision in /home/meng/work/graduate/vendor/gregwar/captcha/src/Gregwar/Captcha/CaptchaBuilder.php:365
Stack trace:
#0 [internal function]: support\App::{closure}()
#1 /home/meng/work/graduate/vendor/gregwar/captcha/src/Gregwar/Captcha/CaptchaBuilder.php(365): imagettftext()
#2 /home/meng/work/graduate/vendor/gregwar/captcha/src/Gregwar/Captcha/CaptchaBuilder.php(459): Gregwar\Captcha\CaptchaBuilder->writePhrase()
#3 /home/meng/work/graduate/plugin/admin/app/controller/common/AccountController.php(127): Gregwar\Captcha\CaptchaBuilder->build()
#4 /home/meng/work/graduate/vendor/workerman/webman-framework/src/App.php(304): plugin\admin\app\controller\common\AccountController->captcha()
#5 /home/meng/work/graduate/plugin/admin/app/middleware/AccessControl.php(21): Webman\App::Webman\{closure}()
#6 /home/meng/work/graduate/vendor/workerman/webman-framework/src/App.php(299): plugin\admin\app\middleware\AccessControl->process()
#7 /home/meng/work/graduate/vendor/workerman/webman-framework/src/App.php(122): Webman\App::Webman\{closure}()
#8 /home/meng/work/graduate/vendor/workerman/workerman/Connection/TcpConnection.php(638): Webman\App->onMessage()
#9 /home/meng/work/graduate/vendor/workerman/workerman/Events/Select.php(311): Workerman\Connection\TcpConnection->baseRead()
#10 /home/meng/work/graduate/vendor/workerman/workerman/Worker.php(2457): Workerman\Events\Select->loop()
#11 /home/meng/work/graduate/vendor/workerman/workerman/Worker.php(1568): Workerman\Worker->run()
#12 /home/meng/work/graduate/vendor/workerman/workerman/Worker.php(1410): Workerman\Worker::forkOneWorkerForLinux()
#13 /home/meng/work/graduate/vendor/workerman/workerman/Worker.php(1384): Workerman\Worker::forkWorkersForLinux()
#14 /home/meng/work/graduate/vendor/workerman/workerman/Worker.php(559): Workerman\Worker::forkWorkers()
#15 /home/meng/work/graduate/vendor/workerman/webman-framework/src/support/App.php(124): Workerman\Worker::runAll()
#16 /home/meng/work/graduate/start.php(4): support\App::run()
#17 {main}
修改给富文本元素赋值的地方改为
if (key === "content") { layui.$("#content").html(value); return; }
用obj.val()方式会将html元素转为text 导致富文本不能正常渲染
walkor大佬, 我想给webman-admin开发一些工具类的插件, 比如上传文件到各大oss之类的, 但是我不知道如何通过我开发的插件拦截webman-admin的上传请求和读取请求, 能否给一些思路?
layuiadmin文档中写道大内部打开标签的方法好像不行了
openTabsPage
根据手册上的控件参数填写lay-verify:phone,该字段就会变为必填,想要的是如果填的话验证格式,不填也可以。
还有就是搜索也会被要求必填,且需要按照格式填写,希望是搜索不验证格式,并且模糊搜索。
参照webman文档使用事务:https://www.workerman.net/doc/webman/others/transaction.html
用Db::beginTransaction();写法发现事务无法回滚,必须用Db::connection('mysql')->beginTransaction();这种加上连接的方式才有效,发现原因是后台一键菜单生成的model里面设置了protected $connection = 'plugin.admin.mysql';
是否考虑将 $connection 去掉,否则很容易掉坑里,最好是将webman-admin数据库配置与webman原本的database.php整合,必要分开两个
一键菜单生成的代码中,表单数据中下拉选项必填项校验的时候,选择了内容还是提示校验不通过,应该是没有检测到已经选择了内容
表单的控件可以是必填,并且验证phone格式吗?
用户表现在没有状态字段,官方表中会加入吗?
Call to a member function connection() on null 请问这是什么原因呢?我的config/database.php 数据库我是读的.env文件,这个是什么问题,要怎么解决
请问后台还没有集成富文本编辑器吗?我但是我看到public/resource目录下有tinymce
每次更新前删除,更新后重新配置数据库?感觉这样有点不方便。
PS D:\code\toys\webman-admin> php -v
PHP 7.4.15 (cli) (built: Feb 2 2021 20:47:36) ( NTS Visual C++ 2017 x64 )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
{
"code": 500,
"message": "Call to undefined method Illuminate\\Database\\MySqlConnection::schema()",
"type": "failed",
"traces": "Error: Call to undefined method Illuminate\\Database\\MySqlConnection::schema() in D:\\code\\toys\\webman-admin\\plugin\\admin\\app\\controller\\database\\TableController.php:87\nStack trace:\n#0 D:\\code\\toys\\webman-admin\\vendor\\workerman\\webman-framework\\src\\App.php(276): plugin\\admin\\app\\controller\\database\\TableController->create(Object(support\\Request))\n#1 D:\\code\\toys\\webman-admin\\plugin\\admin\\app\\middleware\\AccessControl.php(21): Webman\\App::Webman\\{closure}(Object(support\\Request))\n#2 D:\\code\\toys\\webman-admin\\vendor\\workerman\\webman-framework\\src\\App.php(271): plugin\\admin\\app\\middleware\\AccessControl->process(Object(support\\Request), Object(Closure))\n#3 D:\\code\\toys\\webman-admin\\vendor\\workerman\\webman-framework\\src\\App.php(118): Webman\\App::Webman\\{closure}(Object(support\\Request))\n#4 D:\\code\\toys\\webman-admin\\vendor\\workerman\\workerman\\Connection\\TcpConnection.php(638): Webman\\App->onMessage(Object(Workerman\\Connection\\TcpConnection), Object(support\\Request))\n#5 D:\\code\\toys\\webman-admin\\vendor\\workerman\\workerman\\Events\\Select.php(295): Workerman\\Connection\\TcpConnection->baseRead(Resource id #296)\n#6 D:\\code\\toys\\webman-admin\\vendor\\workerman\\workerman\\Worker.php(2465): Workerman\\Events\\Select->loop()\n#7 D:\\code\\toys\\webman-admin\\vendor\\workerman\\workerman\\Worker.php(1449): Workerman\\Worker->run()\n#8 D:\\code\\toys\\webman-admin\\vendor\\workerman\\workerman\\Worker.php(1392): Workerman\\Worker::forkWorkersForWindows()\n#9 D:\\code\\toys\\webman-admin\\vendor\\workerman\\workerman\\Worker.php(557): Workerman\\Worker::forkWorkers()\n#10 D:\\code\\toys\\webman-admin\\vendor\\workerman\\webman-framework\\src\\support\\App.php(124): Workerman\\Worker::runAll()\n#11 D:\\code\\toys\\webman-admin\\start.php(4): support\\App::run()\n#12 {main}"
}
{
"name": "workerman/webman",
"type": "project",
"keywords": [
"high performance",
"http service"
],
"homepage": "http://www.workerman.net",
"license": "MIT",
"description": "High performance HTTP Service Framework.",
"authors": [
{
"name": "walkor",
"email": "[email protected]",
"homepage": "http://www.workerman.net",
"role": "Developer"
}
],
"support": {
"email": "[email protected]",
"issues": "https://github.com/walkor/webman/issues",
"forum": "http://wenda.workerman.net/",
"wiki": "http://workerman.net/doc/webman",
"source": "https://github.com/walkor/webman"
},
"require": {
"php": ">=7.2",
"workerman/webman-framework": "^1.4.3",
"monolog/monolog": "^2.0",
"webman/admin": "^0.2.4"
},
"suggest": {
"ext-event": "For better performance. "
},
"autoload": {
"psr-4": {
"": "./",
"App\\": "./app"
},
"files": [
"./support/helpers.php"
]
},
"scripts": {
"post-package-install": [
"support\\Plugin::install"
],
"post-package-update": [
"support\\Plugin::install"
],
"pre-package-uninstall": [
"support\\Plugin::uninstall"
]
}
}
/**
* 查询
* @param Request $request
* @return Response
/
public function select(Request $request): Response
{
$name = $request->get('name', '');
$page = $request->get('page', 1);
$limit = $request->get('limit', 10);
$offset = ($page-1)$limit;
if ($name && is_string($name)) {
$items = Option::where('name', 'like', "dict_$name%")->limit($limit)->offset($offset)->get()->toArray();
} else {
$items = Option::where('name', 'like', 'dict_%')->limit($limit)->offset($offset)->get()->toArray();
}
$get_items = Option::where('name', 'like', "dict_$name%")->get()->toArray();
$count = count($get_items);
foreach ($items as &$item) {
$item['name'] = Dict::optionNameTodictName($item['name']);
}
return json(['code' => 0, 'msg' => 'ok', 'count' => $count, 'data' => $items]);
}
预计啥时候更新新版本啊
按钮 里的
<button class="pear-btn pear-btn-primary pear-btn-md" lay-event="add" permission="app.admin.admin.insert">
<i class="layui-icon layui-icon-add-1"></i>新增
</button>
权限值 没有传递 设置上有什么意义么?
从页面右上角点击 基本资料
会跳转到 通用设置
-> 附件管理
,使原本的 附件管理
功能无法打开,应该高亮显示 个人资料
。
<!-- 功 能 菜 单 -->
<dl class="layui-nav-child">
<dd><a user-menu-url="/app/admin/account/index" user-menu-id="11" user-menu-title="基本资料">基本资料</a></dd>
<dd><a href="javascript:void(0);" class="logout">注销登录</a></dd>
</dl>
查看代码发现 user-menu-id
设置的是 11,而接口返回的正确的 id 是10。改成 10 果然就正确了,但是这个时候我多想了一下,这个菜单是怎么写入到数据库里的?
查看了插件中的 SQL 文件其中并没有批量插入菜单,而是通过读取配置文件里设置的菜单从上到下依次写入到数据库里面的,也就是说随着功能开发菜单顺序有可能改变,菜单的 id 也不是固定的。
不设置 user-menu-id
好像又无法正常跳转页面,需要解决一下菜单 id 不固定的问题。
修改表格时,在【字段属性】删除前面的行,【表单属性】最后一行的 【控件类型】【控件参数】会丢失
一键菜单生成的代码中,富文本编辑器全屏编辑无法触发blur事件
导致全屏编辑时直接提交表单会丢失富文本中更新的内容
原因如图:富文本全屏状态下,其div区域覆盖了表单提交按钮,而提交按钮z-index在富文本之上,导致点击提交按钮时,iframe子页面的焦点依然在富文本中
涉及代码段:
layui.use(["tinymce"], function() {
var tinymce = layui.tinymce
var edit = tinymce.render({
elem: "#text",
height: "400px",
'images_upload_url': "/app/admin/upload/image",
});
edit.on("blur", function(){
layui.$("#text").val(edit.getContent());
});
});
目前通过新增mouseleave事件解决
edit.on("MouseLeave", function(){
layui.$("#text").val(edit.getContent());
});
不确定是否有其他更好的方式
有没有考虑dcat admin或者laravel admin这种后台的开发方式呢 开发效率真的很快
期望官方未来能集成OSS上传模块,可以避免重复造轮子
大佬. 急需多语言支持
现在虽说也能自己加载多语言插件自己修改实现, 但迭代升级后怕是又被覆盖掉了. 我之前改了一个页面的, 挨着把文案给改成trans('XXX')了. 刚换完发现更新了. . 现在不知道是更还是不更. 更的话估计大概率又恢复回去了吧. . .
希望大佬采纳
角色管理中如果父角色被删除则子角色将变成顶级角色并将不可修改删除;
一旦出错只能通过修改数据库恢复其父级
{
"code": 500,
"msg": "Call to a member function connection() on null",
"type": "failed",
"traces": "Error: Call to a member function connection() on null in E:\\test\\webman\\vendor\\illuminate\\database\\Eloquent\\Model.php:1344\nStack trace:\n#0 E:\\test\\webman\\vendor\\illuminate\\database\\Eloquent\\Model.php(1310): Illuminate\\Database\\Eloquent\\Model::resolveConnection('plugin.admin.my...')\n#1 E:\\test\\webman\\vendor\\illuminate\\database\\Eloquent\\Model.php(1116): Illuminate\\Database\\Eloquent\\Model->getConnection()\n#2 E:\\test\\webman\\vendor\\illuminate\\database\\Eloquent\\Model.php(1033): Illuminate\\Database\\Eloquent\\Model->newBaseQueryBuilder()\n#3 E:\\test\\webman\\vendor\\illuminate\\database\\Eloquent\\Model.php(1069): Illuminate\\Database\\Eloquent\\Model->newModelQuery()\n#4 E:\\test\\webman\\vendor\\illuminate\\database\\Eloquent\\Model.php(1022): Illuminate\\Database\\Eloquent\\Model->newQueryWithoutScopes()\n#5 E:\\test\\webman\\vendor\\illuminate\\database\\Eloquent\\Model.php(1736): Illuminate\\Database\\Eloquent\\Model->newQuery()\n#6 E:\\test\\webman\\vendor\\illuminate\\database\\Eloquent\\Model.php(1748): Illuminate\\Database\\Eloquent\\Model->__call('first', Array)\n#7 E:\\test\\webman\\plugin\\admin\\app\\controller\\InstallController.php(201): Illuminate\\Database\\Eloquent\\Model::__callStatic('first', Array)\n#8 E:\\test\\webman\\vendor\\workerman\\webman-framework\\src\\App.php(319): plugin\\admin\\app\\controller\\InstallController->step2(Object(support\\Request))\n#9 E:\\test\\webman\\vendor\\workerman\\webman-framework\\src\\App.php(349): Webman\\App::Webman\\{closure}(Object(support\\Request))\n#10 E:\\test\\webman\\plugin\\admin\\app\\middleware\\AccessControl.php(47): Webman\\App::Webman\\{closure}(Object(support\\Request))\n#11 E:\\test\\webman\\vendor\\workerman\\webman-framework\\src\\App.php(341): plugin\\admin\\app\\middleware\\AccessControl->process(Object(support\\Request), Object(Closure))\n#12 E:\\test\\webman\\vendor\\workerman\\webman-framework\\src\\App.php(141): Webman\\App::Webman\\{closure}(Object(support\\Request))\n#13 E:\\test\\webman\\vendor\\workerman\\workerman\\Connection\\TcpConnection.php(646): Webman\\App->onMessage(Object(Workerman\\Connection\\TcpConnection), Object(support\\Request))\n#14 E:\\test\\webman\\vendor\\workerman\\workerman\\Events\\Select.php(311): Workerman\\Connection\\TcpConnection->baseRead(Resource id #199)\n#15 E:\\test\\webman\\vendor\\workerman\\workerman\\Worker.php(1479): Workerman\\Events\\Select->loop()\n#16 E:\\test\\webman\\vendor\\workerman\\workerman\\Worker.php(1399): Workerman\\Worker::forkWorkersForWindows()\n#17 E:\\test\\webman\\vendor\\workerman\\workerman\\Worker.php(560): Workerman\\Worker::forkWorkers()\n#18 E:\\test\\webman\\vendor\\workerman\\webman-framework\\src\\support\\App.php(131): Workerman\\Worker::runAll()\n#19 E:\\test\\webman\\start.php(4): support\\App::run()\n#20 {main}"
}
提交在评论里了
类似于 easyadmin 的菜单效果,顶部是一级,然后侧边栏开始是二级:
https://foruda.gitee.com/images/1675992228886678362/5f71203a_5507348.jpeg
如图,像系统相关的属于系统模块菜单,商城相关的属于商城模块菜单。
如果菜单不分模块的话,那么不同模块的菜单会混合在一起,不以利查找和管理。
赋值富文本数据会显示标签,富文本赋值应该是obj.html(,而不是obj.val(,麻烦修改一下
install.sql 是否有必要加上 COLLATE=utf8mb4_general_ci 呢
admin的菜单排序字段好像没有,现在的排序好像是先增加的菜单先显示
pear admin和layui都有了新版本,直接替换,发现有很多问题,具体要更新哪些地方,可以出个指南,到时候社区直接完成这个事情。
查询日期范围的时候,目前只能显示一个文本字段,这样对范围选择很不友好,希望能使用日期控件进行选择,并且能自动识别时间戳的内容。
后台登陆,提示验证码不正确,最后发现是session没有获取到,session已经正确设置了,就是拿不到session,是什么原因呢?相同的nginx代理配置,在其它端是可以正确设置获取session的。
/app/admin/component/pear/css/img/loading.gif not found
正常安装配置后,可以访问后台,现在设置配置文件的前缀,就不能打开原来的表,建议是不是在安装填写数据库配置时就增加的前缀选项。
layui有新版本了,可以直接替换么?
index 页面
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>浏览页面</title>
<link rel="stylesheet" href="/app/admin/component/pear/css/pear.css" />
<link rel="stylesheet" href="/app/admin/admin/css/reset.css" />
</head>
<body class="pear-container">
<!-- 顶部查询表单 -->
$html
<!-- 数据表格 -->
<div class="layui-card">
<div class="layui-card-body">
<table id="data-table" lay-filter="data-table"></table>
</div>
</div>
<!-- 表格顶部工具栏 -->
<script type="text/html" id="table-toolbar">
<button class="pear-btn pear-btn-primary pear-btn-md" lay-event="add" permission="$code_base.insert">
<i class="layui-icon layui-icon-add-1"></i>新增
</button>
<button class="pear-btn pear-btn-danger pear-btn-md" lay-event="batchRemove" permission="$code_base.delete">
<i class="layui-icon layui-icon-delete"></i>删除
</button>
</script>
<!-- 表格行工具栏 -->
<script type="text/html" id="table-bar">
<button class="pear-btn pear-btn-xs tool-btn" lay-event="edit" permission="$code_base.update">编辑</button>
<button class="pear-btn pear-btn-xs tool-btn" lay-event="remove" permission="$code_base.delete">删除</button>
</script>
<script src="/app/admin/component/layui/layui.js"></script>
<script src="/app/admin/component/pear/pear.js"></script>
<script src="/app/admin/admin/js/permission.js"></script>
<script src="/app/admin/admin/js/common.js"></script>
<script>
// 相关常量
const PRIMARY_KEY = "$primary_key";
const SELECT_API = "$url_path_base/select";
const UPDATE_API = "$url_path_base/update";
const DELETE_API = "$url_path_base/delete";
const INSERT_URL = "$url_path_base/insert";
const UPDATE_URL = "$url_path_base/update";
$js
// 表格渲染
layui.use(["table", "form", "common", "popup", "util"], function() {
let table = layui.table;
let form = layui.form;
let $ = layui.$;
let common = layui.common;
let util = layui.util;
let whereNow = {};
$table_js
// 编辑或删除行事件
table.on("tool(data-table)", function(obj) {
if (obj.event === "remove") {
remove(obj);
} else if (obj.event === "edit") {
edit(obj);
}
});
// 表格顶部工具栏事件
table.on("toolbar(data-table)", function(obj) {
if (obj.event === "add") {
add();
} else if (obj.event === "refresh") {
refreshTable();
} else if (obj.event === "batchRemove") {
batchRemove(obj);
}
});
// 表格顶部搜索事件
form.on("submit(table-query)", function(data) {
whereNow = data.field;
table.reload("data-table", {
page: {
curr: 1
},
where: data.field
})
return false;
});
// 表格顶部搜索重置事件
form.on("submit(table-reset)", function(data) {
table.reload("data-table", {
where: []
})
});
// 字段允许为空
form.verify({
phone: [/(^$)|^1\d{10}$/, "请输入正确的手机号"],
email: [/(^$)|^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/, "邮箱格式不正确"],
url: [/(^$)|(^#)|(^http(s*):\/\/[^\s]+\.[^\s]+)/, "链接格式不正确"],
number: [/(^$)|^\d+$/,'只能填写数字'],
date: [/(^$)|^(\d{4})[-\/](\d{1}|0\d{1}|1[0-2])([-\/](\d{1}|0\d{1}|[1-2][0-9]|3[0-1]))*$/, "日期格式不正确"],
identity: [/(^$)|(^\d{15}$)|(^\d{17}(x|X|\d)$)/, "请输入正确的身份证号"]
});
// 表格排序事件
table.on("sort(data-table)", function(obj){
let theWhere = {
field: obj.field,
order: obj.type
};
let sortWhere = {...whereNow, ...theWhere}
table.reload("data-table", {
initSort: obj,
scrollPos: "fixed",
where: sortWhere
});
});
// 表格新增数据
let add = function() {
layer.open({
type: 2,
title: "新增",
shade: 0.1,
shadeClose:true,
area: [common.isModile()?"100%":"500px", common.isModile()?"100%":"450px"],
content: INSERT_URL
});
}
// 表格编辑数据
let edit = function(obj) {
let value = obj.data[PRIMARY_KEY];
layer.open({
type: 2,
title: "修改",
shade: 0.1,
shadeClose:true,
area: [common.isModile()?"100%":"500px", common.isModile()?"100%":"450px"],
content: UPDATE_URL + "?" + PRIMARY_KEY + "=" + value
});
}
// 删除一行
let remove = function(obj) {
return doRemove(obj.data[PRIMARY_KEY]);
}
// 删除多行
let batchRemove = function(obj) {
let checkIds = common.checkField(obj, PRIMARY_KEY);
if (checkIds === "") {
layui.popup.warning("未选中数据");
return false;
}
doRemove(checkIds.split(","));
}
// 执行删除
let doRemove = function (ids) {
let data = {};
data[PRIMARY_KEY] = ids;
layer.confirm("确定删除?", {
icon: 3,
title: "提示"
}, function(index) {
layer.close(index);
let loading = layer.load();
$.ajax({
url: DELETE_API,
data: data,
dataType: "json",
type: "post",
success: function(res) {
layer.close(loading);
if (res.code) {
return layui.popup.failure(res.msg);
}
return layui.popup.success("操作成功", refreshTable);
}
})
});
}
// 刷新表格数据
window.refreshTable = function(param) {
table.reloadData("data-table", {
scrollPos: "fixed"
});
}
})
</script>
</body>
</html>
```
`
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.