forked from element-plus/element-plus
-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: finalized git progress for clone, pull, push
- Loading branch information
Showing
23 changed files
with
490 additions
and
94 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,130 @@ | ||
<script setup lang="ts"> | ||
import ClIcon from '@/components/icon/Icon.vue'; | ||
defineOptions({ name: 'ClBox' }); | ||
import { computed } from 'vue'; | ||
const props = withDefaults( | ||
defineProps<{ | ||
visible?: boolean; | ||
title?: string; | ||
position?: 'top-right' | 'top-left' | 'bottom-right' | 'bottom-left'; | ||
closable?: boolean; | ||
type?: BasicType; | ||
icon?: Icon; | ||
loading?: boolean; | ||
zIndex?: number; | ||
}>(), | ||
{ | ||
position: 'top-right', | ||
closable: true, | ||
} | ||
); | ||
const emit = defineEmits<{ | ||
(e: 'close'): void; | ||
}>(); | ||
const cls = computed<string>(() => { | ||
const { position } = props; | ||
return [position].join(' '); | ||
}); | ||
</script> | ||
|
||
<template> | ||
<div | ||
class="box" | ||
:class="cls" | ||
:style="{ | ||
zIndex: visible ? props.zIndex : -1, | ||
opacity: visible ? 1 : 0, | ||
}" | ||
> | ||
<el-card> | ||
<template #header> | ||
<div class="title" :class="type"> | ||
<div v-if="loading || icon" class="icon-wrapper"> | ||
<cl-icon v-if="loading" :icon="['fa', 'spinner']" spinning /> | ||
<cl-icon v-else :icon="icon" /> | ||
</div> | ||
<template v-if="$slots.title"> | ||
<slot name="title" /> | ||
</template> | ||
<template v-else> | ||
{{ title }} | ||
</template> | ||
</div> | ||
</template> | ||
<slot /> | ||
</el-card> | ||
</div> | ||
</template> | ||
|
||
<style scoped lang="scss"> | ||
.box { | ||
position: fixed; | ||
z-index: 999; | ||
min-width: 360px; | ||
transition: opacity 0.3s; | ||
&.top-right { | ||
top: var(--cl-header-height); | ||
right: 20px; | ||
} | ||
&.top-left { | ||
top: var(--cl-header-height); | ||
left: 20px; | ||
} | ||
&.bottom-right { | ||
bottom: 20px; | ||
right: 20px; | ||
} | ||
&.bottom-left { | ||
bottom: 20px; | ||
left: 20px; | ||
} | ||
.title { | ||
display: flex; | ||
align-items: center; | ||
&.info { | ||
.icon-wrapper { | ||
color: var(--cl-info-color); | ||
} | ||
} | ||
&.success { | ||
.icon-wrapper { | ||
color: var(--cl-success-color); | ||
} | ||
} | ||
&.warning { | ||
.icon-wrapper { | ||
color: var(--cl-warning-color); | ||
} | ||
} | ||
&.danger { | ||
.icon-wrapper { | ||
color: var(--cl-danger-color); | ||
} | ||
} | ||
.icon { | ||
margin-right: 10px; | ||
width: 24px; | ||
} | ||
} | ||
} | ||
</style> | ||
<style scoped> | ||
.box:deep(.title .icon) { | ||
margin-right: 10px; | ||
width: 24px; | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<script setup lang="ts"> | ||
defineOptions({ name: 'ClGitLogsBox' }); | ||
import { translate } from '@/utils'; | ||
defineProps<{ | ||
visible?: boolean; | ||
loading?: boolean; | ||
title?: string; | ||
logs?: string[]; | ||
}>(); | ||
const t = translate; | ||
</script> | ||
|
||
<template> | ||
<cl-box | ||
:visible="logs?.length && visible" | ||
:loading="loading" | ||
:title="title" | ||
:type="loading ? 'warning' : 'info'" | ||
> | ||
<template v-if="logs"> | ||
<div class="logs-list"> | ||
<div v-for="(log, $index) in logs" :key="$index"> | ||
{{ log }} | ||
</div> | ||
</div> | ||
</template> | ||
</cl-box> | ||
</template> | ||
|
||
<style scoped lang="scss"> | ||
.logs-list { | ||
min-height: 240px; | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
<script setup lang="ts"> | ||
defineOptions({ name: 'ClGitLogsDialog' }); | ||
import { ref, watch, computed, onMounted } from 'vue'; | ||
import { useStore } from 'vuex'; | ||
import { translate } from '@/utils'; | ||
import { GIT_STATUS_CLONING } from '@/constants'; | ||
import useGit from '@/components/git/useGit'; | ||
import ClLogsView from '@/views/deps/task/LogsView.vue'; | ||
const t = translate; | ||
const ns = 'git'; | ||
const store = useStore(); | ||
const { git: state } = store.state as RootStoreState; | ||
const { activeDialogKey } = useGit(store); | ||
const dialogVisible = computed(() => activeDialogKey.value === 'logs'); | ||
const logsViewRef = ref<typeof ClLogsView>(); | ||
let handle: number; | ||
const update = () => { | ||
if (dialogVisible) { | ||
handle = setInterval(async () => { | ||
if (!state.form?._id) return; | ||
await store.dispatch(`${ns}/getById`, state.form?._id); | ||
if (state.form?.status !== GIT_STATUS_CLONING) { | ||
clearInterval(handle); | ||
} | ||
}, 5000); | ||
setTimeout(() => { | ||
logsViewRef.value?.scrollToBottom(); | ||
console.debug(logsViewRef.value?.scrollToBottom); | ||
}, 0); | ||
} else { | ||
clearInterval(handle); | ||
} | ||
}; | ||
watch(dialogVisible, update); | ||
onMounted(update); | ||
</script> | ||
|
||
<template> | ||
<cl-dialog | ||
:visible="dialogVisible" | ||
:title="t('components.git.form.cloneLogs')" | ||
@close="store.commit(`${ns}/hideDialog`)" | ||
@confirm="store.commit(`${ns}/hideDialog`)" | ||
> | ||
<cl-logs-view ref="logsViewRef" :logs="state.form?.clone_logs || []" /> | ||
</cl-dialog> | ||
</template> | ||
|
||
<style scoped lang="scss"></style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<script setup lang="ts"> | ||
defineOptions({ name: 'ClGitPath' }); | ||
import { translate } from '@/utils'; | ||
import { FILE_ROOT } from '@/constants'; | ||
const t = translate; | ||
defineProps<{ | ||
path?: string; | ||
}>(); | ||
</script> | ||
|
||
<template> | ||
<template v-if="path">{{ path }}</template> | ||
<template v-else> | ||
{{ FILE_ROOT }} ({{ t('components.file.rootDirectory') }}) | ||
</template> | ||
</template> | ||
|
||
<style scoped lang="scss"></style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -49,5 +49,6 @@ export declare global { | |
error?: string; | ||
auto_pull?: boolean; | ||
spiders?: Spider[]; | ||
clone_logs?: string[]; | ||
} | ||
} |
Oops, something went wrong.