-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: template/types/globals.d.ts (#45)
Signed-off-by: donniean <[email protected]>
- Loading branch information
Showing
1 changed file
with
119 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |