feat:adjust the homepage and default page settings mode#1214
feat:adjust the homepage and default page settings mode#1214hexqi merged 8 commits intoopentiny:developfrom
Conversation
WalkthroughThe changes update the page management workflow by modifying function signatures to include an Changes
Possibly related PRs
Suggested labels
Suggested reviewers
Poem
Warning There were issues while running some tools. Please review the errors and either fix the tool’s configuration or disable the tool if it’s a critical failure. 🔧 ESLint
ERR_PNPM_OPTIONAL_DEPS_REQUIRE_PROD_DEPS Optional dependencies cannot be installed without production dependencies 📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
⏰ Context from checks skipped due to timeout of 90000ms (1)
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
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 (
|
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (2)
packages/plugins/page/src/PageGeneral.vue (2)
56-67: Replaced checkbox with dropdown for default page selection.The UI enhancement from checkbox to dropdown allows users to select a specific child page as the default, which is more intuitive than the previous approach. However, consider these improvements:
- Add a "None" option to allow clearing the default page selection
- Include visual feedback when the selection is saved
<tiny-select v-model="state.defaultPageId" :options="state.childPageOp" placeholder="请选择默认跳转页" @change="changeDefaultPage" + clearable ></tiny-select>
117-136: Add error handling to the async child page fetching.The function to set child and default pages should include error handling for the asynchronous operation.
const setChildAndDefaultPage = async (id) => { if (pageSettingState.isNew) { state.childPageList = [] state.childPageOp = [] state.defaultPageId = '' } else { - state.childPageList = await getPageChildren(id) - if (state.childPageList?.length) { - state.defaultPageId = state.childPageList?.find((item) => item.isDefault)?.id - state.childPageOp = state.childPageList.map((item) => { - return { - value: item.id, - label: item.name, - icon: iconFile() - } - }) - setDefaultPage(state.childPageList, state.defaultPageId) - } + try { + state.childPageList = await getPageChildren(id) + if (state.childPageList?.length) { + state.defaultPageId = state.childPageList?.find((item) => item.isDefault)?.id + state.childPageOp = state.childPageList.map((item) => { + return { + value: item.id, + label: item.name, + icon: iconFile() + } + }) + setDefaultPage(state.childPageList, state.defaultPageId) + } + } catch (error) { + console.error('Failed to fetch child pages:', error) + // Consider adding user notification here + } } }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (6)
packages/common/js/http.js(2 hunks)packages/plugins/page/src/Main.vue(5 hunks)packages/plugins/page/src/PageGeneral.vue(4 hunks)packages/plugins/page/src/PageSetting.vue(4 hunks)packages/plugins/page/src/PageTree.vue(3 hunks)packages/plugins/page/src/composable/usePage.js(4 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
- GitHub Check: push-check
🔇 Additional comments (26)
packages/common/js/http.js (2)
40-40: Function signature enhancement adds flexibility for notification control.The addition of the
isShowNotifyparameter with a default value oftrueprovides a clean way to control notification display while maintaining backward compatibility with existing code.
60-62: Good implementation of conditional notification.This conditional block properly implements the notification toggle feature based on the new parameter. The code is clean and follows the existing code style.
packages/plugins/page/src/composable/usePage.js (4)
69-69: New reactive state property for tracking default page.The addition of the
defaultPageproperty to the reactive state object is a good approach for managing the default page state.
197-197: Proper state reset for defaultPage.Resetting the
defaultPagetonullin theresetPageDatafunction ensures clean state management when navigating between pages.
493-497: Well-implemented utility function with proper null checks.The
setDefaultPagefunction is properly implemented with null/empty checks to prevent errors. It efficiently finds and sets the default page from a list of child pages based on an ID.
519-519: Appropriate export of the new function.Adding the new
setDefaultPagefunction to the exports makes it accessible to other components that need this functionality.packages/plugins/page/src/PageSetting.vue (5)
211-211: Updated function signature maintains consistency with http.js changes.The addition of the
isShowNotifyparameter with a default value oftruealigns with the changes in thehandlePageUpdatefunction, ensuring consistent notification behavior.
215-215: Proper propagation of notification control parameter.The
isShowNotifyparameter is correctly passed to thehandlePageUpdatefunction, ensuring the notification control works throughout the call chain.
276-276: Appropriate reset of defaultPage during copy operation.Resetting the
defaultPagetonullwhen copying a page prevents unintended inheritance of default page settings from the original page.
295-298: New utility function for setting default page.The
settingDefaultPagefunction provides a clean way to update the default page settings. PassingfalsetoupdatePagefor theisShowNotifyparameter is a good choice to avoid redundant notifications when multiple updates are happening in sequence.
312-312: Sequential update of default page after main page edit.Calling
settingDefaultPageaftereditPageensures that both the main page content and the default page settings are updated in the correct sequence.packages/plugins/page/src/Main.vue (5)
28-28: New event handler for setting homepage.The addition of the
@settingHomeevent handler connects the UI action to the corresponding functionality.
40-41: Imported necessary hooks for notification and confirmation.The addition of
useModalanduseNotifyimports provides access to the confirmation dialog and notification functionality needed for the new feature.
46-46: Imported API function for homepage update.The import of
handleRouteHomeUpdateprovides access to the API function needed to persist homepage changes.
122-141: Well-implemented homepage setting function with user confirmation.The
settingHomefunction properly:
- Uses a confirmation dialog to prevent accidental changes
- Constructs the necessary parameters
- Calls the appropriate API function
- Handles success and error states with notifications
- Updates the UI state to reflect the change
This implementation follows good practices for user interaction and state management.
186-188: Appropriate export of the new functionality.Adding the
settingHomefunction to the exports makes it accessible to other components that need this functionality.packages/plugins/page/src/PageTree.vue (4)
99-99: Good enhancement with the settingHome event.Adding the 'settingHome' event to the emits array is a clear way to extend the component's API. The explicit declaration in the emits array follows Vue 3 best practices.
244-246: Implement the settingHome handler correctly.The handler is well-formed, with a clean implementation that simply emits the necessary event with the node data.
253-253: UI labeling looks good with a descriptive action name.The "设置为主页" (Set as Home) label clearly indicates the purpose of this action.
271-273: Appropriate filtering logic for the settingHome operation.The filtering logic prevents the "Set as Home" operation from appearing for non-page nodes or public group pages, which is a good UX decision.
packages/plugins/page/src/PageGeneral.vue (6)
73-75: Import statements updated correctly for new component requirements.The imports were updated to properly support the changes, such as adding
reactiveand removing the unusedCheckboximport.
98-98: Properly destructured additional methods from usePage.The methods
getPageChildrenandsetDefaultPageare now correctly imported from the usePage composable.
111-115: Well-structured reactive state for child page management.The reactive state object is well-organized with clear property names for child page list, options, and the selected default page ID.
138-140: Default page change handler is clean and concise.The
changeDefaultPagemethod effectively updates the default page using the sharedsetDefaultPagemethod.
144-144: WatchEffect now correctly initializes child pages.The
watchEffecthook has been properly updated to call the newsetChildAndDefaultPagemethod when dependencies change.
286-287: Successfully exported new state and methods.The new reactive state and
changeDefaultPagemethod are properly added to the returned object, making them available to the template.
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
What is the current behavior?
Issue Number: N/A
What is the new behavior?
1、主页调整为在下拉菜单设置
2、默认页调整为由父级页面在设置面板下拉选择,保存时更新子页面状态
Does this PR introduce a breaking change?
Other information
Summary by CodeRabbit