You've already forked obsidian-visualiser
Finish Dropdown menu and start project config page
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
import useDatabase from '~/composables/useDatabase';
|
||||
import { explorerContentTable } from '~/db/schema';
|
||||
import type { Navigation, NavigationItem } from '~/schemas/navigation';
|
||||
import type { NavigationItem } from '~/schemas/navigation';
|
||||
|
||||
export type NavigationTreeItem = NavigationItem & { children?: NavigationItem[] };
|
||||
export default defineEventHandler(async (e) => {
|
||||
const { user } = await getUserSession(e);
|
||||
|
||||
@@ -23,7 +24,7 @@ export default defineEventHandler(async (e) => {
|
||||
|
||||
if(content.length > 0)
|
||||
{
|
||||
const navigation: Navigation = [];
|
||||
const navigation: NavigationTreeItem[] = [];
|
||||
|
||||
for(const idx in content)
|
||||
{
|
||||
@@ -53,7 +54,7 @@ export default defineEventHandler(async (e) => {
|
||||
setResponseStatus(e, 404);
|
||||
});
|
||||
|
||||
function addChild(arr: Navigation, e: NavigationItem): void
|
||||
function addChild(arr: NavigationTreeItem[], e: NavigationItem): void
|
||||
{
|
||||
const parent = arr.find(f => e.path.startsWith(f.path));
|
||||
|
||||
@@ -66,7 +67,7 @@ function addChild(arr: Navigation, e: NavigationItem): void
|
||||
}
|
||||
else
|
||||
{
|
||||
arr.push({ title: e.title, path: e.path, type: e.type, order: e.order, private: e.private });
|
||||
arr.push({ ...e });
|
||||
arr.sort((a, b) => {
|
||||
if(a.order && b.order)
|
||||
return a.order - b.order;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { hasPermissions } from "#shared/auth.util";
|
||||
import useDatabase from '~/composables/useDatabase';
|
||||
import { explorerContentTable } from '~/db/schema';
|
||||
import { schema } from '~/schemas/navigation';
|
||||
import { table } from '~/schemas/navigation';
|
||||
|
||||
export default defineEventHandler(async (e) => {
|
||||
const { user } = await getUserSession(e);
|
||||
@@ -11,7 +11,7 @@ export default defineEventHandler(async (e) => {
|
||||
throw createError({ statusCode: 401, statusText: 'Unauthorized' });
|
||||
}
|
||||
|
||||
const body = await readValidatedBody(e, schema.safeParse);
|
||||
const body = await readValidatedBody(e, table.safeParse);
|
||||
|
||||
if(!body.success)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user