From 714c60314b41419c329c9dcf498962cb80da179b Mon Sep 17 00:00:00 2001 From: Xia Chao <236466140+bun-unsafe@users.noreply.github.com> Date: Fri, 4 Sep 2026 03:49:44 +0800 Subject: [PATCH] =?UTF-8?q?fix(mp-toutiao):=20=E5=81=9C=E6=AD=A2=E5=AF=B9?= =?UTF-8?q?=E5=90=8C=E6=AD=A5=E5=AD=90=E7=BB=84=E4=BB=B6=E5=BC=BA=E5=88=B6?= =?UTF-8?q?=E6=B3=A8=E5=85=A5=20componentPlaceholder?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes #6057 --- .../uni-cli-shared/__tests__/cache.spec.js | 18 +++++++++--------- packages/uni-cli-shared/lib/cache.js | 12 ------------ 2 files changed, 9 insertions(+), 21 deletions(-) diff --git a/packages/uni-cli-shared/__tests__/cache.spec.js b/packages/uni-cli-shared/__tests__/cache.spec.js index 3ab10ff484..af554befc1 100644 --- a/packages/uni-cli-shared/__tests__/cache.spec.js +++ b/packages/uni-cli-shared/__tests__/cache.spec.js @@ -80,31 +80,31 @@ describe('shared:cache', () => { }) it('mp-toutiao generate component.json', () => { + const prevPlatform = process.env.UNI_PLATFORM process.env.UNI_PLATFORM = 'mp-toutiao' - const name = 'components/component-tag-name' + // 独立 name:覆盖 add 与 update。不得再强制注入 componentPlaceholder(#6057) + const name = 'components/toutiao-no-force-placeholder' let usingComponents = { 'my-component': '/components/component-tag-name' } - const componentPlaceholder = { - 'my-component': 'view' - } updateUsingComponents(name, usingComponents, 'Component') let componentJsonStr = getChangedJsonFileMap().get(name + '.json') expect(componentJsonStr).toBe(JSON.stringify({ usingComponents, - component: true, - componentPlaceholder + component: true }, null, 2)) expect(0).toBe(getChangedJsonFileMap().size) - usingComponents = {} + usingComponents = { + 'u-icon': '/components/u-icon' + } updateUsingComponents(name, usingComponents, 'Component') componentJsonStr = getChangedJsonFileMap().get(name + '.json') expect(componentJsonStr).toBe(JSON.stringify({ usingComponents, - component: true, - componentPlaceholder + component: true }, null, 2)) expect(0).toBe(getChangedJsonFileMap().size) + process.env.UNI_PLATFORM = prevPlatform }) }) diff --git a/packages/uni-cli-shared/lib/cache.js b/packages/uni-cli-shared/lib/cache.js index ff34a0213c..54f28e25da 100644 --- a/packages/uni-cli-shared/lib/cache.js +++ b/packages/uni-cli-shared/lib/cache.js @@ -200,18 +200,6 @@ function updateUsingComponents (name, usingComponents, type, content = '') { } if (oldJsonStr) { // update jsonObj.usingComponents = usingComponents - // 嵌套组件获取 props 为 null,使用占组件修正父子组件生命周期执行顺序 https://developer.open-douyin.com/docs/resource/zh-CN/mini-app/develop/tutorial/custom-component/placeholder - if (process.env.UNI_PLATFORM === 'mp-toutiao') { - if (type === 'Component') { - const usingComponentnames = Object.keys(jsonObj.usingComponents) - if (usingComponentnames.length) { - jsonObj.componentPlaceholder = {} - usingComponentnames.forEach(componentName => { - jsonObj.componentPlaceholder[componentName] = 'view' - }) - } - } - } const newJsonStr = JSON.stringify(jsonObj, null, 2) if (newJsonStr !== oldJsonStr) { updateJsonFile(name, newJsonStr)