feat: 打通 HBuilderX CLI 构建 + 修复文章闭环静态盲区

构建:
- 新增 tools/build.js:junction HBuilderX 工具链,CLI 构建 h5/mp-weixin
- vue 指向补丁版 @dcloudio/uni-h5-vue(官方 npm vue 不导出 isInSSRComponentSetup)
- 设 HX_APP_ROOT 避免退化成 H5 空壳产物;产物完整性校验

校验工具:
- 新增 check-cloud-methods.js:acorn 解析云对象方法,比对 94 处调用点
- 新增 check-android-contract.js:Kotlin 侧云对象契约校验
- audit-project.js 修 downloadFile 误报(注释未剥离);tools/ 排除出扫描
- package.json 声明此前隐式依赖的 acorn

功能:
- 补 uni-cms-articles.getPublishedArticles(安卓端依赖但此前不存在)
- 修 u-parse <audio> 引用已移除组件导致 H5 构建失败
This commit is contained in:
2026-09-12 01:02:45 +08:00
parent 4f5893f87a
commit 3117146281
26 changed files with 2043 additions and 337 deletions
@@ -1,5 +1,6 @@
const uniID = require('uni-id-common');
const db = uniCloud.database();
// 密钥不要硬编码在源码里:请在 uniCloud 控制台为本云函数配置环境变量
// (或使用 uni-config-center 统一管理),否则源码一旦外泄等于存储桶失守。
@@ -61,18 +62,23 @@ module.exports = {
// return res;
// },
// // 删除文件
async deleteFile(data = {}) {
const { role, errCode } = await uniID.createInstance({ context: this.getClientInfo() }).checkToken(this.getUniIdToken());
if (errCode || !(role || []).includes('admin')) throw new Error('仅管理员可删除文件');
let {
fileList
} = data;
console.log(fileList)
let res = await extStorageManager.deleteFile({
fileList
});
console.log('deleteFile: ', res);
return res;
}
async deleteFile(data = {}) {
const payload = await uniID.createInstance({ context: this.getClientInfo() }).checkToken(this.getUniIdToken());
if (payload.errCode) throw new Error('请先登录');
const fileList = Array.isArray(data.fileList) ? data.fileList.filter(Boolean) : [];
if (!fileList.length) throw new Error('缺少文件地址');
if ((payload.role || []).includes('admin')) {
return extStorageManager.deleteFile({ fileList });
}
const articleId = data.article_id || data.articleId;
if (!articleId) throw new Error('普通用户删除文件必须提供文章 id');
const articleRes = await db.collection('uni-cms-articles').doc(articleId).field({ user_id: true, cmsLst: true, thumbnail: true }).get();
const article = articleRes.data && articleRes.data[0];
if (!article || article.user_id !== payload.uid) throw new Error('无权删除该文章文件');
const refs = JSON.stringify(article);
if (fileList.some(file => !refs.includes(file))) throw new Error('文件不是该文章引用资源');
return extStorageManager.deleteFile({ fileList });
}
}