Repository navigation
fix: style #7864
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: style #7864
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 |
|---|---|---|
|
|
@@ -21,12 +21,12 @@ const handleNewConversation = () => (props.newConversation ? props.newConversati | |
| </script> | ||
|
|
||
| <template> | ||
| <header class="flex-align-center p-4"> | ||
| <header class="flex-align-center gap-1 p-4"> | ||
| <!-- 左侧收起时才在顶部显示:展开左侧 + 新建对话(展开时它们在侧栏内) --> | ||
| <template v-if="!list.leftSideOpen.value"> | ||
| <!-- 展开左侧 --> | ||
| <MkTooltip content="展开侧边栏"> | ||
| <el-button text @click="list.toggleLeftSide()" class="-ml-1 mr-1"> | ||
| <el-button text @click="list.toggleLeftSide()" class="-ml-1 mr-2"> | ||
| <MkIcon name="icon_sidebar_outlined" :size="18" class="text-N900!" /> | ||
| </el-button> | ||
| </MkTooltip> | ||
|
|
@@ -42,15 +42,21 @@ const handleNewConversation = () => (props.newConversation ? props.newConversati | |
| </el-tag> | ||
| </div> | ||
| <!-- 新建对话 --> | ||
| <MkTooltip content="新建对话"> | ||
| <MkTooltip content="新建对话" v-if="!list.leftSideOpen.value"> | ||
| <el-button text @click="handleNewConversation"> | ||
| <MkIcon name="icon_new-chat_outlined" :size="18" class="text-N900!" /> | ||
| </el-button> | ||
| </MkTooltip> | ||
| <!-- 进入分享模式,勾选要分享的对话 --> | ||
| <MkTooltip v-if="showShare" content="分享"> | ||
| <el-button text :disabled="!canShare" @click="emit('share')"> | ||
| <MkIcon name="icon_share_outlined" :size="18" class="text-N900!" /> | ||
| <MkIcon name="icon_share_outlined" :size="18" :class="canShare ? 'text-N900!' : 'text-N400!'" /> | ||
| </el-button> | ||
| </MkTooltip> | ||
| <!-- 导出--> | ||
| <MkTooltip content="导出"> | ||
| <el-button text> | ||
| <MkIcon name="icon_export_outlined" :size="18" class="text-N900!" /> | ||
| </el-button> | ||
| </MkTooltip> | ||
| <slot /> | ||
|
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 a review of the provided code snippet, highlighting issues and optimization suggestions: 1. Missing Event Handler (Critical Issue)
2. Inconsistent Conditional Rendering Logic
3. Optimization: Class Binding Syntax
4. Accessibility (a11y) Improvement
5. Redundant Tooltip Logic?
6. Consistency in Margin/Padding
✅ Recommended Fix for Export Button<!-- Before -->
<th<MkTooltip content="导出">
<el-button text>
<MkIcon name="icon_export_outlined" :size="18" class="text-N900!" />
</el-button>
</th<MkTooltip>
<!-- After -->
<MkTooltip content="导出">
<el-button text @click="handleExport" aria-label="Export"> <!-- Add handler & aria-label -->
<MkIcon name="icon_export_outlined" :size="18" class="text-N900!" />
</el-button>
</MkTooltip>Don't forget to define const handleExport = () => {
// Implement export logic or emit event
}; |
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -106,7 +106,7 @@ defineExpose({ open }) | |
| <MkFormList v-model="tagForm.tags" :default-item="{ key: '', tagId: '' }" @update:model-value="handleRowsChange"> | ||
| <template #default="{ index, item: tag }"> | ||
| <el-form-item | ||
| class="min-w-0 flex-1" | ||
| class="min-w-0 flex-1 small" | ||
| :label="index === 0 ? '标签' : ''" | ||
| :prop="`tags.${index}.key`" | ||
| :rules="{ required: true, message: '请选择标签', trigger: 'change' }" | ||
|
|
@@ -123,7 +123,7 @@ defineExpose({ open }) | |
| </el-select> | ||
| </el-form-item> | ||
| <el-form-item | ||
| class="min-w-0 flex-1" | ||
| class="min-w-0 flex-1 small" | ||
| :label="index === 0 ? '标签值' : ''" | ||
| :prop="`tags.${index}.tagId`" | ||
| :rules="{ required: true, message: '请选择标签值', trigger: 'change' }" | ||
|
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 analysis of the code diff: 1. Irregularities & Potential Issues
2. Optimization Suggestions✅ Recommendation 1: Use Native Component Props (Preferred)If using Element Plus, replace the custom CSS class with the native <!-- Instead of class="... small", use -->
<el-form-item
:size="'small'" <!-- Or bind it: :size="formSize" -->
@update:model-value="handleRowsChange"
...
>✅ Recommendation 2: Use Utility-First Classes (If using UnoCSS/Tailwind)If you intended to reduce spacing/font size manually, use explicit utility classes instead of a vague <!-- Example: Reducing height/padding using UnoCSS/Tailwind syntax -->
<el-form-item
class="min-w-0 flex-1 text-sm py-0 my-1"
...
>✅ Recommendation 3: Create a Custom Composable or Scoped StyleIf you need complex compact styling, apply it to the container ( <MkFormList v-model="tagForm.tags" class="compact-form">
...
</MkFormList>
<style scoped>
.compact-form .el-form-item {
margin-bottom: 12px; /* Adjust as needed */
}
.compact-form .el-select {
width: 100%;
}
</style>Summary of Action Items
|
||
|
|
||
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 is a review of the code changes, focusing on potential issues, best practices, and optimizations.
1. Potential Issues & Bugs
A.
new ConversationButton Visibility Logic (Critical)In the second hunk:
- <MkTooltip content="新建对话"> + <MkTooltip content="新建对话" v-if="!list.leftSideOpen.value">You added
v-if="!list.leftSideOpen.value"to the "New Conversation" button. However, looking at the context above it in the first hunk:It appears that when the sidebar is open, the "New Conversation" button should likely be inside the sidebar itself (as hinted by the Chinese comment: "展开时它们在侧栏内" - When expanded, they are inside the sidebar).
Issue: By adding
v-if="!list.leftSideOpen.value", you are hiding the button in the header when the sidebar is open. This is likely intentional. However, ensure that the "New Conversation" button is correctly rendered inside theleftSidecomponent when it is open. If not, users lose the ability to create a new conversation entirely.B. Missing Click Handler for Export Button
In the third hunk:
The "Export" button has no
@clickhandler. Clicking it will do nothing. You need to bind an event (e.g.,@click="handleExport").C.
v-ifvs. Dynamic Class Binding in TooltipUsing
v-ifdirectly on<MkTooltip>can sometimes cause layout shifts or re-mounting issues depending on howMkTooltipmanages its DOM/Portal. A safer approach for visibility toggling is often CSS-based (e.g., using a computed property with a dynamic style/class) if the component doesn't handlev-ifgracefully. However,v-ifis acceptable if performance isn't critical.2. Coding Style & Best Practices
A. Inconsistent Formatting/Indentation
<!-- 导出-->has inconsistent spacing before the closing-->.B. Hardcoded Icons & Text
icon_export_outlinedis hardcoded. Ensure this icon name exists in your icon set library to avoid missing icons in production.content="导出"is hardcoded Chinese. If the app supports internationalization (i18n), use a translation key (e.g.,:content="$t('common.export')").C. Tailwind Class Usage (
!important)You are using
class="text-N900!"andclass="text-N400!". The exclamation mark!usually denotes an!importantoverride in UnoCSS/Tailwind JIT. Using!importantis a "code smell" unless absolutely necessary for overriding specific library styles (like Element Plus defaults). Verify if this is truly needed or if lower-specificity classes would suffice to maintain cleaner CSS precedence.3. Optimization Suggestions
A. Extract Repeated Tooltip/Button Pattern
You have multiple instances of:
<MkTooltip content="..."> <el-button text @click="..."> <MkIcon name="..." :size="18" class="text-N900!" /> </el-button> </ MkTooltip>Consider creating a smaller reusable component (e.g.,
<ChatHeaderAction />) to reduce verbosity and make future changes (like changing icon size or tooltip style) easier.B. Computed Property for Visibility
Instead of repeating
!list.leftSideOpen.valuein multiplev-ifs, consider a computed property:(Note: Adjust logic as per exact requirements).
4. Summary of Required Actions
@clickhandler to the Export button.<!-- Export -->).!in Tailwind classes (text-N900!).