-
Notifications
You must be signed in to change notification settings - Fork 350
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
fix: route code to move the redirect of an empty node to the parent node #1116
base: refactor/develop
Are you sure you want to change the base?
Conversation
WalkthroughThis pull request modifies the routing logic in the Vue generator plugin. It simplifies the Changes
Sequence Diagram(s)sequenceDiagram
participant Plugin as genRouterPlugin
participant Converter as convertToNestedRoutes
participant Flattener as flattenRoutes
Plugin ->> Converter: Process initial routes
Converter ->> Flattener: Flatten routes (process empty and defined paths)
Flattener -->> Converter: Return flattened routes
Converter ->> Plugin: Return home route with assigned children or flat routes
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/vue-generator/src/plugins/genRouterPlugin.jsOops! Something went wrong! :( ESLint: 8.57.1 Error: Cannot read config file: /packages/vue-generator/.eslintrc.cjs
packages/vue-generator/test/testcases/element-plus-case/expected/appdemo01/src/router/index.jsOops! Something went wrong! :( ESLint: 8.57.1 Error: Cannot read config file: /packages/vue-generator/.eslintrc.cjs
packages/vue-generator/test/testcases/generator/expected/appdemo01/src/router/index.jsOops! Something went wrong! :( ESLint: 8.57.1 Error: Cannot read config file: /packages/vue-generator/.eslintrc.cjs
✨ Finishing Touches
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: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
packages/vue-generator/src/plugins/genRouterPlugin.js
(4 hunks)
🧰 Additional context used
🧠 Learnings (1)
packages/vue-generator/src/plugins/genRouterPlugin.js (1)
Learnt from: lichunn
PR: opentiny/tiny-engine#1011
File: packages/vue-generator/src/plugins/genRouterPlugin.js:19-19
Timestamp: 2025-01-14T09:24:11.999Z
Learning: In Vue router path construction, when recursively flattening nested routes, starting with empty parentPath for child routes is correct as the parent's path is already captured in the parent route object. This avoids duplicate path segments.
⏰ Context from checks skipped due to timeout of 90000ms (1)
- GitHub Check: push-check
🔇 Additional comments (2)
packages/vue-generator/src/plugins/genRouterPlugin.js (2)
12-34
: LGTM! Improved route flattening logic.The removal of the empty path check simplifies the logic while correctly handling route redirection. This aligns with the best practices for Vue router path construction, where empty paths are handled by the parent route.
48-48
: LGTM! Improved home route handling.The changes improve route hierarchy by:
- Using the explicit '/' path for home route (standard practice)
- Correctly assigning flattened routes as children of the home route
Also applies to: 89-92
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: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (4)
packages/vue-generator/src/plugins/genRouterPlugin.js
(4 hunks)packages/vue-generator/test/testcases/element-plus-case/expected/appdemo01/src/router/index.js
(1 hunks)packages/vue-generator/test/testcases/generator/expected/appdemo01/src/router/index.js
(1 hunks)packages/vue-generator/test/testcases/generator/mockData.js
(1 hunks)
✅ Files skipped from review due to trivial changes (1)
- packages/vue-generator/test/testcases/generator/mockData.js
🚧 Files skipped from review as they are similar to previous changes (1)
- packages/vue-generator/src/plugins/genRouterPlugin.js
⏰ Context from checks skipped due to timeout of 90000ms (1)
- GitHub Check: push-check
🔇 Additional comments (2)
packages/vue-generator/test/testcases/element-plus-case/expected/appdemo01/src/router/index.js (1)
13-13
: LGTM! Simplified route structure.The direct export of routes array improves clarity and aligns with the PR's objective of restructuring route handling.
packages/vue-generator/test/testcases/generator/expected/appdemo01/src/router/index.js (1)
4-8
: LGTM! Well-structured parent route with redirect.The implementation effectively moves the redirect logic to the parent route, improving the routing structure.
packages/vue-generator/test/testcases/generator/expected/appdemo01/src/router/index.js
Show resolved
Hide resolved
… fix/router-level
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