15m44j img.json 新格式 + 懒重载 + 修 API 挂起/删图不让提交

用户定调: img.json 格式调整(嵌套 api.baseurl/key + 图像/附件支持.最大图片数量/.最大大小/.后缀格式),
代码读新格式; img.json 懒重载(每次新建工单时增量读); 先取消假定未更改推仓库; 删图后能正常提交。

根因 3 个:
1. API 挂起: 生产 img.json 还是旧格式(baseurl/key 顶层), loadImgJson 按旧路径读 → 但
   easyUploadFile 用新格式路径 api.baseurl 拿不到 → curl 挂起 60s。
2. 删图不让提交: removeTicketImg 用 files.splice 删了数组但 ticketState.files 引用没同步
   (旧代码 splice 后没重新赋值), 提交时 ticketState.files 还残留已删元素。
3. 硬编码 3/2048K/png|jpg: 前端 uploadTicketImage 写死, 后端 uploadTicketFiles 也写死,
   与 img.json 配置不同步。

修 5 处:
1. img.json 本地改新格式(api.baseurl/api.key + 图像/附件支持嵌套), 取消假定未更改, 入库。
2. lsky.php loadImgJson(): 改读新格式 api.baseurl/key + 图像/附件支持.附件支持/.最大图片数量/
   .最大大小/.后缀格式, 兼容旧格式(顶层 baseurl/key + 图像/附件支持布尔); 每次调用重新读文件
   (懒重载, 不缓存); 返回统一结构含 max_images/max_size_mb/allowed_exts/attach_enabled。
3. api/ticket.php: 新增 ticketMaxImages() 读 loadImgJson().max_images; uploadTicketFiles 开头
   调 loadImgJson 懒重载, 按 attach_enabled 决定是否接文件, 按 max_images/max_size_mb/
   allowed_exts 校验; 真实格式(getimagesize)必须在 img.json 允许后缀里。
4. 新增 api/img_cfg.php: 前端 fetch 端点, 返回 {max_images, max_size_mb, allowed_exts,
   attach_enabled} (无 token 校验, 配置非敏感), 每次请求重新读 img.json。
5. player.php: 新增 loadTicketImgCfg() fetch img_cfg.php, uploadTicketImage 前懒重载;
   校验改 ticketImgCfg.max_images/max_size_mb/allowed_exts(不再硬编码 3/2048K);
   removeTicketImg 修 splice 后重新赋值 ticketState.files(同步清数组引用), 删占位符,
   提示"已移除 图片N(剩 M 张可提交)"。

部署清单: img.json(新格式) + lsky.php + api/ticket.php + player.php + api/img_cfg.php(新)。
生产 FTP 推 img.json 新格式(baseurl/key 改 api. 嵌套) + opcache_invalidate.php。
This commit is contained in:
ypsdf1
2026-11-24 21:57:56 +08:00
parent 7e700cadd1
commit f94e155208
5 changed files with 160 additions and 55 deletions
+19 -15
View File
@@ -16,24 +16,28 @@
"备注": "仓库类型2选1,同时双开默认public"
}
},
"图像/附件支持": true,
"图片大小(单位KB)": 2048,
"图片备注": "仅使用图床时填写,GitHub可不填",
"baseurl": "https://example.com/",
"key": "example",
"后缀格式": {
"写法标准": "1行1个",
"建议": "仅开放常见格式,比如jpg、png等",
"type": [
"图像/附件支持": {
"附件支持": true,
"最大图片数量": 3,
"最大大小": 3,
"备注": [
"1. 最大大小默认是MB",
"2. 后缀格式1行1个"
],
"后缀格式": [
"jpg",
"png",
"bmp",
"jpeg"
]
},
"说明": [
"1. 默认支持简单图床EasyImages2.0",
"2. 记得在设置-图床安全-API上传点上",
"3. 部署后把 baseurl/key 改成真实值(单文件直接改, 不建template不gitignore)"
]
}
"api": {
"baseurl": "https://example.com/",
"key": "example",
"说明": [
"1. key和API地址都要填",
"2. 如果附件支持为true但api没配置自动退回false",
"3. 记得在EasyImages2.0后台-图床安全里,开启API上传"
]
}
}