Skip to content

Commit 315137a

Browse files
committed
refactor(deprecated): 迁移旧 API 至 deprecated 目录,保留兼容路径
1 parent 00e7945 commit 315137a

File tree

4 files changed

+46
-73
lines changed

4 files changed

+46
-73
lines changed

src/as-vue-plugin.ts

Lines changed: 0 additions & 39 deletions
This file was deleted.

src/create-vue-router-plugin.ts

Lines changed: 0 additions & 34 deletions
This file was deleted.

src/deprecated/as-vue-plugin.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import type { App, ObjectPlugin } from 'vue'
2+
import type { RouterPlugin } from '../plugin'
3+
import { prepareInstall } from '../prepare-install'
4+
import { setupPlugin } from '../setup-plugin'
5+
6+
/**
7+
* @deprecated
8+
* Please use {@link withInstall} instead.
9+
*/
10+
export function asVuePlugin(plugin: RouterPlugin): RouterPlugin & ObjectPlugin {
11+
return Object.assign(plugin, {
12+
install(app: App) {
13+
const router = app.config.globalProperties.$router
14+
if (!router) {
15+
throw new Error(
16+
'[vue-router-plugin-system] Please install vue-router first.',
17+
)
18+
}
19+
20+
prepareInstall({ app, router })
21+
setupPlugin({ router, plugin })
22+
},
23+
})
24+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import type { App } from 'vue'
2+
import type { RouterPlugin } from '../plugin'
3+
import { asVuePlugin } from './as-vue-plugin'
4+
5+
/**
6+
* @deprecated
7+
* Please use {@link RouterPluginInstall} instead.
8+
*/
9+
export interface VueRouterPlugin extends RouterPlugin {
10+
/**
11+
* Install the plugin.
12+
* @param app vue app
13+
*/
14+
install: (app: App) => void
15+
}
16+
17+
/**
18+
* @deprecated
19+
* Please use {@link withInstall} instead.
20+
*/
21+
export const createVueRouterPlugin: (plugin: RouterPlugin) => VueRouterPlugin =
22+
asVuePlugin

0 commit comments

Comments
 (0)