feat: update admin navigation and configuration for local deployment, enhance user experience with direct API connections
This commit is contained in:
@@ -1,5 +1,3 @@
|
||||
import { apiGet, compactApiParams } from "@/services/api/request";
|
||||
|
||||
export type AssetLibraryItem = {
|
||||
id: string;
|
||||
title: string;
|
||||
@@ -29,5 +27,19 @@ export type AssetLibraryQuery = {
|
||||
};
|
||||
|
||||
export async function fetchAssetLibrary(query: AssetLibraryQuery = {}) {
|
||||
return apiGet<AssetLibraryResponse>("/api/assets", compactApiParams(query));
|
||||
const items: AssetLibraryItem[] = [];
|
||||
const filtered = items.filter((item) => {
|
||||
const keyword = query.keyword?.trim().toLowerCase();
|
||||
if (query.type && item.type !== query.type) return false;
|
||||
if (query.tag?.length && !query.tag.some((tag) => item.tags.includes(tag))) return false;
|
||||
if (!keyword) return true;
|
||||
return [item.title, item.description, item.content, item.url, item.category, ...item.tags].join(" ").toLowerCase().includes(keyword);
|
||||
});
|
||||
const page = Math.max(1, Number(query.page) || 1);
|
||||
const pageSize = Math.max(1, Number(query.pageSize) || filtered.length || 1);
|
||||
return {
|
||||
items: filtered.slice((page - 1) * pageSize, page * pageSize),
|
||||
tags: Array.from(new Set(filtered.flatMap((item) => item.tags).filter(Boolean))),
|
||||
total: filtered.length,
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user