Commit f52d6a3ad5dc12b1fa325d61e2d0f6bba8169b2a

Authored by ww
1 parent c5ca233d

feat: 新增列表组件

  1 +<script lang="ts" setup>
  2 + import { ReloadOutlined } from '@ant-design/icons-vue';
  3 + import { Button, List, Tooltip } from 'ant-design-vue';
  4 + import { reactive } from 'vue';
  5 + import { ref } from 'vue';
  6 +
  7 + const listElRef = ref<Nullable<ComponentElRef>>(null);
  8 +
  9 + const pagination = reactive({});
  10 +
  11 + const loading = ref(false);
  12 +
  13 + const dataSource = ref([]);
  14 +
  15 + const getDataSource = () => {};
  16 +</script>
  17 +
  18 +<template>
  19 + <section class="bg-light-50 my-4 p-4 x dark:text-gray-300 dark:bg-dark-900">
  20 + <List
  21 + ref="listElRef"
  22 + :dataSource="dataSource"
  23 + :pagination="pagination"
  24 + :grid="{ gutter: 16, xs: 1, sm: 1, md: 1, lg: 2, xl: 2, xxl: 3, column: 3 }"
  25 + :loading="loading"
  26 + >
  27 + <template #header>
  28 + <section class="flex justify-between gap-4 min-h-12 items-center">
  29 + <div class="text-lg font-semibold">
  30 + <span>任务列表</span>
  31 + </div>
  32 + <Tooltip title="刷新">
  33 + <Button type="primary" @click="getDataSource">
  34 + <ReloadOutlined :spin="loading" />
  35 + </Button>
  36 + </Tooltip>
  37 + </section>
  38 + </template>
  39 + <template #renderItem="{ item }">
  40 + <List.Item :key="item.id">
  41 + <slot name="item" :item="item"></slot>
  42 + </List.Item>
  43 + </template>
  44 + </List>
  45 + </section>
  46 +</template>
... ...
  1 +import { ComponentPropsOptions } from 'vue';
  2 +
  3 +export const props = {
  4 + title: {
  5 + type: String,
  6 + },
  7 +} as ComponentPropsOptions;
... ...