feat: initialize Vue component library and aligned documentation
This commit is contained in:
@@ -0,0 +1,52 @@
|
||||
<script setup lang="ts">
|
||||
import { IconLoader2 } from "@tabler/icons-vue";
|
||||
import { IconPaperclip } from "@tabler/icons-vue";
|
||||
import { ref, onBeforeUnmount } from "vue";
|
||||
import { Button } from "@heroui-vue/components";
|
||||
const isLoading = ref(false),
|
||||
message = ref("");
|
||||
let timer: ReturnType<typeof setTimeout> | undefined;
|
||||
function upload() {
|
||||
if (isLoading.value) return;
|
||||
isLoading.value = true;
|
||||
message.value = "";
|
||||
timer = setTimeout(() => {
|
||||
isLoading.value = false;
|
||||
message.value = "上传完成,可以再次上传。";
|
||||
}, 2000);
|
||||
}
|
||||
onBeforeUnmount(() => clearTimeout(timer));
|
||||
</script>
|
||||
<template>
|
||||
<div class="upload-demo">
|
||||
<Button :is-pending="isLoading" @click="upload">
|
||||
<span
|
||||
v-if="isLoading"
|
||||
data-slot="spinner"
|
||||
class="inline-flex size-4 shrink-0"
|
||||
aria-hidden="true"
|
||||
>
|
||||
<IconLoader2
|
||||
class="size-full animate-spin motion-reduce:animate-none"
|
||||
/>
|
||||
</span>
|
||||
<IconPaperclip v-else aria-hidden="true" />
|
||||
{{ isLoading ? "上传中…" : "上传文件" }}
|
||||
</Button>
|
||||
<p class="upload-status" role="status">{{ message }}</p>
|
||||
</div>
|
||||
</template>
|
||||
<style scoped>
|
||||
.upload-demo {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
}
|
||||
.upload-status {
|
||||
font-size: 12px;
|
||||
color: var(--muted);
|
||||
min-height: 20px;
|
||||
margin: 0;
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user