-
Notifications
You must be signed in to change notification settings - Fork 354
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: route bar support display preview path #1118
feat: route bar support display preview path #1118
Conversation
…to feat/router-bar-display-preview
WalkthroughThe changes modify the Changes
Sequence Diagram(s)sequenceDiagram
participant UI as CanvasRouteBar.vue
participant API as Meta API
participant GS as Global Service
UI->>API: Request baseInfo (includes previewId)
API-->>UI: Return baseInfo
UI->>UI: Initialize previewId and existsPreview
UI->>UI: onMounted updates previewId if data present
UI->>UI: Watch changes on pageId and previewId
UI->>GS: Call handleClearPreview to reset preview state
Possibly related PRs
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
packages/canvas/route-bar/src/CanvasRouteBar.vueOops! Something went wrong! :( ESLint: 8.57.1 ESLint couldn't find the plugin "@typescript-eslint/eslint-plugin". (The package "@typescript-eslint/eslint-plugin" was not found when loaded as a Node module from the directory "/packages/canvas".) It's likely that the plugin isn't installed correctly. Try reinstalling by running the following:
The plugin "@typescript-eslint/eslint-plugin" was referenced from the config file in "packages/canvas/.eslintrc.cjs » @vue/eslint-config-typescript". If you still can't figure out the problem, please stop by https://eslint.org/chat/help to chat with the team. Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (4)
packages/canvas/route-bar/src/CanvasRouteBar.vue (4)
18-20
: Consider i18n support for the tooltip content.The tooltip text "重置路由视图为占位符" should be internationalized for better maintainability and multi-language support.
- <tiny-tooltip v-if="existsPreview" type="normal" content="重置路由视图为占位符"> + <tiny-tooltip v-if="existsPreview" type="normal" :content="t('resetRouteViewToPlaceholder')">
79-119
: Consider extracting string conversion logic.The string conversion logic is repeated in multiple places. Consider extracting it into a utility function for consistency and maintainability.
+const toStringId = (id) => String(id) + watch( [pageId, previewId], async ([pageId, previewId]) => { if (!pageId) { routes.value = [] return } - let ancestors = ((await getAncestors(pageId, true)) || []).concat(pageId).map((id) => String(id)) + let ancestors = ((await getAncestors(pageId, true)) || []).concat(pageId).map(toStringId) if (previewId) { - const previewAncestors = ((await getAncestors(previewId, true)) || []).concat(previewId).map((id) => String(id)) + const previewAncestors = ((await getAncestors(previewId, true)) || []).concat(previewId).map(toStringId) if (previewAncestors.includes(pageId)) { ancestors = previewAncestors } }
144-146
: Add error handling for preview reset.The
handleClearPreview
function should handle potential errors when updating the preview ID.const handleClearPreview = () => { - getMetaApi(META_SERVICE.GlobalService).updatePreviewId('') + try { + getMetaApi(META_SERVICE.GlobalService).updatePreviewId('') + } catch (error) { + console.error('Failed to clear preview:', error) + // Consider showing a user-friendly error message + } }
180-199
: Consider adding smooth transitions.The visual changes could benefit from smooth transitions for better user experience.
.is-preview { color: var(--te-common-text-weaken); + transition: color 0.2s ease; } .clear-preview { border-radius: 999px; visibility: hidden; margin-left: 2px; width: 16px; height: 16px; font-size: 12px; + transition: visibility 0.2s ease; }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
packages/canvas/route-bar/src/CanvasRouteBar.vue
(6 hunks)
🔇 Additional comments (2)
packages/canvas/route-bar/src/CanvasRouteBar.vue (2)
26-28
: LGTM!The imports are well-organized and correctly support the new functionality.
38-41
: LGTM!The state management is well-implemented using Vue's reactivity system with proper initialization from baseInfo.
@coderabbitai review |
✅ Actions performedReview triggered.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (3)
packages/canvas/route-bar/src/CanvasRouteBar.vue (3)
38-41
: Consider adding type annotations for improved maintainability.The state management is well-structured, but type annotations would make it more maintainable.
-const baseInfo = getMetaApi(META_SERVICE.GlobalService).getBaseInfo() -const pageId = ref(baseInfo.pageId) -const previewId = ref(baseInfo.previewId) -const existsPreview = ref(false) +/** @type {import('vue').Ref<string>} */ +const pageId = ref(baseInfo.pageId) +/** @type {import('vue').Ref<string>} */ +const previewId = ref(baseInfo.previewId) +/** @type {import('vue').Ref<boolean>} */ +const existsPreview = ref(false)
51-56
: Consider adding type guards for more robust event handling.The string conversion is good, but type guards would make the code more robust.
-if (data.pageId) { +if (typeof data.pageId !== 'undefined') { pageId.value = String(data.pageId) } -if ('previewId' in data) { +if (typeof data.previewId !== 'undefined') { previewId.value = String(data.previewId) }
121-146
: Consider adding return type annotations for clarity.The methods are well-implemented, but return type annotations would improve clarity.
-const shouldHighlight = (id, index) => { +/** @returns {boolean} */ +const shouldHighlight = (id, index) => { // ... implementation } -const handleClearPreview = () => { +/** @returns {void} */ +const handleClearPreview = () => { // ... implementation }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
packages/canvas/route-bar/src/CanvasRouteBar.vue
(6 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
- GitHub Check: push-check
🔇 Additional comments (4)
packages/canvas/route-bar/src/CanvasRouteBar.vue (4)
4-20
: LGTM! The template changes enhance user experience.The template improvements provide clear visual feedback and intuitive controls:
- Index-based route highlighting
- Visual distinction for preview paths
- Accessible tooltip for the reset button
26-28
: LGTM! Imports align with new functionality.The added imports support the new UI elements for preview path management.
79-119
: LGTM! Well-structured and documented watch logic.The watch implementation effectively handles both regular and preview paths with clear comments explaining the logic.
180-199
: LGTM! Styles follow project conventions.The styles effectively use CSS variables and provide appropriate visual feedback for the preview path feature.
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?
Does this PR introduce a breaking change?
Other information
Summary by CodeRabbit
Summary by CodeRabbit