@peng_kai/kit 0.2.0-beta.10 → 0.2.0-beta.11

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.
@@ -1,3 +1,4 @@
1
+ import { inject } from 'vue';
1
2
  import type { App } from 'vue';
2
3
  import type { Router } from 'vue-router';
3
4
  import type { TUseMenuStore } from './stores/createUseMenuStore';
@@ -5,7 +6,7 @@ import type { TUsePageStore } from './stores/createUsePageStore';
5
6
  import type { TUsePageTabStore } from './stores/createUsePageTabStore';
6
7
  import type { TRole, TUsePermissionStore } from './stores/createUsePermissionStore';
7
8
 
8
- interface IOtions {
9
+ export interface IOtions {
9
10
  meta: {
10
11
  appId: string
11
12
  appName: string
@@ -20,6 +21,7 @@ interface IOtions {
20
21
  }
21
22
  }
22
23
 
24
+ const PROVIDE_KEY = 'TT_ADMIN';
23
25
  let _meta: IOtions['meta'];
24
26
  let _deps: IOtions['deps'];
25
27
 
@@ -27,6 +29,10 @@ export const adminPlugin = {
27
29
  install(_app: App, options: IOtions) {
28
30
  _meta = options.meta;
29
31
  _deps = options.deps;
32
+ _app.provide(PROVIDE_KEY, {
33
+ meta: this.meta,
34
+ deps: this.deps,
35
+ });
30
36
  },
31
37
  meta: new Proxy({} as IOtions['meta'], {
32
38
  get(_, p) {
@@ -35,7 +41,6 @@ export const adminPlugin = {
35
41
  }),
36
42
  deps: new Proxy({} as IOtions['deps'], {
37
43
  get(_, p) {
38
- console.log('🤡 / _deps:', _deps);
39
44
  const _p = String(p);
40
45
  const _dep = _deps?.[p];
41
46
 
@@ -46,3 +51,7 @@ export const adminPlugin = {
46
51
  },
47
52
  }),
48
53
  };
54
+
55
+ export function injectTTAdmin() {
56
+ return inject<IOtions>(PROVIDE_KEY);
57
+ }
@@ -3,7 +3,7 @@ import { computed } from 'vue';
3
3
  import type { VNode } from 'vue';
4
4
  import { Breadcrumb as ABreadcrumb } from 'ant-design-vue';
5
5
  import type { Route as AntdBreadcrumbRoute } from 'ant-design-vue/es/breadcrumb/Breadcrumb';
6
- import { adminPlugin } from '../../adminPlugin';
6
+ import { injectTTAdmin } from '../../adminPlugin';
7
7
  import type { IBreadcrumb } from '../../stores/createUsePageStore';
8
8
 
9
9
  interface IBreadcrumbRoute extends AntdBreadcrumbRoute {
@@ -23,7 +23,7 @@ function _buildRoute(breadcrumb: IBreadcrumb): IBreadcrumbRoute {
23
23
  </script>
24
24
 
25
25
  <script setup lang="ts">
26
- const pageStore = adminPlugin.deps.usePageStore();
26
+ const pageStore = injectTTAdmin()!.deps.usePageStore();
27
27
  const routes = computed(() => {
28
28
  let breadcrumbs: IBreadcrumbRoute[] = [];
29
29
 
@@ -1,7 +1,7 @@
1
1
  <script setup lang="ts">
2
- import { adminPlugin } from '../../adminPlugin';
2
+ import { injectTTAdmin } from '../../adminPlugin';
3
3
 
4
- const pageStore = adminPlugin.deps.usePageStore();
4
+ const pageStore = injectTTAdmin()!.deps.usePageStore();
5
5
  </script>
6
6
 
7
7
  <template>
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@peng_kai/kit",
3
3
  "type": "module",
4
- "version": "0.2.0-beta.10",
4
+ "version": "0.2.0-beta.11",
5
5
  "description": "",
6
6
  "author": "",
7
7
  "license": "ISC",