diff --git a/cli/create-vc-app/src/templates/module/composables/useList.ts.ejs b/cli/create-vc-app/src/templates/module/composables/useList.ts.ejs index 6997695db..4bd296abf 100644 --- a/cli/create-vc-app/src/templates/module/composables/useList.ts.ejs +++ b/cli/create-vc-app/src/templates/module/composables/useList.ts.ejs @@ -1,43 +1,42 @@ -import { ref, type Ref } from "vue"; -import { useAsync, useLoading } from "@vc-shell/framework"; - -// eslint-disable-next-line @typescript-eslint/no-explicit-any -export default function use<%- ModuleNamePascalCase %>List() { - const data: Ref[]> = ref([]); - const totalCount = ref(0); - const currentPage = ref(1); - const searchQuery = ref(""); - - const { loading: itemsLoading, action: fetchItems } = useAsync(async () => { - // TODO: Replace with real API call - // const result = await apiClient.search({ - // keyword: searchQuery.value, - // skip: (currentPage.value - 1) * 20, - // take: 20, - // }); - // data.value = result.results ?? []; - // totalCount.value = result.totalCount ?? 0; - }); - - const { loading: deleteLoading, action: removeItems } = useAsync(async (ids?: string[]) => { - // TODO: Replace with real API call - // await Promise.all((ids ?? []).map((id) => apiClient.delete(id))); - // await fetchItems(); - }); - - const loading = useLoading(itemsLoading, deleteLoading); - - async function getItems() { - await fetchItems(); - } - - return { - data, - loading, - totalCount, - currentPage, - searchQuery, - getItems, - removeItems, - }; -} +import { ref, type Ref } from "vue"; +import { useAsync, useLoading } from "@vc-shell/framework"; + +export interface <%- ModuleNamePascalCase %>ListQuery { + keyword?: string; + sort?: string; + skip?: number; + take?: number; +} + +// eslint-disable-next-line @typescript-eslint/no-explicit-any +export default function use<%- ModuleNamePascalCase %>List() { + const data: Ref[]> = ref([]); + const totalCount = ref(0); + + const { loading: itemsLoading, action: getItems } = useAsync<<%- ModuleNamePascalCase %>ListQuery>(async (query) => { + // TODO: Replace with real API call + // const result = await apiClient.search({ + // keyword: query?.keyword, + // sort: query?.sort, + // skip: query?.skip ?? 0, + // take: query?.take ?? 20, + // }); + // data.value = result.results ?? []; + // totalCount.value = result.totalCount ?? 0; + }); + + const { loading: deleteLoading, action: removeItems } = useAsync(async (ids?: string[]) => { + // TODO: Replace with real API call + // await Promise.all((ids ?? []).map((id) => apiClient.delete(id))); + }); + + const loading = useLoading(itemsLoading, deleteLoading); + + return { + data, + loading, + totalCount, + getItems, + removeItems, + }; +} diff --git a/cli/create-vc-app/src/templates/module/pages/list.vue.ejs b/cli/create-vc-app/src/templates/module/pages/list.vue.ejs index 882d2737a..23fedd93a 100644 --- a/cli/create-vc-app/src/templates/module/pages/list.vue.ejs +++ b/cli/create-vc-app/src/templates/module/pages/list.vue.ejs @@ -6,26 +6,28 @@ width="50%" > - - + + diff --git a/cli/create-vc-app/src/templates/sample-module/pages/list.vue b/cli/create-vc-app/src/templates/sample-module/pages/list.vue index a00f878ca..8516fb2a0 100644 --- a/cli/create-vc-app/src/templates/sample-module/pages/list.vue +++ b/cli/create-vc-app/src/templates/sample-module/pages/list.vue @@ -7,6 +7,8 @@ @@ -73,8 +74,8 @@