Skip to content

Commit 7086c62

Browse files
feat(ProjectCard): add opening state feedback
1 parent 29fb63d commit 7086c62

File tree

4 files changed

+37
-17
lines changed

4 files changed

+37
-17
lines changed
Lines changed: 30 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
<script lang="ts" setup>
2+
import { JeButton } from 'jetv-ui'
3+
import { ref } from 'vue'
4+
import { useI18n } from 'vue-i18n'
5+
26
import { showNoIdePathDialog } from '~/components/NoIdePathDialog/NoIdePathDialogProvider'
37
import type { CodeEditorEnum } from '~/constants/codeEditor'
48
import { codeEditors } from '~/constants/codeEditor'
@@ -9,36 +13,48 @@ defineProps<{
913
projectPath: string
1014
}>()
1115
16+
const { t } = useI18n()
17+
1218
const settings = useSettingsStore()
19+
const isOpening = ref(false)
1320
1421
function handleClick(codeEditor: CodeEditorEnum, projectPath: string) {
22+
if (isOpening.value)
23+
return // 防止多次点击
24+
1525
const idePath = settings.codeEditorsPath[codeEditor]
1626
1727
if (!idePath) {
1828
showNoIdePathDialog()
29+
return
1930
}
20-
else {
21-
window.api.openProject(idePath, projectPath)
22-
}
31+
32+
isOpening.value = true
33+
window.api.openProject(idePath, projectPath)
34+
35+
// 模拟反馈
36+
setTimeout(() => {
37+
isOpening.value = false
38+
}, 2000)
2339
}
2440
</script>
2541

2642
<template>
27-
<button
28-
font-sans text="13px" lh="26px" whitespace-nowrap
29-
p="x-14px y-3px" b-0 rounded="4px"
30-
light:bg="$blue-4 hover:$blue-3 active:$blue-2"
31-
dark:bg="$blue-6 hover:$blue-5 active:$blue-4"
43+
<div v-if="isOpening" text="default">
44+
{{ t('project.opening') }}
45+
</div>
46+
<JeButton
47+
v-else
48+
class="group-hover/item:block"
49+
type="primary"
50+
hidden
51+
:disabled="isOpening"
3252
@click="handleClick(defaultOpen, projectPath)"
3353
@mousedown.stop @mouseup.stop
3454
>
35-
<span
36-
flex="~ items-center" gap="5px"
37-
color="$gray-12"
38-
>
39-
<!-- 使用 text-color 动态适配 -->
55+
<span flex="~ items-center" gap="5px" color="$gray-12">
4056
<span :class="codeEditors[defaultOpen].icon" />
4157
<span>{{ codeEditors[defaultOpen].label }}</span>
4258
</span>
43-
</button>
59+
</JeButton>
4460
</template>

src/components/ProjectCard/ProjectCard.vue

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,10 +206,8 @@ function showMenu() {
206206
<div flex="~ row items-center" gap="10px">
207207
<OpenButton
208208
v-if="projectExists"
209-
class="group-hover/item:block"
210209
:default-open="projectDefaultOpen"
211210
:project-path="projectPath"
212-
hidden
213211
/>
214212

215213
<!-- More Button -->

src/locales/en.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ license_pop:
7777
no_description_desc: Not has description
7878
project_card:
7979
temporary: Temporary
80+
opening: Opening...
8081
open_in_explorer: Open in Explorer
8182
open_in_terminal: Open in Terminal
8283
edit: Edit
@@ -186,3 +187,5 @@ status:
186187
found_many: Found {count} new projects
187188
done: Scan completed
188189
error: Scan failed
190+
project:
191+
opening: Opening...

src/locales/zh-CN.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ license:
1010
network_use_is_distribution: 使用网络分发
1111
same_license: 使用相同协议
1212
same_license_library: 使用相同协议(library)
13-
same_license_file: 使用相同协议(file)
13+
same_license_file: 使用���同协议(file)
1414
state_changes: 声明变更
1515
liability: 承担责任
1616
trademark_use: 使用商标
@@ -69,6 +69,7 @@ license_pop:
6969
no_description_desc: 没有描述
7070
project_card:
7171
temporary: 临时
72+
opening: 正在打开...
7273
open_in_explorer: 在资源管理器中打开
7374
open_in_terminal: 在终端中打开
7475
edit: 编辑
@@ -178,3 +179,5 @@ status:
178179
found_many: 已发现 {count} 个新项目
179180
done: 扫描完成
180181
error: 扫描失败
182+
project:
183+
opening: 正在打开...

0 commit comments

Comments
 (0)