-
Notifications
You must be signed in to change notification settings - Fork 22
fix(tinyvue): 修复因替换到 @antfu/eslint-config 导致的 bug #184
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
Conversation
WalkthroughReplaced several direct icon component imports with lowercase factory imports and runtime instantiation; removed some compile-time composition API named imports; simplified packaged() calls; adjusted theme-related types and useTheme signature and added themeVisible(); plus numerous formatting and minor CSS scope changes across templates. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
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. Comment |
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
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
template/tinyvue/src/components/menu/index.vue (1)
102-125: Guard tree access against null nodes and invalid keys.
WhenfindId()returns-1(menu path not found), callingtree.value.setCurrentKey(-1)and then destructuringtree.value.getCurrentNode()will fail sincegetCurrentNode()returns null for an unmatched key. Add checks to prevent runtime errors.🛠️ Suggested fix
const key = findId(tabStore.current.name, tabStore.current.link) + if (key === -1) { + return + } tree.value.setCurrentKey(key) - const { parentId = null } = tree.value.getCurrentNode() + const currentNode = tree.value.getCurrentNode?.() + if (!currentNode) { + return + } + const { parentId = null } = currentNode if (parentId && !expandeArr.value.includes(parentId)) { expandeArr.value = expandeArr.value.concat(parentId) }
🤖 Fix all issues with AI agents
In `@template/tinyvue/src/components/menu/index.vue`:
- Around line 45-48: The call to getMenuList on the menuStore can reject and is
currently unhandled; update the usage of useMenuStore/getMenuList to handle
promise rejections (either await getMenuList() inside an async setup or attach
.catch(...) to getMenuList()) and surface/report errors via your app-level error
service or processLogger; ensure rawMenuData (computed(() =>
useDeepClone(unref(menuStore.menuList)))) remains unchanged but only depends on
menuStore.menuList after getMenuList resolution so the UI won't silently fail
when getRoleMenu/network errors occur.
🧹 Nitpick comments (1)
template/tinyvue/src/components/theme/index.vue (1)
2-6: Validate THEME injection and icon factory usage.
Ensure THEME is always provided; otherwisethemecan be undefined at runtime. Also confirm theiconYes()factory is the expected@opentiny/vue-iconAPI.✅ Optional explicit assertion
-const theme = inject<TinyThemeTool>('THEME') +const theme = inject<TinyThemeTool>('THEME')!Also applies to: 42-45
| const menuStore = useMenuStore() | ||
| menuStore.getMenuList() | ||
| const rawMenuData = computed(() => useDeepClone(unref(menuStore.menuList))) | ||
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.
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# First, find the store file containing getMenuList
fd -t f -e ts -e js -e vue | xargs rg -l 'getMenuList\b' | head -20Repository: opentiny/tiny-pro
Length of output: 375
🏁 Script executed:
#!/bin/bash
# Search for getMenuList definition and its implementation
rg -n -B2 -A10 'getMenuList\s*\(' -g '*.{ts,js,vue}' | head -100Repository: opentiny/tiny-pro
Length of output: 7307
🏁 Script executed:
#!/bin/bash
# Also check the menu store file structure
fd -t f 'menu' -type f | grep -i storeRepository: opentiny/tiny-pro
Length of output: 231
🏁 Script executed:
#!/bin/bash
# Find getRoleMenu implementation
rg -n -B2 -A8 'getRoleMenu' -g '*.{ts,js}' | head -80Repository: opentiny/tiny-pro
Length of output: 2295
🏁 Script executed:
#!/bin/bash
# Check for global error handlers (unhandledrejection, error boundaries, etc.)
rg -n 'unhandledrejection|onUnhandledRejection|errorHandler|captureException' -g '*.{ts,js,vue}' | head -30Repository: opentiny/tiny-pro
Length of output: 130
🏁 Script executed:
#!/bin/bash
# Check menu/index.vue more completely to see if there's any error handling context
cat -n template/tinyvue/src/components/menu/index.vue | head -80Repository: opentiny/tiny-pro
Length of output: 2863
Handle possible getMenuList() rejections from unhandled promise.
getMenuList() is called without await or .catch() and can reject if getRoleMenu fails (network error, server error, etc.). The rejection will be unhandled since Vue's global error handler does not catch unhandled promise rejections. The menu will silently fail to load. Add error handling:
-menuStore.getMenuList()
+menuStore.getMenuList().catch((err) => {
+ console.error('Failed to load menu list', err)
+})Alternatively, if using an app-level error reporting service, handle the rejection there.
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| const menuStore = useMenuStore() | |
| menuStore.getMenuList() | |
| const rawMenuData = computed(() => useDeepClone(unref(menuStore.menuList))) | |
| const menuStore = useMenuStore() | |
| menuStore.getMenuList().catch((err) => { | |
| console.error('Failed to load menu list', err) | |
| }) | |
| const rawMenuData = computed(() => useDeepClone(unref(menuStore.menuList))) |
🤖 Prompt for AI Agents
In `@template/tinyvue/src/components/menu/index.vue` around lines 45 - 48, The
call to getMenuList on the menuStore can reject and is currently unhandled;
update the usage of useMenuStore/getMenuList to handle promise rejections
(either await getMenuList() inside an async setup or attach .catch(...) to
getMenuList()) and surface/report errors via your app-level error service or
processLogger; ensure rawMenuData (computed(() =>
useDeepClone(unref(menuStore.menuList)))) remains unchanged but only depends on
menuStore.menuList after getMenuList resolution so the UI won't silently fail
when getRoleMenu/network errors occur.
|
这个 pr 就先改这么多吧 |
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?
替换 eslint 统一格式化的时候出现了一些问题
Issue Number: N/A
What is the new behavior?
Does this PR introduce a breaking change?
Other information
Summary by CodeRabbit
New Features
Refactor
Style
✏️ Tip: You can customize this high-level summary in your review settings.