From 548f80a46fd6ebc64fc8c199f0ae8b40bd0c4370 Mon Sep 17 00:00:00 2001 From: frostime Date: Tue, 15 Aug 2023 11:06:33 +0800 Subject: [PATCH] update api --- src/api.ts | 38 ++++++++++++++++++++++++++++++++++++++ src/types/api.d.ts | 14 ++++++++++++++ 2 files changed, 52 insertions(+) diff --git a/src/api.ts b/src/api.ts index 1aacac4..9d3a2fd 100644 --- a/src/api.ts +++ b/src/api.ts @@ -328,6 +328,27 @@ export async function readDir(path: string): Promise { return request(url, data); } +// /api/export/exportResources +/* +{ + "paths": [ + "/conf/appearance/boot", + "/conf/appearance/langs", + "/conf/appearance/emojis/conf.json", + "/conf/appearance/icons/index.html", + ], + "name": "zip-file-name" +} +*/ +export async function exportResources(paths: string[], name: string): Promise { + let data = { + paths: paths, + name: name + } + let url = '/api/export/exportResources'; + return request(url, data); +} + export async function exportMdContent(id: DocumentId): Promise { let data = { @@ -346,6 +367,23 @@ export async function pandoc(args: PandocArgs[]) { return request(url, data); } +// **************************************** Network **************************************** +export async function forwardProxy( + url: string, method: string, payload: any, + headers: any[], timeout: number = 7000, contentType: string = "text/html" +): Promise { + let data = { + url: url, + method: method, + timeout: timeout, + contentType: contentType, + headers: headers, + payload: payload + } + let url1 = '/api/network/forwardProxy'; + return request(url1, data); +} + // **************************************** System **************************************** diff --git a/src/types/api.d.ts b/src/types/api.d.ts index d363403..1163bb0 100644 --- a/src/types/api.d.ts +++ b/src/types/api.d.ts @@ -30,6 +30,7 @@ interface IResGetTemplates { interface IResReadDir { isDir: boolean; + isSymlink: boolean; name: string; } @@ -43,3 +44,16 @@ interface IResBootProgress { details: string; } +interface IResForwardProxy { + body: string; + contentType: string; + elapsed: number; + headers: { [key: string]: string }; + status: number; + url: string; +} + +interface IResExportResources { + path: string; +} +