Files
YwxAppThink/addon/blog/view/backend/user/index.html
T
yangwx 18101cf11a feat: 上线前安全加固与发布工程化;appmall 由插件迁移为独立应用
安全(P0)
- 发布包签名:新增 scripts/package_keygen.php、scripts/package_verify.php、
  ywxapp\service\PackageVerifier;FrameworkService::apply() 解压前强制验签
  (ywxapp.framework_package_verify,默认开启)
- JWT 收紧:config/jwt.php 移除公开默认密钥,JwtService::assertStrongSecret()
  校验非空 / 长度≥32 / 已知弱值;.env.production.example 键名由 JWT_SECRET_KEY 修正为 JWT_SECRET
- /api/v1/Article:免登录白名单收窄为只读接口,写操作字段白名单 + assertOwner() 越权校验
- 开发者令牌:查找接口不再回显明文、统一失败文案 + 限流
- TemplateInstaller:文件名白名单 + realpath 归一化 + 目录内断言,修复 Zip Slip;补 use ZipArchive
- 后台登录:接入验证码、失败锁定与登录限流(config/ratelimit.php)
- 缓存 / Session 驱动可由 .env 覆盖(CACHE_DRIVER / SESSION_TYPE),集群部署改 redis
- paycenter 支付日志开关改为 PAY_LOG,不再跟随 APP_DEBUG

工程化 / 交付
- 新增 CHANGELOG.md 与 .env.production.example;composer.lock 入库锁定依赖版本
- 插件离线安装 CLI 增加 --uid,后台上传安装透传 uid,付费插件授权校验可通过
- 授权拒绝文案区分「未携带 uid」与「未找到有效授权」,便于排障
- .gitignore 放行 .env.production.example / .env.addon.example / .gitattributes / public/.htaccess

结构
- appmall 由 addon/appmall 迁移为独立应用 app/appmall(市场 / 开发者中心 / 审核 / 分润)
2026-10-22 00:53:39 +08:00

117 lines
4.9 KiB
HTML

<div class="layui-fluid">
<div class="admin-title">用户管理</div>
<div class="layui-card">
<div class="layui-card-body">
<form class="layui-form layui-inline" lay-filter="searchForm">
<div class="layui-inline">
<select name="status">
<option value="all">全部状态</option>
<option value="1">正常</option>
<option value="0">禁用</option>
<option value="-1">删除</option>
</select>
</div>
<div class="layui-inline">
<input type="text" name="keyword" placeholder="搜索账号/昵称/邮箱/手机号" class="layui-input" id="keywordInput">
</div>
<div class="layui-inline">
<button class="layui-btn layui-btn-primary" lay-submit lay-filter="search">搜索</button>
</div>
<button type="button" class="layui-btn layui-btn-danger" id="batchDeleteBtn">批量删除</button>
</form>
<table class="layui-hide" id="userTable" lay-filter="userTable"></table>
</div>
</div>
</div>
<script type="text/html" id="rowTpl">
<a class="layui-btn layui-btn-xs" href="{{ d.edit_url }}">编辑</a>
<a class="layui-btn layui-btn-xs layui-btn-danger" lay-event="delete">删除</a>
</script>
<script>
layui.use(['table', 'layer', 'form', 'http', 'ywxapp'], function () {
var http = layui.http;
var table = layui.table;
var layer = layui.layer;
var form = layui.form;
var $ = layui.$;
var status = '{$status|default="all"}';
var keyword = '{$keyword|default=""}';
$('select[name="status"]').val(status);
$('#keywordInput').val(keyword);
var renderTable = function () {
table.render({
elem: '#userTable',
url: '{:url("blog/backend.user/index")}',
where: { status: status, keyword: keyword },
page: true,
cols: [[
{ type: 'checkbox', fixed: 'left' },
{ field: 'uid', title: 'UID', width: 80, sort: true },
{ field: 'account', title: '账号', width: 140 },
{ field: 'nickname', title: '昵称', width: 140 },
{ field: 'email', title: '邮箱', minWidth: 160 },
{ field: 'mobile', title: '手机号', width: 130 },
{ field: 'article_count', title: '文章数', width: 90, sort: true, align: 'center' },
{ field: 'status_text', title: '状态', width: 90, templet: function (d) {
var map = { '正常': 'layui-bg-green', '禁用': 'layui-bg-gray', '删除': 'layui-bg-red' };
var cls = map[d.status_text] || 'layui-bg-gray';
return '<span class="layui-badge ' + cls + '">' + d.status_text + '</span>';
} },
{ field: 'create_at', title: '注册时间', width: 160 },
{ field: 'update_at', title: '最后登录', width: 160 },
{ title: '操作', width: 130, align: 'center', toolbar: '#rowTpl', fixed: 'right' }
]]
});
};
renderTable();
// 搜索
form.on('submit(search)', function () {
var statusVal = $('select[name="status"]').val();
var kw = $('#keywordInput').val();
table.reload('userTable', { where: { status: statusVal, keyword: kw }, page: { curr: 1 } });
return false;
});
// 批量删除
$('#batchDeleteBtn').click(function () {
var checkData = table.checkStatus('userTable').data;
if (! checkData.length) {
return layer.msg('请选择要删除的用户');
}
var ids = checkData.map(function (i) { return i.uid; });
layer.confirm('确定要删除选中的 ' + ids.length + ' 个用户吗?', function (index) {
http.post('{:url("blog/backend.user/batch")}', { ids: ids }).then(function (res) {
if (res.code === 1) {
layer.msg(res.msg, { icon: 1 }, function () { renderTable(); });
} else {
layer.msg(res.msg, { icon: 2 });
}
});
layer.close(index);
});
});
// 行操作
table.on('tool(userTable)', function (obj) {
if (obj.event === 'delete') {
layer.confirm('确定要删除该用户吗?', function (index) {
http.post('{:url("blog/backend.user/delete")}', { id: obj.data.uid }).then(function (res) {
if (res.code === 1) {
layer.msg(res.msg, { icon: 1 }, function () { renderTable(); });
} else {
layer.msg(res.msg, { icon: 2 });
}
});
layer.close(index);
});
}
});
});
</script>