2024-05-30 22:57:45 +07:00
|
|
|
import Base from "./base";
|
|
|
|
|
import {H3Event} from "h3";
|
|
|
|
|
|
|
|
|
|
export type Category = {
|
|
|
|
|
id: number;
|
|
|
|
|
siteId: number;
|
|
|
|
|
parentId?: number;
|
|
|
|
|
title: string;
|
|
|
|
|
code: string;
|
|
|
|
|
description?: string;
|
|
|
|
|
thumbnail?: string;
|
|
|
|
|
keyword?: string;
|
|
|
|
|
taxonomy?: string;
|
|
|
|
|
type: number;
|
|
|
|
|
layout?: number;
|
|
|
|
|
template?: string;
|
|
|
|
|
feature?: string;
|
|
|
|
|
settings?: string;
|
|
|
|
|
order?: number;
|
|
|
|
|
isPublished?: boolean;
|
|
|
|
|
publishType?: number;
|
|
|
|
|
publishedBy?: string;
|
|
|
|
|
publishedOn?: string;
|
|
|
|
|
status: number;
|
|
|
|
|
} & Base;
|
|
|
|
|
|
2024-06-12 17:17:49 +07:00
|
|
|
export type CategoryTree = Category & {
|
|
|
|
|
children?: Category[]
|
|
|
|
|
}
|
|
|
|
|
|
2024-05-30 22:57:45 +07:00
|
|
|
export const list = async () => {
|
|
|
|
|
try {
|
|
|
|
|
const { site, apiUrl } = useRuntimeConfig().public;
|
|
|
|
|
|
2024-06-12 17:17:49 +07:00
|
|
|
const { items }: CategoryTree[] | any = await $fetch(`${apiUrl}/cms/category/tree/site:1`, {
|
2024-05-30 22:57:45 +07:00
|
|
|
method: "GET",
|
|
|
|
|
headers: {
|
2024-06-12 17:17:49 +07:00
|
|
|
site: 1,
|
2024-05-30 22:57:45 +07:00
|
|
|
},
|
|
|
|
|
});
|
2024-06-12 17:17:49 +07:00
|
|
|
return { items } ;
|
2024-05-30 22:57:45 +07:00
|
|
|
} catch (error) {
|
|
|
|
|
handleError(error);
|
|
|
|
|
}
|
|
|
|
|
};
|