-
Notifications
You must be signed in to change notification settings - Fork 276
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: change default router link #2613
Conversation
WalkthroughThe changes in this pull request focus on modifying the routing configuration within the Changes
Possibly related PRs
Suggested labels
Suggested reviewers
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 (
|
[e2e-test-warn] The title of the Pull request should look like "fix(vue-renderless): [action-menu, alert] fix xxx bug". Please make sure you've read our contributing guide |
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
🧹 Outside diff range and nitpick comments (1)
examples/sites/src/router.js (1)
39-43
: Consider refactoring route resolution logicThe current redirection logic handles multiple concerns (language, theme, path resolution) in a single function. Consider extracting these into separate utility functions for better maintainability and testing:
+ const resolveTheme = (themeKey) => THEME_ROUTE_MAP[themeKey] || THEME_ROUTE_MAP[DEFAULT_THEME] + const resolveLang = (lang) => LANG_PATH_MAP[lang] || LANG_PATH_MAP[ZH_CN_LANG] { path: '/:pathMatch(.*)*', redirect: () => { const lang = $local[LANG_KEY] - const langPath = LANG_PATH_MAP[lang] || LANG_PATH_MAP[ZH_CN_LANG] + const langPath = resolveLang(lang) const themeKey = localStorage.getItem(CURRENT_THEME_KEY) - const theme = THEME_ROUTE_MAP[themeKey] || THEME_ROUTE_MAP[DEFAULT_THEME] + const theme = resolveTheme(themeKey) return { path: `${context}${langPath}/${theme}/overview` } } }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (1)
examples/sites/src/router.js
(2 hunks)
🔇 Additional comments (1)
examples/sites/src/router.js (1)
41-41
:
Potential breaking change in default theme fallback
The change from SMB_THEME
to DEFAULT_THEME
as the fallback option could affect existing applications that rely on the SMB theme as default. Please ensure:
- All necessary themes are mapped in
THEME_ROUTE_MAP
- Documentation is updated to reflect this change
- Migration guide is provided if needed
examples/sites/src/router.js
Outdated
@@ -1,6 +1,6 @@ | |||
import { createRouter, createWebHistory } from 'vue-router' | |||
import Layout from '@/views/layout/layout.vue' | |||
import { LANG_KEY, LANG_PATH_MAP, ZH_CN_LANG, CURRENT_THEME_KEY, THEME_ROUTE_MAP, SMB_THEME } from './const' | |||
import { LANG_KEY, LANG_PATH_MAP, ZH_CN_LANG, CURRENT_THEME_KEY, THEME_ROUTE_MAP, DEFAULT_THEME } from './const' |
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.
💡 Codebase verification
Update remaining SMB_THEME references in useTheme.js
The import change from SMB_THEME
to DEFAULT_THEME
is incomplete. While DEFAULT_THEME
is properly exported in const.ts
, there are still references to SMB_THEME
in useTheme.js
that need to be updated:
examples/sites/src/tools/useTheme.js
:- Import statement still includes
SMB_THEME
- Array value contains
SMB_THEME
- Object key uses
SMB_THEME
- Import statement still includes
🔗 Analysis chain
Verify the constant replacement across the codebase
The import change from SMB_THEME
to DEFAULT_THEME
needs verification to ensure a clean transition.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Description: Verify the constant replacement and check for any remaining SMB_THEME references
# Check if DEFAULT_THEME is properly exported from const file
rg -l "export.*DEFAULT_THEME" ./examples/sites/src/const*
# Check for any remaining SMB_THEME references that might need updating
rg "SMB_THEME" --type js
Length of output: 387
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
🧹 Outside diff range and nitpick comments (2)
examples/sites/src/router.js (2)
37-38
: Consider impact of removing theme persistenceThe redirect logic now always uses
DEFAULT_THEME
instead of persisting user's theme preference. While this simplifies the code, it might affect user experience as their theme preference won't be remembered between sessions.Consider:
- Adding a comment explaining why theme persistence was removed
- Documenting this behavior change in the PR description
- If theme persistence is still desired, consider using Vue's state management solution
Line range hint
1-53
: Add tests for router configuration changesThe changes to default routing behavior should be covered by tests to ensure:
- Default route redirects work as expected
- Theme parameter handling is correct
- Language path resolution functions properly
Would you like me to help create test cases for these scenarios?
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (1)
examples/sites/src/router.js
(2 hunks)
🔇 Additional comments (2)
examples/sites/src/router.js (2)
3-3
: Verify complete migration from SMB_THEME to DEFAULT_THEME
While the import changes here look good, there are still references to SMB_THEME
in other files that need to be updated for consistency.
Line range hint 11-33
: Verify theme parameter handling in routes
The routes contain dynamic :theme
parameters. With the switch to DEFAULT_THEME
, we should verify that all theme-related route handling is consistent.
✅ Verification successful
Let me try a different approach to verify the theme parameter handling.
This broader search should help us understand how theme parameters are handled across the application, including route handling, store management, and any default theme configurations.
Let me do one final check to understand the theme handling implementation completely.
This will help us verify how the theme parameter is handled across the routing system and theme management.
Theme parameter handling is properly implemented and consistent
The theme parameter handling is well-structured and consistent across the codebase:
- Routes correctly use the
:theme
parameter with proper fallback toDEFAULT_THEME
- Theme constants are properly defined and mapped in
const.ts
- Theme handling is centralized in
useTheme.js
with proper route watching and theme switching logic - Default redirects properly use
THEME_ROUTE_MAP[DEFAULT_THEME]
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Description: Check theme parameter handling in route components
# Check theme usage in referenced components
echo "Checking theme usage in Layout component:"
ast-grep --pattern 'theme = $$$' ./examples/sites/src/views/layout/layout.vue
echo "Checking theme usage in Components view:"
ast-grep --pattern 'theme = $$$' ./examples/sites/src/views/components/components.vue
echo "Checking theme usage in Docs view:"
ast-grep --pattern 'theme = $$$' ./examples/sites/src/views/docs/docs.vue
Length of output: 506
Script:
#!/bin/bash
# Let's check for theme-related code patterns more broadly
echo "Checking theme usage in route-related files:"
rg -l "theme" ./examples/sites/src/
echo -e "\nChecking specific theme parameter usage:"
rg -A 2 "route.*theme" ./examples/sites/src/
echo -e "\nChecking vuex store for theme handling:"
rg -A 2 "theme" ./examples/sites/src/store/
echo -e "\nChecking for DEFAULT_THEME usage:"
rg "DEFAULT_THEME" ./examples/sites/src/
Length of output: 2875
Script:
#!/bin/bash
# Check the theme handling implementation
echo "Checking useTheme.js implementation:"
cat ./examples/sites/src/tools/useTheme.js
echo -e "\nChecking const.ts theme-related constants:"
cat ./examples/sites/src/const.ts
echo -e "\nChecking router implementation for theme handling:"
cat ./examples/sites/src/router.js
Length of output: 6138
* feat: change default router link * feat: change default router link
PR
PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
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
New Features
DEFAULT_THEME
.Bug Fixes
SMB_THEME
andCURRENT_THEME_KEY
references to streamline routing logic.LANG_PATH_MAP[ZH_CN_LANG]
.