Skip to content

Commit

Permalink
refactor: template/types/globals.d.ts (#45)
Browse files Browse the repository at this point in the history
Signed-off-by: donniean <[email protected]>
  • Loading branch information
donniean authored Oct 16, 2024
1 parent 97759e0 commit b3ffe0a
Showing 1 changed file with 119 additions and 11 deletions.
130 changes: 119 additions & 11 deletions template/types/globals.d.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,125 @@
type ExtensionMenuParent =
| 'topbar'
| 'global'
| 'toolbox'
| 'access'
| 'cluster'
| 'workspace'
| 'project'
| 'platformSettings';

interface ExtensionAction {
actionType?:
| 'url-router'
| 'url-current-tab'
| 'url-new-tab'
| 'url-new-window'
| 'v3-modal'
| 'modal'
| 'sheet';
actionValue?: string;
}

interface ExtensionMenu extends ExtensionAction {
parent: ExtensionMenuParent;
name: string;
link?: string;
title: string;
icon?: string;
order?: number;
desc?: string;
skipAuth?: boolean;
authKey?: string;
authAction?: string;
children?: ExtensionMenu[];
ksModule?: string;
clusterModule?: string;
workspaceModule?: string;
}

interface Extension {
routes?: Record<string, any>[];
routesByPatch?: Record<string, any>[];
menus?: ExtensionMenu[];
locales?: Record<string, any>;
isCheckLicense?: boolean;
events?: Record<string, any>;
}

interface Options {
isSkipLicenseCheck?: boolean;
extensionName?: string;
}

interface GlobalsConfig {
kubesphereEdition?: 'ks' | 'kse' | undefined;
isKsEdition?: boolean;
isKseEdition?: boolean;
importRemoteExtensions?: {
includes?: string[];
excludes?: string[];
};
[key: string]: any;
}

interface Globals {
app?: any;
config?: any;
installedExtensions?: any;
context?: any;
run?: any;
user?: any;
manifest?: Record<string, string>;
currentCluster?: string;
config: GlobalsConfig;
manifest: Record<string, string>;
ksConfig: Record<string, any>;
licenseInfo: {
formattedLicenses: Record<string, any>[];
};
user: Record<string, any>;
runtime: string;
clusterRole: string;
installedExtensions: {
name: string;
extensionName: string;
link: string;
resourceVersion: string;
}[];
context: {
events: Record<string, any>;
routes: Record<string, any>[];
routesByPatch: Record<string, any>;
injectionPoints: Record<string, any>;
locales: Record<string, any>;
registerLocales: (locales: Record<string, any> | undefined) => void;
registerExtension: (extension: Extension, options?: Options) => void;
registerExtensions: (extensions: Extension[], options?: Options) => void;
};
emitter: {
all: any;
on: any;
off: any;
emit: any;
};
run?: () => Promise<void>;
clusterConfig?: Record<string, any>;
theme: Record<string, string>;
useDefaultTheme: boolean;
defaultTheme: Record<string, string>;
// TODO 新增别名
workspacesAliasName: Record<string, string>;
projectAliasName: Record<string, Record<string, string>>;
clustersAliasName: Record<string, string>;
userAliasName: Record<string, string>;
platformRolesAliasName: Record<string, string>;
ignoreSubRouteChange?: boolean;
}

interface TFunction {
(key: string | string[], options?: Record<string, any>): string;

(key: string | string[], defaultValue?: string, options?: Record<string, any>): string;
}

interface Window {
globals: Globals;
t: any;
readonly globals: Globals;
readonly t: TFunction;
}

declare var t: any;
declare var globals: any;
declare const globals: Globals;
declare const t: TFunction;
// eslint-disable-next-line @typescript-eslint/naming-convention

0 comments on commit b3ffe0a

Please sign in to comment.