@peng_kai/kit 0.2.0-beta.1 → 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) {
@@ -45,3 +51,7 @@ export const adminPlugin = {
45
51
  },
46
52
  }),
47
53
  };
54
+
55
+ export function injectTTAdmin() {
56
+ return inject<IOtions>(PROVIDE_KEY);
57
+ }
@@ -2,7 +2,7 @@
2
2
  import isNil from 'lodash-es/isNil';
3
3
  import isFinite from 'lodash-es/isFinite';
4
4
  import bignumber from 'bignumber.js';
5
- import { dayjs } from '../../../../utils/date';
5
+ import dayjs from '../../../../libs/dayjs';
6
6
 
7
7
  export const paramTypes = { numberRange, datetimeRange, options };
8
8
 
@@ -1,7 +1,7 @@
1
1
  <script setup lang="ts">
2
2
  import { Tooltip as ATooltip } from 'ant-design-vue';
3
3
  import { computed } from 'vue';
4
- import { dayjs } from '../../../../utils/date';
4
+ import dayjs from '../../../../libs/dayjs';
5
5
 
6
6
  defineOptions({
7
7
  inheritAttrs: false,
@@ -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/libs/dayjs.ts CHANGED
@@ -1,5 +1,12 @@
1
1
  import dayjs from 'dayjs';
2
2
 
3
+ import relativeTime from 'dayjs/plugin/relativeTime';
4
+ import 'dayjs/locale/zh';
5
+ import 'dayjs/locale/en';
6
+
3
7
  export { isDayjs, unix, locale, extend } from 'dayjs';
4
8
  export type { Dayjs, PluginFunc, UnitType, UnitTypeLong, UnitTypeLongPlural, UnitTypeShort, QUnitType, ConfigType, ConfigTypeMap, OpUnitType, OptionType, ManipulateType } from 'dayjs';
5
9
  export default dayjs;
10
+
11
+ dayjs.locale('zh');
12
+ dayjs.extend(relativeTime);
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.1",
4
+ "version": "0.2.0-beta.11",
5
5
  "description": "",
6
6
  "author": "",
7
7
  "license": "ISC",
package/utils/date.ts CHANGED
@@ -1,12 +1,4 @@
1
- import dayjs from 'dayjs';
2
- import relativeTime from 'dayjs/plugin/relativeTime';
3
- import 'dayjs/locale/zh';
4
- import 'dayjs/locale/en';
5
-
6
- export { default as dayjs } from 'dayjs';
7
-
8
- dayjs.locale('zh');
9
- dayjs.extend(relativeTime);
1
+ import dayjs from '../libs/dayjs';
10
2
 
11
3
  /**
12
4
  * 返回给定日期的一天的开始时间。