@shencom/api
Version:
shencom api group
61 lines (53 loc) • 1.84 kB
text/typescript
import type { Dictionary, Unfurl } from '@shencom/typing';
import { getInitializedApiConfig } from '../config';
/** 获取栏目 tree */
export const ApiCMSCategoryTree = (
body: SC.API.IndexBodyInterface,
headers?: Record<string, any>,
) => {
const { http, url } = getInitializedApiConfig();
const api = `${url}/service-cms/ncms/category/tree`;
return http.post<SC.API.IndexInterface<SC.CSM.Category>>(api, body, {
headers: { Authorization: null, ...headers },
});
};
/** 获取栏目 index */
export const ApiCMSCategoryIndex = (
body: SC.API.IndexBodyInterface,
headers?: Record<string, any>,
) => {
const { http, url } = getInitializedApiConfig();
const api = `${url}/service-cms/ncms/category/index`;
return http.post<SC.API.IndexInterface<SC.CSM.Category>>(api, body, {
headers: { Authorization: null, ...headers },
});
};
interface ReqCMSArticlesIndex extends SC.API.IndexBodyInterface {
categoryId?: string;
}
/** 获取内容列表 */
export const ApiCMSArticlesIndex = (body: ReqCMSArticlesIndex, headers?: Record<string, any>) => {
const { http, url } = getInitializedApiConfig();
const api = `${url}/service-cms/ncms/articles/index`;
return http.post<SC.API.IndexInterface<SC.CSM.Articles>>(api, body, {
headers: { Authorization: null, ...headers },
});
};
interface ReqCMSArticlesShow extends Dictionary<any> {
id: string;
}
export interface ArticlesDetail extends SC.CSM.Articles {
content: string;
referUrl: string;
}
/** 获取文章内容 */
export const ApiCMSArticlesShow = (
body: Unfurl<ReqCMSArticlesShow>,
headers?: Record<string, any>,
) => {
const { http, url } = getInitializedApiConfig();
const api = `${url}/service-cms/ncms/articles/show`;
return http.post<ArticlesDetail>(api, body, {
headers: { Authorization: null, ...headers },
});
};