update: progressloading component type

This commit is contained in:
IchliebedichZhu 2024-03-05 10:29:33 +00:00
parent a9f594fb1c
commit 4197c99b78
2 changed files with 38 additions and 24 deletions

View File

@ -2,8 +2,8 @@
* @Author: ShawnPhang * @Author: ShawnPhang
* @Date: 2021-12-28 09:29:42 * @Date: 2021-12-28 09:29:42
* @Description: 百分比进度条 * @Description: 百分比进度条
* @LastEditors: ShawnPhang <site: book.palxp.com> * @LastEditors: ShawnPhang <site: book.palxp.com>, Jeremy Yu <https://github.com/JeremyYu-cn>
* @LastEditTime: 2023-07-13 23:05:29 * @Date: 2024-03-04 18:50:00
--> -->
<template> <template>
<div v-if="percent" class="mask"> <div v-if="percent" class="mask">
@ -16,33 +16,45 @@
</div> </div>
</template> </template>
<script lang="ts"> <script lang="ts" setup>
import { defineComponent, watch } from 'vue' import { watch, defineProps, defineEmits } from 'vue'
import { ElProgress } from 'element-plus' import { ElProgress } from 'element-plus'
export default defineComponent({ type TProps = {
components: { ElProgress }, percent: number
props: ['percent', 'text', 'cancelText', 'msg'], text: string
emits: ['done', 'cancel'], cancelText: string
setup(props, context) { msg: string
watch( }
() => props.percent,
type TEmits = {
(event: 'done'): void
(event: 'cancel'): void
}
const {percent, text, cancelText, msg} = defineProps<TProps>()
const emit = defineEmits<TEmits>()
watch(
() => percent,
(num) => { (num) => {
if (num >= 100) { if (num >= 100) {
setTimeout(() => { setTimeout(() => {
context.emit('done') emit('done')
}, 1000) }, 1000)
} }
}, },
) )
const cancel = () => { const cancel = () => {
context.emit('cancel') emit('cancel')
} }
return { cancel } defineExpose({
}, cancel
}) })
</script> </script>
<style lang="less" scoped> <style lang="less" scoped>

View File

@ -5,6 +5,8 @@
* @LastEditors: ShawnPhang * @LastEditors: ShawnPhang
* @LastEditTime: 2022-04-08 10:28:47 * @LastEditTime: 2022-04-08 10:28:47
*/ */
import { App } from "vue"
function capitalizeFirstLetter(string: string) { function capitalizeFirstLetter(string: string) {
return string.charAt(0).toUpperCase() + string.slice(1) return string.charAt(0).toUpperCase() + string.slice(1)
} }
@ -18,7 +20,7 @@ const regex = RegExp('.*^(?!.*?(' + exclude.join('|') + ')).*\\.vue$')
const requireComponent = import.meta.glob('./**/*.vue', { eager: true }) const requireComponent = import.meta.glob('./**/*.vue', { eager: true })
function guide(Vue: Type.Object) { function guide(Vue: App) {
for (const fileName in requireComponent) { for (const fileName in requireComponent) {
if (regex.test(fileName)) { if (regex.test(fileName)) {
const componentConfig = requireComponent[fileName] const componentConfig = requireComponent[fileName]