fix: copy pop-up modal logic displays abnormally#1365
fix: copy pop-up modal logic displays abnormally#1365chilingling merged 10 commits intoopentiny:release/v2.5.xfrom
Conversation
WalkthroughThe import Changes
Poem
Tip ⚡️ Faster reviews with caching
Enjoy the performance boost—your workflow just got faster. 📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
|
场景:
|
Scene:
|
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (1)
packages/toolbars/save/src/js/index.ts (1)
67-69: Excellent addition to fix the data synchronization issue.Adding a call to
updatePageSettingAfterSave()after the page update completes ensures that the internal data copy (currentPageDataCopy) is synchronized with the latest saved state. This directly addresses the issue described in the PR objectives where the copy pop-up modal was incorrectly appearing after saving becausecurrentPageDataCopywasn't updated. This change will prevent the system from incorrectly detecting unsaved changes after a save operation.Consider wrapping this call in a try-catch block similar to other function calls in this file (like
saved()on line 175), to maintain consistent error handling throughout the codebase:isLoading.value = false // 更新页面设置状态,同步 currentPageDataCopy + try { usePage().updatePageSettingAfterSave() + } catch (error) { + useNotify({ + type: 'error', + message: `Error in updating page settings: ${error}` + }) + }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
packages/plugins/page/src/composable/usePage.ts(6 hunks)packages/toolbars/save/src/js/index.ts(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- packages/plugins/page/src/composable/usePage.ts
⏰ Context from checks skipped due to timeout of 90000ms (1)
- GitHub Check: push-check
一、问题分析保存页面时,仅更新了 Canvas 的状态为“已保存”, 二、结论缺乏对 currentPageDataCopy 的更新,导致页面设置状态与 Canvas 状态不一致,引发用户混淆。 三、解决方案在 usePage.ts 中新增 updatePageSettingAfterSave() 方法,用于同步 currentPageData 和 currentPageDataCopy 修改工具栏中的 savePage() 函数,在保存后调用上述同步方法 |
1. Problem analysisWhen saving the page, only the Canvas status is updated to "Save". 2. ConclusionThe lack of updates to currentPageDataCopy causes the page setting status to be inconsistent with the Canvas status, causing user confusion. 3. SolutionAdded updatePageSettingAfterSave() method in usePage.ts to synchronize currentPageData and currentPageDataCopy Modify the savePage() function in the toolbar and call the above synchronization method after saving |
修复:点击复制页面,弹出"您即将复制的页面有更改未保存,是否确定跳过更改直接复制?",但复制页面并没有更改未保存
English | 简体中文
PR
PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
Background and solution
【备注】
#1361 为 前置 PR: 解决页面复制路由更新问题
【问题描述】
点击复制页面,弹出"您即将复制的页面有更改未保存,是否确定跳过更改直接复制?",但复制页面并没有更改未保存
【问题分析】
点击 复制页面 后,会执行下述步骤:
copyPage()对当前页面的信息进行保存和更新;isCurrentDataSame()对data和dataCopy进行对比;isCurrentDataSame()的返回值决定是否展示 “更改未保存” 弹窗;【结论】
第二步对比错误,导致弹窗总是出现,由下述原因导致:
pageSettingState.currentPageData未更新,isCurrentDataSame()中没有对page_content中的children信息进行对比【解决方案】
pageSettingState.currentPageData,isCurrentDataSame()中增加对page_content中的children信息进行对比syncPageContent增加判断:只有当前页面设置的ID与正在编辑的页面ID一致时才同步内容,避免将正在编辑的页面内容错误同步到其他打开的页面设置中【测试场景】
打开应用 A 页面,打开页面管理插件,
打开 A 页面的设置页面。点击复制,表现正常✅
打开应用 A 页面,编辑,不保存。
打开页面管理插件,打开 A 页面的设置页面。
点击复制,提示未保存。表现正常✅,
点击工具栏保存按钮,页面提示为保存状态。
再次点击复制按钮,表现正常✅
What is the current behavior?
Issue Number: N/A
What is the new behavior?
Does this PR introduce a breaking change?
Other information
Summary by CodeRabbit
Summary by CodeRabbit