feat: P0-2抽纯函数+补a-g断言13组+P1-2编辑器空覆盖守卫
P0-2: - content-adapter.js: 解耦Node crypto(客户端直引), 新增mergeCmsItem/normalizeThumbnail/buildPublishPayload - buildPublishPayload补normalizeCmsList归一(抓到vote_id漏生成真bug) - check-article-flow.js: 4组->13组断言,覆盖a-g P1-2: - editText.vue/smallTitle.vue getContents成功回调加空覆盖守卫 - editSetting封面已统一字符串数组,无需改动 验证: verify.js全绿,h5构建90 JS通过
This commit is contained in:
@@ -99,6 +99,16 @@
|
||||
success: async (res) => {
|
||||
let { html, text, delta } = res
|
||||
const oldItem = cms.cmsLst[index]
|
||||
// P1-2 空覆盖守卫(同源 content-adapter.mergeCmsItem):
|
||||
// editor ready 但内容未 hydrate 时空串会把原文字抹掉
|
||||
const nextText = text || ''
|
||||
const hadContent = Boolean(oldItem.text || oldItem.html)
|
||||
const gotContent = Boolean(nextText || html || (delta && delta.ops && delta.ops.length))
|
||||
if (hadContent && !gotContent) {
|
||||
console.warn('编辑器内容为空,跳过覆盖以防丢稿')
|
||||
await back()
|
||||
return
|
||||
}
|
||||
cms.cmsLst[index] = {
|
||||
...oldItem,
|
||||
text: text || '',
|
||||
|
||||
@@ -120,6 +120,17 @@
|
||||
if (!cms || !Array.isArray(cms.cmsLst) || !editorCtx.value) return
|
||||
editorCtx.value.getContents({
|
||||
success: async ({ html = '', text = '', delta = { ops: [] } }) => {
|
||||
// P1-2 空覆盖守卫:编辑已有小标题时,空内容直接返回不覆写
|
||||
if (editingIndex.value >= 0 && cms.cmsLst[editingIndex.value]?.type === 'title') {
|
||||
const oldItem = cms.cmsLst[editingIndex.value]
|
||||
const hadContent = Boolean(oldItem.text || oldItem.html)
|
||||
const gotContent = Boolean(text || html || (delta && delta.ops && delta.ops.length))
|
||||
if (hadContent && !gotContent) {
|
||||
console.warn('小标题内容为空,跳过覆盖以防丢稿')
|
||||
await back()
|
||||
return
|
||||
}
|
||||
}
|
||||
if (!text.trim() && !html.trim()) {
|
||||
uni.showToast({ title: '小标题不能为空', icon: 'none' })
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user