|
| 1 | +type ExtensionMenuParent = |
| 2 | + | 'topbar' |
| 3 | + | 'global' |
| 4 | + | 'toolbox' |
| 5 | + | 'access' |
| 6 | + | 'cluster' |
| 7 | + | 'workspace' |
| 8 | + | 'project' |
| 9 | + | 'platformSettings'; |
| 10 | + |
| 11 | +interface ExtensionAction { |
| 12 | + actionType?: |
| 13 | + | 'url-router' |
| 14 | + | 'url-current-tab' |
| 15 | + | 'url-new-tab' |
| 16 | + | 'url-new-window' |
| 17 | + | 'v3-modal' |
| 18 | + | 'modal' |
| 19 | + | 'sheet'; |
| 20 | + actionValue?: string; |
| 21 | +} |
| 22 | + |
| 23 | +interface ExtensionMenu extends ExtensionAction { |
| 24 | + parent: ExtensionMenuParent; |
| 25 | + name: string; |
| 26 | + link?: string; |
| 27 | + title: string; |
| 28 | + icon?: string; |
| 29 | + order?: number; |
| 30 | + desc?: string; |
| 31 | + skipAuth?: boolean; |
| 32 | + authKey?: string; |
| 33 | + authAction?: string; |
| 34 | + children?: ExtensionMenu[]; |
| 35 | + ksModule?: string; |
| 36 | + clusterModule?: string; |
| 37 | + workspaceModule?: string; |
| 38 | +} |
| 39 | + |
| 40 | +interface Extension { |
| 41 | + routes?: Record<string, any>[]; |
| 42 | + routesByPatch?: Record<string, any>[]; |
| 43 | + menus?: ExtensionMenu[]; |
| 44 | + locales?: Record<string, any>; |
| 45 | + isCheckLicense?: boolean; |
| 46 | + events?: Record<string, any>; |
| 47 | +} |
| 48 | + |
| 49 | +interface Options { |
| 50 | + isSkipLicenseCheck?: boolean; |
| 51 | + extensionName?: string; |
| 52 | +} |
| 53 | + |
| 54 | +interface GlobalsConfig { |
| 55 | + kubesphereEdition?: 'ks' | 'kse' | undefined; |
| 56 | + isKsEdition?: boolean; |
| 57 | + isKseEdition?: boolean; |
| 58 | + importRemoteExtensions?: { |
| 59 | + includes?: string[]; |
| 60 | + excludes?: string[]; |
| 61 | + }; |
| 62 | + [key: string]: any; |
| 63 | +} |
| 64 | + |
1 | 65 | interface Globals { |
2 | | - app?: any; |
3 | | - config?: any; |
4 | | - installedExtensions?: any; |
5 | | - context?: any; |
6 | | - run?: any; |
7 | | - user?: any; |
8 | | - manifest?: Record<string, string>; |
| 66 | + currentCluster?: string; |
| 67 | + config: GlobalsConfig; |
| 68 | + manifest: Record<string, string>; |
| 69 | + ksConfig: Record<string, any>; |
| 70 | + licenseInfo: { |
| 71 | + formattedLicenses: Record<string, any>[]; |
| 72 | + }; |
| 73 | + user: Record<string, any>; |
| 74 | + runtime: string; |
| 75 | + clusterRole: string; |
| 76 | + installedExtensions: { |
| 77 | + name: string; |
| 78 | + extensionName: string; |
| 79 | + link: string; |
| 80 | + resourceVersion: string; |
| 81 | + }[]; |
| 82 | + context: { |
| 83 | + events: Record<string, any>; |
| 84 | + routes: Record<string, any>[]; |
| 85 | + routesByPatch: Record<string, any>; |
| 86 | + injectionPoints: Record<string, any>; |
| 87 | + locales: Record<string, any>; |
| 88 | + registerLocales: (locales: Record<string, any> | undefined) => void; |
| 89 | + registerExtension: (extension: Extension, options?: Options) => void; |
| 90 | + registerExtensions: (extensions: Extension[], options?: Options) => void; |
| 91 | + }; |
| 92 | + emitter: { |
| 93 | + all: any; |
| 94 | + on: any; |
| 95 | + off: any; |
| 96 | + emit: any; |
| 97 | + }; |
| 98 | + run?: () => Promise<void>; |
| 99 | + clusterConfig?: Record<string, any>; |
| 100 | + theme: Record<string, string>; |
| 101 | + useDefaultTheme: boolean; |
| 102 | + defaultTheme: Record<string, string>; |
| 103 | + // TODO 新增别名 |
| 104 | + workspacesAliasName: Record<string, string>; |
| 105 | + projectAliasName: Record<string, Record<string, string>>; |
| 106 | + clustersAliasName: Record<string, string>; |
| 107 | + userAliasName: Record<string, string>; |
| 108 | + platformRolesAliasName: Record<string, string>; |
| 109 | + ignoreSubRouteChange?: boolean; |
| 110 | +} |
| 111 | + |
| 112 | +interface TFunction { |
| 113 | + (key: string | string[], options?: Record<string, any>): string; |
| 114 | + |
| 115 | + (key: string | string[], defaultValue?: string, options?: Record<string, any>): string; |
9 | 116 | } |
10 | 117 |
|
11 | 118 | interface Window { |
12 | | - globals: Globals; |
13 | | - t: any; |
| 119 | + readonly globals: Globals; |
| 120 | + readonly t: TFunction; |
14 | 121 | } |
15 | 122 |
|
16 | | -declare var t: any; |
17 | | -declare var globals: any; |
| 123 | +declare const globals: Globals; |
| 124 | +declare const t: TFunction; |
| 125 | +// eslint-disable-next-line @typescript-eslint/naming-convention |
0 commit comments