web-extend-plugin-vue2 0.2.5 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +45 -28
- package/dist/index.cjs +141 -57
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +140 -58
- package/dist/index.mjs.map +1 -1
- package/index.d.ts +26 -22
- package/package.json +1 -1
package/index.d.ts
CHANGED
|
@@ -48,16 +48,6 @@ export type AdaptRouteDeclarationsFn = (ctx: {
|
|
|
48
48
|
declarations: ReadonlyArray<RouteDeclaration>
|
|
49
49
|
}) => VueRouteConfig[]
|
|
50
50
|
|
|
51
|
-
/** 将插件 `registerMenuItems` 提交的数据并入宿主用于渲染侧栏/目录的 state(映射规则由宿主实现) */
|
|
52
|
-
export type ApplyPluginMenuItemsFn = (ctx: {
|
|
53
|
-
pluginId: string
|
|
54
|
-
/** 已在各条上附带 `pluginId`,并按 `order` 升序 */
|
|
55
|
-
items: Array<Record<string, unknown>>
|
|
56
|
-
}) => void
|
|
57
|
-
|
|
58
|
-
/** 卸载插件时移除该插件贡献的菜单数据 */
|
|
59
|
-
export type RevokePluginMenuItemsFn = (pluginId: string) => void
|
|
60
|
-
|
|
61
51
|
/** 宿主在 `resolveRuntimeOptions({ hostContext })` 中注入;经浅冻结后由 `hostApi.hostContext` 只读暴露 */
|
|
62
52
|
export type HostContext = Readonly<Record<string, unknown>>
|
|
63
53
|
|
|
@@ -88,8 +78,6 @@ export type VueCliAxiosQuickDeps = {
|
|
|
88
78
|
hostLayoutComponent: unknown
|
|
89
79
|
store?: unknown
|
|
90
80
|
hostContext?: Record<string, unknown>
|
|
91
|
-
applyPluginMenuItems?: (ctx: { pluginId: string; items: Array<Record<string, unknown>> }) => void
|
|
92
|
-
revokePluginMenuItems?: (pluginId: string) => void
|
|
93
81
|
}
|
|
94
82
|
|
|
95
83
|
export type HostKitOptions = {
|
|
@@ -100,10 +88,6 @@ export type HostKitOptions = {
|
|
|
100
88
|
transformRoutes?: TransformRoutesFn
|
|
101
89
|
interceptRegisterRoutes?: InterceptRegisterRoutesFn
|
|
102
90
|
adaptRouteDeclarations?: AdaptRouteDeclarationsFn
|
|
103
|
-
/** 必填:插件调用 `registerMenuItems` 时由此写入宿主菜单/路由树等数据结构 */
|
|
104
|
-
applyPluginMenuItems?: ApplyPluginMenuItemsFn
|
|
105
|
-
/** 建议与 `applyPluginMenuItems` 成对配置;`disposeWebPlugin` 会调用以撤销该插件菜单 */
|
|
106
|
-
revokePluginMenuItems?: RevokePluginMenuItemsFn
|
|
107
91
|
/** 由引导流程浅冻结后传入各插件的 `hostApi.hostContext` */
|
|
108
92
|
hostContext?: HostContext
|
|
109
93
|
}
|
|
@@ -128,7 +112,7 @@ export type WebExtendPluginRuntimeOptions = HostKitOptions &
|
|
|
128
112
|
pluginMountPath?: string
|
|
129
113
|
/** 壳路由 meta */
|
|
130
114
|
pluginHostRouteMeta?: Record<string, unknown>
|
|
131
|
-
/**
|
|
115
|
+
/** 为 true 时且配置了 `pluginRoutesParentName` + `hostLayoutComponent` 才自动注册壳路由;默认 false */
|
|
132
116
|
ensurePluginHostRoute?: boolean
|
|
133
117
|
isDev?: boolean
|
|
134
118
|
webPluginDevOrigin?: string
|
|
@@ -163,11 +147,6 @@ export interface HostApi {
|
|
|
163
147
|
* 流水线:`adaptRouteDeclarations` → `transformRoutes` → `interceptRegisterRoutes` 或默认注册。
|
|
164
148
|
*/
|
|
165
149
|
registerRoutes(routes: VueRouteConfig[] | RouteDeclaration[]): void
|
|
166
|
-
/**
|
|
167
|
-
* 向宿主登记侧栏/目录菜单意图;由 `applyPluginMenuItems` 写入宿主 state。
|
|
168
|
-
* 未配置 `applyPluginMenuItems` 时调用会抛错。
|
|
169
|
-
*/
|
|
170
|
-
registerMenuItems(items: Record<string, unknown>[]): void
|
|
171
150
|
registerSlotComponents(
|
|
172
151
|
pointId: string,
|
|
173
152
|
components: Array<{ component: unknown; priority?: number }>
|
|
@@ -202,6 +181,29 @@ export type ManifestFetchCacheOptions = {
|
|
|
202
181
|
now?: () => number
|
|
203
182
|
}
|
|
204
183
|
|
|
184
|
+
/** 从路由 meta 推导的菜单节点(供宿主侧栏;与 `buildMenuDescriptorsFromRoutes` 配套) */
|
|
185
|
+
export type PluginMenuDescriptor = {
|
|
186
|
+
path: string
|
|
187
|
+
name?: string | symbol
|
|
188
|
+
title: string
|
|
189
|
+
order: number
|
|
190
|
+
pluginId?: string
|
|
191
|
+
icon?: unknown
|
|
192
|
+
permission?: unknown
|
|
193
|
+
hidden?: boolean
|
|
194
|
+
external?: boolean
|
|
195
|
+
children?: PluginMenuDescriptor[]
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
/** 由插件 `RouteConfig` 树生成菜单描述(不含 component) */
|
|
199
|
+
export function buildMenuDescriptorsFromRoutes(
|
|
200
|
+
routes: VueRouteConfig[],
|
|
201
|
+
pluginId?: string
|
|
202
|
+
): PluginMenuDescriptor[]
|
|
203
|
+
|
|
204
|
+
/** 调试:返回 `registerRoutes` 为该插件登记的顶层 route name */
|
|
205
|
+
export function getRegisteredTopRouteNamesForPlugin(pluginId: string): string[]
|
|
206
|
+
|
|
205
207
|
/** 命名空间聚合对象,按领域分组 */
|
|
206
208
|
export const WebExtendPluginVue2: Readonly<{
|
|
207
209
|
install: (Vue: unknown, router: unknown, options?: WebExtendPluginRuntimeOptions) => Promise<void>
|
|
@@ -232,6 +234,8 @@ export const WebExtendPluginVue2: Readonly<{
|
|
|
232
234
|
request: (path: string, init?: RequestInit) => Promise<Response>
|
|
233
235
|
}
|
|
234
236
|
registries: unknown
|
|
237
|
+
buildMenuDescriptorsFromRoutes: typeof buildMenuDescriptorsFromRoutes
|
|
238
|
+
getRegisteredTopRouteNamesForPlugin: typeof getRegisteredTopRouteNamesForPlugin
|
|
235
239
|
}>
|
|
236
240
|
config: Readonly<{
|
|
237
241
|
defaultWebExtendPluginRuntime: Record<string, unknown>
|