mira-app-server
Version:
Mira Server - standalone server application using mira-app-core
56 lines • 1.81 kB
TypeScript
import { ServerPluginManager } from './ServerPluginManager';
import { ILibraryServerData } from 'mira-app-core/storage/sqlite';
export interface PluginRouteDefinition {
name: string;
group: string;
path: string;
component: string;
pluginName?: string;
meta: {
roles?: string[];
icon?: string;
title: string;
affixTab?: boolean;
order?: number;
};
builder?: () => string;
}
export declare abstract class ServerPlugin {
protected readonly pluginName: string;
protected configs: Record<string, any>;
protected readonly pluginDir: string;
protected readonly pluginDataDir: string;
protected routes: PluginRouteDefinition[];
constructor(pluginName: string, pluginManager: ServerPluginManager, dbServer: ILibraryServerData);
private ensureDirExists;
protected writeConfig(key: string, value: any): void;
protected saveConfig(): void;
protected readConfig(key: string): any;
protected loadConfig(defaultConfig?: Record<string, any>): void;
protected writeJson(filename: string, data: any): void;
protected readJson(filename: string): any;
/**
* 注册插件路由
* @param route 路由定义
*/
protected registerRoute(route: PluginRouteDefinition): void;
/**
* 批量注册路由
* @param routes 路由定义数组
*/
protected registerRoutes(routes: PluginRouteDefinition[]): void;
/**
* 获取插件注册的所有路由
*/
getRoutes(): PluginRouteDefinition[];
/**
* 移除指定路径的路由
* @param path 路由路径
*/
protected unregisterRoute(path: string): boolean;
/**
* 清空所有注册的路由
*/
protected clearRoutes(): void;
}
//# sourceMappingURL=ServerPlugin.d.ts.map