Files
YwxAppThink/public/static/backend/modules/attachment.js
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

148 lines
5.5 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/**
* 附件统一管理(common_attachment)
*
* 删除走后台 Attachment::delete():先经 FileStorageService 触发 FileDelete 事件
* (OSS / FTP 等自定义存储在此接管物理删除),再软删记录。
*/
layui.define(['table', 'layer', 'form', 'auth', 'http', 'jquery'], function (exports) {
var table = layui.table,
layer = layui.layer,
form = layui.form,
auth = layui.auth,
http = layui.http,
$ = layui.jquery;
// URL 由浏览器按当前页面目录解析(/admin/attachment/),只写动作名
var FUNC = {
index: 'index',
delete: 'delete'
};
function parse(res) {
return {
code: res.code,
msg: res.message,
count: res.count || 0,
data: res.data || []
};
}
function post(url, data, done) {
var loading = layer.load(2);
http.post(url, data).then(function (res) {
layer.close(loading);
if (res && res.code === 0) {
layer.msg(res.message || '操作成功', {icon: 1});
if (done) { done(res.data); }
} else {
layer.msg((res && res.message) || '操作失败', {icon: 2});
}
}).catch(function (err) {
layer.close(loading);
layer.msg('请求失败:' + (err && err.message ? err.message : '网络异常'), {icon: 2});
});
}
function checkedIds() {
var rows = table.checkStatus('dataTable').data || [];
var ids = [];
for (var i = 0; i < rows.length; i++) { ids.push(rows[i].id); }
return ids;
}
var obj = {
render: function () {
table.render({
elem: '#dataTable',
url: FUNC.index,
where: {},
toolbar: '#tableBar',
defaultToolbar: ['filter'],
method: 'get',
cols: [[
{type: 'checkbox', width: 50},
{field: 'id', title: 'ID', width: 70, sort: true},
{title: '预览', width: 70, templet: '#thumbTpl', align: 'center'},
{field: 'original', title: '文件名', minWidth: 220},
{field: 'module', title: '模块', width: 90},
{field: 'size_text', title: '大小', width: 100},
{field: 'storage', title: '存储', width: 90},
{field: 'uid', title: '上传者', width: 90},
{field: 'create_at_text', title: '时间', width: 170, sort: true},
{title: '操作', width: 130, toolbar: '#dataBar', fixed: 'right'}
]],
page: true,
limit: 20,
limits: [20, 50, 100],
response: {statusCode: 0},
parseData: parse,
done: function () {
auth.filterDom($('#dataTable').next('.layui-table-view'));
auth.filterDom('.layui-btn[data-perm]');
}
});
},
events: function () {
table.on('toolbar(dataTable)', function (o) {
if (o.event === 'deleteSelected') {
var ids = checkedIds();
if (ids.length === 0) {
return layer.msg('请先勾选要删除的附件', {icon: 2});
}
layer.confirm(
'确定删除选中的 ' + ids.length + ' 个附件?<br><span style="color:#ff5722">会同时删除存储上的文件</span>',
{title: '提示'},
function (index) {
layer.close(index);
post(FUNC.delete, {ids: ids}, function () {
table.reload('dataTable');
setTimeout(function () { location.reload(); }, 800);
});
}
);
}
});
table.on('tool(dataTable)', function (o) {
if (o.event === 'open') {
window.open(o.data.url, '_blank');
} else if (o.event === 'delete') {
layer.confirm('确定删除该附件?会同时删除存储上的文件', {title: '提示'}, function (index) {
layer.close(index);
post(FUNC.delete, {ids: [o.data.id]}, function () {
table.reload('dataTable');
setTimeout(function () { location.reload(); }, 800);
});
});
}
});
form.on('submit(data-search-btn)', function (o) {
table.reload('dataTable', {
where: {
keyword: o.field.keyword,
module: o.field.module,
only_image: o.field.only_image ? 1 : 0
},
page: {curr: 1}
});
return false;
});
$('#btn-reset').on('click', function () {
setTimeout(function () {
table.reload('dataTable', {
where: {keyword: '', module: '', only_image: 0},
page: {curr: 1}
});
}, 10);
});
}
};
obj.render();
obj.events();
exports('attachment', obj);
});