Repository navigation
fix: template card detail and text #7792
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -30,7 +30,7 @@ function handleUseTemplate() { | |
| </script> | ||
|
|
||
| <template> | ||
| <MkResourceCard :title="template.name"> | ||
| <MkResourceCard :title="template.name" class="cursor-pointer" @click="handleOpenDetail"> | ||
| <template #icon> | ||
| <el-avatar class="bg-transparent!" shape="square" :size="24"> | ||
| <img :src="resetUrl(template.icon, true)" alt="" /> | ||
|
|
@@ -48,8 +48,8 @@ function handleUseTemplate() { | |
| <div class="flex min-w-0 flex-1" @click.stop> | ||
| <!-- 查看模板详情 --> | ||
| <el-button class="flex-1!" plain @click="handleOpenDetail">详情</el-button> | ||
| <!-- 使用模板 --> | ||
| <el-button class="flex-1!" type="primary" :disabled="disabled" @click="handleUseTemplate">使用</el-button> | ||
| <!-- 应用模板 --> | ||
| <el-button class="flex-1!" type="primary" :disabled="disabled" @click="handleUseTemplate">应用</el-button> | ||
| </div> | ||
| </component> | ||
| </template> | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here is the review of the provided Vue code snippet, highlighting irregularities, potential issues, and optimization suggestions. 1. Conflicting Click Handlers (Critical Issue)Issue: You added a
Suggestion: 2.
|
||
|
|
||
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.
Here are the potential issues and optimization suggestions for the provided code snippet:
1. Prop Validation Issue (
function handleApply(tool = props.tool) {)toolwith a default value referencing an external variable (props.tool) inside a script setup or composition context. If this is a plainfunctiondeclaration inside<script>but outside a setup block,propsmight not be in scope, causing a ReferenceError. If it's insidesetup, usingprops.toolas a default parameter in a standalone function definition is unconventional.props.toolor pass arguments correctly from the template/method calls. IfhandleApplyis meant to use the current tool, accessprops.tooldirectly inside the function body instead of using it as a parameter default unless necessary for reusability.2. Event Handling & Performance (
@click="openDetailDrawer"vs@click="handleApply")openDetailDrawer. However, the file name or context suggestshandleApplyis related to applying/using the tool. EnsureopenDetailDraweris the intended action. IfhandleApplywas previously used, verify if behavior changed unintentionally.openDetailDrawerdoesn’t need event details (like$event), this is fine. If you plan to optimize future changes, consider usingv-on="onClickHandlers"or similar patterns if multiple handlers are needed.3. Accessibility (a11y)
<template>component (MkResourceCard) likely renders adivorliby default. Adding a@clickmakes it interactive, but non-interactive HTML elements are not accessible to keyboard-only users (which are essential for screen readers).MkResourceCardinternally handles keyboard events (e.g.,tabindex="0"+@keydown.enter).tabindex="0"and@keydown.enter="openDetailDrawer"manually if the component doesn’t support it.role="button"andaria-labelif semantic HTML isn’t used.4. CSS Class Specificity (
.cursor-pointer)cursor-pointeris common in Tailwind setups but can lead to inconsistency if other cards don’t have it. Consider defining a custom class.resource-cardthat includescursor: pointer;if this style is universal for all resource cards.5. Vue Version Compatibility
MkResourceCardemits or supports native DOM events properly. In Vue 3, fall-through attributes work seamlessly. Verify based on your project’s Vue version.Recommended Improved Code Snippet: