Skip to content

Commit b6ff9ed

Browse files
committed
【解决todo】handle命名
1 parent bb34c2b commit b6ff9ed

File tree

7 files changed

+57
-61
lines changed

7 files changed

+57
-61
lines changed

src/views/ai/image/ImageDetailDrawer.vue

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<el-drawer
33
v-model="showDrawer"
44
title="图片详细"
5-
@close="handlerDrawerClose"
5+
@close="handleDrawerClose"
66
custom-class="drawer-class"
77
>
88
<!-- 图片 -->
@@ -79,8 +79,8 @@ const props = defineProps({
7979
})
8080
8181
/** 抽屉 - close */
82-
const handlerDrawerClose = async () => {
83-
emits('handlerDrawerClose')
82+
const handleDrawerClose = async () => {
83+
emits('handleDrawerClose')
8484
}
8585
8686
/** 获取 - 图片 detail */
@@ -90,7 +90,7 @@ const getImageDetail = async (id) => {
9090
}
9191
9292
/** 任务 - detail */
93-
const handlerTaskDetail = async () => {
93+
const handleTaskDetail = async () => {
9494
showDrawer.value = true
9595
}
9696
@@ -107,7 +107,7 @@ watch(id, async (newVal, oldVal) => {
107107
}
108108
})
109109
//
110-
const emits = defineEmits(['handlerDrawerClose'])
110+
const emits = defineEmits(['handleDrawerClose'])
111111
//
112112
onMounted(async () => {})
113113
</script>

src/views/ai/image/ImageTask.vue

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
v-for="image in imageList"
77
:key="image"
88
:image-detail="image"
9-
@on-btn-click="handlerImageBtnClick"
10-
@on-mj-btn-click="handlerImageMjBtnClick"
9+
@on-btn-click="handleImageBtnClick"
10+
@on-mj-btn-click="handleImageMjBtnClick"
1111
/>
1212
</div>
1313
<div class="task-image-pagination">
@@ -16,15 +16,15 @@
1616
layout="prev, pager, next"
1717
:default-page-size="pageSize"
1818
:total="pageTotal"
19-
@change="handlerPageChange"
19+
@change="handlePageChange"
2020
/>
2121
</div>
2222
</el-card>
2323
<!-- 图片 detail 抽屉 -->
2424
<ImageDetailDrawer
2525
:show="isShowImageDetail"
2626
:id="showImageDetailId"
27-
@handler-drawer-close="handlerDrawerClose"
27+
@handle-drawer-close="handleDrawerClose"
2828
/>
2929
</template>
3030
<script setup lang="ts">
@@ -49,12 +49,12 @@ const pageSize = ref<number>(10) // page size
4949
const pageTotal = ref<number>(0) // page size
5050
5151
/** 抽屉 - close */
52-
const handlerDrawerClose = async () => {
52+
const handleDrawerClose = async () => {
5353
isShowImageDetail.value = false
5454
}
5555
5656
/** 任务 - detail */
57-
const handlerDrawerOpen = async () => {
57+
const handleDrawerOpen = async () => {
5858
isShowImageDetail.value = true
5959
}
6060
@@ -117,12 +117,12 @@ const refreshWatchImages = async () => {
117117
}
118118
119119
/** 图片 - btn click */
120-
const handlerImageBtnClick = async (type: string, imageDetail: ImageVO) => {
120+
const handleImageBtnClick = async (type: string, imageDetail: ImageVO) => {
121121
// 获取 image detail id
122122
showImageDetailId.value = imageDetail.id
123123
// 处理不用 btn
124124
if (type === 'more') {
125-
await handlerDrawerOpen()
125+
await handleDrawerOpen()
126126
} else if (type === 'delete') {
127127
await message.confirm(`是否删除照片?`)
128128
await ImageApi.deleteImageMy(imageDetail.id)
@@ -138,7 +138,7 @@ const handlerImageBtnClick = async (type: string, imageDetail: ImageVO) => {
138138
}
139139
140140
/** 图片 - mj btn click */
141-
const handlerImageMjBtnClick = async (button: ImageMjButtonsVO, imageDetail: ImageVO) => {
141+
const handleImageMjBtnClick = async (button: ImageMjButtonsVO, imageDetail: ImageVO) => {
142142
// 1、构建 params 参数
143143
const data = {
144144
id: imageDetail.id,
@@ -171,7 +171,7 @@ const downloadImage = async (imageUrl) => {
171171
}
172172
173173
// page change
174-
const handlerPageChange = async (page) => {
174+
const handlePageChange = async (page) => {
175175
pageNo.value = page
176176
await getImageList(false)
177177
}

src/views/ai/image/ImageTaskCard.vue

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,21 +23,21 @@
2323
class="btn"
2424
text
2525
:icon="Download"
26-
@click="handlerBtnClick('download', imageDetail)"
26+
@click="handleBtnClick('download', imageDetail)"
2727
/>
2828
<el-button
2929
class="btn"
3030
text
3131
:icon="RefreshRight"
32-
@click="handlerBtnClick('regeneration', imageDetail)"
32+
@click="handleBtnClick('regeneration', imageDetail)"
3333
/>
3434
<el-button
3535
class="btn"
3636
text
3737
:icon="Delete"
38-
@click="handlerBtnClick('delete', imageDetail)"
38+
@click="handleBtnClick('delete', imageDetail)"
3939
/>
40-
<el-button class="btn" text :icon="More" @click="handlerBtnClick('more', imageDetail)" />
40+
<el-button class="btn" text :icon="More" @click="handleBtnClick('more', imageDetail)" />
4141
</div>
4242
</div>
4343
<div class="image-wrapper" ref="cardImageRef">
@@ -54,7 +54,7 @@
5454
v-for="button in imageDetail?.buttons"
5555
:key="button"
5656
style="min-width: 40px; margin-left: 0; margin-right: 10px; margin-top: 5px"
57-
@click="handlerMjBtnClick(button)"
57+
@click="handleMjBtnClick(button)"
5858
>
5959
{{ button.label }}{{ button.emoji }}
6060
</el-button>
@@ -79,11 +79,11 @@ const props = defineProps({
7979
})
8080
8181
/** 按钮 - 点击事件 */
82-
const handlerBtnClick = async (type, imageDetail: ImageVO) => {
82+
const handleBtnClick = async (type, imageDetail: ImageVO) => {
8383
emits('onBtnClick', type, imageDetail)
8484
}
8585
86-
const handlerLoading = async (status: number) => {
86+
const handleLoading = async (status: number) => {
8787
// TODO @fan:这个搞成 Loading 组件,然后通过数据驱动,这样搞可以哇?
8888
if (status === AiImageStatusEnum.IN_PROGRESS) {
8989
cardImageLoadingInstance.value = ElLoading.service({
@@ -99,7 +99,7 @@ const handlerLoading = async (status: number) => {
9999
}
100100
101101
/** mj 按钮 click */
102-
const handlerMjBtnClick = async (button: ImageMjButtonsVO) => {
102+
const handleMjBtnClick = async (button: ImageMjButtonsVO) => {
103103
// 确认窗体
104104
await message.confirm(`确认操作 "${button.label} ${button.emoji}" ?`)
105105
emits('onMjBtnClick', button, props.imageDetail)
@@ -108,15 +108,15 @@ const handlerMjBtnClick = async (button: ImageMjButtonsVO) => {
108108
// watch
109109
const { imageDetail } = toRefs(props)
110110
watch(imageDetail, async (newVal, oldVal) => {
111-
await handlerLoading(newVal.status as string)
111+
await handleLoading(newVal.status as string)
112112
})
113113
114114
// emits
115115
const emits = defineEmits(['onBtnClick', 'onMjBtnClick'])
116116
117117
//
118118
onMounted(async () => {
119-
await handlerLoading(props.imageDetail.status as string)
119+
await handleLoading(props.imageDetail.status as string)
120120
})
121121
</script>
122122

src/views/ai/image/dall3/index.vue

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
:type="(selectHotWord === hotWord ? 'primary' : 'default')"
2626
v-for="hotWord in hotWords"
2727
:key="hotWord"
28-
@click="handlerHotWordClick(hotWord)"
28+
@click="handleHotWordClick(hotWord)"
2929
>
3030
{{ hotWord }}
3131
</el-button>
@@ -45,7 +45,7 @@
4545
<el-image
4646
:src="model.image"
4747
fit="contain"
48-
@click="handlerModelClick(model)"
48+
@click="handleModelClick(model)"
4949
/>
5050
<div class="model-font">{{model.name}}</div>
5151
</div>
@@ -64,7 +64,7 @@
6464
<el-image
6565
:src="imageStyle.image"
6666
fit="contain"
67-
@click="handlerStyleClick(imageStyle)"
67+
@click="handleStyleClick(imageStyle)"
6868
/>
6969
<div class="style-font">{{imageStyle.name}}</div>
7070
</div>
@@ -78,7 +78,7 @@
7878
<div class="size-item"
7979
v-for="imageSize in imageSizeList"
8080
:key="imageSize.key"
81-
@click="handlerSizeClick(imageSize)">
81+
@click="handleSizeClick(imageSize)">
8282
<div :class="selectImageSize === imageSize.key ? 'size-wrapper selectImageSize' : 'size-wrapper'">
8383
<div :style="imageSize.style"></div>
8484
</div>
@@ -91,7 +91,7 @@
9191
size="large"
9292
round
9393
:loading="drawIn"
94-
@click="handlerGenerateImage">
94+
@click="handleGenerateImage">
9595
{{drawIn ? '生成中' : '生成内容'}}
9696
</el-button>
9797
</div>
@@ -183,10 +183,8 @@ const props = defineProps({})
183183
// 定义 emits
184184
const emits = defineEmits(['onDrawStart', 'onDrawComplete'])
185185
186-
// TODO @fan:如果是简单注释,建议用 /** */,主要是现在项目里是这种风格哈,保持一致好点~
187-
// TODO @fan:handler 应该改成 handle 哈
188186
/** 热词 - click */
189-
const handlerHotWordClick = async (hotWord: string) => {
187+
const handleHotWordClick = async (hotWord: string) => {
190188
// 取消选中
191189
if (selectHotWord.value == hotWord) {
192190
selectHotWord.value = ''
@@ -199,22 +197,22 @@ const handlerHotWordClick = async (hotWord: string) => {
199197
}
200198
201199
/** 模型 - click */
202-
const handlerModelClick = async (model: ImageModelVO) => {
200+
const handleModelClick = async (model: ImageModelVO) => {
203201
selectModel.value = model.key
204202
}
205203
206204
/** 样式 - click */
207-
const handlerStyleClick = async (imageStyle: ImageModelVO) => {
205+
const handleStyleClick = async (imageStyle: ImageModelVO) => {
208206
selectImageStyle.value = imageStyle.key
209207
}
210208
211209
/** size - click */
212-
const handlerSizeClick = async (imageSize: ImageSizeVO) => {
210+
const handleSizeClick = async (imageSize: ImageSizeVO) => {
213211
selectImageSize.value = imageSize.key
214212
}
215213
216214
/** 图片生产 */
217-
const handlerGenerateImage = async () => {
215+
const handleGenerateImage = async () => {
218216
// 二次确认
219217
await message.confirm(`确认生成内容?`)
220218
try {
@@ -251,15 +249,14 @@ const settingValues = async (imageDetail: ImageVO) => {
251249
selectImageStyle.value = imageDetail.options?.style
252250
//
253251
const imageSize = imageSizeList.value.find(item => item.key === `${imageDetail.width}x${imageDetail.height}`) as ImageSizeVO
254-
console.log('imageSize', imageSize)
255-
await handlerSizeClick(imageSize)
252+
await handleSizeClick(imageSize)
256253
}
257254
258255
/** 暴露组件方法 */
259256
defineExpose({ settingValues })
257+
260258
</script>
261259
<style scoped lang="scss">
262-
263260
// 提示词
264261
.prompt {
265262
}

src/views/ai/image/index.vue

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
<Dall3
1010
v-if="selectPlatform === AiPlatformEnum.OPENAI"
1111
ref="dall3Ref"
12-
@on-draw-start="handlerDrawStart"
13-
@on-draw-complete="handlerDrawComplete"
12+
@on-draw-start="handleDrawStart"
13+
@on-draw-complete="handleDrawComplete"
1414
/>
1515
<Midjourney
1616
v-if="selectPlatform === AiPlatformEnum.MIDJOURNEY"
@@ -19,12 +19,12 @@
1919
<StableDiffusion
2020
v-if="selectPlatform === AiPlatformEnum.STABLE_DIFFUSION"
2121
ref="stableDiffusionRef"
22-
@on-draw-complete="handlerDrawComplete"
22+
@on-draw-complete="handleDrawComplete"
2323
/>
2424
</div>
2525
</div>
2626
<div class="main">
27-
<ImageTask ref="imageTaskRef" @on-regeneration="handlerRegeneration" />
27+
<ImageTask ref="imageTaskRef" @on-regeneration="handleRegeneration" />
2828
</div>
2929
</div>
3030
</template>
@@ -63,20 +63,20 @@ const platformOptions = [
6363
const drawIn = ref<boolean>(false) // 生成中
6464
6565
/** 绘画 - start */
66-
const handlerDrawStart = async (type) => {
66+
const handleDrawStart = async (type) => {
6767
// todo @fan:这个是不是没用啦?
6868
drawIn.value = true
6969
}
7070
7171
/** 绘画 - complete */
72-
const handlerDrawComplete = async (type) => {
72+
const handleDrawComplete = async (type) => {
7373
drawIn.value = false
7474
// todo
7575
await imageTaskRef.value.getImageList()
7676
}
7777
7878
/** 绘画 - 重新生成 */
79-
const handlerRegeneration = async (imageDetail: ImageVO) => {
79+
const handleRegeneration = async (imageDetail: ImageVO) => {
8080
// 切换平台
8181
selectPlatform.value = imageDetail.platform
8282
console.log('切换平台', imageDetail.platform)

0 commit comments

Comments
 (0)