-
-
Notifications
You must be signed in to change notification settings - Fork 167
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: ✨ 新增Curtain 幕帘属性,支持使用其他图标 #646
Changes from 4 commits
8bab50c
e629d23
704ae69
1e91f8c
e5c9920
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 |
---|---|---|
|
@@ -82,6 +82,7 @@ | |
@include m(active) { | ||
&:active::before { | ||
opacity: 0.15; | ||
border-radius: 6px; | ||
} | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,7 +19,13 @@ | |
> | ||
<view class="wd-curtain__content"> | ||
<image :src="src" class="wd-curtain__content-img" :style="imgStyle" @click="clickImage" @error="imgErr" @load="imgLoad"></image> | ||
<wd-icon name="close-outline" :custom-class="`wd-curtain__content-close ${closePosition}`" @click="close" /> | ||
<wd-icon | ||
:name="closeIconName" | ||
:size="closeIconSize" | ||
:color="closeIconColor" | ||
:custom-class="`wd-curtain__content-close ${closePosition}`" | ||
@click="close" | ||
/> | ||
</view> | ||
</wd-popup> | ||
</view> | ||
|
@@ -39,7 +45,8 @@ export default { | |
<script lang="ts" setup> | ||
import wdIcon from '../wd-icon/wd-icon.vue' | ||
import wdPopup from '../wd-popup/wd-popup.vue' | ||
import { ref, watch } from 'vue' | ||
import { addUnit, objToStyle } from '../common/util' | ||
import { computed, ref, watch, type CSSProperties } from 'vue' | ||
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. 💡 Codebase verification 新导入的内容未在组件中使用,请检查是否需要这些导入。如果不需要,请移除它们以优化代码。 🔗 Analysis chain导入的更新增强了组件的功能,很好! 新增的 为了确保这些新导入的充分利用,请确认:
可以运行以下脚本来验证这些导入的使用情况: 请运行以下脚本以验证新导入的内容在组件中的实际使用情况: 🏁 Scripts executedThe following scripts were executed for the analysis: Script: #!/bin/bash
# 检查新导入的使用情况
echo "Checking usage of new imports:"
rg "addUnit|objToStyle|CSSProperties|computed" src/uni_modules/wot-design-uni/components/wd-curtain/wd-curtain.vue
Length of output: 354 Script: # 检查 `addUnit` 和 `objToStyle` 的使用情况
rg 'addUnit\(|objToStyle\(' src/uni_modules/wot-design-uni/components/wd-curtain/wd-curtain.vue
# 检查 `CSSProperties` 类型的使用情况,排除导入语句
rg 'CSSProperties' src/uni_modules/wot-design-uni/components/wd-curtain/wd-curtain.vue | grep -v 'import'
# 检查 `computed` 的使用情况,排除导入语句
rg 'computed\(' src/uni_modules/wot-design-uni/components/wd-curtain/wd-curtain.vue | grep -v 'import'
Length of output: 304 |
||
import { curtainProps } from './types' | ||
|
||
const props = defineProps(curtainProps) | ||
|
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.
🛠️ Refactor suggestion
建议重构重复代码
当前实现中,每个 curtain 实例都有独立的
value
、handleClick
和handleClose
方法,导致了大量重复代码。建议考虑重构,使用一个通用的状态管理方法来处理所有 curtain 实例,这样可以显著减少代码重复并提高可维护性。例如,可以考虑使用一个对象来管理所有 curtain 的状态,并使用一个通用的方法来处理打开和关闭操作。
以下是一个可能的重构方案:
然后在模板中可以这样使用:
这种方法可以大大减少重复代码,使得添加新的 curtain 实例变得更加简单和一致。
Also applies to: 116-121